/* Bonus Mission — colourful "game" look. Tokens first. Avoids newer CSS (flex gap, :has, dvh) so it
   runs in older in-app browsers such as Zalo's. */
:root {
  --cream: #FFF1D6;
  --ink: #1D1B3A;
  --blue: #3558E6;
  --yellow: #FFC93C;
  --coral: #FF6F59;
  --mint: #2EC4A0;
  --mint-soft: #BFF0E1;
  --amber-soft: #FFE3A3;
  --amber: #F2A900;
  --muted: #5A5780;
  --white: #FFFFFF;
  --head: 'Baloo 2', 'Nunito', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --body: 'Nunito', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--cream); color: var(--ink); font-family: var(--body); font-weight: 700; font-size: 16px; line-height: 1.4; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3 { font-family: var(--head); margin: 0; line-height: 1.1; }
a { color: inherit; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

#app { max-width: 480px; margin: 0 auto; min-height: 100vh; position: relative; padding-bottom: 96px; }
.page { padding: 20px 20px 8px; }
.page.noNav { padding-bottom: 40px; }
.stack > * + * { margin-top: 14px; }
.stack-s > * + * { margin-top: 8px; }
.row { display: -webkit-flex; display: flex; align-items: center; }
.row > * + * { margin-left: 10px; }
.grow { -webkit-flex: 1; flex: 1; min-width: 0; }
.between { justify-content: space-between; }
.wrap { flex-wrap: wrap; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }
.hide { display: none !important; }

/* Cards, chips, buttons */
.card { background: var(--white); border: 3px solid var(--ink); border-radius: 24px; box-shadow: 0 6px 0 var(--ink); padding: 18px 20px; }
.card.flat { box-shadow: none; }
.card.blue { background: var(--blue); color: var(--white); }
.chip { display: inline-block; padding: 4px 12px; background: var(--white); border: 2px solid var(--ink); border-radius: 999px; font-size: 13px; font-weight: 800; color: var(--ink); line-height: 1.3; }
.chip.yellow { background: var(--yellow); } .chip.coral { background: var(--coral); } .chip.mint { background: var(--mint); } .chip.blue { background: var(--blue); color: #fff; }
.label { font-size: 12px; font-weight: 800; letter-spacing: .06em; color: var(--muted); text-transform: uppercase; }
.btn { display: -webkit-flex; display: flex; align-items: center; justify-content: center; width: 100%; min-height: 56px; padding: 0 18px; background: var(--yellow); color: var(--ink); border: 3px solid var(--ink); border-radius: 16px; box-shadow: 0 4px 0 var(--ink); font-family: var(--head); font-weight: 800; font-size: 20px; text-decoration: none; position: relative; top: 0; }
.btn:active { top: 3px; box-shadow: 0 1px 0 var(--ink); }
.btn[disabled] { opacity: .55; box-shadow: 0 4px 0 var(--ink); }
.btn.white { background: var(--white); } .btn.blue { background: var(--blue); color: #fff; } .btn.mint { background: var(--mint); } .btn.coral { background: var(--coral); }
.btn.small { min-height: 44px; font-size: 16px; width: auto; padding: 0 16px; border-radius: 14px; }
.btn svg { margin-left: 8px; }
.linkbtn { background: none; border: none; text-decoration: underline; font-weight: 800; font-size: 15px; min-height: 44px; padding: 0 10px; color: var(--ink); }
.iconbtn { width: 44px; height: 44px; border-radius: 50%; background: var(--white); border: 3px solid var(--ink); display: -webkit-flex; display: flex; align-items: center; justify-content: center; padding: 0; -webkit-flex-shrink: 0; flex-shrink: 0; }
.avatar { width: 48px; height: 48px; border-radius: 50%; border: 3px solid var(--ink); display: -webkit-flex; display: flex; align-items: center; justify-content: center; font-family: var(--head); font-weight: 800; font-size: 22px; line-height: 1; -webkit-flex-shrink: 0; flex-shrink: 0; background: var(--yellow); }
.avatar.s { width: 32px; height: 32px; font-size: 15px; border-width: 2px; }
.av0 { background: var(--yellow); } .av1 { background: var(--coral); } .av2 { background: var(--mint); } .av3 { background: var(--blue); color: #fff; } .av4 { background: #C9B6FF; } .av5 { background: #FF9ECF; }

/* Header + nav */
.hello { font-family: var(--head); font-weight: 700; font-size: 20px; line-height: 1.1; }
.bar { height: 18px; background: var(--white); border: 3px solid var(--ink); border-radius: 9px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--mint); -webkit-transition: width .3s; transition: width .3s; }
.bar.thin { height: 14px; border-width: 2px; border-radius: 7px; }
.nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; max-width: 480px; margin: 0 auto; display: -webkit-flex; display: flex; background: var(--white); border-top: 3px solid var(--ink); padding-bottom: env(safe-area-inset-bottom); }
.nav a { -webkit-flex: 1; flex: 1; min-height: 64px; display: -webkit-flex; display: flex; -webkit-flex-direction: column; flex-direction: column; align-items: center; justify-content: center; text-decoration: none; font-size: 12px; font-weight: 800; color: var(--muted); }
.nav a.on { color: var(--ink); background: var(--yellow); }
.nav a svg { margin-bottom: 2px; }

/* Home */
.feature { background: var(--blue); color: #fff; }
.feature .chip { color: var(--ink); }
.feature h2 { font-size: 30px; font-weight: 800; line-height: 1.05; }
.feature .bar > i { background: var(--yellow); }
.tiles { display: grid; grid-template-columns: 1fr 1fr; grid-gap: 12px; gap: 12px; }
.tile { display: block; text-align: left; text-decoration: none; background: var(--white); border: 3px solid var(--ink); border-radius: 20px; box-shadow: 0 4px 0 var(--ink); padding: 0; overflow: hidden; }
.tile .top { height: 54px; border-bottom: 3px solid var(--ink); display: -webkit-flex; display: flex; align-items: center; justify-content: space-between; padding: 0 12px; }
.tile .bd { padding: 10px 12px 12px; }
.tile h3 { font-size: 18px; font-weight: 800; }
.tile p { margin: 2px 0 8px; font-size: 13px; color: var(--muted); }
.badge { display: inline-block; font-size: 12px; font-weight: 800; padding: 2px 10px; border: 2px solid var(--ink); border-radius: 999px; background: var(--mint); }
.rank { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--ink); display: -webkit-flex; display: flex; align-items: center; justify-content: center; font-family: var(--head); font-weight: 800; font-size: 13px; background: var(--white); -webkit-flex-shrink: 0; flex-shrink: 0; }
.rank.r1 { background: var(--yellow); }
.brow { display: -webkit-flex; display: flex; align-items: center; min-height: 40px; }
.brow > * + * { margin-left: 10px; }
.brow.me { font-weight: 800; }
.brow .nm { width: 52px; font-size: 14px; font-weight: 800; -webkit-flex-shrink: 0; flex-shrink: 0; }
.brow .num { width: 32px; text-align: right; font-weight: 800; font-size: 14px; }
.brow .bar > i { background: var(--mint); }
.brow.me .bar > i { background: var(--coral); }

/* Forms */
.field { display: block; }
.field > span { display: block; margin-bottom: 6px; font-size: 14px; font-weight: 800; }
.input { width: 100%; min-height: 54px; padding: 0 14px; border: 3px solid var(--ink); border-radius: 16px; background: var(--white); font-weight: 800; font-size: 18px; outline: none; }
.input:focus { box-shadow: 0 0 0 4px var(--yellow); }
textarea.input { padding: 12px 14px; min-height: 90px; line-height: 1.35; }
.err { color: #B3261E; font-weight: 800; font-size: 14px; }
.classes { display: -webkit-flex; display: flex; flex-wrap: wrap; margin: -4px; }
.classes button { margin: 4px; min-height: 44px; padding: 0 14px; background: var(--white); border: 3px solid var(--ink); border-radius: 14px; font-weight: 800; font-size: 15px; }
.classes button.on { background: var(--coral); }

/* Question screen */
.qtop { display: -webkit-flex; display: flex; align-items: center; padding: 16px 20px 0; max-width: 480px; margin: 0 auto; }
.qtop > * + * { margin-left: 12px; }
.qcount { font-family: var(--head); font-weight: 800; font-size: 16px; }
.qbody { padding: 14px 20px 0; }
.qcard { background: var(--white); border: 3px solid var(--ink); border-radius: 24px; box-shadow: 0 6px 0 var(--ink); padding: 18px 20px; margin-bottom: 14px; }
.qcard .prompt { font-family: var(--head); font-weight: 700; font-size: 24px; line-height: 1.25; }
.gap { display: inline-block; min-width: 86px; border-bottom: 4px solid var(--amber); background: var(--amber-soft); border-radius: 6px; vertical-align: baseline; }
.base { display: inline-block; margin-top: 10px; padding: 3px 12px; background: var(--ink); color: #fff; border-radius: 999px; font-size: 14px; font-weight: 800; letter-spacing: .04em; }
.opts > button { display: -webkit-flex; display: flex; align-items: center; width: 100%; min-height: 54px; margin-bottom: 8px; padding: 8px 14px; text-align: left; background: var(--white); border: 3px solid var(--ink); border-radius: 16px; font-weight: 800; font-size: 17px; line-height: 1.25; }
.opts > button .l { width: 28px; height: 28px; border: 2px solid var(--ink); border-radius: 50%; background: var(--cream); display: -webkit-flex; display: flex; align-items: center; justify-content: center; font-size: 14px; margin-right: 12px; -webkit-flex-shrink: 0; flex-shrink: 0; }
.opts > button.wrong { background: var(--amber-soft); }
.opts > button.right { background: var(--mint-soft); }
.opts > button .tag { margin-left: auto; padding-left: 8px; font-size: 13px; }
.opts > button[disabled] { opacity: 1; }
.slots { margin-top: 10px; display: -webkit-flex; display: flex; flex-wrap: wrap; }
.slots .sl { display: block; width: 22px; height: 30px; margin: 0 3px 4px 0; border-bottom: 4px solid var(--ink); font-style: normal; font-family: var(--head); font-weight: 800; font-size: 22px; line-height: 28px; text-align: center; }
.slots .sl.on { background: var(--yellow); border-radius: 6px 6px 0 0; }
.passage p { margin: 0 0 12px; font-weight: 700; line-height: 1.5; }
.passage .pl { display: inline-block; width: 24px; height: 24px; line-height: 20px; text-align: center; border: 2px solid var(--ink); border-radius: 50%; background: var(--yellow); font-family: var(--head); font-weight: 800; font-size: 13px; margin-right: 6px; }
mark { background: var(--amber-soft); border-bottom: 3px solid var(--amber); border-radius: 4px; padding: 0 3px; color: inherit; }

/* Feedback sheet */
.scrim { position: fixed; left: 0; right: 0; top: 0; bottom: 0; background: rgba(29,27,58,.35); z-index: 30; }
.sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; max-width: 480px; margin: 0 auto; background: var(--white); border: 3px solid var(--ink); border-bottom: none; border-radius: 28px 28px 0 0; padding: 20px 20px calc(22px + env(safe-area-inset-bottom)); max-height: 88vh; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.sheet.good { background: var(--mint-soft); }
.sheet.try { background: var(--white); }
.sheet h2 { font-size: 26px; font-weight: 800; }
.sheet .ic { width: 44px; height: 44px; border-radius: 50%; border: 3px solid var(--ink); display: -webkit-flex; display: flex; align-items: center; justify-content: center; -webkit-flex-shrink: 0; flex-shrink: 0; background: var(--yellow); }
.sheet.good .ic { background: var(--mint); }
.sheet .exp { font-weight: 700; font-size: 15px; line-height: 1.5; }
.ans { display: inline-block; padding: 2px 10px; background: var(--mint-soft); border: 2px solid var(--ink); border-radius: 10px; font-weight: 800; }
.chain { display: -webkit-flex; display: flex; align-items: stretch; }
.chain .node { -webkit-flex: 1; flex: 1; padding: 6px 8px; background: var(--cream); border: 2px solid var(--ink); border-radius: 12px; min-width: 0; }
.chain .node b { display: block; font-size: 11px; letter-spacing: .06em; color: var(--muted); font-weight: 800; }
.chain .node span { font-weight: 800; font-size: 14px; word-break: break-word; }
.chain .node.hit { background: var(--mint-soft); }
.chain .node.hit b { color: #2B5A4E; }
.chain .arr { -webkit-flex: 0 0 22px; flex: 0 0 22px; display: -webkit-flex; display: flex; align-items: center; justify-content: center; }

/* Done screen */
.confetti { position: absolute; left: 0; right: 0; top: 0; height: 0; pointer-events: none; overflow: visible; }
.confetti i { position: absolute; top: -10px; width: 10px; height: 14px; border: 2px solid var(--ink); border-radius: 3px; -webkit-animation: fall 2.4s ease-in forwards; animation: fall 2.4s ease-in forwards; opacity: 0; }
@-webkit-keyframes fall { 0% { opacity: 1; -webkit-transform: translateY(0) rotate(0); } 100% { opacity: 0; -webkit-transform: translateY(520px) rotate(300deg); } }
@keyframes fall { 0% { opacity: 1; transform: translateY(0) rotate(0); } 100% { opacity: 0; transform: translateY(520px) rotate(300deg); } }
.bigscore { font-family: var(--head); font-weight: 800; font-size: 56px; line-height: 1; }
.review { border: 3px solid var(--ink); border-radius: 16px; background: var(--white); padding: 10px 12px; text-align: left; width: 100%; font-weight: 800; margin-bottom: 8px; }
.review small { display: block; font-weight: 700; color: var(--muted); }

/* Tips */
.tipcard { display: -webkit-flex; display: flex; align-items: center; width: 100%; text-align: left; background: var(--white); border: 3px solid var(--ink); border-radius: 20px; box-shadow: 0 4px 0 var(--ink); padding: 12px 14px; margin-bottom: 14px; text-decoration: none; min-height: 64px; }
.tipcard > * + * { margin-left: 12px; }
.tipcard h3 { font-size: 18px; font-weight: 800; }
.tipcard .ic { width: 44px; height: 44px; border-radius: 14px; border: 3px solid var(--ink); display: -webkit-flex; display: flex; align-items: center; justify-content: center; -webkit-flex-shrink: 0; flex-shrink: 0; }
.step { display: -webkit-flex; display: flex; align-items: flex-start; margin-bottom: 10px; }
.step .n { width: 30px; height: 30px; border-radius: 50%; background: var(--yellow); border: 3px solid var(--ink); font-family: var(--head); font-weight: 800; display: -webkit-flex; display: flex; align-items: center; justify-content: center; margin-right: 10px; -webkit-flex-shrink: 0; flex-shrink: 0; }
table.t { width: 100%; border-collapse: separate; border-spacing: 0; border: 3px solid var(--ink); border-radius: 14px; overflow: hidden; background: var(--white); font-size: 15px; }
table.t th { background: var(--ink); color: #fff; text-align: left; padding: 6px 10px; font-size: 13px; }
table.t td { padding: 8px 10px; border-top: 2px solid var(--ink); font-weight: 800; }
.note { background: var(--amber-soft); border: 3px solid var(--ink); border-radius: 14px; padding: 10px 12px; font-size: 15px; }
.example { background: var(--mint-soft); border: 3px solid var(--ink); border-radius: 14px; padding: 10px 12px; font-size: 15px; }

/* Lessons */
.lh { font-size: 24px; font-weight: 800; }
.stack > .lh { margin-top: 28px; }
.stack > .lh + * { margin-top: 8px; }
.lp { margin: 0; font-weight: 700; line-height: 1.5; }
.ll { margin: 0; padding-left: 22px; line-height: 1.5; }
.ll li { margin-bottom: 6px; }
.toc button { display: -webkit-flex; display: flex; align-items: center; width: 100%; text-align: left; min-height: 44px; padding: 4px 0; background: none; border: none; border-top: 2px solid var(--cream); font-weight: 800; font-size: 15px; }
.toc .n { width: 26px; height: 26px; border-radius: 50%; background: var(--yellow); border: 2px solid var(--ink); display: -webkit-flex; display: flex; align-items: center; justify-content: center; font-family: var(--head); font-size: 13px; margin-right: 10px; -webkit-flex-shrink: 0; flex-shrink: 0; }
.warn { display: -webkit-flex; display: flex; align-items: flex-start; background: #FFD9D2; border: 3px solid var(--ink); border-radius: 14px; padding: 10px 12px; font-size: 15px; }
.warn .wi { width: 26px; height: 26px; border-radius: 50%; background: var(--coral); border: 2px solid var(--ink); display: -webkit-flex; display: flex; align-items: center; justify-content: center; margin-right: 10px; -webkit-flex-shrink: 0; flex-shrink: 0; }
.quote { background: var(--white); border: 3px solid var(--ink); border-left-width: 10px; border-radius: 14px; padding: 10px 12px; font-size: 15px; line-height: 1.5; }
.pair { background: var(--white); border: 3px solid var(--ink); border-radius: 14px; padding: 8px 12px; margin-bottom: 10px; font-size: 15px; }
.pair .bad, .pair .good { padding: 4px 0; line-height: 1.4; }
.pair .bad { color: #8C2A1E; text-decoration: line-through; text-decoration-color: rgba(179,38,30,.5); }
.pair .good { color: #1C6B57; }
.pair span { display: inline-block; width: 22px; font-weight: 800; text-decoration: none; }
.pair .why { color: var(--muted); font-size: 14px; border-top: 2px solid var(--cream); padding-top: 4px; margin-top: 2px; }
.chain.sm .node { padding: 6px 4px; text-align: center; }
.chain.sm .node span { font-size: 12px; }
.chain.sm .node b { font-size: 9.5px; letter-spacing: 0; }
.chain.sm .arr { -webkit-flex: 0 0 14px; flex: 0 0 14px; }
.quiz { background: var(--white); border: 3px solid var(--ink); border-radius: 18px; padding: 12px 14px; box-shadow: 0 4px 0 var(--ink); }
.quiz .qq { font-family: var(--head); font-weight: 700; font-size: 19px; line-height: 1.3; margin: 4px 0 10px; }
.quiz .qopts button { display: -webkit-flex; display: flex; align-items: center; width: 100%; min-height: 48px; margin-bottom: 8px; padding: 6px 12px; text-align: left; background: var(--white); border: 3px solid var(--ink); border-radius: 14px; font-weight: 800; font-size: 16px; line-height: 1.25; }
.quiz .qopts .l { width: 26px; height: 26px; border: 2px solid var(--ink); border-radius: 50%; background: var(--cream); display: -webkit-flex; display: flex; align-items: center; justify-content: center; font-size: 13px; margin-right: 10px; -webkit-flex-shrink: 0; flex-shrink: 0; }
.quiz .qopts button.right { background: var(--mint-soft); }
.quiz .qopts button.wrong { background: var(--amber-soft); }
.quiz .qopts button[disabled] { opacity: 1; }
.quiz .qfb { font-size: 15px; line-height: 1.45; margin-top: 4px; }
.quiz .qfb.ok { background: var(--mint-soft); border: 2px solid var(--ink); border-radius: 12px; padding: 8px 10px; }
.quiz .qfb.no { background: var(--amber-soft); border: 2px solid var(--ink); border-radius: 12px; padding: 8px 10px; }
.quiz .input { min-height: 48px; font-size: 17px; }

/* Topics */
.topic { display: -webkit-flex; display: flex; align-items: center; background: var(--white); border: 3px solid var(--ink); border-radius: 16px; padding: 8px 10px 8px 14px; margin-bottom: 8px; }
.topic > span { -webkit-flex: 1; flex: 1; min-width: 0; }
.vote { min-width: 56px; min-height: 44px; margin-left: 10px; border: 3px solid var(--ink); border-radius: 12px; background: var(--white); font-weight: 800; display: -webkit-flex; display: flex; align-items: center; justify-content: center; }
.vote.on { background: var(--yellow); }
.topic.done { background: var(--mint-soft); }

.toast { position: fixed; left: 50%; bottom: 84px; -webkit-transform: translateX(-50%); transform: translateX(-50%); z-index: 60; background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 14px; font-weight: 800; max-width: 90%; text-align: center; }
.spin { width: 36px; height: 36px; border: 5px solid var(--ink); border-top-color: var(--yellow); border-radius: 50%; margin: 60px auto; -webkit-animation: sp 0.8s linear infinite; animation: sp 0.8s linear infinite; }
@-webkit-keyframes sp { to { -webkit-transform: rotate(360deg); } }
@keyframes sp { to { transform: rotate(360deg); } }
.btn:focus-visible, .input:focus-visible, button:focus-visible, a:focus-visible { outline: 4px solid var(--blue); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { .confetti { display: none; } .bar > i { -webkit-transition: none; transition: none; } .spin { -webkit-animation-duration: 3s; animation-duration: 3s; } }
