:root {
  color-scheme: light;
  --bg: #f5faf9; --card: #fff; --muted-bg: #e4f3f0; --text: #233b3e; --muted: #4d6366; --border: #d5e8e5;
  --accent: #0f6b63; --fill: #0f766e;
  --ok: #166534; --ok-bg: #e3f6e8; --bad: #a83232; --bad-bg: #fdecec;
  --shadow: 0 2px 10px #1f4d4812;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 18px/1.6 ui-rounded, -apple-system, system-ui, sans-serif; -webkit-tap-highlight-color: transparent; }
main { max-width: 560px; margin: 0 auto; padding: calc(16px + env(safe-area-inset-top)) calc(18px + env(safe-area-inset-right)) calc(110px + env(safe-area-inset-bottom)) calc(18px + env(safe-area-inset-left)); }
h1 { font-size: 28px; line-height: 1.25; margin: 4px 0 18px; text-wrap: balance; }
h2 { font-size: 19px; margin: 28px 0 10px; }
small { display: block; font-size: 15px; color: var(--muted); }
a { color: var(--accent); }
a, button { touch-action: manipulation; }
button { font: inherit; color: inherit; cursor: pointer; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
.muted { color: var(--muted); }
.eyebrow { margin: 8px 0 4px; font-size: 14px; font-weight: 700; color: var(--accent); }
.icon { flex: none; width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.back { display: inline-flex; align-items: center; gap: 4px; min-height: 44px; padding: 0 16px 0 8px; margin-bottom: 6px; border-radius: 99px; background: var(--card); font-weight: 600; text-decoration: none; }

.btn, .tile { display: flex; align-items: center; width: 100%; margin: 12px 0; border: 1.5px solid var(--border); border-radius: 18px; background: var(--card); color: var(--text); box-shadow: var(--shadow); text-decoration: none; transition: transform .15s ease-out, box-shadow .15s ease-out; }
.btn { justify-content: center; min-height: 56px; padding: 12px 18px; font-weight: 700; text-align: center; }
.btn:active:not(:disabled), .tile:active { transform: scale(.98); box-shadow: none; }
.btn:disabled { cursor: default; }
.primary { background: var(--fill); border-color: var(--fill); color: #fff; box-shadow: var(--shadow); }

.tile { gap: 14px; min-height: 76px; padding: 12px 14px; }
.tile strong { display: block; line-height: 1.35; }
.grow { flex: 1; min-width: 0; }
.badge { display: grid; place-items: center; flex: none; width: 50px; height: 50px; border-radius: 15px; background: var(--muted-bg); color: var(--accent); }
.tile.current { border-color: var(--fill); }
.tile.current .badge { background: var(--fill); color: #fff; }
.tile.done .badge { background: var(--ok-bg); color: var(--ok); }
.tile.locked { background: var(--bg); color: var(--muted); box-shadow: none; border-style: dashed; }
.tile.locked:active { transform: none; }
.tile.locked:hover { border-color: var(--border); }
.tile.done small { color: var(--ok); font-weight: 600; }

.hero { padding: 18px 20px; border-radius: 24px; background: var(--muted-bg); color: var(--text); }
.hero p { margin: 0; }
.hero strong { font-size: 32px; }
.bar { height: 10px; margin: 8px 0; overflow: hidden; border-radius: 99px; background: var(--muted-bg); }
.bar i { display: block; height: 100%; border-radius: inherit; background: var(--fill); }
.hero .bar { background: var(--card); }

.list { margin: 0; padding: 4px 18px; list-style: none; border-radius: 20px; background: var(--card); }
.list li { display: flex; flex-direction: column; padding: 12px 0; }
.list li + li { border-top: 1px solid var(--border); }
.split { display: flex; justify-content: space-between; gap: 12px; }
.note { padding: 14px 16px; border: 2px dashed var(--border); border-radius: 18px; color: var(--muted); }

.flash { display: grid; width: 100%; min-height: 320px; margin: 16px 0; padding: 0; border: 0; background: none; perspective: 1000px; }
.face { grid-area: 1 / 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; padding: 24px; border: 2px solid var(--border); border-radius: 28px; background: var(--card); box-shadow: var(--shadow); -webkit-backface-visibility: hidden; backface-visibility: hidden; transition: transform .35s ease, visibility .35s; }
.face strong { font-size: 40px; line-height: 1.25; }
.rear { visibility: hidden; transform: rotateY(-180deg); border-color: var(--fill); }
.rear strong { font-size: 30px; color: var(--accent); }
.flipped .front { visibility: hidden; transform: rotateY(180deg); }
.flipped .rear { visibility: visible; transform: none; }
.example { display: flex; align-items: center; gap: 8px; min-height: 44px; }
.example[data-say] { padding: 8px 16px; border-radius: 18px; background: var(--muted-bg); }
.example svg { flex: none; width: 24px; height: 24px; }
.row { display: flex; gap: 12px; }
/* Nút "Tiếp" luôn nằm ngay trên menu, không cần cuộn. */
.dock { position: sticky; bottom: calc(84px + env(safe-area-inset-bottom)); }

.question { margin: 14px 0 20px; padding: 24px 16px; border-radius: 24px; background: var(--muted-bg); text-align: center; }
.question h1 { margin: 0; font-size: 38px; }
.question p { margin: 0; }
.option { justify-content: space-between; gap: 12px; text-align: left; font-weight: 600; }
.ok { border-color: var(--ok); background: var(--ok-bg); box-shadow: none; }
.ok::after { content: "✓"; color: var(--ok); font-weight: 800; }
.bad { border-color: var(--bad); background: var(--bad-bg); box-shadow: none; }
.bad::after { content: "✗"; color: var(--bad); font-weight: 800; }
.option:disabled:not(.ok, .bad) { opacity: .55; box-shadow: none; }
.feedback { min-height: 1.5em; margin: 8px 0; text-align: center; font-weight: 700; }
.good { color: var(--ok); }
.wrong { color: var(--bad); }

.result { text-align: center; padding: 24px 0; }
.ring { display: grid; place-items: center; width: 170px; height: 170px; margin: 0 auto 20px; border-radius: 50%; background: conic-gradient(var(--ok) calc(var(--p) * 1%), var(--muted-bg) 0); }
.ring span { display: grid; place-items: center; width: 136px; height: 136px; border-radius: 50%; background: var(--bg); font-size: 36px; font-weight: 800; }

nav { position: fixed; inset: auto 0 0 0; display: flex; justify-content: center; gap: 8px; padding: 8px calc(12px + env(safe-area-inset-right)) calc(8px + env(safe-area-inset-bottom)) calc(12px + env(safe-area-inset-left)); background: var(--card); border-top: 1px solid var(--border); }
nav a { display: flex; flex: 1; flex-direction: column; align-items: center; max-width: 180px; min-height: 56px; padding: 5px 0; border-radius: 16px; color: var(--muted); font-size: 14px; font-weight: 700; text-decoration: none; }
nav a[aria-current] { background: var(--muted-bg); color: var(--accent); }

@media (hover: hover) { .tile:hover, .btn:hover:not(:disabled, .primary, .ok, .bad) { border-color: var(--fill); } }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
.spoken { align-items: center; gap: 12px; }
.list li.spoken { flex-direction: row; }
.say { display: inline-flex; align-items: center; justify-content: center; gap: 6px; flex: none; min-width: 48px; min-height: 48px; padding: 0 12px; border: 0; border-radius: 99px; background: var(--muted-bg); color: var(--accent); font-weight: 700; }
.question .say { margin-top: 8px; }
.listen-row { display: flex; justify-content: center; gap: 12px; }
input { width: 100%; min-height: 56px; margin-top: 4px; padding: 10px 16px; border: 2px solid var(--accent); border-radius: 18px; background: var(--card); color: var(--text); font: inherit; font-size: 20px; text-align: center; }
input[readonly] { border-color: var(--border); }
.sentence { margin: 0; font-size: 24px; font-weight: 700; line-height: 1.5; }
.answer { margin: 12px 0; padding: 14px 18px; border: 2px solid var(--border); border-radius: 18px; background: var(--card); overflow-wrap: anywhere; }
.answer p { margin: 8px 0; }
.answer p.spoken { display: flex; }
.answer > strong { font-size: 22px; }
.ok-box { border-color: var(--ok); background: var(--ok-bg); }
.ok-box > strong { color: var(--ok); }
.bad-box { border-color: var(--bad); background: var(--bad-bg); }
.bad-box > strong { color: var(--bad); }
