:root {
  --bg: #f3efe6;
  --surface: #fbf9f3;
  --surface-2: #ece7db;
  --line: #dcd5c6;
  --line-soft: rgba(156, 74, 47, 0.06);
  --text: #211f1b;
  --muted: #726b5e;
  --primary: #2c2823;
  --primary-ink: #171410;
  --primary-soft: #e7e0d2;
  --accent: #9c4a2f;
  --accent-soft: #efe1d7;
  --good: #4a6b52;
  --good-soft: #e4eae0;
  --bad: #a13f39;
  --bad-soft: #f0e1de;
  --radius: 8px;
  --radius-sm: 5px;
  --nav-h: 62px;
  --top-h: 54px;
  --shadow-sm: 0 1px 0 rgba(33, 31, 27, 0.03);
  --shadow: 0 2px 10px rgba(33, 31, 27, 0.05);
  --shadow-lg: 0 10px 30px rgba(33, 31, 27, 0.10);
  --font-display: "Fraunces", Georgia, "Times New Roman", serif;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }

body {
  font-family: "Plus Jakarta Sans", system-ui, -apple-system, sans-serif;
  background-color: var(--bg);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%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)' opacity='0.035'/%3E%3C/svg%3E");
  color: var(--text);
  overscroll-behavior-y: none;
  -webkit-font-smoothing: antialiased;
}
.thai { font-family: "Noto Serif Thai", "Noto Sans Thai", serif; }

/* Editorial display type — serif headlines carry the "quality/confident" feel. */
.brand-name, .section-title, .learn-hi, .hero-hi, .ob-title, .pl-prompt,
.step-title, .today-title, .goal-t, .review-title, .pr-title, .quick .qtitle,
.result-score, .stat .num, .quiz-q .prompt, .wod-thai, .cat-body .t,
.fc-back .mean, .fc-front .big, .qx-word, .all-done .ad-title, .pl-ring {
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: -0.01em;
}
.learn-hi, .ob-title, .result-score, .stat .num { font-weight: 600; }

#app {
  max-width: 460px;
  margin: 0 auto;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  position: relative;
  background: var(--bg);
  overflow: hidden; /* app shell: bars are static, only .view scrolls */
}

/* ---------- Topbar ---------- */
.topbar {
  flex-shrink: 0; z-index: 20;
  padding-top: env(safe-area-inset-top, 0px); /* clear the notch / Dynamic Island */
  background: rgba(243, 239, 230, 0.82);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.topbar-inner {
  height: var(--top-h); padding: 0 20px;
  display: flex; align-items: center; justify-content: space-between;
}
.brand { display: flex; align-items: center; gap: 9px; }
.brand-logo {
  display: grid; place-items: center;
  width: 30px; height: 30px; border-radius: 7px;
  background: transparent; color: var(--primary);
  border: 1.5px solid var(--primary);
  font-size: 18px; font-weight: 700;
}
.brand-name { font-weight: 600; letter-spacing: -0.2px; font-size: 18px; }
.streak {
  display: flex; align-items: center; gap: 5px;
  background: var(--surface); padding: 5px 11px; border-radius: 999px;
  font-weight: 700; font-size: 13px; border: 1px solid var(--line);
}
.topbar-right { display: flex; align-items: center; gap: 8px; }
.lang-toggle {
  background: var(--surface); border: 1px solid var(--line); color: var(--text);
  padding: 5px 10px; border-radius: 999px; font-family: inherit;
  font-weight: 700; font-size: 13px; cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.lang-toggle:hover { border-color: var(--primary); }
.lang-toggle:active { transform: scale(0.96); }
.icon-btn {
  display: grid; place-items: center; width: 34px; height: 34px;
  border-radius: 999px; background: var(--surface); border: 1px solid var(--line);
  color: var(--text); cursor: pointer; transition: border-color 0.15s, transform 0.1s;
}
.icon-btn .ic { width: 19px; height: 19px; }
.icon-btn:hover { border-color: var(--primary); }
.icon-btn:active { transform: scale(0.94); }
.notif-btn { position: relative; }
.notif-dot {
  position: absolute; top: 5px; right: 5px; width: 8px; height: 8px;
  border-radius: 999px; background: var(--accent);
  border: 1.5px solid var(--surface); pointer-events: none;
}

/* ---------- Notifications inbox ---------- */
.notif-list { margin-top: 8px; display: flex; flex-direction: column; gap: 10px; }
.notif-item {
  display: flex; gap: 12px; padding: 14px; border-radius: 14px;
  background: var(--surface); border: 1px solid var(--line);
}
.notif-item.unread { border-color: var(--primary); background: var(--primary-soft); }
.notif-ic { flex: 0 0 auto; color: var(--accent); display: inline-flex; }
.notif-ic .ic { width: 20px; height: 20px; }
.notif-main { min-width: 0; }
.notif-h { font-weight: 700; font-size: 15px; color: var(--text); }
.notif-p { margin-top: 3px; font-size: 14px; color: var(--muted); line-height: 1.4; }
.notif-when { margin-top: 6px; font-size: 12px; font-weight: 600; color: var(--muted); }
.notif-empty { text-align: center; padding: 56px 20px; color: var(--muted); }
.notif-empty-ic { display: inline-flex; color: var(--line); }
.notif-empty-ic .ic { width: 40px; height: 40px; }
.notif-empty-t { margin-top: 12px; font-weight: 700; font-size: 16px; color: var(--text); }
.notif-empty-s { margin-top: 4px; font-size: 14px; }

.legal { padding-bottom: 32px; }
.legal-updated { color: var(--muted); font-size: 13px; margin: -6px 0 18px; }
.legal-h { font-size: 15px; font-weight: 700; letter-spacing: -0.2px; margin: 22px 0 8px; }
.legal-p { font-size: 14px; line-height: 1.6; color: var(--text); margin: 0 0 10px; white-space: pre-line; }

/* ---------- Tappable cards ---------- */
.tappable { cursor: pointer; transition: transform 0.12s ease, border-color 0.2s, box-shadow 0.2s; }
.tappable:hover { border-color: var(--primary); }
.tappable:active { transform: scale(0.98); }
.tappable:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

/* ---------- Icons (inline SVG) ---------- */
.ic { width: 1.3em; height: 1.3em; display: inline-block; vertical-align: middle; flex-shrink: 0; }
.ic-lg { width: 1.7em; height: 1.7em; }
.quick .qico { font-size: 0; }
.quick .qico .ic { width: 22px; height: 22px; color: var(--primary-ink); }
.cat-ic { font-size: 0; }
.cat-ic .ic { width: 24px; height: 24px; color: var(--primary-ink); }
.ic-inline { display: inline-flex; vertical-align: middle; margin-right: 7px; color: var(--primary-ink); }
.ic-inline .ic { width: 18px; height: 18px; }
.review-card.due .ic-inline { color: var(--primary-ink); }
.review-title, .goal-t { display: inline-flex; align-items: center; }
.title-with-ic { display: flex; align-items: center; gap: 11px; }
.ic-tile {
  width: 34px; height: 34px; border-radius: 10px;
  background: var(--primary-soft); color: var(--primary-ink);
  display: grid; place-items: center; flex-shrink: 0;
}
.ic-tile .ic { width: 20px; height: 20px; }
.speak-btn .ic { width: 19px; height: 19px; }
.fc-speak .ic { width: 20px; height: 20px; }
.listen-prompt .ic { width: 34px; height: 34px; }
.streak-flame { display: inline-flex; }
.streak-flame .ic { width: 15px; height: 15px; color: var(--accent); }
.ob-opt-ic { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 11px; background: var(--primary-soft); }
.ob-opt-ic .ic { width: 23px; height: 23px; color: var(--primary-ink); }
.ob-emoji-ic { display: grid; place-items: center; }
.ob-emoji-ic .ic { width: 62px; height: 62px; color: var(--primary); stroke-width: 1.5; }

/* ---------- View (app-shell stage) ---------- */
.view {
  flex: 1;
  min-height: 0; /* scroll happens inside each .page, not on #app */
  position: relative;
  overflow: hidden;
}
/* Each mounted screen. Stacked absolutely so push/pop can show two at once. */
.page {
  position: absolute; inset: 0;
  padding: 20px 20px 24px;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  background: var(--bg);
  will-change: transform;
}
.page.anim { transition: transform 0.34s cubic-bezier(.32, .72, 0, 1); }
/* The page sliding the full width sits on top and casts a leading-edge shadow. */
.page.page-top { box-shadow: -14px 0 34px rgba(20, 21, 26, 0.12); }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) {
  .page.anim { transition: none; }
}

.section-title { font-size: 17px; font-weight: 700; letter-spacing: -0.3px; margin: 26px 0 14px; }
.subtle { color: var(--muted); font-size: 14px; line-height: 1.5; }

/* ---------- Home ---------- */
.hero {
  background: var(--primary);
  border-radius: var(--radius);
  padding: 22px;
  color: #fff;
  box-shadow: var(--shadow-lg);
}
.hero-hi { font-size: 26px; font-weight: 700; letter-spacing: -0.3px; }
.hero-level {
  display: inline-block; margin-top: 8px; padding: 3px 10px;
  background: rgba(255, 255, 255, 0.2); border-radius: 999px;
  font-size: 12px; font-weight: 700; letter-spacing: 0.3px;
}
.hero p { color: rgba(255, 255, 255, 0.85); margin-top: 6px; font-size: 14px; }
.progressbar {
  margin-top: 18px; height: 8px; border-radius: 999px;
  background: rgba(255, 255, 255, 0.25); overflow: hidden;
}
.progressbar > span { display: block; height: 100%; background: #fff; border-radius: 999px; transition: width 0.5s ease; }
.hero-meta { display: flex; justify-content: space-between; margin-top: 9px; font-size: 12px; color: rgba(255, 255, 255, 0.9); font-weight: 600; }

/* ---------- Review card ---------- */
.review-card {
  margin-top: 12px; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 16px; box-shadow: var(--shadow-sm);
}
.review-card.due { background: var(--primary-soft); border-color: var(--line); }
.review-top { display: flex; align-items: center; justify-content: space-between; }
.review-title { font-weight: 700; font-size: 15px; }
.review-sub { color: var(--muted); font-size: 14px; margin-bottom: 12px; }
.review-card.due .review-sub { color: var(--primary-ink); font-weight: 600; }

/* Word of the day — content card with a subtle accent tint. */
.wod-card {
  margin-top: 16px; background: var(--primary-soft);
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 18px;
}
.wod-head {
  font-size: 12px; font-weight: 700; letter-spacing: .04em;
  text-transform: uppercase; color: var(--primary-ink); margin-bottom: 10px;
}
.wod-body { display: flex; align-items: center; gap: 12px; }
.wod-text { flex: 1; min-width: 0; }
.wod-thai { font-size: 26px; font-weight: 700; line-height: 1.2; }
.wod-rom { font-size: 14px; color: var(--muted); margin-top: 2px; }
.wod-en { font-size: 15px; font-weight: 600; margin-top: 4px; }
.wod-speak {
  flex: none; width: 44px; height: 44px; border-radius: 50%;
  display: grid; place-items: center; cursor: pointer;
  background: var(--surface); border: 1px solid var(--line); color: var(--primary);
  box-shadow: var(--shadow-sm);
}
.wod-speak:active { transform: scale(.94); }

/* Progress stats — a single informational strip (not tappable), visually
   distinct from action cards: flat, no shadow, hairline dividers. */
.stats-row {
  display: grid; grid-template-columns: repeat(3, 1fr);
  margin-top: 16px; background: transparent;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  overflow: hidden;
}
.stat {
  padding: 14px 8px; text-align: center;
  border-left: 1px solid var(--line);
}
.stat:first-child { border-left: none; }
.stat .num { font-size: 20px; font-weight: 700; letter-spacing: -0.5px; }
.stat .lbl { font-size: 11px; color: var(--muted); margin-top: 3px; font-weight: 500; }

/* =====================================================================
   Learning path (home) — one linear journey, one obvious next step.
   ===================================================================== */
.learn-head { margin-bottom: 12px; text-align: center; }
.learn-hi { font-size: 26px; font-weight: 800; letter-spacing: -0.5px; }
.learn-level {
  display: inline-block; margin-top: 6px; padding: 4px 11px;
  background: var(--primary-soft); color: var(--primary-ink);
  border-radius: 999px; font-size: 12px; font-weight: 700;
}
.learn-pos {
  margin-top: 9px; font-size: 13px; font-weight: 700; color: var(--text);
}
/* Completion ring — replaces the old linear progress bar + ETA copy. */
.learn-ring {
  position: relative; width: 132px; height: 132px; margin: 14px auto 2px;
}
.learn-ring svg { width: 100%; height: 100%; display: block; }
.learn-ring .ring-track {
  fill: none; stroke: var(--surface-2); stroke-width: 10;
}
.learn-ring .ring-fill {
  fill: none; stroke: var(--primary); stroke-width: 10; stroke-linecap: round;
  transition: stroke-dashoffset .6s cubic-bezier(.4, 0, .2, 1);
}
.ring-center {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 1px;
}
.ring-pct {
  font-size: 30px; font-weight: 800; letter-spacing: -.5px; color: var(--text);
  line-height: 1;
}
.ring-lbl {
  font-size: 11px; font-weight: 700; letter-spacing: .5px; text-transform: uppercase;
  color: var(--muted);
}
.step-eyebrow {
  font-size: 11px; font-weight: 800; letter-spacing: .6px; text-transform: uppercase;
  color: var(--muted);
}
.path-step.current .step-eyebrow { color: var(--primary-ink); }
.path-step.locked .step-eyebrow { opacity: .7; }

/* Review nudge — clearly secondary to the path. */
.review-nudge {
  display: flex; align-items: center; gap: 10px; width: 100%;
  margin-bottom: 20px; padding: 12px 14px; cursor: pointer;
  background: var(--good-soft); border: 1px solid transparent;
  border-radius: var(--radius-sm); color: var(--text); font: inherit; text-align: left;
}
.review-nudge .rn-ic { display: grid; place-items: center; color: var(--good); flex: none; }
.review-nudge .rn-ic .ic { width: 20px; height: 20px; }
.review-nudge .rn-text { flex: 1; font-size: 14px; font-weight: 600; }
.review-nudge .rn-go { flex: none; color: var(--good); }
.review-nudge .rn-go .ic { width: 16px; height: 16px; }
.review-nudge:active { transform: scale(.99); }

/* The path — a single left-aligned list. Every unit is a compact row; unit 1
   sits at the top and the newest at the bottom. A measured straight rail
   (.path-trail) threads the dots. Each step's detail card stays collapsed and
   opens only when that step is tapped. */
.path {
  list-style: none; margin: 0; padding: 4px 0; position: relative;
  display: flex; flex-direction: column; align-items: stretch;
}
.path-trail {
  position: absolute; left: 0; top: 0; z-index: 0;
  overflow: visible; pointer-events: none;
}
.trail-base { fill: none; stroke: var(--line); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.trail-accent { fill: none; stroke: var(--accent); stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }

.path-step {
  position: relative; z-index: 1; width: 100%;
}

/* The tappable row: dot + label + go affordance. Generous vertical padding
   spaces the units out; unlocked rows jump straight into the unit on tap. */
.step-row {
  display: flex; align-items: center; gap: 14px; width: 100%;
  padding: 16px 0; cursor: pointer;
  background: none; border: 0; font: inherit; color: var(--text); text-align: left;
}
.path-step.locked .step-row { cursor: default; }
button.step-row:active { opacity: .6; }
.step-node {
  flex: none; width: 24px; height: 24px; border-radius: 50%;
  display: grid; place-items: center; position: relative; z-index: 2;
  background: var(--surface); border: 2px solid var(--line); color: transparent;
}
.step-node .ic { width: 13px; height: 13px; display: none; }
.step-head { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.step-title { font-size: 16px; font-weight: 700; letter-spacing: -0.2px; }
.step-sub { font-size: 13px; color: var(--muted); margin-top: 2px; }
.step-go {
  flex: none; color: var(--muted); display: grid; place-items: center;
}
.step-go .ic { width: 18px; height: 18px; transform: rotate(180deg); }

/* Done — a filled sienna waypoint with a check */
.path-step.done .step-node { background: var(--accent); border-color: var(--accent); }
.path-step.done .step-node .ic { display: block; color: #fff; }

/* Current — the focal step: sienna node with a soft ring + accent title.
   Same size as the others so the rail stays a clean straight line. */
.path-step.current .step-node {
  color: #fff;
  background: var(--accent); border-color: var(--accent);
  box-shadow: 0 0 0 5px var(--accent-soft);
}
.path-step.current .step-node .ic { display: block; }
.path-step.current .step-title { color: var(--accent); }

/* Locked — a faint hollow waypoint */
.path-step.locked .step-node .ic { display: block; color: var(--muted); }
.path-step.locked .step-title { color: var(--muted); }

/* Premium-gated — a sparkles waypoint hinting at the paywall. The current gated
   unit keeps the sienna focal node; future gated units stay muted like locked. */
.path-step.current.premium .step-node .ic,
.path-step.locked.premium .step-node .ic { display: block; }
.path-step.current.premium .step-sub { color: var(--accent); font-weight: 600; }
.path-step.locked.premium .step-go .ic,
.path-step.current.premium .step-go .ic { transform: none; color: var(--accent); }

.path-wrap { display: flex; flex-direction: column; align-items: stretch; }

/* All-units-complete banner */
.all-done {
  text-align: center; background: var(--primary-soft);
  border-radius: var(--radius); padding: 22px 18px; margin-bottom: 22px;
}
.all-done .ad-ic {
  width: 48px; height: 48px; margin: 0 auto 6px; border-radius: 50%;
  display: grid; place-items: center; background: var(--accent-soft); color: var(--accent);
}
.all-done .ad-ic .ic { width: 24px; height: 24px; }
.all-done .ad-title { font-size: 18px; font-weight: 800; margin-top: 6px; }
.all-done .ad-sub { font-size: 14px; color: var(--primary-ink); margin-top: 4px; }

/* =====================================================================
   Practice hub — the optional "explore" screen.
   ===================================================================== */
.practice-list { display: flex; flex-direction: column; gap: 12px; }
.practice-row {
  display: flex; align-items: center; gap: 14px; width: 100%;
  padding: 16px; cursor: pointer; text-align: left; font: inherit; color: var(--text);
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow-sm);
}
.practice-row:active { transform: scale(.99); }
.practice-row.dim { opacity: .55; }
.pr-ic {
  flex: none; width: 44px; height: 44px; border-radius: 12px;
  display: grid; place-items: center;
  background: var(--primary-soft); color: var(--primary);
}
.pr-ic .ic { width: 22px; height: 22px; }
.pr-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.pr-title { font-size: 16px; font-weight: 700; }
.pr-sub { font-size: 13px; color: var(--muted); margin-top: 2px; }

/* Daily-review analysis: one graded read per metric, then a way into SRS. */
.rv-metrics { display: flex; flex-direction: column; gap: 12px; margin-bottom: 22px; }
.rv-metric {
  display: flex; gap: 12px; align-items: flex-start;
  background: var(--card, #fff); border: 1px solid var(--line, #e7e0d2);
  border-radius: 14px; padding: 14px 16px;
}
.rv-dot { flex: none; width: 10px; height: 10px; border-radius: 50%; margin-top: 6px; }
.rv-dot.good { background: #2e7d55; }
.rv-dot.mid { background: #c78a2b; }
.rv-dot.bad { background: #c0392b; }
.rv-m-body { flex: 1; min-width: 0; }
.rv-m-top { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.rv-m-label { font-size: 15px; font-weight: 700; }
.rv-m-val { font-size: 14px; font-weight: 600; color: var(--muted); white-space: nowrap; }
.rv-m-sentence { font-size: 13.5px; line-height: 1.45; color: var(--text); margin-top: 3px; }
.rv-empty { text-align: center; padding: 24px 12px 4px; }
.rv-empty-ic {
  width: 52px; height: 52px; margin: 0 auto 12px; border-radius: 14px;
  display: grid; place-items: center; background: var(--primary-soft); color: var(--primary);
}
.rv-empty-ic .ic { width: 26px; height: 26px; }
.rv-empty-t { font-size: 17px; font-weight: 700; }
.rv-none { text-align: center; font-size: 13.5px; color: var(--muted); padding: 10px 0; }
.pr-go { flex: none; color: var(--muted); }
.pr-go .ic { width: 16px; height: 16px; }

/* Duel — coming-soon placeholder */
.duel-soon { text-align: center; }
.duel-hero { padding: 16px 8px 4px; }
.duel-badge {
  width: 64px; height: 64px; margin: 6px auto 14px; border-radius: 18px;
  display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent);
}
.duel-badge .ic { width: 32px; height: 32px; }
.duel-tag {
  display: inline-block; font-size: 12px; font-weight: 700; letter-spacing: .04em;
  text-transform: uppercase; color: var(--accent);
  background: var(--accent-soft); padding: 4px 10px; border-radius: 999px;
}
.duel-title { font-size: 24px; font-weight: 700; margin: 12px 0 6px; }
.duel-sub { font-size: 14px; color: var(--muted); max-width: 30ch; margin: 0 auto; line-height: 1.5; }
.duel-modes { display: flex; flex-direction: column; gap: 12px; margin: 26px 0 18px; text-align: left; }
.duel-mode {
  display: flex; align-items: center; gap: 14px; padding: 16px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow-sm); opacity: .82;
}
.dm-ic {
  flex: none; width: 44px; height: 44px; border-radius: 12px;
  display: grid; place-items: center; background: var(--primary-soft); color: var(--primary);
}
.dm-ic .ic { width: 22px; height: 22px; }
.dm-txt { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.dm-txt b { font-size: 16px; font-weight: 700; }
.dm-txt small { font-size: 13px; color: var(--muted); margin-top: 2px; }
.duel-foot { font-size: 13px; margin-top: 6px; }

/* "This or that?" preference mini-game */
.pref-count { text-align: center; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 6px; }
.pref-prompt { text-align: center; font-size: 18px; font-weight: 700; color: var(--text); margin-bottom: 22px; }
.pref-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.pref-card {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px;
  min-height: 138px; padding: 22px 14px; font: inherit; cursor: pointer;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow-sm);
  transition: transform 0.1s, border-color 0.15s;
}
.pref-card:active { transform: scale(0.97); }
.pref-card:disabled { cursor: default; }
.pref-card.chosen { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent) inset; }
.pref-word { font-size: 27px; }
.pref-mean { font-size: 14px; font-weight: 600; color: var(--muted); }
.pref-card.chosen .pref-mean { color: var(--accent); }
/* Reserve the Next button's height so revealing it doesn't nudge the layout. */
.pref-foot { margin-top: 22px; min-height: 52px; }

/* =====================================================================
   Tone-trace — the "say it, trace your tone" crown-jewel mechanic.
   ===================================================================== */
.u0-tone { text-align: center; }
.tone-word { display: flex; align-items: center; justify-content: center; gap: 10px; margin-top: 4px; }
.tone-rt .rt-th { font-size: 30px; }
.tone-listen.small { width: 34px; height: 34px; flex: none; margin: 0; }
.tone-mean { color: var(--muted); font-size: 15px; font-weight: 600; margin-top: 2px; }
.tone-name {
  display: inline-flex; align-items: center; gap: 6px; margin: 8px auto 0;
  font-size: 13px; font-weight: 700; color: var(--accent);
  background: var(--accent-soft); padding: 4px 12px; border-radius: 999px;
}
.tone-arrow { font-size: 15px; line-height: 1; }
.tone-chart {
  position: relative; margin: 16px auto 6px; max-width: 340px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 6px; box-shadow: var(--shadow-sm);
}
.tone-svg { display: block; width: 100%; height: 130px; }
.tone-grid { stroke: var(--line); stroke-width: 1; stroke-dasharray: 3 4; }
.tone-target {
  fill: none; stroke: var(--accent); stroke-width: 3; opacity: .34;
  stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 2 7;
}
.tone-live {
  fill: none; stroke: var(--accent); stroke-width: 2; opacity: .45;
  stroke-linecap: round; stroke-linejoin: round;
}
.tone-user {
  fill: none; stroke-width: 3.5; stroke-linecap: round; stroke-linejoin: round;
  stroke: var(--muted);
  transition: stroke .2s;
}
.tone-user.tone-great { stroke: var(--good); }
.tone-user.tone-close { stroke: var(--accent); }
.tone-user.tone-off   { stroke: var(--bad); }
.tone-axis {
  position: absolute; right: 10px; font-size: 10px; font-weight: 700;
  letter-spacing: .04em; text-transform: uppercase; color: var(--muted); opacity: .6;
}
.tone-axis-hi { top: 8px; }
.tone-axis-lo { bottom: 8px; }
.tone-status { min-height: 20px; margin-top: 4px; font-size: 14px; font-weight: 600; color: var(--muted); }
.tone-status.tone-great { color: var(--good); }
.tone-status.tone-close { color: var(--accent); }
.tone-status.tone-off   { color: var(--bad); }
.tone-pct { font-size: 16px; }
.tone-rec {
  margin: 14px auto 0; display: inline-flex; align-items: center; gap: 9px;
  padding: 13px 26px; border-radius: 999px; cursor: pointer;
  background: var(--accent); color: #fff; border: none;
  font: inherit; font-weight: 700; font-size: 16px;
  box-shadow: var(--shadow); transition: transform .12s, background .2s;
}
.tone-rec:active { transform: scale(.96); }
.tone-rec:disabled { opacity: .55; cursor: default; }
.tone-rec .ic { width: 20px; height: 20px; }
.tone-rec.recording { background: var(--bad); animation: tone-pulse 1s ease-in-out infinite; }
@keyframes tone-pulse { 0%, 100% { box-shadow: 0 0 0 0 var(--bad-soft); } 50% { box-shadow: 0 0 0 10px transparent; } }
.tone-actions { display: flex; gap: 10px; }
.tone-actions .btn { flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 7px; }
.tone-actions .tone-retry .ic { width: 17px; height: 17px; }

/* Recap — the "you can now do this" payoff card (motivation beat). */
.recap-card { text-align: center; padding-top: 8px; }
.recap-ic { color: var(--accent); display: grid; place-items: center; margin: 0 auto 6px; }
.recap-ic .ic { width: 42px; height: 42px; }
.recap-title { font-family: var(--font-display, "Fraunces", serif); font-size: 22px; font-weight: 600; margin-bottom: 16px; }
.recap-list { display: flex; flex-direction: column; gap: 10px; text-align: left; }
.recap-row {
  display: flex; align-items: center; gap: 12px; width: 100%;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 12px 14px; cursor: pointer;
  font: inherit; color: var(--text); box-shadow: var(--shadow-sm);
  transition: transform .12s, border-color .2s;
}
.recap-row:active { transform: scale(.98); }
.recap-row:hover { border-color: var(--accent); }
.recap-check {
  flex: none; width: 26px; height: 26px; border-radius: 999px;
  background: var(--good); color: #fff; display: grid; place-items: center;
}
.recap-check .ic { width: 16px; height: 16px; }
.recap-text { flex: 1; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.recap-label { font-size: 14px; font-weight: 600; }
.recap-rt .rt-th { font-size: 17px; }
.recap-rt .rt-rom { font-size: 12px; color: var(--muted); }
.recap-say { flex: none; color: var(--accent); display: grid; place-items: center; }
.recap-say .ic { width: 20px; height: 20px; }

/* =====================================================================
   Co-op duel — "play together" entry (home) + pass-and-play screens.
   Warm accent skin so the social mode reads distinct from the ink path,
   without becoming a launch gate.
   ===================================================================== */
.coop-entry {
  display: flex; align-items: center; gap: 13px; width: 100%;
  margin-bottom: 14px; padding: 12px 14px; cursor: pointer; text-align: left;
  font: inherit; color: var(--text);
  background: var(--accent-soft); border: 1px solid var(--accent);
  border-radius: var(--radius); box-shadow: var(--shadow-sm);
}
.coop-entry:active { transform: scale(.99); }
.coop-entry-ic {
  flex: none; width: 40px; height: 40px; border-radius: 11px;
  display: grid; place-items: center; background: var(--accent); color: #fff;
}
.coop-entry-ic .ic { width: 24px; height: 24px; }
.coop-entry-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.coop-entry-title { font-size: 16px; font-weight: 700; }
.coop-entry-sub { font-size: 13px; color: var(--muted); margin-top: 2px; }
.coop-entry-go { flex: none; color: var(--accent); }
.coop-entry-go .ic { width: 16px; height: 16px; }

/* Deck picker */
.coop-back { margin-bottom: 6px; }
.coop-head { text-align: center; margin-bottom: 20px; }
.coop-head-ic {
  display: inline-grid; place-items: center; width: 54px; height: 54px;
  border-radius: 14px; background: var(--accent-soft); color: var(--accent); margin-bottom: 8px;
}
.coop-head-ic .ic { width: 28px; height: 28px; }
.coop-head .subtle { margin-top: 4px; }
.coop-decks { display: flex; flex-direction: column; gap: 12px; }
.coop-deck {
  display: flex; align-items: center; gap: 14px; width: 100%; padding: 15px;
  cursor: pointer; text-align: left; font: inherit; color: var(--text);
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow-sm);
}
.coop-deck:active { transform: scale(.99); }
.coop-deck-ic {
  flex: none; width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center;
  background: var(--primary-soft); color: var(--primary);
}
.coop-deck-ic .ic { width: 22px; height: 22px; }
.coop-deck-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.coop-deck-t { font-size: 16px; font-weight: 700; }
.coop-deck-s { font-size: 13px; color: var(--muted); margin-top: 2px; }
.coop-deck-go { flex: none; color: var(--muted); }
.coop-deck-go .ic { width: 16px; height: 16px; }

/* Turn intro + handoff */
.coop-intro {
  text-align: center; padding: 40px 16px 20px; min-height: 58vh;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.coop-turn-badge {
  font-size: 12px; font-weight: 700; letter-spacing: .6px; text-transform: uppercase;
  color: var(--accent); background: var(--accent-soft); padding: 5px 12px; border-radius: 999px;
}
.coop-turn-name { font-family: var(--font-display); font-size: 32px; font-weight: 600; margin: 14px 0 6px; }
.coop-turn-sub { font-size: 15px; color: var(--muted); max-width: 290px; margin: 0 auto 26px; }
.coop-intro .btn { max-width: 320px; }
.coop-hand-ic {
  width: 60px; height: 60px; border-radius: 50%; display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent); margin-bottom: 4px;
}
.coop-hand-ic .ic { width: 30px; height: 30px; }

/* Play screen (reuses .quiz-q / .quiz-opts / .opt) */
.coop-scorebar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.coop-who { font-family: var(--font-display); font-size: 17px; font-weight: 600; }
.coop-qn { font-size: 13px; font-weight: 600; color: var(--muted); }

/* Result + shareable card */
.coop-result { text-align: center; padding: 28px 18px; }
.coop-result-ic {
  width: 64px; height: 64px; border-radius: 50%; display: grid; place-items: center;
  margin: 0 auto 10px; background: var(--accent-soft); color: var(--accent);
}
.coop-result-ic .ic { width: 34px; height: 34px; }
.coop-result-headline { font-family: var(--font-display); font-size: 24px; font-weight: 600; margin-bottom: 20px; }
.coop-scores { display: flex; align-items: center; justify-content: center; gap: 12px; margin-bottom: 16px; }
.coop-score {
  flex: 1; max-width: 140px; padding: 16px 10px; border-radius: var(--radius);
  border: 1px solid var(--line); background: var(--surface);
}
.coop-score.win { border-color: var(--accent); background: var(--accent-soft); }
.coop-score-name { display: block; font-size: 13px; font-weight: 600; color: var(--muted); }
.coop-score.win .coop-score-name { color: var(--accent); }
.coop-score-num { display: block; font-family: var(--font-display); font-size: 36px; font-weight: 600; margin-top: 4px; }
.coop-score-num small { font-size: 16px; color: var(--muted); font-weight: 600; }
.coop-vs { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; }
.coop-result-deck { font-size: 13px; color: var(--muted); margin-bottom: 22px; }
.coop-otherdeck {
  display: block; width: 100%; margin-top: 14px; background: none; border: none;
  color: var(--muted); font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; padding: 6px;
}

/* Async duel: name input, invite / waiting, loading, badge */
.coop-name-input {
  width: 100%; box-sizing: border-box; margin-bottom: 16px; padding: 13px 15px;
  font: inherit; font-size: 15px; color: var(--text);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
}
.coop-name-input:focus { outline: none; border-color: var(--accent); }
.coop-intro .coop-name-input { max-width: 320px; margin-top: 4px; }
.coop-invite-score {
  font-family: var(--font-display); font-size: 30px; font-weight: 600; margin-bottom: 8px;
}
.coop-invite-sub { font-size: 14px; color: var(--muted); max-width: 320px; margin: 0 auto 22px; }
.coop-result .coop-invite-share, .coop-result .coop-check { max-width: 340px; margin-left: auto; margin-right: auto; }
.coop-badge {
  display: inline-flex; align-items: center; gap: 7px; margin-bottom: 18px;
  padding: 7px 14px; border-radius: 999px; background: var(--accent-soft); color: var(--accent);
  font-size: 13px; font-weight: 600;
}
.coop-badge .ic { width: 15px; height: 15px; }
.coop-loading { gap: 6px; }
.coop-spinner {
  width: 34px; height: 34px; border-radius: 50%; margin-bottom: 14px;
  border: 3px solid var(--line); border-top-color: var(--accent);
  animation: coop-spin .8s linear infinite;
}
@keyframes coop-spin { to { transform: rotate(360deg); } }

.crumb { font-size: 12.5px; font-weight: 600; color: var(--muted); margin-bottom: 10px; display: flex; flex-wrap: wrap; align-items: center; }
.crumb-sep { opacity: .55; margin: 0 5px; }
.crumb-part:last-child { color: var(--accent); }

.quick-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.quick {
  text-align: left; cursor: pointer; color: var(--text); font: inherit;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 16px;
  display: flex; flex-direction: column; gap: 6px;
  box-shadow: var(--shadow-sm);
  transition: transform 0.12s ease, border-color 0.2s;
}
.quick:active { transform: scale(0.97); }
.quick .qico {
  width: 40px; height: 40px; border-radius: 11px;
  background: var(--primary-soft); display: grid; place-items: center;
  font-size: 21px; margin-bottom: 4px;
}
.quick .qtitle { font-weight: 700; font-size: 15px; }
.quick .qsub { font-size: 12px; color: var(--muted); }

/* ---------- Lesson list ---------- */
.cat-list { display: flex; flex-direction: column; gap: 10px; }
.cat {
  display: flex; align-items: center; gap: 14px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 13px 15px; cursor: pointer;
  box-shadow: var(--shadow-sm); transition: transform 0.12s ease;
}
.cat:active { transform: scale(0.985); }
.cat-ic {
  width: 46px; height: 46px; border-radius: 13px;
  background: var(--primary-soft);
  display: grid; place-items: center; font-size: 23px; flex-shrink: 0;
}
.cat-body { flex: 1; min-width: 0; }
.cat-body .t { font-weight: 700; font-size: 15px; }
.cat-body .s { font-size: 12px; color: var(--muted); margin-top: 2px; }
.cat-progress { height: 5px; border-radius: 999px; background: var(--surface-2); margin-top: 9px; overflow: hidden; }
.cat-progress > span { display: block; height: 100%; border-radius: 999px; background: var(--primary); transition: width 0.4s; }
.cat .chev { color: #c7c9d2; font-size: 22px; font-weight: 400; }

/* ---------- Back button ---------- */
.back-btn {
  background: var(--surface); border: 1px solid var(--line);
  color: var(--text); font: inherit; font-weight: 600; font-size: 14px;
  padding: 8px 14px; border-radius: 999px; cursor: pointer;
  margin-bottom: 14px; box-shadow: var(--shadow-sm);
}
.back-btn:active { transform: scale(0.96); }

/* ---------- Word list ---------- */
.word-row {
  display: flex; align-items: center; gap: 12px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 13px 15px; margin-bottom: 9px;
  box-shadow: var(--shadow-sm);
}
.word-main { flex: 1; min-width: 0; }
.word-thai { font-size: 23px; font-weight: 600; letter-spacing: -0.2px; }
.word-rom { color: var(--primary-ink); font-size: 13px; margin-top: 2px; font-weight: 600; }
.word-tr { color: var(--muted); font-size: 14px; margin-top: 3px; }
.speak-btn {
  width: 42px; height: 42px; flex-shrink: 0;
  border-radius: 50%; border: none; cursor: pointer;
  background: var(--primary-soft); color: var(--primary-ink);
  font-size: 17px; display: grid; place-items: center; transition: transform 0.1s;
}
.speak-btn:active { transform: scale(0.9); }
.word-actions { flex-shrink: 0; display: flex; align-items: center; gap: 8px; }
.asklocal-btn {
  width: 42px; height: 42px; flex-shrink: 0;
  border-radius: 50%; border: 1px solid var(--line); cursor: pointer;
  background: var(--surface); color: var(--muted);
  display: grid; place-items: center; transition: transform 0.1s;
}
.asklocal-btn .ic { width: 19px; height: 19px; }
.asklocal-btn:active { transform: scale(0.9); }

/* ---------- Modal (ask-a-local card) ---------- */
.modal {
  position: fixed; inset: 0; z-index: 60; display: grid; place-items: center;
  padding: 22px; background: rgba(20, 14, 8, 0.42);
  opacity: 0; transition: opacity 0.2s ease;
}
.modal.show { opacity: 1; }
.modal-card {
  position: relative; width: 100%; max-width: 340px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow-lg, 0 18px 50px rgba(0,0,0,.25));
  padding: 26px 22px 22px; text-align: center;
  transform: translateY(10px) scale(0.98); transition: transform 0.22s ease;
}
.modal.show .modal-card { transform: none; }
.modal-close {
  position: absolute; top: 10px; right: 10px; width: 34px; height: 34px;
  border: none; background: none; color: var(--muted); cursor: pointer;
  display: grid; place-items: center; border-radius: 50%;
}
.modal-close .ic { width: 18px; height: 18px; }
.asklocal-brand {
  display: inline-flex; align-items: center; gap: 6px; color: var(--accent);
  font-weight: 700; font-size: 13px; letter-spacing: .2px; margin-bottom: 16px;
}
.asklocal-brand .ic { width: 17px; height: 17px; }
.asklocal-request {
  font-size: 21px; line-height: 1.5; font-weight: 500; color: var(--text);
  padding-bottom: 18px; margin-bottom: 18px; border-bottom: 1px solid var(--line);
}
.asklocal-word { font-size: 54px; font-weight: 600; line-height: 1.1; }
.asklocal-rom { color: var(--primary-ink); font-size: 15px; font-weight: 600; margin-top: 8px; }
.asklocal-hint {
  font-size: 13px; line-height: 1.4; color: var(--muted);
  margin: 18px auto 20px; max-width: 270px;
}
.asklocal-listen { display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.asklocal-listen .ic { width: 17px; height: 17px; }

/* Tap-any-Thai word info modal */
.wordinfo-card { padding-top: 30px; }
.wi-thai {
  display: inline-block; border: none; background: none; cursor: pointer;
  font-size: 46px; font-weight: 600; line-height: 1.1; color: var(--text);
  padding: 2px 6px; border-radius: 10px;
}
.wi-thai:active { background: var(--line); }
.wi-rom { color: var(--accent); font-size: 16px; font-weight: 600; margin-top: 6px; }
.wi-mean { font-size: 18px; font-weight: 500; color: var(--text); margin-top: 10px; }
.wi-ex {
  margin: 16px auto 4px; padding: 12px 14px; max-width: 280px;
  background: var(--line-soft, rgba(156,74,47,0.06)); border-radius: 12px;
  display: flex; flex-direction: column; gap: 4px;
}
.wi-ex-label {
  font-size: 11px; font-weight: 700; letter-spacing: .4px; text-transform: uppercase;
  color: var(--muted);
}
.wi-ex-th { font-size: 20px; font-weight: 600; color: var(--text); }
.wi-ex-en { font-size: 14px; color: var(--muted); }
.wi-note { font-size: 14px; line-height: 1.45; color: var(--muted); margin: 14px auto 4px; max-width: 280px; }
.wi-listen { display: inline-flex; align-items: center; justify-content: center; gap: 8px; margin-top: 18px; }
.wi-listen .ic { width: 17px; height: 17px; }

/* ---------- Flashcards ---------- */
.fc-wrap { display: flex; flex-direction: column; align-items: center; gap: 16px; }
.fc-top { width: 100%; display: flex; align-items: center; justify-content: space-between; }
.fc-top .back-btn { margin-bottom: 0; }
.fc-count { color: var(--muted); font-weight: 600; font-size: 14px; }
.flashcard { width: 100%; aspect-ratio: 3 / 4; max-height: 60vh; perspective: 1400px; cursor: pointer; }
.fc-inner {
  position: relative; width: 100%; height: 100%;
  transition: transform 0.55s cubic-bezier(.2, .8, .2, 1); transform-style: preserve-3d;
}
.flashcard.flipped .fc-inner { transform: rotateY(180deg); }
.fc-face {
  position: absolute; inset: 0; backface-visibility: hidden;
  border-radius: var(--radius);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 24px; text-align: center;
}
.fc-front { background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); }
.fc-back { background: var(--primary); color: #fff; transform: rotateY(180deg); box-shadow: var(--shadow-lg); }
.fc-front .big { font-size: 56px; font-weight: 600; line-height: 1.1; }
.fc-front .hint { margin-top: 18px; color: var(--muted); font-size: 13px; }
.fc-back .rom { font-size: 22px; font-weight: 600; opacity: 0.9; }
.fc-back .mean { font-size: 30px; font-weight: 700; margin-top: 6px; letter-spacing: -0.4px; }
.fc-tag { position: absolute; top: 16px; left: 18px; font-size: 12px; font-weight: 600; color: var(--muted); }
.fc-speak {
  position: absolute; top: 12px; right: 12px; width: 40px; height: 40px;
  border-radius: 50%; border: none; background: var(--primary-soft); color: var(--primary-ink);
  font-size: 17px; cursor: pointer;
}

.fc-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; width: 100%; }
.btn {
  border: none; cursor: pointer; font: inherit; font-weight: 700; font-size: 15px;
  padding: 15px; border-radius: var(--radius-sm); transition: transform 0.1s;
}
.btn:active { transform: scale(0.97); }
.btn-ghost { background: var(--surface); border: 1px solid var(--line); color: var(--text); box-shadow: var(--shadow-sm); }
.btn-primary { background: var(--primary); color: #fff; box-shadow: var(--shadow-sm); }
.btn-block { width: 100%; }

/* ---------- Quiz ---------- */
.quiz-progress { height: 6px; border-radius: 999px; background: var(--surface-2); overflow: hidden; margin-bottom: 22px; }
.quiz-progress > span { display: block; height: 100%; background: var(--primary); transition: width 0.3s; }
.quiz-q {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 28px 20px; text-align: center; box-shadow: var(--shadow-sm);
}
.quiz-q .label { color: var(--muted); font-size: 13px; font-weight: 600; }
.quiz-q .prompt { font-size: 38px; font-weight: 600; margin-top: 10px; letter-spacing: -0.3px; }
.quiz-q .prompt.small { font-size: 26px; }
.quiz-opts { display: flex; flex-direction: column; gap: 10px; margin-top: 16px; }
.opt {
  text-align: left; font: inherit; font-weight: 600; font-size: 16px;
  padding: 16px 18px; border-radius: var(--radius-sm); cursor: pointer;
  background: var(--surface); color: var(--text);
  border: 1.5px solid var(--line); box-shadow: var(--shadow-sm);
  transition: transform 0.1s, border-color 0.2s, background 0.2s;
}
.opt:active { transform: scale(0.985); }
.opt.correct { border-color: var(--good); background: var(--good-soft); color: var(--good); }
.opt.wrong { border-color: var(--bad); background: var(--bad-soft); color: var(--bad); }
.opt:disabled { cursor: default; }

.result-card { text-align: center; padding: 36px 20px; width: 100%; }
.result-ic {
  width: 64px; height: 64px; margin: 0 auto 8px; border-radius: 50%;
  display: grid; place-items: center; background: var(--accent-soft); color: var(--accent);
}
.result-ic .ic { width: 32px; height: 32px; }
.result-score { font-size: 40px; font-weight: 800; margin: 10px 0 4px; letter-spacing: -1px; }
.result-sub { color: var(--muted); margin-bottom: 24px; }
.result-sub:has(+ .result-note) { margin-bottom: 8px; }
.result-note {
  font-size: 13.5px; line-height: 1.5; color: var(--text);
  max-width: 30ch; margin: 0 auto 22px;
}
.result-note.pref-reward {
  display: inline-flex; align-items: center; gap: 7px;
  background: var(--accent-soft); color: var(--accent);
  font-weight: 600; padding: 8px 14px; border-radius: 999px;
  max-width: none; margin: 2px auto 18px;
}
.result-note.pref-reward .pr-reward-ic { display: inline-flex; }
.result-note.pref-reward .pr-reward-ic svg { width: 16px; height: 16px; }
/* Net authority change this speed run — big + clearly colored so a gain reads as
   a win and a loss as a sting (this run vs the unit's previous run). */
.result-sub:has(+ .result-delta) { margin-bottom: 10px; }
.result-delta {
  font-family: "Fraunces", Georgia, serif; font-weight: 800;
  font-size: 30px; letter-spacing: -.5px; margin: 0 0 18px; line-height: 1;
}
.result-delta.gain { color: #2e7d55; }
.result-delta.loss { color: #c0392b; }
.result-delta.flat { color: var(--muted); }
/* Speed-run authority total — the running score that later sits by the avatar. */
.result-authority {
  display: inline-flex; align-items: center; gap: 7px;
  margin: 0 auto 22px; padding: 7px 14px; border-radius: 999px;
  background: var(--surface-2); color: var(--text);
  font-weight: 700; font-size: 14px; letter-spacing: -.2px;
}
.result-authority .ra-ic { display: inline-flex; color: var(--accent); }
.result-authority .ra-ic svg { width: 16px; height: 16px; }
/* Speed CTA on the completion card: flame glyph sits inline before the label. */
[data-speed] .speed-ic { display: inline-flex; vertical-align: -3px; margin-right: 7px; color: var(--accent); }
[data-speed] .speed-ic svg { width: 16px; height: 16px; }
/* A checkpoint/level-test node reads as a review beat, not a fresh unit: its
   eyebrow picks up the accent so the rhythm (learn → review) is visible. */
.path-step.checkpoint .step-eyebrow,
.path-step.capstone .step-eyebrow { color: var(--accent); }

/* ---------- Word notes / examples ---------- */
.w-note, .w-ex, .fc-note, .fc-ex {
  font-size: 12.5px; line-height: 1.45; margin-top: 6px; color: var(--muted);
}
.w-note, .w-ex { padding: 7px 10px; background: var(--surface-2); border-radius: 9px; }
.w-note b, .w-ex b { color: var(--text); font-weight: 700; }
.fc-extra { margin-top: 16px; max-width: 100%; }
.fc-note, .fc-ex { color: rgba(255, 255, 255, 0.9); }
.fc-note b, .fc-ex b { color: #fff; }

/* ---------- SRS grade buttons ---------- */
.srs-actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; width: 100%; }
.srs-btn {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  border: 1.5px solid var(--line); background: var(--surface); color: var(--text);
  font: inherit; cursor: pointer; padding: 12px 8px; border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm); transition: transform 0.1s;
}
.srs-btn:active { transform: scale(0.96); }
.srs-btn .g-t { font-weight: 700; font-size: 15px; }
.srs-btn .g-h { font-size: 11px; color: var(--muted); }
.srs-btn.again { border-color: var(--bad); background: var(--bad-soft); color: var(--bad); }
.srs-btn.again .g-h { color: var(--bad); }
.srs-btn.good { border-color: var(--good); background: var(--good-soft); color: var(--good); }
.srs-btn.good .g-h { color: var(--good); }

/* ---------- Quiz: listen prompt + explanation ---------- */
.listen-prompt {
  width: 76px; height: 76px; border-radius: 50%; border: none; cursor: pointer;
  background: var(--primary); color: #fff; font-size: 32px; margin: 6px auto 0;
  display: grid; place-items: center; box-shadow: var(--shadow-lg);
}
.listen-prompt:active { transform: scale(0.94); }
.listen-hint { color: var(--muted); font-size: 12px; margin-top: 10px; }

.quiz-explain {
  margin-top: 16px; padding: 16px; border-radius: var(--radius-sm);
  border: 1px solid var(--line); background: var(--surface); box-shadow: var(--shadow-sm);
  animation: fade 0.25s ease;
}
.quiz-explain.ok { border-color: var(--good); background: var(--good-soft); }
.quiz-explain.no { border-color: var(--bad); background: var(--bad-soft); }
.qx-word { font-size: 26px; font-weight: 600; }
.qx-word .qx-rom { font-size: 15px; color: var(--primary-ink); font-weight: 600; margin-left: 6px; }
.qx-mean { font-weight: 600; margin-top: 4px; }
.qx-note { font-size: 13px; color: var(--muted); margin-top: 8px; line-height: 1.45; }
.qx-next { margin-top: 14px; }

/* ---------- Alphabet ---------- */
/* Optional "Learn to read" track at the top of the Alphabet tab. */
.alpha-learn { margin-bottom: 26px; }
.alpha-learn-head { font-size: 13px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--accent); margin-bottom: 6px; }
.alpha-learn-sub { margin-bottom: 14px; }
.alpha-lesson {
  width: 100%; display: flex; align-items: center; gap: 14px; text-align: left;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; margin-bottom: 10px; cursor: pointer; transition: transform 0.1s;
}
.alpha-lesson:active { transform: scale(0.99); }
.alpha-lesson.done { background: var(--good-soft); border-color: var(--good-soft); }
.al-ic { flex: none; width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent); }
.alpha-lesson.done .al-ic { background: var(--surface); color: var(--good); }
.al-ic .ic { width: 20px; height: 20px; }
.al-txt { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.al-txt b { font-size: 16px; font-weight: 700; color: var(--text); }
.al-txt small { font-size: 13px; color: var(--muted); }
.al-go { flex: none; color: var(--accent); }
.al-go .ic { width: 18px; height: 18px; }
.alpha-chart-head { font-size: 17px; font-weight: 700; margin: 0 0 6px; color: var(--text); }
.alpha-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.alpha {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 14px 8px; text-align: center; cursor: pointer;
  box-shadow: var(--shadow-sm); transition: transform 0.1s;
}
.alpha:active { transform: scale(0.95); }
.alpha .ch { font-size: 38px; font-weight: 600; line-height: 1; }
.alpha .nm { font-size: 11px; color: var(--muted); margin-top: 8px; line-height: 1.35; }
.pill { display: inline-block; font-size: 10px; font-weight: 700; padding: 3px 9px; border-radius: 999px; margin-top: 8px; }
.pill.mid { background: var(--primary-soft); color: var(--primary-ink); }
.pill.high { background: var(--accent-soft); color: var(--accent); }
.pill.low { background: var(--good-soft); color: var(--good); }
.legend { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.legend .pill { margin-top: 0; }

/* ---------- Bottom nav ---------- */
.bottomnav {
  flex-shrink: 0;
  height: calc(var(--nav-h) + var(--safe-b)); padding-bottom: var(--safe-b);
  display: flex; z-index: 30;
  background: rgba(251, 249, 243, 0.9); backdrop-filter: blur(16px);
  border-top: 1px solid var(--line);
}
.navitem {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; font-size: 11px; font-weight: 600; color: var(--muted);
  cursor: pointer; text-decoration: none; transition: color 0.2s;
}
.navitem .ico { display: grid; place-items: center; opacity: 0.5; transition: opacity 0.2s, transform 0.2s; }
.navitem .ico .ic { width: 23px; height: 23px; }
.navitem.active { color: var(--primary-ink); }
.navitem.active .ico { opacity: 1; transform: translateY(-1px); }

/* ---------- Toast ---------- */
.toast {
  position: fixed; bottom: calc(var(--nav-h) + var(--safe-b) + 16px); left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--text); color: #fff;
  padding: 11px 18px; border-radius: 999px; font-weight: 600; font-size: 14px;
  box-shadow: var(--shadow-lg); opacity: 0; pointer-events: none;
  transition: all 0.3s; z-index: 50; max-width: 88%; text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- Daily goal card ---------- */
.goal-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 14px;
}
.goal-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.goal-t { font-size: 15px; font-weight: 700; }
.goal-n { font-size: 13px; font-weight: 600; color: var(--muted); }
.goal-bar { height: 8px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.goal-bar > span {
  display: block; height: 100%; border-radius: 999px;
  background: var(--primary);
  transition: width 0.4s ease;
}
.goal-card.done { border-color: var(--good-soft); background: var(--good-soft); }
.goal-card.done .goal-n { color: var(--good); }
.goal-card.done .goal-bar > span { background: var(--good); }

/* ---------- Today card (primary action) ---------- */
.today-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 22px;
}
.today-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.today-title { display: inline-flex; align-items: center; font-size: 15px; font-weight: 700; }
.today-n { font-size: 13px; font-weight: 600; color: var(--muted); }
.today-bar { height: 8px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.today-bar > span {
  display: block; height: 100%; border-radius: 999px;
  background: var(--primary);
  transition: width 0.4s ease;
}
.today-note { font-size: 13px; font-weight: 600; color: var(--primary-ink); margin-top: 11px; }
.today-cta { margin-top: 15px; }
.today-card.done .today-n { color: var(--good); }
.today-card.done .today-bar > span { background: var(--good); }

/* ---------- Explore shortcuts ---------- */
.explore-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.explore-grid .quick {
  align-items: center; text-align: center; gap: 10px; padding: 16px 8px;
}
.explore-grid .qico { margin-bottom: 0; }
.explore-grid .qtitle { font-size: 13px; }

/* ---------- Onboarding ---------- */
.onboarding {
  position: fixed; inset: 0; z-index: 100;
  background: var(--bg);
  display: flex; flex-direction: column;
}

/* Persistent header: back · progress bar · lang. Never re-rendered between steps. */
.ob-header {
  flex-shrink: 0;
  display: flex; align-items: center; gap: 14px;
  padding: calc(14px + env(safe-area-inset-top, 0px)) 20px 12px;
  max-width: 460px; width: 100%; margin: 0 auto;
}
.ob-back {
  flex-shrink: 0;
  width: 34px; height: 34px; border-radius: 999px;
  display: grid; place-items: center;
  background: none; border: none; color: var(--text); cursor: pointer;
  opacity: 0; visibility: hidden; transform: translateX(-4px);
  transition: opacity 0.2s, transform 0.2s;
}
.ob-back.show { opacity: 1; visibility: visible; transform: none; }
.ob-back .ic { width: 22px; height: 22px; }
.ob-progress {
  flex: 1; height: 6px; border-radius: 999px;
  background: var(--surface-2); overflow: hidden;
}
.ob-progress > span {
  display: block; height: 100%; width: 12%; border-radius: 999px;
  background: var(--primary);
  transition: width 0.4s cubic-bezier(.32,.72,0,1);
}
.ob-lang {
  flex-shrink: 0;
  background: none; border: none; color: var(--muted);
  font-family: inherit; font-size: 14px; font-weight: 700; cursor: pointer; padding: 6px 4px;
}

/* Sliding stage: screens are stacked and translate in/out horizontally.
   Constrained to the same 460px column as the header so translateX(100%)
   equals the stage width and screens clear fully (else they overlap mid-slide
   on wide viewports). */
.ob-stage { flex: 1; position: relative; overflow: hidden; width: 100%; max-width: 460px; margin: 0 auto; }
.ob-screen {
  position: absolute; top: 0; bottom: 0; left: 0; right: 0;
  width: 100%;
  display: flex; flex-direction: column;
  padding: 12px 24px calc(24px + var(--safe-b));
  overflow-y: auto;
  will-change: transform;
}
.ob-screen.anim { transition: transform 0.34s cubic-bezier(.32,.72,0,1); }
@media (prefers-reduced-motion: reduce) {
  .ob-screen.anim { transition: none; }
  .ob-progress > span { transition: none; }
}

.ob-skip-link {
  display: block; width: 100%; margin-top: 12px; padding: 8px;
  background: none; border: none; color: var(--muted);
  font-family: inherit; font-size: 14px; font-weight: 600; cursor: pointer;
}

.ob-hero { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 14px; }
.ob-logo {
  width: 92px; height: 92px; border-radius: 26px;
  display: flex; align-items: center; justify-content: center;
  font-size: 50px; color: #fff;
  background: var(--primary);
  box-shadow: var(--shadow-lg); margin-bottom: 6px;
}
.ob-emoji { font-size: 68px; margin-bottom: 4px; }

.ob-title { font-size: 27px; font-weight: 800; line-height: 1.2; letter-spacing: -0.02em; }
.ob-title.sm { font-size: 23px; text-align: left; margin: 20px 0 6px; }
.ob-sub { font-size: 15px; line-height: 1.5; color: var(--muted); }
.ob-hero .ob-sub { max-width: 300px; }
.ob-screen > .ob-sub { text-align: left; margin-bottom: 18px; }

.ob-options { display: flex; flex-direction: column; gap: 10px; flex: 1; overflow-y: auto; }
.ob-opt {
  display: flex; align-items: center; gap: 14px; width: 100%; text-align: left;
  background: var(--surface); border: 1.5px solid var(--line); border-radius: var(--radius-sm);
  padding: 14px 16px; cursor: pointer; font-family: inherit;
  transition: border-color 0.15s, background 0.15s, transform 0.1s;
}
.ob-opt:active { transform: scale(0.98); }
.ob-opt.sel { border-color: var(--primary); background: var(--primary-soft); }
.ob-opt-ic { flex-shrink: 0; }
.ob-opt-txt { display: flex; flex-direction: column; gap: 2px; }
.ob-opt-txt b { font-size: 15px; font-weight: 700; }
.ob-opt-txt small { font-size: 13px; color: var(--muted); }
.ob-opt.sel .ob-opt-txt small { color: var(--primary-ink); }

.ob-footer { padding-top: 16px; }
.ob-footer .btn { padding: 15px; font-size: 16px; }
.btn:disabled { opacity: 0.4; pointer-events: none; }
.ob-center { text-align: center; }

/* ---------- Placement (onboarding step) ---------- */
.pl-count { font-size: 13px; font-weight: 700; color: var(--muted); margin: 6px 0 8px; }
.pl-bar { height: 6px; border-radius: 999px; background: var(--surface-2); overflow: hidden; margin-bottom: 22px; }
.pl-bar > span { display: block; height: 100%; border-radius: 999px; background: var(--primary); transition: width 0.35s ease; }
.pl-prompt { font-size: 21px; font-weight: 800; line-height: 1.35; letter-spacing: -0.01em; margin-bottom: 20px; }
/* App-wide rule (#6): Thai script is always secondary — small, muted, sitting
   under the romanization. Used wherever raw Thai appears outside romThai(). */
.th-sub { display: inline-block; font-size: 0.62em; font-weight: 400; color: var(--muted); margin-left: 2px; vertical-align: baseline; }
.pl-options { display: flex; flex-direction: column; gap: 10px; }
.pl-opt {
  width: 100%; text-align: left; background: var(--surface);
  border: 1.5px solid var(--line); border-radius: var(--radius-sm);
  padding: 15px 16px; font-family: inherit; font-size: 16px; font-weight: 600; color: var(--text);
  cursor: pointer; transition: border-color 0.15s, background 0.15s, transform 0.1s;
}
.pl-opt:hover { border-color: var(--primary); }
.pl-opt:active { transform: scale(0.98); background: var(--primary-soft); }
.pl-idk {
  margin-top: 6px; background: transparent; border-style: dashed;
  border-color: var(--line); color: var(--muted, #888);
  text-align: center; font-weight: 500; font-size: 15px;
}
.pl-idk:hover { border-color: var(--muted, #888); color: var(--text); }
.pl-noob {
  display: block; width: 100%; margin-top: 12px; padding: 10px;
  background: none; border: none; color: var(--muted);
  font-family: inherit; font-size: 14px; font-weight: 600; cursor: pointer;
}
.pl-ring {
  width: 118px; height: 118px; border-radius: 50%;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-size: 40px; font-weight: 800; color: var(--primary-ink);
  background: var(--primary-soft);
  border: 3px solid var(--primary);
  box-shadow: var(--shadow); margin-bottom: 8px;
}
.pl-ring small { font-size: 13px; font-weight: 700; color: var(--muted); margin-top: -4px; }

/* ---------- Thai-script off (settings toggle) ---------- */
/* Hide script-only bits and promote romanization as the headword. The brand
   logo, flashcard front and quiz prompts are handled in JS (rom swapped in);
   the ask-local modal lives on <body>, outside #app, so it is never touched. */
#app.hide-thai .word-thai,
#app.hide-thai .w-ex,
#app.hide-thai .fc-ex,
#app.hide-thai .learn-hi,
#app.hide-thai .qx-word .thai { display: none; }
#app.hide-thai .word-rom { font-size: 20px; color: var(--text); margin-top: 0; }
#app.hide-thai .navitem[data-route="alphabet"] { display: none; }

/* ---------- Settings ---------- */
.settings-list { margin-top: 8px; display: flex; flex-direction: column; gap: 10px; }
.setting-row {
  display: flex; align-items: center; gap: 16px;
  padding: 16px; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}
.setting-nav { cursor: pointer; font: inherit; color: var(--text); text-align: left; width: 100%; }
.setting-nav:active { transform: scale(0.99); }
.setting-go { flex: none; color: var(--muted); display: grid; place-items: center; }
.setting-go .ic { width: 18px; height: 18px; transform: rotate(180deg); }
.setting-txt { flex: 1; min-width: 0; }
.setting-label { font-weight: 700; font-size: 15px; }
.setting-desc { color: var(--muted); font-size: 13px; margin-top: 3px; line-height: 1.45; }
.switch {
  flex: none; width: 48px; height: 28px; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--line);
  position: relative; cursor: pointer; transition: background 0.2s, border-color 0.2s;
}
.switch .switch-knob {
  position: absolute; top: 2px; left: 2px; width: 22px; height: 22px;
  border-radius: 50%; background: #fff; box-shadow: var(--shadow-sm);
  transition: transform 0.2s;
}
.switch.on { background: var(--primary); border-color: var(--primary); }
.switch.on .switch-knob { transform: translateX(20px); }

/* ---------- Auth (frictionless unified sign-in / sign-up) ---------- */
.auth-body { display: flex; flex-direction: column; }
.auth-hero { text-align: center; padding: 8px 4px 26px; }
.auth-mark {
  width: 66px; height: 66px; margin: 0 auto 18px; border-radius: 20px;
  display: grid; place-items: center; background: var(--accent-soft); color: var(--accent);
  font-size: 34px; line-height: 1;
}
.auth-mark.thai { font-family: var(--thai-serif, "Noto Serif Thai", serif); font-weight: 600; }
.auth-mark.done { background: var(--accent); color: #fff; }
.auth-mark.done .ic { width: 30px; height: 30px; }
.auth-title { font-size: 24px; font-weight: 700; letter-spacing: -0.4px; margin: 0; }
.auth-sub { color: var(--muted); font-size: 14px; line-height: 1.5; margin: 10px auto 0; max-width: 30ch; }
.auth-email { font-size: 15px; font-weight: 600; margin: 8px 0 0; word-break: break-all; }

.auth-methods { display: flex; flex-direction: column; gap: 12px; }
.auth-btn {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  background: var(--surface); border: 1px solid var(--line); color: var(--text);
  box-shadow: var(--shadow-sm);
}
.auth-btn .brand { flex: none; }
.auth-apple .brand { color: var(--text); }

.auth-or { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 13px; margin: 4px 0; }
.auth-or::before, .auth-or::after { content: ""; flex: 1; height: 1px; background: var(--line); }

.auth-email-form { display: flex; flex-direction: column; gap: 12px; }
.auth-email-in {
  font: inherit; font-size: 15px; padding: 14px 16px; border-radius: var(--radius-sm);
  border: 1px solid var(--line); background: var(--surface); color: var(--text); width: 100%;
}
.auth-email-in:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.auth-actions { margin-top: 8px; }
.auth-delete { margin-top: 6px; background: transparent; color: #b23b2e; box-shadow: none; }
.auth-delete:disabled { opacity: .5; }
.auth-legal { color: var(--muted); font-size: 12px; line-height: 1.5; text-align: center; margin: 22px auto 0; max-width: 34ch; }

/* Signed-in profile card */
.auth-avatar {
  width: 76px; height: 76px; margin: 0 auto 16px; border-radius: 50%;
  display: grid; place-items: center; background: var(--accent); color: #fff;
  font-family: var(--font-display, "Fraunces", serif); font-weight: 600; font-size: 34px; line-height: 1;
}
.auth-since { color: var(--muted); font-size: 13px; margin: 6px 0 0; }
.auth-stats {
  display: flex; gap: 10px; margin: 26px 0 18px;
}
.auth-stat {
  flex: 1; text-align: center; padding: 16px 8px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm);
}
.auth-stat-n { display: block; font-size: 22px; font-weight: 700; letter-spacing: -0.4px; color: var(--accent); }
.auth-stat-l { display: block; font-size: 12px; color: var(--muted); margin-top: 4px; }
.auth-synced-note {
  display: flex; align-items: center; justify-content: center; gap: 7px;
  color: var(--muted); font-size: 13px; margin: 0 0 18px;
}
.auth-synced-note .ic { width: 15px; height: 15px; color: var(--accent); }

/* =====================================================================
   Splash — "we love ไทย". Editorial: paper ground, serif, one sienna ink
   heart, hairline. Brief and tap-to-skip.
   ===================================================================== */
.splash {
  position: fixed; inset: 0; z-index: 999;
  display: grid; place-items: center;
  background: var(--bg);
  opacity: 1; transition: opacity .5s ease;
}
.splash-out { opacity: 0; pointer-events: none; }
.splash-inner {
  display: flex; flex-direction: column; align-items: center; text-align: center;
  padding: 0 24px;
}
.splash-love {
  font-family: var(--font-display); font-style: italic; font-weight: 500;
  font-size: 22px; letter-spacing: .3px; color: var(--muted);
  opacity: 0; animation: splashRise .6s ease .1s forwards;
}
.splash-heart {
  width: 30px; height: 30px; color: var(--accent); margin: 10px 0 6px;
  opacity: 0; transform: scale(.6);
  animation: splashPop .55s cubic-bezier(.2,.9,.3,1.4) .35s forwards;
}
.splash-thai {
  font-family: "Noto Serif Thai", var(--font-display), serif; font-weight: 600;
  font-size: 64px; line-height: 1; color: var(--text);
  opacity: 0; animation: splashRise .7s ease .5s forwards;
}
.splash-rule {
  width: 46px; height: 2px; background: var(--accent); margin: 18px 0 10px;
  transform: scaleX(0); transform-origin: center;
  animation: splashRule .6s ease .8s forwards;
}
.splash-cap {
  font-family: var(--font-display); font-size: 13px; font-weight: 600;
  letter-spacing: 3px; color: var(--muted);
  opacity: 0; animation: splashRise .6s ease .95s forwards;
}
@keyframes splashRise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes splashPop { from { opacity: 0; transform: scale(.6); } to { opacity: 1; transform: scale(1); } }
@keyframes splashRule { to { transform: scaleX(1); } }

/* ---------- Live rally (realtime duel) ---------- */
/* The marquee CTA on home: a filled accent card so it reads as the headline mode. */
.rally-cta { background: var(--accent); border-color: var(--accent); }
.rally-cta .coop-entry-ic { background: rgba(255,255,255,.16); color: #fff; }
.rally-cta .coop-entry-title { color: #fff; }
.rally-cta .coop-entry-sub { color: rgba(255,255,255,.82); }
.rally-cta .coop-entry-go { color: #fff; }

.rally-back { margin-bottom: 6px; }
.rally-body { display: flex; flex-direction: column; }

/* The split arena — each device is the bottom half; opponent is the top. */
.rally-arena {
  position: relative; overflow: hidden;
  height: calc(100vh - var(--top-h) - var(--nav-h) - 28px);
  min-height: 440px;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: linear-gradient(180deg, var(--surface-2) 0%, var(--surface) 48%, var(--surface) 52%, var(--accent-soft) 100%);
  box-shadow: var(--shadow);
}
.rally-band {
  position: absolute; left: 0; right: 0; height: 54px; z-index: 3;
  display: flex; align-items: center; gap: 10px; padding: 0 16px;
}
.rally-band.top { top: 0; }
.rally-band.bottom { bottom: 0; justify-content: flex-end; }
.rally-band-name {
  font-family: var(--font-display); font-weight: 600; font-size: 14px; color: var(--muted);
  max-width: 45%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.rally-lives { display: inline-flex; gap: 6px; }
.rally-life { width: 11px; height: 11px; border-radius: 999px; box-sizing: border-box; }
.rally-life.on { background: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.rally-life.off { background: transparent; border: 1.5px solid var(--line); }

.rally-net {
  position: absolute; left: 12px; right: 12px; top: 50%; height: 0; z-index: 1;
  border-top: 2px dashed var(--line); transform: translateY(-1px);
}

/* The puck: a word travelling between the two paddles. `top` is animated. */
.rally-puck {
  position: absolute; left: 50%; top: 47%; z-index: 2;
  transform: translate(-50%, -50%);
  min-width: 96px; max-width: 78%; padding: 12px 20px;
  display: grid; place-items: center; text-align: center;
  background: var(--surface); border: 1.5px solid var(--accent);
  border-radius: 14px; box-shadow: var(--shadow-lg);
  will-change: top;
}
.rally-puck.incoming { border-color: var(--accent); box-shadow: 0 8px 24px rgba(156,74,47,.28); }
.rally-puck.outgoing { border-color: var(--line); opacity: .9; }
.rally-puck-w { font-size: 24px; font-weight: 700; color: var(--text); line-height: 1.15; }
.rally-puck.thai .rally-puck-w { font-family: var(--font-thai, "Noto Serif Thai", serif); font-size: 30px; }
.rally-puck.hidden { display: none; }
.rally-puck.burst { animation: rallyBurst .4s ease; }
@keyframes rallyBurst {
  0% { transform: translate(-50%,-50%) scale(1); }
  40% { transform: translate(-50%,-50%) scale(1.18); box-shadow: 0 0 0 10px rgba(161,63,57,.16); }
  100% { transform: translate(-50%,-50%) scale(1); }
}

/* The receiver's answer choices, docked above the bottom paddle. */
.rally-opts {
  position: absolute; left: 12px; right: 12px; bottom: 62px; z-index: 4;
  display: flex; flex-direction: column; gap: 8px;
}
.rally-opts.hidden { display: none; }
.rally-ask { text-align: center; font-size: 12px; color: var(--muted); letter-spacing: .3px; }
.rally-opts-row { display: flex; gap: 8px; }
.rally-opt {
  flex: 1; min-width: 0; padding: 13px 8px; cursor: pointer; font: inherit; font-weight: 600;
  font-size: 15px; color: var(--text); background: var(--surface);
  border: 1.5px solid var(--line); border-radius: var(--radius-sm); box-shadow: var(--shadow-sm);
  transition: transform .08s ease;
}
.rally-opt:active { transform: scale(.97); }
.rally-opt.correct { background: var(--good-soft); border-color: var(--good); color: var(--good); }
.rally-opt.wrong { background: var(--bad-soft); border-color: var(--bad); color: var(--bad); opacity: .8; }
.rally-opt:disabled { cursor: default; }

/* Center overlay: countdown numbers, set results, status text. */
.rally-center {
  position: absolute; left: 0; right: 0; top: 50%; transform: translateY(-50%);
  z-index: 5; display: grid; place-items: center; text-align: center; pointer-events: none;
}
.rally-count {
  font-family: var(--font-thai, "Noto Serif Thai", serif);
  font-size: 64px; font-weight: 700; color: var(--accent);
  animation: rallyCount .7s ease;
}
@keyframes rallyCount {
  0% { opacity: 0; transform: scale(.5); }
  35% { opacity: 1; transform: scale(1.05); }
  100% { opacity: .85; transform: scale(1); }
}
.rally-setmsg { font-family: var(--font-display); font-size: 26px; font-weight: 700; }
.rally-setmsg.win { color: var(--good); }
.rally-setmsg.lose { color: var(--bad); }
.rally-setscore { margin-top: 6px; font-size: 15px; color: var(--muted); font-weight: 600; }
.rally-final { font-size: 17px; color: var(--muted); font-weight: 600; margin: 4px 0 14px; }

.rally-arena.flash-loss::after,
.rally-arena.flash-gain::after {
  content: ""; position: absolute; inset: 0; z-index: 6; pointer-events: none;
  animation: rallyFlash .36s ease;
}
.rally-arena.flash-loss::after { background: rgba(161,63,57,.18); }
.rally-arena.flash-gain::after { background: rgba(74,107,82,.16); }
@keyframes rallyFlash { from { opacity: 1; } to { opacity: 0; } }

/* ---------- Level ETA forecast card (home) ---------- */
.eta-card {
  display: flex; gap: 12px; align-items: flex-start;
  margin-bottom: 14px; padding: 13px 14px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow-sm);
}
.eta-card.is-done { background: var(--good-soft); border-color: var(--good); }
.eta-ic {
  flex: none; width: 38px; height: 38px; border-radius: 10px;
  display: grid; place-items: center; background: var(--accent-soft); color: var(--accent);
}
.eta-ic .ic { width: 20px; height: 20px; }
.eta-card.is-done .eta-ic { background: var(--surface); color: var(--good); }
.eta-main { flex: 1; min-width: 0; }
.eta-top { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.eta-to { font-family: var(--font-display); font-weight: 700; font-size: 15px; color: var(--text); }
.eta-days { flex: none; font-family: var(--font-display); font-weight: 700; font-size: 18px; color: var(--accent); white-space: nowrap; }
.eta-sub { font-size: 13px; color: var(--muted); margin-top: 3px; }
.eta-hint { font-size: 12px; color: var(--muted); opacity: .82; margin-top: 5px; line-height: 1.45; }

/* Level-up celebration overlay */
/* Test-mode run picker sheet (normal vs speed). */
.rm-overlay {
  position: fixed; inset: 0; z-index: 200;
  display: grid; place-items: center; padding: 24px;
  background: rgba(28, 20, 14, .44); backdrop-filter: blur(3px);
}
.rm-sheet {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 20px; box-shadow: var(--shadow-lg, 0 18px 50px rgba(0,0,0,.22));
  padding: 22px 20px 14px; max-width: 320px; width: 100%; text-align: center;
  animation: rmIn .28s cubic-bezier(.2,.9,.3,1.2) both;
}
@keyframes rmIn { 0% { transform: translateY(14px) scale(.94); opacity: 0; } 100% { transform: none; opacity: 1; } }
.rm-eyebrow { font-size: 12px; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); margin-bottom: 4px; }
.rm-title { font-family: "Fraunces", Georgia, serif; font-weight: 700; font-size: 20px; margin-bottom: 16px; }
.rm-sheet .btn { margin-bottom: 8px; }
.rm-sheet [data-speed] .speed-ic { display: inline-flex; vertical-align: -3px; margin-right: 7px; color: var(--accent); }
.rm-sheet [data-speed] .speed-ic svg { width: 16px; height: 16px; }
.rm-cancel { background: none; border: none; color: var(--muted); font-size: 14px; padding: 8px; margin-top: 2px; cursor: pointer; }

.levelup-ov {
  position: fixed; inset: 0; z-index: 200;
  display: grid; place-items: center; padding: 24px;
  background: rgba(28, 20, 14, 0); backdrop-filter: blur(0px);
  transition: background .32s ease, backdrop-filter .32s ease;
}
.levelup-ov.is-in { background: rgba(28, 20, 14, .44); backdrop-filter: blur(3px); }
.levelup-ov.is-leaving { background: rgba(28, 20, 14, 0); backdrop-filter: blur(0px); }
.levelup-card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 20px; box-shadow: var(--shadow-lg, 0 18px 50px rgba(0,0,0,.22));
  padding: 30px 26px 24px; max-width: 320px; width: 100%;
  text-align: center;
  transform: translateY(14px) scale(.94); opacity: 0;
  transition: transform .38s cubic-bezier(.2,.9,.3,1.2), opacity .3s ease;
}
.levelup-ov.is-in .levelup-card { transform: translateY(0) scale(1); opacity: 1; }
.levelup-ov.is-leaving .levelup-card { transform: translateY(10px) scale(.96); opacity: 0; }
.levelup-ic {
  width: 62px; height: 62px; margin: 0 auto 14px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent);
  animation: levelupPop .6s cubic-bezier(.2,.9,.3,1.4) both .12s;
}
.levelup-ic .ic { width: 32px; height: 32px; }
.levelup-title { font-family: var(--font-display); font-weight: 700; font-size: 20px; color: var(--text); line-height: 1.25; }
.levelup-band { margin-top: 6px; font-size: 15px; color: var(--accent); font-weight: 600; }
.levelup-cta {
  margin-top: 20px; width: 100%; padding: 13px; border: none;
  border-radius: 12px; background: var(--accent); color: #fff;
  font-family: var(--font-display); font-weight: 700; font-size: 15px; cursor: pointer;
}
@keyframes levelupPop {
  0% { transform: scale(0) rotate(-18deg); }
  70% { transform: scale(1.15) rotate(6deg); }
  100% { transform: scale(1) rotate(0); }
}

/* ---------- Paywall (upgrade screen) ---------- */
.paywall { position: relative; padding-top: 8px; }
.pw-close {
  position: absolute; top: 0; right: 0; width: 40px; height: 40px;
  display: grid; place-items: center; background: none; border: 0;
  color: var(--muted); cursor: pointer;
}
.pw-close .ic { width: 20px; height: 20px; }
.pw-hero { text-align: center; padding: 12px 8px 6px; }
.pw-mark {
  width: 60px; height: 60px; margin: 0 auto 14px; border-radius: 50%;
  display: grid; place-items: center; background: var(--accent-soft); color: var(--accent);
}
.pw-mark .ic { width: 30px; height: 30px; }
.pw-level {
  display: inline-flex; align-items: center; gap: 8px; margin: 0 auto 12px;
  padding: 5px 12px 5px 6px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent);
  font-size: 13px; font-weight: 600;
}
.pw-level-code {
  display: grid; place-items: center; min-width: 30px; height: 22px; padding: 0 8px;
  border-radius: 999px; background: var(--accent); color: #fff;
  font-family: var(--font-display); font-weight: 700; font-size: 13px; letter-spacing: 0.3px;
}
.pw-title { font-family: var(--font-display); font-weight: 700; font-size: 24px; letter-spacing: -0.4px; color: var(--text); line-height: 1.2; }
.pw-sub { margin-top: 8px; font-size: 15px; color: var(--muted); line-height: 1.4; }
.pw-benefits { list-style: none; margin: 20px 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.pw-benefits li { display: flex; align-items: flex-start; gap: 11px; font-size: 15px; line-height: 1.35; color: var(--text); }
.pw-benefits .ic { flex: none; width: 18px; height: 18px; margin-top: 1px; color: var(--accent); }
.pw-plans { display: flex; flex-direction: column; gap: 10px; margin-bottom: 18px; }
.pw-plan {
  position: relative; display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 15px 16px; border: 2px solid var(--line); border-radius: 14px;
  background: var(--surface); cursor: pointer; text-align: left; font: inherit;
  transition: border-color .15s, background .15s;
}
.pw-plan.sel { border-color: var(--accent); background: var(--accent-soft); }
.pw-plan-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.pw-plan-name { font-size: 16px; font-weight: 700; color: var(--text); }
.pw-plan-note { font-size: 13px; color: var(--muted); }
.pw-plan.sel .pw-plan-name { color: var(--accent); }
.pw-plan-price { flex: none; display: flex; flex-direction: column; align-items: flex-end; }
.pw-plan-n { font-family: var(--font-display); font-weight: 700; font-size: 18px; color: var(--text); }
.pw-plan-per { font-size: 12px; color: var(--muted); }
.pw-badge {
  position: absolute; top: -9px; left: 16px; padding: 2px 9px; border-radius: 999px;
  background: var(--accent); color: #fff; font-size: 10px; font-weight: 700; letter-spacing: .5px;
}
.pw-cta { margin-bottom: 12px; }
.pw-restore {
  display: block; width: 100%; padding: 8px; background: none; border: 0;
  color: var(--accent); font: inherit; font-size: 14px; font-weight: 600; cursor: pointer;
}
.pw-fine { margin-top: 14px; font-size: 11px; line-height: 1.5; color: var(--muted); text-align: center; }
.pw-legal { margin: 10px 0 0; text-align: center; }
.pw-legal-link { background: none; border: none; padding: 2px 4px; font: inherit; font-size: 12px; color: var(--accent); text-decoration: underline; cursor: pointer; }
.pw-legal-dot { color: var(--muted); font-size: 12px; }
.setting-badge { flex: none; color: var(--accent); display: grid; place-items: center; }
.setting-badge .ic { width: 20px; height: 20px; }

/* ---------- Level 0 Foundations entry (home) ---------- */
.fnd-entry {
  width: 100%; display: flex; align-items: center; gap: 12px; text-align: left;
  margin-bottom: 12px; padding: 14px 16px; border-radius: 16px;
  background: var(--surface); border: 1px solid var(--accent);
  cursor: pointer; font: inherit; color: var(--text);
}
.fnd-entry-ic { flex: none; width: 40px; height: 40px; border-radius: 12px;
  display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); }
.fnd-entry-ic .ic { width: 22px; height: 22px; }
.fnd-entry-text { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.fnd-entry-title { font-weight: 700; font-size: 15px; }
.fnd-entry-sub { font-size: 12.5px; color: var(--muted); }
.fnd-entry-go { flex: none; color: var(--accent); display: grid; place-items: center; }
.fnd-entry-go .ic { width: 18px; height: 18px; }

/* ---------- Foundations unit list ---------- */
.fnd-head { margin-bottom: 18px; }
.fnd-eyebrow { font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--accent); }
.fnd-units { display: flex; flex-direction: column; gap: 14px; }
.fnd-unit { border: 1px solid var(--line); border-radius: 16px; background: var(--surface); overflow: hidden; }
.fnd-unit.locked { opacity: .55; }
.fnd-unit-head { display: flex; align-items: center; gap: 10px; padding: 14px 16px; }
.fnd-unit-no { font-size: 11px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); }
.fnd-unit-t { flex: 1; font-weight: 700; font-size: 16px; }
.fnd-unit-lock, .fnd-unit-check { flex: none; display: grid; place-items: center; }
.fnd-unit-lock .ic { width: 16px; height: 16px; color: var(--muted); }
.fnd-unit-check .ic { width: 18px; height: 18px; color: var(--good); }
.fnd-lessons { display: flex; flex-direction: column; border-top: 1px solid var(--line); }
.fnd-lesson { display: flex; align-items: center; gap: 12px; padding: 13px 16px; text-align: left;
  background: none; border: none; border-bottom: 1px solid var(--line); font: inherit; color: var(--text); cursor: pointer; }
.fnd-lesson:last-child { border-bottom: none; }
.fnd-lesson-ic { flex: none; width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent); }
.fnd-lesson.done .fnd-lesson-ic { background: var(--good-soft); color: var(--good); }
.fnd-lesson-ic .ic { width: 15px; height: 15px; }
.fnd-lesson-t { flex: 1; font-weight: 600; font-size: 14.5px; }
.fnd-lesson-n { flex: none; font-size: 12px; color: var(--muted); }

/* ---------- Level 0 bite-size lesson player ---------- */
.u0 { display: flex; flex-direction: column; min-height: 70vh; }
.u0-loading { align-items: center; justify-content: center; }
.u0-load { display: grid; place-items: center; }
.u0-load .spinner {
  width: 34px; height: 34px; border-radius: 50%;
  border: 3px solid var(--line); border-top-color: var(--accent);
  animation: coop-spin .8s linear infinite;
}
.u0-top { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; }
.u0-quit { flex: none; background: none; border: none; color: var(--muted); cursor: pointer; display: grid; place-items: center; padding: 4px; }
.u0-quit .ic { width: 20px; height: 20px; }
.u0-bar { flex: 1; height: 8px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.u0-bar > span { display: block; height: 100%; width: 0; border-radius: 999px; background: var(--accent); transition: width .35s ease; }
/* Speed combo — a round badge next to the progress bar. In `counting` mode it
   shows the explicit 3→2→1 fast-answer countdown; in `reward` mode it flashes the
   +N earned. Cosmetic only. */
.u0-combo {
  flex: none; display: grid; place-items: center; width: 34px; height: 34px; border-radius: 999px;
  font-weight: 800; letter-spacing: -.5px;
  opacity: 0; transform: scale(.7); transition: opacity .25s ease, transform .25s ease;
  pointer-events: none;
}
.u0-combo.show { opacity: 1; transform: scale(1); }
.u0-combo.counting { color: var(--muted); border: 2px solid var(--line); }
.u0-combo-n { font-size: 17px; font-variant-numeric: tabular-nums; line-height: 1; }
/* Last two seconds of the item clock — flash to signal the run is about to end. */
.u0-combo.u0-combo-urgent { color: #c0392b; border-color: #c0392b; animation: comboUrgent .6s ease-in-out infinite; }
@keyframes comboUrgent { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.18); } }

/* Opening 3-2-1 gate: the first speed question renders underneath, blurred, while
   a big serif countdown plays over it. Lifts to reveal the question + start clock. */
.u0-gating .u0-body, .u0-gating .u0-foot { filter: blur(7px); opacity: .5; pointer-events: none; transition: filter .25s ease, opacity .25s ease; }
.u0-gate {
  position: fixed; inset: 0; z-index: 70;
  display: flex; align-items: center; justify-content: center;
  background: rgba(243, 239, 230, .34);
}
.u0-gate-n {
  font-family: "Fraunces", Georgia, serif; font-weight: 800; line-height: 1;
  font-size: clamp(90px, 28vw, 190px); color: var(--accent);
  text-shadow: 0 2px 0 rgba(255, 255, 255, .6);
}
.u0-gate-n.pop { animation: gatePop .75s cubic-bezier(.2, .7, .2, 1); }
.u0-gate-n.go { font-size: clamp(56px, 17vw, 128px); animation: gateGo .75s ease; }
@keyframes gatePop { 0% { opacity: 0; transform: scale(.4); } 22% { opacity: 1; transform: scale(1.16); } 65% { transform: scale(1); } 100% { opacity: .12; transform: scale(.88); } }
@keyframes gateGo { 0% { opacity: 0; transform: scale(.55); } 30% { opacity: 1; transform: scale(1.12); } 100% { opacity: 1; transform: scale(1); } }

/* Combo reward: "+1" tokens that float up from the tapped button, game-style.
   One per point earned (see floatPoints), each fired ~130ms apart. */
.point-float {
  position: fixed; z-index: 60; pointer-events: none;
  font-family: "Fraunces", Georgia, serif; font-weight: 800; font-size: 24px;
  letter-spacing: -.5px; color: var(--accent);
  text-shadow: 0 1px 0 rgba(255, 255, 255, .55);
  transform: translate(-50%, 0);
  animation: pointFloat .9s cubic-bezier(.2, .7, .2, 1) forwards;
}
@keyframes pointFloat {
  0%   { opacity: 0; transform: translate(-50%, 4px) scale(.6); }
  18%  { opacity: 1; transform: translate(-50%, -8px) scale(1.12); }
  42%  { transform: translate(-50%, -30px) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -82px) scale(.95); }
}
.result-bonus {
  display: inline-flex; align-items: center; gap: 5px; margin: 0 0 10px;
  color: var(--accent); font-weight: 700; font-size: 17px;
}
.result-bonus .ic { width: 17px; height: 17px; }
.u0-body { flex: 1; }
/* Reserve the answered-state height (feedback line + Continue button) so
   revealing them never reflows the vertically-centered body. */
.u0-foot { margin-top: 20px; min-height: 80px; }

.u0-teach { text-align: center; padding: 16px 0; }
.u0-teach-label { font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--accent); margin-bottom: 18px; }
.u0-teach-speak { width: 56px; height: 56px; border-radius: 50%; border: 1px solid var(--line); background: var(--surface);
  color: var(--accent); display: grid; place-items: center; margin: 0 auto 16px; cursor: pointer; }
.u0-teach-speak .ic { width: 26px; height: 26px; }
.u0-teach-word { font-size: 46px; line-height: 1.2; gap: 6px; }
.u0-teach-mean { font-size: 20px; font-weight: 700; margin-top: 4px; }
.u0-teach-note { font-size: 13.5px; color: var(--muted); line-height: 1.5; margin: 16px auto 0; max-width: 320px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; }

.u0-q { text-align: center; padding: 10px 0 4px; }
.u0-ask { font-size: 15px; font-weight: 600; color: var(--muted); margin-bottom: 16px; }
.u0-prompt { font-size: 34px; font-weight: 700; margin: 4px 0 8px; }
/* romThai token: shows Thai script + Latin reading together. Default = Thai
   primary (large) with the hyphenated romanization as a smaller support line;
   the #app.rom-first preference swaps the two. Ordering is CSS-only (flex order)
   so the markup can always render Thai as the anchor. */
.rt { display: inline-flex; flex-direction: column; align-items: center; gap: 3px; line-height: 1.15; }
.rt-th { order: 0; color: var(--text); font-weight: 700; }
.rt-rom { order: 1; font-size: 0.58em; color: var(--muted); font-weight: 600; }
#app.rom-first .rt-rom { order: 0; font-size: 1em; color: var(--text); font-weight: 700; }
#app.rom-first .rt-th { order: 1; font-size: 0.58em; color: var(--muted); font-weight: 400; }
.u0-replay { width: 72px; height: 72px; border-radius: 50%; border: 1px solid var(--line); background: var(--surface);
  color: var(--accent); display: grid; place-items: center; margin: 0 auto 8px; cursor: pointer; }
.u0-replay.small { width: 44px; height: 44px; margin-bottom: 12px; }
.u0-replay .ic { width: 30px; height: 30px; }
.u0-replay.small .ic { width: 20px; height: 20px; }
.u0-replay-hint { font-size: 13px; color: var(--muted); }
.u0-pair { display: flex; justify-content: center; gap: 22px; margin-bottom: 8px; }
.u0-pair-btn { position: relative; margin: 0; }
.u0-pair-num { position: absolute; top: -4px; left: -4px; width: 22px; height: 22px; border-radius: 50%;
  background: var(--accent); color: #fff; font-size: 12px; font-weight: 700; display: grid; place-items: center; }
.u0-reveal-wrap { margin-top: 14px; }
.u0-reveal { background: none; border: none; color: var(--accent); font: inherit; font-size: 13px; font-weight: 600;
  text-decoration: underline; text-underline-offset: 3px; cursor: pointer; padding: 4px; }
.u0-reveal-rom { margin-top: 8px; display: flex; justify-content: center; gap: 22px; flex-wrap: wrap; font-size: 17px; color: var(--text); }
.u0-reveal-item { display: inline-flex; flex-direction: column; align-items: center; gap: 3px; }
.u0-reveal-item b { color: var(--accent); }
.u0-reveal-mean { font-size: 13px; color: var(--muted); font-weight: 600; }

.u0-opts { display: flex; flex-direction: column; gap: 10px; margin-top: 22px; }
.u0-opt { padding: 15px 18px; border-radius: 14px; border: 1.5px solid var(--line); background: var(--surface);
  font: inherit; font-size: 16px; font-weight: 600; color: var(--text); text-align: center; cursor: pointer; }
.u0-opt.rt-opt { font-size: 21px; padding: 12px 16px; }
.u0-opt:disabled { cursor: default; }
.u0-opt.correct { border-color: var(--good); background: var(--good-soft); color: var(--good); }
.u0-opt.wrong { border-color: var(--bad); background: var(--bad-soft); color: var(--bad); }
/* Always-present Continue: an inert gray button before answering (it stays
   perfectly still), then a live primary button the moment an option is chosen. */
.u0-cont.timing {
  opacity: 1 !important;
  background: var(--surface-2); color: var(--muted); box-shadow: none;
}

.u0-feedback { display: flex; flex-direction: column; gap: 10px; }
/* After answering, Thai options stay tappable to replay their audio: a speaker
   icon sits on the left while the Thai text stays centered. No auto-play. */
.u0-opt.sayable { position: relative; cursor: pointer; }
.u0-opt.sayable:active { transform: scale(.99); }
.u0-opt-say { position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
  display: inline-flex; color: var(--accent); pointer-events: none; }
.u0-opt-say svg { width: 20px; height: 20px; flex: none; }
.u0-opt.correct .u0-opt-say { color: var(--good); }
.u0-opt.wrong .u0-opt-say { color: var(--bad); }

/* ---------- pattern: teach sentence structure before building ---------- */
.u0-pattern { text-align: center; }
.u0-pat-label {
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .08em; color: var(--accent); margin-bottom: 10px;
}
.u0-pat-intro { font-size: 18px; font-weight: 600; color: var(--text); margin-bottom: 18px; }
.u0-pat-formula {
  display: flex; flex-wrap: wrap; align-items: stretch; justify-content: center;
  gap: 6px; margin-bottom: 22px;
}
.u0-pat-chip {
  display: inline-flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 10px 14px; border-radius: 12px; border: 1.5px solid var(--accent-soft);
  background: var(--accent-soft); min-width: 56px; justify-content: center;
}
.u0-pat-chip .rt { font-size: 20px; gap: 1px; }
.u0-pat-gloss { font-size: 11px; font-weight: 600; color: var(--accent); }
.u0-pat-slot {
  border-style: dashed; border-color: var(--muted); background: transparent;
  color: var(--muted); font-size: 14px; font-weight: 700; align-items: center;
}
.u0-pat-plus { display: inline-flex; align-items: center; color: var(--muted); font-weight: 700; }
.u0-pat-ex {
  display: inline-flex; align-items: center; gap: 12px;
  padding: 12px 18px; border-radius: 14px; border: 1.5px solid var(--line);
  background: var(--surface); box-shadow: var(--shadow-sm);
}
.u0-pat-ex-th { font-size: 21px; }
.u0-pat-ex-mean { font-size: 15px; color: var(--muted); font-weight: 600; }

/* ---------- build: word-tile sentence assembly ---------- */
.u0-build-prompt {
  font-size: 24px; font-weight: 700; color: var(--text);
  margin: 4px 0 12px; line-height: 1.3;
}
/* Word-for-word order hint: a faint teacher's annotation that shows how Thai
   orders the words (incl. words the learner's language omits, like อยู่). */
.u0-build-literal {
  font-size: 14px; color: var(--muted); margin: 0 0 18px;
  line-height: 1.4;
}
.u0-build-literal-tag {
  display: inline-block; font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .06em;
  color: var(--accent); margin-right: 6px;
}
/* The answer line: a dashed slot the tiles drop into, always reserving height so
   the layout doesn't jump as tiles are added. */
.u0-build-line {
  display: flex; flex-wrap: wrap; justify-content: center; align-items: center;
  gap: 8px; min-height: 66px; padding: 12px;
  border-radius: 14px; border: 1.5px dashed var(--line);
  background: var(--surface); margin-bottom: 26px;
}
.u0-build-line.correct { border-style: solid; border-color: var(--good); background: var(--good-soft); }
.u0-build-line.wrong { border-style: solid; border-color: var(--bad); background: var(--bad-soft); }
.u0-build-bank {
  display: flex; flex-wrap: wrap; justify-content: center; gap: 10px;
}
.u0-tile {
  display: inline-flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 10px 16px; border-radius: 12px; border: 1.5px solid var(--line);
  background: var(--surface); color: var(--text); cursor: pointer;
  transition: transform .12s ease, opacity .12s ease;
}
.u0-tile:active { transform: scale(.96); }
.u0-tile .rt { font-size: 21px; gap: 2px; }
.u0-tile-bank.used { opacity: 0; pointer-events: none; }
.u0-tile-set { border-color: var(--accent-soft); background: var(--accent-soft); }
/* Per-tile meaning label: lets a beginner arrange by sense, not by reading Thai. */
.u0-tile-gloss {
  font-size: 11px; font-weight: 600; color: var(--muted);
  margin-top: 2px; letter-spacing: .01em;
}
.u0-tile-set .u0-tile-gloss { color: var(--accent); }
/* Empty numbered slot: shows how many words the sentence needs. */
.u0-build-slot {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 42px; height: 42px; padding: 0 10px;
  border-radius: 12px; border: 1.5px dashed var(--line);
  color: var(--line); font-size: 15px; font-weight: 700;
  background: transparent;
}
.u0-build-line:not(.correct):not(.wrong) .u0-tile-set:hover { border-color: var(--accent); }
.u0-build-answer { display: flex; justify-content: center; margin-top: 4px; }
.u0-build-answer .rt { font-size: 24px; }
.u0-build-answer .rt-th { color: var(--good); }
#app.rom-first .u0-build-answer .rt-th { color: var(--muted); }
#app.rom-first .u0-build-answer .rt-rom { color: var(--good); }

/* Full-screen steps: center each step's content vertically so no step needs
   scrolling and short cards don't cling to the top. */
.u0-body { display: flex; flex-direction: column; justify-content: center; }
