/* ============================================================
   Picture Hunt! — Sticker Playground UI (2026)
   Design language: Khan Kids × Duolingo × Toca Boca
   Core moves: mesh-gradient backgrounds, chunky 3D "toy buttons",
   glassy sticker cards, animated sparkles, display typography.
   Toddler-first: 100px+ tap targets, springy feedback.
   ============================================================ */

/* Fredoka is loaded via <link rel="preconnect"> + stylesheet in index.html
   <head> — faster first paint than a render-blocking CSS @import. */

/* ─── Design Tokens ───────────────────────────────────────── */
:root {
  /* Vibrant 2026 playground palette */
  --grape:        #6F4BFF;
  --grape-deep:   #4E2EE0;
  --berry:        #FF4FA8;
  --berry-deep:   #D62A87;
  --tangerine:    #FF8A3D;
  --tangerine-deep:#E0651A;
  --sun:          #FFC93C;
  --sun-deep:     #E6A800;
  --mint:         #2DD4A4;
  --mint-deep:    #14A981;
  --sky:          #4CC9FF;
  --sky-deep:     #1E9FE0;
  --coral:        #FF6B6B;
  --coral-deep:   #E04545;
  --rose:         #FF7AB6;
  --lavender:     #B79CFF;

  /* Neutrals (rich, modern) */
  --ink:          #1B1140;
  --ink-soft:     #44366E;
  --paper:        #FFFFFF;
  --paper-warm:   #FFF6EE;
  --paper-dim:    rgba(255,255,255,0.92);
  --frost:        rgba(255,255,255,0.65);
  --frost-soft:   rgba(255,255,255,0.35);
  --frost-edge:   rgba(255,255,255,0.85);
  --shade:        rgba(27,17,64,0.10);
  --shade-deep:   rgba(27,17,64,0.22);

  /* Category gradients — vibrant + saturated */
  --cat-household: linear-gradient(140deg, #FF8A3D 0%, #FF4FA8 100%);
  --cat-animals:   linear-gradient(140deg, #FFC93C 0%, #FF8A3D 100%);
  --cat-food:      linear-gradient(140deg, #FF6B6B 0%, #FF4FA8 100%);
  --cat-shapes:    linear-gradient(140deg, #4CC9FF 0%, #6F4BFF 100%);
  --cat-colors:    linear-gradient(140deg, #2DD4A4 0%, #4CC9FF 100%);
  --cat-furniture: linear-gradient(140deg, #B79CFF 0%, #FF4FA8 100%);
  --cat-clothing:  linear-gradient(140deg, #4CC9FF 0%, #2DD4A4 100%);
  --cat-halloween: linear-gradient(140deg, #FF7A1A 0%, #2B0B5C 100%);
  --cat-christmas: linear-gradient(140deg, #E63946 0%, #006E3C 100%);
  --cat-spring:    linear-gradient(140deg, #95F0B5 0%, #FF7AB6 100%);

  /* Spacing (8px base) */
  --sp-1: 4px;  --sp-2: 8px;  --sp-3: 12px; --sp-4: 16px;
  --sp-5: 20px; --sp-6: 24px; --sp-8: 32px; --sp-10: 40px;
  --sp-12: 48px; --sp-16: 64px;

  /* Radii — bubbly, nothing sharp */
  --r-sm: 14px; --r-md: 22px; --r-lg: 30px; --r-xl: 40px; --r-full: 999px;

  /* Shadows — layered for depth */
  --lift-1: 0 2px 0 var(--shade), 0 4px 14px rgba(27,17,64,0.10);
  --lift-2: 0 4px 0 var(--shade-deep), 0 10px 24px rgba(27,17,64,0.16);
  --lift-3: 0 6px 0 var(--shade-deep), 0 18px 42px rgba(27,17,64,0.22);
  --glow-sun:   0 0 32px rgba(255,201,60,0.55);
  --glow-mint:  0 0 32px rgba(45,212,164,0.55);
  --glow-grape: 0 0 36px rgba(111,75,255,0.55);

  /* Typography */
  --font-main: 'Fredoka', 'Nunito', 'Quicksand', 'Arial Rounded MT Bold', system-ui, sans-serif;
  --fw-bold: 700;
  --fw-semi: 600;
  --fw-reg:  500;

  /* Motion */
  --ease-bounce: cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-pop:    cubic-bezier(0.22, 1.45, 0.36, 1);
  --ease-smooth: cubic-bezier(0.4, 0, 0.2, 1);
  --dur-fast: 0.14s;
  --dur-med:  0.24s;
  --dur-slow: 0.4s;
}

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

html, body {
  width: 100%; height: 100%;
  overflow: hidden;
  font-family: var(--font-main);
  background: var(--paper-warm);
  color: var(--ink);
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  user-select: none;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-weight: var(--fw-semi);
}

/* ─── Screens ────────────────────────────────────────────── */
.screen {
  position: fixed; inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  transition: opacity 0.35s var(--ease-smooth);
}
.screen.active { display: flex; }

/* ─── Focus visibility (keyboard / switch-access) ──────────── */
:focus-visible {
  outline: 4px solid var(--grape);
  outline-offset: 3px;
}
/* Route-change focus destinations (screen containers + their headings, all
   tabindex="-1") receive focus for screen-reader / keyboard continuity but are
   NOT interactive controls — never paint a ring on them. */
[tabindex="-1"]:focus,
[tabindex="-1"]:focus-visible {
  outline: none;
}
/* On dark/bright surfaces a light halo keeps the ring readable */
.camera-btn:focus-visible,
.result-btn:focus-visible,
.cat-tab:focus-visible {
  outline-color: #fff;
  box-shadow: 0 0 0 8px rgba(27,17,64,0.55);
}


/* ════════════════════════════════════════════════════════════
   LANDING — First hello, mesh-gradient sky + chunky title
   ════════════════════════════════════════════════════════════ */
#landing {
  background:
    radial-gradient(ellipse 80% 60% at 20% 15%,  rgba(255,138,61,0.85) 0%, transparent 55%),
    radial-gradient(ellipse 70% 50% at 85% 25%,  rgba(76,201,255,0.80) 0%, transparent 55%),
    radial-gradient(ellipse 75% 55% at 75% 90%,  rgba(255,79,168,0.85) 0%, transparent 55%),
    radial-gradient(ellipse 60% 45% at 10% 85%,  rgba(45,212,164,0.75) 0%, transparent 55%),
    linear-gradient(160deg, #FFC93C 0%, #FF8A3D 35%, #FF4FA8 70%, #6F4BFF 100%);
  /* Scroll + safe-center + safe-area so the title / fox / "Let's Play!" button are
     never clipped on a short iOS viewport (was `overflow:hidden` + center → the
     button clipped under the home indicator with no way to scroll). The
     decorative ::before/::after are position:fixed so they don't add scrollable
     empty space. */
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  justify-content: flex-start;
  justify-content: safe center;
  padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
}

/* Floating sparkle layer — radial dots, animated drift */
#landing::before {
  content: '';
  position: fixed; inset: -10%;
  background:
    radial-gradient(circle at 12% 18%, rgba(255,255,255,0.95) 0, rgba(255,255,255,0) 4px),
    radial-gradient(circle at 78% 12%, rgba(255,255,255,0.85) 0, rgba(255,255,255,0) 3px),
    radial-gradient(circle at 28% 78%, rgba(255,255,255,0.90) 0, rgba(255,255,255,0) 5px),
    radial-gradient(circle at 88% 65%, rgba(255,255,255,0.85) 0, rgba(255,255,255,0) 4px),
    radial-gradient(circle at 55% 45%, rgba(255,255,255,0.75) 0, rgba(255,255,255,0) 3px),
    radial-gradient(circle at 40% 5%,  rgba(255,255,255,0.95) 0, rgba(255,255,255,0) 4px),
    radial-gradient(circle at 92% 90%, rgba(255,255,255,0.85) 0, rgba(255,255,255,0) 5px);
  animation: starDrift 14s ease-in-out infinite alternate;
  pointer-events: none;
}

/* Floating decorative blob */
#landing::after {
  content: '';
  position: fixed;
  width: 280px; height: 280px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255,255,255,0.32), rgba(255,255,255,0) 70%);
  top: -80px; right: -80px;
  animation: floatSlow 9s ease-in-out infinite;
  pointer-events: none;
}

.landing-content {
  text-align: center;
  padding: var(--sp-12) var(--sp-6);
  position: relative;
  z-index: 1;
}

/* Hunt-buddy greeter on the entry screen */
.landing-fox {
  display: block;
  width: clamp(150px, 42vw, 232px);
  height: auto;
  aspect-ratio: 577 / 640;
  margin: 0 auto var(--sp-3);
  filter: drop-shadow(0 14px 22px rgba(27,17,64,0.30));
  animation: float 3.6s ease-in-out infinite;
}

.title-bounce {
  font-size: clamp(3rem, 12vw, 5.5rem);
  font-weight: var(--fw-bold);
  color: var(--paper);
  text-shadow:
    0 2px 0 var(--ink),
    0 4px 0 rgba(27,17,64,0.6),
    0 12px 28px rgba(27,17,64,0.35);
  animation: landingBounce 2.4s var(--ease-bounce) infinite;
  line-height: 1.05;
  letter-spacing: -0.02em;
}

.landing-sub {
  font-size: clamp(1.3rem, 5vw, 2rem);
  color: var(--paper);
  margin: var(--sp-5) 0 var(--sp-12);
  font-weight: var(--fw-semi);
  opacity: 0.95;
  text-shadow: 0 2px 8px rgba(27,17,64,0.30);
  letter-spacing: 0.01em;
}

.landing-play-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: var(--sp-6) var(--sp-12);
  font-size: clamp(1.8rem, 6.5vw, 2.6rem);
  font-weight: var(--fw-bold);
  font-family: var(--font-main);
  border: none;
  border-radius: var(--r-full);
  cursor: pointer;
  background: var(--paper);
  color: var(--berry-deep);
  box-shadow:
    0 8px 0 #B8226A,
    0 14px 32px rgba(27,17,64,0.35),
    inset 0 -3px 0 rgba(27,17,64,0.06),
    var(--glow-sun);
  min-height: 110px;
  position: relative;
  overflow: hidden;
  transition: transform var(--dur-fast) var(--ease-bounce),
              box-shadow var(--dur-fast) var(--ease-smooth);
  letter-spacing: 0.02em;
}

.landing-play-btn::after {
  content: '';
  position: absolute; inset: 0;
  background: linear-gradient(105deg, transparent 38%, rgba(255,255,255,0.7) 45%, transparent 52%);
  animation: shimmer 2.8s ease-in-out infinite;
  pointer-events: none;
}

.landing-play-btn:active {
  transform: translateY(6px) scale(0.97);
  box-shadow:
    0 2px 0 #B8226A,
    0 6px 14px rgba(27,17,64,0.25),
    inset 0 -2px 0 rgba(27,17,64,0.06);
}


/* ════════════════════════════════════════════════════════════
   HOME / CATEGORY SELECT — Sticker album feel
   ════════════════════════════════════════════════════════════ */
#splash {
  background:
    radial-gradient(ellipse 60% 50% at 90% 5%,  rgba(255,201,60,0.45) 0%, transparent 55%),
    radial-gradient(ellipse 55% 50% at 5% 90%,  rgba(76,201,255,0.40) 0%, transparent 55%),
    radial-gradient(ellipse 70% 55% at 50% 50%, rgba(255,138,61,0.18) 0%, transparent 60%),
    linear-gradient(180deg, #FFF1DD 0%, #FFE3CC 100%);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  /* Override .screen's `justify-content:center`: when the splash content is taller
     than the viewport, centering pushes the TOP (heading, Story Quests hero, the
     Learn-a-Language bar) off-screen and UNREACHABLE (flex-centering overflow trap).
     Top-anchor so the whole splash scrolls; `safe center` re-centers only when the
     content actually fits (browsers without `safe` keep the flex-start fallback). */
  justify-content: flex-start;
  justify-content: safe center;
}

.splash-content {
  text-align: center;
  width: 100%;
  max-width: 560px;
  padding: var(--sp-10) var(--sp-5) var(--sp-10);
}

/* When the install pill is showing, reserve space so it never covers the grid */
body.ph-install-open .splash-content {
  /* Fallback reservation; install-prompt.js overrides this with the pill's real
     (text-wrapped) height at runtime. Generous here so the bottom controls
     (sticker book / settings / sound / daily card) never hide behind the pill. */
  padding-bottom: calc(var(--sp-10) + 168px + env(safe-area-inset-bottom));
}

.home-title {
  font-size: clamp(2rem, 7.5vw, 3rem);
  font-weight: var(--fw-bold);
  color: var(--ink);
  margin-bottom: var(--sp-6);
  position: relative;
  letter-spacing: -0.01em;
  /* Clear the absolute-positioned corner button (dashboard, top-left) so the
     centered heading never renders underneath it on narrow screens. */
  padding: 0 56px;
}

.home-title::after {
  content: '';
  display: block;
  width: 96px;
  height: 8px;
  border-radius: var(--r-full);
  background: linear-gradient(90deg, var(--sun), var(--tangerine), var(--berry));
  margin: var(--sp-3) auto 0;
  box-shadow: 0 2px 8px rgba(255,138,61,0.35);
}

/* ── Category Grid — Stickers ── */
.category-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-3);
  width: 100%;
  padding: 0 var(--sp-1);
}

.category-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  padding: var(--sp-5) var(--sp-3);
  border-radius: var(--r-lg);
  border: 3px solid var(--paper);
  cursor: pointer;
  transition: transform var(--dur-fast) var(--ease-pop),
              box-shadow var(--dur-fast) var(--ease-smooth);
  box-shadow: var(--lift-2);
  min-height: 124px;
  text-align: center;
  position: relative;
  overflow: hidden;
  font-family: var(--font-main);
}

/* Holographic shine streak across each sticker */
.category-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(115deg,
    transparent 40%,
    rgba(255,255,255,0.45) 50%,
    transparent 60%);
  transform: translateX(-100%);
  pointer-events: none;
  transition: transform 0.6s var(--ease-smooth);
}

/* Subtle dot/sparkle texture overlay */
.category-card::after {
  content: '';
  position: absolute; inset: 0;
  background:
    radial-gradient(circle at 18% 22%, rgba(255,255,255,0.35) 0, transparent 8px),
    radial-gradient(circle at 78% 75%, rgba(255,255,255,0.30) 0, transparent 10px);
  pointer-events: none;
  opacity: 0.85;
}

.category-card:nth-child(odd)  { animation: cardWobble 5s ease-in-out infinite; transform-origin: bottom center; }
.category-card:nth-child(even) { animation: cardWobble 5s ease-in-out infinite -2.5s; transform-origin: bottom center; }

.category-card:active {
  transform: scale(0.94) translateY(2px);
  box-shadow: var(--lift-1);
}

.category-card.has-continue {
  border-color: var(--sun);
  box-shadow: var(--lift-2), var(--glow-sun);
}

/* "▶ CONTINUE" chip — injected as the first visual element in cat-info. */
.category-card.has-continue > .cat-info::before {
  content: '▶ CONTINUE';
  align-self: center;
  font-size: 0.62rem;
  font-weight: var(--fw-bold);
  letter-spacing: 0.10em;
  color: var(--ink);
  background: var(--sun);
  padding: 2px var(--sp-2);
  border-radius: var(--r-full);
  margin-bottom: 4px;
  box-shadow: 0 2px 0 var(--sun-deep);
  white-space: nowrap;
}

/* Lock badge for locked cards is rendered by paywall.css (::after override). */
.category-card.locked {
  filter: saturate(0.55) brightness(0.95);
}

.cat-emoji {
  font-size: clamp(2.8rem, 10vw, 3.8rem);
  flex-shrink: 0;
  filter: drop-shadow(0 4px 8px rgba(27,17,64,0.20));
  z-index: 1;
  position: relative;
}
/* Custom illustrated category tile (replaces the category emoji) */
.cat-tile-img {
  width: clamp(66px, 18vw, 86px);
  aspect-ratio: 1 / 1;
  object-fit: contain;
  display: block;
  margin: 0 auto;
  filter: drop-shadow(0 4px 8px rgba(27,17,64,0.22));
}

.cat-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  z-index: 1;
  position: relative;
}

.cat-name {
  font-size: clamp(1.1rem, 4.5vw, 1.45rem);
  font-weight: var(--fw-bold);
  color: var(--paper);
  text-shadow: 0 2px 4px rgba(27,17,64,0.30);
  line-height: 1.2;
  letter-spacing: 0.01em;
}

.cat-progress {
  font-size: clamp(0.78rem, 2.6vw, 0.95rem);
  color: var(--paper);
  font-weight: var(--fw-semi);
  background: rgba(255,255,255,0.22);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  padding: 2px 10px;
  border-radius: var(--r-full);
  display: inline-block;
  margin-top: 4px;
}

.splash-bottom {
  display: flex;
  justify-content: center;
  gap: var(--sp-3);
  margin-top: var(--sp-8);
  flex-wrap: wrap;
}

.setup-icon-btn {
  background: var(--paper);
  border: 3px solid var(--ink);
  font-size: 1.6rem;
  padding: var(--sp-3);
  border-radius: var(--r-md);
  cursor: pointer;
  transition: transform var(--dur-fast) var(--ease-bounce),
              box-shadow var(--dur-fast);
  min-height: 60px;
  min-width: 60px;
  box-shadow: 0 4px 0 var(--ink), 0 8px 16px rgba(27,17,64,0.15);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-main);
  color: var(--ink);
}
.setup-icon-btn:active {
  transform: translateY(4px);
  box-shadow: 0 0 0 var(--ink), 0 2px 6px rgba(27,17,64,0.20);
}

/* Sticker collection — its own labeled row, stacked below the Settings/Sound
   icons so the "book" clearly reads as the kid's sticker album. */
.sticker-shelf {
  display: flex;
  justify-content: center;
  margin-top: var(--sp-3);
}
.sticker-shelf-btn {
  position: relative;            /* anchor for the .sticker-btn-count corner badge */
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  background: var(--paper);
  border: 3px solid var(--ink);
  color: var(--ink);
  font-family: var(--font-main);
  font-weight: var(--fw-bold);
  font-size: 1.2rem;
  padding: var(--sp-2) var(--sp-6);
  min-height: 56px;
  border-radius: var(--r-full);
  cursor: pointer;
  box-shadow: 0 4px 0 var(--ink), 0 8px 16px rgba(27,17,64,0.15);
  transition: transform var(--dur-fast) var(--ease-bounce), box-shadow var(--dur-fast);
}
.sticker-shelf-btn:active {
  transform: translateY(4px);
  box-shadow: 0 0 0 var(--ink), 0 2px 6px rgba(27,17,64,0.20);
}
.sticker-shelf-icon { font-size: 1.5rem; line-height: 1; }


/* ════════════════════════════════════════════════════════════
   BIG BUTTONS — Shared toy-button system
   ════════════════════════════════════════════════════════════ */
.big-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: var(--sp-5) var(--sp-10);
  font-size: clamp(1.5rem, 5.5vw, 2.2rem);
  font-weight: var(--fw-bold);
  font-family: var(--font-main);
  border: none;
  border-radius: var(--r-lg);
  cursor: pointer;
  transition: transform var(--dur-fast) var(--ease-bounce),
              box-shadow var(--dur-fast);
  min-height: 100px;
  min-width: 200px;
  text-align: center;
  position: relative;
  letter-spacing: 0.01em;
  color: var(--paper);
}
.big-btn:active { transform: translateY(5px) scale(0.98); }
.big-btn:disabled { opacity: 0.45; cursor: not-allowed; filter: grayscale(0.5); }

/* Play / Primary — berry burst */
.play-btn {
  background: linear-gradient(180deg, #FF6BB6 0%, #FF4FA8 50%, #E03A8E 100%);
  color: var(--paper);
  box-shadow:
    0 6px 0 #B8226A,
    0 12px 26px rgba(255,79,168,0.45),
    inset 0 2px 0 rgba(255,255,255,0.35);
}
.play-btn:active {
  box-shadow:
    0 1px 0 #B8226A,
    0 4px 10px rgba(255,79,168,0.30),
    inset 0 1px 0 rgba(255,255,255,0.25);
}

/* Setup / Secondary — clean white toy button */
.setup-btn {
  background: var(--paper);
  color: var(--ink);
  box-shadow:
    0 5px 0 var(--ink),
    0 10px 20px rgba(27,17,64,0.18);
  padding: var(--sp-4) var(--sp-8);
  font-size: clamp(1.1rem, 4vw, 1.6rem);
  min-height: 64px;
  border: 3px solid var(--ink);
}
.setup-btn:active {
  box-shadow: 0 1px 0 var(--ink), 0 3px 8px rgba(27,17,64,0.20);
}

/* Camera button — green orb, the treasure-finder */
.camera-btn {
  background: linear-gradient(180deg, #4FE3B6 0%, #2DD4A4 50%, #14A981 100%);
  color: var(--paper);
  box-shadow:
    0 8px 0 #0F8666,
    0 16px 32px rgba(45,212,164,0.50),
    inset 0 3px 0 rgba(255,255,255,0.30);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-3);
  font-size: 4rem !important;
  padding: var(--sp-8) var(--sp-16) !important;
  min-height: 130px !important;
  border-radius: var(--r-full);
  position: relative;
}

/* Inner lens ring on camera button */
.camera-btn::before {
  content: '';
  position: absolute;
  inset: 10px;
  border-radius: var(--r-full);
  border: 4px solid rgba(255,255,255,0.30);
  pointer-events: none;
}

/* Pulsing halo glow */
.camera-btn::after {
  content: '';
  position: absolute;
  inset: -6px;
  border-radius: var(--r-full);
  box-shadow: 0 0 0 0 rgba(45,212,164,0.6);
  animation: cameraPulse 2s ease-in-out infinite;
  pointer-events: none;
}

.camera-btn:active {
  box-shadow:
    0 2px 0 #0F8666,
    0 6px 14px rgba(45,212,164,0.35),
    inset 0 2px 0 rgba(255,255,255,0.25);
}

.camera-btn input[type="file"] {
  position: absolute;
  width: 0; height: 0;
  opacity: 0;
  pointer-events: none;
}


/* ════════════════════════════════════════════════════════════
   SETUP SCREEN — Parent's control panel
   ════════════════════════════════════════════════════════════ */
#setup {
  background:
    radial-gradient(ellipse 60% 50% at 0% 0%,   rgba(76,201,255,0.30) 0%, transparent 55%),
    radial-gradient(ellipse 60% 50% at 100% 100%, rgba(255,79,168,0.25) 0%, transparent 55%),
    linear-gradient(180deg, #FFF6EE 0%, #FFE9D6 100%);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  justify-content: flex-start;
}

.setup-container {
  overflow-y: auto;
  max-height: 100vh;
  max-height: 100dvh;
  width: 100%;
  max-width: 720px;
  padding: var(--sp-10) var(--sp-5) var(--sp-10);
  display: flex;
  flex-direction: column;
  align-items: center;
}

.setup-header {
  font-size: clamp(1.8rem, 7vw, 2.8rem);
  font-weight: var(--fw-bold);
  color: var(--ink);
  margin-bottom: var(--sp-5);
  letter-spacing: -0.01em;
}

/* Category tabs — pills with depth */
.category-tabs {
  display: flex;
  gap: var(--sp-2);
  margin-bottom: var(--sp-4);
  flex-wrap: wrap;
  justify-content: center;
}

.cat-tab {
  padding: var(--sp-2) var(--sp-4);
  font-size: clamp(0.9rem, 3vw, 1.05rem);
  font-weight: var(--fw-semi);
  font-family: var(--font-main);
  border: 2px solid var(--ink);
  border-radius: var(--r-full);
  background: var(--paper);
  color: var(--ink);
  cursor: pointer;
  transition: transform var(--dur-fast) var(--ease-bounce), background-color var(--dur-fast) ease, color var(--dur-fast) ease, box-shadow var(--dur-fast) ease;
  box-shadow: 0 3px 0 var(--ink);
  min-height: 42px;
}
.cat-tab.active {
  background: linear-gradient(180deg, #4FE3B6 0%, #2DD4A4 100%);
  border-color: var(--mint-deep);
  color: var(--paper);
  transform: scale(1.05);
  box-shadow: 0 3px 0 var(--mint-deep), 0 6px 14px rgba(45,212,164,0.35);
}
.cat-tab:active { transform: translateY(3px) scale(0.98); box-shadow: 0 0 0 var(--ink); }

.setup-toolbar {
  display: flex;
  gap: var(--sp-3);
  margin-bottom: var(--sp-2);
}

.setup-tool-btn {
  padding: var(--sp-2) var(--sp-5);
  font-size: clamp(0.95rem, 3vw, 1.1rem);
  font-weight: var(--fw-semi);
  font-family: var(--font-main);
  border: 2px solid var(--ink);
  border-radius: var(--r-md);
  background: var(--paper);
  color: var(--ink);
  cursor: pointer;
  transition: transform var(--dur-fast) var(--ease-bounce);
  box-shadow: 0 3px 0 var(--ink);
  min-height: 44px;
}
.setup-tool-btn:active { transform: translateY(3px); box-shadow: 0 0 0 var(--ink); }

.setup-msg {
  font-size: clamp(0.9rem, 3.5vw, 1.2rem);
  color: var(--ink-soft);
  margin-bottom: var(--sp-3);
  transition: color 0.3s;
  font-weight: var(--fw-semi);
}
.setup-msg.warn {
  color: var(--coral-deep);
  font-weight: var(--fw-bold);
}

.setup-grid {
  padding-bottom: 5rem;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: var(--sp-3);
  width: 100%;
  margin-bottom: var(--sp-6);
}
@media (min-width: 600px) {
  .setup-grid {
    padding-bottom: 5rem;
    grid-template-columns: repeat(4, 1fr);
  }
}

.setup-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--sp-3) var(--sp-2);
  border-radius: var(--r-md);
  border: 3px solid var(--ink);
  background: var(--paper);
  cursor: pointer;
  transition: transform var(--dur-fast) var(--ease-bounce),
              border-color var(--dur-fast),
              background var(--dur-fast),
              box-shadow var(--dur-fast),
              opacity var(--dur-fast);
  min-height: 104px;
  opacity: 0.55;
  box-shadow: 0 3px 0 rgba(27,17,64,0.85);
}

.setup-card.selected {
  border-color: var(--mint-deep);
  background: linear-gradient(180deg, #DFFCEF 0%, #B6F5DC 100%);
  opacity: 1;
  box-shadow: 0 3px 0 var(--mint-deep), 0 8px 16px rgba(45,212,164,0.30);
}

.setup-card:active { transform: translateY(3px) scale(0.97); box-shadow: 0 0 0 var(--ink); }
.setup-card.bounce-tap { animation: cardBounce 0.32s var(--ease-bounce); }

.setup-card-emoji {
  font-size: clamp(2.2rem, 8vw, 3rem);
  line-height: 1.2;
  filter: drop-shadow(0 2px 4px rgba(27,17,64,0.12));
}

.setup-card-img {
  width: clamp(50px, 12vw, 70px);
  height: clamp(50px, 12vw, 70px);
  object-fit: contain;
  border-radius: var(--r-sm);
}

.target-img {
  width: clamp(120px, 35vw, 200px);
  height: clamp(120px, 35vw, 200px);
  object-fit: contain;
  filter: drop-shadow(0 10px 20px rgba(27,17,64,0.18));
}

.setup-card-name {
  font-size: clamp(0.75rem, 2.6vw, 0.95rem);
  color: var(--ink);
  margin-top: var(--sp-1);
  text-align: center;
  text-transform: capitalize;
  font-weight: var(--fw-semi);
}

.setup-done-btn {
  position: sticky;
  bottom: 1rem;
  z-index: 10;
  margin-top: var(--sp-2);
  padding: var(--sp-5) var(--sp-10);
}


/* ════════════════════════════════════════════════════════════
   GAME SCREEN — The treasure hunt
   ════════════════════════════════════════════════════════════ */
#game {
  background:
    radial-gradient(ellipse 55% 45% at 85% 5%,  rgba(255,201,60,0.40) 0%, transparent 55%),
    radial-gradient(ellipse 55% 45% at 5% 95%,  rgba(76,201,255,0.35) 0%, transparent 55%),
    linear-gradient(180deg, #FFF6EE 0%, #FFE9D6 70%, #FFD9BB 100%);
  padding: var(--sp-5);
  gap: var(--sp-3);
  /* Override .screen's `justify-content:center`: on a short iOS viewport the
     centered hunt (camera + target + controls) is taller than the screen, so
     the Home button (top) and Skip button (bottom) get pushed off-screen and
     UNREACHABLE with no way to scroll. Top-anchor + safe-center + scroll so the
     whole hunt is reachable — same fix the splash, paywall and story-mode use. */
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  justify-content: flex-start;
  justify-content: safe center;
}

.game-top {
  width: 92%;
  max-width: 520px;
  display: flex;
  align-items: center;
  gap: var(--sp-3);
}

/* Progress Bar — Rainbow XP track */
.progress-bar {
  flex: 1;
  height: 22px;
  background: var(--paper);
  border-radius: var(--r-full);
  overflow: hidden;
  box-shadow:
    inset 0 3px 6px rgba(27,17,64,0.18),
    0 2px 0 var(--shade);
  border: 3px solid var(--ink);
  position: relative;
}
.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--mint), var(--sky), var(--lavender), var(--rose), var(--sun));
  background-size: 250% 100%;
  border-radius: var(--r-full);
  transition: width 0.6s var(--ease-smooth);
  animation: progressShimmer 4s linear infinite;
  box-shadow: inset 0 2px 0 rgba(255,255,255,0.45);
}

/* Target Area — the quest */
.target-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-3);
  background: var(--paper-dim);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 3px solid var(--paper);
  border-radius: var(--r-xl);
  padding: var(--sp-6) var(--sp-5) var(--sp-4);
  box-shadow:
    0 4px 0 var(--shade-deep),
    0 14px 36px rgba(27,17,64,0.18);
  margin-top: var(--sp-2);
  position: relative;
  width: 92%;
  max-width: 520px;
}

/* Spotlight halo behind the target emoji */
.target-area::before {
  content: '';
  position: absolute;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  width: 200px;
  height: 200px;
  background: radial-gradient(circle, rgba(255,201,60,0.45) 0%, rgba(255,201,60,0) 70%);
  border-radius: 50%;
  pointer-events: none;
  animation: spotlightPulse 3.5s ease-in-out infinite;
}

.target-emoji {
  font-size: clamp(5.5rem, 22vw, 11rem);
  animation: targetFloat 3.2s ease-in-out infinite;
  filter: drop-shadow(0 12px 20px rgba(27,17,64,0.22));
  line-height: 1;
  z-index: 1;
  position: relative;
}

.target-text {
  font-size: clamp(1.1rem, 4.2vw, 1.5rem);
  color: var(--ink-soft);
  font-weight: var(--fw-semi);
  z-index: 1;
  position: relative;
  text-align: center;
}

/* Feedback */
.feedback-area {
  min-height: 60px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.feedback {
  font-size: clamp(1.3rem, 5vw, 2rem);
  font-weight: var(--fw-bold);
  padding: var(--sp-3) var(--sp-6);
  border-radius: var(--r-md);
  animation: popIn 0.4s var(--ease-bounce);
}
.feedback.success {
  background: linear-gradient(180deg, #DFFCEF 0%, #B6F5DC 100%);
  color: var(--mint-deep);
  border: 3px solid var(--mint-deep);
  box-shadow: 0 4px 0 var(--mint-deep);
}
.feedback.fail {
  background: linear-gradient(180deg, #FFE4D0 0%, #FFC9A8 100%);
  color: var(--coral-deep);
  border: 3px solid var(--coral-deep);
  box-shadow: 0 4px 0 var(--coral-deep);
  animation: popIn 0.4s var(--ease-bounce), wiggle 0.5s ease 0.4s;
}

/* Camera Area */
.camera-area {
  margin-top: auto;
  margin-bottom: var(--sp-6);
}

/* Loading */
.loading {
  position: fixed; inset: 0;
  background: rgba(27,17,64,0.55);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--sp-5);
  z-index: 100;
  color: var(--paper);
  font-size: 1.3rem;
  font-weight: var(--fw-semi);
}
.loading.hidden { display: none; }

/* Hunt-buddy searching, on the "looking at your photo" overlay */
.loading-fox {
  width: clamp(120px, 34vw, 168px);
  height: auto;
  aspect-ratio: 526 / 640;
  filter: drop-shadow(0 10px 18px rgba(0,0,0,0.38));
  animation: float 2.6s ease-in-out infinite;
}

.spinner {
  width: 72px; height: 72px;
  border: 7px solid rgba(255,255,255,0.25);
  border-top-color: var(--sun);
  border-right-color: var(--berry);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  box-shadow: 0 0 24px rgba(255,201,60,0.5);
}


/* ════════════════════════════════════════════════════════════
   VICTORY — Celebration
   ════════════════════════════════════════════════════════════ */
#victory {
  background:
    radial-gradient(ellipse 70% 50% at 20% 20%, rgba(255,201,60,0.85) 0%, transparent 55%),
    radial-gradient(ellipse 60% 50% at 80% 30%, rgba(255,79,168,0.85) 0%, transparent 55%),
    radial-gradient(ellipse 70% 55% at 50% 90%, rgba(111,75,255,0.85) 0%, transparent 60%),
    linear-gradient(160deg, #FFC93C 0%, #FF8A3D 30%, #FF4FA8 70%, #6F4BFF 100%);
  /* Scroll + safe-center + safe-area so the celebration (fox + title) and the
     Play Again / Home buttons stay reachable on a short iOS viewport (was
     overflow:hidden + center -> Home clipped off the bottom with no scroll).
     ::before is position:fixed so the sparkle layer doesn't inflate scrollHeight. */
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  justify-content: flex-start;
  justify-content: safe center;
  padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
}

/* Sparkle layer for victory */
#victory::before {
  content: '';
  position: fixed; inset: -10%;
  background:
    radial-gradient(circle at 15% 25%, rgba(255,255,255,0.95) 0, transparent 5px),
    radial-gradient(circle at 80% 18%, rgba(255,255,255,0.85) 0, transparent 4px),
    radial-gradient(circle at 30% 75%, rgba(255,255,255,0.95) 0, transparent 6px),
    radial-gradient(circle at 90% 70%, rgba(255,255,255,0.90) 0, transparent 5px),
    radial-gradient(circle at 60% 40%, rgba(255,255,255,0.80) 0, transparent 4px);
  animation: starDrift 10s ease-in-out infinite alternate;
  pointer-events: none;
}

.victory-content {
  text-align: center;
  padding: var(--sp-6);
  position: relative;
  z-index: 1;
}

.victory-title {
  font-size: clamp(2.5rem, 10vw, 4.8rem);
  font-weight: var(--fw-bold);
  color: var(--paper);
  text-shadow:
    0 3px 0 var(--ink),
    0 6px 0 rgba(27,17,64,0.5),
    0 14px 28px rgba(27,17,64,0.35);
  animation: victoryBounce 0.9s var(--ease-bounce) infinite;
  line-height: 1.1;
  letter-spacing: -0.01em;
}

.victory-emoji {
  font-size: clamp(3.5rem, 14vw, 7rem);
  margin: var(--sp-5) 0;
  animation: victoryFloat 2.2s ease-in-out infinite;
  filter: drop-shadow(0 8px 16px rgba(27,17,64,0.30));
}
/* Hunt-buddy celebrating on the victory screen */
.victory-fox {
  display: block;
  width: clamp(160px, 46vw, 240px);
  height: auto;
  aspect-ratio: 551 / 640;
  margin: var(--sp-4) auto var(--sp-3);
  animation: victoryFloat 2.2s ease-in-out infinite;
  filter: drop-shadow(0 14px 22px rgba(27,17,64,0.32));
}

.victory-sub {
  font-size: clamp(1.3rem, 5.2vw, 2rem);
  color: var(--paper);
  margin-bottom: var(--sp-5);
  font-weight: var(--fw-semi);
  text-shadow: 0 2px 8px rgba(27,17,64,0.25);
}

.victory-stats {
  margin-bottom: var(--sp-6);
}

.victory-stat {
  font-size: clamp(1rem, 4vw, 1.4rem);
  color: var(--paper);
  padding: var(--sp-2) var(--sp-5);
  background: rgba(255,255,255,0.22);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 2px solid rgba(255,255,255,0.45);
  border-radius: var(--r-full);
  display: inline-block;
  font-weight: var(--fw-semi);
  margin: var(--sp-1);
  box-shadow: 0 4px 12px rgba(27,17,64,0.18);
}

.victory-buttons {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-3);
}

.victory-buttons .play-btn {
  background: linear-gradient(180deg, var(--paper) 0%, #FFE9D6 100%);
  color: var(--berry-deep);
  box-shadow:
    0 6px 0 #B8226A,
    0 14px 32px rgba(27,17,64,0.30),
    0 0 28px rgba(255,255,255,0.55);
  border: 3px solid var(--paper);
}
.victory-buttons .setup-btn {
  background: rgba(255,255,255,0.22);
  color: var(--paper);
  border: 3px solid rgba(255,255,255,0.55);
  box-shadow:
    0 5px 0 rgba(27,17,64,0.30),
    0 10px 22px rgba(27,17,64,0.18);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}


/* ════════════════════════════════════════════════════════════
   CONFETTI CANVAS
   ════════════════════════════════════════════════════════════ */
#confetti-canvas {
  position: fixed; inset: 0;
  width: 100%; height: 100%;
  pointer-events: none;
  z-index: 200;
}


/* ════════════════════════════════════════════════════════════
   GAME CONTROLS — Home, Skip, Repeat
   ════════════════════════════════════════════════════════════ */
.home-btn {
  background: var(--paper);
  border: 3px solid var(--ink);
  font-size: 1.5rem;
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--r-md);
  cursor: pointer;
  z-index: 20;
  min-width: 52px;
  min-height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 4px 0 var(--ink), 0 8px 14px rgba(27,17,64,0.15);
  transition: transform var(--dur-fast) var(--ease-bounce);
  color: var(--ink);
  font-family: var(--font-main);
}
.home-btn:active {
  transform: translateY(4px);
  box-shadow: 0 0 0 var(--ink);
}

.skip-area { text-align: center; margin-top: var(--sp-2); }
.skip-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  background: var(--paper);
  border: 3px solid var(--ink);
  color: var(--ink);
  padding: var(--sp-3) var(--sp-6);
  border-radius: var(--r-lg);
  font-size: 1.6rem;
  font-family: var(--font-main);
  font-weight: var(--fw-semi);
  cursor: pointer;
  box-shadow: 0 4px 0 var(--ink), 0 8px 14px rgba(27,17,64,0.12);
  transition: transform var(--dur-fast) var(--ease-bounce);
  min-height: 72px;
}
.skip-btn:active {
  transform: translateY(4px);
  box-shadow: 0 0 0 var(--ink);
}
/* Word label next to the skip icon (clarity for parents; icon stays for toddlers) */
.skip-label { font-size: 1.2rem; line-height: 1; }

/* Inline SVG control icons sit centered in their toy buttons */
.setup-icon-btn svg, .home-btn svg, .skip-btn svg, .repeat-btn svg {
  display: inline-block;
  vertical-align: middle;
}

.repeat-btn {
  background: linear-gradient(180deg, #FFE38B 0%, #FFC93C 100%);
  border: 3px solid var(--sun-deep);
  color: var(--ink);
  padding: var(--sp-2) var(--sp-5);
  border-radius: var(--r-full);
  font-size: 1.4rem;
  font-family: var(--font-main);
  font-weight: var(--fw-bold);
  cursor: pointer;
  margin-top: var(--sp-2);
  box-shadow: 0 4px 0 var(--sun-deep), 0 8px 16px rgba(255,201,60,0.45);
  transition: transform var(--dur-fast) var(--ease-bounce);
  min-height: 72px;
}
.repeat-btn:active {
  transform: translateY(4px);
  box-shadow: 0 0 0 var(--sun-deep);
}


/* ════════════════════════════════════════════════════════════
   RESULT FLOW — Photo preview + actions
   ════════════════════════════════════════════════════════════ */
.miss-fox {
  display: block;
  width: clamp(84px, 24vw, 116px);
  height: auto;
  aspect-ratio: 503 / 640;
  margin: 0 auto var(--sp-1);
  filter: drop-shadow(0 8px 14px rgba(27,17,64,0.22));
  animation: popIn 0.4s var(--ease-bounce);
}

.result-msg {
  font-size: clamp(1.4rem, 5vw, 1.8rem);
  font-weight: var(--fw-bold);
  margin-bottom: var(--sp-4);
  text-align: center;
}
.result-msg.success { color: var(--mint-deep); }
.result-msg.fail    { color: var(--coral-deep); }

.result-buttons {
  display: flex;
  justify-content: center;
  gap: var(--sp-5);
  margin: var(--sp-3) 0;
}

.result-btn {
  border: 4px solid var(--paper);
  border-radius: var(--r-xl);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform var(--dur-fast) var(--ease-bounce),
              box-shadow var(--dur-fast);
}
.result-btn:active { transform: translateY(5px) scale(0.96); }

.result-green {
  background: linear-gradient(180deg, #4FE3B6 0%, #2DD4A4 50%, #14A981 100%);
  width: 124px; height: 124px;
  box-shadow:
    0 7px 0 #0F8666,
    0 14px 26px rgba(45,212,164,0.45);
}
.result-green:active {
  box-shadow: 0 2px 0 #0F8666, 0 6px 12px rgba(45,212,164,0.30);
}

.result-yellow {
  background: linear-gradient(180deg, #FFE38B 0%, #FFC93C 50%, #E6A800 100%);
  width: 124px; height: 124px;
  box-shadow:
    0 7px 0 var(--sun-deep),
    0 14px 26px rgba(255,201,60,0.45);
}
.result-yellow:active {
  box-shadow: 0 2px 0 var(--sun-deep), 0 6px 12px rgba(255,201,60,0.30);
}

.result-icon {
  font-size: 3rem;
  color: var(--paper);
  font-weight: var(--fw-bold);
  line-height: 1;
  filter: drop-shadow(0 2px 4px rgba(27,17,64,0.20));
}

/* Photo Preview */
.photo-preview { text-align: center; margin-bottom: var(--sp-3); }
.preview-img {
  max-width: 70%;
  max-height: 200px;
  border-radius: var(--r-lg);
  border: 5px solid var(--paper);
  object-fit: cover;
  box-shadow: 0 10px 24px rgba(27,17,64,0.25), 0 0 0 3px var(--ink);
}

.preview-buttons {
  display: flex;
  justify-content: center;
  align-items: stretch;
  gap: var(--sp-3);
  padding: var(--sp-2);
}
.preview-btn {
  flex: 1;
  min-height: 104px;
  max-width: 140px;
  border: 4px solid var(--paper);
  border-radius: var(--r-lg);
  font-size: 2.4rem;
  font-family: var(--font-main);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  transition: transform var(--dur-fast) var(--ease-bounce);
  line-height: 1.2;
}
.preview-btn:active { transform: translateY(4px) scale(0.97); }

.preview-label {
  font-size: 1rem;
  font-weight: var(--fw-bold);
  color: var(--paper);
  margin-top: 2px;
}
.preview-submit {
  background: linear-gradient(180deg, #4FE3B6 0%, #2DD4A4 50%, #14A981 100%);
  min-height: 116px;
  font-size: 3rem;
  box-shadow: 0 6px 0 #0F8666, 0 12px 22px rgba(45,212,164,0.40);
}
.preview-submit:active { box-shadow: 0 1px 0 #0F8666, 0 4px 10px rgba(45,212,164,0.30); }

.preview-retake {
  background: linear-gradient(180deg, #FFE38B 0%, #FFC93C 50%, #E6A800 100%);
  box-shadow: 0 6px 0 var(--sun-deep), 0 12px 22px rgba(255,201,60,0.40);
}
.preview-retake:active { box-shadow: 0 1px 0 var(--sun-deep), 0 4px 10px rgba(255,201,60,0.30); }

.preview-cancel {
  background: linear-gradient(180deg, #FF8C8C 0%, #FF6B6B 50%, #E04545 100%);
  box-shadow: 0 6px 0 #B22A2A, 0 12px 22px rgba(255,107,107,0.40);
}
.preview-cancel:active { box-shadow: 0 1px 0 #B22A2A, 0 4px 10px rgba(255,107,107,0.30); }


/* ════════════════════════════════════════════════════════════
   TRANSLATION LABELS
   ════════════════════════════════════════════════════════════ */
.target-translation {
  display: inline-block;
  font-size: clamp(1.2rem, 4.5vw, 1.7rem);
  font-weight: var(--fw-bold);
  color: var(--ink);
  background: var(--sun);
  padding: 4px var(--sp-3);
  border-radius: var(--r-full);
  margin-top: var(--sp-2);
  box-shadow: 0 3px 0 var(--sun-deep);
  letter-spacing: 0.02em;
}

.translation-echo {
  font-size: clamp(2rem, 8vw, 3.5rem);
  font-weight: var(--fw-bold);
  color: var(--ink);
  background: var(--sun);
  padding: var(--sp-2) var(--sp-5);
  border-radius: var(--r-full);
  margin-top: var(--sp-3);
  animation: popIn 0.4s var(--ease-bounce);
  text-align: center;
  letter-spacing: 0.02em;
  display: inline-block;
  box-shadow: 0 5px 0 var(--sun-deep), 0 10px 20px rgba(255,201,60,0.40);
}

.setup-card-translation {
  font-size: 0.7rem;
  color: var(--ink-soft);
  font-weight: var(--fw-semi);
  display: block;
  margin-top: 2px;
  opacity: 0.9;
  word-break: break-word;
  line-height: 1.2;
}


/* ════════════════════════════════════════════════════════════
   DIFFICULTY SELECTOR
   ════════════════════════════════════════════════════════════ */
.difficulty-selector {
  display: flex;
  justify-content: center;
  gap: var(--sp-2);
  margin: var(--sp-2) 0 var(--sp-2);
}
.diff-btn {
  background: var(--paper);
  border: 2px solid var(--ink);
  border-radius: var(--r-md);
  padding: var(--sp-2) var(--sp-4);
  font-size: 1rem;
  font-family: var(--font-main);
  font-weight: var(--fw-semi);
  color: var(--ink);
  cursor: pointer;
  transition: transform var(--dur-fast) var(--ease-bounce), background-color var(--dur-fast) ease, color var(--dur-fast) ease, box-shadow var(--dur-fast) ease;
  min-height: 48px;
  box-shadow: 0 3px 0 var(--ink);
}
.diff-btn.active {
  background: linear-gradient(180deg, #FFE38B 0%, #FFC93C 100%);
  border-color: var(--sun-deep);
  color: var(--ink);
  transform: scale(1.08);
  box-shadow: 0 3px 0 var(--sun-deep), 0 6px 14px rgba(255,201,60,0.40);
}
.diff-btn:active { transform: translateY(3px) scale(1); box-shadow: 0 0 0 var(--ink); }


/* ════════════════════════════════════════════════════════════
   LANGUAGE SELECTOR
   ════════════════════════════════════════════════════════════ */
.lang-selector {
  text-align: center;
  margin: var(--sp-2) 0 var(--sp-3);
}
.lang-btn {
  background: var(--paper);
  border: 2px solid var(--ink);
  border-radius: var(--r-full);
  padding: var(--sp-2) var(--sp-5);
  font-size: 1rem;
  font-family: var(--font-main);
  font-weight: var(--fw-semi);
  color: var(--ink);
  cursor: pointer;
  transition: transform var(--dur-fast), background-color var(--dur-fast) ease, color var(--dur-fast) ease;
  min-height: 44px;
  box-shadow: 0 3px 0 var(--ink);
}
.lang-btn:active {
  transform: translateY(3px);
  box-shadow: 0 0 0 var(--ink);
}
.lang-sub {
  font-size: 0.8rem;
  color: var(--ink-soft, #6B5240);
  margin-top: 4px;
  font-weight: var(--fw-reg, 600);
}
.lang-picker-sub {
  font-size: 0.95rem;
  color: var(--ink-soft, #6B5240);
  text-align: center;
  margin: 6px 0 16px;
  line-height: 1.4;
  padding: 0 4px;
}


/* ════════════════════════════════════════════════════════════
   STORYLINE MODE
   ════════════════════════════════════════════════════════════ */
.story-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-3);
  padding: 0 var(--sp-4);
  margin-bottom: var(--sp-4);
}
.story-card {
  border: 3px solid var(--paper);
  border-radius: var(--r-md);
  padding: var(--sp-4) var(--sp-3);
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  color: var(--paper);
  cursor: pointer;
  font-size: 1rem;
  min-height: 88px;
  box-shadow: var(--lift-2);
  transition: transform var(--dur-fast) var(--ease-bounce);
  font-family: var(--font-main);
}
.story-card:active { transform: translateY(3px) scale(0.97); }
.story-emoji {
  font-size: 2.2rem;
  flex-shrink: 0;
  filter: drop-shadow(0 3px 6px rgba(27,17,64,0.20));
}
.story-info { text-align: left; min-width: 0; flex: 1 1 auto; }
.story-name { font-weight: var(--fw-bold); font-size: 1rem; letter-spacing: 0.01em; overflow-wrap: anywhere; line-height: 1.15; }
.story-meta { font-size: 0.78rem; opacity: 0.9; margin-top: 2px; font-weight: var(--fw-semi); }
.story-completed { opacity: 0.85; }
.story-card.locked { opacity: 0.9; }

/* ════════════════════════════════════════════════════════════
   ADVENTURE TRAIL — storybook chrome for Story Quests (#game.story-mode)
   ════════════════════════════════════════════════════════════ */
/* Distinct storybook backdrop so a quest never looks like a category hunt.
   Top-anchor + safe-center + scroll so the camera stays reachable if the
   chrome makes the screen taller than the viewport (cf. the splash fix). */
#game.story-mode {
  background:
    radial-gradient(ellipse 60% 40% at 12% 4%,   rgba(255,201,60,0.28) 0%, transparent 58%),
    radial-gradient(ellipse 55% 45% at 92% 8%,   rgba(76,201,255,0.24) 0%, transparent 58%),
    radial-gradient(ellipse 70% 50% at 50% 100%, rgba(45,212,164,0.18) 0%, transparent 60%),
    linear-gradient(180deg, #FFF6EE 0%, #FFE9D6 100%);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  justify-content: flex-start;
  justify-content: safe center;
}
#game.story-mode .progress-bar { display: none; } /* the trail replaces it */

.quest-chrome {
  width: 100%;
  max-width: 460px;
  margin: 0 auto var(--sp-2);
  padding: 0 var(--sp-3);
  flex: 0 0 auto;
}

/* header: title + step count */
.quest-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-2);
  margin-bottom: var(--sp-2);
}
.quest-title {
  font-weight: var(--fw-bold);
  font-size: 1.05rem;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.quest-step {
  flex: 0 0 auto;
  font-weight: var(--fw-bold);
  font-size: 0.85rem;
  color: var(--ink);
  background: linear-gradient(180deg, var(--sun) 0%, var(--sun-deep) 100%);
  border: 2px solid var(--sun-deep);
  border-radius: var(--r-full);
  padding: 2px 12px;
}

/* fox narrator + speech bubble */
.quest-narrator {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-2);
  margin-bottom: var(--sp-3);
}
.quest-fox {
  width: 64px;
  height: auto;
  flex: 0 0 auto;
  aspect-ratio: 577 / 640;
  filter: drop-shadow(0 4px 8px rgba(27,17,64,0.25));
}
.quest-fox-pop { animation: questFoxPop 0.5s var(--ease-bounce); }
.quest-bubble {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
  background: var(--paper);
  border: 3px solid var(--ink);
  border-radius: var(--r-md);
  padding: var(--sp-3) var(--sp-4);
  font-size: 1.02rem;
  font-weight: var(--fw-semi);
  line-height: 1.3;
  color: var(--ink);
  box-shadow: 0 4px 0 var(--shade-deep);
  text-align: left;
}
.quest-bubble::before {
  content: '';
  position: absolute;
  left: -13px; top: 22px;
  width: 0; height: 0;
  border: 7px solid transparent;
  border-right-color: var(--ink);
}
.quest-bubble::after {
  content: '';
  position: absolute;
  left: -8px; top: 24px;
  width: 0; height: 0;
  border: 5px solid transparent;
  border-right-color: var(--paper);
}

/* the trail of step "stones" */
.quest-trail {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--sp-1) 0;
}
.trail-node {
  flex: 0 0 auto;
  width: 34px; height: 34px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 3px solid var(--ink);
  background: var(--paper);
  box-shadow: 0 3px 0 var(--shade-deep);
  overflow: hidden;
}
.trail-node img { width: 100%; height: 100%; object-fit: contain; padding: 3px; }
.trail-emoji { font-size: 1rem; line-height: 1; }
.trail-node.done { background: linear-gradient(180deg, #9BF0CC 0%, var(--mint) 100%); }
.trail-node.current {
  background: linear-gradient(180deg, var(--sun) 0%, var(--sun-deep) 100%);
  border-color: var(--sun-deep);
  transform: scale(1.18);
  animation: trailPulse 1.6s ease-in-out infinite;
}
.trail-fox { font-size: 1.1rem; line-height: 1; }
.trail-node.todo {
  background: var(--frost-soft);
  border-style: dashed;
  border-color: var(--ink-soft);
  box-shadow: none;
  opacity: 0.7;
}
.trail-link {
  flex: 1 1 auto;
  height: 4px;
  min-width: 8px;
  max-width: 28px;
  background: var(--shade);
  border-radius: 2px;
}
.trail-link.lit { background: var(--mint); }

/* storybook cover page (during the intro narration) */
#game.quest-cover #target-area,
#game.quest-cover #camera-area,
#game.quest-cover #feedback-area,
#game.quest-cover .skip-area { display: none; }
#game.quest-cover .quest-chrome { margin-top: var(--sp-6); }
.quest-cover-art {
  font-size: 4.5rem;
  text-align: center;
  line-height: 1;
  filter: drop-shadow(0 6px 10px rgba(27,17,64,0.2));
  animation: questFoxPop 0.5s var(--ease-bounce);
}
.quest-cover-title {
  text-align: center;
  font-weight: var(--fw-bold);
  font-size: 1.6rem;
  color: var(--ink);
  margin: var(--sp-2) 0 var(--sp-4);
}

/* motion */
.quest-turn { animation: questTurn 0.42s var(--ease-smooth); }
@keyframes questTurn {
  from { opacity: 0; transform: translateX(18px); }
  to   { opacity: 1; transform: translateX(0); }
}
@keyframes questFoxPop {
  0% { transform: scale(0.6); }
  60% { transform: scale(1.15); }
  100% { transform: scale(1); }
}
@keyframes trailPulse {
  0%, 100% { box-shadow: 0 0 0 4px rgba(255,201,60,0.35), 0 3px 0 var(--sun-deep); }
  50% { box-shadow: 0 0 0 8px rgba(255,201,60,0.15), 0 3px 0 var(--sun-deep); }
}
@media (prefers-reduced-motion: reduce) {
  .quest-turn, .quest-fox-pop, .quest-cover-art, .trail-node.current { animation: none; }
}

/* ════════════════════════════════════════════════════════════
   STORY PICKER — storybook shelf (each quest is a little book)
   ════════════════════════════════════════════════════════════ */
.shelf-header {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  margin-bottom: var(--sp-5);
}
.shelf-fox {
  width: 54px; height: auto;
  aspect-ratio: 577 / 640;
  flex: 0 0 auto;
  filter: drop-shadow(0 3px 6px rgba(27,17,64,0.25));
}
.shelf-title { margin: 0; }

.story-shelf {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  width: 100%;
  max-width: 460px;
  margin: 0 auto;
}
.story-book {
  position: relative;
  display: flex;
  align-items: stretch;
  gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-5) var(--sp-2) 0;
  background: var(--paper);
  border: 3px solid var(--ink);
  border-radius: 7px var(--r-md) var(--r-md) 7px;
  box-shadow: 0 4px 0 var(--shade-deep), 0 10px 20px rgba(27,17,64,0.12);
  cursor: pointer;
  overflow: hidden;
  font-family: var(--font-main);
  text-align: left;
  transition: transform var(--dur-fast) var(--ease-bounce), box-shadow var(--dur-fast);
}
.story-book:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--shade-deep); }
.book-spine { flex: 0 0 12px; align-self: stretch; }
.book-cover {
  flex: 0 0 60px;
  align-self: center;
  height: 60px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--r-sm);
  margin: var(--sp-2) 0;
  box-shadow: inset 0 0 0 2px rgba(255,255,255,0.45), 0 2px 6px rgba(27,17,64,0.2);
}
.book-emoji { font-size: 2.1rem; line-height: 1; filter: drop-shadow(0 2px 3px rgba(0,0,0,0.25)); }
.book-info { display: flex; flex-direction: column; justify-content: center; gap: 3px; min-width: 0; flex: 1 1 auto; padding: var(--sp-2) 0; }
.book-title { font-weight: var(--fw-bold); font-size: 1.05rem; color: var(--ink); overflow-wrap: anywhere; line-height: 1.12; }
.book-meta { font-size: 0.8rem; font-weight: var(--fw-semi); color: var(--ink-soft); }
.book-dots { display: flex; gap: 4px; margin-top: 3px; flex-wrap: wrap; }
.book-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--shade-deep); flex: 0 0 auto; }
/* page-edge lines on the right edge of the book */
.story-book::after {
  content: '';
  position: absolute;
  right: 0; top: 7px; bottom: 7px;
  width: 5px;
  background: repeating-linear-gradient(180deg, rgba(27,17,64,0.16) 0 2px, transparent 2px 4px);
  border-left: 1px solid var(--shade-deep);
}
.book-ribbon {
  position: absolute; top: -3px; right: 16px;
  background: linear-gradient(180deg, #5FEAC0 0%, var(--mint) 100%);
  color: #fff; font-weight: 800; font-size: 0.82rem;
  padding: 5px 8px 7px; border-radius: 0 0 7px 7px;
  box-shadow: 0 2px 5px rgba(20,169,129,0.4);
}
.story-book.locked { opacity: 0.9; }
.story-book.story-completed .book-cover {
  box-shadow: inset 0 0 0 2px rgba(255,255,255,0.45), 0 0 0 3px rgba(45,212,164,0.45);
}

/* ════════════════════════════════════════════════════════════
   HOME GREETING — fox welcomes the child into the hub (first entry)
   ════════════════════════════════════════════════════════════ */
.home-greeting {
  position: fixed; inset: 0; z-index: 8000;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: var(--sp-4);
  padding: var(--sp-6);
  background:
    radial-gradient(ellipse 70% 50% at 50% 32%, rgba(255,201,60,0.40) 0%, transparent 62%),
    radial-gradient(ellipse 60% 45% at 85% 90%, rgba(76,201,255,0.22) 0%, transparent 60%),
    linear-gradient(180deg, #FFF6EE 0%, #FFE9D6 100%);
  cursor: pointer;
  animation: homeGreetIn 0.4s var(--ease-pop);
}
.home-greeting-out { animation: homeGreetOut 0.32s var(--ease-smooth) forwards; }
.home-greeting-fox {
  width: clamp(150px, 46vw, 230px); height: auto;
  aspect-ratio: 577 / 640;
  filter: drop-shadow(0 10px 22px rgba(27,17,64,0.28));
  animation: homeGreetFox 0.6s var(--ease-bounce);
}
.home-greeting-bubble {
  position: relative;
  max-width: 460px;
  background: var(--paper);
  border: 3px solid var(--ink);
  border-radius: var(--r-lg);
  padding: var(--sp-4) var(--sp-5);
  font-family: var(--font-main);
  font-weight: var(--fw-bold);
  font-size: clamp(1.1rem, 4.5vw, 1.4rem);
  line-height: 1.3;
  color: var(--ink);
  text-align: center;
  box-shadow: 0 5px 0 var(--shade-deep), 0 14px 30px rgba(27,17,64,0.18);
}
.home-greeting-bubble::before {
  content: ''; position: absolute; top: -14px; left: 50%; transform: translateX(-50%);
  border: 8px solid transparent; border-bottom-color: var(--ink);
}
.home-greeting-bubble::after {
  content: ''; position: absolute; top: -9px; left: 50%; transform: translateX(-50%);
  border: 6px solid transparent; border-bottom-color: var(--paper);
}
.home-greeting-skip {
  font-family: var(--font-main); font-weight: var(--fw-semi);
  font-size: 0.85rem; color: var(--ink-soft); opacity: 0.85;
}
@keyframes homeGreetIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes homeGreetOut { from { opacity: 1; } to { opacity: 0; } }
@keyframes homeGreetFox {
  0% { transform: scale(0.5) translateY(28px); }
  60% { transform: scale(1.08) translateY(0); }
  100% { transform: scale(1) translateY(0); }
}
@media (prefers-reduced-motion: reduce) {
  .home-greeting, .home-greeting-fox { animation: none; }
}
/* First-run parent card (privacy notice + bilingual opt-in). Scroll/safe-center
   per LESSONS-LEARNED so it can't clip on a short iOS viewport. */
.first-run-overlay {
  position: fixed; inset: 0; z-index: 8500;
  display: flex; align-items: flex-start; justify-content: center;
  overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding: max(var(--sp-5), env(safe-area-inset-top)) var(--sp-4) max(var(--sp-5), env(safe-area-inset-bottom));
  background:
    radial-gradient(ellipse 70% 50% at 50% 28%, rgba(255,201,60,0.38) 0%, transparent 62%),
    linear-gradient(180deg, #FFF6EE 0%, #FFE9D6 100%);
  animation: homeGreetIn 0.4s var(--ease-pop);
}
@supports (justify-content: safe center) { .first-run-overlay { justify-content: safe center; } }
.first-run-out { animation: homeGreetOut 0.3s var(--ease-smooth) forwards; }
.first-run-card {
  background: var(--paper); border: 3px solid var(--ink); border-radius: var(--r-lg);
  box-shadow: 0 6px 0 var(--shade-deep), 0 18px 40px rgba(27,17,64,0.20);
  padding: var(--sp-5) var(--sp-5) var(--sp-4);
  max-width: 420px; width: 100%; margin: auto; text-align: center;
}
.first-run-fox {
  width: clamp(96px, 26vw, 132px); height: auto; aspect-ratio: 577 / 640;
  filter: drop-shadow(0 8px 16px rgba(27,17,64,0.24)); margin-bottom: var(--sp-2);
}
.first-run-title {
  font-family: var(--font-main); font-weight: var(--fw-bold);
  font-size: clamp(1.3rem, 5vw, 1.6rem); color: var(--ink); margin: 0 0 var(--sp-3);
}
.first-run-privacy {
  font-family: var(--font-main); font-size: 0.98rem; line-height: 1.4;
  color: var(--ink-soft); margin: 0 0 var(--sp-3);
}
.first-run-divider { height: 2px; background: var(--ink); opacity: 0.12; border-radius: 2px; margin: var(--sp-3) auto; width: 80%; }
.first-run-q {
  font-family: var(--font-main); font-weight: var(--fw-semi);
  font-size: clamp(1.05rem, 4vw, 1.25rem); line-height: 1.35; color: var(--ink); margin: 0 0 var(--sp-4);
}
.first-run-free {
  display: inline-block; background: var(--mint, #34D6A4); color: #0A3D2C;
  font-size: 0.7rem; font-weight: var(--fw-bold); letter-spacing: 0.06em;
  padding: 2px 10px; border-radius: 999px; vertical-align: middle; margin-left: 4px;
}
.first-run-yes {
  display: block; width: 100%; min-height: 60px; box-sizing: border-box;
  background: linear-gradient(180deg, #5FEAC0 0%, #34D6A4 100%); color: #0A3D2C;
  border: 2px solid #0F8666; border-radius: var(--r-md, 16px);
  font-family: var(--font-main); font-weight: var(--fw-bold); font-size: 1.2rem;
  cursor: pointer; box-shadow: 0 4px 0 #0F8666; margin-bottom: var(--sp-2);
  transition: transform 0.14s var(--ease-bounce);
}
.first-run-yes:active { transform: translateY(4px); box-shadow: 0 0 0 #0F8666; }
.first-run-no {
  display: block; width: 100%; min-height: 48px; box-sizing: border-box;
  background: none; border: none; color: var(--ink-soft);
  font-family: var(--font-main); font-weight: var(--fw-semi); font-size: 1rem;
  text-decoration: underline; cursor: pointer;
}
@media (prefers-reduced-motion: reduce) {
  .first-run-overlay, .first-run-yes { animation: none; transition: none; }
}

.story-badge {
  display: inline-block;
  background: rgba(255,255,255,0.28);
  border: 1px solid rgba(255,255,255,0.45);
  border-radius: var(--r-full);
  padding: 2px 8px;
  font-size: 0.72rem;
  margin-right: 4px;
  font-weight: var(--fw-bold);
}

.back-btn {
  margin-top: var(--sp-3);
  background: var(--paper);
  color: var(--ink);
  border: 3px solid var(--ink);
  border-radius: var(--r-md);
  padding: var(--sp-3) var(--sp-6);
  font-size: 1.2rem;
  font-family: var(--font-main);
  font-weight: var(--fw-semi);
  cursor: pointer;
  min-height: 52px;
  box-shadow: 0 4px 0 var(--ink);
  transition: transform var(--dur-fast) var(--ease-bounce);
}
.back-btn:active {
  transform: translateY(4px);
  box-shadow: 0 0 0 var(--ink);
}


/* ════════════════════════════════════════════════════════════
   PAYWALL HELPERS — premium badge, play meter, upgrade CTA
   ════════════════════════════════════════════════════════════ */
.premium-badge {
  display: inline-block;
  background: linear-gradient(180deg, #FFE38B 0%, #FFC93C 100%);
  color: var(--ink);
  font-weight: var(--fw-bold);
  font-size: 0.9rem;
  letter-spacing: 0.08em;
  padding: 4px var(--sp-4);
  border-radius: var(--r-full);
  margin-bottom: var(--sp-4);
  border: 2px solid var(--sun-deep);
  box-shadow: 0 3px 0 var(--sun-deep);
}

.play-meter {
  font-size: 0.95rem;
  color: var(--ink-soft);
  font-weight: var(--fw-semi);
  margin-bottom: var(--sp-3);
}
.play-meter.warn {
  color: var(--coral-deep);
  font-weight: var(--fw-bold);
}

.upgrade-cta {
  background: linear-gradient(180deg, #FF6BB6 0%, #FF4FA8 50%, #E03A8E 100%);
  color: var(--paper);
  border: 3px solid var(--paper);
  border-radius: var(--r-full);
  padding: var(--sp-3) var(--sp-6);
  font-size: 1.1rem;
  font-family: var(--font-main);
  font-weight: var(--fw-bold);
  cursor: pointer;
  margin-bottom: var(--sp-4);
  min-height: 52px;
  box-shadow:
    0 5px 0 #B8226A,
    0 12px 24px rgba(255,79,168,0.45);
  letter-spacing: 0.02em;
  transition: transform var(--dur-fast) var(--ease-bounce);
}
.upgrade-cta:active {
  transform: translateY(4px);
  box-shadow: 0 1px 0 #B8226A, 0 4px 10px rgba(255,79,168,0.30);
}

/* Storyline hero — primary engagement entry, above the category grid */
.storyline-hero {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  width: 100%;
  text-align: left;
  background: linear-gradient(135deg, #7C4DFF 0%, #4C9CFF 100%);
  color: #fff;
  border: none;
  border-radius: var(--r-xl);
  padding: var(--sp-4) var(--sp-5);
  margin-bottom: var(--sp-4);
  cursor: pointer;
  font-family: var(--font-main);
  box-shadow: 0 5px 0 #3A2A8C, 0 12px 28px rgba(124,77,255,0.40);
  transition: transform var(--dur-fast) var(--ease-bounce);
}
.storyline-hero:active {
  transform: translateY(4px);
  box-shadow: 0 1px 0 #3A2A8C, 0 4px 12px rgba(124,77,255,0.30);
}
.storyline-hero.locked { opacity: 0.96; }
.storyline-hero-emoji {
  font-size: 2.6rem;
  line-height: 1;
  flex-shrink: 0;
  filter: drop-shadow(0 3px 5px rgba(0,0,0,0.25));
}
/* Hunt-buddy as the Story Quests guide */
.storyline-hero-fox {
  width: 58px;
  height: auto;
  aspect-ratio: 578 / 640;
  flex-shrink: 0;
  filter: drop-shadow(0 3px 6px rgba(0,0,0,0.30));
}
.storyline-hero-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.storyline-hero-title {
  font-size: 1.3rem;
  font-weight: var(--fw-bold);
  letter-spacing: 0.01em;
}
.storyline-hero-sub {
  font-size: 0.9rem;
  font-weight: var(--fw-reg, 600);
  opacity: 0.92;
  overflow-wrap: anywhere;
}


/* ════════════════════════════════════════════════════════════
   LANGUAGE PICKER MODAL
   ════════════════════════════════════════════════════════════ */
.lang-picker-modal {
  position: fixed; inset: 0;
  background: rgba(27,17,64,0.55);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  z-index: 500;
  display: flex;
  flex-direction: column;
  align-items: center;
  /* Top-anchor + safe-center + scroll: the 11 language options are taller than a
     short iOS viewport, so plain `center` + `overflow:visible` clipped the last
     options (Portuguese/Arabic) off-screen with no way to reach them. Now the
     list scrolls and every option is reachable. Safe-area padding keeps the
     first/last option clear of the notch and home indicator. */
  justify-content: flex-start;
  justify-content: safe center;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding: max(var(--sp-5), env(safe-area-inset-top)) var(--sp-5) max(var(--sp-5), env(safe-area-inset-bottom));
  gap: var(--sp-3);
}
.lang-picker-title {
  color: var(--paper);
  font-size: clamp(1.4rem, 5vw, 2rem);
  font-weight: var(--fw-bold);
  margin-bottom: var(--sp-3);
}
.lang-picker-option {
  background: var(--paper);
  border: 3px solid var(--ink);
  border-radius: var(--r-md);
  padding: var(--sp-3) var(--sp-5);
  font-family: var(--font-main);
  font-weight: var(--fw-semi);
  font-size: 1.1rem;
  color: var(--ink);
  cursor: pointer;
  min-width: 200px;
  min-height: 52px;
  box-shadow: 0 4px 0 var(--ink);
  transition: transform var(--dur-fast) var(--ease-bounce);
}
.lang-picker-option:active {
  transform: translateY(4px);
  box-shadow: 0 0 0 var(--ink);
}
.lang-picker-option.locked { opacity: 0.6; }
.lang-picker-option.selected {
  background: linear-gradient(180deg, #4FE3B6 0%, #2DD4A4 100%);
  color: var(--paper);
  border-color: var(--mint-deep);
  box-shadow: 0 4px 0 var(--mint-deep), 0 8px 16px rgba(45,212,164,0.35);
}


/* ════════════════════════════════════════════════════════════
   ANIMATIONS — Delight & feedback
   ════════════════════════════════════════════════════════════ */
@keyframes landingBounce {
  0%, 100% { transform: translateY(0) scale(1); }
  50%      { transform: translateY(-10px) scale(1.025); }
}

@keyframes shimmer {
  0%, 100% { transform: translateX(-110%); }
  50%      { transform: translateX(110%); }
}

@keyframes targetFloat {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  33%      { transform: translateY(-14px) rotate(2deg); }
  66%      { transform: translateY(-6px) rotate(-2deg); }
}

@keyframes spotlightPulse {
  0%, 100% { opacity: 0.6; transform: translateX(-50%) scale(1); }
  50%      { opacity: 1;   transform: translateX(-50%) scale(1.12); }
}

@keyframes cameraPulse {
  0%   { box-shadow: 0 0 0 0 rgba(45,212,164,0.55); }
  70%  { box-shadow: 0 0 0 18px rgba(45,212,164,0); }
  100% { box-shadow: 0 0 0 0 rgba(45,212,164,0); }
}

@keyframes cardWobble {
  0%, 100% { transform: rotate(0deg) translateY(0); }
  25%      { transform: rotate(0.6deg) translateY(-1px); }
  75%      { transform: rotate(-0.6deg) translateY(-1px); }
}

@keyframes progressShimmer {
  0%   { background-position: 0% 50%; }
  100% { background-position: 250% 50%; }
}

@keyframes floatSlow {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33%      { transform: translate(14px, -18px) scale(1.06); }
  66%      { transform: translate(-10px, 12px) scale(0.96); }
}

@keyframes starDrift {
  0%   { transform: translate(0, 0); }
  50%  { transform: translate(6px, -6px); }
  100% { transform: translate(-6px, 6px); }
}

@keyframes victoryBounce {
  0%, 100% { transform: translateY(0) scale(1); }
  30%      { transform: translateY(-22px) scale(1.06); }
  50%      { transform: translateY(-8px)  scale(1.02); }
  70%      { transform: translateY(-14px) scale(1.04); }
}

@keyframes victoryFloat {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50%      { transform: translateY(-16px) rotate(4deg); }
}

@keyframes popIn {
  0%   { transform: scale(0);    opacity: 0; }
  70%  { transform: scale(1.15); }
  100% { transform: scale(1);    opacity: 1; }
}

@keyframes wiggle {
  0%, 100% { transform: translateX(0); }
  20%      { transform: translateX(-12px); }
  40%      { transform: translateX(12px); }
  60%      { transform: translateX(-8px); }
  80%      { transform: translateX(8px); }
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes cardBounce {
  0%   { transform: scale(1); }
  40%  { transform: scale(0.85); }
  70%  { transform: scale(1.10); }
  100% { transform: scale(1); }
}

@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-15px); }
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-10px); }
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.06); }
}
.pulse {
  animation: pulse 1.5s ease-in-out infinite !important;
}

@keyframes pulseOnce {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.12); }
  100% { transform: scale(1); }
}
.pulse-once {
  animation: pulseOnce 0.7s var(--ease-bounce) !important;
}


/* ════════════════════════════════════════════════════════════
   SAFE AREA — Notch / home indicator
   ════════════════════════════════════════════════════════════ */
@supports (padding: env(safe-area-inset-top)) {
  #game {
    padding-top: calc(var(--sp-5) + env(safe-area-inset-top));
    padding-bottom: calc(var(--sp-5) + env(safe-area-inset-bottom));
  }
  .camera-area { margin-bottom: calc(var(--sp-6) + env(safe-area-inset-bottom)); }
  .setup-container {
    padding-top: calc(var(--sp-10) + env(safe-area-inset-top));
    padding-bottom: calc(var(--sp-10) + env(safe-area-inset-bottom));
  }
}


/* ════════════════════════════════════════════════════════════
   PORTRAIT LOCK — the game is portrait-only. Phones in landscape get a
   rotate prompt instead of the broken layout (camera fell below a
   non-scrolling fixed screen). Tablets (height ≥ ~744px) are unaffected.
   ════════════════════════════════════════════════════════════ */
#rotate-lock { display: none; }
@media (orientation: landscape) and (max-height: 600px) {
  #rotate-lock {
    display: flex;
    position: fixed; inset: 0; z-index: 9000;
    flex-direction: column; align-items: center; justify-content: center;
    gap: var(--sp-4); padding: var(--sp-6);
    text-align: center;
    background:
      radial-gradient(ellipse 80% 70% at 30% 20%, rgba(255,201,60,0.50) 0%, transparent 60%),
      radial-gradient(ellipse 80% 70% at 80% 85%, rgba(111,75,255,0.45) 0%, transparent 60%),
      var(--paper-warm);
  }
  #rotate-lock img {
    width: clamp(80px, 24vh, 150px); height: auto;
    animation: rotateNudge 2.4s var(--ease-smooth) infinite;
  }
  #rotate-lock p {
    font-size: clamp(1.1rem, 4.6vh, 1.6rem);
    font-weight: var(--fw-bold); color: var(--ink); line-height: 1.35;
  }
}
@keyframes rotateNudge {
  0%, 58%, 100% { transform: rotate(0deg); }
  74%, 88% { transform: rotate(-16deg); }
}


/* ════════════════════════════════════════════════════════════
   RESPONSIVE — Fire tablet 600px + iPhone Safari
   ════════════════════════════════════════════════════════════ */

/* Small phones — slightly tighter */
@media (max-width: 380px) {
  .category-grid {
    grid-template-columns: 1fr 1fr;
    gap: var(--sp-2);
  }
  .category-card {
    padding: var(--sp-4) var(--sp-2);
    min-height: 108px;
  }
  .cat-emoji { font-size: 2.5rem; }
  .camera-btn {
    padding: var(--sp-6) var(--sp-10) !important;
    min-height: 108px !important;
    font-size: 3.2rem !important;
  }
}

/* Tablets — bigger sticker cards */
@media (min-width: 700px) {
  .category-grid {
    grid-template-columns: 1fr 1fr 1fr;
    max-width: 720px;
    margin: 0 auto;
    gap: var(--sp-4);
  }
  .category-card {
    min-height: 144px;
    padding: var(--sp-6) var(--sp-4);
  }
  /* Match the story grid to the category grid so the adventure modes don't look
     under-built next to it on a tablet. */
  .story-grid {
    grid-template-columns: 1fr 1fr 1fr;
    max-width: 720px;
    margin-left: auto;
    margin-right: auto;
  }
  .story-card { min-height: 104px; }
  .target-area { padding: var(--sp-8) var(--sp-6) var(--sp-5); }
}

/* Landscape phones — compress vertical space */
@media (max-height: 500px) {
  .landing-fox { width: clamp(72px, 16vh, 120px); margin-bottom: var(--sp-1); }
  .landing-sub { margin: var(--sp-3) 0 var(--sp-6); }
  .landing-play-btn { padding: var(--sp-4) var(--sp-10); min-height: 88px; }
  .target-emoji { font-size: clamp(3.5rem, 15vw, 6rem); }
  .victory-emoji { margin: var(--sp-3) 0; }
  .victory-fox { width: clamp(96px, 26vh, 150px); margin: var(--sp-2) auto; }
  .target-area { padding: var(--sp-3) var(--sp-4); }
}

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