/* kidenv design system — the polished, kid-friendly baseline every app starts from.
   Build to these tokens and components: it's how a generated app reaches "app-store" polish.
   See DESIGN.md for the rules and CHECKLIST.md for the gate. Vanilla CSS, zero deps. */

:root {
  color-scheme: dark;

  /* --- Palette: bright and friendly, never harsh. Tuned for AA contrast on --surface. --- */
  --brand:        #5b4bff;   /* primary action / identity */
  --brand-ink:    #ffffff;   /* text on --brand */
  --accent:       #ff3dac;   /* hot-pink playful highlight */
  --sun:          #ffb020;   /* warm secondary (amber) */

  /* Feedback colors — encouraging, not shaming. "Try again" is a calm slate, never red. */
  --go:           #1faa59;   /* start / correct / success (green) */
  --go-ink:       #ffffff;
  --stop:         #ff6b5e;   /* stop / pause (warm coral, not alarm-red) */
  --stop-ink:     #3a0d09;
  --calm:         #6b7a99;   /* gentle "try again" — neutral, low-anxiety */

  /* Space theme surfaces — near-black cosmos */
  --surface:      #070b1a;   /* deep space background */
  --card:         #0f1535;   /* deep indigo panels */
  --card-alt:     #1a2050;   /* slightly lighter panel */
  --ink:          #f0eeff;   /* near-white text */
  --ink-soft:     #a8a0d0;   /* muted lavender secondary */
  --line:         #2a305a;   /* hairlines */
  --neon-green:   #39ff14;   /* correct-hit celebration */
  --neon-blue:    #00e5ff;   /* accent glow */
  --star-color:   #ffffff;

  /* Shape, space, type. Generous and rounded reads as friendly. */
  --radius:       18px;
  --radius-lg:    28px;
  --tap-min:      64px;
  --tap-primary:  clamp(72px, 11vh, 104px);
  --gap:          clamp(0.75rem, 2.5vw, 1.25rem);
  --pad:          clamp(1rem, 4vw, 2rem);
  --font: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --font-mono: "Courier New", Courier, monospace;
  --shadow:    0 6px 20px rgba(0, 0, 0, 0.55);
  --shadow-lg: 0 14px 40px rgba(0, 0, 0, 0.65);
  --glow-green: 0 0 16px var(--neon-green), 0 0 32px rgba(57, 255, 20, 0.4);
  --glow-blue:  0 0 16px var(--neon-blue), 0 0 32px rgba(0, 229, 255, 0.3);
  --glow-pink:  0 0 16px var(--accent), 0 0 32px rgba(255, 61, 172, 0.4);
}

/* ==================== RESET & BASE ==================== */

*, *::before, *::after { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  min-height: 100svh;
  font: clamp(16px, 2.4vw, 19px)/1.5 var(--font);
  color: var(--ink);
  background: var(--surface);
  overflow: hidden; /* game fills viewport */
  -webkit-tap-highlight-color: transparent;
}

/* ==================== SCREEN SYSTEM ==================== */

.screen {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: max(var(--pad), env(safe-area-inset-top))
           max(var(--pad), env(safe-area-inset-right))
           max(var(--pad), env(safe-area-inset-bottom))
           max(var(--pad), env(safe-area-inset-left));
  z-index: 10;
}

.screen.active {
  display: flex;
}

/* ==================== STARFIELD BACKGROUND ==================== */

.stars-bg {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.star-field {
  position: absolute;
  inset: 0;
}

/* Stars are injected by JS as <span> elements */
.star {
  position: absolute;
  background: var(--star-color);
  border-radius: 50%;
  animation: twinkle var(--twinkle-dur, 3s) ease-in-out infinite;
  animation-delay: var(--twinkle-delay, 0s);
}

@keyframes twinkle {
  0%, 100% { opacity: var(--star-dim, 0.3); transform: scale(1); }
  50%       { opacity: 1; transform: scale(1.4); }
}

/* ==================== DESIGN SYSTEM LAYOUT ==================== */

.app { width: min(36rem, 100%); display: grid; gap: var(--gap); justify-items: center; text-align: center; }
.stack { display: grid; gap: var(--gap); }
.row { display: flex; flex-wrap: wrap; gap: var(--gap); justify-content: center; }

.card {
  background: var(--card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: var(--pad);
  width: 100%;
  border: 1px solid var(--line);
}

/* ==================== TYPOGRAPHY ==================== */

h1 { font-size: clamp(2rem, 7vw, 3.25rem); line-height: 1.1; margin: 0 0 0.25em; }
h2 { font-size: clamp(1.3rem, 4.5vw, 1.9rem); margin: 0 0 0.4em; }
p  { color: var(--ink-soft); margin: 0.4em 0; }
.lead { font-size: 1.1em; color: var(--ink-soft); }

/* ==================== BUTTONS ==================== */

.btn {
  -webkit-tap-highlight-color: transparent;
  appearance: none;
  border: 0;
  cursor: pointer;
  font: inherit;
  font-weight: 800;
  color: var(--brand-ink);
  background: var(--brand);
  min-height: var(--tap-min);
  min-width: var(--tap-min);
  padding: 0 clamp(1.1rem, 4vw, 1.8rem);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5em;
  transition: transform 0.08s ease, box-shadow 0.15s ease, filter 0.15s ease;
  text-align: center;
}
.btn:hover { filter: brightness(1.1); box-shadow: var(--shadow-lg); }
.btn:active { transform: translateY(2px) scale(0.96); }
.btn:focus-visible { outline: 4px solid color-mix(in srgb, var(--brand) 55%, white); outline-offset: 3px; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: 0.45; cursor: not-allowed; box-shadow: none; filter: none; transform: none; }

.btn-xl {
  min-height: var(--tap-primary);
  font-size: clamp(1.1rem, 3.5vw, 1.5rem);
  border-radius: var(--radius-lg);
  padding: 0 clamp(1.5rem, 6vw, 2.5rem);
  width: 100%;
}

.btn-go   { background: var(--go);   color: var(--go-ink); }
.btn-go:hover { box-shadow: var(--glow-green); }

.btn-stop { background: var(--stop); color: var(--stop-ink); }

.btn-cool { background: var(--sun);  color: #3a2600; }

.btn-ghost {
  background: rgba(255,255,255,0.08);
  color: var(--ink-soft);
  box-shadow: none;
  border: 1px solid var(--line);
}
.btn-ghost:hover { background: rgba(255,255,255,0.13); color: var(--ink); }

/* ==================== BIG READOUT ==================== */

.display {
  font-variant-numeric: tabular-nums;
  font-weight: 800;
  font-size: clamp(3rem, 16vw, 6rem);
  line-height: 1;
  letter-spacing: 0.02em;
  color: var(--neon-blue);
  text-shadow: var(--glow-blue);
}

/* ==================== MOTION ==================== */

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

@keyframes pop { 0% { transform: scale(1); } 40% { transform: scale(1.12); } 100% { transform: scale(1); } }
.pop { animation: pop 0.4s ease; }

/* ==================== MENU SCREEN ==================== */

#screen-menu {
  overflow-y: auto;
  overflow-x: hidden;
  align-items: flex-start;
  padding-top: max(2rem, env(safe-area-inset-top));
}

.menu-content {
  width: min(480px, 100%);
  display: grid;
  gap: var(--gap);
  margin: 0 auto;
  position: relative;
  z-index: 1;
  padding-bottom: 2rem;
}

/* Logo / Title area */
.logo-area {
  text-align: center;
  padding: 1rem 0 0.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}

.game-title {
  font-size: clamp(2.8rem, 12vw, 5rem);
  font-weight: 900;
  line-height: 0.95;
  margin: 0;
  color: var(--ink);
  text-shadow: 0 0 20px rgba(91, 75, 255, 0.7);
  letter-spacing: -0.02em;
}

.blast-word {
  color: var(--accent);
  text-shadow: var(--glow-pink);
  display: block;
}

.tagline {
  font-size: clamp(0.85rem, 2.5vw, 1rem);
  color: var(--ink-soft);
  margin: 0;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

/* Rocket illustration (pure CSS) */
.logo-rocket {
  position: relative;
  width: 48px;
  height: 64px;
  margin: 0 auto;
}

.rocket-body {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  width: 32px;
  height: 52px;
  background: linear-gradient(135deg, #7c6bff 0%, #3a2ccc 100%);
  border-radius: 50% 50% 20% 20% / 60% 60% 20% 20%;
  border: 2px solid rgba(255,255,255,0.2);
}

.rocket-body::before {
  content: "";
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  width: 14px;
  height: 14px;
  background: var(--neon-blue);
  border-radius: 50%;
  box-shadow: var(--glow-blue);
}

.rocket-body::after {
  content: "";
  position: absolute;
  bottom: -10px;
  left: 50%;
  transform: translateX(-50%);
  width: 18px;
  height: 12px;
  background: linear-gradient(180deg, #2a2080, #1a1050);
  clip-path: polygon(20% 0%, 80% 0%, 100% 100%, 0% 100%);
  border-radius: 0 0 4px 4px;
}

.rocket-flame {
  position: absolute;
  bottom: -16px;
  left: 50%;
  transform: translateX(-50%);
  width: 14px;
  height: 20px;
  background: linear-gradient(180deg, #ffb020, #ff5500, transparent);
  border-radius: 0 0 50% 50%;
  animation: flicker 0.2s ease-in-out infinite alternate;
}

@keyframes flicker {
  from { transform: translateX(-50%) scaleY(1) scaleX(1); opacity: 1; }
  to   { transform: translateX(-50%) scaleY(1.2) scaleX(0.8); opacity: 0.8; }
}

/* Menu card */
.menu-card {
  background: rgba(15, 21, 53, 0.95);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(91, 75, 255, 0.3);
  display: grid;
  gap: 1.25rem;
}

.section-label {
  font-size: clamp(0.8rem, 2.5vw, 0.95rem);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-soft);
  margin: 0 0 0.75rem;
  font-weight: 600;
}

/* Operation picker */
.op-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.5rem;
}

.op-btn {
  -webkit-tap-highlight-color: transparent;
  appearance: none;
  border: 2px solid var(--line);
  background: rgba(255,255,255,0.04);
  border-radius: var(--radius);
  cursor: pointer;
  color: var(--ink-soft);
  font: inherit;
  font-weight: 700;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  min-height: var(--tap-min);
  padding: 0.5rem 0.25rem;
  transition: all 0.15s ease;
}

.op-btn:hover {
  background: rgba(91, 75, 255, 0.15);
  border-color: var(--brand);
  color: var(--ink);
}

.op-btn.active {
  background: rgba(91, 75, 255, 0.25);
  border-color: var(--brand);
  color: var(--ink);
  box-shadow: 0 0 12px rgba(91, 75, 255, 0.4);
}

.op-btn:focus-visible {
  outline: 3px solid var(--brand);
  outline-offset: 2px;
}

.op-icon {
  font-size: 1.6rem;
  font-weight: 900;
  line-height: 1;
  color: var(--neon-blue);
}

.op-btn.active .op-icon {
  color: var(--accent);
  text-shadow: var(--glow-pink);
}

.op-name {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Difficulty picker */
.diff-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
}

.diff-btn {
  -webkit-tap-highlight-color: transparent;
  appearance: none;
  border: 2px solid var(--line);
  background: rgba(255,255,255,0.04);
  border-radius: var(--radius);
  cursor: pointer;
  color: var(--ink-soft);
  font: inherit;
  font-weight: 700;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  min-height: var(--tap-min);
  padding: 0.5rem 0.5rem;
  transition: all 0.15s ease;
  font-size: 0.9rem;
}

.diff-btn:hover {
  background: rgba(255, 176, 32, 0.12);
  border-color: var(--sun);
  color: var(--ink);
}

.diff-btn.active {
  background: rgba(255, 176, 32, 0.2);
  border-color: var(--sun);
  color: var(--sun);
  box-shadow: 0 0 12px rgba(255, 176, 32, 0.3);
}

.diff-btn:focus-visible {
  outline: 3px solid var(--sun);
  outline-offset: 2px;
}

/* Difficulty stars: bump size so glyph shapes read clearly.
   .star-filled = bright amber ★ | .star-empty = muted/dim ☆
   This makes the filled vs empty contrast instantly visible even at small phone sizes. */
.diff-stars {
  font-size: 1.35rem;
  letter-spacing: 0.08em;
  display: inline-flex;
  gap: 0.05em;
}

.diff-stars .star-filled {
  color: var(--sun);
  text-shadow: 0 0 6px rgba(255, 176, 32, 0.7);
}

.diff-stars .star-empty {
  color: var(--ink-soft);
  opacity: 0.45;
}

/* Sound toggle */
.sound-toggle {
  width: 100%;
  font-size: 0.95rem;
}

/* ==================== HUD (in-game header) ==================== */

/* HUD uses pointer-events:none so the gradient overlay never swallows alien taps.
   Each interactive child (pause button, etc.) opts back in with pointer-events:auto. */
.hud {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: max(0.5rem, env(safe-area-inset-top)) max(0.75rem, env(safe-area-inset-right)) 0.5rem max(0.75rem, env(safe-area-inset-left));
  background: linear-gradient(180deg, rgba(7,11,26,0.95) 0%, rgba(7,11,26,0.6) 80%, transparent 100%);
  gap: 0.5rem;
  font-size: 0.9rem;
  pointer-events: none;
}

/* Re-enable pointer events on actual interactive controls inside the HUD */
.hud > *,
.hud .pause-btn {
  pointer-events: auto;
}

.hud-lives {
  display: flex;
  gap: 0.2rem;
  font-size: 1.6rem;
}

.heart {
  color: var(--stop);
  text-shadow: 0 0 8px rgba(255, 107, 94, 0.6);
  transition: all 0.2s ease;
}

.heart.lost {
  color: var(--line);
  text-shadow: none;
  opacity: 0.4;
}

.hud-score {
  text-align: center;
}

.score-label {
  display: block;
  font-size: 0.6rem;
  letter-spacing: 0.15em;
  color: var(--ink-soft);
  text-transform: uppercase;
}

.score-value {
  font-weight: 900;
  font-size: clamp(1.2rem, 4vw, 1.8rem);
  color: var(--neon-blue);
  text-shadow: var(--glow-blue);
  font-variant-numeric: tabular-nums;
}

.hud-streak {
  display: flex;
  align-items: center;
  gap: 0.2rem;
  background: rgba(255, 61, 172, 0.12);
  border: 1px solid rgba(255, 61, 172, 0.25);
  border-radius: 999px;
  padding: 0.2rem 0.6rem;
  font-weight: 800;
  color: var(--accent);
}

.hud-streak.active {
  box-shadow: var(--glow-pink);
}

.streak-icon { font-size: 0.9rem; }
.streak-value { font-size: 1rem; min-width: 1.5ch; }

.hud-wave {
  font-size: 0.75rem;
  color: var(--ink-soft);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  white-space: nowrap;
}

/* ==================== GAME ARENA ==================== */

#screen-game {
  display: none;
  flex-direction: column;
  padding: 0;
  align-items: stretch;
  justify-content: stretch;
}

#screen-game.active {
  display: flex;
}

.game-arena {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  overflow: hidden;
  z-index: 5;
}

/* Danger line near the bottom — aliens reaching this lose you a life */
.danger-line {
  position: absolute;
  bottom: 110px;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, rgba(255, 107, 94, 0.5), transparent);
  box-shadow: 0 0 10px rgba(255, 107, 94, 0.3);
}

/* ==================== ALIENS ==================== */

.alien {
  position: absolute;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-radius: 50% 50% 40% 40%;
  font-weight: 900;
  font-size: clamp(1.1rem, 3.5vw, 1.6rem);
  color: #fff;
  text-shadow: 0 1px 4px rgba(0,0,0,0.5);
  transition: transform 0.1s ease;
  will-change: transform;
  min-width: var(--tap-min);
  min-height: var(--tap-min);
  border: 2px solid rgba(255,255,255,0.15);
  box-shadow: 0 4px 20px rgba(0,0,0,0.4), inset 0 1px 0 rgba(255,255,255,0.2);
}

.alien:hover { filter: brightness(1.15); }
.alien:active { transform: scale(0.93); }
.alien:focus-visible { outline: 3px solid white; outline-offset: 3px; }

/* Alien wiggle while descending */
@keyframes alien-float {
  0%, 100% { transform: translateX(0) rotate(-2deg); }
  50%       { transform: translateX(4px) rotate(2deg); }
}
.alien.descending {
  animation: alien-float 2s ease-in-out infinite;
}

/* Hit/miss flash effects */
@keyframes alien-hit {
  0%   { transform: scale(1.3); filter: brightness(2) drop-shadow(0 0 20px var(--neon-green)); }
  50%  { transform: scale(0.8); opacity: 0.5; }
  100% { transform: scale(0); opacity: 0; }
}
.alien.hit-correct {
  animation: alien-hit 0.4s ease forwards;
  pointer-events: none;
}

@keyframes alien-wrong {
  0%   { transform: scale(1) rotate(0deg); filter: brightness(1) drop-shadow(0 0 0px red); }
  20%  { transform: scale(1.1) rotate(-5deg); filter: brightness(1.5) drop-shadow(0 0 16px #ff4444); }
  40%  { transform: scale(1.05) rotate(5deg); }
  60%  { transform: scale(1.1) rotate(-3deg); }
  100% { transform: scale(1) rotate(0deg); filter: brightness(1); }
}
.alien.hit-wrong {
  animation: alien-wrong 0.4s ease;
  pointer-events: none;
}

/* Alien reaching the danger line */
@keyframes alien-escape {
  0%   { opacity: 1; }
  100% { opacity: 0; transform: translateY(30px) scale(0.7); }
}
.alien.escaped {
  animation: alien-escape 0.4s ease forwards;
  pointer-events: none;
}

/* ==================== ALIEN COLOR SCHEMES ==================== */
/* 5 distinct alien types for visual variety */

.alien-0 {
  background: linear-gradient(135deg, #7c3aed, #4f1d96);
}
.alien-1 {
  background: linear-gradient(135deg, #0ea5e9, #0369a1);
}
.alien-2 {
  background: linear-gradient(135deg, #f59e0b, #b45309);
}
.alien-3 {
  background: linear-gradient(135deg, #ec4899, #9d174d);
}
.alien-4 {
  background: linear-gradient(135deg, #10b981, #065f46);
}

/* Alien eyes (CSS decoration) */
.alien::before {
  content: "";
  position: absolute;
  top: 22%;
  left: 50%;
  transform: translateX(-50%);
  width: 60%;
  height: 28%;
  background: rgba(255,255,255,0.15);
  border-radius: 50%;
}

/* Alien answer text */
.alien-answer {
  position: relative;
  z-index: 2;
  font-size: clamp(1.2rem, 4vw, 1.8rem);
  font-weight: 900;
  letter-spacing: -0.02em;
  line-height: 1;
  padding-top: 8px;
}

/* ==================== QUESTION BAR ==================== */

.question-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 20;
  background: linear-gradient(0deg, rgba(7,11,26,0.98) 60%, transparent 100%);
  padding:
    1rem
    max(var(--pad), env(safe-area-inset-right))
    max(1.5rem, env(safe-area-inset-bottom))
    max(var(--pad), env(safe-area-inset-left));
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}

.question-display {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 0.4rem;
  background: rgba(15, 21, 53, 0.8);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.5rem 1.5rem;
  min-width: min(280px, 90vw);
}

.question-text {
  font-size: clamp(2rem, 8vw, 3.5rem);
  font-weight: 900;
  color: var(--neon-blue);
  text-shadow: var(--glow-blue);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  line-height: 1;
}

.question-eq {
  font-size: clamp(1.5rem, 5vw, 2.5rem);
  font-weight: 900;
  color: var(--ink-soft);
  line-height: 1;
}

/* Cannon (CSS illustration) */
.cannon-row {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 40px;
}

.cannon {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.cannon-barrel {
  width: 14px;
  height: 26px;
  background: linear-gradient(180deg, #a0a0c0, #5050a0);
  border-radius: 4px 4px 2px 2px;
  box-shadow: 0 0 10px rgba(91, 75, 255, 0.5);
}

.cannon-base {
  width: 36px;
  height: 14px;
  background: linear-gradient(135deg, #5b4bff, #3020aa);
  border-radius: 6px 6px 10px 10px;
  box-shadow: 0 4px 12px rgba(91, 75, 255, 0.4);
}

/* Pause button (in-game) — sits inside the HUD as the last item.
   Must meet the --tap-min (64px) token from DESIGN.md Rule 1. */
.pause-btn {
  width: var(--tap-min);
  height: var(--tap-min);
  min-width: var(--tap-min);
  min-height: var(--tap-min);
  font-size: 1.25rem;
  padding: 0;
  border-radius: 50%;
  flex-shrink: 0;
}

/* ==================== OVERLAY SCREENS (pause/wave/gameover/win) ==================== */

.overlay-card {
  width: min(400px, 95vw);
  background: rgba(15, 21, 53, 0.97);
  border: 1px solid rgba(91, 75, 255, 0.4);
  backdrop-filter: blur(12px);
  text-align: center;
  position: relative;
  z-index: 1;
  gap: 1rem;
}

.pause-title,
.gameover-title,
.win-title {
  margin: 0;
  color: var(--ink);
}

.gameover-emoji,
.win-emoji {
  font-size: 3.5rem;
  line-height: 1;
}

.gameover-sub {
  color: var(--ink-soft);
  margin: 0;
}

.final-score-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
}

.final-score-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--ink-soft);
}

.final-score {
  font-size: clamp(2.5rem, 12vw, 4rem) !important;
}

.stars-earned {
  font-size: 2rem;
  letter-spacing: 0.2rem;
  color: var(--sun);
  text-shadow: 0 0 12px rgba(255, 176, 32, 0.6);
}

/* Wave clear screen */
.celebrate-card {
  border-color: rgba(57, 255, 20, 0.4);
}

.wave-title {
  color: var(--neon-green);
  text-shadow: var(--glow-green);
  margin: 0;
}

.wave-phrase {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--sun);
  text-shadow: 0 0 10px rgba(255, 176, 32, 0.5);
  margin: 0;
}

.wave-score-row {
  font-size: 1.1rem;
  color: var(--ink-soft);
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  align-items: baseline;
}

/* Win screen */
.win-emoji { font-size: 3.5rem; }

.win-title {
  color: var(--sun);
  text-shadow: 0 0 16px rgba(255, 176, 32, 0.6);
  margin: 0;
}

.win-sub {
  color: var(--ink-soft);
  margin: 0;
}

/* ==================== SCORE POP PARTICLES ==================== */

.score-pop {
  position: fixed;
  font-weight: 900;
  font-size: 1.4rem;
  pointer-events: none;
  z-index: 50;
  color: var(--neon-green);
  text-shadow: var(--glow-green);
  white-space: nowrap;
  animation: score-fly 0.8s ease-out forwards;
}

@keyframes score-fly {
  0%   { opacity: 1; transform: translateY(0) scale(1); }
  100% { opacity: 0; transform: translateY(-70px) scale(1.3); }
}

.streak-pop {
  color: var(--accent);
  text-shadow: var(--glow-pink);
  font-size: 1.1rem;
}

/* ==================== EXPLOSION PARTICLES ==================== */

.particle {
  position: fixed;
  pointer-events: none;
  z-index: 40;
  border-radius: 50%;
  width: 8px;
  height: 8px;
  animation: particle-fly var(--dur, 0.6s) ease-out forwards;
}

@keyframes particle-fly {
  0%   { opacity: 1; transform: translate(0, 0) scale(1); }
  100% { opacity: 0; transform: translate(var(--dx), var(--dy)) scale(0.3); }
}

/* ==================== CELEBRATE BURST (wave clear / win) ==================== */

.celebrate-burst {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  border-radius: var(--radius-lg);
}

.confetti {
  position: absolute;
  width: 8px;
  height: 10px;
  animation: confetti-fall var(--dur, 1.5s) ease-in-out forwards;
  animation-delay: var(--delay, 0s);
}

@keyframes confetti-fall {
  0%   { transform: translate(var(--sx), -20px) rotate(0deg); opacity: 1; }
  100% { transform: translate(var(--ex), 200px) rotate(var(--rot)); opacity: 0; }
}

/* ==================== LASER BEAM ==================== */

.laser {
  position: fixed;
  pointer-events: none;
  z-index: 35;
  width: 3px;
  background: linear-gradient(180deg, var(--neon-blue), transparent);
  box-shadow: 0 0 8px var(--neon-blue);
  animation: laser-fly var(--laser-dur, 0.2s) linear forwards;
  transform-origin: bottom center;
}

@keyframes laser-fly {
  from { opacity: 1; clip-path: inset(100% 0 0 0); }
  to   { opacity: 0; clip-path: inset(0 0 0 0); }
}

/* ==================== RESPONSIVE ==================== */

@media (max-width: 480px) {
  .op-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .hud {
    font-size: 0.8rem;
    gap: 0.3rem;
    padding-left: max(0.5rem, env(safe-area-inset-left));
    padding-right: max(0.5rem, env(safe-area-inset-right));
  }

  .hud-lives {
    font-size: 1.2rem;
  }

  /* Pause button: keep full tap-min height (64px) but trim any extra padding */
  .pause-btn {
    font-size: 1.1rem;
  }
}

@media (max-width: 360px) {
  /* Very small phones: hide the streak counter to reduce crowding while keeping
     the 64px pause-btn tap target and all critical HUD info. */
  .hud-streak {
    display: none;
  }

  .hud {
    gap: 0.2rem;
  }
}

@media (max-width: 320px) {
  .game-title {
    font-size: 2.2rem;
  }

  .op-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .alien-answer {
    font-size: 1rem;
  }

  /* Further compress HUD text at 320px, but keep pause-btn tap target */
  .hud {
    font-size: 0.72rem;
  }

  .hud-lives {
    font-size: 1rem;
  }
}

/* Landscape phone — keep question bar compact */
@media (max-height: 480px) and (orientation: landscape) {
  .danger-line {
    bottom: 80px;
  }

  .question-bar {
    padding-top: 0.5rem;
    padding-bottom: max(0.5rem, env(safe-area-inset-bottom));
  }

  .question-text {
    font-size: 1.6rem;
  }

  .cannon-row {
    height: 28px;
  }
}
