/* ============================================================
   Địa Lý Vui — học địa lý Việt Nam & thế giới qua bài học ngắn.
   Thương hiệu: tím (Việt Nam) pha xanh lá (Thế giới), nền sáng mặc định.
   ============================================================ */

/* ---------- 1. TOKEN ---------- */
:root {
  --vn:        #4C1D6B;
  --vn-ink:    #3D1755;
  --vn-soft:   #F1E9FE;
  --world:     #8DAE1E;
  --world-ink: #5E7714;
  --world-soft:#EEF3DA;
  --pink:      #E0449E;
  --pink-ink:  #B8207A;
  --pink-soft: #FCE7F5;

  --brand:      var(--vn);
  --brand-ink:  var(--vn-ink);
  --brand-soft: var(--vn-soft);
  --on-brand:   #FFFFFF;
  --grad: linear-gradient(135deg, var(--vn), var(--world));

  --ok:          #15803D;
  --ok-soft:     #E6F8EC;
  --ok-ink:      #14532D;
  --bad:         #B91C1C;
  --bad-soft:    #FDECEC;
  --bad-ink:     #8B1A1E;
  --amber:       #A65209;
  --amber-soft:  #FDF1DC;
  --flame:       #C2410C;
  --heart:       #DB2777;
  --xp:          #A65209;

  --bg:          #D8C3F0;
  --fg:          #1C1730;
  --card:        #FFFFFF;
  --muted:       #EDE9F9;
  --muted-fg:    #5C5872;
  --line:        #E1DBF3;
  --line-hi:     #C2B4E8;
  --sky-1:       #B892E8;
  --sky-2:       #D8C3F0;

  --sh-1: 0 1px 2px rgba(28,23,48,.06);
  --sh-2: 0 4px 14px rgba(28,23,48,.10);
  --sh-3: 0 12px 30px rgba(28,23,48,.16);

  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px;
  --s5: 24px; --s6: 32px; --s7: 48px; --s8: 64px;

  --r1: 10px; --r2: 14px; --r3: 20px; --r4: 26px; --rf: 999px;
  --e: cubic-bezier(.22,.8,.32,1);
  --t1: 140ms; --t2: 220ms; --t3: 340ms;

  --gut: 16px;
  --shell: 640px;
  --ic: 24px;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --vn:        #A78BFA;
  --vn-ink:    #C4B5FD;
  --vn-soft:   #2C2050;
  --world:     #B7D444;
  --world-ink: #D3E97A;
  --world-soft:#28300F;
  --pink:      #F472B6;
  --pink-ink:  #F9A8D4;
  --pink-soft: #3A1230;

  --ok:          #22C55E;
  --ok-soft:     #10321F;
  --ok-ink:      #86EFAC;
  --bad:         #F0555A;
  --bad-soft:    #3D161C;
  --bad-ink:     #FCA5A5;
  --amber:       #FBBF24;
  --amber-soft:  #3A2A10;
  --flame:       #FF9A4D;
  --heart:       #FB7185;
  --xp:          #FBBF24;

  --bg:          #100C1E;
  --fg:          #EFEAFB;
  --card:        #1B1630;
  --muted:       #262048;
  --muted-fg:    #B3ABD1;
  --line:        #30295A;
  --line-hi:     #453A78;
  --sky-1:       #2A2154;
  --sky-2:       #142A22;

  --sh-1: 0 1px 2px rgba(0,0,0,.5);
  --sh-2: 0 4px 14px rgba(0,0,0,.55);
  --sh-3: 0 12px 30px rgba(0,0,0,.65);
  color-scheme: dark;
}

/* ---------- 2. NỀN ---------- */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100dvh;
  background: var(--bg); color: var(--fg);
  font-family: "Nunito", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 16px; line-height: 1.5; font-weight: 600;
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}
h1, h2, h3 { margin: 0; font-weight: 900; letter-spacing: -.015em; line-height: 1.22; }
p { margin: 0; }
ul, ol { list-style: none; margin: 0; padding: 0; }
button, input, textarea { font: inherit; color: inherit; }
button { background: none; border: 0; cursor: pointer; touch-action: manipulation; }
button[disabled] { cursor: not-allowed; }
[hidden] { display: none !important; }

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; border-radius: var(--r1); }
svg[viewBox="0 0 24 24"], .ic, .ic-sm { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.ic { width: var(--ic); height: var(--ic); display: block; flex: none; }
.ic-sm { width: 18px; height: 18px; display: block; flex: none; }
.sub { color: var(--muted-fg); font-size: .92rem; font-weight: 600; }
.mt { margin-top: var(--s3); }
.mb { margin-bottom: var(--s4); }
.view-title { font-size: 1.5rem; margin: var(--s2) 0 var(--s3); }
.view { animation: in var(--t2) var(--e) both; }
@keyframes in { from { opacity: 0; transform: translateY(6px); } }

/* ---------- 3. KHUNG ---------- */
.app { display: flex; justify-content: center; min-height: 100dvh; }
.main { flex: 1; min-width: 0; max-width: var(--shell); display: flex; flex-direction: column; }
.content { flex: 1; outline: none; padding: 0 var(--gut) calc(88px + env(safe-area-inset-bottom)); }

/* thanh dieu huong ben, chi hien tren man rong */
.rail { display: none; }
@media (min-width: 900px) {
  .app { gap: var(--s5); }
  .rail {
    display: flex; flex-direction: column; align-items: center; gap: var(--s2);
    width: 92px; flex: none; padding: var(--s5) 0; position: sticky; top: 0; height: 100dvh;
  }
  .rail-brand { width: 44px; height: 44px; border-radius: var(--r2); background: var(--vn); position: relative;
    color: #fff; display: grid; place-items: center; margin-bottom: var(--s4); }
.rail-brand::after { content: ""; position: absolute; top: -4px; right: -4px; width: 12px; height: 12px;
  border-radius: 50%; background: var(--pink); box-shadow: 0 0 0 2px var(--bg); }
  .rail-btn { display: flex; flex-direction: column; align-items: center; gap: 4px;
    width: 76px; padding: var(--s2) 0; border-radius: var(--r2); color: var(--muted-fg);
    font-size: .74rem; font-weight: 800; }
  .rail-btn[aria-current="page"] { background: var(--brand-soft); color: var(--brand-ink); }
  .rail-btn:active { opacity: .7; }
  .tabbar { display: none; }
  .content { padding-bottom: var(--s6); }
}

/* ---------- 4. THANH TRÊN ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: var(--s2);
  padding: calc(var(--s3) + env(safe-area-inset-top)) var(--s4) var(--s3);
  background: linear-gradient(180deg, var(--sky-1), var(--bg) 88%);
}
.subjectchip {
  display: flex; align-items: center; gap: 6px; min-height: 44px;
  padding: 0 var(--s3) 0 6px; border-radius: var(--rf);
  background: var(--card); box-shadow: var(--sh-1); font-size: .84rem; font-weight: 900;
  transition: transform var(--t1) var(--e);
}
.subjectchip:active { transform: scale(.95); }
.subjectchip .dot { width: 30px; height: 30px; border-radius: var(--rf); display: grid; place-items: center; color: #fff; flex: none; }
.subjectchip .dot .ic { width: 18px; height: 18px; }
.subjectchip[data-subject="vn"] .dot { background: linear-gradient(150deg, var(--vn), var(--vn-ink)); }
.subjectchip[data-subject="world"] .dot { background: linear-gradient(150deg, var(--world), var(--world-ink)); }
.subjectchip .lv { color: var(--muted-fg); font-weight: 700; }

.pills { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.pill {
  display: inline-flex; align-items: center; gap: 5px;
  min-height: 44px; min-width: 44px; padding: 0 var(--s3); justify-content: center;
  border-radius: var(--rf); background: var(--card); box-shadow: var(--sh-1);
  font-size: .9rem; font-weight: 800;
}
.pill b { font-weight: 900; }
.p-flame { color: var(--flame); }
.p-xp    { color: var(--xp); }
.p-heart { color: var(--heart); } .p-heart .ic-sm { fill: var(--heart); stroke: none; }
.p-theme { color: var(--muted-fg); padding: 0 var(--s2); }
.ic-sun { display: none; }
:root[data-theme="dark"] .ic-moon { display: none; }
:root[data-theme="dark"] .ic-sun { display: block; }

/* ---------- 5. NÚT & THẺ DÙNG CHUNG ---------- */
.card { background: var(--card); border-radius: var(--r3); box-shadow: var(--sh-1); padding: var(--s4); }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s2);
  min-height: 54px; padding: 0 var(--s5); border-radius: var(--rf);
  font-size: 1.02rem; font-weight: 900; letter-spacing: -.01em;
  transition: transform var(--t1) var(--e), filter var(--t1) var(--e);
}
.btn:active:not([disabled]) { transform: scale(.975); filter: brightness(.96); }
.btn-block { display: flex; width: 100%; }
.btn-sm { min-height: 44px; font-size: .9rem; padding: 0 var(--s4); }
.btn-primary { background: var(--brand); color: var(--on-brand); position: relative; }
.btn-primary::after {
  content: ""; position: absolute; top: -5px; right: -5px; width: 14px; height: 14px;
  border-radius: 50%; background: var(--world); box-shadow: 0 0 0 2.5px var(--bg);
}
.btn-block.btn-primary::after, .result .btn-primary::after { top: -5px; right: 10px; }
.btn-ok      { background: var(--ok); color: #fff; }
.btn-danger  { background: var(--bad); color: #fff; }
.btn-soft    { background: var(--card); color: var(--brand-ink); box-shadow: inset 0 0 0 2px var(--line); }
.btn-text    { background: none; color: var(--muted-fg); font-weight: 700; }
.btn[disabled] { background: var(--muted); color: var(--muted-fg); }

.icon-btn { display: grid; place-items: center; width: 44px; height: 44px; border-radius: var(--rf); color: var(--fg); flex: none; }
.icon-btn:active { opacity: .55; }
.round-btn { display: grid; place-items: center; width: 44px; height: 44px; border-radius: var(--rf); background: var(--muted); color: var(--muted-fg); flex: none; }

.bar { height: 10px; border-radius: var(--rf); background: var(--muted); overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: var(--rf); background: var(--ok); transition: width var(--t3) var(--e); }

.chips { display: flex; flex-wrap: wrap; gap: var(--s2); }
.chip {
  min-height: 44px; padding: 0 var(--s4); border-radius: var(--rf);
  background: var(--card); color: var(--muted-fg); box-shadow: inset 0 0 0 2px var(--line);
  font-size: .86rem; font-weight: 800; transition: all var(--t1) var(--e);
}
.chip.on { background: var(--brand-soft); color: var(--brand-ink); box-shadow: inset 0 0 0 2px var(--brand); }
.chip.on[data-subject="world"] { background: var(--world-soft); color: var(--world-ink); box-shadow: inset 0 0 0 2px var(--world); }

/* ---------- 6. MÀN HỌC (HOME) ---------- */
.hero {
  position: relative; display: flex; flex-direction: column; align-items: center;
  padding: var(--s5) 0 var(--s4); margin: 0 calc(var(--gut) * -1); overflow: hidden;
}
.hero-glow {
  position: absolute; top: -22%; left: 50%; transform: translateX(-50%);
  width: 130%; aspect-ratio: 1; border-radius: 50%;
  background: radial-gradient(circle, color-mix(in srgb, var(--brand) 48%, transparent) 0%,
    color-mix(in srgb, var(--brand) 22%, transparent) 40%,
    color-mix(in srgb, var(--world) 16%, transparent) 58%, transparent 72%);
  pointer-events: none;
}
.hero-globe { position: relative; width: 128px; height: 128px; border-radius: 50%;
  background: var(--vn); display: grid; place-items: center; color: #fff; box-shadow: var(--sh-2);
  animation: bob 4.5s ease-in-out infinite; }
.hero-globe svg { width: 68px; height: 68px; }
.hero-globe img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
.hero-globe::after { content: ""; position: absolute; top: 6px; right: 6px; width: 22px; height: 22px;
  border-radius: 50%; background: var(--pink); box-shadow: 0 0 0 4px var(--bg); }
@keyframes bob { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }
.hero-bubble {
  position: relative; max-width: 360px; margin: var(--s3) var(--gut) 0;
  padding: var(--s3) var(--s4); border-radius: var(--r3);
  background: var(--card); box-shadow: var(--sh-2); text-align: center;
}
.hero-bubble::before {
  content: ""; position: absolute; top: -9px; left: 50%; margin-left: -9px;
  border: 9px solid transparent; border-bottom-color: var(--card); border-top: 0;
}
.hero-bubble p { font-size: 1rem; font-weight: 700; line-height: 1.45; }

.home-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--s2); margin-top: var(--s4); }
.hs { display: flex; flex-direction: column; align-items: center; gap: 1px;
  padding: var(--s3) var(--s2); border-radius: var(--r3); background: var(--card); box-shadow: var(--sh-1); }
.hs b { font-size: 1.2rem; font-weight: 900; }
.hs small { font-size: .68rem; color: var(--muted-fg); font-weight: 700; text-align: center; }

.subjecttabs { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s2); margin-top: var(--s5); }
.subjecttab {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px;
  padding: var(--s3) var(--s4); border-radius: var(--r3); background: var(--card);
  box-shadow: inset 0 0 0 2px var(--line); text-align: left;
}
.subjecttab .ic { color: var(--muted-fg); }
.subjecttab b { font-size: .98rem; }
.subjecttab small { color: var(--muted-fg); font-size: .76rem; font-weight: 700; }
.subjecttab.on[data-subject="vn"] { box-shadow: inset 0 0 0 2px var(--vn); background: var(--vn-soft); }
.subjecttab.on[data-subject="vn"] .ic { color: var(--vn); }
.subjecttab.on[data-subject="world"] { box-shadow: inset 0 0 0 2px var(--world); background: var(--world-soft); }
.subjecttab.on[data-subject="world"] .ic { color: var(--world); }

.levelrow { display: flex; gap: var(--s2); overflow-x: auto; margin-top: var(--s3); padding-bottom: 2px; scrollbar-width: none; }
.levelrow::-webkit-scrollbar { display: none; }
.levelchip { flex: none; min-height: 44px; padding: 0 var(--s4); border-radius: var(--rf);
  background: var(--card); box-shadow: inset 0 0 0 2px var(--line); font-size: .86rem; font-weight: 800; color: var(--muted-fg); }
.levelchip.on { background: var(--brand); color: #fff; box-shadow: none; }
.levelchip.soon { opacity: .55; }
.levelchip .tag { display: inline-block; margin-left: 5px; font-size: .64rem; padding: 1px 6px; border-radius: var(--rf); background: var(--amber-soft); color: var(--amber); font-weight: 900; vertical-align: 2px; }

.cont {
  position: relative; display: flex; flex-direction: column; align-items: flex-start; gap: var(--s2);
  width: 100%; text-align: left; margin-top: var(--s4);
  padding: var(--s5); border-radius: var(--r4);
  background: var(--vn); color: #fff; box-shadow: var(--sh-2);
}
.cont::after { content: ""; position: absolute; top: 14px; right: 18px; width: 16px; height: 16px;
  border-radius: 50%; background: var(--world); box-shadow: 0 0 0 3px color-mix(in srgb, var(--vn) 40%, transparent); }
.cont:active { transform: scale(.99); }
.cont-kick { font-size: .7rem; font-weight: 900; letter-spacing: .12em; text-transform: uppercase; opacity: .85; }
.cont-title { font-size: 1.35rem; font-weight: 900; letter-spacing: -.02em; line-height: 1.2; }
.cont-goal { font-size: .88rem; opacity: .92; font-weight: 600; }
.cont-bar { display: block; width: 100%; height: 7px; margin-top: var(--s1); border-radius: var(--rf); background: rgba(255,255,255,.32); overflow: hidden; }
.cont-bar > i { display: block; height: 100%; background: #fff; border-radius: var(--rf); transition: width var(--t3) var(--e); }
.cont-row { display: flex; align-items: center; width: 100%; font-size: .84rem; font-weight: 800; }
.cont-go { margin-left: auto; display: inline-flex; align-items: center; gap: 4px; }

.unit { margin-top: var(--s3); padding: var(--s2) var(--s3); text-align: center;
  border-radius: var(--r3); background: var(--card); box-shadow: var(--sh-1); }
.unit h2 { font-size: 1.1rem; }
.unit-meta { color: var(--muted-fg); font-size: .8rem; font-weight: 700; margin-top: 2px; }
.unit-head { display: flex; align-items: center; gap: var(--s3); width: 100%; padding: var(--s2) 0; text-align: left; min-height: 56px; }
.unit-ico { flex: none; width: 44px; height: 44px; border-radius: var(--r2); background: var(--muted); display: grid; place-items: center; color: var(--brand); }
.unit-tt { flex: 1; min-width: 0; }
.unit-tt b { display: block; font-size: 1rem; font-weight: 800; line-height: 1.25; }
.unit-tt small { display: block; margin-top: 2px; font-size: .76rem; font-weight: 700; color: var(--muted-fg); }
.unit-caret { flex: none; color: var(--brand); transition: transform var(--t2) var(--e); }
.unit.mo .unit-caret { transform: rotate(180deg); }

.nodes { position: relative; display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--s3) var(--s1); margin-top: var(--s2); padding-bottom: var(--s2); }
.unit:not(.mo) .nodes { display: none; }
.node { position: relative; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.node::before { content: ""; position: absolute; top: 38px; right: 50%; width: 100%; height: 3px; border-radius: var(--rf); background: var(--line); z-index: 0; }
.node:nth-child(3n + 1)::before { display: none; }
.node.done::before, .node.current::before { background: var(--brand-soft); }
.node-btn { position: relative; z-index: 1; width: 76px; height: 76px; padding: 0; border-radius: var(--rf); display: grid; place-items: center; background: var(--muted); color: var(--muted-fg); }
.node-btn .ic { width: 30px; height: 30px; }
.node.locked .node-btn .ic { width: 19px; height: 19px; opacity: .45; }
.node-btn:active:not([disabled]) { transform: scale(.94); }
.node.done .node-btn { background: var(--ok-soft); color: var(--ok); }
.node.current { position: relative; }
.node.current .node-btn { background: var(--brand); color: #fff; box-shadow: 0 0 0 5px var(--brand-soft); position: relative; }
.node.current .node-btn::after { content: ""; position: absolute; top: -2px; right: -2px; width: 16px; height: 16px;
  border-radius: 50%; background: var(--world); box-shadow: 0 0 0 3px var(--bg); }
.node.check .node-btn { background: var(--amber-soft); color: var(--amber); }
.node.open .node-btn { background: var(--brand-soft); color: var(--brand); }
.node.open .node-label { color: var(--fg); }
.node-label { font-size: .78rem; font-weight: 800; color: var(--muted-fg); line-height: 1.25; max-width: 84px; text-align: center; }
.node.current .node-label { color: var(--brand-ink); }
.node.done .node-label { color: var(--fg); }

.soon-card { display: flex; flex-direction: column; align-items: center; gap: var(--s2); text-align: center;
  padding: var(--s6) var(--s4); color: var(--muted-fg); }
.soon-card .ic { width: 40px; height: 40px; color: var(--line-hi); }
.soon-card b { color: var(--fg); font-size: 1.02rem; }

/* ---------- 7. BÀI HỌC: SLIDE DẠY ---------- */
.lesson-head { display: flex; align-items: center; gap: var(--s3); padding: calc(var(--s3) + env(safe-area-inset-top)) 0 var(--s2); }
.lesson-progress { flex: 1; display: flex; gap: 5px; }
.lesson-progress i { flex: 1; height: 8px; border-radius: var(--rf); background: var(--muted); overflow: hidden; display: block; }
.lesson-progress i b { display: block; height: 100%; width: 0; background: var(--brand); border-radius: var(--rf); transition: width var(--t2) var(--e); }
.lesson-progress i.done b { width: 100%; }
.lesson-progress i.teach b { background: var(--world); }

.slide { display: flex; flex-direction: column; gap: var(--s4); padding-top: var(--s4); min-height: 60vh; }
.slide-kicker { font-size: .74rem; font-weight: 900; letter-spacing: .1em; text-transform: uppercase; color: var(--brand-ink); }
.slide h2 { font-size: 1.5rem; }
.slide-body { font-size: 1rem; line-height: 1.6; }
.slide-bullets li { position: relative; padding-left: 26px; margin-top: var(--s2); font-weight: 700; }
.slide-bullets li::before { content: ""; position: absolute; left: 0; top: 8px; width: 8px; height: 8px; border-radius: var(--rf); background: var(--world); }

.place-card { display: flex; flex-direction: column; gap: var(--s3); }
.place-hero { display: flex; align-items: center; gap: var(--s3); }
.place-hero .thumb { position: relative; flex: none; width: 72px; height: 72px; border-radius: var(--r3); background: var(--vn); display: grid; place-items: center; color: #fff; }
.place-hero .thumb::after { content: ""; position: absolute; top: -4px; right: -4px; width: 15px; height: 15px;
  border-radius: 50%; background: var(--world); box-shadow: 0 0 0 3px var(--bg); }
.place-hero .thumb .ic { width: 34px; height: 34px; }
.place-hero h2 { font-size: 1.4rem; }
.place-hero small { color: var(--muted-fg); font-weight: 800; }
.fact-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s2); }
.fact { padding: var(--s3); border-radius: var(--r2); background: var(--muted); }
.fact b { display: block; font-size: 1.02rem; }
.fact small { color: var(--muted-fg); font-size: .74rem; font-weight: 700; }
.place-map { border-radius: var(--r3); background: var(--muted); padding: var(--s3); display: flex; justify-content: center; }
.place-map svg { max-width: 100%; height: auto; max-height: 34vh; }
.place-map path { fill: var(--line-hi); stroke: var(--card); stroke-width: .6; }
.place-map path.hi { fill: var(--brand); }

/* ---------- 8. CÂU HỎI ---------- */
.quiz { display: flex; flex-direction: column; gap: var(--s4); padding-top: var(--s4); min-height: 60vh; }
.quiz-q { font-size: 1.22rem; font-weight: 800; line-height: 1.4; }
.quiz-hint { color: var(--muted-fg); font-size: .86rem; font-weight: 700; }

.opt-list { display: flex; flex-direction: column; gap: var(--s2); }
.opt {
  display: flex; align-items: center; gap: var(--s3); min-height: 58px; padding: var(--s3) var(--s4);
  border-radius: var(--r3); background: var(--card); box-shadow: inset 0 0 0 2px var(--line);
  text-align: left; font-size: 1rem; font-weight: 800;
}
.opt .num { flex: none; width: 26px; height: 26px; border-radius: var(--rf); background: var(--muted);
  color: var(--muted-fg); display: grid; place-items: center; font-size: .78rem; font-weight: 900; }
.opt:active { background: var(--muted); }
.opt.sel { box-shadow: inset 0 0 0 2px var(--brand); background: var(--brand-soft); }
.opt.ok { box-shadow: inset 0 0 0 2px var(--ok); background: var(--ok-soft); color: var(--ok-ink); }
.opt.bad { box-shadow: inset 0 0 0 2px var(--bad); background: var(--bad-soft); color: var(--bad-ink); }
.opt[disabled] { opacity: 1; }
.opt .res-ic { margin-left: auto; flex: none; }

.blank-sentence { font-size: 1.14rem; font-weight: 800; line-height: 1.7; }
.blank-slot { display: inline-block; min-width: 90px; padding: 2px 8px; margin: 0 2px; border-radius: var(--r1);
  background: var(--muted); box-shadow: inset 0 0 0 2px var(--line); text-align: center; }
.blank-slot.filled { color: var(--brand-ink); box-shadow: inset 0 0 0 2px var(--brand); }
.word-bank { display: flex; flex-wrap: wrap; gap: var(--s2); margin-top: var(--s2); }
.word-bank .chip { background: var(--card); }
.word-bank .chip[disabled] { opacity: .35; }
.word-bank .chip.on { opacity: .35; }

.order-seq { display: flex; flex-wrap: wrap; gap: var(--s2); min-height: 44px; }
.order-chip { display: inline-flex; align-items: center; min-height: 40px; padding: 0 var(--s3);
  border-radius: var(--rf); background: var(--brand-soft); color: var(--brand-ink); font-weight: 800; font-size: .88rem; }

.tf-row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s3); }
.tf-btn { background: var(--card); color: var(--fg); box-shadow: inset 0 0 0 2px var(--line); }
.tf-btn.ok { background: var(--ok); color: #fff; box-shadow: none; }
.tf-btn.bad { background: var(--bad); color: #fff; box-shadow: none; }
.tf-btn[disabled] { opacity: 1; }

.type-input { min-height: 58px; width: 100%; padding: 0 var(--s4); border-radius: var(--r3);
  background: var(--card); box-shadow: inset 0 0 0 2px var(--line); font-size: 1.1rem; font-weight: 800; }
.type-input:focus { box-shadow: inset 0 0 0 2px var(--brand); outline: none; }

.match-cols { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s3); }
.match-item { min-height: 54px; padding: 0 var(--s3); border-radius: var(--r2); background: var(--card);
  box-shadow: inset 0 0 0 2px var(--line); font-size: .92rem; font-weight: 800; display: flex; align-items: center; text-align: left; }
.match-item.sel { box-shadow: inset 0 0 0 2px var(--brand); background: var(--brand-soft); }
.match-item.linked { box-shadow: inset 0 0 0 2px var(--ok); background: var(--ok-soft); color: var(--ok-ink); }
.match-item.bad { box-shadow: inset 0 0 0 2px var(--bad); background: var(--bad-soft); }

.listen-box { display: flex; flex-direction: column; align-items: center; gap: var(--s3); padding: var(--s6) 0; }
.listen-btn { position: relative; width: 88px; height: 88px; border-radius: var(--rf); background: var(--vn); color: #fff;
  display: grid; place-items: center; box-shadow: var(--sh-2); }
.listen-btn::after { content: ""; position: absolute; top: 2px; right: 2px; width: 18px; height: 18px;
  border-radius: 50%; background: var(--world); box-shadow: 0 0 0 3px var(--bg); }
.listen-btn .ic { width: 38px; height: 38px; }
.listen-btn:active { transform: scale(.95); }

.map-quiz { border-radius: var(--r3); background: var(--muted); padding: var(--s3); }
.map-quiz svg { width: 100%; height: auto; max-height: 52vh; display: block; }
.map-quiz path { fill: var(--line-hi); stroke: var(--card); stroke-width: .6; cursor: pointer; transition: fill var(--t1) var(--e); }
.map-quiz path:hover { fill: var(--brand); }
.map-quiz path.ok { fill: var(--ok) !important; }
.map-quiz path.bad { fill: var(--bad) !important; }

.qfoot { margin-top: auto; padding-top: var(--s4); position: sticky; bottom: 0; background: linear-gradient(0deg, var(--bg) 60%, transparent); }
.feedback { display: flex; align-items: center; gap: var(--s3); padding: var(--s3) var(--s4); border-radius: var(--r3); margin-bottom: var(--s3); font-weight: 800; }
.feedback.ok { background: var(--ok-soft); color: var(--ok-ink); }
.feedback.bad { background: var(--bad-soft); color: var(--bad-ink); }
.feedback .ic { flex: none; }
.feedback .fb-text { flex: 1; }
.feedback .fb-text small { display: block; font-weight: 700; opacity: .85; margin-top: 2px; }

/* ---------- 9. KẾT QUẢ BÀI ---------- */
.result { display: flex; flex-direction: column; align-items: center; text-align: center; gap: var(--s3); padding: var(--s6) 0 var(--s4); }
.result-badge { position: relative; width: 120px; height: 120px; border-radius: 50%; background: var(--vn); display: grid; place-items: center; color: #fff; box-shadow: var(--sh-2); }
.result-badge .ic { width: 58px; height: 58px; }
.result-badge::after { content: ""; position: absolute; top: 8px; right: 8px; width: 20px; height: 20px;
  border-radius: 50%; background: var(--world); box-shadow: 0 0 0 4px var(--bg); }
.result-title { font-size: 1.5rem; }
.result-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--s2); width: 100%; margin-top: var(--s3); }

/* ---------- 10. BẢN ĐỒ (màn Bản đồ) ---------- */
.map-toolbar { display: flex; gap: var(--s2); align-items: center; margin: var(--s2) 0 var(--s3); }
.map-wrap { border-radius: var(--r3); background: var(--card); box-shadow: var(--sh-1); padding: var(--s3); overflow: hidden; }
.map-wrap svg { width: 100%; height: auto; display: block; touch-action: pan-y; }
.map-wrap path { stroke: var(--card); stroke-width: .6; cursor: pointer; transition: fill var(--t1) var(--e), opacity var(--t1) var(--e); }
.map-wrap path.locked { fill: var(--line-hi); opacity: .55; }
.map-wrap path.active-region { fill: var(--brand); }
.map-wrap path.active-region:active, .map-wrap path.active-region.picked { fill: var(--world); }
.map-legend { display: flex; gap: var(--s4); margin-top: var(--s3); font-size: .78rem; font-weight: 700; color: var(--muted-fg); flex-wrap: wrap; }
.map-legend span { display: inline-flex; align-items: center; gap: 6px; }
.map-legend i { width: 12px; height: 12px; border-radius: 4px; display: inline-block; }

.sheet-backdrop { position: fixed; inset: 0; background: rgba(10,6,20,.5); z-index: 90; display: flex; align-items: flex-end; justify-content: center; }
.sheet { width: 100%; max-width: var(--shell); background: var(--card); border-radius: var(--r4) var(--r4) 0 0;
  padding: var(--s4) var(--s4) calc(var(--s5) + env(safe-area-inset-bottom)); box-shadow: var(--sh-3);
  animation: sheetup var(--t3) var(--e) both; max-height: 82vh; overflow-y: auto; }
@keyframes sheetup { from { transform: translateY(30px); opacity: 0; } }
.sheet-handle { width: 40px; height: 5px; border-radius: var(--rf); background: var(--line-hi); margin: 0 auto var(--s3); }

/* ---------- 11. HỒ SƠ ---------- */
.profile-head { display: flex; flex-direction: column; align-items: center; gap: var(--s2); padding: var(--s5) 0; }
.profile-avatar { position: relative; width: 88px; height: 88px; border-radius: 50%; background: var(--vn); display: grid; place-items: center; color: #fff; }
.profile-avatar::after { content: ""; position: absolute; top: 4px; right: 4px; width: 16px; height: 16px;
  border-radius: 50%; background: var(--pink); box-shadow: 0 0 0 3px var(--bg); }
.profile-avatar .ic { width: 42px; height: 42px; }
.profile-avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
.settings-row { display: flex; align-items: center; gap: var(--s3); min-height: 56px; padding: 0 var(--s2); }
.settings-row .ic { color: var(--brand); }
.settings-row b { flex: 1; font-weight: 800; font-size: .96rem; }
.switch { width: 46px; height: 28px; border-radius: var(--rf); background: var(--muted); position: relative; flex: none; }
.switch i { position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: var(--sh-1); transition: transform var(--t2) var(--e); }
.switch.on { background: var(--brand); }
.switch.on i { transform: translateX(18px); }
.credits { font-size: .76rem; color: var(--muted-fg); line-height: 1.6; padding: var(--s4) var(--s2); }
.credits a { color: var(--brand-ink); }

.toast { position: fixed; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--fg); color: var(--bg); padding: 10px 18px; border-radius: var(--rf); font-weight: 800; font-size: .88rem;
  box-shadow: var(--sh-2); z-index: 100; animation: toastin var(--t2) var(--e) both; }
@keyframes toastin { from { opacity: 0; transform: translate(-50%, 10px); } }

/* ---------- 12. TAB BAR DƯỚI ---------- */
.tabbar {
  position: sticky; bottom: 0; z-index: 30; display: flex;
  padding: var(--s2) var(--s2) calc(var(--s2) + env(safe-area-inset-bottom));
  background: var(--card); box-shadow: 0 -1px 0 var(--line);
}
.tab-btn { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: var(--s1) 0; border-radius: var(--r2); color: var(--muted-fg); font-size: .68rem; font-weight: 800; }
.tab-btn[aria-current="page"] { color: var(--brand); }
.tab-btn:active { opacity: .6; }

/* ---------- 13. RESPONSIVE ---------- */
@media (min-width: 620px) {
  .fact-grid { grid-template-columns: repeat(4, 1fr); }
  .nodes { grid-template-columns: repeat(4, 1fr); }
  .node:nth-child(3n + 1)::before { display: block; }
  .node:nth-child(4n + 1)::before { display: none; }
}
@media (max-width: 380px) {
  .home-stats, .result-stats { grid-template-columns: repeat(3, 1fr); }
  .hs b { font-size: 1.05rem; }
}
