
/**
 * Firefly Catch — firefly-catch.css
 * A serial, accumulative-reward attention game (go/no-go). Deliberately NOT
 * a field-of-simultaneous-targets layout — see pop-spiral.css for the
 * contrasting pattern this avoids.
 */

/* ── Reset & Base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --color-bg-deep:    hsl(165, 38%, 6%);
  --color-bg-surface: hsl(165, 30%, 9%);
  --color-bg-card:    hsl(165, 22%, 12%);

  --color-text-primary: hsl(220, 20%, 92%);
  --color-text-muted:   hsl(220, 15%, 55%);
  --color-text-dim:     hsl(220, 12%, 35%);

  --font-display: 'DM Sans', sans-serif;
  --font-body:    'Inter', sans-serif;

  --text-xs:   clamp(0.65rem, 1.5vw, 0.75rem);
  --text-sm:   clamp(0.8rem, 2vw, 0.875rem);
  --text-md:   clamp(1rem, 3vw, 1.125rem);
  --text-lg:   clamp(1.1rem, 3.5vw, 1.375rem);
  --text-xl:   clamp(1.3rem, 4vw, 1.75rem);
  --text-2xl:  clamp(1.6rem, 5vw, 2.25rem);
  --text-3xl:  clamp(2rem, 6vw, 3rem);

  --space-2:  0.5rem;
  --space-3:  0.75rem;
  --space-4:  1rem;
  --space-5:  1.25rem;
  --space-6:  1.5rem;
  --space-8:  2rem;
  --space-10: 2.5rem;

  --radius-sm:   6px;
  --radius-lg:   20px;
  --radius-xl:   32px;
  --radius-full: 9999px;

  --ease-bounce:     cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-out-expo:   cubic-bezier(0.16, 1, 0.3, 1);

  --warm-hue: 38; /* must match FireflyCatch.WARM_HUE */
}

html, body {
  height: 100%;
  width: 100%;
  overflow: hidden;
  background: var(--color-bg-deep);
  color: var(--color-text-primary);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}

/* ── Ambient Background ── */
.bg { position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; }
.blob { position: absolute; border-radius: 50%; filter: blur(100px); opacity: 0.09; animation: blobDrift 20s ease-in-out infinite alternate; }
.blob-a { width: 460px; height: 460px; background: hsl(165, 45%, 35%); top: -160px; left: -100px; animation-duration: 24s; }
.blob-b { width: 360px; height: 360px; background: hsl(var(--warm-hue), 80%, 50%); bottom: -120px; right: -90px; animation-duration: 18s; animation-delay: -6s; }
@keyframes blobDrift { from { transform: translate(0,0) scale(1); } to { transform: translate(26px, 18px) scale(1.06); } }

/* ── Screen System ── */
.screen {
  position: fixed; inset: 0; z-index: 1;
  display: flex; flex-direction: column;
  opacity: 0; pointer-events: none;
  overflow-y: auto; -webkit-overflow-scrolling: touch;
  transition: opacity 400ms var(--ease-out-expo);
}
.screen.is-active { opacity: 1; pointer-events: all; }

.scr-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: max(env(safe-area-inset-top), 1.25rem) var(--space-6) var(--space-4);
  position: relative; z-index: 10;
}
.nav-back {
  display: flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; border: none;
  background: hsla(165, 25%, 22%, 0.6);
  border-radius: var(--radius-full);
  color: var(--color-text-muted);
  cursor: pointer; text-decoration: none;
  transition: background 200ms, color 200ms, transform 200ms var(--ease-bounce);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border: 1px solid hsla(220, 20%, 40%, 0.15);
}
@media (hover: hover) and (pointer: fine) {
  .nav-back:hover { background: hsla(165, 25%, 30%, 0.7); color: var(--color-text-primary); transform: scale(1.05); }
}
.nav-back:active { transform: scale(0.95); }

/* ════════════ START SCREEN ════════════ */
.scr-inner { flex: 1; display: flex; flex-direction: column; padding-bottom: max(env(safe-area-inset-bottom), var(--space-8)); }
.start-inner { padding: 0 var(--space-6); gap: var(--space-8); justify-content: space-between; }

.start-hero {
  flex: 0 0 auto; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: var(--space-4); text-align: center; padding-top: var(--space-4);
}

.start-firefly-preview {
  position: relative; width: 140px; height: 140px; margin: 0 auto;
  display: flex; align-items: center; justify-content: center;
}
/* A real firefly (same body/wings/glowing-abdomen markup as in play), shown
   lit and gently bobbing in place — the logo is the actual creature, not a
   ball of light. */
.preview-firefly.firefly-entity {
  position: relative; left: auto; top: auto; margin: 0;
  width: 28px; height: 28px;
  animation: previewFireflyBob 3.8s ease-in-out infinite;
}
@keyframes previewFireflyBob {
  0%, 100% { transform: scale(2.7) translateY(2px); }
  50%      { transform: scale(2.7) translateY(-3px); }
}

.start-title {
  font-family: var(--font-display); font-size: var(--text-3xl); font-weight: 600; letter-spacing: -0.025em;
  background: linear-gradient(135deg, hsl(var(--warm-hue), 90%, 68%) 0%, hsl(160, 42%, 58%) 100%);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}
.start-sub { font-size: var(--text-md); color: var(--color-text-muted); line-height: 1.65; font-weight: 300; max-width: 28ch; margin: 0 auto; }
.start-best {
  font-family: var(--font-display); font-size: var(--text-sm); font-weight: 600;
  color: hsl(var(--warm-hue), 80%, 66%); margin-top: var(--space-2); min-height: 1.2em;
}
.start-best:empty { opacity: 0; }

/* ── How-to summary (replaces the old duration picker; the night is endless) ── */
.start-howto {
  flex: 1; display: flex; flex-direction: column; justify-content: center;
  gap: var(--space-3); max-width: 30ch; margin: 0 auto; width: 100%;
}
.howto-row {
  display: flex; align-items: center; gap: var(--space-3);
  font-size: var(--text-sm); color: var(--color-text-muted); line-height: 1.4; text-align: left;
}
.howto-row b { color: var(--color-text-primary); font-weight: 600; }
.howto-ic {
  flex: 0 0 auto; width: 1.9rem; height: 1.9rem; display: flex; align-items: center; justify-content: center;
  font-size: 1.05rem; border-radius: 50%;
  background: hsla(165, 25%, 18%, 0.7); border: 1px solid hsla(220, 20%, 40%, 0.15);
}

/* ── Duration Picker (legacy styles — no longer rendered; kept harmless) ── */
.duration-section { flex: 1; display: flex; flex-direction: column; gap: var(--space-3); min-height: 0; }
.section-label {
  font-family: var(--font-display); font-size: var(--text-xs); font-weight: 500; color: var(--color-text-dim);
  text-transform: uppercase; letter-spacing: 0.12em; text-align: center;
}
.duration-list { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-2); flex: 1; align-content: start; }
.dur-btn {
  display: flex; flex-direction: column; align-items: center; gap: 0.25rem;
  padding: var(--space-4) var(--space-2);
  min-width: 0;
  background: hsla(165, 25%, 16%, 0.7);
  border: 1.5px solid hsla(220, 20%, 30%, 0.2);
  border-radius: var(--radius-lg);
  cursor: pointer; color: var(--color-text-muted);
  transition: background 200ms ease, border-color 200ms ease, transform 200ms var(--ease-bounce), box-shadow 200ms ease;
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  position: relative; overflow: hidden;
}
.dur-btn::before {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(135deg, hsla(var(--warm-hue), 80%, 55%, 0.08) 0%, transparent 60%);
  opacity: 0; transition: opacity 200ms ease; border-radius: inherit;
}
@media (hover: hover) and (pointer: fine) {
  .dur-btn:hover { background: hsla(165, 25%, 22%, 0.8); border-color: hsla(var(--warm-hue), 60%, 50%, 0.3); transform: translateY(-2px); box-shadow: 0 4px 16px hsla(165, 40%, 3%, 0.4); }
  .dur-btn:hover::before { opacity: 1; }
}
.dur-btn:active { transform: scale(0.96); }
.dur-btn.is-selected {
  background: hsla(var(--warm-hue), 55%, 18%, 0.6);
  border-color: hsla(var(--warm-hue), 80%, 60%, 0.55);
  color: var(--color-text-primary);
  box-shadow: 0 0 20px hsla(var(--warm-hue), 80%, 60%, 0.2), 0 4px 16px hsla(165, 40%, 3%, 0.4);
}
.dur-btn.is-selected::before { opacity: 1; }
.dur-time { font-family: var(--font-display); font-size: var(--text-lg); font-weight: 700; letter-spacing: -0.02em; color: inherit; }
.dur-btn.is-selected .dur-time {
  background: linear-gradient(135deg, hsl(var(--warm-hue), 90%, 68%), hsl(160, 42%, 58%));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}
.dur-desc { font-family: var(--font-body); font-size: 0.65rem; color: var(--color-text-dim); font-weight: 400; letter-spacing: 0.02em; white-space: normal; text-align: center; }
.dur-btn.is-selected .dur-desc { color: var(--color-text-muted); }
.dur-best { font-family: var(--font-display); font-size: 0.6rem; font-weight: 600; color: hsl(var(--warm-hue), 80%, 60%); min-height: 0.8em; }
.dur-best:empty { opacity: 0; }

.start-footer { display: flex; justify-content: center; }
.begin-btn {
  display: flex; align-items: center; gap: var(--space-3);
  padding: 1rem 2.5rem; border: none; border-radius: var(--radius-full);
  background: linear-gradient(135deg, hsl(var(--warm-hue), 85%, 58%) 0%, hsl(160, 42%, 52%) 100%);
  color: hsl(165, 40%, 8%);
  font-family: var(--font-display); font-size: var(--text-md); font-weight: 600;
  cursor: pointer; letter-spacing: -0.01em;
  box-shadow: 0 0 40px hsla(var(--warm-hue), 85%, 58%, 0.4), 0 4px 20px hsla(165, 40%, 3%, 0.5);
  transition: transform 200ms var(--ease-bounce), box-shadow 200ms ease;
  position: relative; overflow: hidden;
}
@media (hover: hover) and (pointer: fine) {
  .begin-btn:hover { transform: scale(1.04) translateY(-1px); box-shadow: 0 0 60px hsla(var(--warm-hue), 85%, 58%, 0.55), 0 6px 30px hsla(165, 40%, 3%, 0.6); }
}
.begin-btn:active { transform: scale(0.97); }
.btn-icon { font-size: 1.15em; }

/* ════════════ PLAY SCREEN ════════════ */
#screen-play { position: fixed; inset: 0; display: flex; flex-direction: column; z-index: 1; }

.play-header { display: flex; align-items: center; padding: max(env(safe-area-inset-top), 1rem) var(--space-5) var(--space-3); gap: var(--space-4); z-index: 10; position: relative; }
.hud {
  flex: 1; display: flex; align-items: center; justify-content: space-between; gap: var(--space-4);
  background: hsla(165, 30%, 11%, 0.6);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border: 1px solid hsla(220, 20%, 40%, 0.15);
  border-radius: var(--radius-full);
  padding: var(--space-2) var(--space-5);
}
.hud-score-col { display: flex; flex-direction: column; align-items: center; gap: 2px; min-width: 70px; }
.hud-score, .hud-glow { display: flex; flex-direction: column; align-items: center; min-width: 60px; gap: 4px; }
.glow-bar {
  width: 52px; height: 8px; border-radius: var(--radius-full);
  background: hsla(220, 15%, 30%, 0.5); overflow: hidden;
  border: 1px solid hsla(220, 20%, 40%, 0.15);
}
.glow-fill {
  height: 100%; width: 100%; border-radius: inherit;
  background: linear-gradient(to right, hsl(40, 90%, 55%), hsl(48, 95%, 68%));
  box-shadow: 0 0 8px hsla(45, 95%, 60%, 0.6);
  transition: width 220ms linear, background 400ms ease;
}
.glow-bar.is-low .glow-fill {
  background: linear-gradient(to right, hsl(20, 85%, 50%), hsl(30, 90%, 58%));
  animation: fcGlowBarLow 1.6s ease-in-out infinite;
}
@keyframes fcGlowBarLow { 0%, 100% { opacity: 1; } 50% { opacity: 0.6; } }
.hud-best-row { display: flex; align-items: center; gap: 3px; opacity: 0.7; }
.hud-label { font-family: var(--font-display); font-size: 0.6rem; text-transform: uppercase; letter-spacing: 0.12em; color: var(--color-text-dim); font-weight: 500; }
.hud-val { font-family: var(--font-display); font-size: var(--text-lg); font-weight: 600; color: var(--color-text-primary); line-height: 1.1; transition: transform 150ms var(--ease-bounce), color 300ms; }
.hud-val.pop-anim { transform: scale(1.25); color: hsl(var(--warm-hue), 85%, 65%); }
.hud-best-label { font-family: var(--font-display); font-size: 0.52rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--color-text-dim); font-weight: 500; }
.hud-best-val { font-family: var(--font-display); font-size: 0.62rem; font-weight: 600; color: hsl(var(--warm-hue), 80%, 62%); }

.timer-ring { position: relative; width: 48px; height: 48px; flex-shrink: 0; }
.timer-svg { width: 48px; height: 48px; transform: rotate(-90deg); }
.timer-track { fill: none; stroke: hsla(220, 20%, 25%, 0.5); stroke-width: 3; }
.timer-arc { fill: none; stroke: hsl(var(--warm-hue), 80%, 60%); stroke-width: 3; stroke-linecap: round; stroke-dasharray: 113.1; stroke-dashoffset: 0; transition: stroke-dashoffset 1s linear, stroke 1s ease; }
.timer-num { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-family: var(--font-display); font-size: 0.68rem; font-weight: 600; color: var(--color-text-primary); }

.music-toggle {
  display: flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border: none; border-radius: var(--radius-full);
  background: hsla(165, 25%, 22%, 0.6);
  border: 1px solid hsla(220, 20%, 40%, 0.15);
  font-size: 1rem; opacity: 0.5; cursor: pointer;
  transition: opacity 200ms ease, background 200ms ease;
}
.music-toggle.is-on { opacity: 1; background: hsla(var(--warm-hue), 55%, 22%, 0.6); }

/* ── Scene — the single decision point ── */
.scene {
  flex: 1; position: relative; overflow: hidden;
  display: flex; align-items: flex-end; justify-content: center;
  cursor: pointer;
}
.scene.is-ending { transition: opacity 1200ms var(--ease-out-expo); opacity: 0; }

/* ── Deep-forest backdrop — layered treelines against a moonlit haze, not
   an abstract gradient. Built to read clearly as a forest *from the very
   first second* (stage 0), then deepen as the difficulty tier rises.
   The key to legibility: a lighter horizon-glow band sits BEHIND the
   trees so their dark silhouettes actually stand out. ── */
.sky {
  position: absolute; inset: 0; z-index: -1; overflow: hidden;
  transition: background 3s ease;
  background:
    radial-gradient(120% 60% at 50% 100%, hsla(160, 45%, 22%, 0.55) 0%, transparent 60%),
    linear-gradient(to top, hsl(158, 32%, 9%) 0%, hsl(168, 30%, 12%) 45%, hsl(196, 32%, 15%) 100%);
}
.sky.stage-1 { background:
    radial-gradient(120% 60% at 50% 100%, hsla(158, 48%, 25%, 0.6) 0%, transparent 60%),
    linear-gradient(to top, hsl(156, 34%, 10%) 0%, hsl(166, 32%, 13%) 45%, hsl(198, 34%, 17%) 100%); }
.sky.stage-2 { background:
    radial-gradient(120% 62% at 50% 100%, hsla(154, 50%, 27%, 0.62) 0%, transparent 60%),
    linear-gradient(to top, hsl(152, 36%, 11%) 0%, hsl(164, 34%, 15%) 45%, hsl(202, 38%, 19%) 100%); }
.sky.stage-3 { background:
    radial-gradient(120% 64% at 50% 100%, hsla(150, 52%, 30%, 0.66) 0%, transparent 60%),
    linear-gradient(to top, hsl(150, 38%, 12%) 0%, hsl(162, 36%, 17%) 45%, hsl(206, 42%, 22%) 100%); }

/* Pre-dawn — the final stretch warms toward sunrise (a positive "almost
   there" cue). Overrides whatever tier gradient is active; long transition. */
.sky.is-predawn {
  background:
    radial-gradient(130% 75% at 50% 100%, hsla(28, 70%, 45%, 0.6) 0%, transparent 62%),
    linear-gradient(to top, hsl(30, 45%, 18%) 0%, hsl(20, 40%, 20%) 35%, hsl(210, 45%, 30%) 100%) !important;
  transition: background 18s ease;
}

/* Far treeline — taller, hazier, set a touch lighter so it reads as
   distant treetops behind the near woods. */
.forest-canopy-far {
  position: absolute; left: 0; right: 0; bottom: 0; height: 46%;
  background: hsl(166, 30%, 9%);
  opacity: 0.9;
  clip-path: polygon(
    0% 100%, 0% 52%, 5% 64%, 9% 44%, 14% 60%, 19% 38%, 24% 56%, 29% 42%,
    34% 60%, 39% 36%, 44% 58%, 50% 40%, 55% 60%, 61% 38%, 66% 56%,
    71% 42%, 76% 60%, 81% 38%, 86% 58%, 91% 44%, 96% 62%, 100% 50%, 100% 100%
  );
}

/* Near treeline — the darkest, closest band of woods. */
.sky-hills {
  position: absolute; left: 0; right: 0; bottom: 0; height: 32%;
  background: hsl(158, 38%, 5%);
  clip-path: polygon(
    0% 100%, 0% 50%, 5% 72%, 9% 40%, 13% 66%, 18% 34%, 23% 62%, 28% 38%,
    33% 64%, 38% 32%, 43% 60%, 48% 40%, 53% 66%, 58% 34%, 63% 60%,
    68% 38%, 73% 64%, 78% 36%, 83% 62%, 88% 40%, 93% 66%, 98% 44%, 100% 60%, 100% 100%
  );
}

/* Foreground trunk framing both edges — a couple of dark trunks you're
   peering between, with a soft inner edge so they don't look like flat bars. */
.forest-trunks { position: absolute; inset: 0; pointer-events: none; }
.forest-trunks::before, .forest-trunks::after {
  content: ''; position: absolute; top: -8%; bottom: 0; width: 13%;
  background:
    linear-gradient(to right, hsl(158, 40%, 4%) 0%, hsl(155, 35%, 6%) 45%, transparent 100%);
}
.forest-trunks::before { left: 0; }
.forest-trunks::after  { right: 0; transform: scaleX(-1); }

/* A soft fog band drifting slowly near the forest floor. */
.forest-fog {
  position: absolute; left: -20%; right: -20%; bottom: 6%; height: 32%;
  background: linear-gradient(to top, hsla(160, 30%, 72%, 0.10), transparent);
  filter: blur(7px);
  animation: fcFogDrift 26s ease-in-out infinite alternate;
}
@keyframes fcFogDrift { from { transform: translateX(0); } to { transform: translateX(6%); } }

.sky-moon {
  position: absolute; top: 9%; right: 14%;
  width: 34px; height: 34px; border-radius: 50%;
  background: radial-gradient(circle at 38% 35%, hsl(50, 35%, 92%), hsl(45, 30%, 82%));
  box-shadow: 0 0 34px 6px hsla(48, 40%, 82%, 0.28);
  opacity: 0.4; transition: opacity 2.5s ease;
}
.sky.stage-1 .sky-moon { opacity: 0.55; }
.sky.stage-2 .sky-moon { opacity: 0.7; }
.sky.stage-3 .sky-moon { opacity: 0.9; }

.sky-stars { position: absolute; inset: 0; opacity: 0.45; transition: opacity 2.5s ease; }
.sky.stage-1 .sky-stars { opacity: 0.6; }
.sky.stage-2 .sky-stars, .sky.stage-3 .sky-stars { opacity: 0.85; }
/* A handful of fixed-position star dots via box-shadow — cheaper than DOM nodes. */
.sky-stars::before {
  content: ''; position: absolute; inset: 0;
  background-image:
    radial-gradient(1.5px 1.5px at 12% 14%, white, transparent),
    radial-gradient(1px 1px at 28% 8%, white, transparent),
    radial-gradient(1.5px 1.5px at 45% 16%, white, transparent),
    radial-gradient(1px 1px at 62% 6%, white, transparent),
    radial-gradient(1.5px 1.5px at 78% 12%, white, transparent),
    radial-gradient(1px 1px at 90% 20%, white, transparent),
    radial-gradient(1px 1px at 20% 26%, white, transparent),
    radial-gradient(1.5px 1.5px at 55% 24%, white, transparent),
    radial-gradient(1px 1px at 85% 30%, white, transparent);
  opacity: 0.7;
}

/* Dawn: the scene warms and brightens to morning instead of fading to
   black, so the *win* feels visually distinct from the gentle loss. */
.scene.is-dawn {
  transition: opacity 1300ms var(--ease-out-expo);
}
.scene.is-dawn::after {
  content: ''; position: absolute; inset: 0; z-index: 8; pointer-events: none;
  background: linear-gradient(to top, hsla(38, 80%, 70%, 0.5) 0%, hsla(45, 70%, 80%, 0.35) 40%, hsla(200, 50%, 80%, 0.25) 100%);
  animation: fcDawnRise 1300ms var(--ease-out-expo) forwards;
}
@keyframes fcDawnRise { from { opacity: 0; } to { opacity: 1; } }

/* ── Decorative deep-forest motes — tiny, dim, blurred, non-interactive.
   Much smaller/dimmer than gameplay fireflies so they're never mistaken
   for catchable ones. ── */
.mote-layer { position: absolute; inset: 0; pointer-events: none; z-index: 0; }
.forest-mote {
  position: absolute; width: 2.5px; height: 2.5px; border-radius: 50%;
  background: hsla(50, 80%, 75%, 0.5);
  box-shadow: 0 0 4px hsla(48, 85%, 65%, 0.5);
  filter: blur(0.4px);
  animation: fcMoteDrift 6s ease-in-out infinite alternate;
}
@keyframes fcMoteDrift {
  0%   { transform: translate(0, 0); opacity: 0.25; }
  50%  { opacity: 0.7; }
  100% { transform: translate(var(--drift-x, 10px), var(--drift-y, -12px)); opacity: 0.3; }
}

/* ── The night closes in as your light fails — a vignette (darker edges,
   readable centre), opacity driven by JS from (1 - glow). ── */
.night-veil {
  position: absolute; inset: 0; z-index: 3; pointer-events: none;
  opacity: 0;
  background: radial-gradient(120% 95% at 50% 88%, transparent 32%, hsla(155, 45%, 3%, 0.7) 78%, hsl(155, 50%, 2%) 100%);
  transition: opacity 220ms linear;
}

/* ── Lantern — caught fireflies fly here and hoard; its glow is your life.
   The light *level* inside visibly fills/recedes with --glow (set by JS
   each frame), so the player always sees how full it is and when it's
   nearly out. Sits low-centre, deliberately prominent. ── */
.lantern {
  --glow: 1;
  position: absolute; bottom: 4%; left: 50%; transform: translateX(-50%);
  width: 64px; height: 96px; z-index: 4; pointer-events: none;
}
.lantern-glow {
  position: absolute; left: 50%; top: 44%; transform: translate(-50%, -50%);
  width: 150px; height: 150px; border-radius: 50%;
  background: radial-gradient(circle, hsla(var(--warm-hue), 90%, 60%, calc(0.6 * var(--glow))), transparent 68%);
  filter: blur(4px);
  transition: opacity 300ms ease;
}
.lantern-cage {
  position: absolute; left: 50%; top: 9px; transform: translateX(-50%);
  width: 42px; height: 62px;
  border: 2px solid hsl(40, 32%, 46%);
  border-radius: 9px 9px 13px 13px;
  background: hsla(40, 22%, 10%, 0.55);
  box-shadow: inset 0 0 12px hsla(0, 0%, 0%, 0.55);
  overflow: hidden;
  transition: border-color 300ms ease, background 300ms ease;
}
/* The actual light level — a warm fill anchored to the bottom whose HEIGHT
   is the glow. This is the clear "fuel gauge": it recedes as glow drains
   and rises on every catch. */
.lantern-fill {
  position: absolute; left: 0; right: 0; bottom: 0;
  height: calc(var(--glow) * 100%);
  background: linear-gradient(to top, hsl(36, 95%, 56%), hsl(45, 98%, 68%) 65%, hsla(48, 100%, 86%, 0.95));
  box-shadow: 0 0 18px hsla(42, 95%, 60%, 0.85);
  transition: height 200ms linear, filter 300ms ease;
}
/* A soft flame tip riding the top of the fill. */
.lantern-fill::after {
  content: ''; position: absolute; left: 50%; top: -6px; transform: translateX(-50%);
  width: 16px; height: 13px; border-radius: 50% 50% 48% 48%;
  background: radial-gradient(circle at 50% 70%, hsl(48, 100%, 88%), hsl(38, 95%, 60%) 65%, transparent 80%);
  filter: blur(1px);
}
/* The wire top loop. */
.lantern::before {
  content: ''; position: absolute; left: 50%; top: 0; transform: translateX(-50%);
  width: 16px; height: 11px; border: 2px solid hsl(40, 32%, 46%);
  border-bottom: none; border-radius: 9px 9px 0 0;
}
.lantern-base {
  position: absolute; left: 50%; top: 69px; transform: translateX(-50%);
  width: 48px; height: 9px; border-radius: 0 0 6px 6px;
  background: hsl(38, 28%, 30%);
}
/* Firefly dots inside the lamp: how many GLOW tracks the current light
   level (set by JS each frame). They wink out from the top as it fades and
   relight as you feed it — so the lamp never shows a stale total. */
.lantern-jar { position: absolute; inset: 0; }
.lantern-dot {
  position: absolute; width: 3.5px; height: 3.5px; border-radius: 50%;
  background: hsl(40, 20%, 40%);
  box-shadow: none;
  opacity: 0.35;
  transition: opacity 260ms ease, background 260ms ease, box-shadow 260ms ease;
}
.lantern-dot.is-lit {
  background: hsl(48, 100%, 86%);
  box-shadow: 0 0 5px hsla(45, 95%, 70%, 0.95);
  opacity: 1;
  animation: fcLanternDot 2.4s ease-in-out infinite alternate;
}
@keyframes fcLanternDot {
  from { transform: translate(0, 0); }
  to   { transform: translate(2px, -2px); }
}
.lantern.is-bump { animation: fcLanternBump 360ms var(--ease-bounce); }
@keyframes fcLanternBump {
  0% { transform: translateX(-50%) scale(1); }
  40% { transform: translateX(-50%) scale(1.1); }
  100% { transform: translateX(-50%) scale(1); }
}
/* Low: the flame gutters gently (slow, soft brightness sway — not a flash)
   and the cage takes a warning tint. */
.lantern.is-low .lantern-cage { border-color: hsl(26, 60%, 50%); }
.lantern.is-low .lantern-fill { animation: fcFlameGutter 900ms ease-in-out infinite; }
@keyframes fcFlameGutter { 0%, 100% { filter: brightness(1); } 50% { filter: brightness(0.8); } }
/* Out: the light is gone — cage dark, halo extinguished. */
.lantern.is-out .lantern-fill { height: 0 !important; }
.lantern.is-out .lantern-glow { opacity: 0; }
.lantern.is-out .lantern-cage { border-color: hsl(220, 8%, 30%); background: hsla(220, 12%, 7%, 0.7); }

/* ── Live fireflies + wisps — position is driven entirely by JS
   (translate transform set per-frame from the movement engine), so no
   CSS keyframe animates their location. ── */
.firefly-stage { position: absolute; inset: 0; pointer-events: none; }

.firefly-entity {
  position: absolute; left: 0; top: 0;
  width: 28px; height: 28px; margin: -14px 0 0 -14px;
  will-change: transform;
}
/* A gentle body sway, so each firefly bobs as it flies. */
.firefly-entity .firefly-body {
  position: absolute; left: 50%; top: 50%;
  width: 7px; height: 13px; margin: -7px 0 0 -3.5px;
  border-radius: 46% 46% 50% 50% / 36% 36% 64% 64%;
  background: linear-gradient(to bottom, hsl(30, 16%, 32%) 0%, hsl(28, 14%, 20%) 50%, hsl(34, 30%, 26%) 100%);
  transform-origin: center center;
  animation: fcBodySway 2.4s ease-in-out infinite;
}
@keyframes fcBodySway { 0%, 100% { transform: rotate(-6deg); } 50% { transform: rotate(6deg); } }

/* Ambient halo — faint even when dark, so a real firefly is a tiny visible
   bug at night rather than truly invisible. */
.firefly-entity .firefly-glow {
  position: absolute; inset: -12px; border-radius: 50%;
  filter: blur(3px);
  background: radial-gradient(circle, hsla(42, 60%, 60%, 0.12), transparent 62%);
  transition: background 200ms ease;
}

/* Two translucent wings flanking the thorax, fluttering constantly — this,
   plus the segmented body and glowing tail, is what reads as "firefly"
   rather than "ball of light." */
.firefly-entity .firefly-wing {
  position: absolute; top: 2px;
  width: 9px; height: 6px; border-radius: 60% 60% 55% 55%;
  background: hsla(55, 35%, 90%, 0.20);
  animation: fcWingFlutter 150ms ease-in-out infinite;
}
.firefly-entity .firefly-wing.wing-l { left: 50%; margin-left: -10px; transform-origin: right center; }
.firefly-entity .firefly-wing.wing-r { left: 50%; margin-left: 1px;  transform-origin: left center;  animation-delay: -75ms; }
@keyframes fcWingFlutter { 0%, 100% { transform: scaleX(1) rotate(0deg); } 50% { transform: scaleX(0.5) rotate(10deg); } }

/* The glowing abdomen (tail) — the lit/dark signal lives here. A faint
   amber ember when dim, a bright gold lantern-flame when lit. */
.firefly-entity .firefly-abdomen {
  position: absolute; left: 50%; top: 50%;
  width: 6px; height: 7px; margin: 1px 0 0 -3px;
  border-radius: 50% 50% 60% 60%;
  background: radial-gradient(circle at 50% 35%, hsla(44, 85%, 72%, 0.6), hsla(36, 60%, 42%, 0.28));
  box-shadow: 0 0 5px hsla(42, 80%, 55%, 0.4);
  transition: background 200ms ease, box-shadow 200ms ease, transform 200ms ease;
  animation: fcEmber 1.9s ease-in-out infinite;
}
@keyframes fcEmber { 0%, 100% { opacity: 0.55; } 50% { opacity: 0.85; } }

/* A real firefly that's lit — the one moment it's catchable. */
.firefly-entity.is-lit:not(.is-decoy) .firefly-glow {
  background: radial-gradient(circle, hsla(var(--warm-hue), 92%, 62%, 0.6), transparent 70%);
}
.firefly-entity.is-lit:not(.is-decoy) .firefly-abdomen {
  background: radial-gradient(circle at 50% 35%, hsl(48, 100%, 88%), hsl(40, 95%, 60%));
  box-shadow: 0 0 16px 3px hsla(42, 95%, 60%, 0.9);
  transform: scale(1.25);
  animation: none;
}

/* A wisp — a hazy, formless drift of cool light with no body or wings,
   reinforcing that it isn't really an insect. Always "on", flickery. */
.firefly-entity.is-decoy .firefly-body,
.firefly-entity.is-decoy .firefly-wing,
.firefly-entity.is-decoy .firefly-abdomen { opacity: 0; }
.firefly-entity.is-decoy .firefly-glow {
  inset: -18px;
  filter: blur(6px);
  background: radial-gradient(circle, hsla(var(--decoy-hue, 208), 65%, 65%, 0.5), transparent 75%);
  animation: fcWispFlicker 420ms ease-in-out infinite;
}
@keyframes fcWispFlicker { 0%, 100% { opacity: 1; } 50% { opacity: 0.58; } }

/* A caught firefly flies into the lantern (JS sets the transform to the
   lantern's position), shrinking and fading as it arrives. */
.firefly-entity.is-caught {
  transition: transform 460ms var(--ease-out-expo), opacity 460ms ease;
  opacity: 0;
}
.firefly-entity.is-caught .firefly-body,
.firefly-entity.is-caught .firefly-wing { animation: none; }

/* An expiring special firefly fades out gently. */
.firefly-entity.is-leaving { transition: opacity 360ms ease; opacity: 0; }

/* ── Special: the GOLDEN firefly — bigger, richer, with a soft pulsing
   crown of light. A treat to spot and net. ── */
.firefly-entity.is-golden { transform-box: fill-box; }
.firefly-entity.is-golden .firefly-glow {
  inset: -22px; filter: blur(4px);
  background: radial-gradient(circle, hsla(46, 100%, 65%, 0.85), transparent 68%);
  animation: fcGoldenPulse 1.1s ease-in-out infinite;
}
.firefly-entity.is-golden .firefly-body {
  width: 10px; height: 17px; margin: -9px 0 0 -5px;
  background: linear-gradient(to bottom, hsl(45, 95%, 60%), hsl(40, 90%, 48%) 55%, hsl(48, 100%, 70%));
}
.firefly-entity.is-golden .firefly-abdomen {
  width: 11px; height: 12px; margin-left: -5.5px;
  background: radial-gradient(circle at 50% 35%, hsl(50, 100%, 92%), hsl(44, 98%, 62%));
  box-shadow: 0 0 22px 5px hsla(46, 100%, 62%, 0.95);
  animation: none;
}
.firefly-entity.is-golden .firefly-wing { background: hsla(48, 80%, 90%, 0.3); width: 12px; }
@keyframes fcGoldenPulse { 0%, 100% { opacity: 0.8; transform: scale(1); } 50% { opacity: 1; transform: scale(1.12); } }

/* ── Special: the COMET — an elongated streak with a trailing tail. ── */
.firefly-entity.is-comet .firefly-glow {
  inset: -10px; filter: blur(2px);
  background: radial-gradient(circle, hsla(50, 100%, 75%, 0.9), transparent 70%);
}
.firefly-entity.is-comet .firefly-wing { display: none; }
.firefly-entity.is-comet .firefly-body {
  width: 7px; height: 7px; margin: -3.5px 0 0 -3.5px; border-radius: 50%;
  background: radial-gradient(circle at 40% 35%, hsl(52, 100%, 92%), hsl(44, 98%, 64%));
  box-shadow: 0 0 12px 3px hsla(48, 100%, 66%, 0.9);
}
.firefly-entity.is-comet .firefly-abdomen { display: none; }
/* The tail streams opposite the travel direction. */
.firefly-entity.is-comet::after {
  content: ''; position: absolute; left: 50%; top: 50%;
  width: 46px; height: 4px; margin-top: -2px;
  transform: translateX(-100%) rotate(calc(var(--comet-angle, 0deg) + 180deg));
  transform-origin: right center;
  background: linear-gradient(to left, hsla(48, 100%, 70%, 0.85), transparent);
  filter: blur(1.5px); border-radius: 2px;
}

/* ── Positive-only tier breakthrough announcement ── */
.breakthrough-toast {
  position: absolute; top: 14%; left: 50%; transform: translate(-50%, -10px);
  background: hsla(var(--warm-hue), 55%, 20%, 0.85);
  border: 1px solid hsla(var(--warm-hue), 80%, 60%, 0.4);
  border-radius: var(--radius-full);
  padding: 0.6rem 1.2rem;
  font-family: var(--font-display); font-size: var(--text-sm); font-weight: 600;
  color: hsl(var(--warm-hue), 85%, 80%);
  white-space: nowrap;
  opacity: 0; pointer-events: none;
  transition: opacity 400ms var(--ease-out-expo), transform 400ms var(--ease-out-expo);
  z-index: 7;
}
.breakthrough-toast.is-visible { opacity: 1; transform: translate(-50%, 0); }
/* Milestone captions read as quiet ambient narration, not an announcement. */
.breakthrough-toast.is-caption {
  background: hsla(220, 25%, 14%, 0.7);
  border-color: hsla(220, 25%, 60%, 0.25);
  color: hsl(220, 25%, 82%);
  font-weight: 500; font-style: italic; font-size: var(--text-xs);
}

/* ── Visible combo build — a satisfying escalation; positive-only. ── */
.combo-meter {
  position: absolute; top: 12%; right: 8%;
  display: flex; flex-direction: column; align-items: center; line-height: 1;
  padding: 0.35rem 0.7rem; border-radius: var(--radius-lg);
  background: hsla(var(--warm-hue), 50%, 18%, 0.5);
  border: 1px solid hsla(var(--warm-hue), 70%, 55%, 0.35);
  opacity: 0; transform: scale(0.8) translateY(-6px); pointer-events: none; z-index: 7;
  transition: opacity 220ms ease, transform 220ms var(--ease-bounce), background 300ms ease, border-color 300ms ease;
}
.combo-meter.is-visible { opacity: 1; transform: scale(1) translateY(0); }
.combo-meter .combo-x { font-family: var(--font-display); font-size: 0.5rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.14em; color: hsl(var(--warm-hue), 60%, 72%); }
.combo-meter .combo-val { font-family: var(--font-display); font-weight: 800; font-size: var(--text-lg); color: hsl(var(--warm-hue), 90%, 75%); }
.combo-meter.is-pop .combo-val { animation: comboPop 320ms var(--ease-bounce); }
@keyframes comboPop { 0% { transform: scale(1); } 45% { transform: scale(1.4); } 100% { transform: scale(1); } }
/* Warmer / hotter as the combo climbs. */
.combo-meter.lvl-1 { background: hsla(42, 55%, 20%, 0.55); }
.combo-meter.lvl-2 { background: hsla(36, 60%, 22%, 0.6); border-color: hsla(38, 80%, 58%, 0.5); }
.combo-meter.lvl-3 { background: hsla(28, 70%, 24%, 0.66); border-color: hsla(30, 90%, 60%, 0.6); box-shadow: 0 0 16px hsla(34, 90%, 55%, 0.3); }
.combo-meter.lvl-4 { background: hsla(20, 80%, 26%, 0.72); border-color: hsla(24, 95%, 62%, 0.7); box-shadow: 0 0 24px hsla(30, 95%, 58%, 0.45); }
.combo-meter.lvl-3 .combo-val, .combo-meter.lvl-4 .combo-val { color: hsl(38, 100%, 82%); }

/* The lantern blazes brighter while a big combo is going. */
.lantern.is-blazing .lantern-glow { filter: blur(4px) brightness(1.5); }
.lantern.is-blazing .lantern-fill { filter: brightness(1.35); box-shadow: 0 0 26px hsla(42, 100%, 62%, 0.95); }

/* Golden-catch flourish sparks. */
.flourish-spark {
  position: absolute; width: 5px; height: 5px; border-radius: 50%;
  background: radial-gradient(circle, hsl(50, 100%, 88%), hsl(44, 98%, 62%));
  box-shadow: 0 0 6px hsla(46, 100%, 65%, 0.9);
  transform: translate(-50%, -50%);
  animation: flourishFly 760ms var(--ease-out-expo) forwards;
}
@keyframes flourishFly {
  0% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  100% { opacity: 0; transform: translate(calc(-50% + var(--fx)), calc(-50% + var(--fy))) scale(0.3); }
}

/* ── One-time gentle low-lantern nudge — explains the cause→fix (catch to
   refuel) so a loss never feels like it came from nowhere. Warm, calm. ── */
.low-nudge {
  position: absolute; top: 22%; left: 50%; transform: translate(-50%, -10px);
  max-width: 80%; text-align: center;
  background: hsla(28, 55%, 22%, 0.9);
  border: 1px solid hsla(32, 80%, 60%, 0.45);
  border-radius: var(--radius-lg);
  padding: 0.6rem 1.1rem;
  font-family: var(--font-display); font-size: var(--text-sm); font-weight: 600;
  color: hsl(36, 90%, 82%);
  opacity: 0; pointer-events: none;
  transition: opacity 350ms var(--ease-out-expo), transform 350ms var(--ease-out-expo);
  z-index: 7;
}
.low-nudge.is-visible { opacity: 1; transform: translate(-50%, 0); }

/* ── Per-tap feedback — every tap gets a response, regardless of outcome. ── */
.catch-fx-layer { position: absolute; inset: 0; pointer-events: none; z-index: 6; }

/* The net — swings down over wherever you tapped. The hoop catches, the
   handle gives it a tool-like feel and the connection to hoarding. */
.net-swing {
  position: absolute; transform: translate(-50%, -50%);
  width: 44px; height: 44px;
  transform-origin: 70% 0%;
  animation: fcNetSwing var(--net-ms, 440ms) var(--ease-out-expo) forwards;
}
.net-swing .net-hoop {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: 34px; height: 34px; border-radius: 50%;
  border: 2.5px solid hsla(40, 35%, 75%, 0.9);
  background: radial-gradient(circle, hsla(45, 40%, 85%, 0.10), transparent 70%);
  box-shadow: 0 0 10px hsla(45, 60%, 70%, 0.3);
}
/* A faint mesh inside the hoop. */
.net-swing .net-hoop::after {
  content: ''; position: absolute; inset: 3px; border-radius: 50%;
  background-image:
    repeating-linear-gradient(45deg, hsla(45, 30%, 80%, 0.20) 0 1px, transparent 1px 5px),
    repeating-linear-gradient(-45deg, hsla(45, 30%, 80%, 0.20) 0 1px, transparent 1px 5px);
}
.net-swing .net-handle {
  position: absolute; left: 64%; top: 50%;
  width: 3px; height: 22px; border-radius: 2px;
  background: linear-gradient(to bottom, hsl(34, 35%, 52%), hsl(32, 30%, 38%));
  transform: rotate(38deg); transform-origin: top center;
}
@keyframes fcNetSwing {
  0%   { transform: translate(-50%, -50%) rotate(-42deg) scale(0.7); opacity: 0; }
  35%  { transform: translate(-50%, -50%) rotate(6deg) scale(1.05); opacity: 1; }
  60%  { transform: translate(-50%, -50%) rotate(-4deg) scale(1); opacity: 1; }
  100% { transform: translate(-50%, -50%) rotate(0deg) scale(0.92); opacity: 0; }
}

.tap-fx {
  position: absolute; transform: translate(-50%, -50%);
  width: 40px; height: 40px; border-radius: 50%;
  pointer-events: none;
  animation: confirmRingExpand 600ms var(--ease-out-expo) forwards;
}
.tap-fx-catch { border: 2px solid hsla(var(--warm-hue), 90%, 65%, 0.85); }
.tap-fx-decoy { border: 2px solid hsla(208, 50%, 70%, 0.6); }
.tap-fx-miss  { border: 2px solid hsla(220, 20%, 60%, 0.3); }

.tap-popup {
  position: absolute; transform: translate(-50%, -50%);
  font-family: var(--font-display); font-weight: 700;
  font-size: var(--text-lg);
  color: hsl(var(--warm-hue), 90%, 72%);
  text-shadow: 0 2px 12px hsla(var(--warm-hue), 90%, 60%, 0.6);
  pointer-events: none;
  animation: tapPopupFloat 900ms var(--ease-out-expo) forwards;
}
@keyframes tapPopupFloat {
  0%   { transform: translate(-50%, -50%) scale(0.7); opacity: 0; }
  20%  { transform: translate(-50%, -65%) scale(1); opacity: 1; }
  100% { transform: translate(-50%, -130%) scale(0.9); opacity: 0; }
}
/* Bigger, warmer popups as the combo climbs. */
.tap-popup.lvl-1 { font-size: calc(var(--text-lg) * 1.1); }
.tap-popup.lvl-2 { font-size: calc(var(--text-lg) * 1.25); color: hsl(40, 95%, 74%); }
.tap-popup.lvl-3 { font-size: calc(var(--text-lg) * 1.4); color: hsl(32, 100%, 76%); }
.tap-popup.lvl-4 { font-size: calc(var(--text-lg) * 1.6); color: hsl(26, 100%, 78%); }
.tap-popup .popup-mult { font-size: 0.62em; margin-left: 0.15em; opacity: 0.9; vertical-align: super; }

.confirm-ring {
  position: absolute; transform: translate(-50%, -50%);
  width: 40px; height: 40px; border-radius: 50%;
  border: 2px solid hsla(150, 55%, 65%, 0.8);
  pointer-events: none;
  animation: confirmRingExpand 600ms var(--ease-out-expo) forwards;
}
@keyframes confirmRingExpand {
  0%   { transform: translate(-50%, -50%) scale(0.4); opacity: 0.9; }
  100% { transform: translate(-50%, -50%) scale(2.1); opacity: 0; }
}

/* ── Bloom layer (soft session-completion celebration, same technique as Zen's fixed-mode bloom) ── */
.bloom-layer { position: fixed; inset: 0; pointer-events: none; z-index: 5; }
.bloom-piece { position: absolute; border-radius: 50%; pointer-events: none; filter: blur(0.5px); animation: bloomDrift var(--dur, 1600ms) var(--ease-out-expo) forwards; }
@keyframes bloomDrift {
  0%   { transform: translate(-50%, -50%) scale(0.4); opacity: 0; }
  15%  { opacity: 0.85; }
  100% { transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(1.1); opacity: 0; }
}

/* ════════════ END OVERLAY (shared shape with Pop Spiral, retheme only) ════════════ */
.overlay {
  position: fixed; inset: 0; z-index: 20;
  display: flex; align-items: flex-start; justify-content: center;
  padding: max(env(safe-area-inset-top), var(--space-6)) var(--space-6) max(env(safe-area-inset-bottom), var(--space-6));
  overflow-y: auto;
  opacity: 0; pointer-events: none;
  transition: opacity 400ms var(--ease-out-expo);
}
.overlay.is-visible { opacity: 1; pointer-events: all; }
.overlay-bg { position: absolute; inset: 0; background: hsla(165, 35%, 5%, 0.85); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); pointer-events: none; }
.overlay-card {
  position: relative; background: hsl(165, 28%, 12%);
  border: 1px solid hsla(220, 20%, 40%, 0.2); border-radius: var(--radius-xl);
  padding: var(--space-10) var(--space-8); text-align: center;
  max-width: 380px; width: 100%;
  box-shadow: 0 24px 80px hsla(165, 40%, 3%, 0.7), 0 0 0 1px hsla(220, 20%, 40%, 0.08);
  animation: cardSlideIn 500ms var(--ease-bounce) both;
}
@keyframes cardSlideIn { from { transform: translateY(30px) scale(0.94); opacity: 0; } to { transform: translateY(0) scale(1); opacity: 1; } }
.overlay-emoji { font-size: 3.5rem; display: block; margin-bottom: var(--space-4); animation: emojiPulse 2s ease-in-out infinite; }
@keyframes emojiPulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.12); } }
.overlay-title {
  font-family: var(--font-display); font-size: var(--text-2xl); font-weight: 600; letter-spacing: -0.02em; margin-bottom: var(--space-3);
  background: linear-gradient(135deg, hsl(var(--warm-hue), 90%, 68%), hsl(160, 42%, 58%));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}
.overlay-msg { font-size: var(--text-sm); color: var(--color-text-muted); line-height: 1.65; margin-bottom: var(--space-8); font-weight: 300; }
.overlay-score-display { display: flex; align-items: stretch; gap: 0; background: hsla(165, 25%, 17%, 0.6); border: 1px solid hsla(220, 20%, 30%, 0.2); border-radius: var(--radius-lg); margin-bottom: var(--space-8); overflow: hidden; }
.final-stat { flex: 1; display: flex; flex-direction: column; align-items: center; gap: var(--space-2); padding: var(--space-5) var(--space-3); }
.final-label { font-size: 0.6rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--color-text-dim); font-family: var(--font-display); font-weight: 500; white-space: nowrap; }
.final-val { font-family: var(--font-display); font-size: var(--text-xl); font-weight: 700; color: var(--color-text-primary); letter-spacing: -0.02em; }
.final-divider { width: 1px; background: hsla(220, 20%, 30%, 0.3); align-self: stretch; }
.overlay-actions { display: flex; flex-direction: column; gap: var(--space-3); }
.btn-primary {
  width: 100%; padding: 0.9rem var(--space-6); border: none; border-radius: var(--radius-full);
  background: linear-gradient(135deg, hsl(var(--warm-hue), 85%, 58%) 0%, hsl(160, 42%, 52%) 100%);
  color: hsl(165, 40%, 8%); font-family: var(--font-display); font-size: var(--text-md); font-weight: 600;
  cursor: pointer; box-shadow: 0 0 30px hsla(var(--warm-hue), 85%, 58%, 0.35);
  transition: transform 200ms var(--ease-bounce), box-shadow 200ms ease;
}
@media (hover: hover) and (pointer: fine) {
  .btn-primary:hover { transform: translateY(-2px) scale(1.02); box-shadow: 0 0 50px hsla(var(--warm-hue), 85%, 58%, 0.5); }
}
.btn-primary:active { transform: scale(0.97); }
.btn-ghost {
  display: block; width: 100%; padding: 0.75rem var(--space-6); border-radius: var(--radius-full);
  background: transparent; border: 1px solid hsla(220, 20%, 35%, 0.25); color: var(--color-text-muted);
  font-family: var(--font-display); font-size: var(--text-sm); font-weight: 500; text-decoration: none;
  text-align: center; cursor: pointer; transition: background 200ms ease, color 200ms ease, transform 200ms ease;
}
@media (hover: hover) and (pointer: fine) {
  .btn-ghost:hover { background: hsla(220, 20%, 20%, 0.5); color: var(--color-text-primary); transform: translateY(-1px); }
}
.btn-ghost:active { transform: scale(0.98); }

.new-record-badge {
  display: none; align-items: center; justify-content: center; gap: var(--space-2);
  margin: 0 auto var(--space-5); padding: 0.5rem 1.2rem;
  background: linear-gradient(135deg, hsl(var(--warm-hue), 75%, 22%) 0%, hsl(160, 38%, 16%) 100%);
  border: 1px solid hsla(var(--warm-hue), 80%, 55%, 0.5); border-radius: var(--radius-full);
  box-shadow: 0 0 24px hsla(var(--warm-hue), 80%, 55%, 0.25);
  opacity: 0; transform: scale(0.8);
  transition: opacity 400ms var(--ease-out-expo) 200ms, transform 400ms var(--ease-bounce) 200ms;
}
.new-record-badge.is-visible { display: flex; opacity: 1; transform: scale(1); }
.record-badge-icon { font-size: 1.1rem; }
.record-badge-text { font-family: var(--font-display); font-size: var(--text-sm); font-weight: 700; color: hsl(var(--warm-hue), 85%, 75%); letter-spacing: -0.01em; }
.prev-best-line { font-family: var(--font-body); font-size: var(--text-xs); color: var(--color-text-dim); margin-bottom: var(--space-4); text-align: center; }
.next-suggestion { font-family: var(--font-body); font-size: var(--text-xs); color: var(--color-text-dim); margin-bottom: var(--space-4); text-align: center; min-height: 1em; }

/* ════════════ MILESTONE SCENE MOMENTS ════════════
   One-shot environmental flourishes as the score climbs — pure ambience,
   each self-removes after its animation. */
.milestone-fx-layer { position: absolute; inset: 0; pointer-events: none; z-index: 2; overflow: hidden; }
.milestone-fx { position: absolute; inset: 0; }

/* A shooting star arcs across the upper sky. */
.fx-shooting-star::before {
  content: ''; position: absolute; top: 12%; left: -10%;
  width: 70px; height: 2px; border-radius: 2px;
  background: linear-gradient(to left, hsla(50, 100%, 90%, 0.95), transparent);
  box-shadow: 0 0 8px hsla(50, 100%, 80%, 0.8);
  transform: rotate(18deg);
  animation: fxShootingStar 1500ms var(--ease-out-expo) forwards;
}
@keyframes fxShootingStar {
  0% { opacity: 0; transform: translate(0, 0) rotate(18deg); }
  10% { opacity: 1; }
  100% { opacity: 0; transform: translate(120vw, 38vh) rotate(18deg); }
}

/* A wave of dim glow-points wakes among the distant trees. */
.fx-distant-bloom::before {
  content: ''; position: absolute; left: 0; right: 0; bottom: 18%; height: 30%;
  background-image:
    radial-gradient(2px 2px at 10% 60%, hsla(48,90%,75%,0.9), transparent),
    radial-gradient(2px 2px at 24% 40%, hsla(48,90%,75%,0.9), transparent),
    radial-gradient(2px 2px at 38% 70%, hsla(48,90%,75%,0.9), transparent),
    radial-gradient(2px 2px at 52% 35%, hsla(48,90%,75%,0.9), transparent),
    radial-gradient(2px 2px at 66% 65%, hsla(48,90%,75%,0.9), transparent),
    radial-gradient(2px 2px at 80% 45%, hsla(48,90%,75%,0.9), transparent),
    radial-gradient(2px 2px at 92% 60%, hsla(48,90%,75%,0.9), transparent);
  opacity: 0;
  animation: fxDistantBloom 4500ms ease-in-out forwards;
}
@keyframes fxDistantBloom { 0%,100% { opacity: 0; } 25%,70% { opacity: 0.8; } }

/* Fog rolls slowly across the lower scene. */
.fx-fog-roll::before {
  content: ''; position: absolute; left: -60%; bottom: 0; width: 90%; height: 45%;
  background: radial-gradient(ellipse at center, hsla(160, 30%, 80%, 0.18), transparent 70%);
  filter: blur(10px);
  animation: fxFogRoll 7000ms ease-in-out forwards;
}
@keyframes fxFogRoll {
  0% { opacity: 0; transform: translateX(0); }
  20%,75% { opacity: 1; }
  100% { opacity: 0; transform: translateX(180%); }
}

/* The moon swells and brightens, briefly. */
.fx-moon-swell::before {
  content: ''; position: absolute; top: 9%; right: 14%;
  width: 34px; height: 34px; border-radius: 50%;
  background: radial-gradient(circle at 38% 35%, hsl(50, 40%, 95%), hsl(45, 35%, 85%));
  box-shadow: 0 0 40px 12px hsla(48, 50%, 85%, 0.4);
  animation: fxMoonSwell 4000ms ease-in-out forwards;
}
@keyframes fxMoonSwell { 0%,100% { transform: scale(1); opacity: 0; } 30%,70% { transform: scale(1.5); opacity: 0.9; } }

/* A deer silhouette ambles across the treeline. */
.fx-deer .deer-silhouette {
  position: absolute; bottom: 17%; left: -12%;
  width: 54px; height: 40px;
  background: hsl(155, 35%, 4%);
  clip-path: polygon(0% 55%, 12% 50%, 14% 28%, 20% 22%, 22% 10%, 27% 22%, 33% 24%, 40% 45%, 78% 45%, 80% 24%, 86% 22%, 88% 30%, 92% 50%, 100% 55%, 96% 100%, 86% 100%, 84% 62%, 38% 62%, 34% 100%, 24% 100%, 22% 62%, 6% 64%);
  opacity: 0;
  animation: fxDeerWalk 7000ms linear forwards;
}
@keyframes fxDeerWalk {
  0% { opacity: 0; transform: translateX(0); }
  12%,88% { opacity: 0.85; }
  100% { opacity: 0; transform: translateX(135vw); }
}

/* ── Reduced motion: the wandering flight is the core mechanic itself and
   can't be meaningfully stripped without breaking the game (same logic
   Pop Spiral applies to its bubble layout) — but decorative extras (the
   background blobs, the decoy's rapid flicker) are removed. Color/glow
   differences alone still fully convey lit-vs-decoy state without the
   flicker. ── */
@media (prefers-reduced-motion: reduce) {
  .blob, .preview-firefly { animation: none; }
  .forest-fog, .forest-mote { animation: none; }
  /* Keep the body present but still; drop the constant sway + wing flutter. */
  .firefly-entity .firefly-body { animation: none; }
  .firefly-entity .firefly-wing { animation: none; opacity: 0.2; }
  .firefly-entity .firefly-abdomen { animation: none; }
  .firefly-entity.is-decoy .firefly-glow { animation: none; opacity: 0.85; }
  /* Lantern stays informative without pulsing; the fill level still recedes. */
  .lantern.is-low, .lantern.is-bump { animation: none; }
  .lantern.is-low .lantern-fill { animation: none; }
  .lantern-dot { animation: none; }
  .glow-bar.is-low .glow-fill { animation: none; }
  /* Vignette + lantern fill use opacity/height transitions only — no flashing. */
  /* The net still appears (it's gameplay feedback) but without the swing arc. */
  .net-swing { animation: fcNetSwingReduced 300ms ease forwards; }
  /* Special events / combo / milestones: keep them legible, drop the motion. */
  .firefly-entity.is-golden .firefly-glow { animation: none; }
  .lantern.is-blazing .lantern-glow { filter: blur(4px) brightness(1.3); }
  .combo-meter.is-pop .combo-val { animation: none; }
  .flourish-spark { animation: flourishFadeReduced 600ms ease forwards; }
  .fx-shooting-star::before, .fx-deer .deer-silhouette { animation-duration: 2200ms; }
  .fx-fog-roll::before, .fx-distant-bloom::before, .fx-moon-swell::before { animation: fxFadeReduced 3000ms ease forwards; }
}
@keyframes fcNetSwingReduced {
  0% { opacity: 0; } 25% { opacity: 1; } 100% { opacity: 0; }
}
@keyframes flourishFadeReduced { 0% { opacity: 1; } 100% { opacity: 0; } }
@keyframes fxFadeReduced { 0%,100% { opacity: 0; } 30%,70% { opacity: 0.7; } }
