:root {
  --bg: #0d0d12;
  --panel: rgba(10, 10, 18, 0.92);
  --panel-border: rgba(255, 255, 255, 0.12);
  --accent: #ffb347;
  --green: #4caf50;
  --red: #f44336;
  --blue: #42a5f5;
  --text: #f0f0f0;
  --text-dim: rgba(240, 240, 240, 0.55);
  --text-muted: rgba(240, 240, 240, 0.3);
  --radius: 6px;
  --shadow: 0 4px 24px rgba(0,0,0,0.7);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { width: 100%; height: 100%; overflow: hidden; background: #87ceeb; }
body { font-family: 'Inter', sans-serif; color: var(--text); user-select: none; }
.hidden { display: none !important; }

#gameCanvas { position: fixed; top: 0; left: 0; width: 100vw; height: 100vh; display: block; outline: none; cursor: crosshair; }

/* Loading */
#loading-screen { position: fixed; inset: 0; z-index: 1000; display: flex; align-items: center; justify-content: center; background: var(--bg); }
.loading-content { text-align: center; }
.loading-icon { font-size: 64px; animation: spin 1s linear infinite; display: block; }
.loading-title { font-family: 'Press Start 2P', monospace; font-size: 22px; color: var(--accent); margin: 16px 0 4px; }
.loading-sub { color: var(--text-dim); font-size: 13px; margin-bottom: 24px; }
.loading-bar { width: 280px; height: 6px; background: rgba(255,255,255,0.1); border-radius: 3px; margin: 0 auto 12px; overflow: hidden; }
.loading-fill { height: 100%; background: var(--accent); border-radius: 3px; transition: width 0.3s; width: 0%; }
.loading-tip { color: var(--text-muted); font-size: 11px; font-style: italic; }
@keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }

/* Login / Title */
#login-screen, #title-screen { position: fixed; inset: 0; z-index: 950; display: flex; align-items: center; justify-content: center; background: radial-gradient(ellipse at 50% 50%, rgba(40,30,15,0.8) 0%, rgba(13,13,18,0.95) 80%); backdrop-filter: blur(4px); }
.login-content, .title-content { background: var(--panel); border: 1px solid var(--panel-border); border-radius: 16px; padding: 32px; width: 380px; max-width: 90%; display: flex; flex-direction: column; gap: 12px; text-align: center; box-shadow: var(--shadow); }
.login-logo, .title-logo { font-size: 64px; filter: drop-shadow(0 0 24px rgba(255,179,71,0.4)); }
.login-title, .game-title { font-family: 'Press Start 2P', monospace; font-size: 22px; color: var(--accent); margin-bottom: 4px; }
.login-tagline, .game-subtitle { font-size: 13px; color: var(--text-dim); margin-bottom: 4px; }
.game-tagline { color: var(--text); font-size: 14px; margin-bottom: 16px; }
.login-tabs { display: flex; gap: 4px; }
.login-tab { flex: 1; padding: 8px; background: transparent; border: 1px solid var(--panel-border); color: var(--text-dim); border-radius: var(--radius); cursor: pointer; font-size: 13px; }
.login-tab.active { background: var(--accent); color: #0d0d12; border-color: var(--accent); font-weight: 700; }
#login-form, #register-form { display: flex; flex-direction: column; gap: 10px; }
input[type=text], input[type=password] { padding: 10px 12px; background: rgba(0,0,0,0.4); border: 1px solid var(--panel-border); color: var(--text); border-radius: var(--radius); font-size: 14px; font-family: inherit; }
input:focus { outline: none; border-color: var(--accent); }
.btn-auth, .btn-title { padding: 12px; background: var(--accent); color: #0d0d12; border: none; border-radius: var(--radius); font-weight: 700; cursor: pointer; transition: transform 0.15s; font-family: inherit; font-size: 14px; }
.btn-auth:hover, .btn-title:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(255,179,71,0.4); }
.btn-auth-skip, .btn-title.btn-secondary { padding: 10px; background: transparent; color: var(--text-dim); border: 1px solid var(--panel-border); border-radius: var(--radius); cursor: pointer; font-size: 13px; font-family: inherit; }
.btn-auth-skip:hover, .btn-title.btn-secondary:hover { color: var(--text); border-color: rgba(255,255,255,0.3); }
.auth-error { color: var(--red); font-size: 12px; min-height: 16px; }
.login-divider { color: var(--text-muted); font-size: 11px; }
.title-buttons { display: flex; flex-direction: column; gap: 10px; }
.title-hint { color: var(--text-muted); font-size: 11px; margin-top: 8px; }

/* HUD */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 100; }

#height-display {
  position: absolute; top: 12px; left: 50%; transform: translateX(-50%);
  background: var(--panel); border: 1px solid var(--accent);
  border-radius: 16px; padding: 12px 28px;
  text-align: center; backdrop-filter: blur(8px);
  box-shadow: 0 4px 24px rgba(0,0,0,0.6);
  pointer-events: auto;
}
.height-val { font-family: 'VT323', monospace; font-size: 56px; color: var(--accent); line-height: 1; letter-spacing: 2px; text-shadow: 0 0 12px rgba(255,179,71,0.5); }
.height-unit { font-size: 22px; color: var(--text-dim); margin-left: 4px; }
.height-best { font-size: 12px; color: var(--text-dim); margin-top: 4px; letter-spacing: 2px; text-transform: uppercase; }

#online-wrap {
  position: absolute; top: 12px; right: 12px;
  background: var(--panel); border: 1px solid var(--panel-border);
  border-radius: var(--radius); padding: 8px 12px;
  display: flex; gap: 10px; align-items: center;
  backdrop-filter: blur(8px); pointer-events: auto;
}
#online-indicator { color: var(--green); font-weight: 700; font-size: 12px; }
.btn-mini { background: rgba(255,255,255,0.1); border: 1px solid var(--panel-border); color: var(--text); padding: 2px 8px; border-radius: 3px; font-size: 10px; cursor: pointer; }
#players-panel { position: absolute; top: 60px; right: 12px; width: 220px; max-height: 360px; overflow-y: auto; background: var(--panel); border: 1px solid var(--panel-border); border-radius: var(--radius); padding: 10px; backdrop-filter: blur(8px); pointer-events: auto; transform: translateX(240px); transition: transform 0.3s; }
#players-panel.open { transform: translateX(0); }
.players-header { font-size: 11px; font-weight: 700; color: var(--accent); margin-bottom: 8px; }
.online-self, .online-other { font-size: 12px; padding: 5px 8px; border-radius: 3px; display: flex; justify-content: space-between; }
.online-self { background: rgba(127,255,175,0.1); color: #7fffaf; font-weight: 700; }
.online-other { color: var(--text-dim); }
.online-other:not(:last-child) { border-bottom: 1px solid rgba(255,255,255,0.04); }
.online-height { color: var(--accent); font-family: 'VT323', monospace; font-size: 14px; }

#profile-badge { position: absolute; top: 12px; left: 12px; background: var(--panel); border: 1px solid var(--panel-border); border-radius: var(--radius); padding: 6px 12px; font-size: 12px; backdrop-filter: blur(8px); pointer-events: auto; color: var(--blue); }

#fear-meter {
  position: absolute; bottom: 80px; left: 50%; transform: translateX(-50%);
  width: 240px; pointer-events: none;
}
.fear-label { text-align: center; font-size: 11px; color: #ff6b6b; margin-bottom: 4px; letter-spacing: 2px; text-transform: uppercase; animation: shake 0.4s ease-in-out infinite; }
@keyframes shake { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-2px); } 75% { transform: translateX(2px); } }
.fear-bar { width: 100%; height: 8px; background: rgba(0,0,0,0.6); border: 1px solid rgba(255,107,107,0.6); border-radius: 4px; overflow: hidden; }
.fear-fill { height: 100%; background: linear-gradient(90deg, #ffd700, #ff6b6b, #aa0000); border-radius: 4px; transition: width 0.3s; }

#hud-bottom-right { position: absolute; bottom: 16px; right: 16px; display: flex; gap: 6px; pointer-events: auto; }
.btn-hud-mini { background: var(--panel); border: 1px solid var(--panel-border); border-radius: var(--radius); padding: 8px 12px; font-size: 18px; cursor: pointer; color: var(--text); backdrop-filter: blur(8px); transition: all 0.15s; }
.btn-hud-mini:hover { background: rgba(255,255,255,0.1); border-color: var(--accent); transform: translateY(-2px); }

#fall-warning {
  position: absolute; top: 30%; left: 50%; transform: translate(-50%, -50%);
  font-family: 'Press Start 2P', monospace; font-size: 32px;
  color: #ff3333; text-shadow: 0 0 30px rgba(255,0,0,0.8), 0 4px 8px rgba(0,0,0,0.8);
  letter-spacing: 4px;
  animation: warning-flash 0.4s ease-in-out infinite;
  pointer-events: none;
}
@keyframes warning-flash { 0%, 100% { opacity: 1; transform: translate(-50%, -50%) scale(1); } 50% { opacity: 0.6; transform: translate(-50%, -50%) scale(1.08); } }

#crosshair { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); color: rgba(255,255,255,0.5); font-size: 18px; pointer-events: none; }

#wind-indicator {
  position: absolute; top: 90px; right: 12px;
  background: rgba(100, 150, 200, 0.4); border: 1px solid rgba(180, 220, 255, 0.5);
  padding: 4px 12px; border-radius: 12px; font-size: 11px; backdrop-filter: blur(4px);
  animation: wind-sway 2s ease-in-out infinite;
}
@keyframes wind-sway { 0%, 100% { transform: translateX(0); } 50% { transform: translateX(4px); } }

/* Notifications */
#notifications { position: fixed; top: 130px; right: 16px; z-index: 500; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.notif { background: var(--panel); border: 1px solid var(--panel-border); border-radius: var(--radius); padding: 10px 16px; font-size: 13px; max-width: 280px; backdrop-filter: blur(8px); animation: notif-in 0.3s ease, notif-out 0.3s ease forwards; animation-delay: 0s, 2.7s; }
.notif.success { border-color: var(--green); }
.notif.error { border-color: var(--red); }
.notif.money { border-color: var(--accent); color: var(--accent); font-weight: 700; }
.notif.info { border-color: var(--blue); }
@keyframes notif-in { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: translateX(0); } }
@keyframes notif-out { from { opacity: 1; } to { opacity: 0; transform: translateX(20px); } }

/* Click-to-play hint */
#click-to-play { position: fixed; bottom: 140px; left: 50%; transform: translateX(-50%); z-index: 90; cursor: pointer; pointer-events: auto; }
.ctp-box { padding: 10px 20px; background: var(--panel); border: 1px solid var(--accent); border-radius: 24px; display: flex; gap: 10px; align-items: center; box-shadow: 0 0 0 1px rgba(255,179,71,0.3), 0 4px 16px rgba(0,0,0,0.5); animation: ctp-pulse 2s ease-in-out infinite; }
.ctp-icon { font-size: 22px; animation: bounce 1s ease-in-out infinite; }
@keyframes bounce { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-3px); } }
@keyframes ctp-pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(255,179,71,0.3); } 50% { box-shadow: 0 0 0 6px rgba(255,179,71,0); } }
.ctp-text { font-size: 13px; font-weight: 700; color: var(--accent); }
.ctp-sub { font-size: 10px; color: var(--text-dim); }

/* Help / Leaderboard / Music windows */
#help-overlay, #leaderboard-overlay, #music-panel, #pause-menu, #fall-screen { position: fixed; inset: 0; z-index: 300; background: rgba(0,0,0,0.75); backdrop-filter: blur(4px); display: flex; align-items: center; justify-content: center; }
.help-window, .leaderboard-window, .music-window, .pause-box, .fall-content { background: var(--panel); border: 1px solid var(--panel-border); border-radius: 12px; padding: 28px; max-width: 540px; width: 90%; max-height: 85vh; overflow-y: auto; }

.help-header, .lb-header, .music-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.help-header h2, .lb-header h2, .music-header h2 { font-size: 20px; color: var(--accent); }
.btn-close-x { background: transparent; border: 1px solid var(--panel-border); color: var(--text-dim); width: 28px; height: 28px; border-radius: 4px; cursor: pointer; font-size: 14px; }
.help-controls { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-bottom: 16px; }
.help-row { display: flex; gap: 10px; padding: 6px 10px; background: rgba(255,255,255,0.04); border-radius: var(--radius); font-size: 12px; align-items: center; }
.help-row kbd { background: var(--accent); color: #0d0d12; padding: 2px 8px; border-radius: 3px; font-weight: 700; font-family: monospace; font-size: 11px; min-width: 60px; text-align: center; }
.help-tips ul { list-style: none; }
.help-tips li { padding: 4px 0; font-size: 12px; color: var(--text-dim); line-height: 1.6; }
.help-tips h3 { font-size: 14px; color: var(--accent); margin-bottom: 8px; margin-top: 8px; }

/* Leaderboard */
.lb-row { display: flex; align-items: center; gap: 12px; padding: 8px 12px; background: rgba(255,255,255,0.04); border-radius: var(--radius); margin-bottom: 4px; }
.lb-rank { font-family: 'VT323', monospace; font-size: 20px; color: var(--accent); width: 32px; text-align: center; }
.lb-rank.gold { color: gold; }
.lb-rank.silver { color: silver; }
.lb-rank.bronze { color: #cd7f32; }
.lb-name { flex: 1; font-weight: 700; font-size: 14px; }
.lb-height { font-family: 'VT323', monospace; color: var(--accent); font-size: 18px; }
.lb-hint { font-size: 11px; color: var(--text-muted); text-align: center; margin-top: 12px; }

/* Music */
.music-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-bottom: 12px; }
.music-btn { padding: 12px; background: rgba(255,255,255,0.06); border: 1px solid var(--panel-border); border-radius: var(--radius); color: var(--text); cursor: pointer; text-align: center; transition: all 0.15s; }
.music-btn:hover { background: rgba(255,255,255,0.12); }
.music-btn.active { background: rgba(255,179,71,0.15); border-color: var(--accent); }
.music-btn .icon { font-size: 24px; }
.music-btn .name { font-size: 11px; margin-top: 4px; }
.btn-music-stop { width: 100%; padding: 8px; background: rgba(244,67,54,0.3); border: 1px solid var(--red); color: var(--red); border-radius: var(--radius); cursor: pointer; margin-bottom: 8px; }
.vol-wrap { display: flex; align-items: center; gap: 8px; font-size: 12px; }
.vol-wrap input { flex: 1; }

/* Fall screen */
.fall-content { text-align: center; }
.fall-icon { font-size: 80px; margin-bottom: 12px; animation: spin 3s linear infinite; }
.fall-title { font-family: 'Press Start 2P', monospace; font-size: 32px; color: var(--red); text-shadow: 0 0 24px rgba(244,67,54,0.6); letter-spacing: 4px; margin-bottom: 16px; }
.fall-stats { font-size: 18px; color: var(--text-dim); margin-bottom: 8px; }
.fall-h { color: var(--accent); font-family: 'VT323', monospace; font-size: 32px; font-weight: 700; }
.fall-best { font-size: 14px; color: var(--green); margin-bottom: 20px; font-weight: 700; }

/* Pause */
.pause-box { display: flex; flex-direction: column; gap: 8px; min-width: 280px; max-width: 340px; }
.pause-title { font-family: 'Press Start 2P', monospace; font-size: 18px; text-align: center; margin-bottom: 8px; }
.btn-pause-item { padding: 11px 18px; background: rgba(255,255,255,0.06); border: 1px solid var(--panel-border); color: var(--text); border-radius: var(--radius); font-size: 13px; cursor: pointer; }
.btn-pause-item:hover { background: rgba(255,255,255,0.12); }
.btn-pause-item.save-main { background: var(--accent); color: #0d0d12; font-weight: 700; }

::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 2px; }
