:root {
  --red: #E8423B; --red-d: #B8281F; --red-l: #FDE6E2;
  --gold: #FFC845; --gold-d: #D99A12; --gold-l: #FFF2CC;
  --jade: #2BB59A; --jade-d: #1B8B75; --jade-l: #D9F4EC;
  --ink: #3A1F1A; --ink-2: #7A5A52; --ink-3: #B49C94;
  --cream: #FFF4E0; --paper: #FFFAF3; --white: #fff;
  --line: #F0E2D0; --line-2: #E6D4BE;
  --t1: #2F7DE1; --t2: #1FA67A; --t3: #E08A00; --t4: #E8423B; --t0: #9A8A82;
  --r: 22px;
  --sh: 0 1px 0 rgba(58,31,26,.04), 0 10px 28px -14px rgba(58,31,26,.28);
  --sh-lg: 0 2px 0 rgba(58,31,26,.04), 0 24px 48px -20px rgba(58,31,26,.4);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --spring: cubic-bezier(.34, 1.4, .64, 1);
  --out: cubic-bezier(.22, 1, .36, 1);
  --smooth: cubic-bezier(.45, .05, .25, 1);
  font-family: "Be Vietnam Pro", system-ui, sans-serif;
  color: var(--ink);
  -webkit-tap-highlight-color: transparent;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; overscroll-behavior: none; }
body { background: #F1E3CF radial-gradient(circle at 20% 10%, #F8EBDA 0, transparent 40%), radial-gradient(circle at 80% 90%, #F6E2C8 0, transparent 40%); }
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; padding: 0; }
button:disabled { cursor: default; }
input { font: inherit; }
h1, h2, h3, p { margin: 0; }
[lang="zh"] { font-family: "Noto Sans SC", sans-serif; }

#app {
  position: relative; height: 100dvh; max-width: 480px; margin: 0 auto; overflow: hidden;
  background: var(--paper);
  background-image: radial-gradient(rgba(232,66,59,.05) 1.2px, transparent 1.4px);
  background-size: 22px 22px;
}
.screen { position: absolute; inset: 0; display: flex; flex-direction: column; visibility: hidden; opacity: 0; pointer-events: none; }
.screen.is-active { visibility: visible; opacity: 1; pointer-events: auto; }
.screen.tabbed { padding-bottom: calc(76px + var(--safe-b)); }
.scroll { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; overscroll-behavior: contain; }
.scroll::-webkit-scrollbar { display: none; }
.ic { width: 24px; height: 24px; flex: none; }
.ic.big { width: 44px; height: 44px; }

/* ---------- Chữ Hán có pinyin ---------- */
.hzr { display: inline-flex; align-items: flex-end; flex-wrap: wrap; gap: 0 .06em; font-family: "Noto Sans SC", sans-serif; font-weight: 700; line-height: 1; }
.hzr ruby { display: inline-flex; flex-direction: column-reverse; align-items: center; ruby-position: over; }
.hzr rt { display: block; font-family: "Be Vietnam Pro", sans-serif; font-size: .38em; font-weight: 700; line-height: 1.5; letter-spacing: .01em; transition: opacity .3s, transform .3s var(--out); }
.hzr .punct { padding-bottom: .02em; }
.hzr.xl { font-size: 58px; } .hzr.lg { font-size: 40px; } .hzr.md { font-size: 28px; } .hzr.sm { font-size: 22px; }
.t1 rt, .py.t1 { color: var(--t1); } .t2 rt, .py.t2 { color: var(--t2); } .t3 rt, .py.t3 { color: var(--t3); } .t4 rt, .py.t4 { color: var(--t4); } .t0 rt, .py.t0 { color: var(--t0); }
.py { font-weight: 800; }
.no-pinyin .hzr rt { opacity: 0; transform: translateY(4px); }

/* ---------- Linh vật, nhân vật, tranh ---------- */
.mascot { display: grid; place-items: center; }
.mascot svg { width: 100%; height: 100%; overflow: visible; }
.mascot-xl { width: 190px; height: 190px; } .mascot-lg { width: 150px; height: 150px; } .mascot-md { width: 92px; height: 92px; } .mascot-sm { width: 64px; height: 64px; flex: none; }
.mascot.fallback::before { content: "🥟"; font-size: 70%; }
.pose-idle #body, .pose-think #body, .pose-sleep #body { animation: bao-bob 2.6s var(--smooth) infinite; }
.pose-idle #arm-r { animation: bao-wave 1.6s var(--smooth) infinite; transform-origin: 20% 90%; }
.pose-happy #body, .pose-cheer #body { animation: bao-jump 1.2s var(--smooth) infinite; }
.pose-happy #arm-l, .pose-happy #arm-r, .pose-cheer #arm-r { animation: bao-wave 1s var(--smooth) infinite; }
.pose-sad svg { animation: bao-shake .55s var(--smooth) 2; }
.pose-sleep #eyes { animation: none; }
[data-art] svg { display: block; width: 100%; height: 100%; overflow: visible; }
.art-missing { visibility: hidden; }
.person { width: 100%; height: 100%; }
.pic { position: relative; display: grid; place-items: center; }
.pic svg { width: 100%; height: 100%; }
.pic-text { border-radius: 22px; background: var(--gold-l); box-shadow: inset 0 0 0 2px #F7E0A0; }
.pic-text span { font-size: 46px; font-weight: 700; color: var(--red-d); }

/* ---------- Nút ---------- */
.btn {
  position: relative; display: block; width: 100%; min-height: 56px; border-radius: 18px; font-weight: 800; font-size: 17px; letter-spacing: .02em;
  background: var(--white); color: var(--ink); box-shadow: 0 4px 0 var(--line-2), inset 0 0 0 2px var(--line);
  transition: transform .14s var(--out), box-shadow .14s var(--out), background .25s, color .25s; overflow: hidden;
}
.btn::after { content: ""; position: absolute; left: 14px; right: 14px; top: 7px; height: 7px; border-radius: 6px; background: rgba(255,255,255,.28); pointer-events: none; }
.btn:active:not(:disabled) { transform: translateY(4px); box-shadow: 0 0 0 var(--line-2), inset 0 0 0 2px var(--line); }
.btn-primary { background: var(--red); color: #fff; box-shadow: 0 5px 0 var(--red-d); }
.btn-primary:active:not(:disabled) { box-shadow: 0 0 0 var(--red-d); transform: translateY(5px); }
.btn:disabled { background: #EFE6DA; color: var(--ink-3); box-shadow: 0 5px 0 #E2D6C6; }
.btn:disabled::after { display: none; }
.btn-soft { min-height: 50px; font-size: 15px; }
.btn-soft.red { background: var(--red-l); color: var(--red-d); box-shadow: 0 4px 0 #F5C1BB; }
.btn-soft.gold { background: var(--gold-l); color: #8A5A00; box-shadow: 0 4px 0 #F3D98A; }
.btn-soft.jade { background: var(--jade-l); color: var(--jade-d); box-shadow: 0 4px 0 #A8E2D4; }
.icon-btn { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 12px; transition: transform .15s; }
.icon-btn:active { transform: scale(.88); }
.link-btn { align-self: center; color: var(--ink-3); font-weight: 700; font-size: 14px; padding: 8px; }

/* ---------- Màn chờ ---------- */
.splash { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  background: radial-gradient(circle at 50% 38%, #FFE7A8 0, var(--gold) 40%, #FFB238 100%); }
.logo { font-weight: 800; font-size: 46px; letter-spacing: .05em; color: var(--red);
  text-shadow: 0 3px 0 var(--red-d), 0 7px 0 rgba(58,31,26,.12); animation: logoIn .9s var(--spring) both .2s; }
.logo.small { font-size: 30px; text-align: center; animation: none; }
.tag { font-weight: 600; color: var(--ink-2); animation: fadeUp .6s var(--out) both .45s; }
.dots { display: flex; gap: 7px; margin-top: 24px; }
.dots i { width: 9px; height: 9px; border-radius: 50%; background: var(--red); animation: dot 1.1s infinite var(--smooth); }
.dots i:nth-child(2) { animation-delay: .15s; } .dots i:nth-child(3) { animation-delay: .3s; }
@keyframes dot { 0%,100% { transform: translateY(0); opacity: .4 } 50% { transform: translateY(-9px); opacity: 1 } }
@keyframes logoIn { from { transform: scale(.4) rotate(-8deg); opacity: 0 } to { transform: none; opacity: 1 } }
@keyframes fadeUp { from { transform: translateY(16px); opacity: 0 } to { transform: none; opacity: 1 } }
@keyframes pop { from { transform: scale(0); opacity: 0 } to { transform: none; opacity: 1 } }
@keyframes shake { 20%,60% { transform: translateX(-8px) } 40%,80% { transform: translateX(8px) } }
.shake { animation: shake .42s var(--smooth); }

/* ---------- Đăng nhập ---------- */
.login { flex: 1; overflow-y: auto; padding: calc(12px + var(--safe-t)) 20px calc(22px + var(--safe-b)); display: flex; flex-direction: column; gap: 14px; }
.login-hero { position: relative; flex: none; height: 250px; border-radius: 30px; overflow: hidden; background: #FFE7A8; box-shadow: var(--sh); }
.scene-art { position: absolute; inset: 0; }
.login-hero .scene-art { animation: sceneIn 1s var(--out) both; }
.login-hero .scene-art #people { display: none; }
.login-hero .person { position: absolute; z-index: 1; bottom: -6px; width: 96px; height: 154px; }
.hero-a { left: 21%; animation: slideInL .8s var(--spring) both .3s; }
.hero-b { right: 21%; animation: slideInR .8s var(--spring) both .45s; }
.hero-b svg { transform: scaleX(-1); }
.hero-bubble { position: absolute; z-index: 2; top: 14px; left: 50%; transform: translateX(-50%); background: #fff; border-radius: 16px;
  padding: 8px 14px; font-weight: 800; font-size: 14px; white-space: nowrap; box-shadow: var(--sh); animation: popC .55s var(--spring) both 1.1s; }
.login-hero .hero-bao { position: absolute; z-index: 2; width: 72px; height: 72px; right: 8px; bottom: -6px; animation: peek .9s var(--spring) both 1.2s; }
@keyframes popC { from { transform: translateX(-50%) scale(0); } }
@keyframes peek { from { transform: translateY(80px) rotate(12deg) } }
@keyframes sceneIn { from { transform: scale(1.12); opacity: 0 } }
@keyframes slideInL { from { transform: translateX(-70px); opacity: 0 } }
@keyframes slideInR { from { transform: translateX(70px); opacity: 0 } }
.seg { position: relative; display: grid; grid-template-columns: 1fr 1fr; background: #F1E5D4; border-radius: 16px; padding: 4px; }
.seg-btn { position: relative; z-index: 1; padding: 11px; font-weight: 700; color: var(--ink-2); transition: color .25s; }
.seg-btn.is-on { color: var(--ink); }
.seg-ink { position: absolute; top: 4px; bottom: 4px; left: 4px; width: calc(50% - 4px); background: #fff; border-radius: 12px; box-shadow: 0 2px 0 var(--line-2); transition: transform .45s var(--spring); }
.seg.right .seg-ink { transform: translateX(100%); }
.form { display: flex; flex-direction: column; gap: 12px; animation: fadeUp .4s var(--out); }
.field { display: flex; flex-direction: column; gap: 6px; font-weight: 700; font-size: 14px; }
.field input { height: 54px; border-radius: 16px; border: 2px solid var(--line); background: #fff; padding: 0 16px; font-size: 16px; outline: none; transition: border-color .2s, box-shadow .25s; }
.field input:focus { border-color: var(--red); box-shadow: 0 0 0 5px rgba(232,66,59,.13); }
.err { color: var(--red-d); font-weight: 600; font-size: 14px; }
.fine { color: var(--ink-3); font-size: 12.5px; text-align: center; }

/* ---------- Thanh trên trang chủ ---------- */
.topbar { position: relative; z-index: 3; display: flex; justify-content: space-between; align-items: center; gap: 6px;
  padding: calc(10px + var(--safe-t)) 12px 10px; background: rgba(255,250,243,.86); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border-bottom: 1.5px solid var(--line); }
.chip { display: flex; align-items: center; gap: 4px; padding: 6px 9px; border-radius: 14px; font-weight: 800; font-size: 15px; transition: transform .15s, background .2s; }
.chip:active { background: #F1E5D4; transform: scale(.94); }
.chip .ic { width: 26px; height: 26px; }
.chip.course { font-size: 14px; background: var(--red-l); color: var(--red-d); }
.bump { animation: bump .55s var(--spring); display: inline-block; }
@keyframes bump { 40% { transform: scale(1.5); color: var(--red) } }

/* ---------- Lộ trình ---------- */
.path { position: relative; padding: 14px 14px 80px; }
.unit-banner { --c: var(--red); --cd: var(--red-d); position: relative; display: flex; align-items: flex-end; justify-content: space-between; min-height: 132px; margin: 8px 0 14px;
  padding: 16px 8px 16px 18px; border-radius: 26px; background: var(--c); color: #fff; box-shadow: 0 6px 0 var(--cd), var(--sh); overflow: hidden; }
.unit-banner::before { content: ""; position: absolute; right: -40px; top: -50px; width: 170px; height: 170px; border-radius: 50%; border: 22px solid rgba(255,255,255,.14); }
.unit-banner::after { content: ""; position: absolute; left: -30px; bottom: -60px; width: 120px; height: 120px; border-radius: 50%; background: rgba(255,255,255,.08); }
.unit-banner.c-jade { --c: var(--jade); --cd: var(--jade-d); }
.unit-banner.c-gold { --c: #F5A623; --cd: #C77F0A; }
.ub-text { position: relative; z-index: 1; display: flex; flex-direction: column; gap: 4px; align-self: center; min-width: 0; }
.ub-text small { opacity: .9; font-weight: 700; font-size: 12.5px; letter-spacing: .02em; }
.ub-text h2 { font-size: 21px; font-weight: 800; line-height: 1.2; }
.ub-prog { width: 130px; height: 9px; border-radius: 6px; background: rgba(255,255,255,.28); overflow: hidden; margin-top: 6px; }
.ub-prog i { display: block; height: 100%; border-radius: 6px; background: #fff; transition: width .8s var(--out); }
.ub-count { font-size: 12px; font-weight: 700; opacity: .9; }
.unit-art { position: relative; z-index: 1; display: flex; align-items: flex-end; width: 124px; height: 124px; margin: -16px -2px -24px 0; flex: none; }
.unit-art .person { width: 62px; height: 100%; margin-left: -4px; }
.unit-art .person:nth-child(2) svg { transform: scaleX(-1); }
.lane { position: relative; display: flex; flex-direction: column; align-items: center; gap: 24px; padding: 42px 0 30px; }
.node { --c: var(--red); --cd: var(--red-d); position: relative; width: 78px; height: 72px; border-radius: 50%; display: grid; place-items: center;
  background: var(--c); box-shadow: 0 8px 0 var(--cd), 0 14px 18px -8px rgba(58,31,26,.4); transition: transform .16s var(--out), box-shadow .16s var(--out);
  animation: nodeIn .6s var(--spring) both; }
.node.c-jade { --c: var(--jade); --cd: var(--jade-d); } .node.c-gold { --c: #F5A623; --cd: #C77F0A; }
.node::after { content: ""; position: absolute; left: 14px; right: 14px; top: 8px; height: 14px; border-radius: 50%; background: rgba(255,255,255,.3); }
.node-in { display: grid; place-items: center; width: 52px; height: 52px; border-radius: 50%; background: rgba(255,255,255,.22); }
.node .ic { width: 36px; height: 36px; }
.node:active { transform: translateY(7px); box-shadow: 0 1px 0 var(--cd); }
.node.done { --c: var(--gold); --cd: var(--gold-d); }
.node.locked { --c: #E9DECF; --cd: #D5C7B4; box-shadow: 0 8px 0 var(--cd); }
.node.locked .ic { opacity: .45; filter: grayscale(1); }
.node.locked::after { display: none; }
.node.chest { width: 92px; } .node.chest, .node.chest.locked { background: none; box-shadow: none; }
.node.chest::after { display: none; } .node.chest .node-in { background: none; width: 80px; height: 80px; } .node.chest .ic { width: 74px; height: 74px; }
.node.chest.locked .ic { filter: grayscale(.6); opacity: .6; }
.node.trophy { width: 92px; height: 84px; }
.node.current { animation: nodeIn .6s var(--spring) both, nodeBob 2.4s var(--smooth) infinite .8s; }
.node.current::before { content: ""; position: absolute; inset: -12px; border-radius: 50%; border: 6px solid var(--c); opacity: .25; animation: ring 1.8s var(--out) infinite; }
@keyframes ring { from { transform: scale(.88); opacity: .45 } to { transform: scale(1.35); opacity: 0 } }
@keyframes nodeIn { from { transform: scale(0) } }
@keyframes nodeBob { 50% { transform: translateY(-4px) } }
.stars { position: absolute; bottom: -24px; font-size: 12px; letter-spacing: 1px; color: var(--gold-d); }
.start-tag { position: absolute; bottom: 100%; margin-bottom: 16px; left: 50%; transform: translateX(-50%);
  background: #fff; color: var(--c); font-weight: 800; padding: 8px 14px; border-radius: 14px; white-space: nowrap; box-shadow: var(--sh), inset 0 0 0 2px var(--line); animation: float 2s var(--smooth) infinite; }
.start-tag::after { content: ""; position: absolute; top: 100%; left: 50%; margin-left: -7px; border: 7px solid transparent; border-top-color: #fff; }
@keyframes float { 50% { transform: translate(-50%, -6px) } }
.deco { position: absolute; width: 78px; height: 78px; opacity: .95; pointer-events: none; animation: fadeUp .8s var(--out) both .3s; }
.deco.left { left: 2px; } .deco.right { right: 2px; }
.path-bao { position: absolute; width: 96px; height: 96px; pointer-events: none; }
.node-pop { --c: var(--red); --cd: var(--red-d); position: absolute; left: 16px; right: 16px; z-index: 5; padding: 18px; border-radius: 22px; background: var(--c); color: #fff;
  box-shadow: 0 6px 0 var(--cd), var(--sh-lg); transform-origin: var(--ax, 50%) 0; }
.node-pop.c-jade { --c: var(--jade); --cd: var(--jade-d); } .node-pop.c-gold { --c: #F5A623; --cd: #C77F0A; }
.node-pop::before { content: ""; position: absolute; top: -9px; left: var(--ax, 50%); margin-left: -9px; border: 9px solid transparent; border-top: 0; border-bottom-color: var(--c); }
.node-pop.open { animation: popDown .42s var(--spring); }
.node-pop h3 { font-size: 19px; font-weight: 800; }
.node-pop p { opacity: .92; margin: 4px 0 14px; }
.node-pop .btn { background: #fff; color: var(--c); box-shadow: 0 5px 0 rgba(0,0,0,.15); }
@keyframes popDown { from { transform: scale(.5); opacity: 0 } }

/* ---------- Thanh tab ---------- */
.tabbar { position: absolute; left: 0; right: 0; bottom: 0; z-index: 20; display: grid; grid-template-columns: repeat(4, 1fr);
  padding: 7px 8px calc(7px + var(--safe-b)); background: rgba(255,255,255,.92); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border-top: 1.5px solid var(--line); }
.tabbar button { position: relative; z-index: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 0; font-size: 11.5px; font-weight: 700; color: var(--ink-3); transition: color .3s; }
.tabbar button .ic { width: 30px; height: 30px; transition: transform .45s var(--spring), filter .3s; filter: grayscale(.85) opacity(.65); }
.tabbar button.is-on { color: var(--red); }
.tabbar button.is-on .ic { transform: translateY(-3px) scale(1.14); filter: none; }
.tab-ink { position: absolute; top: 7px; left: 8px; width: calc((100% - 16px) / 4); height: 56px; border-radius: 16px; background: var(--red-l); transition: transform .5s var(--spring); }

/* ---------- Bài học ---------- */
.lesson-top { display: flex; align-items: center; gap: 10px; padding: calc(12px + var(--safe-t)) 14px 8px; }
.bar { position: relative; flex: 1; height: 16px; border-radius: 10px; background: #EFE4D5; overflow: hidden; }
.bar span { position: absolute; inset: 0 auto 0 0; width: 0; border-radius: 10px; background: var(--jade); transition: width .7s var(--spring); }
.bar span::after { content: ""; position: absolute; left: 8px; right: 8px; top: 3px; height: 4px; border-radius: 4px; background: rgba(255,255,255,.45); }
.py-btn { display: flex; align-items: center; gap: 4px; height: 34px; padding: 0 10px; border-radius: 12px; background: var(--jade-l); color: var(--jade-d); font-weight: 800; font-size: 12px; transition: background .25s, color .25s, transform .15s; }
.py-btn span { font-size: 16px; }
.py-btn.off { background: #EFE6DA; color: var(--ink-3); }
.py-btn:active { transform: scale(.92); }
.hearts { display: flex; align-items: center; gap: 3px; font-weight: 800; color: var(--red); }
.hearts.lost { animation: shake .42s var(--smooth); }
.combo { position: absolute; z-index: 4; top: calc(54px + var(--safe-t)); left: 50%; transform: translateX(-50%); padding: 5px 12px; border-radius: 999px; background: var(--gold); color: var(--ink); font-weight: 800; font-size: 12.5px; animation: pop .45s var(--spring); }
.ex-wrap { position: relative; flex: 1; overflow: hidden auto; padding: 6px 18px 20px; scrollbar-width: none; }
.ex { display: flex; flex-direction: column; gap: 14px; min-height: 100%; will-change: transform, opacity; }
.ex.enter { animation: exIn .55s var(--out) both; }
.ex.leave { animation: exOut .36s var(--smooth) both; position: absolute; inset: 6px 18px 20px; pointer-events: none; }
@keyframes exIn { from { transform: translateX(56px) scale(.98); opacity: 0 } }
@keyframes exOut { to { transform: translateX(-56px) scale(.98); opacity: 0 } }
.ex h2 { font-size: 21px; font-weight: 800; }
.ex h2 .py { font-size: 18px; margin-left: 4px; }

.ex-head { display: flex; align-items: flex-end; gap: 6px; }
.head-person { width: 84px; height: 136px; flex: none; margin-bottom: -10px; animation: slideInL .6s var(--spring) both; }
.say-bubble { position: relative; flex: 1; padding: 12px 14px; border-radius: 18px 18px 18px 6px; background: #fff; box-shadow: var(--sh), inset 0 0 0 2px var(--line); display: flex; flex-direction: column; gap: 3px; animation: pop .45s var(--spring) both .2s; transform-origin: 0 100%; }
.say-bubble b { font-size: 17px; } .say-bubble span { font-size: 14px; color: var(--ink-2); font-weight: 500; }

.tone-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tone-card { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 12px 10px; border-radius: 20px; background: #fff; text-align: center;
  box-shadow: 0 4px 0 var(--line-2), inset 0 0 0 2px var(--line); transition: transform .2s var(--out), box-shadow .25s, background .25s; animation: fadeUp .45s var(--out) both; }
.tone-card:nth-child(2) { animation-delay: .06s } .tone-card:nth-child(3) { animation-delay: .12s } .tone-card:nth-child(4) { animation-delay: .18s }
.tone-card b { font-size: 26px; } .tone-card small { font-weight: 800; font-size: 12px; color: var(--ink-2); } .tone-card em { font-style: normal; font-size: 11.5px; color: var(--ink-3); line-height: 1.35; }
.tone-card.on { transform: translateY(-3px); background: #FFFCF7; box-shadow: 0 7px 0 var(--line-2), inset 0 0 0 2.5px currentColor; }
.tone-card.t1 { color: var(--t1) } .tone-card.t2 { color: var(--t2) } .tone-card.t3 { color: var(--t3) } .tone-card.t4 { color: var(--t4) }
.tone-curve { width: 76px; height: 54px; overflow: visible; }
.tone-curve .track { stroke: #EFE4D5; stroke-width: 1.5; stroke-dasharray: 3 4; fill: none; }
.tone-curve .curve { fill: none; stroke: currentColor; stroke-width: 6; stroke-linecap: round; stroke-dasharray: 1; stroke-dashoffset: 0; animation: draw .9s var(--smooth) both; }
.tone-curve .dot { fill: currentColor; }
.tone-curve.t1 { color: var(--t1) } .tone-curve.t2 { color: var(--t2) } .tone-curve.t3 { color: var(--t3) } .tone-curve.t4 { color: var(--t4) }
@keyframes draw { from { stroke-dashoffset: 1 } }
.tone-opt { display: flex; flex-direction: column; align-items: center; gap: 2px; text-align: center; }
.tone-opt b { font-size: 24px; }
.tone-opt .tone-curve { width: 60px; height: 42px; }

.sound-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
.sound-card { position: relative; display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 12px 6px 10px; border-radius: 18px; background: #fff;
  box-shadow: 0 4px 0 var(--line-2), inset 0 0 0 2px var(--line); transition: transform .2s var(--out), box-shadow .25s; animation: pop .45s var(--spring) both; }
.sound-card b { font-size: 34px; font-weight: 800; color: var(--red); line-height: 1.1; }
.sound-card small { font-size: 11px; color: var(--ink-2); font-weight: 600; line-height: 1.3; text-align: center; }
.sound-card .ic { width: 20px; height: 20px; opacity: .6; }
.sound-card.on { transform: translateY(-3px); box-shadow: 0 7px 0 var(--line-2), inset 0 0 0 2.5px var(--red); }
.sound-card:active { transform: translateY(3px); }

.listen-hero { display: flex; flex-direction: column; align-items: center; gap: 10px; margin: 6px 0; }
.speak { position: relative; width: 48px; height: 48px; display: grid; place-items: center; border-radius: 16px; background: var(--jade); box-shadow: 0 4px 0 var(--jade-d); transition: transform .14s var(--out), box-shadow .14s; flex: none; }
.speak:active { transform: translateY(4px); box-shadow: none; }
.speak .ic { width: 30px; height: 30px; }
.speak.sm { width: 40px; height: 40px; border-radius: 13px; } .speak.sm .ic { width: 24px; height: 24px; }
.speak.big { width: 96px; height: 96px; border-radius: 28px; box-shadow: 0 6px 0 var(--jade-d); } .speak.big .ic { width: 56px; height: 56px; }
.speak.huge { width: 130px; height: 130px; border-radius: 36px; box-shadow: 0 8px 0 var(--jade-d); } .speak.huge .ic { width: 74px; height: 74px; }
.speak.playing::before, .speak.playing::after { content: ""; position: absolute; inset: 0; border-radius: inherit; border: 3px solid var(--jade); animation: wave 1.1s var(--out) both; }
.speak.playing::after { animation-delay: .25s; }
@keyframes wave { from { transform: scale(1); opacity: .8 } to { transform: scale(1.5); opacity: 0 } }
.slow-btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 12px; background: var(--jade-l); color: var(--jade-d); font-weight: 800; font-size: 13.5px; transition: transform .14s; }
.slow-btn .ic { width: 20px; height: 20px; }
.slow-btn:active { transform: scale(.94); }

.opts { display: flex; flex-direction: column; gap: 10px; margin-top: auto; }
.opts.grid { display: grid; grid-template-columns: 1fr 1fr; }
.opt { position: relative; min-height: 60px; padding: 12px 16px; border-radius: 18px; background: #fff; text-align: left; font-weight: 700; font-size: 17px;
  box-shadow: 0 4px 0 var(--line-2), inset 0 0 0 2px var(--line); transition: transform .14s var(--out), background .25s, box-shadow .25s, opacity .3s;
  animation: fadeUp .45s var(--out) both; }
.opt:nth-child(2) { animation-delay: .05s } .opt:nth-child(3) { animation-delay: .1s } .opt:nth-child(4) { animation-delay: .15s } .opt:nth-child(5) { animation-delay: .2s }
.opt:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 1px 0 var(--line-2), inset 0 0 0 2px var(--line); }
.opt.sel { background: #EEF6FF; box-shadow: 0 4px 0 #B8D3F5, inset 0 0 0 2.5px var(--t1); transform: translateY(-1px); }
.opt.right { background: var(--jade-l); color: var(--jade-d); box-shadow: 0 4px 0 #9ED9CB, inset 0 0 0 2.5px var(--jade); animation: bounce .5s var(--spring); }
.opt.wrong { background: var(--red-l); color: var(--red-d); box-shadow: 0 4px 0 #F5B8B2, inset 0 0 0 2.5px var(--red); animation: shake .42s var(--smooth); }
.opt.gone { opacity: 0; transform: scale(.85); pointer-events: none; transition: opacity .35s, transform .35s var(--out); }
.opt:disabled { cursor: default; }
@keyframes bounce { 40% { transform: scale(1.05) translateY(-4px) } }
.big-py { text-align: center; font-size: 28px; }
.word-opt { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.word-opt small { color: var(--ink-3); font-weight: 600; font-size: 13px; }

.prompt-word { flex: 1; display: flex; align-items: center; justify-content: center; gap: 12px; min-height: 100px; }
.listen-hero { flex: 1; justify-content: center; }
.pic-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: auto; }
.pic-grid.n3 > :last-child { grid-column: 1 / -1; justify-self: center; width: calc(50% - 6px); }
.pic-opt { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 12px 8px 10px; text-align: center; }
.pic-opt .pic { width: 100%; height: clamp(96px, 17dvh, 140px); }
.pic-opt .pic[data-art^="people/"] svg { transform: scale(1.35) translateY(10%); }
.pic-opt .pic-text span { font-size: 40px; }
.pic-opt .cap { font-size: 14px; color: var(--ink-2); font-weight: 700; }
.hero-pic { position: relative; align-self: center; width: min(220px, 60vw); aspect-ratio: 1; border-radius: 30px; background: #fff; box-shadow: var(--sh), inset 0 0 0 2px var(--line); padding: 14px; animation: pop .55s var(--spring) both; }
.hero-pic .pic { width: 100%; height: 100%; }
.hero-mean { position: absolute; left: 50%; bottom: -14px; transform: translateX(-50%); padding: 5px 12px; border-radius: 10px; background: var(--ink); color: #fff; font-weight: 700; font-size: 13px; white-space: nowrap; }

.new-word { position: relative; margin: auto 0; padding: 18px 16px 18px; border-radius: 28px; background: #fff; box-shadow: var(--sh-lg), inset 0 0 0 2px var(--line);
  display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; animation: cardIn .7s var(--spring) both; }
@keyframes cardIn { from { transform: perspective(700px) rotateX(18deg) translateY(30px) scale(.94); opacity: 0 } }
.new-badge { position: absolute; top: -12px; left: 50%; transform: translateX(-50%); background: var(--gold); color: var(--ink); font-weight: 800; font-size: 12px; padding: 5px 12px; border-radius: 10px; box-shadow: 0 3px 0 var(--gold-d); }
.nw-stage { position: relative; width: 100%; height: 190px; border-radius: 22px; background: linear-gradient(180deg, var(--cream), #FFE9C2); overflow: hidden; display: flex; align-items: flex-end; justify-content: center; }
.nw-stage::before { content: ""; position: absolute; left: 50%; bottom: -60px; width: 240px; height: 120px; margin-left: -120px; border-radius: 50%; background: rgba(255,255,255,.55); }
.nw-pic { position: relative; height: 92%; aspect-ratio: 200/320; animation: pop .6s var(--spring) both .15s; }
.nw-pic[data-art^="pics/"] { aspect-ratio: 1; height: 80%; align-self: center; }
.nw-pic.pic-text { height: 120px; width: 120px; align-self: center; }
.nw-person { position: absolute; right: 8px; bottom: -14px; width: 78px; height: 126px; animation: slideInR .6s var(--spring) both .3s; }
.nw-stage:has(.nw-pic[data-art^="people/"]) .nw-person { display: none; }
.nw-word { margin-top: 4px; }
.nw-mean { font-size: 20px; font-weight: 800; color: var(--red); }
.nw-actions { display: flex; align-items: center; gap: 10px; }

.speak-card { display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: 22px; background: #fff; box-shadow: var(--sh), inset 0 0 0 2px var(--line); }
.speak-card .pic { width: 84px; height: 84px; flex: none; } .speak-card .pic[data-art^="people/"] { height: 100px; width: 64px; }
.speak-card > div:nth-child(2) { flex: 1; } .speak-card p { color: var(--ink-2); font-weight: 600; margin-top: 4px; }
.speak-card.glow { animation: glow 1s var(--out); }
@keyframes glow { 30% { box-shadow: 0 0 0 6px rgba(43,181,154,.35), inset 0 0 0 2px var(--jade); } }
.mic-zone { display: flex; flex-direction: column; align-items: center; gap: 12px; margin: auto 0; }
.mic { position: relative; width: 120px; height: 120px; border-radius: 50%; display: grid; place-items: center; background: var(--red); box-shadow: 0 8px 0 var(--red-d); transition: transform .15s var(--out), box-shadow .15s; }
.mic .ic { width: 64px; height: 64px; filter: brightness(0) invert(1); }
.mic:active { transform: translateY(6px); box-shadow: 0 2px 0 var(--red-d); }
.mic i { position: absolute; inset: 0; border-radius: 50%; border: 4px solid var(--red); opacity: 0; }
.mic.rec i { animation: wave 1.2s var(--out) infinite; } .mic.rec i + i { animation-delay: .4s; }
.mic.rec { background: var(--red-d); }
.mic-msg { text-align: center; color: var(--ink-2); font-weight: 600; max-width: 280px; }

.answer-line { min-height: 74px; border-bottom: 2px solid var(--line); display: flex; flex-wrap: wrap; gap: 8px; padding: 8px 0; align-content: flex-end; }
.answer-line + .answer-line { min-height: 0; }
.bank { display: flex; flex-wrap: wrap; justify-content: center; gap: 9px; margin-top: auto; }
.tile { min-width: 58px; min-height: 62px; padding: 4px 12px 6px; border-radius: 16px; background: #fff; display: inline-flex; align-items: flex-end; justify-content: center;
  box-shadow: 0 4px 0 var(--line-2), inset 0 0 0 2px var(--line); animation: pop .35s var(--spring) both; transition: transform .14s var(--out); }
.tile .hzr { font-size: 26px; }
.tile.used { visibility: hidden; }
.tile:active { transform: translateY(3px); }
.vi-sentence { display: flex; gap: 10px; align-items: center; }
.mini-person { width: 74px; height: 120px; flex: none; animation: slideInL .55s var(--spring) both; }
.bubble-s { position: relative; padding: 13px 15px; border-radius: 18px; background: #fff; box-shadow: var(--sh), inset 0 0 0 2px var(--line); font-weight: 700; font-size: 17px; animation: pop .45s var(--spring) both .2s; transform-origin: 0 50%; }
.bubble-s::before { content: ""; position: absolute; left: -8px; top: 20px; border: 8px solid transparent; border-right-color: #fff; border-left: 0; }
.match { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: auto; }
.match .col { display: flex; flex-direction: column; gap: 10px; }
.match .opt { text-align: center; display: flex; align-items: center; justify-content: center; min-height: 72px; }

.dlg-stage { position: relative; height: clamp(250px, 42dvh, 370px); border-radius: 26px; overflow: hidden; background: var(--cream); box-shadow: var(--sh), inset 0 0 0 2px var(--line); flex: none; }
.dlg-bg { position: absolute; inset: 0; }
.dlg-stage .person { position: absolute; bottom: -22px; width: 38%; max-width: 160px; height: 72%; }
.dlg-a { left: 4px; animation: slideInL .65s var(--spring) both .1s; }
.dlg-b { right: 4px; animation: slideInR .65s var(--spring) both .25s; }
.dlg-b svg { transform: scaleX(-1); }
.dlg-bubble { position: absolute; z-index: 3; max-width: 64%; padding: 8px 12px; border-radius: 18px; background: #fff; box-shadow: var(--sh), inset 0 0 0 2px var(--line);
  display: flex; flex-direction: column; gap: 2px; animation: pop .5s var(--spring) both .6s; }
.dlg-bubble small { color: var(--ink-2); font-weight: 600; font-size: 12.5px; }
.dlg-bubble.a { left: 12px; top: 12px; border-bottom-left-radius: 6px; padding-right: 54px; transform-origin: 0 100%; }
.dlg-bubble.b { right: 12px; top: 96px; border-bottom-right-radius: 6px; background: var(--jade-l); animation-delay: 0s; transform-origin: 100% 100%; }
.dlg-bubble .speak.sm { position: absolute; right: 8px; top: 50%; margin-top: -20px; }
.dlg-opt { display: flex; flex-direction: column; gap: 3px; }
.dlg-opt small { color: var(--ink-2); font-weight: 600; font-size: 13px; }

.write-box { position: relative; align-self: center; width: min(280px, 76vw); aspect-ratio: 1; border-radius: 26px; background: #fff; box-shadow: var(--sh), inset 0 0 0 2px var(--line); touch-action: none; }
.write-box svg.grid { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.write-box #hw { position: absolute; inset: 0; }
.write-tools { display: flex; gap: 10px; justify-content: center; }
.write-tools .btn { width: auto; min-height: 46px; padding: 0 16px; font-size: 14px; display: flex; align-items: center; gap: 6px; }
.write-tools .ic { width: 22px; height: 22px; }
.write-msg { text-align: center; color: var(--ink-2); font-weight: 600; min-height: 22px; }

.lesson-foot { padding: 12px 18px calc(16px + var(--safe-b)); border-top: 1.5px solid var(--line); background: rgba(255,250,243,.92); }
.sheet { position: absolute; left: 0; right: 0; bottom: 0; z-index: 8; padding: 18px 18px calc(18px + var(--safe-b)); border-radius: 28px 28px 0 0;
  display: flex; flex-direction: column; gap: 14px; animation: sheetUp .5s var(--spring); box-shadow: 0 -10px 30px -10px rgba(58,31,26,.25); }
.sheet.closing { animation: sheetDown .22s var(--smooth) forwards; }
.sheet.ok { background: #E3F7F0; color: var(--jade-d); }
.sheet.bad { background: #FFE9E5; color: var(--red-d); }
.sheet.ok .btn { background: var(--jade); color: #fff; box-shadow: 0 5px 0 var(--jade-d); }
.sheet.bad .btn { background: var(--red); color: #fff; box-shadow: 0 5px 0 var(--red-d); }
.sheet-row { display: flex; gap: 12px; align-items: center; }
.sheet-txt { flex: 1; min-width: 0; }
.sheet h3 { font-size: 22px; font-weight: 800; }
.sheet p { font-weight: 600; margin-top: 2px; }
@keyframes sheetUp { from { transform: translateY(100%) } }
@keyframes sheetDown { to { transform: translateY(100%) } }

/* ---------- Kết quả ---------- */
#confetti { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 3; }
.result { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; padding: 24px 20px calc(24px + var(--safe-b));
  background: radial-gradient(circle at 50% 28%, #FFE7A8, rgba(255,250,243,0) 62%); }
.result h1 { font-size: 27px; font-weight: 800; color: var(--red); animation: logoIn .7s var(--spring) both .3s; }
.result-art { position: relative; width: 100%; height: 210px; }
.result-art::before { content: ""; position: absolute; left: 50%; top: 46%; width: 260px; height: 260px; margin: -130px 0 0 -130px; border-radius: 50%;
  background: repeating-conic-gradient(rgba(255,200,69,.35) 0 10deg, transparent 10deg 20deg); animation: spin 18s linear infinite; mask: radial-gradient(circle, #000 30%, transparent 70%); -webkit-mask: radial-gradient(circle, #000 30%, transparent 70%); }
@keyframes spin { to { transform: rotate(360deg) } }
.crowd { position: absolute; inset: 0; display: flex; align-items: flex-end; justify-content: center; }
.crowd .person { width: 22%; height: 88%; margin: 0 -2%; animation: pop .55s var(--spring) both; }
.crowd .person:nth-child(1) { animation-delay: .15s; } .crowd .person:nth-child(2) { animation-delay: .25s; }
.crowd .person:nth-child(4) { animation-delay: .35s; } .crowd .person:nth-child(5) { animation-delay: .45s; }
.crowd .person:nth-child(2) svg #rig { animation-delay: -.25s; } .crowd .person:nth-child(4) svg #rig { animation-delay: -.5s; } .crowd .person:nth-child(5) svg #rig { animation-delay: -.75s; }
.crowd .result-bao { width: 24%; height: 60%; margin: 0 -1%; z-index: 2; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; width: 100%; }
.stats.grid2 { grid-template-columns: 1fr 1fr; padding: 0 16px; }
.stat { border-radius: 18px; padding: 10px; text-align: center; animation: pop .5s var(--spring) both; border: 2px solid; }
.stat:nth-child(2) { animation-delay: .1s } .stat:nth-child(3) { animation-delay: .2s } .stat:nth-child(4) { animation-delay: .3s }
.stat small { display: block; font-weight: 800; font-size: 12px; }
.stat b { display: block; font-size: 25px; font-weight: 800; color: var(--ink); }
.stat.gold { border-color: var(--gold); background: var(--gold-l); color: #8A5A00; }
.stat.jade { border-color: var(--jade); background: var(--jade-l); color: var(--jade-d); }
.stat.red { border-color: var(--red); background: var(--red-l); color: var(--red-d); }
.stat.ink { border-color: var(--ink-3); background: #F4ECE3; color: var(--ink-2); }
.streak-card { width: 100%; display: flex; gap: 12px; align-items: center; padding: 12px 14px; border-radius: 18px; background: #fff; box-shadow: var(--sh), inset 0 0 0 2px var(--line); animation: fadeUp .5s var(--out) both .5s; }
.streak-card b { display: block; } .streak-card small { color: var(--ink-2); }

/* ---------- Ôn tập ---------- */
.page-head { padding: calc(16px + var(--safe-t)) 18px 8px; display: flex; flex-direction: column; gap: 4px; }
.page-head h1 { font-size: 28px; font-weight: 800; }
.page-head p { color: var(--ink-2); font-weight: 600; }
.deck { position: relative; flex: 1; margin: 16px 28px 10px; perspective: 1100px; }
.card3d { position: absolute; inset: 0; transform-style: preserve-3d; transition: transform .7s var(--spring); cursor: pointer; touch-action: pan-y; }
.card3d.flip { transform: rotateY(180deg); }
.card3d .face { position: absolute; inset: 0; border-radius: 30px; backface-visibility: hidden; -webkit-backface-visibility: hidden; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 12px; background: #fff; box-shadow: var(--sh-lg), inset 0 0 0 2px var(--line); padding: 20px; text-align: center; }
.card3d .back { transform: rotateY(180deg); background: linear-gradient(180deg, #fff, var(--cream)); }
.card3d[data-lean="r"] .face { box-shadow: var(--sh-lg), inset 0 0 0 3px var(--jade); }
.card3d[data-lean="l"] .face { box-shadow: var(--sh-lg), inset 0 0 0 3px var(--red); }
.deck-pic { width: 60%; aspect-ratio: 1; max-height: 46%; } .deck-pic[data-art^="people/"] { aspect-ratio: 200/320; width: auto; height: 46%; }
.hz-only { font-size: 56px; font-weight: 700; }
.deck-mean { font-size: 22px; color: var(--red); }
.card3d .hint { position: absolute; bottom: 18px; color: var(--ink-3); font-size: 13px; font-weight: 600; }
.card3d.under { transform: translateY(calc(var(--d) * 14px)) scale(calc(1 - var(--d) * .05)); filter: brightness(calc(1 - var(--d) * .03)); pointer-events: none; transition: transform .5s var(--spring); }
.card3d.fly-left { transform: translateX(-150%) rotate(-26deg); opacity: 0; transition: transform .45s var(--smooth), opacity .45s; }
.card3d.fly-right { transform: translateX(150%) rotate(26deg); opacity: 0; transition: transform .45s var(--smooth), opacity .45s; }
.card3d.fly-up { transform: translateY(-130%) scale(.9); opacity: 0; transition: transform .45s var(--smooth), opacity .45s; }
.deck-actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; padding: 10px 18px 14px; }
.deck-empty { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; text-align: center; color: var(--ink-2); font-weight: 600; }

/* ---------- Từ điển ---------- */
.search { display: flex; align-items: center; gap: 8px; margin-top: 8px; height: 54px; padding: 0 14px; border-radius: 18px; background: #fff; box-shadow: var(--sh), inset 0 0 0 2px var(--line); transition: box-shadow .25s; }
.search:focus-within { box-shadow: inset 0 0 0 2px var(--red), 0 0 0 5px rgba(232,66,59,.13); }
.search input { flex: 1; border: 0; outline: none; background: none; font-size: 16px; }
.dict-list { list-style: none; margin: 0; padding: 8px 16px 20px; display: flex; flex-direction: column; gap: 10px; }
.dict-list li { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 20px; background: #fff; box-shadow: var(--sh), inset 0 0 0 2px var(--line); animation: fadeUp .35s var(--out) both; }
.dict-list li.empty { justify-content: center; color: var(--ink-3); font-weight: 600; padding: 20px; }
.dict-pic { width: 54px; height: 54px; flex: none; border-radius: 14px; background: var(--cream); overflow: hidden; }
.dict-pic[data-art^="people/"] svg { transform: scale(1.9) translateY(18%); }
.dict-pic.pic-text span { font-size: 26px; }
.dict-txt { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.dict-list .dv { color: var(--ink-2); font-size: 14px; font-weight: 600; }

/* ---------- Hồ sơ ---------- */
.prof-head { display: flex; align-items: center; gap: 14px; padding: calc(18px + var(--safe-t)) 18px 16px; }
.prof-head h1 { font-size: 24px; font-weight: 800; }
.prof-head p { color: var(--ink-2); font-size: 14px; }
.card { margin: 14px 16px 0; padding: 16px; border-radius: 22px; background: #fff; box-shadow: var(--sh), inset 0 0 0 2px var(--line); }
.card h3 { font-size: 16px; font-weight: 800; margin-bottom: 12px; }
.week { display: flex; align-items: flex-end; gap: 8px; height: 120px; }
.week div { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; height: 100%; justify-content: flex-end; font-size: 11px; font-weight: 700; color: var(--ink-3); }
.week i { width: 100%; border-radius: 8px 8px 4px 4px; background: var(--gold); transform-origin: bottom; animation: grow .8s var(--spring) both; }
.week div:last-child i { background: var(--red); }
@keyframes grow { from { transform: scaleY(0) } }
.card.list { padding: 4px 0; margin-bottom: 20px; }
.row { display: flex; justify-content: space-between; align-items: center; width: 100%; padding: 15px 16px; font-weight: 700; border-bottom: 1.5px solid #F4ECE2; cursor: pointer; }
.row:last-child { border: 0; } .row span { color: var(--ink-3); }
.row.danger { color: var(--red); }
.row:active { background: #FBF4EA; }
.switch { appearance: none; -webkit-appearance: none; width: 48px; height: 28px; border-radius: 999px; background: #E6D8C4; position: relative; margin: 0; cursor: pointer; transition: background .25s; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: 0 2px 4px rgba(0,0,0,.15); transition: transform .35s var(--spring); }
.switch:checked { background: var(--jade); } .switch:checked::after { transform: translateX(20px); }
.streak-scene { display: flex; gap: 14px; align-items: center; background: #2E2350; color: #FFF4E0; box-shadow: var(--sh); overflow: hidden; }
.streak-scene h3 { margin-bottom: 4px; color: var(--gold); }
.streak-scene p { font-size: 14px; opacity: .9; }
.night { position: relative; width: 96px; height: 120px; flex: none; margin: -8px 0 -24px; }
.night .moon { position: absolute; left: 4px; top: 6px; width: 26px; height: 26px; border-radius: 50%; background: #FFE9A8; box-shadow: 6px -4px 0 0 #2E2350 inset; }
.night .person { position: absolute; inset: 8px 0 0 18px; }

.toast { position: absolute; left: 50%; top: calc(14px + var(--safe-t)); z-index: 50; transform: translate(-50%, -130%); padding: 10px 16px; border-radius: 14px;
  background: var(--ink); color: #fff; font-weight: 700; font-size: 14px; transition: transform .45s var(--spring); white-space: nowrap; box-shadow: var(--sh-lg); }
.toast.on { transform: translate(-50%, 0); }

/* Chuyển cảnh dự phòng */
.screen.fallback-in { animation: fbIn .45s var(--out) both; }
@keyframes fbIn { from { opacity: 0; transform: scale(1.04) } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
@media (min-width: 520px) {
  body { display: flex; align-items: center; }
  #app { height: min(100dvh, 880px); border-radius: 38px; box-shadow: 0 0 0 10px #2A1E1C, 0 40px 80px rgba(58,31,26,.35); }
}

/* ---------- Hộp thoại phủ màn hình (hết tim, đổi mật khẩu) ---------- */
.overlay { position: absolute; inset: 0; z-index: 30; display: flex; align-items: center; justify-content: center; padding: 20px; background: rgba(42,30,28,.45); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); animation: fadeIn .3s var(--out); }
@keyframes fadeIn { from { opacity: 0 } }
.nh-card { width: 100%; max-width: 380px; display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 22px 20px 16px; border-radius: 28px; background: var(--paper); box-shadow: var(--sh-lg); text-align: center; }
.nh-card.open, .overlay:not([hidden]) .nh-card { animation: popDown .5s var(--spring); }
.nh-card h2 { font-size: 24px; font-weight: 800; color: var(--red); }
.nh-card p { color: var(--ink-2); font-weight: 600; }
.nh-card .field { width: 100%; text-align: left; }

/* ---------- Bảng xếp hạng ---------- */
.board { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.board li { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 14px; background: #FBF5EC; font-weight: 700; }
.board li.me { background: var(--jade-l); box-shadow: inset 0 0 0 2px var(--jade); }
.board li.empty { justify-content: center; color: var(--ink-3); }
.board b { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank { width: 28px; height: 28px; flex: none; display: grid; place-items: center; border-radius: 50%; background: #EFE4D5; font-size: 13px; font-weight: 800; color: var(--ink-2); }
.rank.r1 { background: var(--gold); color: var(--ink); } .rank.r2 { background: #D9DEE3; color: var(--ink); } .rank.r3 { background: #F0B58A; color: var(--ink); }
.b-streak { font-size: 13px; } .b-xp { color: var(--gold-d); font-size: 14px; }

/* ---------- Quản trị ---------- */
.add-user { margin-bottom: 12px; }
.add-user .field input { height: 48px; }
.code-box { margin-bottom: 12px; padding: 12px 14px; border-radius: 16px; background: var(--gold-l); box-shadow: inset 0 0 0 2px #F3D98A; font-weight: 600; line-height: 1.5; animation: pop .45s var(--spring); }
.code-box code { display: inline-block; margin: 4px 0; padding: 4px 8px; border-radius: 8px; background: #fff; font-size: 16px; font-weight: 800; letter-spacing: .04em; user-select: all; }
.code-box small { color: var(--ink-2); }
.admin-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.admin-list li { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-radius: 14px; background: #FBF5EC; }
.admin-list li > div { flex: 1; min-width: 0; }
.admin-list small { color: var(--ink-2); font-weight: 600; }
.admin-list li.empty { justify-content: center; color: var(--ink-3); font-weight: 600; }
.mini { padding: 7px 10px; border-radius: 10px; background: #fff; box-shadow: inset 0 0 0 1.5px var(--line-2); font-weight: 700; font-size: 12.5px; white-space: nowrap; }
.mini.danger { color: var(--red-d); }
.mini:active { transform: scale(.94); }
.tag-admin { padding: 4px 8px; border-radius: 8px; background: var(--red-l); color: var(--red-d); font-weight: 800; font-size: 12px; }
.week b { font-size: 10px; color: var(--gold-d); min-height: 12px; }

/* Hộp xác nhận chung luôn nằm trên cùng */
.overlay.top { z-index: 60; }
/* Câu hỏi "chọn từ tiếng Trung": hiện nghĩa tiếng Việt to ở giữa */
.prompt-vi { flex: 1; display: flex; align-items: center; justify-content: center; min-height: 120px; }
.prompt-vi span { padding: 16px 22px; border-radius: 22px; background: #fff; box-shadow: var(--sh), inset 0 0 0 2px var(--line); font-size: 24px; font-weight: 800; text-align: center; animation: pop .5s var(--spring) both; }
.prompt-word .hzr.xl { font-size: 64px; }

/* ---------- Cửa sổ chọn cấp HSK ---------- */
.chip.course { cursor: pointer; }
.chip.course::after { content: "▾"; margin-left: 2px; font-size: 11px; opacity: .7; }
.course-card { align-items: stretch; text-align: left; gap: 8px; max-height: 86dvh; overflow-y: auto; }
.course-head { display: flex; align-items: center; justify-content: space-between; }
.course-card h2 { color: var(--ink); font-size: 22px; }
.course-card > p { font-size: 14px; }
.course-list { list-style: none; margin: 4px 0 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.course-list .empty { text-align: center; color: var(--ink-3); font-weight: 600; padding: 16px; }
.lvl { position: relative; width: 100%; display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: 20px; background: #fff; text-align: left;
  box-shadow: 0 4px 0 var(--line-2), inset 0 0 0 2px var(--line); transition: transform .15s var(--out), box-shadow .2s; animation: fadeUp .4s var(--out) both; }
.course-list li:nth-child(2) .lvl { animation-delay: .05s } .course-list li:nth-child(3) .lvl { animation-delay: .1s } .course-list li:nth-child(4) .lvl { animation-delay: .15s } .course-list li:nth-child(5) .lvl { animation-delay: .2s }
.lvl:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 1px 0 var(--line-2), inset 0 0 0 2px var(--line); }
.lvl.cur { box-shadow: 0 4px 0 #9ED9CB, inset 0 0 0 2.5px var(--jade); background: #F3FBF8; }
.lvl.locked { opacity: .62; background: #F7F1E8; }
.lvl-badge { width: 52px; height: 52px; flex: none; display: grid; place-items: center; border-radius: 16px; background: var(--red); color: #fff; font-size: 24px; font-weight: 800; box-shadow: 0 4px 0 var(--red-d); }
.lvl:nth-of-type(1) .lvl-badge { background: var(--red); }
.course-list li:nth-child(2) .lvl-badge { background: #F5A623; box-shadow: 0 4px 0 #C77F0A; }
.course-list li:nth-child(3) .lvl-badge { background: var(--jade); box-shadow: 0 4px 0 var(--jade-d); }
.course-list li:nth-child(4) .lvl-badge { background: #6C63D9; box-shadow: 0 4px 0 #4A43A8; }
.course-list li:nth-child(5) .lvl-badge { background: #3A1F1A; box-shadow: 0 4px 0 #000; }
.lvl.locked .lvl-badge { background: #E2D6C6 !important; box-shadow: 0 4px 0 #CFC1AE !important; }
.lvl-badge .ic { width: 26px; height: 26px; }
.lvl-txt { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.lvl-txt b { font-size: 18px; } .lvl-txt small { color: var(--ink-2); font-weight: 600; font-size: 12.5px; }
.lvl-bar { display: block; height: 7px; border-radius: 4px; background: #EFE4D5; overflow: hidden; }
.lvl-bar em { display: block; height: 100%; border-radius: 4px; background: var(--jade); transition: width .8s var(--out); }
.lvl-cur { position: absolute; top: -8px; right: 12px; padding: 3px 9px; border-radius: 8px; background: var(--jade); color: #fff; font-size: 11px; font-weight: 800; }
