/* ═══════════════════════════════════════════════════════════════════════
   LION & LION ENGLISH ADVENTURE — styles
   ═══════════════════════════════════════════════════════════════════════ */

/* ───────────── tokens ───────────── */
:root {
  --font-display: 'Fredoka', 'Nunito', ui-rounded, system-ui, sans-serif;
  --font-body: 'Nunito', ui-rounded, system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-emoji: 'Apple Color Emoji', 'Segoe UI Emoji', 'Noto Color Emoji', sans-serif;

  --bg: #fff7e8;
  --deco-1: rgba(251, 191, 36, 0.32);
  --deco-2: rgba(56, 189, 248, 0.16);
  --topbar: rgba(255, 247, 232, 0.88);
  --surface: #ffffff;
  --surface-2: #fff3da;
  --surface-3: #ffe7b8;
  --border: #f0dcb4;
  --text: #3a2206;
  --text-soft: #7d5c2c;
  --primary: #f59e0b;
  --primary-hi: #fcc434;
  --primary-lo: #c97a06;
  --primary-ink: #a85a03;
  --on-primary: #3a1c00;
  --accent: #1d5fd8;
  --good: #16a34a;
  --good-soft: #dcfce7;
  --good-edge: #15803d;
  --bad: #e11d48;
  --bad-soft: #ffe4e6;
  --hero-1: #ffe3a3;
  --hero-2: #ffd0a8;
  --tile-s: 92%;
  --tile-l: 90%;
  --shadow-1: 0 1px 0 rgba(120, 72, 0, 0.05), 0 8px 22px -12px rgba(120, 72, 0, 0.28);
  --shadow-2: 0 2px 0 rgba(120, 72, 0, 0.06), 0 22px 44px -18px rgba(120, 72, 0, 0.38);
  --r-xl: 28px;
  --r-lg: 22px;
  --r-md: 16px;
  --r-sm: 12px;
  --m0: #c9b99c;
  --m1: #f59e0b;
  --m2: #3b82f6;
  --m3: #10b981;
  --m4: #8b5cf6;
  color-scheme: light;
}

[data-theme="dark"] {
  --bg: #0f172a;
  --deco-1: rgba(245, 158, 11, 0.12);
  --deco-2: rgba(99, 102, 241, 0.16);
  --topbar: rgba(15, 23, 42, 0.86);
  --surface: #1b2538;
  --surface-2: #233049;
  --surface-3: #2c3b58;
  --border: #31415f;
  --text: #f1f5f9;
  --text-soft: #a9b6cb;
  --primary-ink: #fbbf24;
  --accent: #7cb3ff;
  --good-soft: #12351f;
  --bad-soft: #3d1420;
  --hero-1: #2a2a4a;
  --hero-2: #3b2a3a;
  --tile-s: 45%;
  --tile-l: 26%;
  --shadow-1: 0 1px 0 rgba(0, 0, 0, 0.2), 0 10px 24px -14px rgba(0, 0, 0, 0.6);
  --shadow-2: 0 2px 0 rgba(0, 0, 0, 0.2), 0 22px 44px -18px rgba(0, 0, 0, 0.7);
  --m0: #55617a;
  color-scheme: dark;
}

[data-theme="space"] {
  --bg: #0d0824;
  --deco-1: rgba(168, 85, 247, 0.22);
  --deco-2: rgba(236, 72, 153, 0.14);
  --topbar: rgba(13, 8, 36, 0.86);
  --surface: #1c1440;
  --surface-2: #261c52;
  --surface-3: #312466;
  --border: #3b2d75;
  --text: #f5f3ff;
  --text-soft: #c4b5fd;
  --primary-ink: #fcd34d;
  --accent: #a5b4fc;
  --good-soft: #143326;
  --bad-soft: #3f1430;
  --hero-1: #2e1c63;
  --hero-2: #4a1f5c;
  --tile-s: 55%;
  --tile-l: 28%;
  --shadow-1: 0 1px 0 rgba(0, 0, 0, 0.25), 0 10px 24px -14px rgba(0, 0, 0, 0.7);
  --shadow-2: 0 2px 0 rgba(0, 0, 0, 0.25), 0 22px 44px -18px rgba(0, 0, 0, 0.8);
  --m0: #5b4f86;
  color-scheme: dark;
}

[data-theme="jungle"] {
  --bg: #0b241a;
  --deco-1: rgba(132, 204, 22, 0.16);
  --deco-2: rgba(16, 185, 129, 0.16);
  --topbar: rgba(11, 36, 26, 0.88);
  --surface: #133a2b;
  --surface-2: #194735;
  --surface-3: #215741;
  --border: #2a6449;
  --text: #ecfdf5;
  --text-soft: #a7e3c5;
  --primary-ink: #fcd34d;
  --accent: #93e1ff;
  --good-soft: #0f3d24;
  --bad-soft: #42171f;
  --hero-1: #1d5a3c;
  --hero-2: #3b5a1d;
  --tile-s: 45%;
  --tile-l: 26%;
  --shadow-1: 0 1px 0 rgba(0, 0, 0, 0.2), 0 10px 24px -14px rgba(0, 0, 0, 0.6);
  --shadow-2: 0 2px 0 rgba(0, 0, 0, 0.2), 0 22px 44px -18px rgba(0, 0, 0, 0.7);
  --m0: #4c7a63;
  color-scheme: dark;
}

[data-theme="ocean"] {
  --bg: #06294a;
  --deco-1: rgba(56, 189, 248, 0.2);
  --deco-2: rgba(45, 212, 191, 0.14);
  --topbar: rgba(6, 41, 74, 0.88);
  --surface: #0b3a63;
  --surface-2: #0f4775;
  --surface-3: #145588;
  --border: #1d6599;
  --text: #e8f5ff;
  --text-soft: #9fd0f5;
  --primary-ink: #fcd34d;
  --accent: #a7f3ff;
  --good-soft: #0c3d33;
  --bad-soft: #3e1a2c;
  --hero-1: #0e5a8a;
  --hero-2: #146a7d;
  --tile-s: 50%;
  --tile-l: 28%;
  --shadow-1: 0 1px 0 rgba(0, 0, 0, 0.2), 0 10px 24px -14px rgba(0, 0, 0, 0.6);
  --shadow-2: 0 2px 0 rgba(0, 0, 0, 0.2), 0 22px 44px -18px rgba(0, 0, 0, 0.7);
  --m0: #3f6f93;
  color-scheme: dark;
}

/* ───────────── base ───────────── */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.45;
  color: var(--text);
  background: var(--bg);
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
  transition: background-color 0.3s ease, color 0.3s ease;
}
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(60vmax 60vmax at 105% -10%, var(--deco-1), transparent 60%),
    radial-gradient(50vmax 50vmax at -15% 110%, var(--deco-2), transparent 60%);
}
body.no-scroll { overflow: hidden; }
[hidden] { display: none !important; }
h1, h2, h3, h4 { font-family: var(--font-display); font-weight: 600; line-height: 1.15; margin: 0; letter-spacing: 0.005em; }
p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); }
img { max-width: 100%; display: block; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
.muted { color: var(--text-soft); }
.center { text-align: center; }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip-link { position: absolute; left: 12px; top: -60px; z-index: 5000; padding: 0.6rem 1rem; border-radius: 12px; background: var(--surface); color: var(--text); font-weight: 800; box-shadow: var(--shadow-2); }
.skip-link:focus { top: 12px; }
kbd { font-family: var(--font-body); }

/* ───────────── buttons ───────────── */
.btn {
  --b-bg: var(--surface);
  --b-fg: var(--text);
  --b-edge: var(--border);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 48px;
  padding: 0.7rem 1.25rem;
  border: 0;
  border-radius: var(--r-md);
  background: var(--b-bg);
  color: var(--b-fg);
  box-shadow: 0 4px 0 var(--b-edge);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.05rem;
  line-height: 1.15;
  text-decoration: none;
  text-align: center;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  transition: transform 0.08s ease, box-shadow 0.08s ease, filter 0.15s ease;
}
.btn:hover { filter: brightness(1.04); }
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--b-edge); }
.btn:disabled { opacity: 0.55; cursor: default; transform: none; filter: none; box-shadow: 0 4px 0 var(--b-edge); }
.btn small { display: block; font-family: var(--font-body); font-weight: 700; font-size: 0.8rem; opacity: 0.75; }
.btn-primary { --b-bg: linear-gradient(180deg, var(--primary-hi), var(--primary)); --b-fg: var(--on-primary); --b-edge: var(--primary-lo); }
.btn-outline { --b-fg: var(--primary-ink); --b-edge: var(--primary-lo); border: 3px solid var(--primary); }
.btn-soft { --b-bg: var(--surface-2); --b-edge: var(--border); }
.btn-ghost { --b-bg: transparent; --b-fg: var(--text-soft); box-shadow: none; min-height: 44px; }
.btn-ghost:hover { --b-bg: var(--surface-2); filter: none; }
.btn-ghost:active { transform: none; box-shadow: none; }
.btn-danger-soft { --b-bg: var(--bad-soft); --b-fg: var(--bad); --b-edge: rgba(225, 29, 72, 0.35); }
[data-theme]:not([data-theme="light"]) .btn-danger-soft { --b-fg: #fda4af; }
.btn-xl { min-height: 68px; font-size: 1.25rem; flex-direction: column; gap: 0.1rem; border-radius: var(--r-lg); }
.btn-lg { min-height: 56px; font-size: 1.15rem; padding: 0.8rem 1.6rem; }
.btn-sm { min-height: 38px; padding: 0.4rem 0.85rem; font-size: 0.95rem; box-shadow: 0 3px 0 var(--b-edge); }
.btn-block { width: 100%; }
.link-btn {
  background: none;
  border: 0;
  padding: 0.3rem 0.2rem;
  color: var(--accent);
  font-weight: 800;
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-thickness: 2px;
}
.link-danger { color: var(--bad); }
[data-theme]:not([data-theme="light"]) .link-danger { color: #fda4af; }
.icon-btn {
  flex: none;
  width: 44px;
  height: 44px;
  border-radius: 14px;
  border: 0;
  background: var(--surface-2);
  box-shadow: 0 3px 0 var(--border);
  display: grid;
  place-items: center;
  font-size: 1.2rem;
  line-height: 1;
  transition: transform 0.08s ease, box-shadow 0.08s ease;
}
.icon-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--border); }
.icon-btn-sm { width: 36px; height: 36px; font-size: 1rem; border-radius: 11px; vertical-align: middle; }

/* ───────────── cards & chips ───────────── */
.card {
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--r-xl);
  padding: 1.25rem;
  box-shadow: var(--shadow-1);
}
.card-title { font-size: 1.2rem; margin-bottom: 0.9rem; display: flex; align-items: center; gap: 0.5rem; }
.card-title small { font-family: var(--font-body); font-size: 0.85rem; font-weight: 800; color: var(--text-soft); }
.card-title-row { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; margin-bottom: 0.9rem; flex-wrap: wrap; }
.card-title-row .card-title { margin: 0; }
.eyebrow { font-size: 0.8rem; font-weight: 900; letter-spacing: 0.08em; text-transform: uppercase; color: var(--primary-ink); }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  min-height: 40px;
  padding: 0.3rem 0.75rem;
  border-radius: 999px;
  background: var(--surface);
  border: 2px solid var(--border);
  font-weight: 900;
  white-space: nowrap;
}
.chip-lg { min-height: 48px; font-size: 1.2rem; padding: 0.4rem 1rem; }
.tag { display: inline-flex; align-items: center; padding: 0.15rem 0.55rem; border-radius: 999px; background: var(--surface-2); font-size: 0.78rem; font-weight: 800; color: var(--text-soft); }
.tag-done { background: var(--good-soft); color: var(--good); }
[data-theme]:not([data-theme="light"]) .tag-done { color: #86efac; }
.bar { height: 10px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--primary), var(--primary-hi)); transition: width 0.5s ease; }

/* ───────────── screens: splash, gateway, join, auth ───────────── */
.screen { min-height: 100vh; min-height: 100dvh; padding: max(16px, env(safe-area-inset-top)) 16px max(24px, env(safe-area-inset-bottom)); }
.screen-center { display: grid; place-items: center; }
.splash { display: grid; place-content: center; justify-items: center; gap: 0.75rem; text-align: center; }
.splash-lion { font-size: 4.5rem; line-height: 1; font-family: var(--font-emoji); animation: bob 1.4s ease-in-out infinite; }
.splash-text { font-family: var(--font-display); font-weight: 500; font-size: 1.15rem; color: var(--text-soft); }

.gate { width: 100%; max-width: 440px; text-align: center; padding: 1rem 0; }
.gate-mark { font-size: clamp(5rem, 24vw, 7.5rem); line-height: 1.05; font-family: var(--font-emoji); filter: drop-shadow(0 14px 18px rgba(180, 100, 0, 0.25)); animation: bob 3.2s ease-in-out infinite; }
.gate-title { font-size: clamp(2.4rem, 10vw, 3.25rem); font-weight: 700; margin-top: 0.5rem; }
.gate-title span { display: block; font-size: 0.48em; font-weight: 500; color: var(--primary-ink); letter-spacing: 0.02em; margin-top: 0.2rem; }
.gate-sub { margin: 0.75rem 0 2rem; color: var(--text-soft); font-weight: 700; font-size: 1.05rem; }
.gate-actions { display: grid; gap: 0.9rem; }
.gate-actions .btn-ghost { flex-direction: column; gap: 0; font-size: 1rem; }

.page-narrow { max-width: 980px; margin: 0 auto; padding: 0.5rem 0 2rem; }
.back-btn { margin-left: -0.5rem; }
.join-head { text-align: center; margin: 0.5rem auto 1.75rem; max-width: 560px; }
.join-head h1 { font-size: clamp(2rem, 7vw, 2.75rem); margin-bottom: 0.5rem; }
.join-head p { font-weight: 700; color: var(--text-soft); font-size: 1.1rem; }
.branch-grid { display: grid; gap: 1.25rem; grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr)); }
.branch { display: flex; flex-direction: column; gap: 0.6rem; }
.branch h2 { font-size: 1.3rem; }
.branch h2 small { font-family: var(--font-body); font-size: 0.85rem; color: var(--text-soft); font-weight: 800; }
.branch-name { font-weight: 800; }
.branch-addr { color: var(--text-soft); font-weight: 600; font-size: 0.95rem; }
.map-frame { aspect-ratio: 16 / 10; border-radius: var(--r-lg); overflow: hidden; border: 3px solid var(--primary); background: var(--surface-2); margin: 0.25rem 0 0.4rem; }
.map-frame iframe { width: 100%; height: 100%; border: 0; display: block; }
.join-cta { margin-top: 1.25rem; display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; background: linear-gradient(135deg, var(--hero-1), var(--hero-2)); border: 0; }
.join-cta h2 { font-size: 1.35rem; }
.join-cta p { font-weight: 700; color: var(--text-soft); }

.auth { width: 100%; max-width: 440px; padding: 1.25rem 1.5rem 1.6rem; }
.auth-mark { font-size: 3.5rem; text-align: center; line-height: 1; margin: -0.25rem 0 1rem; font-family: var(--font-emoji); }
.auth-h { font-size: 1.5rem; }
.auth-form { display: grid; gap: 0.9rem; margin-top: 1.1rem; }
.auth-form .link-btn { justify-self: center; }
.field { display: grid; gap: 0.35rem; border: 0; padding: 0; margin: 0; min-width: 0; }
.field > span, .field legend { font-weight: 800; font-size: 0.95rem; padding: 0; }
.field small { font-weight: 700; color: var(--text-soft); }
.field input[type="text"], .field input[type="email"], .field input[type="password"], .field input:not([type]) {
  width: 100%;
  min-height: 52px;
  padding: 0.7rem 0.95rem;
  border-radius: 14px;
  border: 2px solid var(--border);
  background: var(--surface-2);
  font-size: 1.05rem;
  font-weight: 700;
  outline: none;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.field input:focus { border-color: var(--primary); background: var(--surface); }
.pw-wrap { position: relative; display: block; }
.pw-wrap input { padding-right: 3.2rem !important; }
.pw-toggle { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); width: 42px; height: 42px; border: 0; background: none; border-radius: 10px; font-size: 1.1rem; }
.level-picker { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.5rem; }
.level-picker label { position: relative; }
.level-picker input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.level-picker span { display: grid; justify-items: center; gap: 0.1rem; padding: 0.6rem 0.3rem; border-radius: 14px; border: 2px solid var(--border); background: var(--surface-2); font-size: 1.5rem; transition: border-color 0.15s, background 0.15s; }
.level-picker b { font-family: var(--font-display); font-weight: 600; font-size: 0.95rem; }
.level-picker input:checked + span { border-color: var(--primary); background: var(--surface-3); box-shadow: 0 3px 0 var(--primary-lo); }
.level-picker input:focus-visible + span { outline: 3px solid var(--accent); outline-offset: 2px; }
.auth-msg { margin-top: 1rem; padding: 0.85rem 1rem; border-radius: 14px; font-weight: 700; }
.auth-msg.is-error { background: var(--bad-soft); color: var(--bad); }
.auth-msg.is-ok { background: var(--good-soft); color: var(--good); }
.auth-msg-actions { display: flex; gap: 0.5rem; margin-top: 0.6rem; flex-wrap: wrap; }

.segmented { display: flex; gap: 0.25rem; padding: 0.3rem; border-radius: 16px; background: var(--surface-2); border: 2px solid var(--border); }
.segmented button { flex: 1; min-height: 42px; border: 0; border-radius: 12px; background: transparent; font-family: var(--font-display); font-weight: 600; font-size: 1rem; color: var(--text-soft); padding: 0.3rem 0.6rem; white-space: nowrap; }
.segmented button[aria-selected="true"], .segmented button[aria-checked="true"] { background: var(--surface); color: var(--text); box-shadow: 0 2px 0 var(--border), 0 4px 10px -6px rgba(0, 0, 0, 0.25); }
.segmented-sm { display: inline-flex; flex-wrap: wrap; }
.segmented-sm button { flex: none; font-size: 0.92rem; min-height: 38px; }

/* ───────────── app chrome ───────────── */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--topbar);
  -webkit-backdrop-filter: saturate(1.4) blur(14px);
  backdrop-filter: saturate(1.4) blur(14px);
  border-bottom: 2px solid var(--border);
  padding-top: env(safe-area-inset-top);
}
.topbar-inner { max-width: 1120px; margin: 0 auto; display: flex; align-items: center; gap: 1rem; padding: 0.55rem 16px; }
.brand { display: flex; align-items: center; gap: 0.6rem; border: 0; background: none; padding: 0.15rem; border-radius: 16px; text-align: left; }
.brand-avatar { width: 46px; height: 46px; display: grid; place-items: center; font-size: 1.75rem; border-radius: 15px; background: var(--surface-2); border: 2px solid var(--border); font-family: var(--font-emoji); }
.brand-name { font-family: var(--font-display); font-weight: 700; font-size: 1.1rem; line-height: 1.05; }
.brand-name small { display: block; font-weight: 500; font-size: 0.75rem; color: var(--text-soft); }
.tabs { display: flex; gap: 0.2rem; margin: 0 auto; }
.tabs button { display: inline-flex; align-items: center; gap: 0.4rem; min-height: 44px; padding: 0.45rem 0.85rem; border: 0; border-radius: 14px; background: transparent; font-family: var(--font-display); font-weight: 600; font-size: 1rem; color: var(--text-soft); }
.tabs button span { font-size: 1.15rem; font-family: var(--font-emoji); }
.tabs button:hover { background: var(--surface-2); color: var(--text); }
.tabs button[aria-current="page"] { background: var(--surface); color: var(--text); box-shadow: inset 0 -3px 0 var(--primary), 0 2px 8px -4px rgba(0, 0, 0, 0.2); }
.top-stats { display: flex; align-items: center; gap: 0.45rem; }
.chip-star b { color: var(--primary-ink); font-size: 1.05rem; }
.chip-level { gap: 0.5rem; }
.mini-xp { display: block; width: 44px; height: 7px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.mini-xp i { display: block; height: 100%; background: linear-gradient(90deg, var(--primary), var(--primary-hi)); border-radius: inherit; transition: width 0.5s ease; }
.demo-banner { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 0.25rem 0.9rem; padding: 0.35rem 16px; background: var(--surface-3); font-weight: 800; font-size: 0.92rem; text-align: center; }

.main { max-width: 1120px; margin: 0 auto; padding: 1.25rem 16px 3rem; outline: none; }
.view { animation: fadeUp 0.25s ease both; }
.view-head { margin: 0.25rem 0 1.25rem; }
.view-head h1 { font-size: clamp(1.9rem, 6vw, 2.5rem); margin-bottom: 0.25rem; }
.view-head p { font-weight: 700; }
.view-head-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.section-title { font-size: 1.3rem; margin: 1.75rem 0 0.85rem; }
.section-title:first-of-type { margin-top: 0.5rem; }

/* ───────────── home ───────────── */
.hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.5rem 1.75rem;
  background: linear-gradient(135deg, var(--hero-1), var(--hero-2));
  border: 0;
  box-shadow: var(--shadow-2);
  overflow: hidden;
}
.hero-text { flex: 1; min-width: 0; }
.hero h1 { font-size: clamp(1.9rem, 6.5vw, 2.8rem); margin: 0.15rem 0 0.6rem; overflow-wrap: anywhere; }
.hero-sub { display: flex; align-items: center; flex-wrap: wrap; gap: 0.4rem 0.75rem; font-weight: 800; color: var(--text-soft); font-size: 0.95rem; margin-bottom: 0.7rem; }
.level-tag { display: inline-flex; padding: 0.2rem 0.65rem; border-radius: 999px; background: var(--surface); color: var(--text); border: 2px solid var(--border); }
.xp-track { height: 14px; border-radius: 999px; background: rgba(0, 0, 0, 0.1); overflow: hidden; max-width: 460px; }
[data-theme]:not([data-theme="light"]) .xp-track { background: rgba(255, 255, 255, 0.12); }
.xp-track i { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--primary), var(--primary-hi)); transition: width 0.6s cubic-bezier(0.34, 1.56, 0.64, 1); }
.hero-avatar, .profile-avatar { border: 0; background: none; padding: 0; line-height: 1; font-family: var(--font-emoji); }
.hero-avatar { font-size: clamp(4.25rem, 16vw, 6.5rem); filter: drop-shadow(0 12px 14px rgba(0, 0, 0, 0.18)); animation: bob 3.4s ease-in-out infinite; }
.is-petted { animation: pet 0.5s ease !important; }

.stat-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.85rem; margin-top: 1rem; }
.stat { display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; column-gap: 0.65rem; align-items: center; padding: 0.85rem 1rem; border-radius: var(--r-lg); background: var(--surface); border: 2px solid var(--border); box-shadow: var(--shadow-1); }
.stat-icon { grid-row: span 2; font-size: 1.9rem; font-family: var(--font-emoji); }
.stat b { font-family: var(--font-display); font-size: 1.55rem; font-weight: 600; line-height: 1; }
.stat small { font-weight: 800; color: var(--text-soft); font-size: 0.8rem; }
.streak-note { margin: 0.85rem 0.25rem 0; font-weight: 800; color: var(--text-soft); }

.home-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-top: 1.25rem; }
.span-2 { grid-column: 1 / -1; }
.next-card { display: flex; flex-direction: column; gap: 0.9rem; }
.next-body { display: flex; align-items: center; gap: 1rem; flex: 1; }
.next-body h2 { font-size: 1.45rem; margin-bottom: 0.2rem; }
.next-body p { font-weight: 700; }
.next-icon { flex: none; width: 76px; height: 76px; border-radius: 22px; display: grid; place-items: center; font-size: 2.6rem; background: hsl(var(--hue) var(--tile-s) var(--tile-l)); font-family: var(--font-emoji); }

.daily-list { display: grid; gap: 0.65rem; }
.daily { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 0.75rem; padding: 0.7rem 0.85rem; border-radius: var(--r-md); background: var(--surface-2); border: 2px solid transparent; }
.daily.is-ready { border-color: var(--primary); background: var(--surface-3); }
.daily.is-claimed { opacity: 0.7; }
.daily-icon { font-size: 1.6rem; font-family: var(--font-emoji); }
.daily-body { display: grid; gap: 0.25rem; min-width: 0; }
.daily-body b { font-size: 0.98rem; }
.daily-body small { font-weight: 800; color: var(--text-soft); font-size: 0.78rem; }
.daily-reward { font-weight: 900; color: var(--primary-ink); white-space: nowrap; }
.daily-done { font-size: 1.4rem; }

.today-games { display: flex; flex-wrap: wrap; gap: 0.6rem; }
.today-chip { position: relative; width: 60px; height: 60px; border-radius: 18px; border: 2px solid var(--border); background: var(--surface-2); font-size: 1.75rem; display: grid; place-items: center; font-family: var(--font-emoji); filter: grayscale(0.65); opacity: 0.75; transition: transform 0.1s ease; }
.today-chip:hover { transform: translateY(-2px); filter: none; opacity: 1; }
.today-chip.is-done { filter: none; opacity: 1; border-color: var(--good); background: var(--good-soft); }
.today-chip i { position: absolute; right: -6px; top: -6px; width: 22px; height: 22px; border-radius: 50%; background: var(--good); color: #fff; font-style: normal; font-size: 0.75rem; font-weight: 900; display: grid; place-items: center; font-family: var(--font-body); border: 2px solid var(--surface); }

/* ───────────── games list ───────────── */
.game-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 250px), 1fr)); gap: 1rem; }
.game-card {
  display: grid;
  grid-template-columns: 68px 1fr;
  grid-template-rows: 1fr auto;
  column-gap: 0.9rem;
  row-gap: 0.5rem;
  align-items: center;
  padding: 1rem;
  text-align: left;
  border-radius: var(--r-xl);
  background: var(--surface);
  border: 2px solid var(--border);
  box-shadow: 0 5px 0 var(--border);
  transition: transform 0.1s ease, box-shadow 0.1s ease;
}
.game-card:hover { transform: translateY(-3px); box-shadow: 0 8px 0 var(--border); }
.game-card:active { transform: translateY(3px); box-shadow: 0 2px 0 var(--border); }
.game-icon { grid-row: span 2; align-self: start; width: 68px; height: 68px; border-radius: 20px; display: grid; place-items: center; font-size: 2.3rem; background: hsl(var(--hue) var(--tile-s) var(--tile-l)); font-family: var(--font-emoji); }
.game-text { display: grid; gap: 0.15rem; }
.game-text b { font-family: var(--font-display); font-weight: 600; font-size: 1.2rem; }
.game-text small { font-weight: 700; color: var(--text-soft); font-size: 0.9rem; line-height: 1.3; }
.game-foot { display: flex; flex-wrap: wrap; gap: 0.35rem; min-height: 0; }
.game-foot:empty { display: none; }
.game-card.is-featured {
  grid-column: 1 / -1;
  grid-template-columns: 84px 1fr;
  background: linear-gradient(120deg, #c2410c, #b91c1c 60%, #9d174d);
  border-color: transparent;
  box-shadow: 0 5px 0 #7f1d1d;
  color: #fff;
  padding: 1.25rem 1.4rem;
}
.game-card.is-featured:hover { box-shadow: 0 8px 0 #7f1d1d; }
.game-card.is-featured .game-icon { width: 84px; height: 84px; font-size: 3rem; background: rgba(255, 255, 255, 0.18); }
.game-card.is-featured .game-text b { font-size: 1.5rem; }
.game-card.is-featured .game-text small { color: rgba(255, 255, 255, 0.92); font-size: 1rem; }
.game-card.is-featured .tag { background: rgba(255, 255, 255, 0.2); color: #fff; }

/* ───────────── ABC ───────────── */
.abc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(86px, 1fr)); gap: 0.75rem; }
.abc-tile {
  aspect-ratio: 1;
  border-radius: var(--r-lg);
  border: 2px solid var(--border);
  background: hsl(var(--hue) var(--tile-s) var(--tile-l));
  box-shadow: 0 4px 0 var(--border);
  display: grid;
  place-content: center;
  justify-items: center;
  line-height: 1;
  transition: transform 0.1s ease;
}
.abc-tile:hover { transform: translateY(-3px) rotate(-2deg); }
.abc-tile:active { transform: translateY(2px); }
.abc-tile b { font-family: var(--font-display); font-weight: 700; font-size: 2.3rem; }
.abc-tile small { font-family: var(--font-display); font-weight: 500; font-size: 1.15rem; color: var(--text-soft); margin-top: 0.15rem; }

.letter-sheet { text-align: center; display: grid; justify-items: center; gap: 0.75rem; }
.letter-big { font-family: var(--font-display); font-weight: 700; font-size: 5rem; line-height: 1; color: var(--primary-ink); }
.letter-big span { font-weight: 500; font-size: 0.7em; margin-left: 0.1em; color: var(--text-soft); }
.letter-sheet h2 { font-size: 1.4rem; }
.letter-sheet .word-grid { width: 100%; margin-top: 0.5rem; }

.word-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: 0.6rem; }
.word-tile { display: grid; justify-items: center; gap: 0.15rem; padding: 0.7rem 0.4rem; border-radius: var(--r-md); border: 2px solid var(--border); background: var(--surface-2); text-align: center; transition: transform 0.1s ease; }
.word-tile:hover { transform: translateY(-2px); }
.word-emoji { font-size: 2rem; line-height: 1.15; font-family: var(--font-emoji); }
.word-tile b { font-family: var(--font-display); font-weight: 600; font-size: 1.05rem; overflow-wrap: anywhere; }
.word-tile small { font-size: 0.72rem; font-weight: 800; color: var(--text-soft); display: inline-flex; align-items: center; gap: 0.3rem; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; flex: none; }
.dot.m0, .stack .m0 { background: var(--m0); }
.dot.m1, .stack .m1 { background: var(--m1); }
.dot.m2, .stack .m2 { background: var(--m2); }
.dot.m3, .stack .m3 { background: var(--m3); }
.dot.m4, .stack .m4 { background: var(--m4); }

/* ───────────── shop ───────────── */
.shop-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 0.85rem; }
.shop-grid-wide { grid-template-columns: repeat(auto-fill, minmax(min(100%, 190px), 1fr)); }
.shop-item {
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 0.3rem;
  padding: 1rem 0.5rem;
  border-radius: var(--r-lg);
  border: 3px solid var(--border);
  background: var(--surface);
  box-shadow: 0 4px 0 var(--border);
  text-align: center;
  transition: transform 0.1s ease, border-color 0.15s ease;
}
button.shop-item:hover { transform: translateY(-2px); }
button.shop-item:active { transform: translateY(2px); }
.shop-emoji { font-size: 3rem; line-height: 1.1; font-family: var(--font-emoji); }
.shop-label { font-family: var(--font-display); font-weight: 600; font-size: 1rem; }
.shop-name { font-weight: 800; font-size: 0.95rem; }
.shop-item.is-on { border-color: var(--primary); background: var(--surface-2); box-shadow: 0 4px 0 var(--primary-lo); }
.shop-item.is-on .shop-label { color: var(--primary-ink); }
.shop-item.is-poor .shop-label { color: var(--text-soft); }
.shop-item.is-poor .shop-emoji { filter: grayscale(0.6); opacity: 0.75; }
.shop-item.is-confirm { border-color: var(--good); animation: pop 0.3s ease; }
.shop-item.is-confirm .shop-label { color: var(--good); }
.theme-swatch { width: 72px; height: 72px; border-radius: 20px; display: grid; place-items: center; font-size: 2.2rem; font-family: var(--font-emoji); border: 2px solid rgba(0, 0, 0, 0.08); }
[data-swatch="light"] .theme-swatch { background: linear-gradient(135deg, #fff1cf, #ffd59a); }
[data-swatch="dark"] .theme-swatch { background: linear-gradient(135deg, #1e293b, #0f172a); }
[data-swatch="space"] .theme-swatch { background: linear-gradient(135deg, #3b2580, #0d0824); }
[data-swatch="jungle"] .theme-swatch { background: linear-gradient(135deg, #2f7a4c, #0b241a); }
[data-swatch="ocean"] .theme-swatch { background: linear-gradient(135deg, #0e7ac0, #06294a); }
.shop-power { grid-template-columns: auto 1fr; justify-items: start; text-align: left; gap: 0.4rem 1rem; padding: 1rem 1.1rem; }
.shop-power .shop-emoji { grid-row: span 2; }
.power-text { display: grid; gap: 0.15rem; }
.power-text b { font-family: var(--font-display); font-weight: 600; font-size: 1.15rem; }
.power-text small { font-weight: 700; color: var(--text-soft); }
.shop-power .btn { grid-column: 2; justify-self: start; }

/* ───────────── me ───────────── */
.profile { display: flex; align-items: center; gap: 1.25rem; flex-wrap: wrap; padding: 1.4rem 1.6rem; background: linear-gradient(135deg, var(--hero-1), var(--hero-2)); border: 0; box-shadow: var(--shadow-2); }
.profile-avatar { font-size: clamp(4rem, 14vw, 5.5rem); }
.profile-info { display: grid; gap: 0.45rem; min-width: 0; flex: 1; }
.profile-info h1 { font-size: clamp(1.8rem, 6vw, 2.4rem); display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; overflow-wrap: anywhere; }
.profile-info .muted { font-weight: 700; }
.profile .segmented { background: var(--surface); }
.me-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-top: 1rem; }
.numbers { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.6rem; }
.num { display: grid; justify-items: center; gap: 0.1rem; padding: 0.75rem 0.3rem; border-radius: var(--r-md); background: var(--surface-2); text-align: center; }
.num span { font-size: 1.4rem; font-family: var(--font-emoji); }
.num b { font-family: var(--font-display); font-size: 1.5rem; font-weight: 600; line-height: 1.1; }
.num small { font-size: 0.74rem; font-weight: 800; color: var(--text-soft); line-height: 1.2; }
.stack { display: flex; height: 18px; border-radius: 999px; overflow: hidden; background: var(--surface-3); margin: 0.75rem 0; }
.stack i { display: block; height: 100%; }
.legend { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 0.4rem 1.1rem; font-weight: 800; font-size: 0.9rem; }
.legend li { display: inline-flex; align-items: center; gap: 0.4rem; }
.badge-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(128px, 1fr)); gap: 0.65rem; }
.badge { display: grid; justify-items: center; text-align: center; gap: 0.15rem; padding: 0.85rem 0.5rem; border-radius: var(--r-md); background: var(--surface-2); border: 2px solid var(--primary); }
.badge span { font-size: 2.2rem; line-height: 1.1; font-family: var(--font-emoji); }
.badge b { font-family: var(--font-display); font-weight: 600; font-size: 1rem; }
.badge small { font-weight: 700; color: var(--text-soft); font-size: 0.76rem; line-height: 1.25; }
.badge.is-locked { border-color: transparent; }
.badge.is-locked span { filter: grayscale(1); opacity: 0.35; }
.badge.is-locked b { color: var(--text-soft); }
.art-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 0.75rem; }
.art { margin: 0; display: grid; gap: 0.35rem; }
.art img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: var(--r-md); border: 2px solid var(--border); background: #fff; }
.art figcaption { display: flex; justify-content: space-between; }
.empty-art { grid-column: 1 / -1; display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; font-weight: 700; }
.settings { display: grid; gap: 0.25rem; }
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 0.6rem 0.25rem; font-weight: 800; border-bottom: 2px dashed var(--border); cursor: pointer; }
.switch-row:last-child { border-bottom: 0; }
.switch-row input {
  appearance: none;
  -webkit-appearance: none;
  flex: none;
  width: 56px;
  height: 32px;
  border-radius: 999px;
  background: var(--surface-3);
  border: 2px solid var(--border);
  position: relative;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease;
  margin: 0;
}
.switch-row input::after { content: ''; position: absolute; top: 2px; left: 2px; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: 0 2px 4px rgba(0, 0, 0, 0.25); transition: transform 0.2s ease; }
.switch-row input:checked { background: var(--good); border-color: var(--good); }
.switch-row input:checked::after { transform: translateX(24px); }
.settings-actions { display: flex; flex-wrap: wrap; gap: 0.75rem; margin-top: 1rem; }

/* ───────────── sheet (dialog) ───────────── */
.sheet-bg { position: fixed; inset: 0; z-index: 200; display: flex; align-items: flex-end; justify-content: center; background: rgba(30, 15, 0, 0.45); padding: 0; opacity: 0; transition: opacity 0.18s ease; }
.sheet-bg.open { opacity: 1; }
.sheet {
  position: relative;
  width: min(620px, 100%);
  max-height: 90vh;
  max-height: 90dvh;
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--surface);
  border-radius: var(--r-xl) var(--r-xl) 0 0;
  padding: 1.5rem 1.25rem max(1.5rem, env(safe-area-inset-bottom));
  box-shadow: var(--shadow-2);
  transform: translateY(24px);
  transition: transform 0.22s cubic-bezier(0.2, 0.9, 0.3, 1.2);
}
.sheet-bg.open .sheet { transform: none; }
.sheet h2 { font-size: 1.5rem; margin: 0 3rem 0.75rem 0; }
.sheet > div > p { margin-bottom: 1rem; font-weight: 600; }
.sheet-close { position: absolute; top: 0.85rem; right: 0.85rem; }
.sheet-form { display: grid; gap: 1rem; }
.sheet-actions { display: flex; gap: 0.75rem; justify-content: flex-end; flex-wrap: wrap; }
.level-list { display: grid; gap: 0.6rem; margin-top: 1rem; }
.level-choice { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 0.8rem; padding: 0.85rem 1rem; border-radius: var(--r-md); border: 3px solid var(--border); background: var(--surface-2); text-align: left; font-size: 1.6rem; }
.level-choice b { font-family: var(--font-display); font-weight: 600; font-size: 1.2rem; }
.level-choice small { font-size: 0.85rem; font-weight: 800; color: var(--text-soft); }
.level-choice.is-on { border-color: var(--primary); background: var(--surface-3); }
.wall-tools { display: flex; flex-wrap: wrap; gap: 0.6rem; align-items: center; margin-bottom: 0.6rem; }
.wall-search { flex: 1; min-width: 160px; min-height: 44px; padding: 0.5rem 0.85rem; border-radius: 12px; border: 2px solid var(--border); background: var(--surface-2); font-weight: 700; }
.wall-search:focus { outline: none; border-color: var(--primary); }
.wall-hint { font-size: 0.9rem; font-weight: 700; margin-bottom: 0.75rem; }

/* ───────────── toasts ───────────── */
.toasts { position: fixed; z-index: 3000; bottom: calc(20px + env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%); display: grid; align-content: end; gap: 0.5rem; width: min(380px, calc(100% - 24px)); pointer-events: none; }
@media (max-width: 760px) {
  body:not(.no-scroll) .toasts { bottom: calc(84px + env(safe-area-inset-bottom)); }
}
/* during a game, answers sit low on the screen, so rare toasts show at the top */
body.no-scroll .toasts { top: calc(64px + env(safe-area-inset-top)); bottom: auto; align-content: start; }
.toast { display: flex; align-items: center; gap: 0.75rem; padding: 0.7rem 1rem; border-radius: var(--r-md); background: var(--surface); border: 2px solid var(--border); box-shadow: var(--shadow-2); animation: toastIn 0.3s cubic-bezier(0.2, 0.9, 0.3, 1.3) both; }
.toast.out { animation: toastOut 0.3s ease both; }
.toast-icon { font-size: 1.7rem; line-height: 1; font-family: var(--font-emoji); }
.toast b { display: block; font-family: var(--font-display); font-weight: 600; font-size: 1.02rem; }
.toast small { display: block; font-weight: 700; color: var(--text-soft); }
.float-reward { position: fixed; z-index: 3100; transform: translate(-50%, 0); font-family: var(--font-display); font-weight: 700; font-size: 1.35rem; color: var(--primary-ink); pointer-events: none; animation: floatUp 1s ease-out both; text-shadow: 0 2px 0 var(--surface); }

/* ───────────── game overlay ───────────── */
.game { position: fixed; inset: 0; z-index: 100; display: flex; justify-content: center; overflow-y: auto; overscroll-behavior: contain; background: var(--bg); opacity: 0; transform: translateY(14px); transition: opacity 0.18s ease, transform 0.18s ease; }
.game::before { content: ''; position: fixed; inset: 0; pointer-events: none; background: radial-gradient(70vmax 50vmax at 50% -20%, var(--deco-1), transparent 60%); }
.game.open { opacity: 1; transform: none; }
.game-shell { position: relative; width: 100%; max-width: 780px; min-height: 100%; display: flex; flex-direction: column; padding: max(10px, env(safe-area-inset-top)) 16px max(20px, env(safe-area-inset-bottom)); }
.game-head { display: flex; align-items: center; gap: 0.75rem; padding: 0.35rem 0; }
.game-title { flex: 1; min-width: 0; font-size: 1.25rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.game-hud { display: flex; gap: 0.35rem; flex-wrap: wrap; justify-content: flex-end; }
.hud-pill { display: inline-flex; align-items: center; gap: 0.25rem; padding: 0.3rem 0.65rem; border-radius: 999px; background: var(--surface); border: 2px solid var(--border); font-weight: 900; font-size: 0.95rem; white-space: nowrap; }
.hud-fire { border-color: #fb923c; }
.hud-time { min-width: 4.4em; justify-content: center; }
.hud-time.is-low { background: var(--bad-soft); border-color: var(--bad); color: var(--bad); animation: pulse 1s ease infinite; }
[data-theme]:not([data-theme="light"]) .hud-time.is-low { color: #fda4af; }
.game-progress { height: 10px; border-radius: 999px; background: var(--surface-3); overflow: hidden; margin: 0.6rem 0 1.25rem; }
.game-progress i { display: block; height: 100%; width: 0; border-radius: inherit; background: linear-gradient(90deg, #22c55e, #4ade80); transition: width 0.35s ease; }
.game-stage { flex: 1; display: flex; flex-direction: column; gap: 1.25rem; padding-bottom: 1.5rem; animation: fadeUp 0.22s ease both; }
/* centre short content vertically, but stay top-aligned when it overflows */
.game-stage > :first-child { margin-top: auto; }
.game-stage > :last-child { margin-bottom: auto; }
.empty { text-align: center; font-weight: 800; color: var(--text-soft); padding: 3rem 1rem; }

/* question parts */
.q { display: grid; justify-items: center; gap: 0.6rem; text-align: center; }
.q-label { font-weight: 800; color: var(--text-soft); font-size: 1.05rem; }
.q-word {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.2rem 0.9rem;
  border: 0;
  border-radius: 18px;
  background: none;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(2.3rem, 10vw, 3.6rem);
  line-height: 1.1;
  color: var(--text);
  overflow-wrap: anywhere;
}
.q-word:hover { background: var(--surface-2); }
.say-ico { font-size: 0.42em; opacity: 0.7; font-family: var(--font-emoji); }
.q-word-gap { letter-spacing: 0.06em; }
.gap { display: inline-block; min-width: 0.75em; border-bottom: 5px solid var(--primary); color: transparent; line-height: 1; }
.gap.is-filled { color: var(--good); border-color: var(--good); }
.q-emoji { font-size: clamp(4.25rem, 20vw, 6.5rem); line-height: 1.05; font-family: var(--font-emoji); animation: popIn 0.35s cubic-bezier(0.2, 0.9, 0.3, 1.4) both; }
.q-emoji-sm { font-size: clamp(3rem, 13vw, 4.25rem); }
.q-hint { font-weight: 700; color: var(--text-soft); max-width: 34ch; font-size: 1.05rem; }
.q-actions { display: flex; justify-content: center; gap: 0.5rem; flex-wrap: wrap; }
.q-feedback { min-height: 1.5em; text-align: center; font-weight: 800; font-size: 1.1rem; }

.listen-btns { display: flex; align-items: center; justify-content: center; gap: 1rem; margin: 0.25rem 0; }
.big-play { width: 116px; height: 116px; border-radius: 50%; border: 0; font-size: 3rem; font-family: var(--font-emoji); background: linear-gradient(180deg, var(--primary-hi), var(--primary)); box-shadow: 0 6px 0 var(--primary-lo), 0 16px 30px -12px rgba(245, 158, 11, 0.7); transition: transform 0.08s ease, box-shadow 0.08s ease; }
.big-play:active { transform: translateY(4px); box-shadow: 0 2px 0 var(--primary-lo); }
.slow-play { width: 64px; height: 64px; border-radius: 50%; border: 0; font-size: 1.8rem; font-family: var(--font-emoji); background: var(--surface-2); box-shadow: 0 4px 0 var(--border); }
.slow-play:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--border); }

.opts { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.85rem; }
.opt {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  min-height: 92px;
  padding: 0.75rem;
  border-radius: var(--r-lg);
  border: 3px solid var(--border);
  background: var(--surface);
  box-shadow: 0 5px 0 var(--border);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.35rem;
  color: var(--text);
  touch-action: manipulation;
  transition: transform 0.08s ease, box-shadow 0.08s ease, background 0.15s ease, border-color 0.15s ease, opacity 0.2s ease;
}
.opt:not(:disabled):hover { border-color: var(--primary); }
.opt:not(:disabled):active { transform: translateY(4px); box-shadow: 0 1px 0 var(--border); }
.opt:disabled { cursor: default; }
.opt kbd { position: absolute; top: 6px; left: 10px; font-size: 0.75rem; font-weight: 800; color: var(--text-soft); opacity: 0.6; }
.opt-emoji { font-size: clamp(2.2rem, 9vw, 2.8rem); line-height: 1.1; font-family: var(--font-emoji); }
.opts-emoji .opt { min-height: clamp(118px, 30vw, 160px); }
.opts-emoji .opt-emoji { font-size: clamp(3.2rem, 14vw, 4.6rem); }
.opt-text { overflow-wrap: anywhere; line-height: 1.15; }
.opts-text .opt { min-height: 76px; font-size: 1.4rem; }
.opts-letters { grid-template-columns: repeat(4, 1fr); }
.opts-letters .opt { font-size: 2.4rem; min-height: 86px; }
.opt.is-right { background: var(--good-soft); border-color: var(--good); box-shadow: 0 5px 0 var(--good-edge); animation: pop 0.35s ease; opacity: 1; }
.opt.is-reveal { animation: none; }
.opt.is-wrong { background: var(--bad-soft); border-color: var(--bad); box-shadow: none; transform: translateY(4px); opacity: 0.7; }
.opt.is-dim { opacity: 0.4; }

.slots { display: flex; justify-content: center; flex-wrap: nowrap; gap: clamp(0.2rem, 1vw, 0.4rem); max-width: 100%; }
.slot { flex: 0 1 48px; min-width: 0; width: 48px; height: clamp(46px, 12vw, 60px); border-radius: 12px; border: 3px solid var(--border); background: var(--surface); display: grid; place-items: center; font-family: var(--font-display); font-weight: 600; font-size: clamp(1.4rem, 6vw, 2rem); transition: border-color 0.15s ease, transform 0.15s ease; }
.slot-on { border-color: var(--primary); }
.slot-fixed { flex: 0 0 auto; width: auto; min-width: 10px; border-color: transparent; background: transparent; }
.slots.is-right .slot:not(.slot-fixed) { border-color: var(--good); background: var(--good-soft); animation: pop 0.35s ease; }
.slots.is-reveal .slot:not(.slot-fixed) { border-color: var(--bad); }
.type-row { display: flex; gap: 0.6rem; max-width: 520px; width: 100%; margin: 0 auto; }
.type-input {
  flex: 1;
  min-width: 0;
  min-height: 62px;
  padding: 0.5rem 1rem;
  border-radius: var(--r-md);
  border: 3px solid var(--border);
  background: var(--surface);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.7rem;
  text-align: center;
  outline: none;
  transition: border-color 0.15s ease;
}
.type-input:focus { border-color: var(--primary); }
.type-input.is-right { border-color: var(--good); background: var(--good-soft); }
.type-input.is-wrong { border-color: var(--bad); background: var(--bad-soft); }
.type-row .btn { min-height: 62px; }

.tiles { display: flex; justify-content: center; flex-wrap: wrap; gap: 0.6rem; }
.tile {
  min-width: 58px;
  height: 62px;
  padding: 0 0.7rem;
  border-radius: 16px;
  border: 0;
  background: linear-gradient(180deg, var(--primary-hi), var(--primary));
  color: var(--on-primary);
  box-shadow: 0 5px 0 var(--primary-lo);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.8rem;
  touch-action: manipulation;
  transition: transform 0.08s ease, box-shadow 0.08s ease, opacity 0.2s ease;
}
.tile:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--primary-lo); }
.tile.is-used { opacity: 0.18; transform: scale(0.9); box-shadow: none; }
.tile-word { font-size: 1.3rem; height: 54px; }
.build { display: flex; align-items: flex-end; justify-content: center; flex-wrap: wrap; gap: 0.35rem; min-height: 72px; padding: 0.75rem; border-radius: var(--r-lg); border: 3px dashed var(--border); background: var(--surface); font-family: var(--font-display); font-weight: 600; font-size: 1.45rem; }
.build-line { display: contents; }
.build-word { padding: 0.2rem 0.55rem; border-radius: 10px; background: var(--surface-2); animation: popIn 0.25s ease both; }
.build-end { padding-bottom: 0.2rem; }
.build.is-right { border-style: solid; border-color: var(--good); background: var(--good-soft); }
.sentence { font-weight: 800; font-size: clamp(1.35rem, 5.5vw, 1.9rem); line-height: 1.7; max-width: 30ch; text-wrap: balance; }
.blank { display: inline-block; min-width: 4.2em; margin: 0 0.15em; border-bottom: 5px solid var(--primary); text-align: center; line-height: 1.1; color: var(--good); font-family: var(--font-display); }
.blank.is-filled { border-color: var(--good); animation: pop 0.35s ease; }

/* memory */
.memory { display: grid; grid-template-columns: repeat(var(--cols, 4), 1fr); gap: clamp(0.4rem, 2vw, 0.75rem); max-width: 600px; width: 100%; margin: 0 auto; }
.mcard { aspect-ratio: 3 / 3.4; padding: 0; border: 0; background: none; perspective: 700px; touch-action: manipulation; }
.mcard-inner { position: relative; display: block; width: 100%; height: 100%; transform-style: preserve-3d; transition: transform 0.35s ease; }
.mcard.is-up .mcard-inner { transform: rotateY(180deg); }
.mcard-face { position: absolute; inset: 0; display: grid; place-items: center; border-radius: var(--r-md); -webkit-backface-visibility: hidden; backface-visibility: hidden; padding: 0.25rem; }
.mcard-back { background: linear-gradient(160deg, var(--primary-hi), var(--primary)); box-shadow: 0 5px 0 var(--primary-lo); font-size: clamp(1.6rem, 7vw, 2.4rem); font-family: var(--font-emoji); }
.mcard-front { transform: rotateY(180deg); background: var(--surface); border: 3px solid var(--border); box-shadow: 0 4px 0 var(--border); }
.mcard-emoji { font-size: clamp(2rem, 9vw, 3rem); font-family: var(--font-emoji); }
.mcard-word { font-family: var(--font-display); font-weight: 600; font-size: clamp(0.85rem, 3.6vw, 1.25rem); line-height: 1.1; overflow-wrap: anywhere; text-align: center; }
.mcard.is-matched .mcard-front { border-color: var(--good); background: var(--good-soft); box-shadow: 0 4px 0 var(--good-edge); }
.mcard.is-matched { animation: pop 0.35s ease; }

/* category sort */
.buckets { display: grid; grid-template-columns: repeat(var(--n, 3), 1fr); gap: 0.6rem; }
.bucket { display: flex; flex-direction: column; align-items: stretch; gap: 0.5rem; min-height: 150px; padding: 0.65rem; border-radius: var(--r-lg); border: 3px solid var(--border); background: var(--surface); box-shadow: 0 5px 0 var(--border); text-align: center; transition: border-color 0.15s ease, transform 0.08s ease; }
.bucket:active { transform: translateY(3px); }
.bucket:hover { border-color: var(--primary); }
.bucket-head { display: grid; justify-items: center; gap: 0.1rem; position: relative; }
.bucket-head kbd { position: absolute; top: -2px; left: 2px; font-size: 0.7rem; font-weight: 800; color: var(--text-soft); opacity: 0.6; }
.bucket-icon { font-size: 1.9rem; font-family: var(--font-emoji); line-height: 1.1; }
.bucket-head b { font-family: var(--font-display); font-weight: 600; font-size: 1.05rem; overflow-wrap: anywhere; }
.bucket-items { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.3rem; }
.bucket-tag { display: inline-flex; align-items: center; gap: 0.2rem; padding: 0.15rem 0.45rem; border-radius: 999px; background: var(--good-soft); font-weight: 800; font-size: 0.82rem; animation: popIn 0.25s ease both; }
.chips { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.55rem; padding: 0.85rem; border-radius: var(--r-lg); background: var(--surface-2); min-height: 72px; }
.word-chip { display: inline-flex; align-items: center; gap: 0.35rem; min-height: 52px; padding: 0.4rem 0.95rem; border-radius: 999px; border: 3px solid var(--border); background: var(--surface); box-shadow: 0 4px 0 var(--border); font-family: var(--font-display); font-weight: 600; font-size: 1.15rem; transition: transform 0.1s ease, border-color 0.15s ease; touch-action: manipulation; }
.word-chip > .pic-emoji { font-size: 1.3rem; }
.word-chip[aria-pressed="true"] { border-color: var(--primary); background: var(--surface-3); transform: translateY(-4px); box-shadow: 0 8px 0 var(--primary-lo); }

/* typing race */
.race { display: grid; gap: 1rem; justify-items: center; }
.race-timer { width: 100%; height: 16px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.race-timer i { display: block; height: 100%; width: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--primary), var(--primary-hi)); }
.race-timer.is-low i { background: linear-gradient(90deg, #ef4444, #f97316); }
.race-card { display: grid; justify-items: center; gap: 0.25rem; padding: 1rem 2rem; border-radius: var(--r-xl); background: var(--surface); border: 2px solid var(--border); box-shadow: var(--shadow-1); min-width: min(100%, 320px); }
.race-word { font-family: var(--font-display); font-weight: 600; font-size: clamp(2.2rem, 10vw, 3.3rem); line-height: 1.1; text-align: center; overflow-wrap: anywhere; }
.race-input { width: min(100%, 460px); flex: none; }

/* art studio */
.studio { display: grid; gap: 0.85rem; }
.studio-prompt { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 0.4rem; font-weight: 800; font-size: 1.15rem; }
.studio-word { font-family: var(--font-display); font-weight: 600; font-size: 1.6rem; }
.studio-emoji { font-size: 1.8rem; font-family: var(--font-emoji); }
.studio-tools { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 0.6rem 1rem; }
.swatches, .sizes { display: flex; flex-wrap: wrap; gap: 0.35rem; justify-content: center; }
.swatch { width: 36px; height: 36px; border-radius: 50%; border: 3px solid var(--surface); background: var(--c); box-shadow: 0 0 0 2px var(--border); transition: transform 0.1s ease; }
.swatch[aria-checked="true"] { transform: scale(1.15); box-shadow: 0 0 0 3px var(--text); }
.swatch-eraser { background: repeating-conic-gradient(#ddd 0 25%, #fff 0 50%) 50% / 12px 12px; }
.size { width: 42px; height: 42px; border-radius: 12px; border: 2px solid var(--border); background: var(--surface); display: grid; place-items: center; }
.size i { display: block; width: var(--z); height: var(--z); border-radius: 50%; background: var(--text); }
.size[aria-checked="true"] { border-color: var(--primary); background: var(--surface-3); }
.studio-actions { display: flex; gap: 0.4rem; }
.canvas-wrap { border-radius: var(--r-lg); overflow: hidden; border: 3px solid var(--border); background: #fff; box-shadow: var(--shadow-1); touch-action: none; }
.canvas-wrap canvas { display: block; width: 100%; height: auto; touch-action: none; cursor: crosshair; }
.studio-save { display: flex; flex-wrap: wrap; gap: 0.6rem; justify-content: center; }

/* intro & results */
.intro, .results { display: grid; justify-items: center; text-align: center; gap: 0.75rem; padding: 1rem 0; }
.intro-icon, .results-badge { font-size: clamp(4.5rem, 20vw, 6rem); line-height: 1; font-family: var(--font-emoji); animation: popIn 0.5s cubic-bezier(0.2, 0.9, 0.3, 1.5) both; }
.intro h3, .results-title { font-size: clamp(2rem, 8vw, 2.6rem); }
.intro p { font-weight: 700; color: var(--text-soft); font-size: 1.1rem; margin-bottom: 0.5rem; }
.results-line { font-weight: 700; font-size: 1.15rem; color: var(--text-soft); }
.results-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 120px)); gap: 0.6rem; margin: 0.5rem 0; }
.results-stats div { display: grid; padding: 0.75rem 0.4rem; border-radius: var(--r-md); background: var(--surface); border: 2px solid var(--border); }
.results-stats b { font-family: var(--font-display); font-weight: 600; font-size: 1.6rem; line-height: 1.1; }
.results-stats small { font-weight: 800; color: var(--text-soft); font-size: 0.8rem; }
.results-best { font-weight: 900; color: var(--primary-ink); font-size: 1.1rem; }
.results-review { width: 100%; max-width: 560px; padding: 1rem; border-radius: var(--r-lg); background: var(--surface-2); }
.results-review h4 { font-size: 1.1rem; margin-bottom: 0.6rem; }
.review-list { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.45rem; }
.review-word { display: inline-flex; align-items: center; gap: 0.35rem; min-height: 44px; padding: 0.3rem 0.8rem; border-radius: 999px; border: 2px solid var(--border); background: var(--surface); font-family: var(--font-display); font-weight: 600; font-size: 1.05rem; }
.results-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.75rem; margin-top: 0.5rem; }

/* ───────────── word pictures ───────────── */
.pic { display: block; flex: none; }
img.pic { object-fit: contain; background: #fff; border-radius: 12px; -webkit-user-drag: none; user-select: none; }
.pic-emoji { font-family: var(--font-emoji); line-height: 1.05; text-align: center; }
.opt-pic { width: 100%; height: clamp(104px, 27vw, 140px); }
.pic-emoji.opt-pic { height: auto; font-size: clamp(3.2rem, 14vw, 4.6rem); }
.opts-pics .opt { padding: 0.55rem; min-height: clamp(122px, 32vw, 160px); }
.opt-pic-sm { width: 100%; height: 72px; }
.pic-emoji.opt-pic-sm { height: auto; font-size: 2.6rem; }
.q-pic { display: grid; place-items: center; animation: popIn 0.35s cubic-bezier(0.2, 0.9, 0.3, 1.4) both; }
.pic-q { width: auto; max-width: min(78vw, 260px); height: clamp(130px, 34vw, 190px); }
.pic-emoji.pic-q { height: auto; font-size: clamp(4.25rem, 20vw, 6.5rem); }
.q-pic-sm .pic-q { height: clamp(96px, 24vw, 130px); }
.q-pic-sm .pic-emoji.pic-q { height: auto; font-size: clamp(3rem, 13vw, 4.25rem); }
.mcard-pic { width: 92%; height: 86%; }
.pic-emoji.mcard-pic { width: auto; height: auto; font-size: clamp(2rem, 9vw, 3rem); }
.chip-pic { width: 36px; height: 36px; border-radius: 8px; }
.pic-emoji.chip-pic { width: auto; height: auto; font-size: 1.4rem; }
.word-chip { padding-left: 0.4rem; }
.chip-text { text-align: left; line-height: 1.1; }
.tag-pic { width: 20px; height: 20px; border-radius: 5px; }
.pic-emoji.tag-pic { width: auto; height: auto; font-size: 1rem; }
.review-pic { width: 34px; height: 34px; border-radius: 8px; }
.pic-emoji.review-pic { width: auto; height: auto; font-size: 1.4rem; }
.review-word { padding-left: 0.35rem; }
.review-text { text-align: left; line-height: 1.1; }
.pic-tile { width: 72px; height: 64px; margin: 0 auto; }
.pic-emoji.pic-tile { width: auto; height: auto; font-size: 2.3rem; }
.word-pic { display: grid; place-items: center; min-height: 64px; }
.pic-lg { width: auto; max-width: 70%; height: 150px; }
.pic-emoji.pic-lg { height: auto; font-size: 5rem; }
.letter-pic { display: grid; place-items: center; }
.pic-studio { width: 48px; height: 48px; border-radius: 10px; }
.pic-emoji.pic-studio { width: auto; height: auto; font-size: 1.9rem; }
.race-pic .pic-q { height: clamp(110px, 28vw, 150px); }


/* ───────────── animations ───────────── */
@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-10px); } }
@keyframes pet { 0% { transform: scale(1); } 40% { transform: scale(1.18) rotate(-8deg); } 70% { transform: scale(0.95) rotate(5deg); } 100% { transform: scale(1); } }
@keyframes pop { 0% { transform: scale(1); } 45% { transform: scale(1.07); } 100% { transform: scale(1); } }
@keyframes popIn { from { transform: scale(0.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes fadeUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes shake { 0%, 100% { translate: 0; } 20% { translate: -7px; } 40% { translate: 6px; } 60% { translate: -4px; } 80% { translate: 3px; } }
@keyframes pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.06); } }
@keyframes floatUp { from { opacity: 1; transform: translate(-50%, 0); } to { opacity: 0; transform: translate(-50%, -46px); } }
@keyframes toastIn { from { opacity: 0; transform: translateY(14px) scale(0.96); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to { opacity: 0; transform: translateY(10px); } }
.shake { animation: shake 0.4s ease; }

/* ───────────── responsive ───────────── */
@media (max-width: 900px) {
  .brand-name { display: none; }
}

@media (max-width: 760px) {
  /* backdrop-filter would trap the fixed bottom tab bar inside the header */
  .topbar { -webkit-backdrop-filter: none; backdrop-filter: none; background: var(--bg); }
  .topbar-inner { gap: 0.5rem; padding: 0.45rem 12px; }
  .tabs {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 60;
    margin: 0;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 0.15rem;
    padding: 0.35rem 0.4rem calc(0.35rem + env(safe-area-inset-bottom));
    background: var(--surface);
    border-top: 2px solid var(--border);
    box-shadow: 0 -10px 26px -18px rgba(0, 0, 0, 0.35);
  }
  .tabs button { flex-direction: column; gap: 0.05rem; min-height: 56px; padding: 0.3rem 0; font-size: 0.78rem; border-radius: 14px; }
  .tabs button span { font-size: 1.45rem; }
  .tabs button[aria-current="page"] { background: var(--surface-2); box-shadow: inset 0 -3px 0 var(--primary); }
  .top-stats { margin-left: auto; }
  .main { padding: 1rem 12px calc(96px + env(safe-area-inset-bottom)); }
  .hero { padding: 1.2rem 1.25rem; }
  .stat-row { grid-template-columns: repeat(2, 1fr); gap: 0.6rem; }
  .home-grid, .me-grid { grid-template-columns: 1fr; }
  .numbers { grid-template-columns: repeat(2, 1fr); }
  .card { padding: 1.1rem; border-radius: var(--r-lg); }
  .profile { padding: 1.2rem; }
  .game-card.is-featured { grid-template-columns: 64px 1fr; padding: 1rem; }
  .game-card.is-featured .game-icon { width: 64px; height: 64px; font-size: 2.3rem; }
  .game-card.is-featured .game-text b { font-size: 1.25rem; }
  .game-card.is-featured .game-text small { font-size: 0.9rem; }
  .view-head-row { flex-wrap: wrap; }
}

@media (max-width: 420px) {
  .chip-level .mini-xp { display: none; }
  .top-stats .chip { padding: 0.25rem 0.6rem; min-height: 38px; }
  .opts-letters { grid-template-columns: repeat(2, 1fr); }
  .buckets { gap: 0.4rem; }
  .bucket { padding: 0.5rem 0.35rem; min-height: 132px; }
  .bucket-head b { font-size: 0.92rem; }
  .bucket-tag { font-size: 0.74rem; }
  .word-chip { font-size: 1.05rem; padding: 0.35rem 0.8rem; }
  .game-title { font-size: 1.05rem; }
  .hud-pill { padding: 0.25rem 0.5rem; font-size: 0.88rem; }
  .results-stats { grid-template-columns: repeat(3, 1fr); width: 100%; }
}

@media (min-width: 761px) {
  .sheet-bg { align-items: center; padding: 24px; }
  .sheet { border-radius: var(--r-xl); padding: 1.75rem; }
  .opts-emoji, .opts-pics, .opts-words { grid-template-columns: repeat(4, 1fr); }
  .opts-text { grid-template-columns: repeat(2, 1fr); }
}

@media (hover: none) {
  .opt kbd, .bucket-head kbd { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; scroll-behavior: auto !important; }
  .mcard.is-up .mcard-inner { transform: none; }
  .mcard.is-up .mcard-back { visibility: hidden; }
  .mcard-front { transform: none; visibility: hidden; }
  .mcard.is-up .mcard-front { visibility: visible; }
}
