/* Giao diện tối: nền xanh rêu đậm, điểm nhấn lime, chữ Archivo + Be Vietnam Pro */
:root {
  --bg: #07110d;
  --bg2: #0c1a14;
  --panel: #10231b;
  --panel2: #163024;
  --line: #1f4233;
  --ink: #eafff2;
  --muted: #7fa893;
  --lime: #c4f82a;
  --lime-dim: #8fbf1f;
  --gold: #ffc83d;
  --coral: #ff5b46;
  --cyan: #4dd0e1;
  --shadow: 0 18px 40px -18px rgba(0, 0, 0, .7);
  --hk: 'Noto Sans HK', 'PingFang HK', 'PingFang TC', 'Heiti TC', 'Microsoft JhengHei', sans-serif;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  font-family: 'Be Vietnam Pro', system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(ellipse 90% 45% at 50% -10%, rgba(196, 248, 42, .10), transparent 60%),
    repeating-linear-gradient(90deg, transparent, transparent 78px, rgba(31, 66, 51, .18) 78px, rgba(31, 66, 51, .18) 80px);
}
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; }
button:disabled { cursor: default; }
#app { position: relative; height: 100dvh; max-width: 520px; margin: 0 auto; }
.screen { height: 100%; display: flex; flex-direction: column; }
.muted { color: var(--muted); font-size: 14px; line-height: 1.5; }
.center { text-align: center; }
.hk { font-family: var(--hk); }
.jp { color: var(--lime); font-weight: 600; letter-spacing: .3px; }

/* ---------- top bar ---------- */
.top {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: calc(12px + var(--safe-t)) 16px 12px;
  border-bottom: 1px solid var(--line);
  background: rgba(7, 17, 13, .85); backdrop-filter: blur(10px);
  position: relative; z-index: 2;
}
.brand { display: flex; align-items: center; gap: 10px; font-family: 'Archivo', sans-serif; font-weight: 900; text-transform: uppercase; font-size: 15px; line-height: .95; letter-spacing: -.3px; }
.brand b { display: block; font-size: 9px; letter-spacing: 2.5px; color: var(--muted); margin-bottom: 3px; }
.crest {
  width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; flex: none;
  background: linear-gradient(150deg, var(--lime), var(--lime-dim)); color: #0a1410;
  font-family: var(--hk); font-size: 22px; font-weight: 900; transform: rotate(-4deg);
  box-shadow: 0 8px 22px -8px rgba(196, 248, 42, .6);
}
.stats { display: flex; align-items: center; gap: 8px; }
.stat { font-family: 'Archivo'; font-weight: 900; font-size: 14px; color: var(--muted); }
.stat.streak.on { color: var(--gold); }
.stat.xp { color: var(--lime); }
.ring {
  --p: 0; width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center;
  background: conic-gradient(var(--lime) calc(var(--p) * 1%), var(--line) 0);
}
.ring i { font-style: normal; font-size: 8px; font-weight: 700; width: 23px; height: 23px; border-radius: 50%; background: var(--bg); display: grid; place-items: center; }
.avatar, .lav {
  width: 32px; height: 32px; border-radius: 50%; overflow: hidden; display: grid; place-items: center;
  background: var(--panel2); border: 1px solid var(--line); font-weight: 700; color: var(--lime); flex: none;
}
.avatar img, .lav img { width: 100%; height: 100%; object-fit: cover; }
.lav.big { width: 52px; height: 52px; font-size: 20px; }
.pill-login {
  display: flex; align-items: center; gap: 6px; padding: 7px 11px; border-radius: 40px;
  background: #fff; color: #1f1f1f; font-weight: 600; font-size: 13px;
}

/* ---------- home ---------- */
.scroll { flex: 1; overflow-y: auto; padding: 14px 16px 30px; -webkit-overflow-scrolling: touch; }
.note {
  background: var(--panel); border: 1px solid var(--line); border-left: 3px solid var(--lime);
  padding: 11px 13px; border-radius: 12px; font-size: 13px; line-height: 1.5; margin-bottom: 14px;
}
.note.warn { border-left-color: var(--gold); }
.link { color: var(--lime); font-weight: 700; text-decoration: underline; }

.unit { margin-bottom: 26px; }
.unit-head {
  position: relative; overflow: hidden;
  background: linear-gradient(135deg, var(--uc), color-mix(in srgb, var(--uc) 55%, #000));
  border-radius: 18px; padding: 16px 18px 20px; box-shadow: var(--shadow);
}
.unit-head small { font-size: 11px; font-weight: 700; letter-spacing: 1.5px; text-transform: uppercase; opacity: .85; }
.unit-head h2 { font-family: 'Archivo'; font-weight: 900; text-transform: uppercase; font-size: 22px; letter-spacing: -.3px; margin: 3px 0 2px; }
.unit-head p { font-size: 13px; opacity: .9; }
.unit-bar { position: absolute; left: 0; right: 0; bottom: 0; height: 5px; background: rgba(0, 0, 0, .25); }
.unit-bar i { display: block; height: 100%; background: var(--lime); }

.path { display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 22px 0 4px; }
.node-wrap { position: relative; transform: translateX(var(--x)); display: flex; flex-direction: column; align-items: center; }
.node {
  width: 70px; height: 66px; border-radius: 50%;
  background: var(--uc); color: #0a1410; font-size: 26px; font-weight: 900;
  box-shadow: 0 6px 0 color-mix(in srgb, var(--uc) 55%, #000), 0 14px 24px -10px rgba(0, 0, 0, .8);
  transition: transform .12s;
}
.node:active:not(:disabled) { transform: translateY(4px); box-shadow: 0 2px 0 color-mix(in srgb, var(--uc) 55%, #000); }
.node.done { background: var(--lime); box-shadow: 0 6px 0 var(--lime-dim), 0 14px 24px -10px rgba(0, 0, 0, .8); }
.node.locked { background: var(--panel2); color: var(--muted); font-size: 20px; box-shadow: 0 6px 0 #0b1a13; }
.node.cur { animation: pulse 1.8s infinite; }
.node.cur span { color: #fff; }
@keyframes pulse {
  0%, 100% { outline: 4px solid color-mix(in srgb, var(--uc) 0%, transparent); outline-offset: 2px; }
  50% { outline: 4px solid color-mix(in srgb, var(--uc) 60%, transparent); outline-offset: 6px; }
}
.node-label { font-size: 11px; color: var(--muted); margin-top: 8px; font-weight: 600; }
.start-tag {
  position: absolute; top: -34px; white-space: nowrap; background: var(--panel); border: 1px solid var(--line);
  color: var(--lime); font-family: 'Archivo'; font-weight: 900; font-size: 11px; letter-spacing: 1.5px;
  padding: 5px 10px; border-radius: 9px; animation: bob 1.4s ease-in-out infinite;
}
.start-tag::after { content: ''; position: absolute; left: 50%; bottom: -5px; width: 8px; height: 8px; background: var(--panel); border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); transform: translateX(-50%) rotate(45deg); }
@keyframes bob { 50% { transform: translateY(-4px); } }
.mascot-end { text-align: center; font-size: 44px; padding: 10px 0 20px; }
.mascot-end p { font-size: 13px; color: var(--muted); }

.sec-title {
  font-family: 'Archivo'; font-weight: 900; text-transform: uppercase; font-size: 13px; letter-spacing: 2px;
  color: var(--muted); margin: 18px 0 10px; display: flex; align-items: center; gap: 10px;
}
.sec-title:first-child { margin-top: 2px; }
.live { color: var(--coral); font-size: 10px; letter-spacing: 1px; animation: blink 1.6s infinite; }
@keyframes blink { 50% { opacity: .35; } }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; }
.panel.pad { padding: 16px; display: grid; gap: 12px; }
.panel.list { overflow: hidden; }
.lrow { display: grid; grid-template-columns: 34px 32px 1fr auto; align-items: center; gap: 10px; padding: 11px 14px; border-bottom: 1px solid var(--line); }
.lrow:last-child { border-bottom: 0; }
.lrow.me { background: rgba(196, 248, 42, .08); }
.rank { font-family: 'Archivo'; font-weight: 900; font-size: 16px; text-align: center; color: var(--muted); }
.lname { font-weight: 600; font-size: 14px; }
.lname em { color: var(--lime); font-style: normal; font-size: 12px; }
.lpts { font-family: 'Archivo'; font-weight: 900; color: var(--lime); }
.empty { text-align: center; font-size: 40px; padding: 30px 10px; }
.empty p { font-size: 14px; color: var(--muted); margin-top: 6px; }
.acct { display: flex; align-items: center; gap: 12px; }
.acct small { display: block; color: var(--muted); font-size: 12px; }
.acct small.ok { color: var(--lime); }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.kpi { padding: 14px 8px; text-align: center; display: grid; gap: 3px; }
.kpi b { font-family: 'Archivo'; font-weight: 900; font-size: 20px; }
.kpi small { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; }
.kpi.gold b { color: var(--gold); } .kpi.lime b { color: var(--lime); } .kpi.coral b { color: var(--coral); }
.grid3 + .muted { margin-top: 10px; }
.goals { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.chip { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 12px; font-family: 'Archivo'; font-weight: 900; text-align: left; }
.chip small { display: block; font-family: 'Be Vietnam Pro'; font-weight: 500; font-size: 12px; color: var(--muted); }
.chip.on { border-color: var(--lime); background: rgba(196, 248, 42, .1); color: var(--lime); }

.bottom-nav {
  display: flex; gap: 6px; padding: 8px 10px calc(8px + var(--safe-b));
  background: var(--bg2); border-top: 1px solid var(--line);
}
.tab {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
  font-weight: 600; font-size: 12px; color: var(--muted); padding: 7px 6px; border-radius: 12px; transition: .18s;
}
.tab span { font-size: 20px; }
.tab.active { background: var(--lime); color: #0a1410; box-shadow: 0 8px 22px -7px rgba(196, 248, 42, .85); transform: translateY(-1px); }

/* ---------- buttons ---------- */
.btn {
  width: 100%; padding: 15px; border-radius: 14px; font-family: 'Archivo'; font-weight: 900;
  text-transform: uppercase; letter-spacing: 1.5px; font-size: 15px; transition: transform .1s, opacity .2s;
  display: flex; align-items: center; justify-content: center; gap: 8px;
}
.btn:active:not(:disabled) { transform: scale(.98); }
.btn.primary { background: var(--lime); color: #0a1410; box-shadow: 0 10px 24px -10px rgba(196, 248, 42, .8); }
.btn.danger { background: var(--coral); color: #fff; }
.btn.ghost { background: transparent; border: 1px solid var(--line); color: var(--ink); }
.btn.google { background: #fff; color: #1f1f1f; text-transform: none; letter-spacing: 0; font-family: 'Be Vietnam Pro'; font-weight: 600; }
.btn:disabled { opacity: .35; box-shadow: none; }

/* ---------- lesson ---------- */
.lesson-top { display: flex; align-items: center; gap: 12px; padding: calc(14px + var(--safe-t)) 16px 10px; }
.x { font-size: 20px; color: var(--muted); width: 32px; height: 32px; }
.prog { flex: 1; height: 14px; background: var(--panel2); border-radius: 10px; overflow: hidden; }
.prog i { display: block; height: 100%; background: linear-gradient(90deg, var(--lime-dim), var(--lime)); border-radius: 10px; transition: width .4s; }
.hearts { font-family: 'Archivo'; font-weight: 900; color: var(--coral); }
.qbody { flex: 1; overflow-y: auto; padding: 10px 18px 20px; display: flex; flex-direction: column; gap: 16px; }
.kicker { font-family: 'Archivo'; font-weight: 900; font-size: 20px; line-height: 1.25; }
.kicker.new { color: var(--gold); font-size: 15px; text-transform: uppercase; letter-spacing: 2px; }

.intro-card {
  background: var(--panel); border: 1px solid var(--line); border-top: 5px solid var(--uc);
  border-radius: 20px; padding: 26px 18px; text-align: center; display: grid; gap: 8px; box-shadow: var(--shadow);
}
.intro-card .emoji { font-size: 56px; }
.intro-card .hk { font-size: 52px; font-weight: 700; }
.intro-card .jp { font-size: 20px; }
.intro-card .vi { font-size: 18px; color: var(--ink); }
.audio-row { display: flex; justify-content: center; gap: 10px; margin-top: 6px; }
.audio {
  width: 44px; height: 44px; border-radius: 12px; background: var(--cyan); color: #04231f; font-size: 20px; flex: none;
  box-shadow: 0 4px 0 #2a8f9b;
}
.audio.slow { background: var(--panel2); box-shadow: 0 4px 0 #0b1a13; }
.audio.big { width: 64px; height: 64px; font-size: 28px; border-radius: 18px; }
.audio:active { transform: translateY(3px); box-shadow: none; }

.bubble-row { display: flex; align-items: flex-end; gap: 10px; }
.mascot { font-size: 50px; line-height: 1; }
.bubble {
  position: relative; background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 12px 14px;
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
}
.bubble .audio { width: 38px; height: 38px; font-size: 17px; }
.bubble .audio.slow { display: none; }
.bubble .hk { font-size: 30px; font-weight: 700; }
.bubble.vi-big { font-size: 18px; font-weight: 600; }
.prompt.center { text-align: center; display: grid; gap: 6px; }
.hk.xl { font-size: 64px; font-weight: 700; }
.prompt .vi { color: var(--muted); }

.opts { display: grid; gap: 10px; }
.opts.grid { grid-template-columns: 1fr 1fr; }
.opt {
  background: var(--panel); border: 2px solid var(--line); border-radius: 14px; padding: 14px; text-align: left;
  font-size: 16px; font-weight: 500; transition: border-color .12s, background .12s, transform .1s;
  box-shadow: 0 3px 0 var(--line);
}
.opt:active:not(:disabled) { transform: translateY(2px); box-shadow: none; }
.opt.sel { border-color: var(--lime); background: rgba(196, 248, 42, .1); box-shadow: 0 3px 0 var(--lime-dim); }
.opt.card { text-align: center; display: grid; gap: 4px; padding: 16px 8px; }
.opt.card .emoji { font-size: 34px; }
.opt.card .hk { font-size: 26px; font-weight: 700; }
.opt.card .jp { font-size: 13px; }
.opt.mono { font-family: ui-monospace, 'SF Mono', Menlo, monospace; font-size: 18px; text-align: center; letter-spacing: .5px; }
.listen-box { display: flex; justify-content: center; gap: 12px; padding: 10px 0; }

.answer-line { min-height: 64px; border-bottom: 2px solid var(--line); display: flex; flex-wrap: wrap; gap: 8px; padding: 8px 0; align-items: flex-start; }
.answer-line .ph { color: var(--muted); font-size: 13px; align-self: center; }
.bank { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; padding-top: 6px; }
.tile {
  background: var(--panel2); border: 1px solid var(--line); border-radius: 12px; padding: 8px 12px; display: grid; gap: 1px;
  text-align: center; box-shadow: 0 3px 0 #0b1a13;
}
.tile span { font-family: var(--hk); font-size: 22px; font-weight: 700; }
.tile small { font-size: 10px; color: var(--lime); }
.tile.ghost { background: var(--bg2); color: transparent; box-shadow: none; border-style: dashed; font-family: var(--hk); font-size: 22px; padding: 8px 12px 21px; }

.match { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.match > div { display: grid; gap: 10px; align-content: start; }
.opt.mt { text-align: center; padding: 12px 8px; font-size: 14px; min-height: 62px; display: grid; place-content: center; gap: 2px; }
.opt.mt .hk { font-size: 22px; font-weight: 700; }
.opt.mt small { color: var(--lime); font-size: 11px; }
.opt.mt.gone { opacity: .15; border-style: dashed; box-shadow: none; }
.opt.mt.bad { border-color: var(--coral); animation: shake .3s; }
@keyframes shake { 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }

.lesson-foot { padding: 14px 18px calc(16px + var(--safe-b)); border-top: 1px solid var(--line); display: grid; gap: 12px; }
.lesson-foot.right { background: rgba(196, 248, 42, .1); border-top-color: var(--lime-dim); }
.lesson-foot.wrong { background: rgba(255, 91, 70, .12); border-top-color: var(--coral); }
.fb { display: grid; gap: 6px; animation: up .2s ease-out; }
@keyframes up { from { transform: translateY(10px); opacity: 0; } }
.fb-title { font-family: 'Archivo'; font-weight: 900; font-size: 18px; }
.fb.ok .fb-title { color: var(--lime); }
.fb.bad .fb-title { color: var(--coral); }
.fb-ans { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; }
.fb-ans .hk { font-size: 22px; font-weight: 700; }
.fb-ans .vi { color: var(--muted); font-size: 14px; }

/* ---------- result ---------- */
.result { justify-content: center; padding: 24px 20px calc(24px + var(--safe-b)); gap: 14px; text-align: center; }
.res-hero { font-size: 90px; animation: pop .5s cubic-bezier(.3, 1.6, .5, 1); }
@keyframes pop { from { transform: scale(.3); opacity: 0; } }
.result h1 { font-family: 'Archivo'; font-weight: 900; text-transform: uppercase; font-size: 28px; color: var(--lime); }
.streak-msg { color: var(--gold); font-weight: 600; }
.res-actions { display: grid; gap: 10px; margin-top: 10px; }
.result .note { text-align: left; }

@media (min-width: 560px) {
  #app { border-left: 1px solid var(--line); border-right: 1px solid var(--line); }
}

/* trạng thái sau khi kiểm tra */
.opt.right { border-color: var(--lime); background: rgba(196, 248, 42, .16); box-shadow: 0 3px 0 var(--lime-dim); }
.opt.wrong { border-color: var(--coral); background: rgba(255, 91, 70, .14); box-shadow: 0 3px 0 #a33a2c; }
.opt.dim { opacity: .45; }
.opt:disabled { color: var(--ink); }
