/* 3B Exam Quest — design system
   Ink + cream cards over a 3D world. Chunky "pressable" buttons, rounded type.
   Subject colours: math coral, ela violet, science green, ss blue. */

:root {
  --ink: #1d2340;
  --ink-2: #4a5170;
  --ink-3: #7b819c;
  --cream: #fffdf7;
  --paper: #f6f1e6;
  --line: #e7e0cf;
  --good: #18a874;
  --good-bg: #e3f7ee;
  --bad: #e2574c;
  --bad-bg: #fdeceb;
  --gold: #f5b630;
  --gold-deep: #d18f0b;

  --math: #ff7a59;   --math-deep: #d9532f;   --math-soft: #ffe6dc;
  --ela: #8b6cff;    --ela-deep: #6345e0;    --ela-soft: #ece6ff;
  --science: #1fbf8f;--science-deep: #11906a;--science-soft: #dcf7ee;
  --ss: #3a9bf0;     --ss-deep: #1f74c4;     --ss-soft: #dfeefd;

  --accent: var(--ss);
  --accent-deep: var(--ss-deep);
  --accent-soft: var(--ss-soft);

  --r-lg: 26px;
  --r-md: 18px;
  --r-sm: 12px;
  --shadow: 0 18px 50px -18px rgba(16, 24, 56, .45), 0 2px 0 rgba(255,255,255,.6) inset;
  --font: ui-rounded, "SF Pro Rounded", "Nunito", "Segoe UI Rounded", "Arial Rounded MT Bold", system-ui, -apple-system, "Segoe UI", "PingFang TC", "Microsoft JhengHei", sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --ease-out: cubic-bezier(.22, 1, .36, 1);
  --ease-spring: cubic-bezier(.34, 1.56, .64, 1);
}

[data-subject="math"]    { --accent: var(--math);    --accent-deep: var(--math-deep);    --accent-soft: var(--math-soft); }
[data-subject="ela"]     { --accent: var(--ela);     --accent-deep: var(--ela-deep);     --accent-soft: var(--ela-soft); }
[data-subject="science"] { --accent: var(--science); --accent-deep: var(--science-deep); --accent-soft: var(--science-soft); }
[data-subject="ss"]      { --accent: var(--ss);      --accent-deep: var(--ss-deep);      --accent-soft: var(--ss-soft); }

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #16324f; color: var(--ink); font-family: var(--font); -webkit-font-smoothing: antialiased; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
h1, h2, h3, h4 { margin: 0; line-height: 1.15; letter-spacing: -.01em; }
p { margin: 0; }
.muted { color: var(--ink-3); }

#world { position: fixed; inset: 0; width: 100vw; height: 100vh; display: block; outline: none; touch-action: none; }
#confetti { position: fixed; inset: 0; width: 100vw; height: 100vh; pointer-events: none; z-index: 90; }

/* ---------- Buttons ---------- */
.btn {
  --b: var(--accent); --bd: var(--accent-deep);
  display: inline-flex; align-items: center; justify-content: center; gap: .5em;
  min-height: 52px; padding: 0 26px; border: 0; border-radius: 999px;
  background: var(--b); color: #fff; font-weight: 800; font-size: 18px; letter-spacing: .01em;
  box-shadow: 0 5px 0 var(--bd), 0 10px 22px -10px var(--bd);
  transform: translateY(0); transition: transform .12s var(--ease-out), box-shadow .12s var(--ease-out), filter .2s;
  user-select: none; -webkit-tap-highlight-color: transparent;
}
.btn:hover { filter: brightness(1.05); }
.btn:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--bd), 0 4px 10px -6px var(--bd); }
.btn:disabled { filter: grayscale(.7) opacity(.55); cursor: not-allowed; transform: none; }
.btn.ghost { --b: #fff; --bd: var(--line); color: var(--ink); }
.btn.gold { --b: var(--gold); --bd: var(--gold-deep); color: #3b2600; }
.btn.good { --b: var(--good); --bd: #0f7a53; }
.btn.small { min-height: 40px; padding: 0 16px; font-size: 15px; box-shadow: 0 3px 0 var(--bd); }
.btn.small:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--bd); }
.btn.wide { width: 100%; }

.icon-btn {
  width: 46px; height: 46px; border-radius: 14px; border: 0; background: rgba(255,255,255,.92);
  font-size: 22px; display: grid; place-items: center; box-shadow: 0 3px 0 rgba(20,30,60,.18);
  transition: transform .12s var(--ease-out);
}
.icon-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 rgba(20,30,60,.18); }

:focus-visible { outline: 3px solid var(--gold); outline-offset: 3px; }

/* ---------- Loading ---------- */
.screen { position: fixed; inset: 0; display: grid; place-items: center; z-index: 80;
  background: radial-gradient(1200px 600px at 50% 30%, #2f6ea3, #16324f 70%); transition: opacity .6s var(--ease-out); }
.screen.fade { opacity: 0; pointer-events: none; }
.loading-card { text-align: center; color: #fff; }
.loading-card h1 { font-size: 40px; font-weight: 900; margin: 10px 0 20px; }
.loading-card .muted { color: rgba(255,255,255,.7); margin-top: 14px; }
.logo-mark { font-size: 64px; animation: bob 2.4s ease-in-out infinite; }
.bar { width: 260px; height: 12px; border-radius: 99px; background: rgba(255,255,255,.18); overflow: hidden; margin: 0 auto; }
.bar i { display: block; height: 100%; width: 0; border-radius: 99px; background: linear-gradient(90deg, var(--gold), #ffd977); transition: width .3s var(--ease-out); }
@keyframes bob { 0%,100% { transform: translateY(0) rotate(-4deg); } 50% { transform: translateY(-8px) rotate(4deg); } }

/* ---------- HUD ---------- */
#hud { position: fixed; left: 0; right: 0; top: 0; z-index: 30; display: flex; align-items: center; gap: 14px;
  padding: max(14px, env(safe-area-inset-top)) 18px 14px; pointer-events: none; }
#hud > * { pointer-events: auto; }
.hud-player { display: flex; align-items: center; gap: 10px; border: 0; border-radius: 999px; padding: 6px 18px 6px 6px;
  background: rgba(255,255,255,.95); box-shadow: 0 3px 0 rgba(20,30,60,.18); font-weight: 800; font-size: 17px; }
.avatar { width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; font-size: 26px; background: var(--paper); }
.hud-stats { display: flex; gap: 8px; margin-left: auto; }
.stat { display: flex; align-items: baseline; gap: 5px; background: rgba(255,255,255,.95); border-radius: 999px; padding: 9px 14px;
  box-shadow: 0 3px 0 rgba(20,30,60,.18); font-weight: 800; }
.stat .ico { font-size: 17px; align-self: center; }
.stat b { font-size: 18px; font-variant-numeric: tabular-nums; }
.stat small { font-size: 12px; color: var(--ink-3); font-weight: 700; }
.stat.bump { animation: bump .5s var(--ease-spring); }
@keyframes bump { 0% { transform: scale(1); } 40% { transform: scale(1.18); } 100% { transform: scale(1); } }
.hud-actions { display: flex; gap: 8px; }
@media (max-width: 760px) {
  .hud-name { display: none; } .hud-player { padding-right: 6px; }
  .stat small { display: none; } .stat { padding: 8px 11px; }
  .stat.countdown { display: none; }
}

/* ---------- Floating 3D labels ---------- */
#labels { position: fixed; inset: 0; pointer-events: none; z-index: 10; }
.island-label { position: absolute; transform: translate(-50%, -100%); white-space: nowrap; text-align: center; pointer-events: auto; cursor: pointer;
  transition: opacity .3s; }
.island-label .pill { display: inline-flex; align-items: center; gap: 8px; background: var(--cream); color: var(--ink);
  padding: 8px 16px 8px 10px; border-radius: 999px; font-weight: 900; font-size: 18px; box-shadow: 0 4px 0 var(--accent-deep), 0 12px 30px -10px rgba(0,0,0,.5); }
.island-label .pill .dot { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--accent); color: #fff; font-size: 16px; }
.island-label .sub { display: block; margin-top: 6px; font-size: 13px; font-weight: 800; color: #fff; text-shadow: 0 1px 3px rgba(0,0,0,.6); }
.island-label .quests { display: inline-block; margin-left: 4px; background: var(--bad); color: #fff; border-radius: 99px; padding: 1px 8px; font-size: 13px; }
.island-label.dim { opacity: .0; pointer-events: none; }
.hint-bubble { position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); z-index: 20; background: rgba(20,30,60,.78); color: #fff;
  padding: 12px 20px; border-radius: 999px; font-weight: 800; backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); transition: opacity .4s; }

/* ---------- Panel (island) ---------- */
.panel { position: fixed; z-index: 25; right: 18px; top: 86px; bottom: 18px; width: min(430px, calc(100vw - 36px));
  background: var(--cream); border-radius: var(--r-lg); box-shadow: var(--shadow); display: flex; flex-direction: column; overflow: hidden;
  animation: slideIn .5s var(--ease-out); }
@keyframes slideIn { from { transform: translateX(40px); opacity: 0; } to { transform: none; opacity: 1; } }
.panel-head { padding: 22px 22px 16px; background: var(--accent); color: #fff; position: relative; }
.panel-head .eyebrow { font-size: 13px; font-weight: 800; opacity: .85; text-transform: uppercase; letter-spacing: .08em; }
.panel-head h2 { font-size: 28px; font-weight: 900; margin-top: 4px; }
.panel-head p { margin-top: 6px; font-weight: 600; opacity: .92; }
.panel-head .close { position: absolute; right: 14px; top: 14px; width: 38px; height: 38px; border-radius: 12px; border: 0; background: rgba(255,255,255,.22); color: #fff; font-size: 20px; }
.panel-progress { margin-top: 14px; height: 10px; background: rgba(255,255,255,.3); border-radius: 99px; overflow: hidden; }
.panel-progress i { display: block; height: 100%; background: #fff; border-radius: 99px; transition: width .6s var(--ease-out); }
.panel-body { padding: 16px 18px 22px; overflow-y: auto; flex: 1; }
.section-title { font-size: 13px; text-transform: uppercase; letter-spacing: .08em; font-weight: 900; color: var(--ink-3); margin: 10px 4px 10px; display: flex; align-items: center; gap: 8px; }
.section-title .tag { background: var(--bad-bg); color: var(--bad); border-radius: 99px; padding: 2px 8px; letter-spacing: 0; text-transform: none; }

.quest-card { display: flex; align-items: center; gap: 14px; width: 100%; text-align: left; border: 2px solid var(--line); background: #fff;
  border-radius: var(--r-md); padding: 12px 14px; margin-bottom: 10px; transition: transform .15s var(--ease-out), border-color .15s, box-shadow .15s; }
.quest-card:hover { transform: translateY(-2px); border-color: var(--accent); box-shadow: 0 8px 20px -12px var(--accent-deep); }
.quest-card .gem { width: 46px; height: 46px; border-radius: 14px; flex: none; display: grid; place-items: center; font-size: 24px; background: var(--accent-soft); }
.quest-card.focus .gem { background: var(--bad-bg); animation: pulse 2s ease-in-out infinite; }
.quest-card.done .gem { background: var(--good-bg); }
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 0 rgba(226,87,76,.35); } 50% { box-shadow: 0 0 0 8px rgba(226,87,76,0); } }
.quest-card .meta { flex: 1; min-width: 0; }
.quest-card h4 { font-size: 17px; font-weight: 900; }
.quest-card .scope { font-size: 13px; color: var(--ink-3); font-weight: 700; margin-top: 2px; }
.quest-card .why { font-size: 12.5px; color: var(--bad); font-weight: 800; margin-top: 4px; }
.quest-card .scope { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.stars { letter-spacing: 1px; font-size: 15px; white-space: nowrap; }
@media (max-width: 640px) {
  .panel { top: auto; left: 0; right: 0; bottom: 0; width: 100%; height: 64vh; border-radius: 26px 26px 0 0; animation: sheetUp .45s var(--ease-out); }
  .panel-head { padding: 16px 18px 12px; }
  .panel-head h2 { font-size: 23px; }
  .panel-head p { font-size: 14px; }
  .quest-card { position: relative; padding-right: 12px; align-items: flex-start; }
  .quest-card .meta { padding-right: 58px; }
  .quest-card .stars { position: absolute; top: 12px; right: 12px; font-size: 13px; }
  .section-title { flex-wrap: wrap; }
  .arcade-grid { grid-template-columns: 1fr 1fr; }
  .quest-frame { height: calc(100vh - 20px); }
  .overlay { padding: 10px; }
  .qcard, .lesson { padding: 18px 16px; }
}
@keyframes sheetUp { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
.stars .off { filter: grayscale(1) opacity(.3); }
.arcade-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.arcade-card { border: 0; border-radius: var(--r-md); padding: 14px; text-align: left; color: #fff; background: linear-gradient(150deg, var(--accent), var(--accent-deep));
  box-shadow: 0 4px 0 color-mix(in srgb, var(--accent-deep) 70%, black); min-height: 104px; display: flex; flex-direction: column; justify-content: space-between;
  transition: transform .15s var(--ease-out); }
.arcade-card:hover { transform: translateY(-2px) rotate(-.5deg); }
.arcade-card .big { font-size: 30px; }
.arcade-card b { font-size: 15px; font-weight: 900; line-height: 1.2; }

/* ---------- Overlay (quest, modal) ---------- */
.overlay { position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; padding: 18px;
  background: radial-gradient(1000px 700px at 50% 40%, rgba(22,50,79,.55), rgba(10,20,40,.82)); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  animation: fadeIn .35s var(--ease-out); }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal-layer { z-index: 60; }

.card { background: var(--cream); border-radius: var(--r-lg); box-shadow: var(--shadow); width: min(760px, 100%); max-height: calc(100vh - 36px); overflow: auto;
  animation: popIn .45s var(--ease-spring); }
@keyframes popIn { from { transform: translateY(16px) scale(.96); opacity: 0; } to { transform: none; opacity: 1; } }
.card-pad { padding: 28px; }
@media (max-width: 560px) { .card-pad { padding: 20px; } }

/* Quest frame */
.quest-frame { width: min(980px, 100%); height: min(720px, calc(100vh - 36px)); background: var(--cream); border-radius: var(--r-lg); box-shadow: var(--shadow);
  display: flex; flex-direction: column; overflow: hidden; animation: popIn .45s var(--ease-spring); }
.quest-top { display: flex; align-items: center; gap: 14px; padding: 14px 18px; border-bottom: 2px solid var(--line); }
.quest-top .q-title { font-weight: 900; font-size: 17px; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.quest-top .q-title small { display: block; color: var(--ink-3); font-size: 12.5px; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; }
.q-steps { display: flex; gap: 5px; }
.q-steps i { width: 22px; height: 8px; border-radius: 99px; background: var(--line); transition: background .3s; }
.q-steps i.now { background: var(--accent); }
.q-steps i.ok { background: var(--good); }
.q-steps i.no { background: var(--bad); }
.quest-body { flex: 1; overflow: auto; position: relative; }
.quest-foot { padding: 14px 18px; border-top: 2px solid var(--line); display: flex; gap: 10px; align-items: center; justify-content: flex-end; min-height: 82px; }

/* Question card */
.qcard { padding: 26px 30px 20px; max-width: 760px; margin: 0 auto; }
.qcard .level { display: inline-flex; gap: 6px; align-items: center; font-size: 12.5px; font-weight: 900; color: var(--accent-deep); background: var(--accent-soft);
  padding: 5px 10px; border-radius: 99px; text-transform: uppercase; letter-spacing: .06em; }
.qcard .prompt { font-size: clamp(20px, 2.6vw, 26px); font-weight: 800; margin: 14px 0 18px; line-height: 1.35; }
.qcard .visual { display: flex; justify-content: center; margin: 4px 0 20px; }
.qcard .visual svg { max-width: 100%; height: auto; }
.choices { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.choice { display: flex; align-items: center; gap: 12px; text-align: left; border: 2.5px solid var(--line); background: #fff; border-radius: var(--r-md);
  padding: 14px 16px; font-size: 19px; font-weight: 700; min-height: 64px; transition: transform .12s var(--ease-out), border-color .15s, background .15s; }
.choice .key { width: 32px; height: 32px; flex: none; border-radius: 10px; background: var(--paper); display: grid; place-items: center; font-weight: 900; font-size: 15px; color: var(--ink-2); }
.choice:hover:not(:disabled) { border-color: var(--accent); transform: translateY(-2px); }
.choice.sel { border-color: var(--accent); background: var(--accent-soft); }
.choice.sel .key { background: var(--accent); color: #fff; }
.choice.right { border-color: var(--good); background: var(--good-bg); }
.choice.right .key { background: var(--good); color: #fff; }
.choice.wrong { border-color: var(--bad); background: var(--bad-bg); animation: shake .4s; }
.choice.wrong .key { background: var(--bad); color: #fff; }
.choice:disabled { cursor: default; }
@keyframes shake { 0%,100% { transform: translateX(0); } 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }
.tf-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.tf-row .choice { justify-content: center; font-size: 22px; font-weight: 900; min-height: 84px; }
.answer-input { width: 100%; max-width: 420px; font-size: 26px; font-weight: 800; padding: 14px 18px; border-radius: var(--r-md); border: 3px solid var(--line);
  background: #fff; outline: none; transition: border-color .15s; }
.answer-input:focus { border-color: var(--accent); }
.answer-input.right { border-color: var(--good); background: var(--good-bg); }
.answer-input.wrong { border-color: var(--bad); background: var(--bad-bg); }
.order-list { display: flex; flex-direction: column; gap: 10px; max-width: 640px; }
.order-item { display: flex; align-items: center; gap: 12px; background: #fff; border: 2.5px solid var(--line); border-radius: var(--r-md); padding: 12px 14px;
  font-size: 18px; font-weight: 700; user-select: none; touch-action: none; cursor: grab; transition: border-color .15s, background .2s; }
.order-item .num { width: 32px; height: 32px; flex: none; border-radius: 50%; background: var(--accent); color: #fff; display: grid; place-items: center; font-weight: 900; }
.order-item .moves { margin-left: auto; display: flex; gap: 6px; }
.order-item .moves button { width: 38px; height: 38px; border-radius: 10px; border: 0; background: var(--paper); font-size: 16px; font-weight: 900; }
.order-item.dragging { opacity: .6; border-color: var(--accent); }
.order-item.right { border-color: var(--good); background: var(--good-bg); }
.order-item.wrong { border-color: var(--bad); background: var(--bad-bg); }

.feedback { display: flex; gap: 14px; align-items: flex-start; flex: 1; text-align: left; animation: popIn .35s var(--ease-spring); }
.feedback .badge { width: 46px; height: 46px; flex: none; border-radius: 50%; display: grid; place-items: center; font-size: 26px; color: #fff; }
.feedback.ok .badge { background: var(--good); }
.feedback.no .badge { background: var(--bad); }
.feedback b { font-size: 18px; font-weight: 900; display: block; }
.feedback.ok b { color: var(--good); }
.feedback.no b { color: var(--bad); }
.feedback span { font-size: 15px; color: var(--ink-2); font-weight: 600; }

/* Mini-game layout (used by js/ui.js mgLayout) */
.mg { position: absolute; inset: 0; display: flex; flex-direction: column; }
.mg-instruction { padding: 18px 24px 8px; font-size: clamp(19px, 2.3vw, 24px); font-weight: 800; text-align: center; line-height: 1.3; }
.mg-instruction small { display: block; font-size: 14px; color: var(--ink-3); font-weight: 700; margin-top: 4px; }
.mg-stage { position: relative; flex: 1; min-height: 220px; margin: 6px 16px; border-radius: var(--r-md); overflow: hidden;
  background: linear-gradient(180deg, var(--accent-soft), #fff); }
.mg-stage canvas { display: block; width: 100%; height: 100%; touch-action: none; }
.mg-controls { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; padding: 10px 16px 6px; }
.mg-chip { border: 2.5px solid var(--line); background: #fff; border-radius: 999px; padding: 10px 18px; font-weight: 800; font-size: 17px; min-height: 48px;
  transition: transform .12s var(--ease-out), border-color .15s, background .15s; }
.mg-chip:hover:not(:disabled) { border-color: var(--accent); transform: translateY(-2px); }
.mg-chip.sel { border-color: var(--accent); background: var(--accent-soft); }
.mg-chip.right { border-color: var(--good); background: var(--good-bg); }
.mg-chip.wrong { border-color: var(--bad); background: var(--bad-bg); }
.mg-readout { position: absolute; left: 12px; top: 12px; background: rgba(255,255,255,.92); border-radius: 12px; padding: 8px 12px; font-weight: 900; font-size: 18px;
  box-shadow: 0 2px 0 var(--line); font-variant-numeric: tabular-nums; }
.mg-tip { position: absolute; right: 12px; bottom: 12px; background: rgba(29,35,64,.75); color: #fff; border-radius: 12px; padding: 7px 11px; font-size: 13px; font-weight: 700; }

/* Results */
.results { text-align: center; padding: 34px 28px; }
.results .big-stars { font-size: 64px; letter-spacing: 6px; margin: 8px 0 10px; }
.results .big-stars span { display: inline-block; animation: starPop .6s var(--ease-spring) both; }
.results .big-stars span:nth-child(2) { animation-delay: .25s; }
.results .big-stars span:nth-child(3) { animation-delay: .5s; }
@keyframes starPop { from { transform: scale(0) rotate(-40deg); opacity: 0; } to { transform: none; opacity: 1; } }
.results h2 { font-size: 34px; font-weight: 900; }
.results .score { font-size: 18px; color: var(--ink-2); font-weight: 700; margin-top: 6px; }
.results .xp-gain { display: inline-flex; gap: 8px; align-items: center; margin-top: 16px; background: #fff7df; color: #8a5a00; border-radius: 999px; padding: 10px 18px; font-weight: 900; font-size: 18px; }
.review-list { text-align: left; margin: 22px auto 0; max-width: 620px; }
.review-item { background: #fff; border: 2px solid var(--line); border-radius: var(--r-md); padding: 12px 14px; margin-bottom: 8px; font-size: 15px; }
.review-item b { display: block; margin-bottom: 4px; }
.review-item .ok { color: var(--good); font-weight: 800; }
.review-item .no { color: var(--bad); font-weight: 800; }
.lesson-box { text-align: left; background: var(--accent-soft); border-radius: var(--r-md); padding: 16px 18px; margin: 18px auto 0; max-width: 620px; }
.lesson-box h4 { font-size: 16px; font-weight: 900; color: var(--accent-deep); margin-bottom: 6px; }
.lesson-box ul { margin: 6px 0 0; padding-left: 20px; }
.lesson-box li { margin: 3px 0; font-weight: 600; }
.results .actions { display: flex; gap: 12px; justify-content: center; margin-top: 24px; flex-wrap: wrap; }

/* Lesson (before quest) */
.lesson { padding: 26px 30px; max-width: 760px; margin: 0 auto; }
.lesson .big-idea { font-size: 22px; font-weight: 800; line-height: 1.4; margin: 10px 0 16px; }
.lesson .points { display: grid; gap: 8px; margin-bottom: 16px; }
.lesson .points div { background: #fff; border: 2px solid var(--line); border-radius: var(--r-sm); padding: 10px 14px; font-weight: 700; font-size: 17px; display: flex; gap: 10px; }
.lesson .trap { background: var(--bad-bg); border-radius: var(--r-md); padding: 14px 16px; margin-bottom: 10px; }
.lesson .trap b { color: var(--bad); }
.lesson .trick { background: #fff7df; border-radius: var(--r-md); padding: 14px 16px; font-weight: 700; }
.lesson .example { background: #fff; border: 2px dashed var(--accent); border-radius: var(--r-md); padding: 14px 16px; margin-bottom: 14px; }
.lesson .example ol { margin: 8px 0 0; padding-left: 22px; }
.lesson .example li { margin: 3px 0; font-weight: 600; }

/* Login */
.login { padding: 34px 32px 30px; text-align: center; }
.login .hero { font-size: 66px; line-height: 1; animation: bob 3s ease-in-out infinite; }
.login h1 { font-size: 36px; font-weight: 900; margin-top: 10px; }
.login p.lead { font-size: 17px; color: var(--ink-2); font-weight: 600; margin: 10px auto 22px; max-width: 460px; }
.code-boxes { position: relative; display: flex; gap: 10px; justify-content: center; margin: 0 auto 18px; width: max-content; cursor: text; }
.code-boxes .cell { width: 64px; height: 76px; display: grid; place-items: center; font-size: 36px; font-weight: 900; border-radius: 16px; border: 3px solid var(--line); background: #fff;
  font-variant-numeric: tabular-nums; transition: border-color .15s, transform .15s; }
.code-boxes .cell.on { border-color: var(--ss); transform: translateY(-2px); }
.code-input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; font-size: 16px; border: 0; caret-color: transparent; }
.code-boxes.bad .cell { border-color: var(--bad); animation: shake .4s; }
.avatar-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 10px; max-width: 460px; margin: 6px auto 18px; }
.avatar-grid button { aspect-ratio: 1; border-radius: 18px; border: 3px solid var(--line); background: #fff; font-size: 34px; transition: transform .12s var(--ease-spring); }
.avatar-grid button.sel { border-color: var(--ss); background: var(--ss-soft); transform: scale(1.08); }
.name-input { width: 100%; max-width: 320px; font-size: 22px; font-weight: 800; text-align: center; padding: 12px 16px; border-radius: 16px; border: 3px solid var(--line); outline: none; }
.name-input:focus { border-color: var(--ss); }
.link-btn { border: 0; background: none; color: var(--ink-3); font-weight: 800; text-decoration: underline; margin-top: 14px; }

/* Parent view */
.parent { padding: 28px 30px; }
.parent h2 { font-size: 28px; font-weight: 900; }
.parent .zh { color: var(--ink-3); font-weight: 700; font-size: .85em; }
.subject-rows { display: grid; gap: 14px; margin-top: 18px; }
.subject-row { border: 2px solid var(--line); border-radius: var(--r-md); padding: 14px 16px; background: #fff; }
.subject-row h3 { display: flex; align-items: center; gap: 10px; font-size: 19px; font-weight: 900; }
.subject-row h3 .dot { width: 14px; height: 14px; border-radius: 50%; background: var(--accent); }
.meter { height: 12px; border-radius: 99px; background: var(--paper); overflow: hidden; margin: 10px 0 8px; }
.meter i { display: block; height: 100%; border-radius: 99px; background: var(--accent); }
.concept-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.concept-chips span { font-size: 13px; font-weight: 800; padding: 4px 10px; border-radius: 99px; background: var(--paper); color: var(--ink-2); }
.concept-chips span.focus { background: var(--bad-bg); color: var(--bad); }
.concept-chips span.done { background: var(--good-bg); color: var(--good); }

/* Toasts */
#toasts { position: fixed; z-index: 95; left: 50%; top: 90px; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast { background: var(--ink); color: #fff; padding: 12px 20px; border-radius: 999px; font-weight: 800; font-size: 16px; box-shadow: 0 10px 30px -10px rgba(0,0,0,.6);
  animation: toastIn .45s var(--ease-spring), toastOut .4s ease-in 2.6s forwards; display: flex; gap: 10px; align-items: center; }
.toast.gold { background: linear-gradient(90deg, #f5b630, #ffd75e); color: #3b2600; }
@keyframes toastIn { from { transform: translateY(-14px) scale(.9); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes toastOut { to { transform: translateY(-10px); opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
