/* style.css - Phúc Sinh Academy: Học tiếng Anh.
   Hệ design token: navy + vàng thương hiệu, chữ lớn dễ đọc, tương phản AA, focus rõ, hỗ trợ prefers-reduced-motion. */
:root {
  --bg: #f4f6fb; --card: #ffffff; --text: #17202f; --muted: #4a566b; --line: #d6dcea;
  --pbg: #14306f; --pfg: #ffffff; --pbg2: #1d3b8b; --gold: #f2b705; --goldtxt: #2a2000;
  --ok: #0f6b37; --okbg: #e3f5ea; --bad: #a3231b; --badbg: #fdebea; --warnbg: #fff6dc; --warn: #6b4a00; --sel: #e6edfd;
  --r-sm: 10px; --r: 16px; --r-lg: 22px;
  --sh1: 0 1px 2px rgba(20,48,111,.08), 0 2px 8px rgba(20,48,111,.06);
  --sh2: 0 4px 18px rgba(20,48,111,.14);
  --fs: 18px; --rare: #1d6fd6; --epic: #7c3aed;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1320; --card: #182033; --text: #eaeef7; --muted: #aeb8cc; --line: #2c3750;
    --pbg: #8fb0ff; --pfg: #0a1126; --pbg2: #6f95f5; --goldtxt: #2a2000;
    --ok: #6fe0a0; --okbg: #12301f; --bad: #ff9c94; --badbg: #3a1a18; --warnbg: #3a2f10; --warn: #ffd98a; --sel: #23305a;
    --sh1: 0 1px 2px rgba(0,0,0,.4); --sh2: 0 4px 18px rgba(0,0,0,.5); --rare: #7db3ff; --epic: #c4a5ff;
  }
}
* { box-sizing: border-box; }
html { font-size: var(--fs); -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif; line-height: 1.55; padding-bottom: 78px; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5rem; letter-spacing: -.01em; }
h1 { font-size: 1.5rem; } h2 { font-size: 1.2rem; } h3 { font-size: 1.05rem; }
h2.sec { margin: 1.4rem 0 .6rem; }
p { margin: 0 0 .7rem; } ul, ol { margin: 0 0 .7rem; padding-left: 1.3rem; }
hr { border: 0; border-top: 1px solid var(--line); margin: 1rem 0; }
a { color: var(--pbg2); }
@media (prefers-color-scheme: dark) { a { color: var(--pbg); } }
a.back { text-decoration: none; font-weight: 600; }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; border-radius: 6px; }
.skip { position: absolute; left: -999px; top: 0; background: var(--pbg); color: var(--pfg); padding: .5rem 1rem; z-index: 100; }
.skip:focus { left: 0; }
.vh { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); font-size: .92rem; }
.center { text-align: center; }
.wrong-t { color: var(--bad); font-weight: 700; } .wrong-t[class*="lbl"], .mis .wrong-t { text-decoration: line-through; }
p.wrong-t { text-decoration: none; }
.right-t { color: var(--ok); font-weight: 700; }
.lbl { font-size: .75rem; font-weight: 800; text-transform: uppercase; letter-spacing: .04em; }
.lbl-s { font-size: .78rem; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: .6rem 0 .3rem; }

/* ---- Khung trang ---- */
.shell { display: block; }
.side { display: none; }
.top { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; gap: .5rem; padding: .5rem .8rem; background: var(--pbg); color: var(--pfg); box-shadow: var(--sh1); }
.brand { display: flex; align-items: center; gap: .55rem; color: inherit; text-decoration: none; font-size: .95rem; line-height: 1.15; }
.brand img { border-radius: 9px; } .brand small { display: block; font-size: .72rem; opacity: .85; }
.topstats { display: flex; gap: .3rem; flex-wrap: wrap; justify-content: flex-end; align-items: center; }
.pill { display: inline-flex; align-items: center; gap: .25rem; font-size: .78rem; background: rgba(255,255,255,.16); color: var(--pfg); padding: .12rem .55rem; border-radius: 99px; text-decoration: none; border: 1px solid rgba(255,255,255,.3); }
@media (prefers-color-scheme: dark) { .pill { background: rgba(0,0,0,.2); border-color: rgba(0,0,0,.3); } }
.pill.dark { background: var(--sel); color: var(--text); border-color: var(--line); }
.pill:empty { display: none; }
.usermini { display: inline-flex; border-radius: 50%; background: #fff; }
.usermini .uinfo { display: none; }
main { max-width: 820px; margin: 0 auto; padding: 1rem .9rem 1.5rem; outline: none; }
main.enter { animation: pagein .28s ease both; }
@keyframes pagein { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 1rem; margin-bottom: .9rem; box-shadow: var(--sh1); }
.loading { display: flex; align-items: center; gap: .7rem; }
.spinner { width: 20px; height: 20px; border: 3px solid var(--line); border-top-color: var(--pbg2); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.row { display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; }
.row.between { justify-content: space-between; } .row.center { justify-content: center; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: .6rem; }
body.anon .tabs, body.anon .side, body.anon .topstats .pill, body.anon .usermini { display: none; }
body.anon { padding-bottom: 1rem; }

/* ---- Nút ---- */
button, .btn { font: inherit; cursor: pointer; border-radius: 12px; border: 2px solid var(--line); background: var(--card); color: var(--text); padding: .6rem 1rem; min-height: 46px; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: .4rem; text-align: center; transition: transform .12s, box-shadow .12s, border-color .12s; }
button:hover, .btn:hover { border-color: var(--pbg2); box-shadow: var(--sh1); }
button:active, .btn:active { transform: translateY(1px); }
button.primary, .btn.primary { background: var(--pbg); color: var(--pfg); border-color: var(--pbg); font-weight: 700; }
button.gold, .btn.gold { background: var(--gold); color: var(--goldtxt); border-color: var(--gold); font-weight: 700; }
button.big, .btn.big { width: 100%; min-height: 56px; font-size: 1.1rem; margin-top: .4rem; }
button.sm, .btn.sm { min-height: 38px; padding: .3rem .8rem; font-size: .9rem; }
button:disabled { opacity: .55; cursor: not-allowed; }
button.link { border: none; background: none; color: var(--pbg2); padding: .3rem; min-height: 0; text-decoration: underline; box-shadow: none; }
button.on { background: var(--pbg); color: var(--pfg); border-color: var(--pbg); }
button.danger { color: var(--bad); border-color: var(--bad); }
.spk { min-height: 40px; min-width: 40px; padding: .3rem; border-radius: 99px; color: var(--pbg2); }
.spk.lg { min-height: 54px; min-width: 54px; }

/* ---- Điều hướng ---- */
.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: grid; grid-template-columns: repeat(5, 1fr); background: var(--card); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); box-shadow: 0 -2px 10px rgba(20,48,111,.08); }
.tabs a { text-align: center; padding: .75rem .1rem; color: var(--muted); text-decoration: none; font-size: .82rem; font-weight: 700; }
.tabs a.on { color: var(--pbg2); box-shadow: inset 0 3px 0 var(--pbg2); }
@media (prefers-color-scheme: dark) { .tabs a.on { color: var(--pbg); box-shadow: inset 0 3px 0 var(--pbg); } }
.badge { background: var(--bad); color: #fff; border-radius: 99px; font-size: .7rem; padding: 0 .4rem; margin-left: .25rem; }
@media (prefers-color-scheme: dark) { .badge { background: #ff6b60; color: #200; } }
.toast { position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%) translateY(10px); background: var(--text); color: var(--bg); padding: .65rem 1rem; border-radius: 12px; z-index: 50; max-width: 92%; opacity: 0; pointer-events: none; transition: opacity .25s, transform .25s; box-shadow: var(--sh2); }
.toast.show { opacity: 1; transform: translateX(-50%); }

@media (min-width: 960px) {
  body { padding-bottom: 0; }
  .shell { display: grid; grid-template-columns: 264px 1fr; min-height: 100vh; }
  .side { display: flex; flex-direction: column; gap: 1rem; position: sticky; top: 0; height: 100vh; padding: 1rem .8rem; background: var(--pbg); color: var(--pfg); }
  .side .brand { padding: .3rem .4rem; font-size: 1.05rem; }
  .sidenav { display: flex; flex-direction: column; gap: .15rem; }
  .sidenav a { color: var(--pfg); text-decoration: none; padding: .55rem .8rem; border-radius: 10px; font-weight: 600; opacity: .92; }
  .sidenav a:hover { background: rgba(255,255,255,.12); opacity: 1; }
  .sidenav a.on { background: var(--gold); color: var(--goldtxt); opacity: 1; }
  .usercard { margin-top: auto; display: flex; align-items: center; gap: .6rem; padding: .6rem; border-radius: 12px; background: rgba(255,255,255,.12); color: var(--pfg); text-decoration: none; }
  .usercard svg { background: #fff; border-radius: 50%; }
  .top .brand { display: none; }
  .top { background: var(--bg); color: var(--text); box-shadow: none; justify-content: flex-end; padding: .7rem 1.2rem; }
  .top .pill { background: var(--card); color: var(--text); border-color: var(--line); }
  .top .usermini { display: none; }
  .tabs { display: none; }
  main { padding: 1rem 1.4rem 2rem; max-width: 880px; margin: 0; }
  :root { --fs: 19px; }
  .toast { bottom: 24px; }
}
.uinfo { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.uname { font-size: .95rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 150px; }
.utitle { font-size: .75rem; opacity: .85; }
.usermini svg, .usercard svg { flex: 0 0 auto; }

/* ---- Thanh tiến độ ---- */
.bar { height: 12px; background: var(--line); border-radius: 99px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--ok); border-radius: 99px; transition: width .4s ease; }
.bar.gold > i { background: var(--gold); }

/* ---- Trang chủ ---- */
.hero { display: flex; gap: 1rem; align-items: center; background: linear-gradient(135deg, var(--sel), var(--card)); border-left: 6px solid var(--gold); }
.hero h1 { margin-bottom: .3rem; font-size: 1.35rem; } .hero p { margin-bottom: .2rem; }
.hero-av svg { border-radius: 50%; background: #fff; box-shadow: var(--sh1); }
.focus { border: 2px solid var(--gold); }
.quick { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: .5rem; margin-bottom: .9rem; }
.qk { display: block; text-align: center; padding: .7rem .4rem; background: var(--card); border: 1px solid var(--line); border-radius: var(--r-sm); text-decoration: none; color: var(--text); font-weight: 700; box-shadow: var(--sh1); }
.qk:hover { border-color: var(--pbg2); }
.guide .steps { padding-left: 0; list-style: none; } .guide .steps li { margin-bottom: .5rem; }
.quest-mini .row { margin-top: .5rem; }
.note { background: var(--sel); border-left: 5px solid var(--pbg2); padding: .6rem .9rem; border-radius: 8px; margin: .6rem 0; font-size: .95rem; }
.note.warn { background: var(--warnbg); border-left-color: var(--gold); color: var(--text); }
.level h2 { margin-top: 1.2rem; }
.path { display: flex; flex-direction: column; gap: .7rem; }
.unit { display: flex; gap: .8rem; align-items: center; background: var(--card); border: 2px solid var(--line); border-radius: var(--r); padding: .8rem; text-decoration: none; color: var(--text); box-shadow: var(--sh1); transition: transform .15s, border-color .15s; }
.unit:nth-child(even) { margin-left: 1.2rem; } .unit:nth-child(odd) { margin-right: 1.2rem; }
.unit:hover { border-color: var(--pbg2); transform: translateY(-2px); }
.unit.rec { border-color: var(--gold); box-shadow: 0 0 0 2px var(--gold); }
.unit.done { border-color: var(--ok); }
.unit .num { flex: 0 0 auto; width: 46px; height: 46px; border-radius: 50%; background: var(--pbg); color: var(--pfg); display: grid; place-items: center; font-weight: 800; }
.unit.done .num { background: var(--ok); color: var(--card); }
.unit .info { flex: 1; min-width: 0; } .unit .t { font-weight: 700; }
.tag { display: inline-block; font-size: .75rem; padding: .05rem .5rem; border-radius: 99px; background: var(--sel); color: var(--text); margin-right: .3rem; }
.tag.gold { background: var(--gold); color: var(--goldtxt); font-weight: 700; }
.tag.rare { background: var(--rare); color: #fff; } .tag.epic { background: var(--epic); color: #fff; }
@media (prefers-color-scheme: dark) { .tag.rare, .tag.epic { color: #0a1126; } }
.step { display: flex; justify-content: space-between; align-items: center; gap: .6rem; padding: .9rem 1rem; border: 2px solid var(--line); border-radius: var(--r); background: var(--card); color: var(--text); text-decoration: none; margin-bottom: .6rem; font-weight: 600; box-shadow: var(--sh1); }
.step:hover { border-color: var(--pbg2); } .step.ok { border-color: var(--ok); }

/* ---- Ngữ pháp, từ vựng ---- */
.formula { background: var(--sel); border-left: 5px solid var(--pbg2); padding: .6rem .9rem; border-radius: 8px; font-weight: 600; margin: .5rem 0; }
.formula div + div { margin-top: .25rem; }
.ex { display: flex; gap: .4rem; align-items: flex-start; padding: .4rem 0; border-bottom: 1px dashed var(--line); }
.ex .en { font-weight: 700; } .ex .vi { color: var(--muted); font-size: .92rem; }
.mis { border: 1px solid var(--line); border-radius: 10px; padding: .6rem .8rem; margin-bottom: .5rem; }
.word { font-size: 1.25rem; font-weight: 800; } .word.sm { font-size: 1.05rem; }
.ipa { color: var(--muted); font-family: "Segoe UI", Arial, sans-serif; }
.vcard { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: .8rem 1rem; margin-bottom: .6rem; box-shadow: var(--sh1); }

/* ---- Bài tập ---- */
.sess-head, .examhead { display: flex; align-items: center; gap: .7rem; margin-bottom: 1rem; }
.sess-head .bar { flex: 1; }
.examhead { justify-content: space-between; margin-bottom: .6rem; flex-wrap: wrap; }
.timer { font-variant-numeric: tabular-nums; font-weight: 800; background: var(--sel); padding: .1rem .6rem; border-radius: 8px; }
.timer.low { background: var(--badbg); color: var(--bad); }
.prompt { font-size: .85rem; font-weight: 700; color: var(--muted); margin-bottom: .4rem; }
.q { font-size: 1.3rem; font-weight: 700; margin-bottom: 1rem; }
.opts { display: grid; gap: .6rem; }
.opt { justify-content: flex-start; text-align: left; font-size: 1.05rem; }
.opt .optnum { width: 26px; height: 26px; border-radius: 6px; border: 2px solid var(--line); display: inline-grid; place-items: center; font-size: .8rem; flex: 0 0 auto; }
.opt.sel { background: var(--sel); border-color: var(--pbg2); }
.opts button:disabled { opacity: 1; }
.opt.right { background: var(--okbg); border-color: var(--ok); } .opt.wrong { background: var(--badbg); border-color: var(--bad); }
input.fill, input.txt, textarea.txt, select.txt { font: inherit; font-size: 1.1rem; padding: .45rem .7rem; border: 2px solid var(--line); border-radius: 10px; background: var(--card); color: var(--text); }
input.fill { min-width: 7ch; width: 12ch; max-width: 100%; }
input.txt, textarea.txt, select.txt { width: 100%; } .txt.sm { width: auto; max-width: 100%; font-size: 1rem; }
input:focus, textarea:focus, select:focus { border-color: var(--pbg2); outline: none; box-shadow: 0 0 0 3px var(--gold); }
.answerarea { min-height: 62px; border-bottom: 2px solid var(--line); padding: .4rem 0; display: flex; flex-wrap: wrap; gap: .45rem; margin-bottom: .9rem; border-top: 2px solid var(--line); }
.bank { display: flex; flex-wrap: wrap; gap: .45rem; min-height: 50px; }
.chip { min-height: 44px; padding: .4rem .8rem; border-radius: 10px; }
.feedback { border-radius: var(--r); padding: .8rem 1rem; margin-top: 1rem; border: 2px solid; }
.feedback.ok { background: var(--okbg); border-color: var(--ok); } .feedback.bad { background: var(--badbg); border-color: var(--bad); }
.feedback .ft { font-weight: 800; font-size: 1.05rem; } .feedback.ok .ft { color: var(--ok); } .feedback.bad .ft { color: var(--bad); }
.match { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; } .match .col { display: grid; gap: .5rem; align-content: start; }
.match button { min-height: 52px; font-size: 1rem; }
.match button.sel { background: var(--sel); border-color: var(--pbg2); }
.match button.right { background: var(--okbg); border-color: var(--ok); opacity: 1; } .match button.wrong { background: var(--badbg); border-color: var(--bad); }
.matchsel .mrow { display: grid; grid-template-columns: 1fr auto 1.4fr; gap: .5rem; align-items: center; margin-bottom: .5rem; }
.score { font-size: 2.6rem; font-weight: 800; color: var(--pbg2); line-height: 1.1; } .score.sm { font-size: 1.8rem; }
@media (prefers-color-scheme: dark) { .score { color: var(--pbg); } }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: .5rem; margin: .8rem 0; }
.tile { background: var(--sel); border-radius: var(--r-sm); padding: .6rem .3rem; text-align: center; } .tile b { display: block; font-size: 1.25rem; } .tile span { display: block; }
.wl { border-left: 4px solid var(--bad); padding: .3rem .8rem; margin-bottom: .7rem; }
.wl.okc { border-left-color: var(--ok); }
.msg { min-height: 1.4rem; margin: .4rem 0; font-weight: 600; } .msg.bad { color: var(--bad); } .msg.ok { color: var(--ok); }

/* ---- Đánh giá ---- */
.stars { display: flex; gap: .2rem; margin: .4rem 0; }
.star { border: none; background: none; color: var(--line); padding: .1rem; min-height: 44px; min-width: 44px; box-shadow: none; }
.star.on { color: var(--gold); } .star:hover { color: var(--gold); box-shadow: none; }
.star svg { width: 34px; height: 34px; }
.seg { display: grid; grid-template-columns: repeat(auto-fit, minmax(86px, 1fr)); gap: .5rem; }
.seg button.on { background: var(--pbg); color: var(--pfg); border-color: var(--pbg); font-weight: 700; }

/* ---- Ôn tập, tiến độ ---- */
.flash { text-align: center; padding: 1.6rem 1rem; } .flash .word { font-size: 2rem; }
.grades { display: grid; grid-template-columns: repeat(4, 1fr); gap: .45rem; margin-top: 1rem; }
.grades button { flex-direction: column; font-size: .95rem; padding: .5rem .2rem; } .grades small { font-size: .72rem; opacity: .85; }
.stat { text-align: center; padding: .7rem .3rem; } .stat b { display: block; font-size: 1.6rem; }
.chart { width: 100%; height: auto; } .chart text { fill: var(--muted); font-size: 11px; font-family: system-ui, sans-serif; }
.chart rect.bg { fill: var(--line); } .chart rect.v { fill: var(--pbg2); }
.badges { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; }
.bdg { border: 2px solid var(--line); border-radius: 12px; padding: .6rem; font-size: .88rem; }
.bdg.got { border-color: var(--gold); background: var(--sel); } .bdg.lock { opacity: .65; }

/* ---- Tài khoản ---- */
.authwrap { width: 100%; max-width: 560px; margin: 0 auto; }
.authhead { text-align: center; margin-bottom: 1rem; } .authhead img { border-radius: 14px; box-shadow: var(--sh2); margin-bottom: .5rem; }
.field { margin-bottom: .9rem; } .field label { display: block; font-weight: 700; margin-bottom: .25rem; } .hint { margin-top: .2rem; }
.avpick { display: grid; grid-template-columns: repeat(4, 1fr); gap: .5rem; justify-items: stretch; }
.avpick button { padding: .3rem; min-height: 0; border-radius: 14px; } .avpick button.on { border-color: var(--gold); box-shadow: 0 0 0 3px var(--gold); background: var(--sel); color: var(--text); }
.chips { display: flex; flex-wrap: wrap; gap: .5rem; }
.chipuser { text-align: left; padding: .4rem .7rem; justify-content: flex-start; }
.code { font-family: ui-monospace, Consolas, monospace; font-size: 1.35rem; font-weight: 800; letter-spacing: .08em; background: var(--sel); border: 2px dashed var(--pbg2); border-radius: 12px; padding: .8rem; margin-bottom: .8rem; word-break: break-all; user-select: all; }
.check { display: flex; gap: .5rem; align-items: flex-start; margin: .6rem 0; cursor: pointer; } .check input { width: 22px; height: 22px; margin-top: .15rem; }
.empty { text-align: center; } .empty-ic { color: var(--muted); }
.empty h2 { margin-top: .4rem; }

/* ---- Kiểm tra ---- */
.stepper { display: flex; gap: .3rem; flex-wrap: wrap; margin-bottom: .8rem; font-size: .78rem; }
.stepper span { padding: .15rem .6rem; border-radius: 99px; background: var(--line); color: var(--muted); font-weight: 700; }
.stepper .past { background: var(--okbg); color: var(--ok); } .stepper .now { background: var(--pbg); color: var(--pfg); }
.modes { display: grid; gap: .8rem; } @media (min-width: 700px) { .modes { grid-template-columns: 1fr 1fr; } }
.mode h2 { margin-bottom: .3rem; }
.rules li { margin-bottom: .35rem; }
.passage { background: var(--sel); border-left: 5px solid var(--pbg2); border-radius: 8px; padding: .7rem .9rem; margin-bottom: .9rem; }
.passage p { margin: 0; }
.qcard { margin-top: .8rem; }
#qgrid { display: flex; flex-wrap: wrap; gap: .35rem; }
.qn { min-width: 44px; min-height: 44px; padding: 0; font-weight: 700; }
.qn.done { background: var(--okbg); border-color: var(--ok); } .qn.flag { box-shadow: inset 0 0 0 3px var(--gold); } .qn.cur { outline: 3px solid var(--pbg2); outline-offset: 1px; }
.sect { width: 100%; margin-top: .5rem; }
.levelnote { background: var(--sel); border-radius: 10px; padding: .7rem .9rem; margin-top: .6rem; text-align: left; }
.radar { width: 100%; max-width: 380px; height: auto; display: block; margin: 0 auto; }
.radar text { fill: var(--text); font-size: 11px; font-family: system-ui, sans-serif; }
.radar .ring { fill: none; stroke: var(--line); stroke-width: 1; } .radar .axis { stroke: var(--line); stroke-width: 1; }
.radar .poly.cur { fill: rgba(29,59,139,.28); stroke: var(--pbg2); stroke-width: 2.5; } .radar .poly.prev { fill: none; stroke: var(--muted); stroke-width: 2; stroke-dasharray: 5 4; }
.radar .dot { fill: var(--pbg2); }
@media (prefers-color-scheme: dark) { .radar .poly.cur { fill: rgba(143,176,255,.3); } }
.tbl { width: 100%; border-collapse: collapse; margin-top: .6rem; } .tbl th, .tbl td { text-align: left; padding: .4rem .5rem; border-bottom: 1px solid var(--line); }

/* ---- Thưởng, kho ---- */
.chestwrap { padding: .5rem; } .chest .lid { transform-origin: 14px 46px; transition: transform .7s cubic-bezier(.3,1.4,.5,1); } .chest.open .lid { transform: rotate(-58deg); }
.rwgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: .6rem; margin-top: 1rem; }
.rw { border: 2px solid var(--line); border-radius: var(--r); padding: .7rem .4rem; display: flex; flex-direction: column; align-items: center; gap: .25rem; background: var(--card); animation: pop .5s cubic-bezier(.3,1.5,.5,1) both; }
.rw.rare { border-color: var(--rare); } .rw.epic { border-color: var(--epic); box-shadow: 0 0 14px rgba(124,58,237,.35); }
@keyframes pop { from { opacity: 0; transform: scale(.5) translateY(14px); } to { opacity: 1; transform: none; } }
.notes { text-align: left; }
.vgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .7rem; }
.vitem { border: 2px solid var(--line); border-radius: var(--r); padding: .7rem .5rem; display: flex; flex-direction: column; align-items: center; text-align: center; gap: .25rem; background: var(--card); }
.vitem.rare { border-color: var(--rare); } .vitem.epic { border-color: var(--epic); }
.vitem.locked { opacity: .55; filter: grayscale(.9); } .vitem.equipped { box-shadow: 0 0 0 3px var(--gold); }
.vic { min-height: 64px; display: grid; place-items: center; }

/* ---- Luyện nói, nhiệm vụ ---- */
.wchips { display: flex; flex-wrap: wrap; gap: .4rem; margin: .6rem 0; }
.wchip { padding: .25rem .6rem; border-radius: 10px; font-weight: 700; border: 2px solid; display: inline-flex; flex-direction: column; align-items: center; line-height: 1.2; }
.wchip small { font-size: .65rem; font-weight: 600; }
.wchip.ok { background: var(--okbg); border-color: var(--ok); color: var(--ok); }
.wchip.close { background: var(--warnbg); border-color: var(--gold); color: var(--warn); }
.wchip.wrong { background: var(--badbg); border-color: var(--bad); color: var(--bad); }
.wchip.missing { background: var(--line); border-color: var(--muted); color: var(--muted); text-decoration: line-through; }
.listening { color: var(--pbg2); font-weight: 700; animation: blink 1.2s infinite; } @keyframes blink { 50% { opacity: .45; } }
.speakres { display: flex; gap: .8rem; align-items: center; flex-wrap: wrap; }
.pairgrid { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem; } .pw { background: var(--sel); border-radius: var(--r-sm); padding: .6rem; }
.quest { display: flex; gap: .7rem; align-items: center; justify-content: space-between; padding: .7rem 0; border-bottom: 1px dashed var(--line); } .quest .qt { flex: 1; min-width: 0; } .quest.claimed { opacity: .65; } .quest .bar { margin: .3rem 0; }

/* ---- In báo cáo ---- */
@media print {
  body { background: #fff; color: #000; padding: 0; }
  .top, .side, .tabs, .toast, .noprint, .skip { display: none !important; }
  .shell { display: block; } main { max-width: none; padding: 0; } .card { box-shadow: none; border: 1px solid #999; break-inside: avoid; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; scroll-behavior: auto !important; } }
@media (max-width: 420px) { .grid3 { grid-template-columns: 1fr 1fr; } .pairgrid { grid-template-columns: 1fr; } .match { gap: .4rem; } .hero { flex-direction: column; text-align: center; } .unit:nth-child(even) { margin-left: .4rem; } .unit:nth-child(odd) { margin-right: .4rem; } }

/* ---- Đồng bộ, xếp hạng, đồng ý dữ liệu (chế độ máy chủ) ---- */
#st-sync[data-state="synced"] { background: rgba(60,200,120,.25); }
#st-sync[data-state="offline"], #st-sync[data-state="auth"], #st-sync[data-state="error"] { background: var(--gold); color: var(--goldtxt); border-color: var(--gold); }
.tbl tr.me td { font-weight: 700; background: var(--sel); }
.note.consent ul { padding-left: 1.1rem; margin: .4rem 0; }
.syncline { font-weight: 600; }
code { background: var(--sel); padding: 0 .35rem; border-radius: 6px; }

/* ---- Màn chưa đăng nhập: NGUYÊN NHÂN GỐC lỗi cột hẹp lệch trái ----
   Ở màn hình >= 960px, .shell là lưới 2 cột (264px + 1fr) dành cho thanh bên. Khi chưa đăng nhập thanh bên bị ẩn
   (display:none) nên .col rơi vào cột đầu 264px. Sửa: chưa đăng nhập thì .shell là khối thường, nội dung căn giữa. */
body.anon .shell { display: block; min-height: 0; }
body.anon .top { display: none; }
body.anon main { max-width: 640px; margin: 0 auto; padding: 1.5rem 1rem 2.5rem; }
body.anon .authwrap .card { box-shadow: var(--sh2); }
body.anon .authwrap form.card { padding: 1.2rem 1.2rem 1.4rem; }
.avpick button { min-width: 0; padding: .25rem; }
.avpick svg { width: 100%; max-width: 46px; height: auto; display: block; margin: 0 auto; }
@media (min-width: 520px) { .avpick { grid-template-columns: repeat(8, 1fr); gap: .35rem; } }
.chips { gap: .5rem; } .chipuser { flex: 1 1 200px; min-width: 0; }
.authwrap .row.center { justify-content: center; }

/* ---- Logo thương hiệu (vàng kim, nền trong suốt) ---- */
.logo-hero { display: block; margin: 0 auto .6rem; height: 128px; width: auto; max-width: 70vw; object-fit: contain; border-radius: 0; box-shadow: none; filter: drop-shadow(0 4px 10px rgba(20,48,111,.25)); }
.logo-hero.lg { height: 160px; }
.authhead img.logo-hero { border-radius: 0; box-shadow: none; margin-bottom: .6rem; }
.brand .logo-mark { height: 40px; width: auto; border-radius: 0; filter: drop-shadow(0 1px 4px rgba(0,0,0,.35)); }
.brand-side { flex-direction: column; align-items: center; justify-content: center; gap: .3rem; text-align: center; padding: .4rem 0 .2rem; }
.logo-side { width: 112px; height: auto; display: block; border-radius: 0; filter: drop-shadow(0 2px 8px rgba(0,0,0,.35)); }
.brand-side small { font-size: .78rem; opacity: .9; letter-spacing: .04em; }
.logo-welcome { height: 84px; width: auto; flex: 0 0 auto; filter: drop-shadow(0 3px 8px rgba(20,48,111,.25)); }
.hero-new { flex-wrap: wrap; justify-content: center; text-align: center; }
.hero-new .hero-tx { flex: 1 1 260px; }
.splash { flex-direction: column; justify-content: center; text-align: center; padding: 2rem 1rem; gap: 1rem; }
.splash > div { display: flex; align-items: center; justify-content: center; gap: .6rem; }
.logo-splash { height: 138px; width: auto; filter: drop-shadow(0 4px 10px rgba(20,48,111,.25)); animation: splashin .6s ease both; }
@keyframes splashin { from { opacity: 0; transform: scale(.92); } to { opacity: 1; transform: none; } }
@media (prefers-color-scheme: dark) { .logo-hero, .logo-welcome, .logo-splash { filter: drop-shadow(0 4px 14px rgba(0,0,0,.55)); } }
@media (max-width: 420px) { .logo-hero { height: 104px; } .logo-hero.lg { height: 128px; } body.anon main { padding: 1rem .75rem 2rem; } }
.about ul { padding-left: 1.1rem; } .about li { margin-bottom: .35rem; }

/* ---- Thanh bên/thanh đầu luôn nền navy đậm để logo vàng nổi (cả chế độ tối) ---- */
.side { --pfg: #ffffff; background: #14306f; color: #ffffff; }
@media (max-width: 959px) { .top { --pfg: #ffffff; background: #14306f; color: #ffffff; } }
@media (prefers-color-scheme: dark) { .side { background: #0f2255; } }
@media (prefers-color-scheme: dark) and (max-width: 959px) { .top { background: #0f2255; } }
@media (max-width: 520px) { .top .brand span { display: none; } }
.hero-new .hero-av { display: none; }
@media (prefers-color-scheme: dark) { .logo-hero, .logo-welcome, .logo-splash { filter: none; } }
