/* ============================================================
   Math Mission: Planet Rescue
   A bubbly, toy-like space adventure. Deep-blue cosmos,
   glowing planets, candy-bright accents.
   ============================================================ */

:root {
  /* Cosmos palette — deep blues with candy accents */
  --space-900: #0a0a2e;
  --space-800: #141148;
  --space-700: #1d1a5e;
  --space-600: #2b2785;

  --star: #fff6d5;
  --sun: #ffd36e;
  --bubblegum: #ff8fcf;
  --coral: #ff6b8b;
  --mint: #7be3a4;
  --sky: #7fd1ff;
  --grape: #b98cff;
  --tang: #ffae5c;

  --ink: #2a2350;
  --paper: #fffaf0;

  --font-display: "Fredoka", "Trebuchet MS", sans-serif;
  --font-body: "Nunito", system-ui, sans-serif;

  --ring-easy: var(--mint);
  --ring-medium: var(--sky);
  --ring-hard: var(--grape);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  font-family: var(--font-body);
  color: var(--paper);
  background: var(--space-900);
  overflow: hidden;
}

body {
  position: relative;
  -webkit-font-smoothing: antialiased;
}

/* ============================================================
   COSMOS BACKGROUND
   ============================================================ */
.cosmos {
  position: fixed;
  inset: 0;
  z-index: 0;
  background:
    radial-gradient(120% 90% at 50% -10%, #2b2785 0%, transparent 55%),
    radial-gradient(120% 100% at 80% 110%, #3a1d6e 0%, transparent 60%),
    linear-gradient(160deg, var(--space-900), var(--space-800) 55%, #0c0a35);
  overflow: hidden;
}

.nebula {
  position: absolute;
  border-radius: 50%;
  filter: blur(60px);
  opacity: 0.5;
  mix-blend-mode: screen;
  animation: drift 26s ease-in-out infinite alternate;
}
.nebula--one {
  width: 46vmax; height: 46vmax;
  top: -14vmax; left: -10vmax;
  background: radial-gradient(circle, var(--grape), transparent 65%);
}
.nebula--two {
  width: 40vmax; height: 40vmax;
  bottom: -16vmax; right: -8vmax;
  background: radial-gradient(circle, var(--bubblegum), transparent 65%);
  animation-duration: 32s;
}
.nebula--three {
  width: 30vmax; height: 30vmax;
  top: 30%; right: 20%;
  background: radial-gradient(circle, var(--sky), transparent 65%);
  animation-duration: 38s;
  opacity: 0.35;
}
@keyframes drift {
  from { transform: translate3d(0,0,0) scale(1); }
  to   { transform: translate3d(4vmax, 3vmax, 0) scale(1.12); }
}

#starfield {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.shooting-star {
  position: absolute;
  top: 14%;
  left: -10%;
  width: 140px;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--star));
  border-radius: 2px;
  filter: drop-shadow(0 0 6px var(--star));
  opacity: 0;
  animation: shoot 9s ease-in 3s infinite;
}
@keyframes shoot {
  0%   { opacity: 0; transform: translate(0,0) rotate(18deg); }
  3%   { opacity: 1; }
  12%  { opacity: 0; transform: translate(120vw, 36vh) rotate(18deg); }
  100% { opacity: 0; }
}

/* ============================================================
   STAGE + SCREENS
   ============================================================ */
.stage {
  position: relative;
  z-index: 1;
  height: 100%;
  display: grid;
  place-items: center;
  padding: clamp(0.75rem, 3vw, 2rem);
}

.screen { width: 100%; max-width: 960px; }
.screen[hidden] { display: none; }

/* ============================================================
   MAIN MENU
   ============================================================ */
.menu-card {
  position: relative;
  text-align: center;
  padding: clamp(1.5rem, 4vw, 3rem) clamp(1.25rem, 4vw, 3.25rem);
  border-radius: 36px;
  background: linear-gradient(165deg, rgba(43,39,133,0.72), rgba(20,17,72,0.86));
  border: 2px solid rgba(255,255,255,0.14);
  box-shadow:
    0 30px 80px -30px rgba(0,0,0,0.7),
    inset 0 1px 0 rgba(255,255,255,0.18);
  backdrop-filter: blur(8px);
  animation: pop-in 0.6s cubic-bezier(.2,.9,.3,1.3) both;
  max-width: 640px;
  margin: 0 auto;
}
@keyframes pop-in {
  from { opacity: 0; transform: translateY(30px) scale(0.94); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.eyebrow {
  font-family: var(--font-display);
  text-transform: uppercase;
  letter-spacing: 0.32em;
  font-size: 0.72rem;
  color: var(--sun);
  margin: 0 0 0.4rem;
}

.title {
  margin: 0 0 0.5rem;
  font-family: var(--font-display);
  font-weight: 700;
  line-height: 0.92;
  text-wrap: balance;
}
.title__line { display: block; }
.title__line--top {
  font-size: clamp(2.1rem, 7vw, 3.5rem);
  color: var(--paper);
  text-shadow: 0 2px 0 var(--grape);
}
.title__line--bottom {
  font-size: clamp(2.6rem, 9vw, 4.4rem);
  background: linear-gradient(95deg, var(--sun), var(--bubblegum) 55%, var(--sky));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 3px 0 rgba(0,0,0,0.25));
}

.mascot {
  margin: 0.4rem auto 0.2rem;
  width: min(220px, 60%);
  animation: bob 3.4s ease-in-out infinite;
}
.mascot__ship { width: 100%; height: auto; filter: drop-shadow(0 14px 22px rgba(0,0,0,0.4)); }
@keyframes bob {
  0%,100% { transform: translateY(0) rotate(-2deg); }
  50%     { transform: translateY(-12px) rotate(2deg); }
}

.lede {
  max-width: 30rem;
  margin: 0.3rem auto 1.4rem;
  font-size: clamp(0.95rem, 2.4vw, 1.1rem);
  line-height: 1.5;
  color: rgba(255,250,240,0.86);
}
.lede strong { color: var(--sun); }

/* Difficulty picker */
.difficulty { border: 0; margin: 0; padding: 0; }
.difficulty legend {
  font-family: var(--font-display);
  font-size: 1rem;
  letter-spacing: 0.04em;
  color: rgba(255,255,255,0.7);
  margin: 0 auto 0.85rem;
  padding: 0;
}
.difficulty__grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: clamp(0.6rem, 2vw, 1rem);
}

.diff-btn {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  padding: 1.1rem 0.6rem 1rem;
  border: 2px solid rgba(255,255,255,0.16);
  border-radius: 24px;
  background: rgba(255,255,255,0.06);
  color: var(--paper);
  cursor: pointer;
  font-family: var(--font-display);
  transition: transform 0.18s cubic-bezier(.2,.9,.3,1.4), box-shadow 0.2s, background 0.2s, border-color 0.2s;
}
.diff-btn:hover, .diff-btn:focus-visible {
  transform: translateY(-6px) scale(1.03);
  background: rgba(255,255,255,0.12);
  outline: none;
}
.diff-btn:active { transform: translateY(-2px) scale(0.99); }

.diff-btn__planet {
  width: 52px; height: 52px;
  border-radius: 50%;
  position: relative;
  box-shadow: inset -8px -8px 0 rgba(0,0,0,0.18), 0 6px 16px rgba(0,0,0,0.35);
}
.diff-btn__planet::after {
  content: "";
  position: absolute;
  inset: -7px 50% auto -7px;
  width: 74px; height: 18px;
  border: 4px solid rgba(255,255,255,0.55);
  border-radius: 50%;
  transform: translateY(20px) rotate(-22deg);
}
.diff-btn--easy   { border-color: rgba(123,227,164,0.5); }
.diff-btn--easy   .diff-btn__planet { background: radial-gradient(circle at 35% 30%, #b9f5cf, var(--mint)); }
.diff-btn--medium { border-color: rgba(127,209,255,0.5); }
.diff-btn--medium .diff-btn__planet { background: radial-gradient(circle at 35% 30%, #c7ecff, var(--sky)); }
.diff-btn--hard   { border-color: rgba(185,140,255,0.5); }
.diff-btn--hard   .diff-btn__planet { background: radial-gradient(circle at 35% 30%, #dcc6ff, var(--grape)); }

.diff-btn__name { font-size: 1.25rem; font-weight: 600; }
.diff-btn__desc {
  font-family: var(--font-body);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: rgba(255,255,255,0.66);
  text-transform: uppercase;
}

/* Mute toggle */
.mute {
  margin-top: 1.4rem;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  border-radius: 999px;
  border: 2px solid rgba(255,255,255,0.18);
  background: rgba(255,255,255,0.06);
  color: rgba(255,255,255,0.8);
  font-family: var(--font-display);
  font-size: 0.85rem;
  cursor: pointer;
  transition: background 0.2s, transform 0.15s;
}
.mute:hover { background: rgba(255,255,255,0.12); transform: translateY(-2px); }
.mute__icon {
  width: 16px; height: 16px;
  border-radius: 3px 0 0 3px;
  position: relative;
  background: var(--sun);
  clip-path: polygon(0 30%, 40% 30%, 100% 0, 100% 100%, 40% 70%, 0 70%);
}
.mute.is-muted .mute__icon { background: rgba(255,255,255,0.4); }

/* ============================================================
   GAME — HUD
   ============================================================ */
.screen--game {
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: clamp(0.75rem, 2vw, 1.5rem);
  height: 100%;
  max-height: 100%;
  padding: clamp(0.5rem, 2vw, 1rem) 0;
}

.hud {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}
.hud__chip {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  padding: 0.5rem 1.1rem;
  border-radius: 18px;
  background: linear-gradient(160deg, rgba(255,255,255,0.14), rgba(255,255,255,0.04));
  border: 2px solid rgba(255,255,255,0.16);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.2);
}
.hud__label {
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-weight: 800;
  color: rgba(255,255,255,0.6);
}
.hud__value {
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-weight: 700;
  line-height: 1;
}
.hud__chip--level .hud__value { color: var(--sun); }
.hud__chip--score .hud__value { color: var(--mint); }

/* Streak / combo chip — pops in as the run heats up */
.hud__chip--combo { animation: badge-pop 0.4s cubic-bezier(.2,.9,.3,1.6) both; }
.hud__chip--combo[hidden] { display: none; }
.hud__chip--combo .hud__value { color: var(--bubblegum); }
.hud__chip--combo.is-hot .hud__value { color: var(--coral); }
.hud__chip--combo.is-bump { animation: combo-bump 0.45s ease; }
@keyframes combo-bump {
  0% { transform: scale(1); }
  40% { transform: scale(1.32) rotate(-3deg); }
  100% { transform: scale(1); }
}

/* Lives — beating hearts */
.hud__hearts { display: flex; gap: 4px; align-items: center; }
.heart {
  width: 18px; height: 18px;
  background: var(--coral);
  clip-path: path("M9 16 C9 16 1 11 1 5.5 C1 2.5 3.2 1 5 1 C6.6 1 8.2 2 9 3.6 C9.8 2 11.4 1 13 1 C14.8 1 17 2.5 17 5.5 C17 11 9 16 9 16 Z");
  filter: drop-shadow(0 2px 3px rgba(0,0,0,0.4));
  animation: heart-beat 1.1s ease-in-out infinite;
}
@keyframes heart-beat {
  0%,100% { transform: scale(1); }
  30% { transform: scale(1.18); }
  45% { transform: scale(1); }
}
.heart.is-lost {
  background: rgba(255,255,255,0.22);
  animation: heart-pop-out 0.5s ease forwards;
}
@keyframes heart-pop-out {
  0% { transform: scale(1.4); }
  100% { transform: scale(0.85); opacity: 0.45; }
}

.hud__badges {
  flex: 1;
  display: flex;
  gap: 0.3rem;
  flex-wrap: wrap;
  align-content: center;
  min-height: 32px;
  padding: 0 0.25rem;
}
.badge {
  width: 28px; height: 28px;
  display: grid;
  place-items: center;
  animation: badge-pop 0.5s cubic-bezier(.2,.9,.3,1.6) both;
}
.badge svg { width: 100%; height: 100%; filter: drop-shadow(0 2px 4px rgba(0,0,0,0.4)); }
@keyframes badge-pop {
  from { transform: scale(0) rotate(-40deg); opacity: 0; }
  to   { transform: scale(1) rotate(0); opacity: 1; }
}

.hud__quit {
  padding: 0.5rem 1rem;
  border-radius: 14px;
  border: 2px solid rgba(255,255,255,0.18);
  background: rgba(255,107,139,0.18);
  color: var(--paper);
  font-family: var(--font-display);
  font-size: 0.85rem;
  cursor: pointer;
  transition: background 0.2s, transform 0.15s;
}
.hud__quit:hover { background: rgba(255,107,139,0.34); transform: translateY(-2px); }

/* ============================================================
   FLIGHT AREA — ship + gate
   ============================================================ */
.flight {
  position: relative;
  border-radius: 28px;
  overflow: hidden;
  min-height: 220px;
  border: 2px solid rgba(255,255,255,0.1);
  background:
    radial-gradient(80% 120% at 15% 50%, rgba(127,209,255,0.12), transparent 60%),
    linear-gradient(120deg, rgba(20,17,72,0.5), rgba(43,39,133,0.35));
  box-shadow: inset 0 0 60px rgba(0,0,0,0.45);
}

/* ----- Countdown timer ----- */
.timer {
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 12px;
  z-index: 6;
  background: rgba(0,0,0,0.32);
  box-shadow: inset 0 -1px 0 rgba(255,255,255,0.08);
}
.timer__fill {
  height: 100%;
  width: 100%;
  border-radius: 0 8px 8px 0;
  background: linear-gradient(90deg, var(--mint) 0%, var(--sun) 70%, var(--tang) 100%);
  box-shadow: 0 0 14px rgba(255,211,110,0.55);
  transition: width 0.12s linear, background 0.3s;
  will-change: width;
}
.timer__label {
  position: absolute;
  right: 12px; top: 14px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--paper);
  text-shadow: 0 2px 6px rgba(0,0,0,0.7);
  transform-origin: center;
}

/* Danger! time is running out */
.is-danger .timer__fill {
  background: linear-gradient(90deg, #ff3b3b, var(--coral));
  box-shadow: 0 0 16px rgba(255,59,59,0.8);
}
.is-danger .timer__label {
  color: #ff7a7a;
  animation: time-pulse 0.5s ease-in-out infinite;
}
@keyframes time-pulse {
  0%,100% { transform: scale(1); }
  50% { transform: scale(1.4); }
}
.is-danger .flight {
  animation: danger-flash 0.7s ease-in-out infinite;
}
@keyframes danger-flash {
  0%,100% { box-shadow: inset 0 0 60px rgba(0,0,0,0.45); }
  50% { box-shadow: inset 0 0 90px rgba(255,40,40,0.55); }
}

/* Floating "+points" reward */
.score-pop {
  position: absolute;
  left: 50%; top: 26%;
  transform: translateX(-50%);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(1.3rem, 4vw, 1.9rem);
  color: var(--sun);
  text-shadow: 0 2px 10px rgba(0,0,0,0.7);
  pointer-events: none;
  z-index: 7;
  animation: score-float 1.1s ease-out forwards;
}
@keyframes score-float {
  0% { opacity: 0; transform: translate(-50%, 14px) scale(0.5); }
  25% { opacity: 1; transform: translate(-50%, -2px) scale(1.1); }
  100% { opacity: 0; transform: translate(-50%, -64px) scale(1); }
}

/* Speed-line streaks that flow during flight */
.flight::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: repeating-linear-gradient(
    90deg,
    transparent 0 40px,
    rgba(255,255,255,0.06) 40px 42px
  );
  opacity: 0;
  transform: translateX(0);
}
.flight.is-warping::before {
  opacity: 1;
  animation: warp-lines 0.5s linear infinite;
}
@keyframes warp-lines {
  from { transform: translateX(0); }
  to   { transform: translateX(-82px); }
}

.ship {
  position: absolute;
  left: 8%;
  top: 50%;
  width: clamp(96px, 18vw, 160px);
  transform: translateY(-50%);
  z-index: 3;
  animation: ship-hover 2.6s ease-in-out infinite;
  transition: left 0.9s cubic-bezier(.5,0,.2,1), transform 0.9s ease;
}
.ship svg { width: 100%; height: auto; filter: drop-shadow(0 10px 16px rgba(0,0,0,0.45)); }
@keyframes ship-hover {
  0%,100% { transform: translateY(-50%); }
  50%     { transform: translateY(calc(-50% - 10px)); }
}
.ship.is-zooming {
  left: 120%;
  animation: none;
  transform: translateY(-50%) rotate(-4deg);
}

.ship__flame {
  position: absolute;
  left: -22px;
  top: 50%;
  width: 30px; height: 22px;
  transform: translateY(-50%);
  background: radial-gradient(circle at 100% 50%, var(--sun), var(--coral) 70%, transparent);
  border-radius: 50% 0 0 50%;
  filter: blur(1px);
  opacity: 0.85;
  animation: flicker 0.18s steps(2) infinite;
}
@keyframes flicker {
  0% { transform: translateY(-50%) scaleX(1); opacity: 0.85; }
  100% { transform: translateY(-50%) scaleX(0.7); opacity: 1; }
}

/* Math Gate */
.gate {
  position: absolute;
  right: 12%;
  top: 50%;
  transform: translateY(-50%);
  width: clamp(120px, 24vw, 190px);
  aspect-ratio: 1;
  z-index: 2;
  display: grid;
  place-items: center;
}
.gate__ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 6px dashed var(--ring-medium);
  opacity: 0.85;
}
.gate__ring--outer { animation: spin 14s linear infinite; }
.gate__ring--inner {
  inset: 14%;
  border-style: solid;
  border-width: 4px;
  opacity: 0.4;
  animation: spin 9s linear infinite reverse;
}
@keyframes spin { to { transform: rotate(360deg); } }

.gate.is-open .gate__ring {
  animation: gate-open 0.7s ease forwards;
  border-color: var(--sun);
}
@keyframes gate-open {
  to { transform: scale(1.7); opacity: 0; }
}

/* Planet character living inside the gate */
.planet {
  position: relative;
  width: 64%;
  aspect-ratio: 1;
  z-index: 1;
  animation: planet-float 3s ease-in-out infinite;
}
.planet.is-wiggle { animation: wiggle 0.5s ease; }
.planet.is-cheer  { animation: cheer 0.6s ease; }
@keyframes planet-float {
  0%,100% { transform: translateY(0) rotate(-3deg); }
  50%     { transform: translateY(-8px) rotate(3deg); }
}
@keyframes wiggle {
  0%,100% { transform: rotate(0); }
  20% { transform: rotate(-9deg) scale(1.02); }
  40% { transform: rotate(8deg); }
  60% { transform: rotate(-6deg); }
  80% { transform: rotate(4deg); }
}
@keyframes cheer {
  0% { transform: scale(1); }
  40% { transform: scale(1.22) rotate(6deg); }
  70% { transform: scale(0.96); }
  100% { transform: scale(1); }
}
.planet svg { width: 100%; height: 100%; overflow: visible; }

.gate__sparkles {
  position: absolute;
  inset: -10%;
  pointer-events: none;
  z-index: 4;
}
.spark {
  position: absolute;
  width: 12px; height: 12px;
  background: var(--star);
  clip-path: polygon(50% 0, 61% 39%, 100% 50%, 61% 61%, 50% 100%, 39% 61%, 0 50%, 39% 39%);
  animation: spark-fly 0.7s ease-out forwards;
}
@keyframes spark-fly {
  from { transform: translate(0,0) scale(0.2); opacity: 1; }
  to   { transform: translate(var(--dx), var(--dy)) scale(1.1); opacity: 0; }
}

/* ============================================================
   PROBLEM PANEL
   ============================================================ */
.panel {
  display: grid;
  gap: 0.9rem;
  animation: pop-in 0.4s cubic-bezier(.2,.9,.3,1.3) both;
}
.panel[hidden] { display: none; }

.panel__bubble {
  position: relative;
  margin: 0 auto;
  max-width: 30rem;
  width: 100%;
  text-align: center;
  padding: 1rem 1.4rem 1.2rem;
  background: var(--paper);
  color: var(--ink);
  border-radius: 26px;
  border: 3px solid #fff;
  box-shadow: 0 16px 36px -12px rgba(0,0,0,0.55);
}
.panel__bubble::after {
  content: "";
  position: absolute;
  top: -16px; left: 50%;
  transform: translateX(-50%);
  border: 14px solid transparent;
  border-bottom-color: var(--paper);
  border-top: 0;
}
.panel__hello {
  margin: 0 0 0.2rem;
  font-family: var(--font-display);
  font-weight: 600;
  color: var(--bubblegum);
  font-size: 1rem;
}
.panel__problem {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(2rem, 7vw, 3rem);
  letter-spacing: 0.04em;
  color: var(--ink);
}

.answer {
  margin: 0 auto;
  max-width: 30rem;
  width: 100%;
  text-align: center;
}
.answer__label {
  display: block;
  font-family: var(--font-display);
  font-size: 0.9rem;
  color: rgba(255,255,255,0.78);
  margin-bottom: 0.45rem;
}
.answer__row {
  display: flex;
  gap: 0.6rem;
  justify-content: center;
}
.answer__input {
  flex: 1;
  max-width: 12rem;
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-weight: 600;
  text-align: center;
  color: var(--ink);
  padding: 0.6rem 0.8rem;
  border-radius: 18px;
  border: 3px solid rgba(255,255,255,0.3);
  background: var(--paper);
  box-shadow: inset 0 2px 6px rgba(0,0,0,0.12);
  transition: border-color 0.2s, box-shadow 0.2s, transform 0.15s;
}
.answer__input::-webkit-outer-spin-button,
.answer__input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.answer__input { -moz-appearance: textfield; appearance: textfield; }
.answer__input:focus {
  outline: none;
  border-color: var(--sky);
  box-shadow: inset 0 2px 6px rgba(0,0,0,0.12), 0 0 0 4px rgba(127,209,255,0.35);
}
.answer.is-wrong .answer__input {
  border-color: var(--coral);
  animation: shake 0.4s;
}
@keyframes shake {
  0%,100% { transform: translateX(0); }
  25% { transform: translateX(-7px); }
  75% { transform: translateX(7px); }
}

.answer__go {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.1rem;
  color: var(--ink);
  padding: 0.6rem 1.3rem;
  border-radius: 18px;
  border: 0;
  cursor: pointer;
  background: linear-gradient(160deg, var(--sun), var(--tang));
  box-shadow: 0 8px 0 #c9842f, 0 12px 20px rgba(0,0,0,0.35);
  transition: transform 0.1s, box-shadow 0.1s;
}
.answer__go:hover { transform: translateY(-2px); }
.answer__go:active {
  transform: translateY(6px);
  box-shadow: 0 2px 0 #c9842f, 0 4px 10px rgba(0,0,0,0.35);
}

.answer__feedback {
  min-height: 1.5rem;
  margin: 0.7rem 0 0;
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 1.05rem;
}
.answer__feedback.is-good { color: var(--mint); }
.answer__feedback.is-try  { color: var(--sun); }

/* ============================================================
   VICTORY OVERLAY (confetti)
   ============================================================ */
.victory {
  position: fixed;
  inset: 0;
  z-index: 20;
  pointer-events: none;
  overflow: hidden;
}
.victory[hidden] { display: none; }
.confetti {
  position: absolute;
  top: -20px;
  width: 12px; height: 16px;
  border-radius: 3px;
  animation: fall linear forwards;
}
@keyframes fall {
  to { transform: translateY(110vh) rotate(720deg); opacity: 0.2; }
}

/* ============================================================
   GAME OVER OVERLAY
   ============================================================ */
.gameover {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 1.25rem;
  background: rgba(10,10,46,0.82);
  backdrop-filter: blur(7px);
  animation: pop-in 0.4s ease both;
}
.gameover[hidden] { display: none; }
.gameover__card {
  text-align: center;
  max-width: 30rem;
  width: 100%;
  padding: clamp(1.5rem, 5vw, 2.6rem);
  border-radius: 32px;
  background: linear-gradient(165deg, rgba(43,39,133,0.85), rgba(20,17,72,0.92));
  border: 2px solid rgba(255,255,255,0.16);
  box-shadow: 0 30px 80px -30px rgba(0,0,0,0.8), inset 0 1px 0 rgba(255,255,255,0.18);
  animation: pop-in 0.55s cubic-bezier(.2,.9,.3,1.3) both;
}
.gameover__eyebrow {
  font-family: var(--font-display);
  text-transform: uppercase;
  letter-spacing: 0.3em;
  font-size: 0.7rem;
  color: var(--coral);
  margin: 0 0 0.3rem;
}
.gameover__title {
  margin: 0 0 1rem;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(2rem, 7vw, 3rem);
  background: linear-gradient(95deg, var(--coral), var(--sun));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.gameover__line {
  margin: 0.3rem 0;
  font-size: 1.05rem;
  color: rgba(255,250,240,0.9);
}
.gameover__line strong { color: var(--sun); }
.gameover__line--combo strong { color: var(--bubblegum); }
.gameover__btn {
  margin: 1.3rem 0 0.6rem;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.2rem;
  color: var(--ink);
  padding: 0.7rem 2rem;
  border-radius: 18px;
  border: 0;
  cursor: pointer;
  background: linear-gradient(160deg, var(--sun), var(--tang));
  box-shadow: 0 8px 0 #c9842f, 0 12px 20px rgba(0,0,0,0.4);
  transition: transform 0.1s, box-shadow 0.1s;
}
.gameover__btn:hover { transform: translateY(-2px); }
.gameover__btn:active {
  transform: translateY(6px);
  box-shadow: 0 2px 0 #c9842f, 0 4px 10px rgba(0,0,0,0.35);
}
.gameover__home {
  display: block;
  margin: 0.4rem auto 0;
  background: none;
  border: 0;
  color: rgba(255,255,255,0.66);
  font-family: var(--font-display);
  font-size: 0.95rem;
  cursor: pointer;
  text-decoration: underline;
}
.gameover__home:hover { color: var(--paper); }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 560px) {
  .difficulty__grid { grid-template-columns: 1fr; }
  .diff-btn { flex-direction: row; justify-content: center; gap: 0.8rem; padding: 0.9rem; }
  .diff-btn__planet { width: 40px; height: 40px; }
  .diff-btn__planet::after { display: none; }
  .hud__badges { order: 4; width: 100%; }
  .answer__row { flex-direction: column; align-items: center; }
  .answer__input { max-width: 100%; width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
