/* =========================================================
   Adanv — Memory Games | Pro UX/UI
   Design tokens, mobile-first, dark mode, reduced-motion
   ========================================================= */

/* ---------- Tokens ---------- */
:root {
  /* Brand */
  --c-primary: #7C5CFF;
  --c-primary-600: #6A47F0;
  --c-primary-50: #EFEAFF;
  --c-accent: #FF6BC1;
  --c-accent-2: #FFC542;
  --c-mint: #45E0B8;
  --c-sky: #5AC8FF;

  /* Surfaces */
  --c-bg: #FAF7FF;
  --c-bg-elev: #FFFFFF;
  --c-surface: #FFFFFF;
  --c-surface-2: #F4F0FF;
  --c-border: #E8E2F8;

  /* Text */
  --c-text: #1B1437;
  --c-text-muted: #5C5478;
  --c-text-soft: #8A82A4;
  --c-on-primary: #FFFFFF;

  /* Status */
  --c-success: #1FB67A;
  --c-error: #E5484D;

  /* Radii */
  --r-sm: 8px;
  --r-md: 14px;
  --r-lg: 22px;
  --r-xl: 32px;
  --r-pill: 999px;

  /* Shadows */
  --sh-sm: 0 2px 6px rgba(28, 20, 55, 0.06);
  --sh-md: 0 8px 24px rgba(28, 20, 55, 0.08);
  --sh-lg: 0 24px 60px rgba(28, 20, 55, 0.18);
  --sh-glow: 0 10px 30px rgba(124, 92, 255, 0.35);

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

  /* Type */
  --f-display: 'Fredoka', system-ui, sans-serif;
  --f-body: 'Nunito', system-ui, sans-serif;

  /* Motion */
  --t-fast: 140ms;
  --t-base: 220ms;
  --t-slow: 320ms;
  --ease-out: cubic-bezier(.2,.8,.2,1);
  --ease-in:  cubic-bezier(.4,.0,1,1);
  --ease: cubic-bezier(.2,.8,.2,1);
}

[data-theme="dark"] {
  --c-bg: #0E0B1F;
  --c-bg-elev: #181230;
  --c-surface: #1B1538;
  --c-surface-2: #251D49;
  --c-border: #312763;

  --c-text: #F4F1FF;
  --c-text-muted: #B7AED9;
  --c-text-soft: #8479B7;

  --sh-sm: 0 2px 6px rgba(0,0,0,.4);
  --sh-md: 0 8px 24px rgba(0,0,0,.45);
  --sh-lg: 0 24px 60px rgba(0,0,0,.55);
  --sh-glow: 0 10px 30px rgba(124, 92, 255, .55);
}

/* ---------- Reset ---------- */
*, *::before, *::after {
  box-sizing: border-box;
  /* Default to no double-tap zoom across the app. Tetris/Snake override with touch-action: none for swipes. */
  touch-action: manipulation;
}
html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}
body {
  margin: 0;
  font-family: var(--f-body);
  font-size: 16px;
  line-height: 1.6;
  color: var(--c-text);
  background: var(--c-bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
img, svg { display: block; max-width: 100%; }
button {
  font: inherit; cursor: pointer; border: 0; background: none; color: inherit;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
a { color: inherit; text-decoration: none; }
ul, ol { list-style: none; padding: 0; margin: 0; }
h1, h2, h3, h4 { font-family: var(--f-display); font-weight: 600; line-height: 1.15; margin: 0; color: var(--c-text); }
h1 { font-size: clamp(2rem, 4.6vw + 1rem, 3.75rem); letter-spacing: -0.02em; }
h2 { font-size: clamp(1.6rem, 2.4vw + 1rem, 2.4rem); letter-spacing: -0.01em; }
h3 { font-size: 1.25rem; }
p { margin: 0; }

:focus-visible {
  outline: 3px solid var(--c-primary);
  outline-offset: 3px;
  border-radius: 4px;
}

.skip-link {
  position: absolute; left: -9999px; top: 0;
  background: var(--c-primary); color: #fff; padding: 12px 16px;
  border-radius: 0 0 var(--r-md) 0; z-index: 1000; font-weight: 700;
}
.skip-link:focus { left: 0; }

.container {
  width: min(1200px, 100% - 32px);
  margin-inline: auto;
}

.eyebrow {
  display: inline-block;
  font-family: var(--f-display);
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--c-primary);
  background: var(--c-primary-50);
  padding: 6px 12px;
  border-radius: var(--r-pill);
  letter-spacing: .04em;
  margin-bottom: var(--s-3);
}
[data-theme="dark"] .eyebrow {
  background: rgba(124, 92, 255, .18);
  color: #C9BBFF;
}

.grad-text {
  background: linear-gradient(95deg, var(--c-primary) 0%, var(--c-accent) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* ---------- Header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  backdrop-filter: saturate(160%) blur(14px);
  -webkit-backdrop-filter: saturate(160%) blur(14px);
  background: color-mix(in srgb, var(--c-bg) 85%, transparent);
  border-bottom: 1px solid var(--c-border);
}
.header-row {
  display: flex; align-items: center; justify-content: space-between;
  height: 68px; gap: var(--s-4);
}
.brand {
  display: inline-flex; align-items: center; gap: 10px;
  font-family: var(--f-display); font-weight: 700; font-size: 1.25rem;
  color: var(--c-text);
}
.brand-mark { width: 36px; height: 36px; border-radius: 10px; box-shadow: var(--sh-sm); }
.brand-mark svg { width: 100%; height: 100%; }
.brand-tld { color: var(--c-text-soft); font-weight: 500; }
.brand-v {
  background: linear-gradient(135deg, var(--c-primary), var(--c-accent));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  font-weight: 700;
}
.brand.small { font-size: 1rem; }
.brand.small .brand-mark { width: 28px; height: 28px; border-radius: 8px; }

.primary-nav {
  display: none; gap: var(--s-6);
  font-weight: 700; color: var(--c-text-muted);
}
.primary-nav a {
  padding: 10px 14px; border-radius: var(--r-pill);
  transition: color var(--t-fast) var(--ease), background var(--t-fast) var(--ease);
  min-height: 44px; display: inline-flex; align-items: center; gap: 6px;
}
.primary-nav a svg { width: 16px; height: 16px; }
.primary-nav .nav-trophy { color: var(--c-primary); }
.primary-nav a:hover, .primary-nav a:focus-visible {
  color: var(--c-primary); background: var(--c-primary-50);
}
[data-theme="dark"] .primary-nav a:hover, [data-theme="dark"] .primary-nav a:focus-visible {
  background: rgba(124,92,255,.16); color: #C9BBFF;
}
@media (min-width: 768px) { .primary-nav { display: inline-flex; } }

.header-tools { display: inline-flex; align-items: center; gap: var(--s-2); }

.player-pill {
  display: inline-flex; align-items: center; gap: 10px;
  height: 44px; padding: 0 14px 0 10px;
  border-radius: var(--r-pill);
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  color: var(--c-text);
  transition: transform var(--t-fast) var(--ease), background var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease);
  max-width: 220px;
}
.player-pill:hover { background: var(--c-surface-2); border-color: color-mix(in srgb, var(--c-primary) 35%, var(--c-border)); }
.player-pill:active { transform: scale(.97); }
.player-pill-icon {
  width: 28px; height: 28px;
  padding: 5px; border-radius: 50%;
  background: linear-gradient(135deg, var(--c-primary), var(--c-accent));
  color: white; flex-shrink: 0;
}
.player-pill-text {
  display: flex; flex-direction: column; align-items: flex-start;
  line-height: 1.05; min-width: 0;
}
.player-pill-label {
  font-size: .68rem; font-weight: 700; letter-spacing: .08em;
  text-transform: uppercase; color: var(--c-text-soft);
}
.player-pill-name {
  font-family: var(--f-display); font-weight: 600; font-size: .95rem;
  max-width: 150px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  display: inline-flex; align-items: center; gap: 6px;
}
.flag-slot { display: inline-flex; align-items: center; }
.flag {
  width: 20px; height: 15px;
  border-radius: 2px;
  display: inline-block;
  vertical-align: middle;
  object-fit: cover;
  border: 1px solid color-mix(in srgb, var(--c-border) 60%, transparent);
  background: var(--c-surface-2);
  flex-shrink: 0;
}
.flag.sm { width: 18px; height: 13px; }
.flag.lg { width: 28px; height: 21px; }
@media (max-width: 480px) {
  .player-pill-text { display: none; }
  .player-pill { padding: 0 6px; }
  .streak-pill-text { display: none; }
  .streak-pill { padding: 0 8px; }
}

/* ---- Streak pill (header) ---- */
.streak-pill {
  display: inline-flex; align-items: center; gap: 8px;
  height: 44px; padding: 0 12px 0 10px;
  border-radius: var(--r-pill);
  background: linear-gradient(135deg, color-mix(in srgb, #FF7A3D 18%, var(--c-surface)), color-mix(in srgb, #FFC542 18%, var(--c-surface)));
  border: 1px solid color-mix(in srgb, #FF7A3D 25%, var(--c-border));
  color: var(--c-text);
  transition: transform var(--t-fast) var(--ease), background var(--t-fast) var(--ease);
}
.streak-pill:hover { transform: translateY(-1px); }
.streak-pill:active { transform: scale(.97); }
.streak-flame {
  font-size: 1.2rem;
  filter: drop-shadow(0 0 4px rgba(255, 122, 61, .5));
  animation: flame-flicker 2s var(--ease) infinite;
}
@keyframes flame-flicker {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.08) rotate(-2deg); }
}
.streak-pill-text {
  display: flex; flex-direction: column; align-items: flex-start;
  line-height: 1.05;
}
.streak-pill-label {
  font-size: .68rem; font-weight: 700; letter-spacing: .08em;
  text-transform: uppercase; color: var(--c-text-soft);
}
.streak-pill-num {
  font-family: var(--f-display); font-weight: 700; font-size: 1rem;
  color: #E85D1F;
}
.streak-pill-unit { font-size: .85em; opacity: .8; margin-left: 1px; }
[data-theme="dark"] .streak-pill-num { color: #FFB58A; }

/* ---- Streak modal ---- */
.streak-panel { max-width: 520px; }
.streak-hero {
  text-align: center; padding: var(--s-3) 0 var(--s-2);
}
.streak-flame-big {
  font-size: 4rem; line-height: 1;
  filter: drop-shadow(0 0 16px rgba(255, 122, 61, .6));
  animation: flame-flicker 1.6s var(--ease) infinite;
}
.streak-hero-num {
  font-family: var(--f-display); font-weight: 800; font-size: 3.6rem;
  background: linear-gradient(135deg, #FF7A3D, #FFC542);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  line-height: 1;
}
.streak-hero-label {
  font-weight: 700; color: var(--c-text-soft); text-transform: uppercase;
  letter-spacing: .08em; font-size: .85rem;
}
.streak-tier {
  text-align: center; min-height: 1.4em;
  font-weight: 700; margin: var(--s-3) 0;
  color: var(--c-primary);
}
.streak-stats {
  display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-3);
  margin: var(--s-3) 0;
}
.streak-stat {
  display: flex; flex-direction: column; align-items: center;
  padding: var(--s-3); border-radius: var(--r-md);
  background: var(--c-surface-2); border: 1px solid var(--c-border);
}
.streak-stat-label {
  font-size: .72rem; font-weight: 700; letter-spacing: .06em;
  text-transform: uppercase; color: var(--c-text-soft);
}
.streak-stat-val {
  font-family: var(--f-display); font-weight: 700; font-size: 1.6rem;
  color: var(--c-text);
}
.streak-cal-head {
  font-weight: 700; font-size: .82rem; text-transform: uppercase;
  letter-spacing: .06em; color: var(--c-text-soft);
  margin: var(--s-4) 0 var(--s-2);
}
.streak-cal {
  display: grid; grid-template-columns: repeat(10, 1fr); gap: 4px;
}
.streak-cell {
  aspect-ratio: 1; border-radius: 6px;
  background: var(--c-surface-2); border: 1px solid var(--c-border);
  position: relative;
  transition: transform var(--t-fast) var(--ease);
}
.streak-cell.active {
  background: linear-gradient(135deg, #FF7A3D, #FFC542);
  border-color: #FF7A3D;
  box-shadow: 0 0 6px rgba(255, 122, 61, .4);
}
.streak-cell.today {
  outline: 2px solid var(--c-primary); outline-offset: 1px;
}
.streak-tiers {
  display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px;
  margin-top: var(--s-4);
}
.streak-tier-item {
  display: flex; flex-direction: column; align-items: center;
  padding: 8px 4px; border-radius: var(--r-md);
  background: var(--c-surface-2); border: 1px solid var(--c-border);
  text-align: center;
  opacity: .55;
  transition: opacity var(--t-base) var(--ease);
}
.streak-tier-item.unlocked { opacity: 1; border-color: color-mix(in srgb, var(--c-primary) 35%, var(--c-border)); }
.streak-tier-emoji { font-size: 1.4rem; line-height: 1; }
.streak-tier-name { font-weight: 700; font-size: .82rem; margin-top: 2px; }
.streak-tier-days { font-size: .7rem; color: var(--c-text-soft); }

/* milestone-toast keyframes (still used by streak celebration) */
@keyframes install-rise {
  from { opacity: 0; transform: translate(-50%, 8px); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}

.theme-toggle {
  width: 44px; height: 44px;
  border-radius: var(--r-pill);
  display: inline-grid; place-items: center;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  color: var(--c-text-muted);
  transition: transform var(--t-fast) var(--ease), background var(--t-fast) var(--ease);
}
.theme-toggle:hover { transform: translateY(-1px); }
.theme-toggle:active { transform: translateY(0) scale(.96); }
.theme-toggle .icon { width: 20px; height: 20px; }
.theme-toggle .icon-moon { display: none; }
[data-theme="dark"] .theme-toggle .icon-sun { display: none; }
[data-theme="dark"] .theme-toggle .icon-moon { display: block; }

/* ---------- Hero ---------- */
.hero { position: relative; padding: var(--s-12) 0 var(--s-16); overflow: hidden; }
.hero-inner {
  display: grid; gap: var(--s-10);
  grid-template-columns: 1fr;
  align-items: center;
  position: relative; z-index: 1;
}
@media (min-width: 960px) { .hero-inner { grid-template-columns: 1.1fr 1fr; gap: var(--s-16); } }

.lede { font-size: 1.125rem; color: var(--c-text-muted); max-width: 56ch; margin-top: var(--s-4); }

.hero-cta { display: flex; flex-wrap: wrap; gap: var(--s-3); margin-top: var(--s-8); }

.btn {
  display: inline-flex; align-items: center; gap: 10px;
  min-height: 52px; padding: 0 26px;
  border-radius: var(--r-pill);
  font-family: var(--f-display); font-weight: 600; font-size: 1.05rem;
  transition: transform var(--t-fast) var(--ease),
              box-shadow var(--t-fast) var(--ease),
              background var(--t-fast) var(--ease),
              color var(--t-fast) var(--ease);
  white-space: nowrap;
}
.btn svg { width: 20px; height: 20px; }
.btn-primary {
  background: linear-gradient(95deg, var(--c-primary), var(--c-accent));
  color: var(--c-on-primary);
  box-shadow: var(--sh-glow);
}
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 16px 40px rgba(124,92,255,.45); }
.btn-primary:active { transform: translateY(0) scale(.98); }
.btn-ghost {
  background: var(--c-surface); color: var(--c-text);
  border: 1px solid var(--c-border);
}
.btn-ghost:hover { background: var(--c-surface-2); transform: translateY(-1px); }
.btn-ghost:active { transform: translateY(0) scale(.98); }

.hero-stats {
  display: flex; flex-wrap: wrap; gap: var(--s-6) var(--s-10); margin-top: var(--s-10);
}
.hero-stats li { display: flex; flex-direction: column; }
.hero-stats strong {
  font-family: var(--f-display); font-size: 2rem; font-weight: 700;
  color: var(--c-text); line-height: 1;
}
.hero-stats span { color: var(--c-text-muted); font-size: 0.95rem; margin-top: 2px; }

/* Floating cards art */
.hero-art { position: relative; min-height: 360px; }
.card-stack { position: relative; width: 100%; height: 100%; min-height: 360px; }
.float-card {
  position: absolute;
  width: 110px; height: 140px; border-radius: 22px;
  background: var(--c-surface);
  display: grid; place-items: center;
  font-size: 60px;
  box-shadow: var(--sh-md);
  border: 1px solid var(--c-border);
  animation: floaty 6s var(--ease) infinite;
}
.float-card.back {
  background: linear-gradient(135deg, var(--c-primary), var(--c-accent));
  background-image:
    radial-gradient(circle at 30% 30%, rgba(255,255,255,.25), transparent 40%),
    linear-gradient(135deg, var(--c-primary), var(--c-accent));
}
.float-card.c1 { top: 6%;  left: 8%;  transform: rotate(-12deg); animation-delay: 0s; }
.float-card.c2 { top: 2%;  right: 14%; transform: rotate(10deg); animation-delay: .6s; }
.float-card.c3 { top: 38%; left: 30%; transform: rotate(-3deg); animation-delay: 1.2s; z-index: 2; }
.float-card.c4 { bottom: 8%; left: 6%; transform: rotate(8deg); animation-delay: 1.8s; }
.float-card.c5 { bottom: 14%; right: 8%; transform: rotate(-8deg); animation-delay: 2.4s; }
.float-card.c6 { top: 22%; right: 0%; transform: rotate(14deg); animation-delay: 3s; width: 100px; height: 130px; }
@keyframes floaty {
  0%, 100% { translate: 0 0; }
  50% { translate: 0 -10px; }
}

/* Hero blobs */
.hero-blob {
  position: absolute; border-radius: 50%;
  filter: blur(60px); opacity: .55;
  pointer-events: none; z-index: 0;
}
.blob-a { width: 380px; height: 380px; background: var(--c-accent); top: -80px; right: -80px; }
.blob-b { width: 320px; height: 320px; background: var(--c-mint); bottom: -120px; left: -100px; opacity: .35; }
[data-theme="dark"] .blob-a { opacity: .35; }
[data-theme="dark"] .blob-b { opacity: .25; }

/* ---------- Section heads ---------- */
.section-head { text-align: center; max-width: 640px; margin: 0 auto var(--s-10); }
.section-head p { color: var(--c-text-muted); margin-top: var(--s-3); font-size: 1.05rem; }

/* ---------- Games grid ---------- */
.games { padding: var(--s-16) 0; }
.game-grid {
  display: grid; gap: var(--s-5);
  grid-template-columns: 1fr;
}
@media (min-width: 720px) { .game-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1024px) { .game-grid { grid-template-columns: repeat(3, 1fr); } }

.game-card {
  position: relative;
  padding: var(--s-6);
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-xl);
  box-shadow: var(--sh-sm);
  display: flex; flex-direction: column; gap: var(--s-5);
  cursor: pointer;
  transition: transform var(--t-base) var(--ease), box-shadow var(--t-base) var(--ease), border-color var(--t-base) var(--ease);
  overflow: hidden;
  isolation: isolate;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}
.game-card::before {
  content: ""; position: absolute; inset: 0; z-index: -1;
  background: radial-gradient(140% 90% at 100% 0%, rgba(124,92,255,.08), transparent 60%);
  opacity: 0; transition: opacity var(--t-base) var(--ease);
}
.game-card:hover, .game-card:focus-visible {
  transform: translateY(-4px);
  box-shadow: var(--sh-lg);
  border-color: color-mix(in srgb, var(--c-primary) 40%, var(--c-border));
}
.game-card:hover::before, .game-card:focus-visible::before { opacity: 1; }
.game-card:active { transform: translateY(-1px) scale(.995); }

.game-illu {
  height: 140px; border-radius: var(--r-lg);
  display: grid; place-items: center;
  position: relative;
  background: linear-gradient(135deg, var(--c-surface-2), var(--c-bg-elev));
  border: 1px solid var(--c-border);
  overflow: hidden;
}

/* match illu */
.illu-match {
  display: grid; grid-template-columns: repeat(2, 56px); gap: 10px;
  padding: 12px;
}
.illu-match .mini-card {
  width: 56px; height: 70px; border-radius: 12px;
  background: var(--c-surface);
  display: grid; place-items: center;
  font-size: 28px;
  box-shadow: var(--sh-sm);
  border: 1px solid var(--c-border);
}
.illu-match .mini-card.back {
  background: linear-gradient(135deg, var(--c-primary), var(--c-accent));
  background-image:
    radial-gradient(circle at 30% 30%, rgba(255,255,255,.3), transparent 50%),
    linear-gradient(135deg, var(--c-primary), var(--c-accent));
}

/* echo illu */
.illu-echo {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px;
  padding: 16px; width: 130px; height: 130px; place-items: stretch;
}
.illu-echo .dot { border-radius: 18px; box-shadow: inset 0 -4px 0 rgba(0,0,0,.12); }
.illu-echo .d1 { background: #FF6BC1; }
.illu-echo .d2 { background: #FFC542; }
.illu-echo .d3 { background: #5AC8FF; }
.illu-echo .d4 { background: #45E0B8; }

/* missing illu */
.illu-missing { display: flex; gap: 8px; font-size: 36px; }
.illu-missing .ghost {
  width: 44px; height: 44px; border-radius: 50%;
  background: var(--c-surface); border: 2px dashed var(--c-border);
  display: grid; place-items: center; font-size: 22px; color: var(--c-text-soft);
  font-family: var(--f-display);
}

/* tetris illu */
.illu-tetris {
  display: grid;
  grid-template-columns: repeat(4, 24px);
  grid-template-rows: repeat(4, 24px);
  gap: 4px;
  padding: 14px;
}
.illu-tetris .t-block {
  display: block;
  width: 24px; height: 24px;
  border-radius: 5px;
  box-shadow: inset 0 -3px 0 rgba(0,0,0,.18), inset 0 2px 0 rgba(255,255,255,.25);
}
.illu-tetris .t1 { grid-column: 1; grid-row: 4; background: #5AC8FF; }
.illu-tetris .t2 { grid-column: 2; grid-row: 4; background: #5AC8FF; }
.illu-tetris .t3 { grid-column: 2; grid-row: 3; background: #FFC542; }
.illu-tetris .t4 { grid-column: 3; grid-row: 3; background: #FFC542; }
.illu-tetris .t5 { grid-column: 3; grid-row: 4; background: #FF6BC1; }
.illu-tetris .t6 { grid-column: 4; grid-row: 4; background: #45E0B8; }

/* snake illu */
.illu-snake {
  display: grid;
  grid-template-columns: repeat(6, 18px);
  grid-template-rows: repeat(4, 18px);
  gap: 3px;
  padding: 14px;
}
.illu-snake .s-cell {
  display: block;
  width: 18px; height: 18px;
  border-radius: 4px;
  background: #45E0B8;
  box-shadow: inset 0 -2px 0 rgba(0,0,0,.15);
}
.illu-snake .s1 { grid-column: 1; grid-row: 3; }
.illu-snake .s2 { grid-column: 2; grid-row: 3; }
.illu-snake .s3 { grid-column: 3; grid-row: 3; }
.illu-snake .s4 { grid-column: 3; grid-row: 2; background: #2FC79A; }
.illu-snake .s-food { grid-column: 5; grid-row: 2; font-size: 20px; align-self: center; justify-self: center; }

/* math illu */
.illu-math {
  display: flex; align-items: center; gap: 8px;
  font-family: var(--f-display); font-weight: 800;
  padding: 14px;
}
.illu-math .m-num {
  width: 38px; height: 44px;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: 10px;
  display: grid; place-items: center;
  font-size: 24px;
  box-shadow: var(--sh-sm);
  color: var(--c-primary);
}
.illu-math .m-op { font-size: 22px; color: var(--c-text-muted); }
.illu-math .m-q {
  background: linear-gradient(135deg, var(--c-primary), var(--c-accent));
  color: #fff; border-color: transparent;
}

/* word scramble illu */
.illu-scramble { display: flex; gap: 6px; padding: 14px; flex-wrap: nowrap; }
.illu-scramble .ws-tile {
  width: 28px; height: 36px;
  display: grid; place-items: center;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: 8px;
  font-family: var(--f-display); font-weight: 800; font-size: 18px;
  color: var(--c-primary);
  box-shadow: var(--sh-sm);
}
.illu-scramble .ws-tile:nth-child(2) { transform: rotate(-6deg); background: var(--c-primary-50); }
.illu-scramble .ws-tile:nth-child(4) { transform: rotate(5deg); background: var(--c-primary-50); }

/* missing letter illu */
.illu-spell { display: flex; gap: 8px; padding: 14px; align-items: center; }
.illu-spell .ml-tile {
  width: 38px; height: 44px;
  display: grid; place-items: center;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: 10px;
  font-family: var(--f-display); font-weight: 800; font-size: 22px;
  color: var(--c-primary);
  box-shadow: var(--sh-sm);
}
.illu-spell .ml-blank {
  background: linear-gradient(135deg, var(--c-primary), var(--c-accent));
  color: #fff; border-color: transparent;
}

/* rhyme illu */
.illu-rhyme { display: flex; flex-direction: column; gap: 8px; padding: 14px; align-items: flex-start; }
.illu-rhyme .rh-word {
  display: inline-block;
  font-family: var(--f-display); font-weight: 800; font-size: 18px;
  padding: 6px 14px; border-radius: var(--r-pill);
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  color: var(--c-primary);
  box-shadow: var(--sh-sm);
}
.illu-rhyme .rh-target {
  background: linear-gradient(135deg, var(--c-primary), var(--c-accent));
  color: #fff; border-color: transparent;
}
.illu-rhyme .rh-match { margin-left: 18px; }

.game-meta h3 { margin-bottom: 6px; }
.game-meta p { color: var(--c-text-muted); }

.tag-row { display: flex; gap: var(--s-2); margin-top: var(--s-3); flex-wrap: wrap; }
.tag {
  display: inline-block; font-size: .8rem; font-weight: 700;
  padding: 4px 10px; border-radius: var(--r-pill);
  background: var(--c-surface-2); color: var(--c-text-muted);
}

.play-arrow {
  position: absolute; top: var(--s-5); right: var(--s-5);
  width: 40px; height: 40px; border-radius: var(--r-pill);
  display: grid; place-items: center;
  background: var(--c-primary); color: white;
  transition: transform var(--t-base) var(--ease);
}
.play-arrow svg { width: 18px; height: 18px; }
.game-card:hover .play-arrow { transform: translateX(4px) rotate(0deg); }

/* ---------- Levels rail ---------- */
.levels { padding: var(--s-12) 0 var(--s-16); }
.level-rail {
  display: grid; gap: var(--s-4);
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
}
.level-chip {
  position: relative;
  padding: var(--s-5) var(--s-5) var(--s-5) 64px;
  border-radius: var(--r-lg);
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  box-shadow: var(--sh-sm);
  display: flex; flex-direction: column; gap: 2px;
  transition: transform var(--t-base) var(--ease);
}
.level-chip:hover { transform: translateY(-2px); }
.level-chip .num {
  position: absolute; left: 16px; top: 50%; transform: translateY(-50%);
  width: 36px; height: 36px; border-radius: 12px;
  display: grid; place-items: center;
  font-family: var(--f-display); font-weight: 700; font-size: 1.05rem;
  color: white;
}
.level-chip .name { font-family: var(--f-display); font-weight: 600; font-size: 1.1rem; }
.level-chip .age { color: var(--c-text-muted); font-size: .9rem; }
.lvl-1 .num { background: #45E0B8; }
.lvl-2 .num { background: #5AC8FF; }
.lvl-3 .num { background: #FFC542; color: #4a3300; }
.lvl-4 .num { background: #FF6BC1; }
.lvl-5 .num { background: linear-gradient(135deg, #7C5CFF, #FF6BC1); }

/* ---------- About ---------- */
.about { padding: var(--s-12) 0 var(--s-20); }
.about-grid {
  display: grid; gap: var(--s-10);
  grid-template-columns: 1fr;
}
@media (min-width: 900px) { .about-grid { grid-template-columns: 1fr 1fr; align-items: center; } }
.about p { color: var(--c-text-muted); margin-top: var(--s-4); font-size: 1.05rem; }

.feature-list { display: grid; gap: var(--s-3); }
.feature-list li {
  display: flex; gap: var(--s-4); align-items: flex-start;
  padding: var(--s-4) var(--s-5);
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-sm);
}
.feat-icon {
  flex-shrink: 0;
  width: 40px; height: 40px; border-radius: 12px;
  display: grid; place-items: center;
  background: var(--c-primary-50); color: var(--c-primary);
}
[data-theme="dark"] .feat-icon { background: rgba(124,92,255,.16); color: #C9BBFF; }
.feat-icon svg { width: 20px; height: 20px; }
.feature-list strong { display: block; font-family: var(--f-display); font-weight: 600; font-size: 1rem; color: var(--c-text); }
.feature-list span { color: var(--c-text-muted); font-size: .95rem; }

/* ---------- Footer ---------- */
.site-footer {
  border-top: 1px solid var(--c-border);
  padding: var(--s-8) 0;
  background: var(--c-surface);
}
.footer-row { display: flex; flex-wrap: wrap; gap: var(--s-4); justify-content: space-between; align-items: center; }
.copy { color: var(--c-text-muted); font-size: .9rem; }
.footer-left { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.visitor-count {
  font-size: .7rem;
  color: var(--c-text-soft);
  letter-spacing: 0.02em;
}
.visitor-count .vc-num {
  color: var(--c-text-soft);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}
.visitor-count .vc-today { color: var(--c-text-soft); }
.visitor-count .vc-today:not(:empty)::before { content: " · "; }

/* =========================================================
   MODAL — game shell
   ========================================================= */
.modal {
  position: fixed; inset: 0; z-index: 100;
  display: grid; place-items: end stretch;
}
@media (min-width: 768px) { .modal { place-items: center; } }
.modal[hidden] { display: none; }
.modal-backdrop {
  position: absolute; inset: 0;
  background: rgba(20, 12, 50, .55);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  animation: fade-in var(--t-base) var(--ease);
}
.modal-panel {
  position: relative;
  width: 100%; max-width: 980px;
  max-height: 95vh;
  background: var(--c-bg-elev);
  border: 1px solid var(--c-border);
  border-radius: var(--r-xl) var(--r-xl) 0 0;
  box-shadow: var(--sh-lg);
  display: flex; flex-direction: column;
  overflow: hidden;
  animation: slide-up var(--t-slow) var(--ease);
  padding-bottom: env(safe-area-inset-bottom);
}
@media (min-width: 768px) {
  .modal-panel { border-radius: var(--r-xl); animation: pop var(--t-slow) var(--ease); margin: 0 16px; }
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes slide-up { from { translate: 0 16px; opacity: 0; } to { translate: 0 0; opacity: 1; } }
@keyframes pop { from { scale: .96; opacity: 0; } to { scale: 1; opacity: 1; } }

.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--s-5) var(--s-6);
  border-bottom: 1px solid var(--c-border);
  gap: var(--s-3);
}
.modal-title-row { display: flex; align-items: center; gap: var(--s-3); min-width: 0; }
.modal-title-row h2 { font-size: 1.3rem; }
.level-pill {
  display: inline-block;
  font-family: var(--f-display); font-weight: 600; font-size: .85rem;
  padding: 4px 12px; border-radius: var(--r-pill);
  background: var(--c-primary-50); color: var(--c-primary);
}
[data-theme="dark"] .level-pill { background: rgba(124,92,255,.18); color: #C9BBFF; }
.modal-actions { display: flex; gap: var(--s-2); }
.icon-btn {
  width: 44px; height: 44px;
  display: grid; place-items: center;
  border-radius: var(--r-pill);
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  color: var(--c-text-muted);
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease), transform var(--t-fast) var(--ease);
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  cursor: pointer;
}
.icon-btn:hover { background: var(--c-surface-2); color: var(--c-text); }
.icon-btn:active { transform: scale(.94); }
.icon-btn svg { width: 20px; height: 20px; pointer-events: none; }

.modal-body { padding: var(--s-6); overflow-y: auto; -webkit-overflow-scrolling: touch; }

/* ---- Level select screen ---- */
.lvl-select { text-align: center; }
.lvl-select-intro { color: var(--c-text-muted); margin-bottom: var(--s-6); font-size: 1.05rem; }
.lvl-grid {
  display: grid; gap: var(--s-3);
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  max-width: 720px; margin: 0 auto;
}
.lvl-btn {
  position: relative;
  padding: var(--s-5) var(--s-4);
  border-radius: var(--r-lg);
  background: var(--c-surface);
  border: 2px solid var(--c-border);
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  min-height: 130px;
  font-family: var(--f-display);
  transition: transform var(--t-base) var(--ease), border-color var(--t-base) var(--ease), box-shadow var(--t-base) var(--ease);
  text-align: center;
}
.lvl-btn:hover, .lvl-btn:focus-visible { transform: translateY(-3px); box-shadow: var(--sh-md); border-color: var(--c-primary); }
.lvl-btn:active { transform: translateY(0) scale(.98); }
.lvl-btn .lvl-num {
  width: 40px; height: 40px; border-radius: 12px;
  display: grid; place-items: center; color: white;
  font-weight: 700; font-size: 1.05rem;
}
.lvl-btn .lvl-label { font-weight: 600; font-size: 1.1rem; color: var(--c-text); }
.lvl-btn .lvl-best { font-size: .85rem; color: var(--c-text-soft); font-family: var(--f-body); font-weight: 600; }
.lvl-btn[data-l="1"] .lvl-num { background: #45E0B8; }
.lvl-btn[data-l="2"] .lvl-num { background: #5AC8FF; }
.lvl-btn[data-l="3"] .lvl-num { background: #FFC542; color: #4a3300; }
.lvl-btn[data-l="4"] .lvl-num { background: #FF6BC1; }
.lvl-btn[data-l="5"] .lvl-num { background: linear-gradient(135deg, #7C5CFF, #FF6BC1); }

/* ---- Game HUD ---- */
.hud {
  display: flex; flex-wrap: wrap; gap: var(--s-3) var(--s-5);
  align-items: center; justify-content: center;
  padding: var(--s-3) var(--s-4);
  background: var(--c-surface);
  border-radius: var(--r-lg);
  border: 1px solid var(--c-border);
  margin-bottom: var(--s-5);
}
.stat { display: flex; flex-direction: column; align-items: center; min-width: 64px; }
.stat .label { font-size: .75rem; color: var(--c-text-soft); text-transform: uppercase; letter-spacing: .05em; font-weight: 700; }
.stat .value { font-family: var(--f-display); font-weight: 700; font-size: 1.4rem; color: var(--c-text); line-height: 1.1; }

/* ---- Card Match board ---- */
.match-board {
  display: grid; gap: clamp(6px, 1.5vw, 12px);
  margin: 0 auto;
  max-width: 720px;
  perspective: 1200px;
}
.mc {
  aspect-ratio: 3/4;
  position: relative;
  cursor: pointer;
  transform-style: preserve-3d;
  transition: transform var(--t-slow) var(--ease);
  border-radius: clamp(8px, 1.4vw, 14px);
  outline: none;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}
.mc:focus-visible { outline: 3px solid var(--c-primary); outline-offset: 3px; }
.mc.flipped, .mc.matched { transform: rotateY(180deg); }
.mc-face {
  position: absolute; inset: 0;
  border-radius: inherit;
  display: grid; place-items: center;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  font-size: clamp(28px, 6vw, 56px);
  user-select: none;
}
.mc-back {
  background: linear-gradient(135deg, var(--c-primary), var(--c-accent));
  background-image:
    radial-gradient(circle at 30% 30%, rgba(255,255,255,.3), transparent 50%),
    linear-gradient(135deg, var(--c-primary), var(--c-accent));
  box-shadow: var(--sh-sm);
}
.mc-back::after {
  content: ""; width: 40%; height: 40%; border-radius: 50%;
  background: rgba(255,255,255,.18);
  border: 3px solid rgba(255,255,255,.35);
}
.mc-front {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  transform: rotateY(180deg);
  box-shadow: var(--sh-sm);
}
.mc.matched .mc-front {
  background: color-mix(in srgb, var(--c-mint) 30%, var(--c-surface));
  animation: pulse-good 600ms var(--ease);
}
@keyframes pulse-good {
  0% { transform: rotateY(180deg) scale(1); }
  40% { transform: rotateY(180deg) scale(1.07); }
  100% { transform: rotateY(180deg) scale(1); }
}

/* ---- Echo Sequence pads ---- */
.echo-stage {
  max-width: 460px; margin: 0 auto;
  display: flex; flex-direction: column; align-items: center; gap: var(--s-5);
}
.echo-status {
  font-family: var(--f-display); font-weight: 600; font-size: 1.15rem;
  color: var(--c-text); min-height: 1.6em;
}
.echo-pads {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--s-3);
  width: 100%; aspect-ratio: 1;
  padding: var(--s-3);
  background: var(--c-surface-2);
  border-radius: var(--r-xl);
  border: 1px solid var(--c-border);
}
.pad {
  border-radius: var(--r-lg);
  position: relative;
  cursor: pointer;
  transition: transform 80ms var(--ease-out), filter var(--t-fast) var(--ease);
  box-shadow: inset 0 -8px 0 rgba(0,0,0,.18);
  outline: none;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}
.pad:focus-visible { outline: 3px solid var(--c-primary); outline-offset: 4px; }
.pad:active { transform: scale(.97); }
.pad[data-color="0"] { background: #FF6BC1; }
.pad[data-color="1"] { background: #FFC542; }
.pad[data-color="2"] { background: #5AC8FF; }
.pad[data-color="3"] { background: #45E0B8; }
.pad.lit { filter: brightness(1.6) saturate(1.2); transform: scale(1.02); }
.pad[disabled] { cursor: not-allowed; opacity: .85; }

.echo-actions { display: flex; gap: var(--s-3); flex-wrap: wrap; justify-content: center; }

/* ---- What's Missing ---- */
.miss-stage { max-width: 760px; margin: 0 auto; text-align: center; }
.miss-grid {
  display: grid; gap: clamp(8px, 1.6vw, 14px);
  margin: var(--s-5) auto 0;
  max-width: 600px;
}
.miss-tile {
  aspect-ratio: 1;
  border-radius: var(--r-md);
  background: var(--c-surface);
  border: 2px solid var(--c-border);
  display: grid; place-items: center;
  font-size: clamp(28px, 5vw, 44px);
  cursor: pointer;
  transition: transform var(--t-base) var(--ease), border-color var(--t-base) var(--ease), background var(--t-base) var(--ease);
  user-select: none;
  outline: none;
}
.miss-tile.guessable { cursor: pointer; }
.miss-tile.guessable:hover { transform: translateY(-3px); border-color: var(--c-primary); }
.miss-tile.guessable:focus-visible { outline: 3px solid var(--c-primary); outline-offset: 3px; }
.miss-tile.gone { background: var(--c-surface-2); color: transparent; opacity: .9; }
.miss-tile.correct { border-color: var(--c-success); background: color-mix(in srgb, var(--c-mint) 25%, var(--c-surface)); animation: pulse-good 500ms var(--ease); }
.miss-tile.wrong { border-color: var(--c-error); animation: shake 320ms var(--ease); }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}

.miss-status { font-family: var(--f-display); font-weight: 600; font-size: 1.15rem; min-height: 1.6em; }
.miss-actions { display: flex; gap: var(--s-3); flex-wrap: wrap; justify-content: center; margin-top: var(--s-5); }

.miss-tile.placeholder {
  background: repeating-linear-gradient(45deg,
    var(--c-surface-2) 0 8px,
    color-mix(in srgb, var(--c-primary) 14%, var(--c-surface-2)) 8px 16px);
  border-style: dashed;
  border-color: var(--c-primary);
  color: var(--c-primary);
  font-family: var(--f-display);
  font-weight: 900;
  animation: pulse-good 1200ms ease-in-out infinite alternate;
}

.miss-candidates {
  margin-top: var(--s-5);
  display: flex; flex-direction: column; align-items: center; gap: var(--s-3);
}
.miss-candidate-prompt {
  margin: 0;
  font-family: var(--f-display);
  font-weight: 700;
  color: var(--c-text);
  font-size: 1rem;
}
.miss-candidate-row {
  display: flex; gap: clamp(8px, 2vw, 14px);
  flex-wrap: wrap; justify-content: center;
}
.miss-candidate {
  width: clamp(64px, 14vw, 86px);
  height: clamp(64px, 14vw, 86px);
  border-radius: var(--r-md);
  background: var(--c-surface);
  border: 2px solid var(--c-border);
  display: grid; place-items: center;
  font-size: clamp(32px, 6vw, 44px);
  cursor: pointer;
  box-shadow: var(--sh-sm);
  transition: transform var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease), background var(--t-fast) var(--ease);
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.miss-candidate:hover { transform: translateY(-3px); border-color: var(--c-primary); }
.miss-candidate:active { transform: scale(.94); }
.miss-candidate:focus-visible { outline: 3px solid var(--c-primary); outline-offset: 3px; }
.miss-candidate:disabled { cursor: default; }
.miss-candidate.correct { border-color: var(--c-success); background: color-mix(in srgb, var(--c-mint) 25%, var(--c-surface)); animation: pulse-good 500ms var(--ease); }
.miss-candidate.wrong   { border-color: var(--c-error);   background: color-mix(in srgb, var(--c-error, #FF4757) 18%, var(--c-surface)); animation: shake 320ms var(--ease); }

/* ---- Win screen ---- */
.win-screen {
  text-align: center; padding: var(--s-6) var(--s-4);
  display: flex; flex-direction: column; align-items: center; gap: var(--s-4);
}
.win-emoji { font-size: 80px; line-height: 1; animation: bounce 700ms var(--ease) infinite alternate; }
@keyframes bounce {
  from { transform: translateY(0); }
  to { transform: translateY(-12px); }
}
.win-screen h3 { font-size: 2rem; }
.win-screen p { color: var(--c-text-muted); font-size: 1.05rem; max-width: 40ch; }
.win-stats {
  display: flex; gap: var(--s-6); margin-top: var(--s-3);
}
.win-actions { display: flex; gap: var(--s-3); flex-wrap: wrap; justify-content: center; margin-top: var(--s-4); }

/* ---------- Win-screen save form ---------- */
.save-form {
  width: 100%; max-width: 420px;
  margin: var(--s-2) auto 0;
  display: flex; flex-direction: column; gap: 6px;
  text-align: left;
}
.save-label {
  font-family: var(--f-display); font-weight: 600; font-size: .9rem;
  color: var(--c-text-muted);
  letter-spacing: .02em;
}
.save-row {
  display: flex; gap: var(--s-2); align-items: stretch;
  width: 100%;
}
.save-row input {
  flex: 1; min-width: 0;
  height: 52px; padding: 0 16px;
  border-radius: var(--r-md);
  border: 2px solid var(--c-border);
  background: var(--c-surface);
  color: var(--c-text);
  font-family: var(--f-display); font-size: 1.05rem; font-weight: 600;
  transition: border-color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
}
.save-row input:focus {
  outline: none;
  border-color: var(--c-primary);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--c-primary) 20%, transparent);
}
.save-row .btn { white-space: nowrap; padding: 0 18px; }
.save-row .btn svg { width: 18px; height: 18px; }
.save-error {
  color: var(--c-error); font-size: .9rem; font-weight: 700; margin: 0;
}
@media (max-width: 480px) {
  .save-row { flex-direction: column; }
  .save-row .btn { justify-content: center; }
}

/* ---------- Confetti ---------- */
.confetti {
  position: fixed; inset: 0;
  pointer-events: none;
  z-index: 200;
}

/* =========================================================
   NAME DIALOG
   ========================================================= */
.name-panel { max-width: 460px; }
.name-form { display: flex; flex-direction: column; gap: var(--s-4); }
.name-help { color: var(--c-text-muted); margin: 0; }
.name-field { display: flex; flex-direction: column; gap: 6px; }
.name-field-label {
  font-family: var(--f-display); font-weight: 600; font-size: .95rem;
  color: var(--c-text);
}
.name-field input {
  width: 100%;
  height: 52px;
  padding: 0 16px;
  border-radius: var(--r-md);
  border: 2px solid var(--c-border);
  background: var(--c-surface);
  color: var(--c-text);
  font-family: var(--f-display); font-size: 1.1rem; font-weight: 600;
  transition: border-color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
}
.name-field input:focus {
  outline: none;
  border-color: var(--c-primary);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--c-primary) 20%, transparent);
}
.name-error { color: var(--c-error); font-size: .9rem; font-weight: 700; margin: 0; }
.name-actions { display: flex; justify-content: flex-end; }

/* =========================================================
   LEVEL SELECT — leaderboard button
   ========================================================= */
.lvl-select-head {
  display: flex; flex-direction: column; gap: var(--s-3);
  margin-bottom: var(--s-6);
}
.lvl-select-actions {
  display: flex; flex-wrap: wrap; gap: var(--s-2);
  justify-content: center;
}
.chip-btn {
  display: inline-flex; align-items: center; gap: 8px;
  height: 40px; padding: 0 16px;
  border-radius: var(--r-pill);
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  color: var(--c-text); font-weight: 700; font-size: .95rem;
  transition: background var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease), transform var(--t-fast) var(--ease);
}
.chip-btn:hover { background: var(--c-surface-2); border-color: color-mix(in srgb, var(--c-primary) 40%, var(--c-border)); }
.chip-btn:active { transform: scale(.97); }
.chip-btn[aria-pressed="true"] {
  background: var(--c-primary); color: white; border-color: var(--c-primary);
}
.chip-btn svg { width: 18px; height: 18px; }

/* =========================================================
   LEADERBOARD
   ========================================================= */
.lb-view { max-width: 720px; margin: 0 auto; }
.lb-tabs {
  display: grid; grid-template-columns: repeat(5, 1fr); gap: var(--s-2);
  background: var(--c-surface-2);
  padding: 6px;
  border-radius: var(--r-pill);
  margin-bottom: var(--s-5);
}
.lb-tab {
  height: 40px;
  border-radius: var(--r-pill);
  font-family: var(--f-display); font-weight: 600; font-size: .95rem;
  color: var(--c-text-muted);
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
  display: inline-grid; place-items: center;
}
.lb-tab:hover { color: var(--c-text); }
.lb-tab[aria-selected="true"] {
  background: var(--c-bg-elev); color: var(--c-text);
  box-shadow: var(--sh-sm);
}

.lb-list { display: flex; flex-direction: column; gap: var(--s-2); }
.lb-row {
  display: grid;
  grid-template-columns: 44px 1fr auto auto;
  gap: var(--s-3);
  align-items: center;
  padding: var(--s-3) var(--s-4);
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  transition: transform var(--t-fast) var(--ease);
}
.lb-row.is-you {
  border-color: var(--c-primary);
  background: color-mix(in srgb, var(--c-primary) 8%, var(--c-surface));
}
[data-theme="dark"] .lb-row.is-you {
  background: color-mix(in srgb, var(--c-primary) 18%, var(--c-surface));
}
.lb-row.top-3 { transform: scale(1); }
.lb-row.top-3:hover { transform: translateX(2px); }
.lb-rank {
  width: 36px; height: 36px;
  display: grid; place-items: center;
  border-radius: 12px;
  font-family: var(--f-display); font-weight: 700; font-size: 1rem;
  background: var(--c-surface-2); color: var(--c-text-muted);
}
.lb-row[data-rank="1"] .lb-rank { background: linear-gradient(135deg, #FFD75A, #FFAA1F); color: #4a3300; }
.lb-row[data-rank="2"] .lb-rank { background: linear-gradient(135deg, #DCE3EA, #A6B0BD); color: #2a313a; }
.lb-row[data-rank="3"] .lb-rank { background: linear-gradient(135deg, #E8A877, #B47443); color: #3a210d; }
.lb-name {
  font-family: var(--f-display); font-weight: 600; font-size: 1.05rem;
  color: var(--c-text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  display: flex; align-items: center; gap: 8px;
}
.you-tag {
  font-size: .7rem; font-weight: 800; letter-spacing: .06em;
  background: var(--c-primary); color: white;
  padding: 2px 8px; border-radius: var(--r-pill); text-transform: uppercase;
  font-family: var(--f-body);
}
.lb-score { font-family: var(--f-display); font-weight: 600; color: var(--c-text); font-size: 1rem; }
.lb-date { color: var(--c-text-soft); font-size: .82rem; font-weight: 600; }
@media (max-width: 520px) {
  .lb-row { grid-template-columns: 36px 1fr auto; }
  .lb-date { display: none; }
}

.lb-empty {
  text-align: center; padding: var(--s-10) var(--s-4);
  color: var(--c-text-muted);
  border: 2px dashed var(--c-border);
  border-radius: var(--r-lg);
}
.lb-empty-emoji { font-size: 48px; line-height: 1; margin-bottom: var(--s-3); }

.lb-loading {
  display: flex; align-items: center; justify-content: center;
  gap: var(--s-3);
  text-align: center; padding: var(--s-10) var(--s-4);
  color: var(--c-text-muted);
  border: 2px dashed var(--c-border);
  border-radius: var(--r-lg);
  font-weight: 600;
}
.lb-error {
  margin-top: var(--s-3);
  text-align: center;
  font-size: .85rem;
  color: var(--c-error);
  background: color-mix(in srgb, var(--c-error) 8%, transparent);
  border: 1px solid color-mix(in srgb, var(--c-error) 25%, transparent);
  padding: var(--s-2) var(--s-3);
  border-radius: var(--r-md);
}

/* Saving spinner — used in save form & loading screens */
.saving-dot {
  display: inline-block;
  width: 14px; height: 14px;
  border-radius: 50%;
  border: 2px solid currentColor;
  border-top-color: transparent;
  animation: saving-spin 0.7s linear infinite;
  vertical-align: -2px;
}
@keyframes saving-spin {
  to { transform: rotate(360deg); }
}
@media (prefers-reduced-motion: reduce) {
  .saving-dot { animation-duration: 2.5s; }
}

.lb-foot {
  display: flex; gap: var(--s-3); justify-content: space-between;
  align-items: center; flex-wrap: wrap;
  margin-top: var(--s-5);
  padding-top: var(--s-4);
  border-top: 1px solid var(--c-border);
}
.lb-foot-note { color: var(--c-text-soft); font-size: .85rem; }
.lb-clear {
  font-size: .85rem; font-weight: 700; color: var(--c-error);
  padding: 8px 14px; border-radius: var(--r-pill);
  border: 1px solid color-mix(in srgb, var(--c-error) 40%, transparent);
  background: transparent;
  transition: background var(--t-fast) var(--ease);
}
.lb-clear:hover { background: color-mix(in srgb, var(--c-error) 12%, transparent); }

/* Leaderboard hub — game switcher */
.lb-game-tabs {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: var(--s-2);
  background: var(--c-surface-2);
  padding: 6px;
  border-radius: var(--r-lg);
  margin-bottom: var(--s-4);
}
@media (min-width: 720px) {
  .lb-game-tabs { grid-template-columns: repeat(5, 1fr); }
}
@media (min-width: 980px) {
  .lb-game-tabs { grid-template-columns: repeat(9, 1fr); }
}
.lb-game-tab {
  height: 52px;
  border-radius: var(--r-md);
  font-family: var(--f-display); font-weight: 600; font-size: .95rem;
  color: var(--c-text-muted);
  display: inline-flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px;
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
  padding: 0 8px;
}
.lb-game-tab:hover { color: var(--c-text); }
.lb-game-tab[aria-selected="true"] {
  background: var(--c-bg-elev); color: var(--c-text);
  box-shadow: var(--sh-sm);
}
.lb-game-tab .lb-game-emoji { font-size: 18px; line-height: 1; }
.lb-game-tab .lb-game-name { font-size: .78rem; line-height: 1.1; text-align: center; }
@media (min-width: 980px) {
  .lb-game-tab { flex-direction: column; gap: 2px; }
  .lb-game-tab .lb-game-emoji { font-size: 20px; }
  .lb-game-tab .lb-game-name { font-size: .82rem; }
}

/* Win-screen rank ribbon */
.rank-ribbon {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 16px;
  border-radius: var(--r-pill);
  background: linear-gradient(95deg, var(--c-primary), var(--c-accent));
  color: white;
  font-family: var(--f-display); font-weight: 700; font-size: 1rem;
  box-shadow: var(--sh-glow);
}
.rank-ribbon.silver { background: linear-gradient(95deg, #A6B0BD, #6E7884); box-shadow: 0 8px 24px rgba(110,120,132,.4); }
.rank-ribbon.bronze { background: linear-gradient(95deg, #B47443, #7A4920); box-shadow: 0 8px 24px rgba(122,73,32,.4); }
.rank-ribbon.normal { background: var(--c-surface-2); color: var(--c-text); box-shadow: none; }

/* =========================================================
   Block Drop (Tetris)
   ========================================================= */
.tetris-stage {
  display: flex; flex-direction: column; align-items: center;
  gap: var(--s-3);
}
.tetris-canvas {
  border-radius: var(--r-md);
  box-shadow: var(--sh-sm);
  border: 2px solid var(--c-border);
  display: block;
  background: var(--c-surface-2);
  touch-action: none;
}
#tNext {
  border-radius: var(--r-sm);
  background: var(--c-surface-2);
  display: inline-block;
}
.tetris-controls {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(2, 1fr);
  gap: 8px;
  width: min(360px, 100%);
}
.td-btn {
  height: 56px;
  border-radius: var(--r-md);
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  box-shadow: var(--sh-sm);
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--c-text);
  display: inline-flex; align-items: center; justify-content: center;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
  transition: transform var(--t-fast) var(--ease), background var(--t-fast) var(--ease);
}
.td-btn:active { transform: scale(.94); background: var(--c-surface-2); }
.td-rotate { grid-column: 3; grid-row: 1; background: linear-gradient(135deg, var(--c-primary), var(--c-accent)); color: #fff; border-color: transparent; }
.td-drop   { grid-column: 1; grid-row: 1; background: var(--c-surface-2); }
.td-left   { grid-column: 1; grid-row: 2; }
.td-down   { grid-column: 2; grid-row: 2; }
.td-right  { grid-column: 3; grid-row: 2; }
.tetris-hint { color: var(--c-text-soft); font-size: .85rem; text-align: center; margin: 0; }
@media (max-width: 520px) {
  .tetris-hint { display: none; }
}
.t-music-btn {
  align-self: center;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: 999px;
  color: var(--c-text);
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
  padding: 8px 14px;
  box-shadow: var(--sh-sm);
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: transform var(--t-fast) var(--ease), background var(--t-fast) var(--ease);
}
.t-music-btn:hover { background: var(--c-surface-2); }
.t-music-btn:active { transform: scale(.94); }
.t-music-btn[aria-pressed="false"] { opacity: 0.55; }

/* =========================================================
   Color Rush
   ========================================================= */
.illu-colorrush {
  display: flex; gap: 10px; padding: 14px; align-items: center;
}
.illu-colorrush .cr-illu-word {
  font-family: var(--f-display); font-weight: 900; font-size: 22px;
  padding: 6px 12px; border-radius: 10px;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  color: #FF4757;
  box-shadow: var(--sh-sm);
  letter-spacing: 0.04em;
}
.illu-colorrush .cr-illu-dot {
  width: 22px; height: 22px; border-radius: 50%;
  box-shadow: inset 0 -3px 0 rgba(0,0,0,.18);
}
.illu-colorrush .cr-d-blue   { background: #3F87FF; }
.illu-colorrush .cr-d-green  { background: #2ECC71; }
.illu-colorrush .cr-d-yellow { background: #FFC542; }

.cr-stage {
  display: flex; flex-direction: column; gap: var(--s-5);
  align-items: center; padding: var(--s-3) 0;
}
.cr-prompt {
  font-family: var(--f-display); font-weight: 900;
  font-size: clamp(2.4rem, 9vw, 4.2rem);
  letter-spacing: 0.04em;
  text-align: center;
  min-height: 1.2em;
  user-select: none;
  text-shadow: 0 2px 0 rgba(0,0,0,0.06);
}
.cr-options {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px;
  width: min(440px, 100%);
}
@media (min-width: 520px) {
  .cr-options { grid-template-columns: repeat(4, 1fr); }
}
.cr-options:has(.cr-option:nth-child(5)) { grid-template-columns: repeat(3, 1fr); }
@media (min-width: 520px) {
  .cr-options:has(.cr-option:nth-child(5)) { grid-template-columns: repeat(6, 1fr); }
  .cr-options:has(.cr-option:nth-child(7)) { grid-template-columns: repeat(4, 1fr); }
}
.cr-option {
  height: 64px; border: 0; border-radius: var(--r-md);
  cursor: pointer;
  box-shadow: var(--sh-sm), inset 0 -4px 0 rgba(0,0,0,.18);
  transition: transform var(--t-fast) var(--ease);
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.cr-option:active { transform: scale(.94); }
.cr-option.cr-good { animation: pulse-good 380ms var(--ease); }
.cr-option.cr-bad  { animation: shake 320ms var(--ease); }
.cr-hint { color: var(--c-text-soft); font-size: .9rem; text-align: center; margin: 0; max-width: 320px; }

/* =========================================================
   Pattern Builder
   ========================================================= */
.illu-pattern {
  display: flex; gap: 6px; padding: 14px; align-items: center;
}
.illu-pattern .pt-cell {
  min-width: 32px; height: 38px; padding: 0 6px;
  display: grid; place-items: center;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: 8px;
  font-size: 20px;
  box-shadow: var(--sh-sm);
}
.illu-pattern .pt-q {
  background: linear-gradient(135deg, var(--c-primary), var(--c-accent));
  color: #fff; border-color: transparent;
  font-family: var(--f-display); font-weight: 900;
}

.pb-stage {
  display: flex; flex-direction: column; gap: var(--s-5);
  align-items: center; padding: var(--s-3) 0;
}
.pb-row {
  display: flex; flex-wrap: wrap; gap: 10px; justify-content: center;
}
.pb-cell {
  min-width: 56px; height: 64px; padding: 0 14px;
  display: grid; place-items: center;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  font-family: var(--f-display); font-weight: 800; font-size: 1.8rem;
  color: var(--c-primary);
  box-shadow: var(--sh-sm);
}
.pb-cell.pb-q {
  background: linear-gradient(135deg, var(--c-primary), var(--c-accent));
  color: #fff; border-color: transparent;
}
.pb-options {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px;
  width: min(440px, 100%);
}
@media (min-width: 520px) {
  .pb-options { grid-template-columns: repeat(4, 1fr); }
}
.pb-option {
  min-height: 64px; padding: 10px 14px;
  display: grid; place-items: center;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  font-family: var(--f-display); font-weight: 800; font-size: 1.5rem;
  color: var(--c-text);
  cursor: pointer;
  box-shadow: var(--sh-sm);
  transition: transform var(--t-fast) var(--ease), background var(--t-fast) var(--ease);
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.pb-option:active { transform: scale(.94); }
.pb-option.pb-good { background: color-mix(in srgb, var(--c-success, #2ECC71) 25%, var(--c-surface)); border-color: var(--c-success, #2ECC71); }
.pb-option.pb-bad  { background: color-mix(in srgb, var(--c-error, #FF4757) 22%, var(--c-surface)); border-color: var(--c-error, #FF4757); animation: shake 320ms var(--ease); }
.pb-hint { color: var(--c-text-soft); font-size: .9rem; text-align: center; margin: 0; }

/* =========================================================
   Whack-a-Mole
   ========================================================= */
.illu-whack {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  padding: 12px 14px;
  align-items: center;
  justify-items: center;
}
.illu-whack .wm-illu-cell {
  width: 26px; height: 26px;
  background: radial-gradient(circle at 50% 30%, #B07849 60%, #6B4226 100%);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; line-height: 1;
  box-shadow: inset 0 -3px 0 rgba(0,0,0,.18), 0 2px 4px rgba(0,0,0,.15);
}
.illu-whack .wm-illu-mole::before { content: '🐭'; }
.illu-whack .wm-illu-bomb::before { content: '💣'; }

.wm-stage {
  display: flex; flex-direction: column; gap: var(--s-4);
  align-items: center; padding: var(--s-3) 0;
}
.wm-prompt { color: var(--c-text-soft); font-size: .95rem; text-align: center; margin: 0; }
.wm-grid {
  display: grid;
  gap: 10px;
  width: min(440px, 100%);
}
.wm-hole {
  position: relative;
  aspect-ratio: 1;
  background: transparent;
  border: 0;
  padding: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  overflow: hidden;
}
.wm-hole .wm-mound {
  position: absolute;
  inset: 38% 4% 0 4%;
  background: radial-gradient(ellipse at 50% 0%, #5A3320 0%, #3D2616 70%);
  border-radius: 50% 50% 14px 14px / 80% 80% 14px 14px;
  box-shadow: inset 0 -4px 0 rgba(0,0,0,.35), 0 4px 8px rgba(0,0,0,.18);
  pointer-events: none;
}
.wm-hole .wm-mound::after {
  content: '';
  position: absolute;
  left: 12%; right: 12%; top: 4px; height: 28%;
  background: radial-gradient(ellipse at 50% 100%, rgba(0,0,0,.6) 0%, rgba(0,0,0,0) 70%);
  border-radius: 50%;
}
.wm-hole .wm-creature {
  position: absolute;
  left: 50%;
  top: 38%;
  width: 100%;
  text-align: center;
  font-size: clamp(1.8rem, 7vw, 2.6rem);
  line-height: 1;
  pointer-events: none;
  transform: translate(-50%, 100%);
  opacity: 0;
  transition: transform 180ms cubic-bezier(.34, 1.56, .64, 1), opacity 120ms ease;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,.25));
}
.wm-hole.wm-up .wm-creature {
  transform: translate(-50%, -10%);
  opacity: 1;
}
.wm-hole.wm-whacked .wm-creature {
  transform: translate(-50%, 100%) scale(0.5) rotate(-18deg);
  opacity: 0;
  transition: transform 220ms ease-in, opacity 200ms ease-in;
}
.wm-hole.wm-golden .wm-creature {
  filter: drop-shadow(0 0 10px rgba(255, 200, 0, 0.85)) drop-shadow(0 2px 4px rgba(0,0,0,.25));
  animation: wmGoldenGlow 600ms ease-in-out infinite alternate;
}
@keyframes wmGoldenGlow {
  from { filter: drop-shadow(0 0 6px rgba(255, 200, 0, 0.6)) drop-shadow(0 2px 4px rgba(0,0,0,.25)); }
  to   { filter: drop-shadow(0 0 14px rgba(255, 200, 0, 0.95)) drop-shadow(0 2px 4px rgba(0,0,0,.25)); }
}
.wm-hole.wm-bombhit { animation: shake 320ms var(--ease); }
.wm-hole.wm-bombhit::after {
  content: '💥';
  position: absolute;
  inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: clamp(2rem, 8vw, 3rem);
  pointer-events: none;
  animation: pulse-good 420ms ease-out;
}
.wm-hole.wm-flash { animation: pulse-good 360ms ease-out; }

/* =========================================================
   Space Attack
   ========================================================= */
.illu-space {
  background: radial-gradient(ellipse at 30% 70%, #2d3978 0%, #0a0e2a 70%);
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px;
  position: relative;
  overflow: hidden;
}
.illu-space::before {
  content: '';
  position: absolute; inset: 0;
  background-image:
    radial-gradient(1px 1px at 20% 30%, #fff, transparent),
    radial-gradient(1px 1px at 60% 60%, #fff, transparent),
    radial-gradient(1px 1px at 80% 20%, #fff, transparent),
    radial-gradient(1px 1px at 40% 80%, #fff, transparent);
  opacity: 0.6;
}
.illu-space .sp-illu-ship { font-size: 24px; filter: drop-shadow(0 0 6px #ffeb3b); z-index: 1; }
.illu-space .sp-illu-shot {
  flex: 1;
  height: 2px;
  margin: 0 8px;
  background: linear-gradient(90deg, #ffeb3b, transparent);
  border-radius: 1px;
  z-index: 1;
}
.illu-space .sp-illu-foes { font-size: 20px; letter-spacing: 4px; z-index: 1; }

.space-stage {
  display: flex; flex-direction: column; gap: var(--s-3);
  align-items: center;
}
.space-canvas {
  border-radius: var(--r-md);
  box-shadow: var(--sh-md);
  background: #0a0e2a;
  cursor: grab;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
}
.space-canvas:active { cursor: grabbing; }
.space-hint { color: var(--c-text-soft); font-size: .9rem; text-align: center; margin: 0; }

/* =========================================================
   Flying Birds
   ========================================================= */
.illu-flappy {
  background: linear-gradient(180deg, #7ec8e3 0%, #cdeaf6 100%);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 18px;
  position: relative;
  overflow: hidden;
}
.illu-flappy::after {
  content: '';
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 14px;
  background: #dec88a;
  border-top: 3px solid #7fc06b;
}
.illu-flappy .fb-illu-pipe {
  width: 16px;
  background: #56b85f;
  border: 1.5px solid #2d7a36;
  border-radius: 2px;
  z-index: 1;
}
.illu-flappy .fb-illu-pipe-l { height: 38%; align-self: flex-start; margin-top: 0; }
.illu-flappy .fb-illu-pipe-r { height: 38%; align-self: flex-end; margin-bottom: 14px; }
.illu-flappy .fb-illu-bird {
  font-size: 24px;
  z-index: 2;
  filter: drop-shadow(0 2px 3px rgba(0,0,0,.25));
}

.flappy-stage {
  display: flex; flex-direction: column; gap: var(--s-3);
  align-items: center;
}
.flappy-canvas {
  border-radius: var(--r-md);
  box-shadow: var(--sh-md);
  background: #7ec8e3;
  touch-action: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.flappy-hint { color: var(--c-text-soft); font-size: .9rem; text-align: center; margin: 0; }

/* =========================================================
   Fruit Crush
   ========================================================= */
.illu-candy {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(2, 1fr);
  gap: 4px;
  padding: 10px 12px;
}
.illu-candy span {
  font-size: 18px;
  display: flex; align-items: center; justify-content: center;
  background: var(--c-surface);
  border-radius: 6px;
  box-shadow: inset 0 -2px 0 rgba(0,0,0,.08);
}

.candy-stage {
  display: flex; flex-direction: column; gap: var(--s-3);
  align-items: center;
}
.candy-hint { color: var(--c-text-soft); font-size: .9rem; text-align: center; margin: 0; }
.candy-grid {
  display: grid;
  gap: 4px;
  width: min(440px, 100%);
  background: var(--c-surface-2);
  padding: 6px;
  border-radius: var(--r-md);
  box-shadow: var(--sh-sm);
}
.candy-cell {
  aspect-ratio: 1;
  background: var(--c-surface);
  border: 0;
  border-radius: 8px;
  font-size: clamp(1.3rem, 5vw, 2rem);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  box-shadow: inset 0 -2px 0 rgba(0,0,0,.08);
  transition: transform var(--t-fast) var(--ease), background var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
}
.candy-grid { touch-action: none; }
.candy-cell:active { transform: scale(0.94); }
.candy-cell.candy-sel {
  background: color-mix(in srgb, var(--c-primary, #7C5CFF) 30%, var(--c-surface));
  box-shadow: 0 0 0 3px var(--c-primary, #7C5CFF), inset 0 -2px 0 rgba(0,0,0,.08);
  transform: scale(1.06);
}
.candy-cell.candy-pop {
  animation: candyPop 240ms ease-out forwards;
}
@keyframes candyPop {
  0%   { transform: scale(1); opacity: 1; }
  50%  { transform: scale(1.2); opacity: 0.8; }
  100% { transform: scale(0.2); opacity: 0; }
}

/* =========================================================
   Snake
   ========================================================= */
.snake-stage {
  display: flex; flex-direction: column; align-items: center;
  gap: var(--s-3);
}
.snake-canvas {
  border-radius: var(--r-md);
  box-shadow: var(--sh-sm);
  border: 2px solid var(--c-border);
  background: var(--c-surface-2);
  touch-action: none;
  display: block;
}
.snake-status {
  font-size: .9rem;
  color: var(--c-text-muted);
  min-height: 20px;
  text-align: center;
}
.snake-controls {
  display: grid;
  grid-template-columns: repeat(3, 56px);
  grid-template-rows: repeat(2, 56px);
  gap: 8px;
}
.sd-btn {
  border-radius: var(--r-md);
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  box-shadow: var(--sh-sm);
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--c-text);
  display: inline-flex; align-items: center; justify-content: center;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
  transition: transform var(--t-fast) var(--ease), background var(--t-fast) var(--ease);
}
.sd-btn:active { transform: scale(.94); background: var(--c-surface-2); }
.sd-up    { grid-column: 2; grid-row: 1; }
.sd-left  { grid-column: 1; grid-row: 2; }
.sd-down  { grid-column: 2; grid-row: 2; }
.sd-right { grid-column: 3; grid-row: 2; }

/* =========================================================
   Math Sprint
   ========================================================= */
.math-stage {
  display: flex; flex-direction: column; align-items: stretch;
  gap: var(--s-4); max-width: 480px; margin: 0 auto;
}
.math-timer-wrap {
  height: 8px; border-radius: 999px;
  background: var(--c-surface-2);
  overflow: hidden;
}
.math-timer-bar {
  height: 100%;
  background: var(--c-mint);
  transform-origin: left center;
  transform: scaleX(1);
  transition: transform 50ms linear, background var(--t-base) var(--ease);
}
.math-question {
  font-family: var(--f-display);
  font-weight: 800;
  font-size: clamp(2rem, 7vw, 3.2rem);
  text-align: center;
  padding: var(--s-6) var(--s-4);
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-sm);
  color: var(--c-text);
  letter-spacing: 0.02em;
}
.math-choices {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--s-3);
}
.math-choice {
  font-family: var(--f-display);
  font-weight: 700;
  font-size: 1.5rem;
  height: 64px;
  border-radius: var(--r-lg);
  background: var(--c-surface);
  border: 2px solid var(--c-border);
  color: var(--c-text);
  box-shadow: var(--sh-sm);
  transition: transform var(--t-fast) var(--ease), background var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease);
  cursor: pointer;
}
.math-choice:hover { background: var(--c-surface-2); border-color: var(--c-primary); }
.math-choice:active { transform: scale(.97); }
.math-choice.correct {
  background: color-mix(in srgb, var(--c-success) 18%, var(--c-surface));
  border-color: var(--c-success); color: var(--c-success);
}
.math-choice.wrong {
  background: color-mix(in srgb, var(--c-error) 18%, var(--c-surface));
  border-color: var(--c-error); color: var(--c-error);
}
.math-choice:disabled { cursor: default; opacity: .9; }
.math-actions { text-align: center; }
.math-feedback { min-height: 28px; text-align: center; font-weight: 700; }
.math-feedback .ok  { color: var(--c-success); }
.math-feedback .bad { color: var(--c-error); }

/* =========================================================
   Word games (Scramble, Missing Letter, Rhyme Time)
   ========================================================= */
.wd-stage {
  display: flex; flex-direction: column; align-items: stretch;
  gap: var(--s-4); max-width: 520px; margin: 0 auto;
}
.wd-timer-wrap {
  height: 8px; border-radius: 999px;
  background: var(--c-surface-2);
  overflow: hidden;
}
.wd-timer-bar {
  height: 100%;
  background: var(--c-mint);
  transform-origin: left center;
  transform: scaleX(1);
  transition: transform 50ms linear, background var(--t-base) var(--ease);
}
.wd-hint {
  text-align: center; font-size: 2.4rem; min-height: 1.1em;
}
.wd-hint:empty { display: none; }
.wd-prompt {
  font-family: var(--f-display);
  font-weight: 800;
  font-size: clamp(1.6rem, 5.5vw, 2.4rem);
  text-align: center;
  padding: var(--s-5) var(--s-4);
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-sm);
  color: var(--c-text);
  letter-spacing: 0.08em;
  word-break: break-word;
}
.wd-prompt .wd-blank {
  display: inline-block;
  min-width: 0.8em;
  padding: 0 .12em;
  border-bottom: 4px solid var(--c-primary);
  margin: 0 .06em;
  color: var(--c-text-muted);
}
.wd-prompt .wd-blank.active {
  background: color-mix(in srgb, var(--c-primary) 16%, transparent);
  border-radius: 6px 6px 0 0;
}
.wd-prompt .wd-blank.filled {
  color: var(--c-primary);
  border-bottom-color: var(--c-primary);
}
.wd-actions { display: flex; justify-content: center; gap: var(--s-3); flex-wrap: wrap; }
.wd-feedback { min-height: 28px; text-align: center; font-weight: 700; }
.wd-feedback .ok  { color: var(--c-success); }
.wd-feedback .bad { color: var(--c-error); }

/* Scramble — letter tiles to tap */
.ws-answer {
  display: flex; flex-wrap: wrap; gap: 6px; justify-content: center;
  min-height: 56px;
  padding: 8px 12px;
  background: var(--c-surface-2);
  border: 1px dashed var(--c-border);
  border-radius: var(--r-lg);
  font-family: var(--f-display); font-weight: 800;
  font-size: 1.6rem;
  letter-spacing: 0.06em;
}
.ws-answer .ws-slot {
  width: 1.2em; min-height: 1.4em;
  border-bottom: 3px solid var(--c-border);
  text-align: center;
  color: var(--c-primary);
}
.ws-answer .ws-slot.filled { border-bottom-color: var(--c-primary); }
.ws-pool { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.ws-tile-btn {
  width: 52px; height: 56px;
  display: grid; place-items: center;
  background: var(--c-surface);
  border: 2px solid var(--c-border);
  border-radius: var(--r-lg);
  font-family: var(--f-display); font-weight: 800; font-size: 1.6rem;
  color: var(--c-text);
  box-shadow: var(--sh-sm);
  cursor: pointer;
  transition: transform var(--t-fast) var(--ease), background var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease);
  touch-action: manipulation;
}
.ws-tile-btn:hover { background: var(--c-surface-2); border-color: var(--c-primary); }
.ws-tile-btn:active { transform: scale(.94); }
.ws-tile-btn.used {
  visibility: hidden;
}

/* 4-choice grid (Missing Letter, Rhyme Time) */
.wd-choices {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--s-3);
}
.wd-choice {
  font-family: var(--f-display);
  font-weight: 700;
  font-size: 1.4rem;
  min-height: 64px;
  padding: 10px 14px;
  border-radius: var(--r-lg);
  background: var(--c-surface);
  border: 2px solid var(--c-border);
  color: var(--c-text);
  box-shadow: var(--sh-sm);
  transition: transform var(--t-fast) var(--ease), background var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease);
  cursor: pointer;
  touch-action: manipulation;
}
.wd-choice:hover { background: var(--c-surface-2); border-color: var(--c-primary); }
.wd-choice:active { transform: scale(.97); }
.wd-choice.correct {
  background: color-mix(in srgb, var(--c-success) 18%, var(--c-surface));
  border-color: var(--c-success); color: var(--c-success);
}
.wd-choice.wrong {
  background: color-mix(in srgb, var(--c-error) 18%, var(--c-surface));
  border-color: var(--c-error); color: var(--c-error);
}
.wd-choice:disabled { cursor: default; opacity: .9; }

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
  html { scroll-behavior: auto; }
  .float-card { animation: none !important; }
}

/* ---------- Print kindness ---------- */
@media print {
  .site-header, .modal, .hero-blob, .confetti { display: none !important; }
}
