/* ─────────────────────────────────────────────────────────────────────────
   Polyfox — premium clay design system (competitor-ui research §17).
   "Studio light, not iOS blur": warm dark chrome, fired-clay terracotta
   primary, hard clay-slab edges, fingerprint grain, Fraunces display +
   Outfit UI, target language always in Noto. Dark-first; light mode and
   the No-Theme classroom are the same system in their calm variants.
   ───────────────────────────────────────────────────────────────────────── */
[hidden] { display: none !important; }
@font-face {
  font-family: "Fraunces"; src: url("/fonts/fraunces-var.woff2") format("woff2");
  font-weight: 100 900; font-display: swap;
}
@font-face {
  font-family: "Outfit"; src: url("/fonts/outfit-var.woff2") format("woff2");
  font-weight: 100 900; font-display: swap;
}

:root {
  /* Brand clay palette (constant across modes & worlds) */
  --terra: #E4572E; --terra-hi: #EE6A3C; --terra-deep: #B93A1B;
  --marigold: #F2A007; --sage: #7FB069; --sky: #4EA8DE;
  --grape: #7B5EA7; --blush: #EF8FAB; --danger: #C1292E;
  --ink: #1E1B16; --paper: #F7F1E5;
  /* Dark-first chrome (default) */
  --bg: #1E1B16; --surface: #2A251E; --card: #352E24; --card-2: #40382B;
  --text: #F7F1E5; --muted: #CBBFA9; --line: rgba(247, 241, 229, 0.16);
  --outline: #D8CCB4; --input: #241F18; --groove: #1A1611; --trail: #4A4033;
  --good-text: #A8CC96; --sky-text: #9CD2F2; --danger-text: #F2A09C; --marigold-text: #F2A007;
  --bg-scene-opacity: 0.22;
  --sh1: 0 2px 0 rgba(0, 0, 0, 0.55), 0 12px 24px rgba(0, 0, 0, 0.32);
  --sh2: 0 4px 0 rgba(0, 0, 0, 0.4), 0 24px 48px rgba(0, 0, 0, 0.45);
  --font-ui: "Outfit", "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-display: "Fraunces", Georgia, "Times New Roman", serif;
  --font-target: "Noto Sans", "Noto Sans JP", "Noto Sans KR", "Noto Sans SC", "Noto Sans TC",
    "Noto Sans Arabic", "Noto Sans Hebrew", "Noto Sans Devanagari", "Noto Sans Thai", "Outfit", sans-serif;
}
:root[data-mode="light"] {
  --bg-scene-opacity: 0.14;
  --bg: #F7F1E5; --surface: #F7F1E5; --card: #FDF9EF; --card-2: #FFFDF6;
  --text: #1E1B16; --muted: #6E6252; --line: #E3D7C0;
  --outline: #1E1B16; --input: #FFFDF8; --groove: #E9DFC9; --trail: #D9C9A8;
  --good-text: #4C7A37; --sky-text: #1D6FA5; --danger-text: #C1292E; --marigold-text: #966600;
  --sh1: 0 2px 0 rgba(30, 27, 22, 0.9), 0 12px 24px rgba(30, 27, 22, 0.18);
  --sh2: 0 4px 0 rgba(30, 27, 22, 0.35), 0 24px 48px rgba(30, 27, 22, 0.3);
}
/* No world — just lessons: the same system, paper-first and quiet. */
body[data-theme="none"] {
  --bg-scene-opacity: 0.3;
  --bg: #F7F1E5; --surface: #F7F1E5; --card: #FDF9EF; --card-2: #FFFDF6;
  --text: #1E1B16; --muted: #6E6252; --line: #E3D7C0;
  --outline: #1E1B16; --input: #FFFDF8; --groove: #E9DFC9; --trail: #D9C9A8;
  --good-text: #4C7A37; --sky-text: #1D6FA5; --danger-text: #C1292E; --marigold-text: #966600;
  --sh1: 0 2px 0 rgba(30, 27, 22, 0.55), 0 10px 20px rgba(30, 27, 22, 0.12);
  --sh2: 0 4px 0 rgba(30, 27, 22, 0.3), 0 20px 40px rgba(30, 27, 22, 0.22);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font-ui); font-size: 17px; line-height: 1.45;
  color: var(--text); background: var(--bg); min-height: 100vh;
  transition: background 0.4s, color 0.4s;
}
h1, h2, .brand-name, .boss-name-display {
  font-family: var(--font-display); font-variation-settings: "SOFT" 100, "WONK" 1;
  font-optical-sizing: auto; letter-spacing: -0.01em;
}

/* Animated clay-gradient background — kept, but pulled back toward ink so
   the chrome stays stable and premium in every world. */
.bg-scene { position: fixed; inset: 0; z-index: -2; overflow: hidden; background: linear-gradient(160deg, #2E2620, #1E1B16); transition: background 0.6s; }
body[data-theme="starward"] .bg-scene { background: linear-gradient(160deg, #1B2040, #12101F); }
body[data-theme="reallife"] .bg-scene { background: linear-gradient(160deg, #2A3742, #1C232B); }
body[data-theme="pirates"] .bg-scene { background: linear-gradient(160deg, #274A47, #182423); }
body[data-theme="wildwest"] .bg-scene { background: linear-gradient(160deg, #4A3220, #241A10); }
body[data-theme="neon"] .bg-scene { background: linear-gradient(160deg, #2C1445, #150A20); }
body[data-theme="mythic"] .bg-scene { background: linear-gradient(160deg, #38312A, #201D17); }
body[data-theme="deep"] .bg-scene { background: linear-gradient(160deg, #1E3A40, #12242B); }
body[data-theme="egypt"] .bg-scene { background: linear-gradient(160deg, #45351D, #241B0F); }
body[data-theme="chess"] .bg-scene { background: linear-gradient(160deg, #2E2A25, #1C1A17); }
body[data-theme="none"] .bg-scene { background: linear-gradient(160deg, #F7F1E5, #EFE6D2); }
:root[data-mode="light"] .bg-scene { background: linear-gradient(160deg, #F3EAD8, #EAE0CB); }
:root[data-mode="light"] body[data-theme="none"] .bg-scene { background: linear-gradient(160deg, #F7F1E5, #EFE6D2); }
.bg-blob { position: absolute; border-radius: 50%; filter: blur(50px); opacity: 0.32; animation: drift 26s ease-in-out infinite alternate; }
.b1 { width: 55vmax; height: 55vmax; background: var(--terra); top: -18vmax; left: -12vmax; }
.b2 { width: 42vmax; height: 42vmax; background: var(--sky); bottom: -14vmax; right: -10vmax; animation-delay: -8s; }
.b3 { width: 26vmax; height: 26vmax; background: var(--marigold); bottom: 12vh; left: 30vw; opacity: 0.2; animation-delay: -16s; }
@keyframes drift { from { transform: translate(0, 0) scale(1); } to { transform: translate(4vmax, -3vmax) scale(1.08); } }
/* The living world scene: the active world's clay diorama, crossfaded on
   world switches (two stacked layers, .on is the visible one) and drifting
   almost imperceptibly — a photographed clay world breathing, not a video.
   Presence is a per-mode variable: quiet in light mode, a soft wash behind
   the paper classroom of No world. */
.bg-art { position: absolute; inset: -4%; width: 108%; height: 108%; object-fit: cover; opacity: 0; transition: opacity 0.8s ease; }
.bg-art.on { opacity: var(--bg-scene-opacity, 0.22); animation: sceneDrift 36s ease-in-out infinite alternate; }
@keyframes sceneDrift { from { transform: scale(1.02) translate(0, 0); } to { transform: scale(1.09) translate(-1.2%, 1.6%); } }
body.reduce-motion .bg-blob { animation: none; }
body.reduce-motion .bg-art, body.reduce-motion .screen-scene img { animation: none; }
body.reduce-motion *, body.reduce-motion *::before, body.reduce-motion *::after { animation-duration: 0.001s !important; animation-iteration-count: 1 !important; transition-duration: 0.001s !important; }
@media (prefers-reduced-motion: reduce) { .bg-blob { animation: none; } .bg-art, .screen-scene img { animation: none; } }

/* ── Living world scenes inside screens ──────────────────────────────────
   The same diorama, per screen, under scrims whose strengths were set by
   a worst-patch luminance check (scene × scrim vs the real text tokens,
   every theme, both modes — all ≥ WCAG AA 4.5:1; see BUILD-REPORT). The
   map's trail runs over the scene; lessons get the scene blurred and
   nearly still — softened, dimmed, never competing with the words. */
.screen-scene { position: absolute; inset: 0; border-radius: inherit; overflow: hidden; z-index: 0; pointer-events: none; }
.screen-scene img { position: absolute; inset: -3%; width: 106%; height: 106%; object-fit: cover; animation: sceneDrift 38s ease-in-out infinite alternate; }
.screen-scene .scrim { position: absolute; inset: 0; }
#screen-map .screen-scene .scrim { background: linear-gradient(180deg, color-mix(in srgb, var(--surface) 95%, transparent), color-mix(in srgb, var(--surface) 84%, transparent) 55%, color-mix(in srgb, var(--surface) 90%, transparent)); }
#screen-lesson .screen-scene .scrim, #screen-review .screen-scene .scrim { background: linear-gradient(180deg, color-mix(in srgb, var(--surface) 93%, transparent), color-mix(in srgb, var(--surface) 90%, transparent)); }
#screen-lesson .screen-scene img, #screen-review .screen-scene img { animation: none; filter: blur(3px) saturate(0.94); }
#screen-map > :not(.screen-scene), #screen-lesson > :not(.screen-scene), #screen-review > :not(.screen-scene) { position: relative; z-index: 1; }
#screen-map::after, #screen-lesson::after, #screen-review::after { z-index: 2; }

/* Studio-light surfaces: top-left light wash (::before) + fingerprint
   grain (::after) on every clay surface. */
.screen, .card, .unit-card, .plan, .boss-stage, .fox-panel, .round-card { position: relative; }
.screen::before, .card::before, .unit-card::before, .plan::before, .boss-stage::before, .fox-panel::before, .round-card::before {
  content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  background: radial-gradient(130% 100% at 10% 0%, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0) 55%);
}
.screen::after, .card::after, .unit-card::after, .plan::after, .boss-stage::after, .fox-panel::after, .round-card::after {
  content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none; opacity: 0.05;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ── Chrome ──────────────────────────────────────────────────────────── */
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; justify-content: space-between; align-items: center;
  padding: 10px 14px; border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  -webkit-backdrop-filter: blur(12px) saturate(1.2); backdrop-filter: blur(12px) saturate(1.2);
}
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .topbar { background: var(--bg); }
}
.brand { display: flex; align-items: center; gap: 9px; background: none; border: 0; cursor: pointer; font: inherit; }
.brand-icon { width: 38px; height: 38px; border-radius: 12px; box-shadow: var(--sh1); }
.brand-name { font-weight: 700; font-size: 1.3rem; color: var(--text); }
.top-actions { display: flex; gap: 8px; align-items: center; }
.icon-btn { background: var(--card); border: 2px solid var(--line); border-radius: 14px; font-size: 1.05rem; padding: 7px 11px; cursor: pointer; color: var(--text); box-shadow: var(--sh1); }
.icon-btn:active { transform: translateY(2px); }
.xp-chip { background: var(--card); border: 2px solid var(--line); border-radius: 999px; padding: 6px 13px; font-size: 0.92rem; font-variant-numeric: tabular-nums; box-shadow: var(--sh1); }
.xp-chip b { color: var(--marigold-text); }

main { max-width: 880px; margin: 0 auto; padding: 18px 14px 48px; }
.screen { background: var(--surface); border-radius: 24px; padding: 22px; box-shadow: var(--sh2); }
body[data-theme="none"] .screen { box-shadow: var(--sh1); }
h1 { font-size: clamp(2rem, 6vw, 2.5rem); line-height: 1.1; margin: 0.2em 0; font-weight: 700; }
h2 { font-size: 1.45rem; margin: 1.1em 0 0.3em; font-weight: 700; }
h3 { margin: 0.2em 0 0.6em; font-weight: 700; }
.tagline { font-size: 1.12rem; margin: 0.2em 0; }
.sub { color: var(--muted); margin: 0.25em 0 0.8em; }
.fineprint { font-size: 0.82rem; color: var(--muted); }
.err { color: var(--danger-text); min-height: 1.2em; font-weight: 600; }
a { color: var(--terra); }

.hero-wrap { position: relative; border-radius: 24px; overflow: hidden; box-shadow: var(--sh2); }
.hero-img { width: 100%; display: block; border-radius: 24px; height: clamp(230px, 42vh, 400px); object-fit: cover; }
.hero-overlay { position: absolute; left: 0; right: 0; bottom: 0; padding: 38px 16px 12px; color: #fff; background: linear-gradient(transparent, rgba(20, 12, 4, 0.72)); }
.hero-overlay h1 { color: #fff; text-shadow: 0 2px 10px rgba(0, 0, 0, 0.4); }
.hero-overlay .tagline { color: #ffe9d6; }
#screen-auth .hero-img { margin-bottom: 10px; }

.card { background: var(--card); border: 2px solid var(--line); border-radius: 24px; padding: 20px; margin: 14px 0; box-shadow: var(--sh1); }

/* ── Buttons — three kinds only ──────────────────────────────────────── */
.btn {
  font: inherit; font-weight: 700; border-radius: 18px; min-height: 48px;
  border: 2px solid var(--outline); background: var(--card); color: var(--text);
  padding: 10px 20px; cursor: pointer; box-shadow: var(--sh1);
  transition: transform 0.06s ease, box-shadow 0.06s ease, filter 0.12s ease;
}
.btn:hover { filter: brightness(1.05); }
.btn:active { transform: translateY(2px); }
.btn.primary {
  background: linear-gradient(180deg, var(--terra-hi), var(--terra) 55%); color: var(--ink);
  border: 0; text-transform: uppercase; letter-spacing: 0.04em; font-size: 0.95rem;
  box-shadow: 0 4px 0 var(--terra-deep), var(--sh1);
}
.btn.primary:active { transform: translateY(4px) scaleY(0.97); box-shadow: 0 0 0 var(--terra-deep), 0 2px 6px rgba(0, 0, 0, 0.25); }
.btn.ghost { background: transparent; border-color: transparent; box-shadow: none; }
.btn.ghost:hover { text-decoration: underline; text-underline-offset: 3px; }
.btn.big { width: 100%; min-height: 56px; padding: 14px; font-size: 1.02rem; margin: 6px 0; }
.btn.small { min-height: 38px; padding: 6px 12px; font-size: 0.88rem; border-radius: 14px; }
.btn.danger { background: color-mix(in srgb, var(--danger) 12%, var(--card)); border-color: var(--danger); color: var(--danger-text); }
.btn:disabled { opacity: 0.55; cursor: default; }
.cta-row { display: flex; gap: 10px; flex-wrap: wrap; margin: 12px 0; }
.cta-row .btn { flex: 1 1 220px; }
.badge { background: var(--marigold); color: var(--ink); border-radius: 999px; padding: 0 8px; font-size: 0.85em; font-weight: 800; }

.tabs { display: flex; gap: 8px; margin-bottom: 12px; }
.tab { flex: 1; font: inherit; font-weight: 700; min-height: 46px; padding: 9px; border-radius: 14px; border: 2px solid var(--line); background: var(--input); color: var(--text); cursor: pointer; }
.tab.active { background: linear-gradient(180deg, var(--terra-hi), var(--terra)); color: var(--ink); border-color: transparent; box-shadow: 0 3px 0 var(--terra-deep); }
label { display: block; font-weight: 600; margin: 10px 0; }
input[type="email"], input[type="password"], input[type="text"] {
  display: block; width: 100%; margin-top: 5px; font: inherit; padding: 12px 13px;
  border: 2px solid var(--line); border-radius: 14px; background: var(--input); color: var(--text);
}
input:focus-visible, button:focus-visible { outline: 3px solid var(--sky); outline-offset: 2px; }
.divider { display: flex; align-items: center; gap: 10px; color: var(--muted); margin: 14px 0; }
.divider::before, .divider::after { content: ""; flex: 1; border-top: 2px solid var(--line); }

/* ── Pickers ─────────────────────────────────────────────────────────── */
.lang-grid, .theme-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.lang-card, .theme-card {
  text-align: left; font: inherit; cursor: pointer; background: var(--card); color: var(--text);
  border: 3px solid var(--line); border-radius: 24px; padding: 14px; box-shadow: var(--sh1);
  transition: border-color 0.12s, transform 0.12s;
}
.lang-card:hover, .theme-card:hover { transform: translateY(-2px); }
.lang-card.sel, .theme-card.sel { border-color: var(--terra); box-shadow: 0 0 0 3px color-mix(in srgb, var(--terra) 30%, transparent), var(--sh1); }
.lang-card .native { font-family: var(--font-target); font-size: 1.15rem; font-weight: 800; display: block; }
.lang-card .lname { color: var(--muted); font-size: 0.9rem; }
.lang-card .depth { display: inline-block; margin-top: 6px; font-size: 0.72rem; font-weight: 700; padding: 2px 8px; border-radius: 999px; border: 1.5px solid var(--line); background: color-mix(in srgb, var(--marigold) 16%, var(--card)); color: var(--text); }
.theme-card .depth { display: inline-block; margin-top: 7px; font-size: 0.72rem; font-weight: 700; padding: 2px 8px; border-radius: 999px; border: 1.5px solid var(--line); background: color-mix(in srgb, var(--sage, #7FB069) 18%, var(--card)); color: var(--text); }
select { font: inherit; width: 100%; min-height: 46px; padding: 9px 12px; border-radius: 14px; border: 2px solid var(--line); background: var(--input); color: var(--text); }
select:focus-visible { outline: 3px solid var(--sky); outline-offset: 2px; }
.fox-hear { margin-top: 8px; }
.theme-card img { width: 100%; height: 92px; object-fit: cover; border-radius: 14px; display: block; margin-bottom: 8px; background: var(--groove); }
.theme-card .tname { font-weight: 800; display: block; }
.theme-card .ttag { font-size: 0.82rem; color: var(--muted); }

.values { padding-left: 0; list-style: none; margin: 0; }
.values li { margin: 9px 0; line-height: 1.45; }
.garden { display: flex; align-items: center; gap: 10px; margin-top: 14px; padding-top: 14px; border-top: 2px dashed var(--line); }
.garden-disc {
  width: 46px; height: 46px; flex: 0 0 auto; border-radius: 50%; display: grid; place-items: center; font-size: 1.25rem;
  background: radial-gradient(circle at 35% 28%, color-mix(in srgb, var(--sage) 55%, var(--card)), color-mix(in srgb, var(--sage) 30%, var(--card)));
  box-shadow: inset 0 3px 6px rgba(30, 27, 22, 0.25), var(--sh1);
}
.garden p { margin: 0; font-size: 0.92rem; color: var(--muted); }

/* ── Campaign map — diorama trail ────────────────────────────────────── */
.unit-list { display: flex; flex-direction: column; gap: 14px; position: relative; padding-left: 66px; margin-top: 10px; }
.unit-list::before {
  content: ""; position: absolute; left: 28px; top: 12px; bottom: 12px; width: 10px; border-radius: 999px;
  background: repeating-linear-gradient(180deg, var(--trail) 0 26px, transparent 26px 46px);
  box-shadow: inset 0 2px 3px rgba(0, 0, 0, 0.3);
}
.unit-card { position: relative; background: var(--card); border: 2px solid var(--line); border-radius: 24px; padding: 20px; box-shadow: var(--sh1); }
.unit-card.locked { opacity: 0.8; }
.node-disc {
  position: absolute; left: -66px; top: 18px; width: 56px; height: 56px; border-radius: 50%;
  display: grid; place-items: center; font-weight: 800; font-size: 1.05rem; color: var(--text);
  background: radial-gradient(circle at 34% 28%, var(--card-2), var(--card));
  border: 2px solid var(--line); box-shadow: var(--sh1); z-index: 1;
}
.node-disc.done {
  color: var(--ink);
  background:
    repeating-radial-gradient(circle at 50% 50%, rgba(30, 27, 22, 0.10) 0 2px, transparent 2px 5px),
    radial-gradient(circle at 34% 28%, #A9D69B, var(--sage));
  box-shadow: inset 0 4px 8px rgba(30, 27, 22, 0.35), 0 2px 0 rgba(30, 27, 22, 0.5);
}
.node-disc.current {
  background: linear-gradient(180deg, var(--terra-hi), var(--terra)); color: var(--ink);
  border-color: var(--terra-deep);
  box-shadow: 0 0 0 5px color-mix(in srgb, var(--terra) 32%, transparent), var(--sh1);
  animation: nodePulse 1.6s ease-in-out infinite;
}
.node-disc.locked { background: #8A8175; color: rgba(30, 27, 22, 0.55); filter: saturate(0.4); box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.25); }
@keyframes nodePulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.06); } }
.unit-head { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
.unit-title { font-weight: 800; font-size: 1.08rem; }
.unit-sit { color: var(--muted); font-size: 0.92rem; }
.unit-meta { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.pill { font-size: 0.78rem; font-weight: 700; border: 1.5px solid var(--line); border-radius: 999px; padding: 2px 9px; background: var(--groove); color: var(--text); }
.pill.done { background: color-mix(in srgb, var(--sage) 25%, var(--card)); border-color: var(--sage); }
.depth-note { background: color-mix(in srgb, var(--marigold) 13%, var(--card)); border: 1.5px dashed var(--marigold); border-radius: 14px; padding: 9px 13px; font-size: 0.9rem; }
.loot-list { margin: 0; padding-left: 18px; }

/* ── Lessons ─────────────────────────────────────────────────────────── */
.progress-track { height: 14px; background: var(--groove); border-radius: 999px; overflow: hidden; margin: 10px 0 16px; box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.3); }
.progress-fill { height: 100%; width: 0%; background: linear-gradient(90deg, var(--terra-hi), var(--terra)); border-radius: 999px; transition: width 0.35s ease; }
.round-card { min-height: 220px; }
.lesson-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.lesson-head .back-btn { margin-bottom: 0; }

/* ── Teach phase ("Meet the words") ────────────────────────────────────
   Words are taught before they are tested: learner-paced cards, one new
   item each, nothing scored. The card sits on the same clay system as the
   rounds it precedes. */
.teach-head h3 { margin: 0 0 4px; }
.teach-contract { font-size: 1.05rem; margin: 0 0 2px; }
.teach-card { text-align: center; padding: 10px 0 2px; }
.teach-count { color: var(--muted); font-size: 0.85rem; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; }
.teach-target { font-family: var(--font-target); font-size: 2.1rem; font-weight: 800; line-height: 1.25; margin: 8px 0 2px; }
.teach-en { font-size: 1.15rem; font-weight: 700; margin: 4px 0 14px; }
.teach-example {
  margin: 16px auto 2px; max-width: 30rem; text-align: left;
  background: color-mix(in srgb, var(--sky) 10%, var(--card)); border: 2px solid var(--line);
  border-radius: 16px; padding: 12px 14px;
}
.teach-example-target { font-family: var(--font-target); font-size: 1.2rem; font-weight: 700; margin: 2px 0; }
.teach-example .btn { margin-top: 8px; }
.teach-nav { display: flex; justify-content: space-between; gap: 10px; margin-top: 16px; }
.round-prompt { font-size: 1.15rem; font-weight: 800; margin-bottom: 8px; }
.round-en { color: var(--muted); margin-bottom: 10px; }
.speak-btn { font-size: 1.5rem; background: color-mix(in srgb, var(--sky) 18%, var(--card)); border: 2px solid var(--sky); border-radius: 999px; padding: 8px 18px; cursor: pointer; color: var(--text); box-shadow: 0 3px 0 color-mix(in srgb, var(--sky) 55%, var(--ink)); }
.speak-btn:active { transform: translateY(3px); box-shadow: none; }
.options { display: grid; gap: 10px; margin-top: 14px; }
.opt-btn {
  font: inherit; font-size: 1.05rem; text-align: left; padding: 13px 16px; min-height: 56px; border-radius: 16px;
  border: 2px solid var(--outline); background: var(--card-2); color: var(--text); cursor: pointer;
  box-shadow: 0 3px 0 color-mix(in srgb, var(--outline) 70%, var(--ink));
  transition: transform 0.06s ease, box-shadow 0.06s ease;
}
.opt-btn:hover { border-color: var(--sky); }
.opt-btn:active { transform: translateY(3px); box-shadow: 0 0 0 rgba(0, 0, 0, 0); }
.opt-btn.right { border-color: var(--sage); background: color-mix(in srgb, var(--sage) 22%, var(--card)); box-shadow: 0 3px 0 color-mix(in srgb, var(--sage) 60%, var(--ink)); }
.opt-btn.right::after { content: " ✓"; font-weight: 900; color: var(--good-text); }
.opt-btn.wrong { border-color: var(--danger); background: color-mix(in srgb, var(--danger) 13%, var(--card)); animation: shake 0.3s; }
@keyframes shake { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }
.tiles-bank, .tiles-answer { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; min-height: 52px; padding: 10px; border: 2px dashed var(--line); border-radius: 16px; }
.tiles-answer { border-style: solid; border-color: var(--line); background: var(--groove); box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.2); }
.tile {
  font: inherit; font-weight: 700; font-family: var(--font-target); padding: 10px 14px; min-height: 48px; border-radius: 14px;
  border: 2px solid var(--outline); background: var(--card-2); color: var(--text); cursor: pointer;
  box-shadow: 0 3px 0 color-mix(in srgb, var(--outline) 70%, var(--ink));
}
.tile:active { transform: translateY(3px); box-shadow: none; }
.dict-row { display: flex; gap: 10px; margin-top: 12px; align-items: center; flex-wrap: wrap; }
.dict-row input { flex: 1 1 180px; }
.dict-row [data-mic] {
  width: 72px; height: 72px; min-height: 72px; flex: 0 0 auto; border-radius: 50%; padding: 0;
  font-size: 1.7rem; background: linear-gradient(180deg, var(--terra-hi), var(--terra)); color: var(--ink);
  border: 0; box-shadow: 0 4px 0 var(--terra-deep), var(--sh1);
}
.dict-row [data-mic]:active { transform: translateY(4px); box-shadow: 0 0 0 var(--terra-deep); }
.dict-row [data-mic]:disabled { background: var(--groove); color: var(--muted); box-shadow: none; font-size: 0.8rem; }
.mic-note { font-size: 0.82rem; color: var(--muted); }
.roman { color: var(--muted); font-size: 0.95rem; }
.target-big { font-family: var(--font-target); font-size: 1.5rem; font-weight: 800; }
[dir="rtl"] { text-align: right; }

/* ── Fox coach — a clay tile that flips in ───────────────────────────── */
.fox-panel {
  display: flex; gap: 12px; align-items: flex-start; background: color-mix(in srgb, var(--marigold) 12%, var(--card));
  border: 2.5px solid var(--marigold); border-radius: 24px; padding: 16px; margin: 14px 0; box-shadow: var(--sh1);
  animation: tileFlip 0.3s ease; transform-origin: top center;
}
@keyframes tileFlip { from { transform: perspective(700px) rotateX(-64deg); opacity: 0; } to { transform: none; opacity: 1; } }
.fox-img { width: 74px; height: 74px; object-fit: cover; border-radius: 16px; flex: 0 0 auto; box-shadow: var(--sh1); }

/* ── Animated characters (batch 1) ─────────────────────────────────────
   The fox and the signature bosses are living clay now, not just plates:
   short muted loops/one-shots cut from the locked plates, layered over
   the plate itself (the plate is the poster and the fallback). Same
   discipline as the cutscenes: with the master Motion & Haptics toggle
   off, the OS asking for reduced motion, or Data Saver on, no video is
   ever fetched — the plate simply stands there, as it always did. */
.fox-media { position: relative; flex: 0 0 auto; width: 74px; height: 74px; display: inline-block; }
.fox-media .fox-img { display: block; }
.fox-vid { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: 50% 28%; border-radius: 16px; box-shadow: var(--sh1); background: #D9C6A5; }
.fox-vid[hidden] { display: none; }
.fox-media.greet, .fox-media.party { width: 96px; height: 96px; }
.fox-media.greet .fox-img, .fox-media.party .fox-img { width: 96px; height: 96px; }
.fox-greet { display: flex; gap: 14px; align-items: center; margin: 14px 0; }
.fox-greet h3 { margin: 0 0 4px; }
.celebrate-wrap { display: flex; justify-content: center; margin-bottom: 6px; }
.fox-panel h4 { margin: 0 0 4px; }
.fox-panel p { margin: 0.2em 0; line-height: 1.45; }
.fox-source { font-size: 0.78rem; color: var(--muted); font-style: italic; }

/* ── Boss arena ──────────────────────────────────────────────────────── */
.boss-stage { background-color: #2A251E; color: var(--paper); border-radius: 24px; padding: 20px; box-shadow: var(--sh2); overflow: hidden; }
/* Arena: the active world's diorama scene, FULL-BLEED portrait behind the
   plinth — the render had to letterbox its boss into a landscape window;
   the game doesn't. (The round-2 arena still remains as the load-failure
   fallback.) A dark scrim gradient keeps the fight's paper text at WCAG AA
   over the worst bright patch of every scene — verified numerically, see
   BUILD-REPORT — and the boss head sits on its own dark band, like the
   render's header. It is a still with a slow drift, not a loop: the render
   has no clean loopable segment, and a bad loop is worse than a good
   still. Drift dies with the master Motion toggle (body.reduce-motion)
   and with the OS reduced-motion setting; Data Saver gets the lite scene
   instead of none at all. No world: the classroom scene stays a whisper
   under a paper scrim — calm, paper-first. */
.boss-backdrop { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0.9; z-index: 0; pointer-events: none; animation: backdropDrift 26s ease-in-out infinite alternate; }
.boss-scrim { position: absolute; inset: 0; z-index: 0; pointer-events: none; background: linear-gradient(180deg, rgba(18, 14, 10, 0.40), rgba(18, 14, 10, 0.60) 45%, rgba(18, 14, 10, 0.70)); }
body[data-theme="none"] .boss-backdrop { opacity: 0.3; }
body[data-theme="none"] .boss-scrim { background: linear-gradient(180deg, rgba(247, 241, 229, 0.72), rgba(247, 241, 229, 0.78)); }
.boss-stage > :not(.boss-backdrop):not(.boss-scrim) { position: relative; z-index: 1; }
@keyframes backdropDrift { from { transform: scale(1.02) translate(0, 0); } to { transform: scale(1.1) translate(-1.5%, 1.5%); } }
body.reduce-motion .boss-backdrop { animation: none; }
@media (prefers-reduced-motion: reduce) { .boss-backdrop { animation: none; } }

/* ── Cutscene player ─────────────────────────────────────────────────── */
.cutscene { position: fixed; inset: 0; z-index: 90; background: #0B0906; display: flex; align-items: center; justify-content: center; }
.cutscene[hidden] { display: none; }
.cut-notice { position: absolute; bottom: 80px; left: 5%; right: 5%; z-index: 3; padding: 16px; background: #241E16; color: #fff; text-align: center; border-radius: 16px; }
.cutscene video, .cutscene > img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: #0B0906; }
.cut-ui { position: absolute; left: 0; right: 0; bottom: 0; display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 14px 16px calc(14px + env(safe-area-inset-bottom)); background: linear-gradient(transparent, rgba(11, 9, 6, 0.88) 45%); z-index: 2; }
.cut-title { font-family: var(--font-display); font-weight: 700; font-size: 1.05rem; color: var(--paper); letter-spacing: 0.01em; }
.cut-actions { display: flex; gap: 8px; margin-left: auto; }
/* Keep the video/Continue actions reachable on narrow Android WebViews.
   Previously the long title and unwrapped action row overflowed sideways. */
@media (max-width: 600px) {
  /* Bind the fixed overlay to the visual viewport even if page content widens it. */
  .cutscene {
    width: 100vw; height: 100dvh;
    max-width: 100vw; max-height: 100dvh;
    overflow: hidden;
  }
  .cut-ui {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    padding: 12px 12px calc(12px + env(safe-area-inset-bottom));
  }
  .cut-title { min-width: 0; font-size: 0.93rem; overflow-wrap: anywhere; }
  .cut-actions { margin-left: 0; max-width: 100%; flex-wrap: wrap; justify-content: stretch; }
  .cut-actions .btn {
    min-width: 0;
    flex: 1 1 120px;
    white-space: normal;
    overflow-wrap: anywhere;
  }
  .cut-notice { bottom: calc(162px + env(safe-area-inset-bottom)); }
}
body[data-theme="none"] .boss-stage { background-color: var(--card); color: var(--text); }
.boss-art-wrap { position: relative; }
.boss-art-wrap::after {
  content: ""; display: block; height: 16px; margin-top: -4px; border-radius: 0 0 14px 14px;
  background: linear-gradient(180deg, #463B2D, #241E16); box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.09);
}
body[data-theme="none"] .boss-art-wrap::after { display: none; }
.boss-art { width: 100%; height: 190px; object-fit: cover; border-radius: 16px; display: block; box-shadow: var(--sh2); transform-origin: 50% 100%; animation: bossBreathe 3.4s ease-in-out infinite; }
/* The boss's living layer: the idle loop plays over the plate (poster +
   fallback beneath). Reactions (flinch/gloat) move the whole wrap — boss
   and plinth together — so they read the same over video as over plate. */
.boss-video { position: absolute; top: 0; left: 0; width: 100%; height: 190px; object-fit: cover; border-radius: 16px; box-shadow: var(--sh2); background: #241E16; }
.boss-video[hidden] { display: none; }
.boss-art-wrap.flinch { animation: flinch 0.32s ease; }
.boss-art-wrap.gloat { animation: gloat 0.55s ease; }
.boss-stage.enraged .boss-video { filter: saturate(1.3) hue-rotate(-10deg); }
@keyframes bossBreathe { 0%, 100% { transform: scale(1) translateY(0); } 50% { transform: scale(1.016) translateY(-3px); } }
.boss-stage.enraged .boss-art { animation-duration: 1.5s; filter: saturate(1.3) hue-rotate(-10deg); }
.boss-stage.enraged #bossName { color: var(--blush); }
.boss-art.flinch { animation: flinch 0.32s ease; }
@keyframes flinch { 0% { transform: translateX(0); } 25% { transform: translateX(-9px) rotate(-1deg); } 60% { transform: translateX(6px); } 100% { transform: translateX(0); } }
.boss-art.gloat { animation: gloat 0.55s ease; }
@keyframes gloat { 0%, 100% { transform: translateY(0) scale(1); } 30% { transform: translateY(-7px) scale(1.03); } 60% { transform: translateY(0) scale(1.01); } }
.boss-art.squashed { animation: none; transform: scaleY(0.22) scaleX(1.14); transition: transform 0.5s cubic-bezier(0.25, 2.4, 0.45, 1); filter: saturate(1.1); }
.boss-head { display: flex; gap: 12px; align-items: center; margin-top: 12px; }
body:not([data-theme="none"]) .boss-head { background: rgba(18, 14, 10, 0.5); border-radius: 14px; padding: 8px 12px; }
.boss-head h2 { font-family: var(--font-display); font-variation-settings: "SOFT" 100, "WONK" 1; font-weight: 900; margin: 0; }
.boss-emoji { font-size: 2.4rem; }
.taunt { font-style: italic; background: rgba(247, 241, 229, 0.08); border-left: 4px solid var(--terra); padding: 9px 13px; border-radius: 0 14px 14px 0; }
body[data-theme="none"] .taunt { background: var(--groove); }
.bar-row { display: grid; grid-template-columns: 168px 1fr; gap: 10px; align-items: center; margin: 10px 0; font-size: 0.88rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.chunks { display: flex; gap: 5px; }
.chunk { flex: 1 1 0; height: 20px; border-radius: 7px; background: rgba(0, 0, 0, 0.35); box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.45); position: relative; }
body[data-theme="none"] .chunk { background: var(--groove); }
.chunk.filled.shieldc { background: linear-gradient(180deg, #7CC4EE, var(--sky)); box-shadow: inset 0 -3px 0 rgba(20, 60, 90, 0.45), 0 1px 0 rgba(0, 0, 0, 0.4); }
.chunk.filled.hpc { background: linear-gradient(180deg, #D84A4E, var(--danger)); box-shadow: inset 0 -3px 0 rgba(70, 10, 12, 0.5), 0 1px 0 rgba(0, 0, 0, 0.4); }
.chunk.crumbling { animation: crumble 0.45s ease-in forwards; z-index: 2; }
.chunk.crumbling::before {
  content: ""; position: absolute; inset: 0; border-radius: inherit;
  background:
    linear-gradient(115deg, transparent 45%, rgba(30, 27, 22, 0.85) 48%, transparent 52%),
    linear-gradient(58deg, transparent 43%, rgba(30, 27, 22, 0.7) 47%, transparent 51%);
}
@keyframes crumble { 30% { transform: translateY(2px) rotate(-4deg); } 100% { transform: translateY(16px) rotate(24deg) scale(0.65); opacity: 0; } }
.chip-particle { position: absolute; border-radius: 40%; pointer-events: none; z-index: 6; animation: chipFall 0.65s ease-in forwards; }
@keyframes chipFall { to { transform: translate(var(--dx), var(--dy)) rotate(var(--rot)); opacity: 0; } }
.confetti-chip { position: absolute; top: -12px; border-radius: 42%; pointer-events: none; z-index: 6; animation: confettiFall 1.5s ease-in forwards; }
@keyframes confettiFall { to { transform: translate(var(--dx), var(--dy)) rotate(var(--rot)); opacity: 0; } }
.phase-chip { display: inline-block; margin-top: 8px; font-weight: 800; font-size: 0.85rem; background: var(--grape); color: var(--paper); border-radius: 999px; padding: 5px 13px; }
.combo { display: inline-block; margin-left: 8px; font-weight: 800; background: var(--marigold); color: var(--ink); border-radius: 999px; padding: 5px 13px; font-size: 0.85rem; font-variant-numeric: tabular-nums; }
.floater {
  position: absolute; top: 110px; right: 22px; font-family: var(--font-display); font-weight: 900; font-size: 2.1rem; color: var(--marigold);
  text-shadow: 0 2px 0 var(--ink), 0 4px 14px rgba(0, 0, 0, 0.4); animation: floatUp 0.9s ease forwards; pointer-events: none; z-index: 7;
}
@keyframes floatUp { from { transform: translateY(10px); opacity: 0; } 25% { opacity: 1; } to { transform: translateY(-46px); opacity: 0; } }
.boss-says {
  background: var(--paper); color: var(--ink); border-radius: 20px; padding: 13px 15px; margin-bottom: 12px;
  border-bottom-left-radius: 4px; box-shadow: var(--sh1); cursor: pointer; position: relative;
}
.boss-says .target-big { color: var(--ink); }
.boss-says .roman { color: #6E6252; }
.gloss-hint { font-size: 0.78rem; color: #1D6FA5; font-weight: 700; margin-top: 4px; }
.boss-says .boss-gloss { display: none; margin-top: 4px; font-weight: 600; }
.boss-says.show-gloss .boss-gloss { display: block; }
.boss-says.show-gloss .gloss-hint { display: none; }
.loot-line { font-family: var(--font-display); font-size: 1.15rem; font-weight: 700; color: var(--marigold-text); }

/* ── Plans ───────────────────────────────────────────────────────────── */
.plans { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 12px; }
.plan { background: var(--card); border: 2.5px solid var(--line); border-radius: 24px; padding: 20px; box-shadow: var(--sh1); }
.plan.hot { border-color: var(--grape); box-shadow: 0 0 0 3px color-mix(in srgb, var(--grape) 25%, transparent), var(--sh1); }
.plan .price { font-family: var(--font-display); font-size: 1.9rem; font-weight: 900; font-variant-numeric: tabular-nums; }
.plan ul { padding-left: 18px; margin: 8px 0; }
.plan li { margin: 5px 0; font-size: 0.92rem; }

/* ── Settings / misc ─────────────────────────────────────────────────── */
.slider-row { display: grid; grid-template-columns: 92px 1fr 44px; align-items: center; gap: 10px; }
input[type="range"] { accent-color: var(--terra); }
.check-row { display: flex; gap: 9px; align-items: center; font-weight: 600; }
input[type="checkbox"] { accent-color: var(--terra); width: 20px; height: 20px; }
table.admin { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
table.admin td, table.admin th { border-bottom: 1px solid var(--line); padding: 6px 4px; text-align: left; }
.footer { text-align: center; color: var(--muted); padding: 16px 16px 96px; font-size: 0.85rem; }
.footer a { color: inherit; }

/* ── Floating glass bottom nav — chrome only (the §16/§17 rule) ──────────
   Liquid-Glass treatment lives ONLY here and on the top bar: translucent,
   backdrop-blurred, with a 1px top highlight. Content surfaces stay solid
   clay. Where backdrop-filter is unsupported the bar falls back to the solid
   stage/paper surface — no transparency, no blur, same layout. */
.bottom-nav {
  position: fixed; z-index: 60;
  left: 50%; transform: translateX(-50%);
  bottom: calc(10px + env(safe-area-inset-bottom, 0px));
  display: flex; gap: 4px; padding: 6px;
  border-radius: 999px;
  background: var(--card);
  border: 1px solid var(--line);
  box-shadow: var(--sh2), inset 0 1px 0 rgba(255, 255, 255, 0.14);
}
@supports (backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px)) {
  .bottom-nav {
    background: color-mix(in srgb, var(--bg) 68%, transparent);
    -webkit-backdrop-filter: blur(18px) saturate(1.5);
    backdrop-filter: blur(18px) saturate(1.5);
    border-color: color-mix(in srgb, var(--line) 55%, rgba(255, 255, 255, 0.22));
  }
}
.bottom-nav button {
  appearance: none; border: 0; cursor: pointer; background: transparent; color: var(--muted);
  font-family: var(--font-ui); font-weight: 700; font-size: 0.72rem;
  display: flex; flex-direction: column; align-items: center; gap: 1px;
  min-width: 68px; min-height: 52px; padding: 7px 10px 5px; border-radius: 999px;
}
.bottom-nav button .nav-emoji, .bottom-nav button { line-height: 1.15; }
.bottom-nav button.active { background: linear-gradient(180deg, var(--terra-hi), var(--terra)); color: var(--ink); box-shadow: 0 2px 0 var(--terra-deep); }
.bottom-nav button:active { transform: translateY(1px); }
.bottom-nav[hidden] { display: none; }
.back-btn { margin-bottom: 10px; }
@media (max-width: 560px) {
  .bar-row { grid-template-columns: 1fr; gap: 4px; }
  .screen { padding: 16px; }
  main { padding: 12px 8px 40px; }
  .unit-list { padding-left: 58px; }
  .node-disc { left: -58px; width: 50px; height: 50px; }
  .unit-list::before { left: 24px; }
}

/* ── levels (phase 1): tier tabs + placement cards ─────────────────────── */
.tier-tabs { display: flex; gap: 8px; flex-wrap: wrap; margin: 10px 0 14px; }
.tier-tab { border: 2px solid var(--line, #d8cfc0); background: var(--card, #fffaf0); color: inherit;
  border-radius: 999px; padding: 8px 14px; font: inherit; font-weight: 700; cursor: pointer; }
.tier-tab .tier-count { opacity: .65; font-weight: 600; }
.tier-tab.sel { background: var(--accent, #e4572e); border-color: var(--accent, #e4572e); color: #fff; }
.placement-list { display: grid; gap: 12px; margin-top: 14px; }
.placement-card { display: flex; gap: 14px; align-items: center; text-align: left; width: 100%;
  border: 2px solid var(--line, #d8cfc0); background: var(--card, #fffaf0); color: inherit;
  border-radius: 18px; padding: 16px; font: inherit; cursor: pointer; }
.placement-card:active { transform: scale(.99); }
.placement-icon { font-size: 2rem; }
.placement-main { display: grid; gap: 4px; }
.placement-main span { opacity: .8; }

/* ── per-question coach reactions (phase 2) ────────────────────────────── */
.coach-strip { display: flex; align-items: center; gap: 12px; margin: 10px 0 12px;
  background: var(--card, #fffaf0); border: 2px solid var(--line, #d8cfc0);
  border-radius: 18px; padding: 8px 14px 8px 8px; }
.coach-strip .fox-media { width: 64px; height: 64px; flex: 0 0 64px; border-radius: 14px; overflow: hidden; }
.coach-strip .fox-media img, .coach-strip .fox-media video { width: 100%; height: 100%; object-fit: cover; }
.coach-line { margin: 0; font-weight: 600; }
.coach-strip.combo { border-color: var(--marigold, #f2a007); box-shadow: 0 0 0 3px rgba(242,160,7,.35); }
#coachMedia.ear-perk { animation: earPerk 1.1s ease-in-out infinite alternate; }
@keyframes earPerk { from { transform: rotate(-2.5deg) scale(1); } to { transform: rotate(2.5deg) scale(1.05); } }
@media (prefers-reduced-motion: reduce) { #coachMedia.ear-perk { animation: none; } }

/* ── themed ambience (phase 3): per-world particle layer ───────────────── */
/* Particles are generated spans animated with transform + opacity ONLY.
   No background-image is ever transformed — the clay backdrops stay
   still. The layer exists only on lesson + arena screens and only
   while the shared motion gate allows it (JS-gated, see renderAmbience). */
#ambience { position: fixed; inset: 0; overflow: hidden; pointer-events: none; z-index: 3; }
.amb-p { position: absolute; bottom: -4vh; left: var(--x); width: var(--s); height: var(--s);
  opacity: 0; border-radius: 50%; animation: ambRise var(--d) linear infinite; animation-delay: var(--dl); }
.amb-p.fall { bottom: auto; top: -4vh; animation-name: ambFall; }
@keyframes ambRise {
  0% { transform: translate3d(0, 0, 0); opacity: 0; }
  12% { opacity: var(--o); }
  88% { opacity: var(--o); }
  100% { transform: translate3d(var(--sw), -108vh, 0); opacity: 0; }
}
@keyframes ambFall {
  0% { transform: translate3d(0, 0, 0) rotate(0deg); opacity: 0; }
  12% { opacity: var(--o); }
  88% { opacity: var(--o); }
  100% { transform: translate3d(var(--sw), 108vh, 0) rotate(160deg); opacity: 0; }
}
.amb-embers { background: radial-gradient(circle, #ffd9a0 0%, #f28c28 55%, rgba(242,140,40,0) 100%); }
.amb-bubbles { background: transparent; border: 1.5px solid rgba(190,230,255,.85); }
.amb-motes { background: #6ee7ff; border-radius: 2px; box-shadow: 0 0 6px rgba(110,231,255,.8); }
.amb-dust { background: radial-gradient(circle, rgba(216,190,150,.9), rgba(216,190,150,0) 70%); }
.amb-spray { background: radial-gradient(circle, rgba(210,240,255,.95), rgba(210,240,255,0) 70%); }
.amb-petals { background: #f5a8c0; border-radius: 70% 30% 70% 30%; }
.amb-snow { background: radial-gradient(circle, rgba(255,255,255,.95), rgba(255,255,255,0) 70%); }
.amb-sparkle { background: #fff6cf; box-shadow: 0 0 8px rgba(255,240,180,.95); }
.amb-paper { background: radial-gradient(circle, rgba(203,190,165,.8), rgba(203,190,165,0) 70%); }

/* ── social sign-in buttons (rendered only when a provider is configured) ── */
.oauth-btns { display: grid; gap: 10px; }
.btn.oauth { display: flex; align-items: center; justify-content: center; gap: 10px;
  background: var(--card-2); color: var(--text); border: 2px solid var(--line);
  text-decoration: none; box-shadow: var(--sh1); }
.btn.oauth .oauth-mark { font-family: var(--font-display); font-weight: 900; font-size: 1.05rem; line-height: 1; }
.btn.oauth.google .oauth-mark { color: var(--terra); }
.btn.oauth.apple { background: #141210; color: #F7F1E5; border-color: #141210; }
.btn.oauth.apple .oauth-mark::before { content: "\F8FF"; }

/* ── consent modal (first-use third-party AI decision) ───────────────────── */
.modal { position: fixed; inset: 0; z-index: 60; display: flex; align-items: center; justify-content: center;
  padding: 18px; background: rgba(20, 16, 11, 0.62); }
.modal[hidden] { display: none; }
.modal-card { max-width: 520px; width: 100%; max-height: 88vh; overflow: auto; }
.modal-card h3 { margin-top: 0; }

/* ── daily challenge ─────────────────────────────────────────────────────── */
.daily-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.daily-head h3 { margin: 0; }
.garden-daily .garden-disc { transition: transform 0.5s ease, background 0.5s ease; }
.garden.flourish .garden-disc { transform: scale(1.22) rotate(-6deg); background: color-mix(in srgb, var(--blush) 45%, var(--card-2)); }
#screen-daily .screen-scene .scrim { background: linear-gradient(180deg, color-mix(in srgb, var(--surface) 93%, transparent), color-mix(in srgb, var(--surface) 90%, transparent)); }
#screen-daily .screen-scene img { animation: none; filter: blur(3px) saturate(0.94); }
#screen-daily > :not(.screen-scene) { position: relative; z-index: 1; }

/* ── scene acts: the world moves with your steps ─────────────────────────── */
/* Act 0 (dawn) is the diorama exactly as it always rested — no shift.
   Act 1 (day) opens the crop and warms the grade; Act 2 (dusk) closes
   in golden. The victory grade is warmest of all. Everything here is
   filter + object-position + opacity: the dioramas are never
   transformed by the act system. The JS gate (applySceneAct) pins the
   act to 0 whenever motion is off or the OS asks for reduced motion,
   so under those settings none of these shifts ever appear — and the
   transitions below are killed too, so even a state change is still. */
.screen-scene img, .boss-backdrop, #ambience { transition: filter 1.4s ease, object-position 1.4s ease, opacity 1.4s ease; }
body[data-scene-act="1"] .screen-scene img { object-position: 50% 46%; }
body[data-scene-act="2"] .screen-scene img { object-position: 50% 60%; }
body[data-scene-act="1"] .boss-backdrop { object-position: 50% 46%; filter: saturate(1.06) brightness(1.03); }
body[data-scene-act="2"] .boss-backdrop { object-position: 50% 58%; filter: saturate(1.13) brightness(0.97) sepia(0.18); }
body[data-scene-act="1"] #screen-lesson .screen-scene img,
body[data-scene-act="1"] #screen-review .screen-scene img,
body[data-scene-act="1"] #screen-daily .screen-scene img { filter: blur(3px) saturate(1.03) brightness(1.04); }
body[data-scene-act="2"] #screen-lesson .screen-scene img,
body[data-scene-act="2"] #screen-review .screen-scene img,
body[data-scene-act="2"] #screen-daily .screen-scene img { filter: blur(3px) saturate(1.09) brightness(0.99) sepia(0.14); }
body[data-scene-act="0"] #ambience { opacity: 0.55; }
body[data-scene-act="1"] #ambience { opacity: 0.8; }
body[data-scene-act="2"] #ambience { opacity: 1; }
body.scene-victory .boss-backdrop { filter: saturate(1.28) brightness(1.06) sepia(0.22); }
body.scene-victory #ambience { opacity: 1; }
body.reduce-motion .screen-scene img, body.reduce-motion .boss-backdrop, body.reduce-motion #ambience { transition: none; }
@media (prefers-reduced-motion: reduce) {
  .screen-scene img, .boss-backdrop, #ambience { transition: none; }
}


/* Compact, named account identity without squeezing XP into a vertical column. */
.brand-copy{display:flex;flex-direction:column;align-items:flex-start;min-width:0;max-width:200px;line-height:1.15}
.learner-identity{display:block;font-size:.72rem;color:var(--text);opacity:.85;max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.learner-greeting{font-size:1rem;font-weight:600;margin:.25rem 0}
.xp-chip{white-space:nowrap;flex-shrink:0}
#classroomLink{margin:8px 0;display:inline-flex}
#classroomLink[hidden],.learner-identity[hidden],.learner-greeting[hidden]{display:none!important}
#accountInfo{overflow-wrap:anywhere;scroll-margin-top:120px}
@media(max-width:560px){.topbar{flex-wrap:wrap;gap:8px;padding:8px 12px}.brand{flex:1 1 auto;min-width:0;padding:0}.brand-copy{max-width:175px}.top-actions{flex:1 1 100%;justify-content:space-between;gap:5px}.top-actions .icon-btn{padding:7px 10px}.xp-chip{font-size:.78rem;padding:6px 8px}.brand-icon{width:32px;height:32px}}

#homeClassroomLink{display:block;text-align:center;text-decoration:none;margin:0 0 14px;white-space:normal}#homeClassroomLink[hidden]{display:none!important}

/* Ensure readable text on the new classroom entry across themes. */
#homeClassroomLink{color:#1e1b16;background:linear-gradient(180deg,#ffd49a,#edaa66);border-color:#edaa66;text-align:center;white-space:normal;line-height:1.3}#classroomLink{color:var(--text);text-align:center;white-space:normal}
