/* Voc — design tokens from design/brand.md section 8 (values verbatim), then layout. */
:root {
  color-scheme: light dark;

  /* neutrals */
  --bg:        #F6F7FB;
  --card:      #FFFFFF;
  --text:      #1B2233;
  --text-2:    #4F586B;
  --border:    #D6DAE5;   /* decorative divider, not measured */
  --border-2:  #6F788D;   /* control outline, must be >= 3:1 on --card */

  /* primary */
  --primary:    #1E5BD6;
  --primary-2:  #153F96;
  --on-primary: #FFFFFF;

  /* accents: always bright background + dark text */
  --orange: #FFA94D;
  --yellow: #FFD93D;
  --mint:   #5EE0C8;
  --pink:   #FF9EC4;
  --on-accent: #1B2233;

  /* semantic */
  --success:    #17783B;
  --success-bg: #DDF5E4;
  --success-tx: #0E5A2A;
  --on-success: #FFFFFF;
  --error:      #D02E2E;
  --error-bg:   #FDE3E1;
  --error-tx:   #8A1B18;
  --on-error:   #FFFFFF;

  /* guide (小步) */
  --guide-coat:   var(--orange);
  --guide-muzzle: #FFE3C2;
  --guide-line:   #1B2233;

  /* type */
  --font-ui:    "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", system-ui, sans-serif;
  --font-round: "jf-openhuninn", "Noto Sans TC", "PingFang TC", system-ui, sans-serif;
  --font-body:  var(--font-ui);

  /* age band defaults = 9-12 (b); a and c override below */
  --fs-body:   1.125rem;  /* 18px */
  --fs-small:  1rem;      /* 16px */
  --fs-word:   2.125rem;  /* 34px */
  --fs-title:  1.5rem;    /* 24px */
  --fs-button: 1.25rem;   /* 20px */
  --lh-body:   1.6;
  --radius-card:   16px;
  --radius-button: 16px;
  --btn-min-h: 48px;
  --tap-gap:   8px;
  --progress-h: 8px;

  /* motion */
  --t-fast: 80ms;
  --t-feedback: 250ms;
  --t-celebrate: 1200ms;
  --shadow-btn: 0 4px 0 var(--primary-2);
}

html[data-age="a"] {
  --font-body: var(--font-round);
  --fs-body:   1.25rem;   /* 20px */
  --fs-small:  1.125rem;  /* 18px */
  --fs-word:   2.5rem;    /* 40px */
  --fs-title:  1.75rem;   /* 28px */
  --fs-button: 1.5rem;    /* 24px */
  --radius-card:   20px;
  --radius-button: 20px;
  --btn-min-h: 64px;
  --tap-gap:   12px;
  --progress-h: 12px;
}

html[data-age="c"] {
  --fs-body:   1.0625rem; /* 17px */
  --fs-small:  0.9375rem; /* 15px */
  --fs-word:   1.875rem;  /* 30px */
  --fs-title:  1.375rem;  /* 22px */
  --fs-button: 1.125rem;  /* 18px */
  --lh-body:   1.55;
  --radius-card:   14px;
  --radius-button: 12px;
  --progress-h: 6px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg:        #121622;
    --card:      #1C2233;
    --text:      #F1F3F8;
    --text-2:    #B3BACB;
    --border:    #2E3649;
    --border-2:  #7D879C;

    --primary:    #7FA8FF;
    --primary-2:  #B7CCFF;
    --on-primary: #121622;

    /* accents unchanged; only the text on them changes */
    --on-accent: #121622;

    --success:    #5FD48A;
    --success-bg: #173D27;
    --success-tx: #BDF0CF;
    --on-success: #121622;
    --error:      #FF7B72;
    --error-bg:   #4A1E1C;
    --error-tx:   #FFC9C4;
    --on-error:   #121622;

    --guide-line: #121622;
    --shadow-btn: 0 4px 0 #3E62B8;
  }
}

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

/* ---- base ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; }
body {
  font-family: var(--font-body);
  font-size: var(--fs-body);
  line-height: var(--lh-body);
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
  -webkit-text-size-adjust: 100%;
}
[hidden] { display: none !important; }
main { max-width: 480px; margin: 0 auto; padding: 16px 16px 32px; }
h1, h2 { font-size: var(--fs-title); line-height: 1.3; font-weight: 700; }
h2 { font-size: var(--fs-body); margin-top: 20px; }
p { margin: 0; }
.note, .subtitle, .meta { color: var(--text-2); font-size: var(--fs-small); }
.err { color: var(--error-tx); background: var(--error-bg); border-radius: 8px; padding: 8px 12px; font-size: var(--fs-small); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; }
mark { background: var(--error-bg); color: var(--error-tx); border-radius: 4px; padding: 0 2px; }

.screen { display: flex; flex-direction: column; gap: var(--tap-gap); min-height: calc(100vh - 48px); }
.stack { display: flex; flex-direction: column; gap: var(--tap-gap); }
.row { display: flex; gap: var(--tap-gap); }
.row > * { flex: 1; }
.topbar { display: flex; justify-content: space-between; align-items: center; min-height: 48px; }
.spacer { flex: 1; }
.center { text-align: center; }
.guide-wrap { display: flex; justify-content: center; padding: 8px 0; }
.card, .qcard {
  background: var(--card);
  border-radius: var(--radius-card);
  padding: 16px;
  border: 1px solid var(--border);
}

/* ---- buttons and controls ---- */
.btn {
  font: inherit;
  font-size: var(--fs-button);
  font-weight: 700;
  min-height: var(--btn-min-h);
  padding: 8px 16px;
  border-radius: var(--radius-button);
  border: 0;
  background: var(--card);
  color: var(--text);
  cursor: pointer;
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: transform var(--t-fast), box-shadow var(--t-fast), background-color var(--t-feedback), border-color var(--t-feedback);
  touch-action: manipulation;
}
.btn:disabled { opacity: 0.5; cursor: default; }
.btn-primary { background: var(--primary); color: var(--on-primary); box-shadow: var(--shadow-btn); }
.btn-primary:active:not(:disabled) { transform: translateY(2px); box-shadow: none; }
.btn-secondary { background: var(--card); color: var(--primary); border: 2px solid var(--border-2); }
.btn-text { background: transparent; color: var(--primary-2); width: auto; min-height: 48px; padding: 8px 12px; }
.btn-danger { background: var(--card); color: var(--error); border: 2px solid var(--error); }
.btn-xl { min-height: 80px; font-size: calc(var(--fs-button) * 1.2); }
.btn-age { flex-direction: column; min-height: 64px; line-height: 1.2; }
.btn-age .sub { font-size: var(--fs-small); font-weight: 400; }
.btn-listen { width: auto; min-width: 96px; align-self: center; background: var(--primary); color: var(--on-primary); box-shadow: var(--shadow-btn); }
.btn-listen:active:not(:disabled) { transform: translateY(2px); box-shadow: none; }
.btn-big-listen { min-height: 72px; }
html[data-age="a"] .btn-big-listen { min-height: 96px; }
html[data-age="c"] .btn-big-listen { min-height: 64px; }
.btn-hold { min-height: 96px; user-select: none; -webkit-user-select: none; }
.option { background: var(--card); color: var(--text); border: 2px solid var(--border-2); font-weight: 700; text-align: center; }
.option[data-state="correct"] { background: var(--success-bg); color: var(--success-tx); border-color: var(--success); }
.option[data-state="wrong"] { background: var(--error-bg); color: var(--error-tx); border-color: var(--error); }
.option[data-state="correct"]::before { content: "✓ "; }
.options { display: flex; flex-direction: column; gap: var(--tap-gap); }
.input, select.input {
  font: inherit;
  font-size: var(--fs-body);
  min-height: var(--btn-min-h);
  padding: 8px 12px;
  border: 2px solid var(--border-2);
  border-radius: var(--radius-button);
  background: var(--card);
  color: var(--text);
  width: 100%;
}
.input.flash { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary); }
label.field { display: flex; flex-direction: column; gap: 4px; font-size: var(--fs-small); color: var(--text-2); }
.check { display: flex; align-items: center; gap: 12px; min-height: var(--btn-min-h); font-size: var(--fs-body); color: var(--text); }
.check input { width: 28px; height: 28px; accent-color: var(--primary); }
.entry { justify-content: space-between; text-align: left; min-height: 64px; font-weight: 400; border: 2px solid var(--border-2); }
.entry b { font-weight: 700; }
.entry .arrow { color: var(--text-2); }
.entry .desc { font-size: var(--fs-small); color: var(--text-2); }

/* ---- practice ---- */
.practice-header { max-width: 480px; margin: 0 auto; padding: 8px 16px 0; color: var(--text-2); font-size: var(--fs-small); text-align: center; }
.progress-row { display: flex; align-items: center; gap: 12px; }
progress { flex: 1; height: var(--progress-h); appearance: none; -webkit-appearance: none; border: 0; border-radius: 999px; overflow: hidden; background: var(--border); accent-color: var(--primary); transition: width 200ms; }
progress::-webkit-progress-bar { background: var(--border); border-radius: 999px; }
progress::-webkit-progress-value { background: var(--primary); border-radius: 999px; transition: width 200ms; }
progress::-moz-progress-bar { background: var(--primary); }
.progress-label { color: var(--text-2); font-size: var(--fs-small); font-variant-numeric: tabular-nums; }
.tag { font-size: var(--fs-small); font-weight: 700; padding: 2px 10px; border-radius: 999px; color: var(--on-accent); }
.tag[data-mode="read"], .tag[data-mode="intro"] { background: var(--mint); }
.tag[data-mode="listen"] { background: var(--orange); }
.tag[data-mode="spell"] { background: var(--pink); }
.tag[data-mode="speak"] { background: var(--yellow); }
.stem { font-weight: 700; }
.qcard { display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; position: relative; }
.qcard .icon { font-size: 2.5rem; line-height: 1; }
.word { font-size: var(--fs-word); font-weight: 700; line-height: 1.2; word-break: break-word; }
.zh-big { font-size: var(--fs-title); font-weight: 700; }
.example { margin-top: 8px; }
.example-zh { color: var(--text-2); font-size: var(--fs-small); }
.guide-row { display: flex; justify-content: flex-end; margin-bottom: calc(-1 * var(--tap-gap)); }
html[data-age="b"] .qcard[data-mode="read"], html[data-age="b"] .qcard[data-mode="intro"] { border-top: 8px solid var(--mint); }
html[data-age="b"] .qcard[data-mode="listen"] { border-top: 8px solid var(--orange); }
html[data-age="b"] .qcard[data-mode="spell"] { border-top: 8px solid var(--pink); }
html[data-age="b"] .qcard[data-mode="speak"] { border-top: 8px solid var(--yellow); }
html[data-age="a"] .qcard[data-mode="read"], html[data-age="a"] .qcard[data-mode="intro"] { background: var(--mint); color: var(--on-accent); border-color: var(--mint); }
html[data-age="a"] .qcard[data-mode="listen"] { background: var(--orange); color: var(--on-accent); border-color: var(--orange); }
html[data-age="a"] .qcard .meta, html[data-age="a"] .qcard .example-zh { color: var(--on-accent); }
.speak-result { min-height: 1.6em; text-align: center; color: var(--text-2); }

/* visible answer feedback inside the question (C-03); the aria-live copy is visually hidden */
.result-line { min-height: 1.6em; text-align: center; font-weight: 700; color: var(--success-tx); margin: 0; }
body[data-last-result="wrong"] .result-line { color: var(--error-tx); }
.notice { background: var(--success-bg); color: var(--success-tx); border-radius: 8px; padding: 8px 12px; margin-bottom: 12px; }
/* live feedback line (aria-live) */
.live { min-height: 1.6em; text-align: center; font-weight: 700; color: var(--success-tx); }
.live:empty { display: none; }
body[data-last-result="wrong"] .live { color: var(--error-tx); }

/* ---- feedback sheet and confirm dialog ---- */
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  background: var(--card); color: var(--text);
  border-radius: var(--radius-card) var(--radius-card) 0 0;
  border-top: 1px solid var(--border);
  padding: 16px 16px 24px; max-width: 480px; margin: 0 auto;
  display: flex; flex-direction: column; gap: var(--tap-gap);
  box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.15);
}
.sheet .fb-line { font-size: var(--fs-title); font-weight: 700; text-align: center; }
.sheet .fb-sub { text-align: center; }
.modal-backdrop { position: fixed; inset: 0; z-index: 30; background: rgba(18, 22, 34, 0.55); display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal { background: var(--card); color: var(--text); border-radius: var(--radius-card); padding: 20px; width: 100%; max-width: 420px; display: flex; flex-direction: column; gap: var(--tap-gap); }
.modal p { text-align: center; }
.result { border-radius: 8px; padding: 10px 12px; white-space: pre-line; font-size: var(--fs-small); }
.result[data-status="ok"] { background: var(--success-bg); color: var(--success-tx); }
.result[data-status="error"] { background: var(--error-bg); color: var(--error-tx); }
.result[data-status="checking"] { background: var(--card); color: var(--text-2); border: 1px solid var(--border); }

/* ---- dashboard ---- */
.stat { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.stat .num { font-size: var(--fs-word); font-weight: 700; line-height: 1.1; }
html[data-age="a"] .stat .num { font-size: 2.5rem; }
.hardest { display: flex; flex-direction: column; gap: 4px; }
.hardest .head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.hardest li { list-style: none; display: flex; justify-content: space-between; gap: 8px; border-bottom: 1px solid var(--border); padding: 4px 0; }
.hardest li .w { font-weight: 700; }
.hardest li .d { color: var(--text-2); font-size: var(--fs-small); }
.layer2 { border-top: 1px solid var(--border); padding-top: 12px; display: flex; flex-direction: column; gap: 8px; }
.bar { display: flex; height: 12px; border-radius: 999px; overflow: hidden; background: var(--border); }
.bar span { display: block; height: 100%; }
.bar .b-new { background: var(--border-2); } .bar .b-learning { background: var(--pink); } .bar .b-reviewing { background: var(--yellow); } .bar .b-stable { background: var(--mint); }
.dots { display: flex; gap: 6px; flex-wrap: wrap; }
.dots span { width: 22px; height: 22px; border-radius: 50%; background: var(--border); }
.dots span.on { background: var(--primary); }
.goal-bar { height: 12px; border-radius: 999px; background: var(--border); overflow: hidden; }
.goal-bar span { display: block; height: 100%; background: var(--primary); transition: width 200ms; }
.official-list { max-height: 200px; overflow: auto; }

/* ---- guide (小步) ---- */
.guide .head, .guide .ear   { fill: var(--guide-coat); }
.guide .ear                 { stroke: var(--guide-line); stroke-width: 1.5; }
.guide .muzzle              { fill: var(--guide-muzzle); }
.guide .eye, .guide .nose   { fill: var(--guide-line); }
.guide .mouth, .guide .tail { stroke: var(--guide-line); }
.guide .sparks circle       { fill: var(--yellow); opacity: 0; }
.guide[data-mood="ready"] .head       { transform: rotate(-6deg); transform-origin: 30px 34px; }
.guide[data-mood="correct"] .tail     { transform: rotate(-25deg); transform-origin: 50px 46px; }
.guide[data-mood="wrong"] .ear-l      { transform: rotate(-35deg); transform-origin: 18px 30px; }
.guide[data-mood="wrong"] .ear-r      { transform: rotate(35deg);  transform-origin: 42px 30px; }
.guide[data-mood="wrong"] .eye        { transform: scaleY(0.25);   transform-origin: center; }
.guide[data-mood="wrong"] .head       { transform: rotate(6deg); transform-origin: 30px 34px; }
.guide[data-mood="goal"] .tail        { transform: rotate(-45deg); transform-origin: 50px 46px; }
.guide[data-mood="goal"] .sparks circle { opacity: 1; }
.guide .ear, .guide .eye, .guide .tail, .guide .head { transition: transform var(--t-feedback); }

/* ---- motion (only via data-anim; never added under reduced motion) ---- */
[data-anim="bounce"] { animation: bounce 300ms ease-out; }
[data-anim="goal"] { animation: pop 1200ms ease-out; }
[data-anim="flash"] { animation: flash 600ms ease-out; }
.banner { position: fixed; top: 0; left: 0; right: 0; z-index: 25; background: var(--yellow); color: var(--on-accent); text-align: center; font-weight: 700; padding: 12px; }
.banner[data-anim="streak5"] { animation: slide 1500ms ease-in-out forwards; }
@keyframes bounce { 0% { transform: translateY(0); } 40% { transform: translateY(-6px); } 100% { transform: translateY(0); } }
@keyframes pop { 0% { transform: scale(1); } 30% { transform: scale(1.25); } 100% { transform: scale(1); } }
@keyframes flash { 0% { filter: brightness(1); } 30% { filter: brightness(1.6); } 100% { filter: brightness(1); } }
@keyframes slide { 0% { transform: translateY(-100%); } 15% { transform: translateY(0); } 85% { transform: translateY(0); } 100% { transform: translateY(-100%); } }

/* ---- 404 ---- */
.s14 { text-align: center; align-items: center; justify-content: center; gap: 16px; }
.s14 a.btn { text-decoration: none; }

/* =====================================================================
   Skin v2 (2026-09-23): "英語冒險，從小步開始" — cream paper, mint frames,
   pastel answer tiles, chunky 3D buttons, illustrated 小步.
   Brand tokens above stay untouched (locked contrast tests read them);
   this layer adds its own tokens and restyles on top.
   ===================================================================== */
:root {
  --paper:      #FBF7EC;
  --paper-2:    #F3EEDD;
  --frame:      #BFE6D8;
  --frame-2:    #8FD3BD;
  --teal:       #1FA383;
  --teal-bg:    #DDF5EC;
  --ink:        #16213A;
  --tile-mint:  #C8F1E2;  --tile-mint-2:  #86D8BB;
  --tile-lav:   #E4DBFB;  --tile-lav-2:   #B7A6EE;
  --tile-sun:   #FFEEA6;  --tile-sun-2:   #F2CE4A;
  --tile-sky:   #CFE3FF;  --tile-sky-2:   #8DB8F5;
  --press:      #0F3C9C;
  --font-word:  "Nunito", "Noto Sans TC", system-ui, sans-serif;
  --shadow-card: 0 1px 0 rgba(22,33,58,.04), 0 10px 30px rgba(31,90,70,.10);
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #121622; --paper-2: #182033; --frame: #2B4A44; --frame-2: #3C6B60;
    --teal: #5FD4B4; --teal-bg: #173A31; --ink: #F1F3F8;
    --tile-mint: #1D4A3E; --tile-mint-2: #0F2E26;
    --tile-lav:  #3A3263; --tile-lav-2:  #241E42;
    --tile-sun:  #4C4318; --tile-sun-2:  #2E280C;
    --tile-sky:  #213F66; --tile-sky-2:  #132640;
    --press: #3E62B8;
    --shadow-card: 0 10px 30px rgba(0,0,0,.35);
  }
}

body {
  background:
    radial-gradient(120% 60% at 50% 115%, color-mix(in srgb, var(--tile-mint) 70%, transparent) 0 40%, transparent 41%),
    radial-gradient(80% 40% at 0% 100%, color-mix(in srgb, var(--frame) 60%, transparent) 0 50%, transparent 51%),
    var(--paper);
  background-attachment: fixed;
  color: var(--ink);
}
main { padding-top: 20px; }
h1, h2, .stem, .zh-big { font-weight: 900; letter-spacing: .01em; }
h1 { font-size: calc(var(--fs-title) * 1.15); line-height: 1.25; text-wrap: balance; }

/* every screen sits on a mint-framed sheet, like the reference cards */
.screen:not([hidden]) {
  background: color-mix(in srgb, var(--card) 88%, transparent);
  border: 3px solid var(--frame);
  border-radius: 28px;
  padding: 20px 18px 22px;
  box-shadow: var(--shadow-card);
  min-height: calc(100vh - 56px);
  backdrop-filter: blur(2px);
}
html[data-age="c"] .screen:not([hidden]) { border-width: 2px; border-radius: 22px; }

/* ---- 小步 ---- */
img.guide { display: block; object-fit: contain; height: auto; filter: drop-shadow(0 6px 10px rgba(22,33,58,.18)); }
.guide-wrap { padding: 4px 0; }
body[data-screen="S1"] img.guide { width: 190px; }
html[data-age="a"] body[data-screen="S1"] img.guide, body[data-screen="S1"][data-age="a"] img.guide { width: 220px; }
body[data-screen="S9"] img.guide { width: 200px; }
body[data-screen="S14"] img.guide, .s14 img.guide { width: 180px; }
.guide-row img.guide { width: 84px; }
.sheet img.guide { width: 88px; }
img.guide[data-mood="ready"]   { animation: guide-idle 3.2s ease-in-out infinite; }
img.guide[data-mood="correct"] { animation: guide-hop 520ms cubic-bezier(.3,1.6,.5,1); }
img.guide[data-mood="wrong"]   { animation: guide-tilt 700ms ease-out; }
img.guide[data-mood="goal"]    { animation: guide-cheer 1.2s cubic-bezier(.3,1.5,.5,1); }
@keyframes guide-idle  { 0%,100% { transform: translateY(0) rotate(0); } 50% { transform: translateY(-4px) rotate(-1.5deg); } }
@keyframes guide-hop   { 0% { transform: translateY(0) scale(1); } 35% { transform: translateY(-18px) scale(1.06); } 70% { transform: translateY(0) scale(.97,1.03); } 100% { transform: none; } }
@keyframes guide-tilt  { 0% { transform: rotate(0); } 30% { transform: rotate(-7deg); } 60% { transform: rotate(4deg); } 100% { transform: rotate(0); } }
@keyframes guide-cheer { 0% { transform: scale(.6) rotate(-8deg); opacity: .4; } 45% { transform: scale(1.12) rotate(4deg); opacity: 1; } 70% { transform: scale(.96) rotate(-2deg); } 100% { transform: none; } }

/* ---- buttons: chunky, 3D, pressable ---- */
.btn { border-radius: 18px; font-weight: 900; letter-spacing: .02em; }
html[data-age="c"] .btn { border-radius: 14px; }
.btn-primary, .btn-listen {
  background-color: var(--primary);
  background-image: linear-gradient(180deg, color-mix(in srgb, var(--primary) 88%, white) 0%, var(--primary) 60%);
  box-shadow: 0 6px 0 var(--press), 0 10px 18px rgba(21,63,150,.25);
  transform: translateY(0);
}
.btn-primary:active:not(:disabled), .btn-listen:active:not(:disabled) { transform: translateY(5px); box-shadow: 0 1px 0 var(--press); }
.btn-listen { border-radius: 999px; padding-inline: 26px; min-width: 150px; }
.btn-listen::before { content: ""; width: 22px; height: 22px; background: currentColor; -webkit-mask: var(--ico-speaker) center/contain no-repeat; mask: var(--ico-speaker) center/contain no-repeat; }
:root { --ico-speaker: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M4 9h4l5-4v14l-5-4H4z'/%3E%3Cpath d='M16 8.5a5 5 0 0 1 0 7M18.5 6a8.5 8.5 0 0 1 0 12' fill='none' stroke='%23000' stroke-width='2.2' stroke-linecap='round'/%3E%3C/svg%3E"); }
.btn-secondary {
  background: var(--card); color: var(--primary); border: 0;
  box-shadow: inset 0 0 0 2px var(--frame-2), 0 4px 0 var(--frame-2);
}
.btn-secondary:active:not(:disabled) { transform: translateY(3px); box-shadow: inset 0 0 0 2px var(--frame-2), 0 1px 0 var(--frame-2); }
.btn-text { font-weight: 800; color: var(--primary-2); }
.btn-age { border-radius: 22px; }
.entry { border: 0; background: var(--card); box-shadow: inset 0 0 0 2px var(--frame), 0 4px 0 var(--frame); border-radius: 18px; }
.entry:active { transform: translateY(3px); box-shadow: inset 0 0 0 2px var(--frame), 0 1px 0 var(--frame); }
.input, select.input { border-radius: 16px; border-color: var(--frame-2); background: var(--card); }
.input:focus { border-color: var(--primary); box-shadow: 0 0 0 4px color-mix(in srgb, var(--primary) 22%, transparent); outline: none; }

/* ---- question card ---- */
.qcard {
  border: 0; border-radius: 26px; padding: 26px 18px 22px;
  background: var(--card);
  box-shadow: inset 0 0 0 2px var(--paper-2), 0 8px 24px rgba(22,33,58,.08);
}
html[data-age="b"] .qcard[data-mode] { border-top: 0; }
html[data-age="a"] .qcard[data-mode="read"], html[data-age="a"] .qcard[data-mode="intro"],
html[data-age="a"] .qcard[data-mode="listen"] { background: var(--card); color: var(--ink); }
html[data-age="a"] .qcard .meta, html[data-age="a"] .qcard .example-zh { color: var(--text-2); }
.word { font-family: var(--font-word); font-weight: 900; font-size: calc(var(--fs-word) * 1.45); letter-spacing: -.01em; color: var(--ink); line-height: 1.05; }
html[data-age="c"] .word { font-size: calc(var(--fs-word) * 1.3); }
.stem { font-size: calc(var(--fs-body) * 1.12); }

/* ---- answer tiles: 2x2 pastel grid, each a different color ---- */
.options { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.option {
  border: 0; min-height: 86px; border-radius: 22px; font-size: calc(var(--fs-button) * 1.15);
  color: var(--ink); background: var(--tile-mint);
  box-shadow: 0 6px 0 var(--tile-mint-2);
  transition: transform 90ms, box-shadow 90ms, background-color 200ms;
  word-break: break-word; padding: 10px;
}
.option:nth-child(4n+2) { background: var(--tile-lav); box-shadow: 0 6px 0 var(--tile-lav-2); }
.option:nth-child(4n+3) { background: var(--tile-sun); box-shadow: 0 6px 0 var(--tile-sun-2); }
.option:nth-child(4n+4) { background: var(--tile-sky); box-shadow: 0 6px 0 var(--tile-sky-2); }
.option:active:not(:disabled) { transform: translateY(5px); box-shadow: 0 1px 0 rgba(22,33,58,.25); }
html[data-age="a"] .option { min-height: 104px; font-size: calc(var(--fs-button) * 1.25); }
html[data-age="c"] .option { min-height: 68px; border-radius: 16px; }
.option[data-state="correct"] {
  background: var(--success-bg); color: var(--success-tx);
  box-shadow: inset 0 0 0 3px var(--success), 0 6px 0 var(--success);
  animation: tile-yes 420ms cubic-bezier(.3,1.6,.5,1);
}
.option[data-state="wrong"] {
  background: var(--error-bg); color: var(--error-tx);
  box-shadow: inset 0 0 0 3px var(--error), 0 6px 0 var(--error);
  animation: tile-no 360ms ease-in-out;
}
.option[data-state="correct"]::before { content: "✓"; margin-right: 6px; }
@keyframes tile-yes { 0% { transform: scale(1); } 40% { transform: scale(1.07); } 100% { transform: scale(1); } }
@keyframes tile-no  { 0%,100% { transform: translateX(0); } 20% { transform: translateX(-7px); } 40% { transform: translateX(6px); } 60% { transform: translateX(-4px); } 80% { transform: translateX(3px); } }

/* ---- progress: 10 chunky segments ---- */
progress {
  height: 14px; border-radius: 999px;
  -webkit-mask: repeating-linear-gradient(90deg, #000 0 calc(10% - 5px), transparent calc(10% - 5px) 10%);
          mask: repeating-linear-gradient(90deg, #000 0 calc(10% - 5px), transparent calc(10% - 5px) 10%);
}
progress::-webkit-progress-bar { background: var(--paper-2); }
progress::-webkit-progress-value { background: var(--teal); }
progress::-moz-progress-bar { background: var(--teal); }
.progress-label { font-weight: 800; color: var(--text-2); }
.tag { border-radius: 999px; padding: 3px 12px; font-weight: 900; }

/* ---- feedback ---- */
.result-line { font-size: calc(var(--fs-body) * 1.1); font-weight: 900; color: var(--success-tx); }
.sheet {
  border-radius: 28px 28px 0 0; border-top: 0; padding: 20px 18px 28px;
  box-shadow: 0 -12px 30px rgba(22,33,58,.18);
  animation: sheet-up 260ms cubic-bezier(.2,1.2,.4,1);
}
.sheet .fb-line { font-weight: 900; }
@keyframes sheet-up { from { transform: translateY(100%); } to { transform: none; } }
.banner {
  top: 12px; left: 50%; right: auto; transform: translateX(-50%);
  width: min(92vw, 420px); border-radius: 999px; padding: 12px 20px;
  background: var(--yellow); box-shadow: 0 6px 0 #E0B500, 0 12px 24px rgba(0,0,0,.15);
  font-weight: 900; font-size: calc(var(--fs-body) * 1.05);
}
.banner[data-anim="streak5"] { animation: banner-pop 1500ms cubic-bezier(.3,1.5,.5,1) forwards; }
@keyframes banner-pop { 0% { transform: translate(-50%, -140%); } 15% { transform: translate(-50%, 0) scale(1.05); } 25% { transform: translate(-50%, 0) scale(1); } 85% { transform: translate(-50%, 0); } 100% { transform: translate(-50%, -140%); } }

/* ---- summary and records ---- */
.stat .num { font-family: var(--font-word); font-weight: 900; color: var(--primary); font-size: calc(var(--fs-word) * 1.3); }
.card { border: 0; border-radius: 22px; box-shadow: inset 0 0 0 2px var(--frame), 0 4px 0 var(--frame); }
.goal-bar, .bar { height: 16px; background: var(--paper-2); }
.goal-bar span { background: linear-gradient(90deg, var(--teal), color-mix(in srgb, var(--teal) 70%, var(--yellow))); }
.dots span { width: 24px; height: 24px; background: var(--paper-2); }
.dots span.on { background: var(--teal); box-shadow: 0 3px 0 color-mix(in srgb, var(--teal) 60%, black); }
.hardest li { border-bottom: 2px dashed var(--paper-2); padding: 8px 0; }
.hardest li .w { font-family: var(--font-word); font-weight: 900; font-size: 1.1em; }
.notice { border-radius: 14px; }


/* after answering: keep the right answer vivid, fade only the rest */
.option:disabled { opacity: .5; }
.option[data-state="correct"]:disabled, .option[data-state="wrong"]:disabled { opacity: 1; }

/* ---- cloud records (S15) and leaderboard (S16) ---- */
.arcade-id { font-weight: 900; font-size: calc(var(--fs-title) * 1.2); color: var(--ink); }
.arcade-id .num, .board .num { font-family: var(--font-word); font-weight: 900; font-variant-numeric: tabular-nums; }
.arcade-id .num { color: var(--primary); letter-spacing: .04em; }
.segs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.btn.seg {
  min-height: 48px; font-size: var(--fs-small); padding: 6px 8px; color: var(--primary);
  background: var(--card); box-shadow: inset 0 0 0 2px var(--frame-2), 0 4px 0 var(--frame-2);
}
.btn.seg[aria-pressed="true"] { background: var(--primary); color: var(--on-primary); box-shadow: 0 4px 0 var(--press); }
.btn.seg:active:not(:disabled) { transform: translateY(3px); }
.btn.metric { align-self: center; font-size: var(--fs-small); }
.board { list-style: none; display: flex; flex-direction: column; gap: 8px; }
.board li {
  display: grid; grid-template-columns: 2.4em 1fr auto; align-items: center; gap: 8px;
  background: var(--card); border-radius: 16px; padding: 10px 14px;
  box-shadow: inset 0 0 0 2px var(--paper-2);
}
.board.self li { grid-template-columns: 1fr auto; }
.board li.me, .board li.now { box-shadow: inset 0 0 0 3px var(--frame-2); }
.board .rank { font-size: 1.25em; text-align: center; color: var(--text-2); }
.board .who { font-weight: 700; overflow-wrap: anywhere; }
.board .nums .num { font-size: 1.2em; color: var(--ink); }
.board .nums .sub { font-size: 0.9em; }
.board li.podium { box-shadow: inset 0 0 0 2px var(--frame), 0 4px 0 var(--frame); }
.board li.p1 { background: var(--tile-sun); box-shadow: 0 5px 0 var(--tile-sun-2); }
.board li.p2 { background: var(--tile-sky); box-shadow: 0 5px 0 var(--tile-sky-2); }
.board li.p3 { background: var(--tile-mint); box-shadow: 0 5px 0 var(--tile-mint-2); }
.board li.podium .rank { color: var(--ink); }
@media (prefers-reduced-motion: no-preference) {
  .board li.podium { animation: podium-in 520ms cubic-bezier(.3,1.5,.5,1) both; }
  .board li.p2 { animation-delay: 90ms; }
  .board li.p3 { animation-delay: 180ms; }
  .board li.p1 .rank { animation: podium-glow 1.6s ease-in-out 600ms 2; }
}
@keyframes podium-in { 0% { transform: translateY(14px) scale(.96); opacity: 0; } 100% { transform: none; opacity: 1; } }
@keyframes podium-glow { 0%,100% { transform: scale(1); } 50% { transform: scale(1.25) rotate(-6deg); } }

/* ---- learning center: floating button, bottom sheet, motto (2026-09-23 CYC 追加) ---- */
main { padding-bottom: calc(88px + env(safe-area-inset-bottom)); }
.fab {
  position: fixed; z-index: 25;
  right: calc(16px + env(safe-area-inset-right)); bottom: calc(16px + env(safe-area-inset-bottom));
  width: 56px; height: 56px; border-radius: 50%; border: 0; padding: 0; cursor: pointer;
  display: grid; place-items: center; color: var(--ink);
  background: radial-gradient(circle at 35% 30%, color-mix(in srgb, var(--mint) 70%, white), var(--mint) 70%);
  box-shadow: 0 5px 0 var(--teal), 0 10px 20px rgba(22,33,58,.22);
  transition: transform 90ms, box-shadow 90ms;
  touch-action: manipulation;
}
.fab svg { fill: currentColor; }
.fab:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--teal), 0 4px 10px rgba(22,33,58,.2); }
@media (prefers-color-scheme: dark) { .fab { color: #121622; } }
/* hidden while a question or its feedback is up (focus on the word), and before boot */
body[data-screen=""] .fab, body[data-screen="S3"] .fab, body[data-screen="S4"] .fab, body[data-screen="S5"] .fab,
body[data-screen="S6"] .fab, body[data-screen="S7"] .fab,
body:has([data-testid="feedback"]:not([hidden])) .fab, body:has([data-testid="confirm-backdrop"]:not([hidden])) .fab, body:has([data-testid="notice-db-reload"]:not([hidden])) .fab { display: none; }
/* another tab changed the database: this overlay sits above everything, including the learning-center sheet */
.modal-backdrop.db-reload { z-index: 60; }

.center-backdrop {
  position: fixed; inset: 0; z-index: 40; background: rgba(18, 22, 34, 0.42);
  display: flex; align-items: flex-end; justify-content: center;
}
.center-sheet {
  width: 100%; max-width: 480px; max-height: 88vh; overflow-y: auto;
  background: var(--paper); color: var(--ink);
  border-radius: 28px 28px 0 0; box-shadow: inset 0 0 0 1.5px var(--frame), 0 -10px 30px rgba(22,33,58,.2);
  padding: 8px 16px calc(20px + env(safe-area-inset-bottom));
  touch-action: pan-x;
}
.center-sheet:focus { outline: none; }
.grabber { width: 40px; height: 5px; border-radius: 999px; background: #9AA1AE; margin: 4px auto 10px; }
.center-sheet h2 { margin: 0 4px 10px; font-size: var(--fs-body); font-weight: 900; color: var(--text-2); }
.center-list { background: var(--card); border-radius: 18px; box-shadow: inset 0 0 0 1.5px var(--frame); overflow: hidden; }
.center-row {
  font: inherit; width: 100%; min-height: 56px; border: 0; background: transparent; color: var(--ink);
  display: grid; grid-template-columns: 36px 1fr auto; align-items: center; gap: 12px;
  padding: 8px 14px; text-align: left; cursor: pointer;
}
.center-row + .center-row { border-top: 1px solid var(--paper-2); }
.center-row:active:not(:disabled) { background: var(--paper-2); }
.center-row:disabled { opacity: .45; cursor: default; }
.center-row .ico { width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; color: #16213A; }
.center-row[data-kind="cloud"] .ico { background: var(--tile-sky); }
.center-row[data-kind="board"] .ico { background: var(--yellow); }
.center-row[data-kind="records"] .ico { background: var(--mint); }
.center-row[data-kind="settings"] .ico { background: #E4DBFB; }
.center-row[data-kind="home"] .ico { background: var(--orange); }
@media (prefers-color-scheme: dark) { .center-row[data-kind="cloud"] .ico { background: #CFE3FF; } }
.center-row .txt { display: flex; flex-direction: column; line-height: 1.3; }
.center-row .txt b { font-weight: 800; font-size: var(--fs-body); }
.center-row .desc { font-size: var(--fs-small); color: var(--text-2); }
.center-row .chev { color: var(--text-2); font-size: 1.4em; }

.motto { display: none; margin: 18px auto 0; max-width: 420px; padding: 10px 12px; text-align: center; border-radius: 16px; cursor: default; user-select: none; -webkit-user-select: none; }
body[data-screen="S1"] .motto, body[data-screen="S9"] .motto, body[data-screen="S10"] .motto { display: block; }
.motto:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; }
.motto-en { font-family: var(--font-word); font-weight: 800; font-size: calc(var(--fs-body) * 1.02); color: var(--ink); line-height: 1.35; }
.motto-zh { margin-top: 2px; font-size: var(--fs-small); color: var(--text-2); }
/* pull the card up so the motto sits under it on the first screen */
body[data-screen="S1"] .screen:not([hidden]), body[data-screen="S9"] .screen:not([hidden]), body[data-screen="S10"] .screen:not([hidden]) {
  min-height: calc(100vh - 56px - 200px);
}


/* =====================================================================
   Home v3 (2026-09-24): first-run and 6-8 home adapted from the
   "小步冒險" design package (pages 01 and 02).
   ===================================================================== */
body[data-screen="S1"] .screen:not([hidden]) { background: transparent; border: 0; box-shadow: none; padding: 4px 2px 12px; backdrop-filter: none; }
.brand { font-family: var(--font-word); font-size: 34px; letter-spacing: -2px; font-weight: 900; position: relative; line-height: 1.12; padding: 0 17px 7px 0; display: inline-block; color: var(--ink); }
.brand::after { content: ""; position: absolute; height: 5px; width: 37px; background: #60C9B0; bottom: 0; left: 20px; border-radius: 100%; transform: rotate(-9deg); }
.brand i { position: absolute; right: 2px; top: 2px; width: 6px; height: 16px; background: #FFD43D; border-radius: 5px; transform: rotate(25deg); }
.brand i::after { content: ""; position: absolute; width: 6px; height: 12px; background: #FFD43D; left: 9px; top: 8px; border-radius: 5px; transform: rotate(35deg); }
.topbar:has(.brand) { justify-content: space-between; }
.kicker { font-size: 13px; letter-spacing: .12em; font-weight: 800; color: var(--text-2); text-align: center; }
.welcome-head { text-align: center; display: flex; flex-direction: column; gap: 8px; }
.welcome-head h1 { font-size: 1.6rem; line-height: 1.45; }
.accent { color: var(--primary); }
.underline { position: relative; white-space: nowrap; isolation: isolate; padding-inline: 2px; }
.underline::after { content: ""; position: absolute; left: 0; right: 0; height: 8px; bottom: 2px; background: #FFDC5E; border-radius: 50%; z-index: -1; transform: rotate(-3deg); }
.welcome-art { display: flex; justify-content: center; background: var(--tile-mint); border-radius: 32px 32px 70px 70px; position: relative; padding: 14px; }
.welcome-art img.guide { width: 170px; }
.welcome-art .spark { position: absolute; color: #A56C00; right: 16%; top: 26px; animation: twinkle 2.4s ease-in-out infinite; }
@keyframes twinkle { 0%,100% { transform: scale(1) rotate(0); opacity: 1; } 50% { transform: scale(1.18) rotate(12deg); opacity: .75; } }
.label { font-size: 15px; font-weight: 800; color: var(--text-2); margin-top: 4px; }
.age-choices { display: flex; flex-direction: column; gap: 12px; }
.btn.btn-age { flex-direction: row; justify-content: flex-start; gap: 14px; text-align: left; background: var(--card); color: var(--ink); min-height: 72px; padding: 10px 16px; box-shadow: inset 0 0 0 2px var(--frame-2), 0 5px 0 var(--frame-2); }
.btn.btn-age:active:not(:disabled) { transform: translateY(4px); box-shadow: inset 0 0 0 2px var(--frame-2), 0 1px 0 var(--frame-2); }
.btn-age .age-text { display: flex; flex-direction: column; flex: 1; line-height: 1.3; }
.btn-age .sub { color: var(--text-2); font-weight: 500; }
.btn-age > svg:last-child { color: var(--primary); flex-shrink: 0; }
.age-dot { width: 44px; height: 44px; border-radius: 14px; display: grid; place-items: center; flex-shrink: 0; color: var(--ink); }
.age-dot[data-band="6-8"] { background: var(--tile-sun); }
.age-dot[data-band="9-12"] { background: var(--tile-mint); }
.age-dot[data-band="13-18"] { background: var(--tile-sky); }
.footer-note { font-size: 12px; letter-spacing: .08em; color: var(--text-2); text-align: center; margin-top: 6px; }

.hello { font-size: 1.2rem; font-weight: 800; margin-top: 4px; }
.home-title { font-size: 1.75rem; line-height: 1.35; }
.hero { position: relative; height: 248px; margin: 0 -18px -2px; overflow: hidden; isolation: isolate; border-radius: 0; }
.hero .landscape { position: absolute; inset: 0; width: 100%; height: 100%; }
.hero img.guide { position: absolute; width: 239px; bottom: -6px; left: calc(50% - 122px); z-index: 2; }
.hero-label { position: absolute; right: 20px; top: 15px; font-size: 12px; line-height: 1.5; color: #183E4B; font-weight: 800; transform: rotate(-8deg); z-index: 3; background: #FFF7CB; padding: 6px 11px; border-radius: 9px; box-shadow: 0 3px 8px rgba(0,0,0,.08); }
.hero-star { position: absolute; right: 60px; bottom: 39px; color: #D59B00; z-index: 3; animation: twinkle 2.8s ease-in-out infinite; }
.mission { display: flex; align-items: center; gap: 13px; border: 1px solid var(--border); padding: 16px; border-radius: 21px; background: var(--card); box-shadow: 0 8px 20px rgba(22,33,58,.08); margin-top: -18px; z-index: 4; position: relative; }
.mission-icon { background: var(--tile-mint); color: var(--ink); width: 48px; height: 48px; border-radius: 15px; display: grid; place-items: center; flex-shrink: 0; }
.mission p { font-size: 14px; color: var(--text-2); }
.mission strong { font-size: 18px; }
@media (prefers-color-scheme: dark) { .hero .landscape { filter: brightness(.72) saturate(.9); } .hero-label { color: #183E4B; } }
