:root {
  --cyan: #2fd8ff;
  --cyan-dim: #1a8ab3;
  --bg: #02040a;
  --panel: rgba(6, 14, 28, 0.82);
  --glow: 0 0 12px rgba(47, 216, 255, 0.55), 0 0 40px rgba(47, 216, 255, 0.18);
  --font-display: 'Orbitron', 'Segoe UI', sans-serif;
  --font-body: 'Rajdhani', 'Segoe UI', sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  width: 100%; height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: #cfeeff;
  font-family: var(--font-body);
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
  overscroll-behavior: none;
}

#game {
  position: fixed; inset: 0;
  width: 100%; height: 100%;
  display: block;
  touch-action: none;
}

.hidden { display: none !important; }

/* ---------- HUD ---------- */
#hud {
  position: fixed; inset: 0;
  pointer-events: none;
  padding: calc(14px + env(safe-area-inset-top)) calc(16px + env(safe-area-inset-right))
           calc(14px + env(safe-area-inset-bottom)) calc(16px + env(safe-area-inset-left));
  display: flex; justify-content: space-between; align-items: flex-start;
  z-index: 10;
}

#hud-left { display: flex; flex-direction: column; gap: 6px; }

#score-label {
  font-family: var(--font-display);
  font-size: 11px; letter-spacing: 4px; color: var(--cyan-dim);
}
#score {
  font-family: var(--font-display);
  font-size: 42px; font-weight: 900; line-height: 1;
  color: #eaffff;
  text-shadow: var(--glow);
  transition: transform 0.1s;
}
#score.pop { transform: scale(1.18); }

#combo-wrap { display: flex; align-items: center; gap: 8px; margin-top: 2px; }
#combo-bar {
  width: 120px; height: 6px; border-radius: 3px;
  background: rgba(47, 216, 255, 0.15);
  overflow: hidden;
}
#combo-fill {
  height: 100%; width: 100%;
  background: linear-gradient(90deg, var(--cyan), #aef);
  box-shadow: 0 0 8px var(--cyan);
  transform-origin: left;
}
#combo-x {
  font-family: var(--font-display);
  font-weight: 700; font-size: 18px; color: #ffe066;
  text-shadow: 0 0 10px rgba(255, 224, 102, 0.8);
}

#powerups { display: flex; gap: 8px; margin-top: 6px; }
.pu-chip {
  display: flex; align-items: center; gap: 6px;
  font-family: var(--font-display); font-size: 11px; letter-spacing: 1px;
  padding: 4px 10px; border-radius: 12px;
  background: var(--panel);
  border: 1px solid var(--pu-color, var(--cyan));
  color: var(--pu-color, var(--cyan));
  box-shadow: 0 0 10px color-mix(in srgb, var(--pu-color, var(--cyan)) 40%, transparent);
}
.pu-ring {
  width: 14px; height: 14px; border-radius: 50%;
  background: conic-gradient(var(--pu-color, var(--cyan)) calc(var(--p) * 100%), rgba(255,255,255,0.12) 0);
}

#hud-right { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
#best-label, #mode-label {
  font-family: var(--font-display);
  font-size: 12px; letter-spacing: 3px; color: var(--cyan-dim);
}
#best { color: #eaffff; }
#lives { display: flex; gap: 5px; }
#lives .life {
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--cyan);
  box-shadow: 0 0 8px var(--cyan);
}
#lives .life.lost {
  background: rgba(47, 216, 255, 0.12);
  box-shadow: none;
}
.hud-btns { display: flex; gap: 8px; pointer-events: auto; }
.hud-btns button {
  width: 38px; height: 38px; border-radius: 10px;
  background: var(--panel); color: var(--cyan);
  border: 1px solid rgba(47, 216, 255, 0.35);
  font-size: 15px; cursor: pointer;
}
.hud-btns button:active { background: rgba(47, 216, 255, 0.2); }

/* Touch chevrons (volume mode on touch devices) */
#touch-chevrons {
  position: fixed;
  right: calc(18px + env(safe-area-inset-right));
  bottom: calc(24px + env(safe-area-inset-bottom));
  display: grid;
  grid-template-areas: ". u ." "l . r" ". d .";
  gap: 6px;
  pointer-events: auto;
}
#touch-chevrons button {
  width: 52px; height: 52px; border-radius: 14px;
  background: var(--panel); color: var(--cyan);
  border: 1px solid rgba(47, 216, 255, 0.4);
  font-size: 20px;
}
#touch-chevrons button[data-i="up"] { grid-area: u; }
#touch-chevrons button[data-i="down"] { grid-area: d; }
#touch-chevrons button[data-i="left"] { grid-area: l; }
#touch-chevrons button[data-i="right"] { grid-area: r; }
#touch-chevrons button:active { background: rgba(47, 216, 255, 0.25); }

/* Floating score text */
#floaters { position: fixed; inset: 0; pointer-events: none; z-index: 11; }
.floater {
  position: absolute;
  font-family: var(--font-display); font-weight: 700;
  text-shadow: 0 0 10px currentColor;
  animation: floatUp 0.9s ease-out forwards;
}
@keyframes floatUp {
  0% { opacity: 0; transform: translate(-50%, 0) scale(0.7); }
  15% { opacity: 1; transform: translate(-50%, -10px) scale(1.1); }
  100% { opacity: 0; transform: translate(-50%, -60px) scale(1); }
}

/* ---------- Screens ---------- */
.screen {
  position: fixed; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 18px;
  background: radial-gradient(ellipse at center, rgba(2, 4, 10, 0.25) 0%, rgba(2, 4, 10, 0.78) 100%);
  backdrop-filter: blur(2px);
  z-index: 20;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

.title {
  font-family: var(--font-display);
  font-size: clamp(44px, 9vw, 92px);
  font-weight: 900;
  letter-spacing: 0.12em;
  color: #eaffff;
  text-shadow: var(--glow);
  animation: titlePulse 3.2s ease-in-out infinite;
}
@keyframes titlePulse {
  0%, 100% { text-shadow: 0 0 12px rgba(47,216,255,0.55), 0 0 40px rgba(47,216,255,0.18); }
  50% { text-shadow: 0 0 18px rgba(47,216,255,0.85), 0 0 70px rgba(47,216,255,0.35); }
}
.subtitle { letter-spacing: 6px; font-size: 13px; color: var(--cyan-dim); text-transform: uppercase; }

h2 {
  font-family: var(--font-display);
  font-size: clamp(26px, 5vw, 44px); font-weight: 700;
  letter-spacing: 0.15em; color: #eaffff;
  text-shadow: var(--glow);
}

#mode-cards { display: flex; gap: 14px; flex-wrap: wrap; justify-content: center; }
.mode-card {
  width: 168px; padding: 18px 12px;
  background: var(--panel);
  border: 1px solid rgba(47, 216, 255, 0.25);
  border-radius: 14px;
  color: #cfeeff; cursor: pointer;
  transition: transform 0.15s, border-color 0.15s, box-shadow 0.15s;
  font-family: var(--font-body);
}
.mode-card:hover { transform: translateY(-3px); }
.mode-card.selected {
  border-color: var(--cyan);
  box-shadow: var(--glow);
}
.mode-icon { font-size: 30px; color: var(--cyan); margin-bottom: 8px; }
.mode-name { font-family: var(--font-display); font-weight: 700; letter-spacing: 3px; font-size: 15px; }
.mode-desc { font-size: 13px; color: #7fb6cc; margin-top: 6px; }

#play-row { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; }

.big-btn {
  font-family: var(--font-display);
  font-size: 20px; font-weight: 700; letter-spacing: 6px;
  padding: 14px 58px;
  background: linear-gradient(180deg, rgba(47,216,255,0.22), rgba(47,216,255,0.08));
  color: #eaffff;
  border: 1px solid var(--cyan);
  border-radius: 14px;
  cursor: pointer;
  box-shadow: var(--glow);
  transition: transform 0.12s, box-shadow 0.12s;
}
.big-btn:hover { transform: scale(1.05); box-shadow: 0 0 20px rgba(47,216,255,0.8), 0 0 60px rgba(47,216,255,0.3); }

.small-btn, #quality-btns button, #speed-btns button, #btn-sound, #btn-fpv, #btn-guide, .lb-tab {
  font-family: var(--font-display);
  font-size: 12px; letter-spacing: 2px;
  padding: 9px 18px;
  background: var(--panel);
  color: var(--cyan);
  border: 1px solid rgba(47, 216, 255, 0.35);
  border-radius: 10px;
  cursor: pointer;
}
.small-btn:hover { border-color: var(--cyan); }
.menu-row { display: flex; gap: 12px; }
#menu-hint { font-size: 13px; color: #5f8ea3; letter-spacing: 1px; margin-top: 4px; }

/* Game over */
#go-score {
  font-family: var(--font-display); font-size: clamp(40px, 8vw, 72px);
  font-weight: 900; color: #eaffff; text-shadow: var(--glow); line-height: 1;
}
#go-stats { font-size: 15px; color: #7fb6cc; letter-spacing: 1px; text-align: center; }
#go-newbest {
  font-family: var(--font-display); font-size: 15px; letter-spacing: 4px;
  color: #ffe066; text-shadow: 0 0 12px rgba(255, 224, 102, 0.9);
  animation: titlePulse 1.4s ease-in-out infinite;
}
#go-submit { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
#go-name {
  font-family: var(--font-display); font-size: 14px; letter-spacing: 2px;
  padding: 9px 14px; width: 190px;
  background: rgba(2, 8, 18, 0.9); color: #eaffff;
  border: 1px solid rgba(47, 216, 255, 0.35); border-radius: 10px;
  outline: none; text-transform: uppercase;
}
#go-name:focus { border-color: var(--cyan); }
#go-rank { font-family: var(--font-display); font-size: 16px; letter-spacing: 2px; color: #ffe066; }

/* Leaderboard */
#lb-tabs, #lb-view { display: flex; gap: 8px; }
#lb-view .lb-tab { font-size: 10px; padding: 6px 14px; }
.lb-tab.selected { border-color: var(--cyan); background: rgba(47, 216, 255, 0.15); }
#lb-status { font-size: 13px; color: #5f8ea3; letter-spacing: 1px; min-height: 18px; }
/* Fixed-height list so the header, tabs and buttons never shift with row count. */
#leaderboard { justify-content: flex-start; padding-top: max(8vh, calc(12px + env(safe-area-inset-top))); }
#lb-list {
  list-style: none; width: min(420px, 88vw);
  height: 52vh; overflow-y: auto;
  display: flex; flex-direction: column; gap: 4px;
}
#lb-list li {
  display: flex; justify-content: space-between; align-items: baseline;
  padding: 7px 14px;
  background: var(--panel);
  border: 1px solid rgba(47, 216, 255, 0.12);
  border-radius: 8px;
  font-size: 15px;
}
#lb-list li .lb-rank { color: var(--cyan-dim); width: 34px; font-family: var(--font-display); font-size: 12px; }
#lb-list li .lb-name { flex: 1; letter-spacing: 1px; font-weight: 600; }
#lb-list li .lb-score { font-family: var(--font-display); font-size: 14px; color: #eaffff; }
#lb-list li.me { border-color: #ffe066; }

/* Settings */
.setting-row {
  display: flex; align-items: center; gap: 18px;
  font-size: 16px; letter-spacing: 2px;
}
.setting-row > span { width: 90px; text-align: right; color: #7fb6cc; }
#quality-btns, #speed-btns { display: flex; gap: 6px; }
#quality-btns button.selected, #speed-btns button.selected {
  border-color: var(--cyan); background: rgba(47, 216, 255, 0.15);
}

/* About */
.about-list {
  display: flex; flex-direction: column; gap: 8px;
  width: min(470px, 90vw);
  max-height: 56vh; overflow-y: auto;
}
.about-section {
  font-family: var(--font-display);
  font-size: 11px; letter-spacing: 3px; color: var(--cyan-dim);
  margin-top: 8px; text-align: center;
}
.about-row {
  display: flex; align-items: center; gap: 14px;
  background: var(--panel);
  border: 1px solid rgba(47, 216, 255, 0.12);
  border-radius: 10px;
  padding: 9px 16px;
}
.about-icon {
  flex: none; border-radius: 50%;
  background: var(--c);
  box-shadow: 0 0 12px var(--c), 0 0 28px color-mix(in srgb, var(--c) 45%, transparent);
}
.about-icon.sm { width: 14px; height: 14px; }
.about-icon.md { width: 18px; height: 18px; }
.about-icon.lg { width: 22px; height: 22px; }
.about-icon.gem { border-radius: 4px; transform: rotate(45deg); }
.about-icon.ring { background: transparent; border: 5px solid var(--c); }
.about-name {
  font-family: var(--font-display);
  font-size: 12px; font-weight: 700; letter-spacing: 2px;
  width: 84px; flex: none; color: #eaffff;
}
.about-desc { font-size: 14px; color: #7fb6cc; }

/* Demo caption */
#demo-caption {
  position: fixed; left: 0; right: 0;
  bottom: calc(7vh + env(safe-area-inset-bottom));
  text-align: center; z-index: 15; pointer-events: none;
}
.demo-title {
  font-family: var(--font-display); font-size: clamp(26px, 5vw, 46px);
  font-weight: 900; letter-spacing: 0.2em; color: #eaffff;
  text-shadow: var(--glow);
}
.demo-sub {
  margin-top: 6px; font-size: 14px; letter-spacing: 4px;
  color: var(--cyan-dim); text-transform: uppercase;
  animation: blink 2.2s ease-in-out infinite;
}
@keyframes blink { 0%, 100% { opacity: 0.35; } 50% { opacity: 1; } }

#fps {
  position: fixed; bottom: 8px; left: 8px; z-index: 40;
  font: 12px monospace; color: #7fff7f; pointer-events: none;
  text-shadow: 0 0 4px #000;
}

@media (max-width: 700px) {
  #mode-cards { gap: 8px; }
  .mode-card { width: min(88vw, 300px); padding: 10px 12px; display: flex; align-items: center; gap: 12px; text-align: left; }
  .mode-icon { margin-bottom: 0; }
  .mode-desc { margin-top: 2px; }
  #score { font-size: 32px; }
  .screen { gap: 12px; }
}
