/* Perfect Dodge — Neon Minimal Arcade theme */

:root {
  --bg-0: #05060c;
  --bg-1: #0b0e1a;
  --neon-cyan: #4bf7ff;
  --neon-pink: #ff4bd8;
  --neon-violet: #8d5bff;
  --neon-amber: #ffcf4b;
  --text-hi: #eef2ff;
  --text-lo: #8b93b8;
  --danger: #ff5470;
  --safe-area-top: env(safe-area-inset-top, 0px);
  --safe-area-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  background: var(--bg-0);
  color: var(--text-hi);
  font-family: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  overflow: hidden;
  overscroll-behavior: none;
}

#app {
  position: fixed;
  inset: 0;
  background: radial-gradient(120% 120% at 50% 0%, var(--bg-1) 0%, var(--bg-0) 70%);
}

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

/* ---------------------------------------------------------------- top bar */

#top-controls {
  position: absolute;
  top: calc(12px + var(--safe-area-top));
  left: 50%;
  transform: translateX(-50%);
  z-index: 50;
  display: flex;
  gap: 8px;
}

.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(20, 24, 40, 0.65);
  backdrop-filter: blur(6px);
  color: var(--text-hi);
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.icon-btn:active { transform: scale(0.92); }
/* .icon-btn's own `display: flex` above has the same specificity as the
   browser's built-in `[hidden] { display: none }` rule, and an author
   style always wins that tie — so #btn-pause's `hidden` attribute was
   being silently ignored and it rendered on every screen, including the
   menu (where clicking it is a correct no-op, which looked like "the
   button doesn't work"). This re-asserts display:none with higher
   specificity so `hidden` actually hides it again. */
.icon-btn[hidden] { display: none; }

/* ---------------------------------------------------------------- screens */

.screen {
  position: absolute;
  inset: 0;
  z-index: 40;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: calc(24px + var(--safe-area-top)) 20px calc(24px + var(--safe-area-bottom));
  overflow-y: auto;
}

.screen[hidden] { display: none; }

.modal-screen {
  background: rgba(3, 4, 9, 0.72);
  backdrop-filter: blur(4px);
}

.modal-card {
  width: min(420px, 92vw);
  background: linear-gradient(180deg, rgba(20,24,44,0.95), rgba(10,12,22,0.95));
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 20px;
  padding: 28px 24px;
  box-shadow: 0 0 60px rgba(140, 90, 255, 0.15);
}

.modal-card-lg { width: min(480px, 94vw); }

.menu-inner {
  width: min(420px, 92vw);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

/* ---------------------------------------------------------------- title */

.game-title {
  font-size: clamp(38px, 11vw, 64px);
  line-height: 0.95;
  letter-spacing: 4px;
  margin: 0;
  font-weight: 800;
  color: var(--text-hi);
  text-shadow: 0 0 24px rgba(75, 247, 255, 0.55);
}
.game-title span {
  color: var(--neon-pink);
  text-shadow: 0 0 24px rgba(255, 75, 216, 0.65);
}

.tagline {
  margin: 0 0 8px;
  color: var(--text-lo);
  letter-spacing: 1px;
  font-size: 14px;
  text-transform: uppercase;
}

/* ---------------------------------------------------------------- buttons */

.btn {
  appearance: none;
  border: none;
  border-radius: 999px;
  padding: 14px 36px;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 1px;
  cursor: pointer;
  min-width: 200px;
  transition: transform 0.08s ease;
}
.btn:active { transform: scale(0.96); }

.btn-primary {
  background: linear-gradient(135deg, var(--neon-cyan), var(--neon-violet));
  color: #050614;
  box-shadow: 0 0 30px rgba(75, 247, 255, 0.35);
}

.btn-ghost {
  background: transparent;
  color: var(--text-hi);
  border: 1px solid rgba(255,255,255,0.18);
}

.menu-secondary {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
  margin-top: 4px;
}
.menu-secondary .btn { min-width: 150px; padding: 12px 20px; font-size: 13px; }

.menu-best {
  color: var(--text-lo);
  font-size: 14px;
  letter-spacing: 0.5px;
}
.menu-best span { color: var(--neon-amber); font-weight: 700; }

/* ---------------------------------------------------------------- nickname */

.menu-nickname {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 999px;
  padding: 6px 8px 6px 18px;
}
.menu-nickname-label {
  font-size: 11px;
  letter-spacing: 1px;
  color: var(--text-lo);
  text-transform: uppercase;
  white-space: nowrap;
}
.menu-nickname input {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-hi);
  font-size: 15px;
  padding: 8px 10px;
}
.field-error {
  color: var(--danger);
  font-size: 12px;
  margin: -4px 0 0;
}

/* ---------------------------------------------------------------- how to */

.howto-list {
  text-align: left;
  list-style: none;
  padding: 0;
  margin: 16px 0 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  color: var(--text-lo);
  font-size: 14px;
}
.howto-list strong { color: var(--neon-cyan); }

/* ---------------------------------------------------------------- countdown */

#screen-countdown { background: rgba(3,4,9,0.5); }
#countdown-number {
  font-size: 22vw;
  font-weight: 900;
  color: var(--neon-cyan);
  text-shadow: 0 0 60px rgba(75,247,255,0.7);
  animation: pd-pop 0.5s ease;
}
@keyframes pd-pop {
  0% { transform: scale(0.4); opacity: 0; }
  60% { transform: scale(1.15); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}

/* ---------------------------------------------------------------- HUD */

#hud {
  position: absolute;
  top: 0; left: 0; right: 0;
  z-index: 45;
  padding: calc(14px + var(--safe-area-top)) 16px 0;
  pointer-events: none;
}
#hud[hidden] { display: none; }

.hud-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}
.hud-label {
  font-size: 10px;
  letter-spacing: 2px;
  color: var(--text-lo);
}
.hud-score #hud-score-value,
#hud-score-value {
  font-size: 28px;
  font-weight: 800;
  color: var(--text-hi);
  text-shadow: 0 0 16px rgba(75,247,255,0.4);
}
.hud-best {
  text-align: right;
  /* #top-controls (sound+pause) is now anchored top-center, not top-right,
     so BEST sits flush in the top-right corner with nothing reserved. */
}
#hud-best-value {
  font-size: 16px;
  font-weight: 700;
  color: var(--neon-amber);
}

.hud-combo {
  position: absolute;
  top: 70px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 1px;
  color: var(--neon-pink);
  text-shadow: 0 0 14px rgba(255,75,216,0.7);
}
.hud-milestone {
  position: absolute;
  top: 100px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 15px;
  font-weight: 700;
  color: var(--neon-amber);
  text-shadow: 0 0 16px rgba(255,207,75,0.7);
  animation: pd-milestone 1.6s ease forwards;
}
@keyframes pd-milestone {
  0% { opacity: 0; transform: translate(-50%, 6px); }
  15% { opacity: 1; transform: translate(-50%, 0); }
  80% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -6px); }
}

/* ---------------------------------------------------------------- game over */

.gameover-title {
  margin: 0;
  font-size: 28px;
  letter-spacing: 3px;
  color: var(--danger);
  text-shadow: 0 0 20px rgba(255,84,112,0.5);
}
.gameover-score {
  font-size: 56px;
  font-weight: 900;
  color: var(--text-hi);
  text-shadow: 0 0 30px rgba(75,247,255,0.5);
}
.gameover-newbest {
  margin: -8px 0 0;
  color: var(--neon-amber);
  font-weight: 800;
  letter-spacing: 2px;
  text-shadow: 0 0 16px rgba(255,207,75,0.7);
}
.gameover-stats {
  margin: 0 0 6px;
  color: var(--text-lo);
  font-size: 13px;
}
.save-status {
  font-size: 12px;
  color: var(--text-lo);
  margin: -6px 0 0;
}
.save-status.is-error { color: var(--danger); }
.save-status.is-ok { color: var(--neon-cyan); }

/* ---------------------------------------------------------------- leaderboard */

.leaderboard-tabs {
  display: flex;
  gap: 8px;
  margin: 12px 0;
}
.lb-tab {
  flex: 1;
  padding: 8px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.12);
  background: transparent;
  color: var(--text-lo);
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 1px;
  cursor: pointer;
}
.lb-tab.active {
  background: rgba(75,247,255,0.12);
  color: var(--neon-cyan);
  border-color: rgba(75,247,255,0.4);
}

.leaderboard-list {
  max-height: 50vh;
  overflow-y: auto;
  margin-bottom: 16px;
  text-align: left;
}
.leaderboard-empty {
  color: var(--text-lo);
  text-align: center;
  font-size: 13px;
}
.lb-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 6px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  font-size: 14px;
}
.lb-rank { width: 26px; color: var(--text-lo); font-weight: 700; }
.lb-rank.top1 { color: var(--neon-amber); }
.lb-rank.top2 { color: #d7dbe8; }
.lb-rank.top3 { color: #d3854b; }
.lb-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-score { font-weight: 800; color: var(--neon-cyan); }

.btn-close-modal { margin-top: 8px; }

/* ---------------------------------------------------------------- SEO content */

.seo-content {
  max-width: 560px;
  margin-top: 40px;
  color: var(--text-lo);
  font-size: 13px;
  line-height: 1.6;
  text-align: left;
}
.seo-content h2 { font-size: 15px; color: var(--text-hi); }

/* ---------------------------------------------------------------- responsive */

@media (min-width: 720px) {
  .game-title { letter-spacing: 8px; }
}

@media (max-height: 560px) {
  .menu-inner { gap: 8px; }
  .game-title { font-size: clamp(30px, 8vw, 48px); }
}
