/*
 * Number Nova — mental math practice for sourcestrongai.com/games/number-nova/
 *
 * Design language: deep-space ground, warm nova accents (brand orange →
 * gold), cool cyan/magenta counterpoints, glassy cards, generous radii,
 * tabular numerals everywhere numbers live. Mobile-first; every control is
 * a ≥44px touch target; fluid type via clamp(); reduced-motion honored.
 */

:root {
  --bg0: #07080f;
  --bg1: #0c0f20;
  --ink: #f4f2ec;
  --dim: rgba(244, 242, 236, 0.62);
  --faint: rgba(244, 242, 236, 0.38);
  --card: rgba(255, 255, 255, 0.045);
  --card-hi: rgba(255, 255, 255, 0.08);
  --line: rgba(255, 255, 255, 0.09);
  --line-hi: rgba(255, 255, 255, 0.18);
  --orange: #ff5e00;
  --gold: #ffc432;
  --cyan: #5ad7ff;
  --magenta: #ff4d9d;
  --violet: #8b5cf6;
  --green: #34d399;
  --red: #ff4757;
  --radius: 16px;
  --font:
    -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  height: 100%;
}

body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg0);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* ---------- deep-space backdrop ---------- */

body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -2;
  background:
    radial-gradient(1100px 700px at 85% -10%, rgba(139, 92, 246, 0.16), transparent 60%),
    radial-gradient(900px 650px at -15% 30%, rgba(255, 94, 0, 0.13), transparent 60%),
    radial-gradient(1000px 800px at 60% 115%, rgba(90, 215, 255, 0.09), transparent 55%),
    linear-gradient(180deg, var(--bg0) 0%, var(--bg1) 55%, var(--bg0) 100%);
}

/* two star layers, drifting apart slowly */
body::after {
  content: '';
  position: fixed;
  inset: -50% 0;
  z-index: -1;
  pointer-events: none;
  background-image:
    radial-gradient(1.2px 1.2px at 22px 44px, rgba(255, 255, 255, 0.55) 50%, transparent 51%),
    radial-gradient(1px 1px at 180px 130px, rgba(255, 255, 255, 0.32) 50%, transparent 51%),
    radial-gradient(1.6px 1.6px at 300px 260px, rgba(255, 200, 140, 0.4) 50%, transparent 51%),
    radial-gradient(1px 1px at 90px 320px, rgba(160, 220, 255, 0.35) 50%, transparent 51%);
  background-size: 380px 380px;
  animation: drift 240s linear infinite alternate;
  opacity: 0.7;
}
@keyframes drift {
  from {
    transform: translate3d(0, 0, 0);
  }
  to {
    transform: translate3d(-80px, 40px, 0);
  }
}

/* ---------- shared chrome ---------- */

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--orange);
  color: #fff;
  padding: 10px 16px;
  border-radius: 0 0 10px 0;
  z-index: 50;
}
.skip-link:focus {
  left: 0;
}

.noscript-card {
  max-width: 420px;
  margin: 18vh auto 0;
  padding: 22px;
  background: var(--card);
  border: 1px solid var(--line-hi);
  border-radius: var(--radius);
  line-height: 1.55;
}
.noscript-card a {
  color: var(--gold);
}
.noscript-title {
  margin-top: 0;
  font-size: 1.15rem;
}

#fx-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 40;
}

.screen {
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: env(safe-area-inset-top) max(16px, env(safe-area-inset-right))
    env(safe-area-inset-bottom) max(16px, env(safe-area-inset-left));
}

.hidden {
  display: none !important;
}

.mini-header {
  position: sticky;
  top: 0;
  z-index: 10;
  align-self: stretch;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 14px 2px 10px;
  background: linear-gradient(180deg, rgba(7, 8, 15, 0.9), rgba(7, 8, 15, 0));
}
.brand-link {
  color: var(--ink);
  text-decoration: none;
  font-weight: 800;
  letter-spacing: 0.01em;
  padding: 12px 0;
  touch-action: manipulation;
}
.brand-link .accent {
  color: var(--orange);
}
.mini-header-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.more-games {
  color: var(--dim);
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 700;
  white-space: nowrap;
  padding: 14px 0; /* 44px-class tap box */
  touch-action: manipulation;
}
.more-games:hover {
  color: var(--gold);
}

.mini-footer {
  margin-top: auto;
  padding: 18px 0 14px;
  display: flex;
  gap: 10px;
  align-items: center;
  color: var(--faint);
  font-size: 0.85rem;
}
.mini-footer a {
  color: var(--dim);
  text-decoration: none;
  padding: 14px 0;
  touch-action: manipulation;
}
.mini-footer a:hover {
  color: var(--gold);
}

.screen-inner {
  width: 100%;
  max-width: 540px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

button {
  font-family: inherit;
}
button:focus-visible,
a:focus-visible {
  outline: 2px solid var(--orange);
  outline-offset: 2px;
  border-radius: 8px;
}

/* ---------- hero ---------- */

.hero {
  position: relative;
  text-align: center;
  padding: 26px 0 8px;
}
.hero-burst {
  position: absolute;
  inset: -40px -20px;
  background: radial-gradient(closest-side at 50% 42%, rgba(255, 94, 0, 0.22), transparent 72%);
  filter: blur(6px);
  pointer-events: none;
}
.game-title {
  margin: 0;
  font-size: clamp(2.6rem, 11vw, 4rem);
  line-height: 0.95;
  font-weight: 900;
  letter-spacing: 0.02em;
}
.title-gradient {
  background: linear-gradient(92deg, var(--orange) 10%, var(--gold) 55%, #ffe9a8 90%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: 0 0 42px rgba(255, 148, 42, 0.35);
}
.hook-line {
  margin: 10px 0 0;
  color: var(--dim);
  font-size: clamp(0.92rem, 3.4vw, 1.02rem);
  font-weight: 600;
}

/* ---------- player card ---------- */

.player-card {
  width: 100%;
  margin: 18px 0 6px;
  padding: 14px 16px;
  background: linear-gradient(135deg, rgba(255, 94, 0, 0.1), rgba(139, 92, 246, 0.1)), var(--card);
  border: 1px solid var(--line-hi);
  border-radius: var(--radius);
}
.player-row {
  display: flex;
  align-items: center;
  gap: 14px;
}
.level-badge {
  flex: 0 0 auto;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-weight: 900;
  font-size: 1.45rem;
  color: #fff;
  background:
    radial-gradient(circle at 30% 28%, rgba(255, 255, 255, 0.5), transparent 36%),
    conic-gradient(
      from 210deg,
      var(--orange),
      var(--gold),
      var(--magenta),
      var(--violet),
      var(--orange)
    );
  box-shadow: 0 6px 22px rgba(255, 94, 0, 0.35);
}
.player-meta {
  flex: 1;
  min-width: 0;
}
.player-title-line {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
}
#level-title {
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-size: 0.82rem;
  color: var(--gold);
}
.daily-streak {
  font-size: 0.78rem;
  color: var(--dim);
  white-space: nowrap;
}
.daily-streak b {
  color: var(--gold);
}
.xp-bar {
  position: relative;
  height: 9px;
  margin: 8px 0 5px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 99px;
  overflow: hidden;
}
.xp-fill {
  height: 100%;
  width: 0%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--orange), var(--gold));
  transition: width 0.7s cubic-bezier(0.22, 1, 0.36, 1);
}
.xp-fill::after {
  /* travelling shine so progress reads alive */
  content: '';
  position: absolute;
  inset: 0;
  width: 40%;
  background: linear-gradient(100deg, transparent, rgba(255, 255, 255, 0.45), transparent);
  animation: shine 2.8s ease-in-out infinite;
}
@keyframes shine {
  0% {
    transform: translateX(-110%);
  }
  60%,
  100% {
    transform: translateX(280%);
  }
}
.xp-text {
  font-size: 0.74rem;
  color: var(--dim);
  font-variant-numeric: tabular-nums;
}

/* ---------- config blocks ---------- */

.cfg-block {
  width: 100%;
  margin: 14px 0 0;
  padding: 12px 14px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
}
.cfg-title {
  padding: 0 6px;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--dim);
}
.cfg-hint {
  margin: 9px 2px 0;
  font-size: 0.8rem;
  color: var(--dim);
  min-height: 1em;
}
.best-line {
  color: var(--gold);
  font-variant-numeric: tabular-nums;
}

.mode-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 9px;
  margin-top: 8px;
}
@media (max-width: 380px) {
  .mode-grid {
    grid-template-columns: 1fr;
  }
}
.mode-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 13px 8px 11px;
  background: rgba(255, 255, 255, 0.03);
  border: 1.5px solid var(--line);
  border-radius: 14px;
  color: var(--ink);
  cursor: pointer;
  transition:
    border-color 0.15s ease-out,
    background 0.15s ease-out,
    transform 0.1s ease-out,
    box-shadow 0.15s ease-out;
  touch-action: manipulation;
}
.mode-card:active {
  transform: scale(0.97);
}
.mode-icon {
  font-size: 1.3rem;
}
.mode-name {
  font-weight: 800;
  font-size: 0.95rem;
}
.mode-sub {
  font-size: 0.68rem;
  color: var(--dim);
  text-align: center;
  line-height: 1.25;
}
.mode-card[aria-checked='true'] {
  border-color: rgba(255, 148, 42, 0.75);
  background: linear-gradient(160deg, rgba(255, 94, 0, 0.16), rgba(255, 196, 50, 0.07));
  box-shadow: 0 4px 18px rgba(255, 94, 0, 0.22);
}

.seg {
  display: flex;
  gap: 4px;
  margin-top: 8px;
  padding: 4px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--line);
  border-radius: 12px;
}
.seg button {
  flex: 1 1 0;
  min-height: 44px;
  border: none;
  border-radius: 9px;
  background: transparent;
  color: var(--ink);
  opacity: 0.6;
  font-size: 0.86rem;
  font-weight: 800;
  cursor: pointer;
  transition:
    background 0.15s ease-out,
    opacity 0.15s ease-out,
    transform 0.1s ease-out;
  touch-action: manipulation;
}
.seg button:active {
  transform: scale(0.96);
}
.seg button[aria-checked='true'] {
  background: linear-gradient(135deg, var(--orange), #ff8a00);
  color: #3a2200; /* ink on orange: AA where white text would fail */
  opacity: 1;
  box-shadow: 0 3px 14px rgba(255, 94, 0, 0.4);
}
.seg-4 button[data-diff='insane'][aria-checked='true'] {
  /* solid mid-violet: white text clears AA here, the two-stop gradient did not */
  background: #7c3aed;
  color: #fff;
  box-shadow: 0 3px 14px rgba(255, 77, 157, 0.4);
}

.ops-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}
.op-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  padding: 0 14px;
  border-radius: 99px;
  border: 1.5px solid var(--line-hi);
  background: rgba(255, 255, 255, 0.03);
  color: var(--dim);
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease-out;
  touch-action: manipulation;
}
.op-chip span {
  font-size: 1.05rem;
  font-weight: 900;
}
.op-chip[aria-pressed='true'] {
  border-color: rgba(90, 215, 255, 0.7);
  background: rgba(90, 215, 255, 0.12);
  color: var(--ink);
  box-shadow: 0 2px 12px rgba(90, 215, 255, 0.15);
}
.op-chip:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.btn-primary {
  margin-top: 20px;
  min-height: 58px;
  padding: 0 64px;
  border: none;
  border-radius: 16px;
  font-size: 1.25rem;
  font-weight: 900;
  letter-spacing: 0.04em;
  color: #fff;
  background: linear-gradient(135deg, var(--orange) 0%, #ff8a00 100%);
  box-shadow:
    0 10px 30px rgba(255, 94, 0, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.25);
  cursor: pointer;
  transition:
    transform 0.12s ease-out,
    box-shadow 0.2s ease-out;
  touch-action: manipulation;
}
.btn-primary:hover {
  box-shadow:
    0 12px 38px rgba(255, 94, 0, 0.55),
    inset 0 1px 0 rgba(255, 255, 255, 0.25);
}
.btn-primary:active {
  transform: scale(0.97);
}

.btn-ghost {
  margin-top: 12px;
  min-height: 48px;
  padding: 0 28px;
  border: 1px solid var(--line-hi);
  border-radius: 13px;
  background: transparent;
  color: var(--dim);
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  touch-action: manipulation;
}
.btn-ghost:hover {
  color: var(--ink);
  border-color: var(--faint);
}

.chip-btn {
  min-height: 44px;
  min-width: 44px;
  padding: 0 13px;
  border: 1px solid var(--line-hi);
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--dim);
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  touch-action: manipulation;
}
.chip-btn:hover {
  color: var(--ink);
}

.more-link {
  margin-top: 18px;
  color: var(--dim);
  text-decoration: none;
  font-size: 0.9rem;
  padding: 14px 0;
  touch-action: manipulation;
}
.more-link:hover {
  color: var(--gold);
}

/* ================= GAME SCREEN ================= */

#screen-game {
  justify-content: flex-start;
}

.game-top {
  /* explicit width (not bare stretch): stretch clamped by max-width falls
     back to flex-start, which left-aligned the whole HUD on wide screens */
  width: min(100%, 540px);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: calc(env(safe-area-inset-top) + 12px) 0 6px;
}
.top-stats {
  display: flex;
  gap: 8px;
  align-items: center;
}
.hud-pill {
  min-width: 86px;
  text-align: center;
  padding: 8px 14px;
  border-radius: 99px;
  background: var(--card);
  border: 1px solid var(--line-hi);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  font-size: 1rem;
}
.hud-timer.hud-low {
  color: #ffb4b4;
  border-color: rgba(255, 71, 87, 0.65);
  animation: lowPulse 0.9s ease-in-out infinite;
}
@keyframes lowPulse {
  50% {
    background: rgba(255, 71, 87, 0.16);
  }
}

.stage {
  position: relative;
  width: 100%;
  max-width: 470px;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-bottom: 26px;
  /* center in the space below the HUD instead of hugging the top */
  margin-block: auto;
}
/* zen keeps its fixed finish bar clear of the answer controls */
#screen-game.has-zenbar .stage {
  padding-bottom: 96px;
}

.combo-zone {
  height: 34px;
  display: grid;
  place-items: center;
}
.combo-flame {
  font-size: 1.5rem;
  filter: drop-shadow(0 0 10px rgba(255, 148, 42, 0.8));
  animation: flicker 0.5s ease-in-out infinite alternate;
  scale: var(--flame-scale, 1);
}
@keyframes flicker {
  from {
    transform: rotate(-6deg) scale(1);
  }
  to {
    transform: rotate(6deg) scale(1.12);
  }
}

.score-line {
  display: flex;
  align-items: baseline;
  gap: 12px;
}
.hud-score {
  font-size: clamp(1.7rem, 7vw, 2.2rem);
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 0 24px rgba(255, 196, 50, 0.3);
}
.hud-mult {
  font-size: 0.95rem;
  font-weight: 900;
  color: var(--gold);
  font-variant-numeric: tabular-nums;
  animation: multPop 0.25s ease-out;
}
@keyframes multPop {
  from {
    transform: scale(1.4);
  }
  to {
    transform: scale(1);
  }
}

.ring-wrap {
  position: relative;
  margin: 14px 0 6px;
  width: min(78vw, 300px);
  aspect-ratio: 1;
  display: grid;
  place-items: center;
}
.ring-wrap svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}
.ring-bg {
  fill: none;
  stroke: rgba(255, 255, 255, 0.07);
  stroke-width: 6;
}
.ring-fg {
  fill: none;
  stroke: url(#none);
  stroke: var(--cyan);
  stroke-width: 6;
  stroke-linecap: round;
  stroke-dasharray: 326.73;
  stroke-dashoffset: 0;
  filter: drop-shadow(0 0 8px rgba(90, 215, 255, 0.55));
  transition: stroke 0.3s ease-out;
}
.ring-fg.ring-gold {
  stroke: var(--gold);
  filter: drop-shadow(0 0 8px rgba(255, 196, 50, 0.6));
}
.ring-fg.ring-red {
  stroke: var(--red);
  filter: drop-shadow(0 0 10px rgba(255, 71, 87, 0.7));
}
.ring-hidden svg {
  display: none;
}

.question {
  font-size: clamp(2.1rem, 11vw, 3.4rem);
  font-weight: 900;
  letter-spacing: 0.02em;
  font-variant-numeric: tabular-nums;
  text-align: center;
  padding: 0 8px;
  text-shadow: 0 0 34px rgba(244, 242, 236, 0.22);
}
.question.q-correct {
  animation: qCorrect 0.45s ease-out;
}
.question.q-wrong {
  animation: qWrong 0.45s ease-out;
}
@keyframes qCorrect {
  0% {
    transform: scale(1);
    text-shadow: 0 0 0 rgba(52, 211, 153, 0);
  }
  30% {
    transform: scale(1.07);
    text-shadow: 0 0 34px rgba(52, 211, 153, 0.85);
  }
  100% {
    transform: scale(1);
  }
}
@keyframes qWrong {
  0%,
  100% {
    transform: translateX(0);
  }
  20% {
    transform: translateX(-9px);
    color: #ffb4b4;
  }
  45% {
    transform: translateX(8px);
  }
  70% {
    transform: translateX(-5px);
  }
}

/* choice answers */
.choices {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 20px;
}
.choice {
  min-height: 84px;
  border-radius: 18px;
  border: 1.5px solid var(--line-hi);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.02));
  color: var(--ink);
  font-size: clamp(1.5rem, 6.5vw, 2rem);
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  transition:
    transform 0.1s ease-out,
    border-color 0.15s ease-out,
    background 0.15s ease-out;
  touch-action: manipulation;
}
.choice:hover {
  border-color: rgba(255, 255, 255, 0.34);
}
.choice:active {
  transform: scale(0.96);
}
.choice.ch-correct {
  background: linear-gradient(180deg, rgba(52, 211, 153, 0.32), rgba(52, 211, 153, 0.12));
  border-color: var(--green);
  animation: chCorrect 0.5s ease-out;
}
.choice.ch-wrong {
  background: linear-gradient(180deg, rgba(255, 71, 87, 0.3), rgba(255, 71, 87, 0.1));
  border-color: var(--red);
  animation: chWrong 0.4s ease-out;
}
.choice.ch-dim {
  opacity: 0.4;
}
@keyframes chCorrect {
  30% {
    transform: scale(1.05);
  }
}
@keyframes chWrong {
  20%,
  60% {
    transform: translateX(-6px);
  }
  40%,
  80% {
    transform: translateX(6px);
  }
}

/* typed answers */
.typers {
  width: 100%;
  margin-top: 18px;
}
.answer-well {
  min-height: 62px;
  margin-bottom: 12px;
  display: grid;
  place-items: center;
  font-size: clamp(1.8rem, 8vw, 2.5rem);
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.06em;
  border-radius: 16px;
  border: 1.5px dashed var(--line-hi);
  background: rgba(255, 255, 255, 0.03);
}
.answer-well.well-flash-ok {
  border-color: var(--green);
  animation: qCorrect 0.45s ease-out;
}
.answer-well.well-flash-bad {
  border-color: var(--red);
  animation: chWrong 0.4s ease-out;
}
.keypad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.key {
  min-height: 60px;
  border-radius: 14px;
  border: 1px solid var(--line-hi);
  background: rgba(255, 255, 255, 0.05);
  color: var(--ink);
  font-size: 1.45rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  transition:
    transform 0.08s ease-out,
    background 0.12s ease-out;
  touch-action: manipulation;
}
.key:active {
  transform: scale(0.94);
  background: rgba(255, 255, 255, 0.11);
}
.key-wide {
  font-size: 1.2rem;
}
.key-ok {
  background: rgba(52, 211, 153, 0.16);
  border-color: rgba(52, 211, 153, 0.55);
  color: var(--green);
  font-size: 1.5rem;
}

/* floating reward texts */
#float-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 30;
}
.float-txt {
  position: absolute;
  font-weight: 900;
  font-size: 1.35rem;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 2px 14px rgba(0, 0, 0, 0.5);
  animation: floatUp 0.9s ease-out forwards;
  will-change: transform, opacity;
}
.float-good {
  color: var(--gold);
}
.float-bad {
  color: #ff9ba4;
}
.float-info {
  color: var(--cyan);
  font-size: 1.05rem;
}
@keyframes floatUp {
  0% {
    transform: translateY(0) scale(0.8);
    opacity: 0;
  }
  18% {
    opacity: 1;
    transform: translateY(-12px) scale(1.08);
  }
  100% {
    transform: translateY(-72px) scale(1);
    opacity: 0;
  }
}

/* countdown */
.countdown {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  z-index: 25;
  background: rgba(7, 8, 15, 0.55);
  backdrop-filter: blur(4px);
  pointer-events: none; /* purely visual — ✕ must stay tappable */
}
.countdown span {
  font-size: clamp(5rem, 30vw, 9rem);
  font-weight: 900;
  background: linear-gradient(180deg, #ffe9a8, var(--orange));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: cdPop 0.9s ease-out infinite;
}
.countdown.cd-go span {
  font-size: clamp(3rem, 17vw, 5.5rem);
  background: linear-gradient(180deg, #b9fff0, var(--cyan));
  -webkit-background-clip: text;
  background-clip: text;
}
@keyframes cdPop {
  0% {
    transform: scale(1.7);
    opacity: 0;
  }
  30% {
    transform: scale(1);
    opacity: 1;
  }
  100% {
    transform: scale(0.86);
    opacity: 0;
  }
}

/* overlays */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 35;
  display: grid;
  place-items: center;
  background: rgba(7, 8, 15, 0.72);
  backdrop-filter: blur(6px);
}
.overlay-card {
  width: min(88vw, 330px);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 28px 24px;
  background: linear-gradient(170deg, rgba(255, 255, 255, 0.07), rgba(255, 255, 255, 0.03));
  border: 1px solid var(--line-hi);
  border-radius: 22px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.5);
}
.overlay-title {
  margin: 0 0 18px;
  font-size: 1.6rem;
  font-weight: 900;
  letter-spacing: 0.04em;
}
.overlay-card .btn-primary {
  width: 100%;
  margin-top: 0;
  padding: 0;
}
.overlay-card .btn-ghost {
  width: 100%;
}

.zen-bar {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(env(safe-area-inset-bottom) + 16px);
  z-index: 20;
}
.zen-bar .btn-ghost {
  margin-top: 0;
  background: rgba(7, 8, 15, 0.7);
  backdrop-filter: blur(4px);
}

/* ================= SUMMARY ================= */

.summary-inner {
  padding-top: 8vh;
}
.new-best {
  font-weight: 900;
  letter-spacing: 0.18em;
  font-size: 0.95rem;
  padding: 8px 18px;
  border-radius: 99px;
  color: #3a2200;
  background: linear-gradient(90deg, var(--gold), #ffe9a8, var(--gold));
  background-size: 200% 100%;
  animation: bestShimmer 1.6s linear infinite;
  margin-bottom: 14px;
}
@keyframes bestShimmer {
  to {
    background-position: -200% 0;
  }
}
.medal {
  font-size: 3.4rem;
  line-height: 1;
  animation: medalPop 0.6s cubic-bezier(0.22, 1.4, 0.36, 1);
  filter: drop-shadow(0 6px 20px rgba(255, 196, 50, 0.4));
}
@keyframes medalPop {
  0% {
    transform: scale(0.2) rotate(-18deg);
    opacity: 0;
  }
  70% {
    transform: scale(1.15) rotate(4deg);
  }
  100% {
    transform: scale(1) rotate(0);
  }
}
.summary-title {
  margin: 10px 0 2px;
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: 0.24em;
  color: var(--dim);
}
.sum-score {
  font-size: clamp(3rem, 14vw, 4.4rem);
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  background: linear-gradient(180deg, #fff, #ffd9a8);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.sum-gains {
  margin: 2px 0 6px;
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--gold);
}
.sum-grid {
  width: 100%;
  max-width: 360px;
  margin: 18px 0 6px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px 20px;
  padding: 16px 18px;
  border-radius: var(--radius);
  background: var(--card);
  border: 1px solid var(--line);
}
.sum-grid > div {
  display: flex;
  justify-content: space-between;
  gap: 8px;
}
.sum-grid dt {
  color: var(--dim);
  font-size: 0.86rem;
}
.sum-grid dd {
  margin: 0;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}
.summary-inner .btn-primary {
  margin-top: 14px;
  width: min(100%, 340px);
  padding: 0;
}
.summary-inner .btn-ghost {
  width: min(100%, 340px);
}

/* toast */
.toast {
  pointer-events: none;
  position: fixed;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom) + 22px);
  transform: translateX(-50%);
  z-index: 45;
  padding: 11px 20px;
  border-radius: 99px;
  background: rgba(20, 22, 38, 0.92);
  border: 1px solid var(--line-hi);
  color: var(--ink);
  font-size: 0.9rem;
  font-weight: 600;
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.45);
  animation: toastIn 0.25s ease-out;
  max-width: 86vw;
  text-align: center;
}
@keyframes toastIn {
  from {
    opacity: 0;
    transform: translate(-50%, 8px);
  }
}

/* ---------- short screens ---------- */
@media (max-height: 640px) {
  /* game screen: shrink the ring and controls so question + answers fit */
  .ring-wrap {
    width: min(60vw, 42svh, 240px);
  }
  .choices {
    margin-top: 12px;
    gap: 10px;
  }
  .choice {
    min-height: 64px;
  }
  .typers {
    margin-top: 10px;
  }
  .answer-well {
    min-height: 46px;
    margin-bottom: 8px;
  }
  .key {
    min-height: 48px;
  }
  .hero {
    padding-top: 10px;
  }
  .game-title {
    font-size: clamp(2.1rem, 9vw, 2.8rem);
  }
  .player-card {
    margin-top: 10px;
  }
  .cfg-block {
    margin-top: 10px;
    padding: 9px 12px 11px;
  }
  .btn-primary {
    margin-top: 14px;
    min-height: 52px;
  }
}

/* very short viewports (landscape phones): question + first answer row
   must co-exist on screen without scrolling */
@media (max-height: 480px) {
  .ring-wrap {
    width: min(46vw, 34svh, 180px);
    margin: 6px 0 2px;
  }
  .question {
    font-size: clamp(1.6rem, 8svh, 2.4rem);
  }
  .choices {
    margin-top: 10px;
    gap: 8px;
  }
  .choice {
    min-height: 52px;
  }
  .key {
    min-height: 44px;
  }
  .answer-well {
    min-height: 40px;
    margin-bottom: 6px;
  }
  .stage {
    padding-bottom: 10px;
  }
  .combo-zone {
    height: 20px;
  }
}

/* ---------- desktop niceties ---------- */
@media (min-width: 900px) {
  .choice:hover {
    transform: translateY(-2px);
    border-color: rgba(255, 196, 50, 0.5);
    box-shadow: 0 10px 26px rgba(0, 0, 0, 0.35);
  }
}

/* ---------- reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  body::after,
  .xp-fill::after,
  .combo-flame,
  .hud-timer.hud-low,
  .hud-mult,
  .float-txt,
  .toast,
  .new-best {
    animation: none !important;
  }
  .countdown span {
    animation: none;
    opacity: 1;
    transform: none;
  }
  .question,
  .choice,
  .medal {
    animation-duration: 0.01s !important;
  }
}
