:root {
  --bg: #0b1020;
  --surface: #131a2e;
  --surface-2: #1a2340;
  --line: #26304f;
  --text: #e8ecf8;
  --muted: #8b95b5;
  --brand: #2dd4bf;
  --brand-ink: #042f2b;
  --good: #22c55e;
  --good-bg: #0f2a1c;
  --bad: #f43f5e;
  --bad-bg: #2d1220;
  --gold: #fbbf24;
  --radius: 18px;
  --nav-h: 68px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: "IBM Plex Sans Arabic", system-ui, -apple-system, "Segoe UI", Tahoma, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
button:disabled { cursor: not-allowed; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

.app {
  max-width: 520px;
  margin: 0 auto;
  min-height: 100dvh;
  position: relative;
  background: radial-gradient(120% 60% at 50% 0%, #17204000 0%, #0b1020 70%), var(--bg);
}

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(10px + var(--safe-t)) 16px 10px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 6px; font-weight: 700; font-size: 20px; }
.stats { display: flex; gap: 6px; }
.stat {
  display: flex; align-items: center; gap: 4px;
  padding: 5px 10px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--line);
  font-size: 14px;
}
.stat b { font-variant-numeric: tabular-nums; }

/* ---------- screens ---------- */
.screen { padding: 16px 16px calc(var(--nav-h) + 24px + var(--safe-b)); }
.page-title { font-size: 24px; margin: 4px 0 16px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.muted { color: var(--muted); }

/* ---------- home ---------- */
.banner {
  width: 100%; display: flex; align-items: center; gap: 12px; text-align: start;
  padding: 14px 16px; border-radius: var(--radius);
  background: linear-gradient(135deg, var(--sec), color-mix(in srgb, var(--sec) 55%, #000));
  box-shadow: 0 6px 0 color-mix(in srgb, var(--sec) 45%, #000);
  color: #fff;
}
.banner-ic { font-size: 30px; width: 48px; height: 48px; display: grid; place-items: center; background: #ffffff26; border-radius: 14px; }
.banner-txt { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.banner-txt small { opacity: .85; }
.banner-txt b { font-size: 18px; text-align: right; }
.banner-more { font-size: 13px; background: #00000033; padding: 6px 10px; border-radius: 999px; white-space: nowrap; }

.goal-card {
  display: flex; align-items: center; gap: 12px; margin-top: 18px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px;
}
.goal-card > div { flex: 1; display: flex; flex-direction: column; }
.goal-card small { color: var(--muted); }
.ring { flex: none; }
.chip {
  padding: 8px 12px; border-radius: 999px; font-size: 13px; font-weight: 600;
  background: var(--surface-2); border: 1px solid var(--line);
}

.unit { margin-top: 26px; }
.unit-head {
  display: flex; align-items: center; gap: 10px; color: var(--muted);
  font-size: 13px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase;
}
.unit-head::before, .unit-head::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.path { display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 18px 0 6px; }
.node-wrap { display: flex; flex-direction: column; align-items: center; position: relative; width: 140px; }
.node {
  width: 76px; height: 72px; border-radius: 50%;
  font-size: 30px; font-weight: 700;
  display: grid; place-items: center;
  background: var(--surface-2); color: var(--muted);
  box-shadow: 0 7px 0 #0a0f1e;
  transition: transform .08s;
}
.node:active { transform: translateY(4px); box-shadow: 0 3px 0 #0a0f1e; }
.node.done { background: var(--sec); color: #fff; box-shadow: 0 7px 0 color-mix(in srgb, var(--sec) 50%, #000); }
.node.current {
  background: var(--sec); color: #fff;
  box-shadow: 0 7px 0 color-mix(in srgb, var(--sec) 50%, #000), 0 0 0 6px color-mix(in srgb, var(--sec) 30%, transparent);
  animation: pulse 1.8s ease-in-out infinite;
}
.node.locked { opacity: .6; font-size: 24px; }
@keyframes pulse {
  50% { box-shadow: 0 7px 0 color-mix(in srgb, var(--sec) 50%, #000), 0 0 0 12px color-mix(in srgb, var(--sec) 12%, transparent); }
}
.node-tip {
  position: absolute; top: -30px; z-index: 1;
  background: #fff; color: #0b1020; font-weight: 700; font-size: 13px;
  padding: 4px 12px; border-radius: 10px;
  animation: bob 1.6s ease-in-out infinite;
}
.node-tip::after { content: ""; position: absolute; bottom: -5px; left: 50%; margin-left: -6px; border: 6px solid transparent; border-bottom: 0; border-top-color: #fff; }
@keyframes bob { 50% { transform: translateY(-4px); } }
.node-stars { margin-top: 10px; font-size: 13px; letter-spacing: 2px; }
.node-title { font-size: 12px; color: var(--muted); text-align: center; margin-top: 2px; }

.stars .on { color: var(--gold); }
.stars .off { color: #3a4466; }

/* ---------- bottom nav ---------- */
.nav {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%); z-index: 20;
  width: 100%; max-width: 520px;
  display: grid; grid-template-columns: repeat(5, 1fr);
  padding: 6px 8px calc(6px + var(--safe-b));
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
}
.nav-btn {
  position: relative;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 6px 0; border-radius: 14px; font-size: 12px; color: var(--muted);
}
.nav-ic { font-size: 22px; filter: grayscale(.7); transition: filter .15s, transform .15s; }
.nav-btn.active { color: var(--text); background: var(--surface-2); }
.nav-btn.active .nav-ic { filter: none; transform: scale(1.1); }
.badge {
  position: absolute; top: 2px; left: calc(50% - 22px);
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--bad); color: #fff; font-style: normal; font-size: 11px; font-weight: 700;
  display: grid; place-items: center;
}

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 52px; padding: 0 20px; border-radius: 16px;
  font-weight: 700; font-size: 16px;
  background: var(--surface-2); border: 1px solid var(--line);
  box-shadow: 0 4px 0 #0a0f1e;
}
.btn:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 1px 0 #0a0f1e; }
.btn.primary { background: var(--brand); color: var(--brand-ink); border-color: transparent; box-shadow: 0 4px 0 #129a8a; }
.btn.danger { background: var(--bad); color: #fff; border-color: transparent; box-shadow: 0 4px 0 #a51f3a; }
.btn.ghost { background: transparent; box-shadow: none; }
.btn:disabled { opacity: .45; }
.btn.wide { width: 100%; }
.stack { display: flex; flex-direction: column; gap: 12px; width: 100%; }

/* ---------- sheet ---------- */
.sheet { position: fixed; inset: 0; z-index: 50; }
.sheet-backdrop { position: absolute; inset: 0; background: #000a; opacity: 0; transition: opacity .2s; }
.sheet-panel {
  position: absolute; bottom: 0; left: 50%; width: 100%; max-width: 520px; max-height: 85dvh; overflow: auto;
  transform: translate(-50%, 100%); transition: transform .22s ease-out;
  background: var(--surface); border: 1px solid var(--line); border-bottom: 0;
  border-radius: 24px 24px 0 0; padding: 10px 16px calc(20px + var(--safe-b));
}
.sheet-panel::before { content: ""; display: block; width: 40px; height: 5px; border-radius: 3px; background: var(--line); margin: 0 auto 12px; }
.sheet.open .sheet-backdrop { opacity: 1; }
.sheet.open .sheet-panel { transform: translate(-50%, 0); }
.sheet-title { text-align: center; margin: 0 0 14px; }

.sec-list { display: flex; flex-direction: column; gap: 10px; }
.sec-item {
  display: flex; align-items: center; gap: 12px; text-align: start;
  padding: 12px; border-radius: 16px; background: var(--surface-2); border: 1px solid var(--line);
}
.sec-item.active { border-color: var(--sec); box-shadow: inset 0 0 0 1px var(--sec); }
.sec-ic { font-size: 26px; width: 50px; height: 50px; flex: none; display: grid; place-items: center; border-radius: 14px; background: color-mix(in srgb, var(--sec) 22%, transparent); }
.sec-txt { flex: 1; display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.sec-txt b { text-align: right; }
.sec-txt small { color: var(--muted); }
.bar { display: block; height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; margin-top: 4px; }
.bar i { display: block; height: 100%; background: var(--sec, var(--brand)); border-radius: 3px; }

.lesson-sheet { text-align: center; padding: 4px 0; }
.lesson-sheet small { color: var(--sec); font-weight: 600; }
.lesson-sheet h3 { font-size: 22px; margin: 4px 0 10px; }
.ls-meta { display: flex; justify-content: center; gap: 16px; color: var(--muted); margin-bottom: 18px; }
.lesson-sheet .btn { width: 100%; }

/* ---------- lesson ---------- */
.lesson { min-height: 100dvh; display: flex; flex-direction: column; }
.lesson-top { display: flex; align-items: center; gap: 12px; padding: calc(14px + var(--safe-t)) 16px 8px; }
.icon-btn { width: 40px; height: 40px; border-radius: 50%; font-size: 20px; color: var(--muted); flex: none; }
.icon-btn:hover { background: var(--surface); }
.progress { flex: 1; height: 14px; background: var(--surface-2); border-radius: 7px; overflow: hidden; }
.progress i { display: block; height: 100%; background: var(--good); border-radius: 7px; transition: width .35s ease; box-shadow: inset 0 -4px 0 #0002, inset 0 3px 0 #fff3; }
.pill { padding: 5px 10px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); font-size: 14px; font-weight: 600; white-space: nowrap; }
.lesson-body { flex: 1; padding: 16px; }
.lesson-body.enter { animation: slide-in .25s ease-out; }
@keyframes slide-in { from { opacity: 0; transform: translateX(-16px); } }
.q-kind { color: var(--muted); font-size: 14px; font-weight: 600; }
.q-text { font-size: 21px; line-height: 1.5; margin: 8px 0 22px; text-align: start; font-weight: 600; }
.options { display: flex; flex-direction: column; gap: 10px; }
.opt, .mcell {
  width: 100%; text-align: left; padding: 14px 16px; border-radius: 16px;
  background: var(--surface); border: 2px solid var(--line); box-shadow: 0 4px 0 var(--line);
  font-size: 16px; line-height: 1.4;
  transition: border-color .12s, background .12s;
}
.opt:hover:not(:disabled), .mcell:hover:not(:disabled) { background: var(--surface-2); }
.opt.sel, .mcell.sel { border-color: #60a5fa; background: #13254a; box-shadow: 0 4px 0 #2b4f8f; }
.opt.right { border-color: var(--good); background: var(--good-bg); box-shadow: 0 4px 0 #166534; }
.opt.wrong { border-color: var(--bad); background: var(--bad-bg); box-shadow: 0 4px 0 #9f1239; animation: shake .3s; }
.opt.dim { opacity: .5; }
.match { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.mcol { display: flex; flex-direction: column; gap: 10px; }
.mcell { padding: 12px; font-size: 14px; min-height: 64px; text-align: center; }
.mcell.matched { opacity: .5; border-color: var(--good); background: var(--good-bg); box-shadow: none; }
.mcell.bad { border-color: var(--bad); background: var(--bad-bg); animation: shake .3s; }
@keyframes shake { 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }

.lesson-foot {
  position: sticky; bottom: 0;
  padding: 14px 16px calc(16px + var(--safe-b));
  border-top: 1px solid var(--line); background: var(--bg);
  display: flex; flex-direction: column; gap: 12px;
}
.lesson-foot .btn { width: 100%; }
.lesson-foot.good { background: var(--good-bg); border-color: #166534; animation: rise .2s ease-out; }
.lesson-foot.bad { background: var(--bad-bg); border-color: #9f1239; animation: rise .2s ease-out; }
@keyframes rise { from { transform: translateY(30px); opacity: 0; } }
.fb b { font-size: 19px; }
.lesson-foot.good .fb b { color: #4ade80; }
.lesson-foot.bad .fb b { color: #fb7185; }
.fb-answer { margin-top: 4px; font-weight: 600; }
.fb-explain { margin: 6px 0 0; color: #c9d1ea; line-height: 1.6; font-size: 15px; }
.hint { margin: 0; text-align: center; color: var(--muted); }

/* ---------- result / no hearts ---------- */
.center-screen {
  min-height: 100dvh; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 12px; text-align: center; padding: 24px 16px calc(24px + var(--safe-b));
}
.center-screen h1 { margin: 4px 0 0; font-size: 28px; }
.center-screen p { color: var(--muted); margin: 0; line-height: 1.6; max-width: 340px; }
.big-stars { font-size: 44px; letter-spacing: 6px; }
.big-stars .on { display: inline-block; animation: pop .4s backwards; }
.big-stars .on:nth-child(2) { animation-delay: .15s; }
.big-stars .on:nth-child(3) { animation-delay: .3s; }
@keyframes pop { from { transform: scale(0); } 70% { transform: scale(1.3); } }
.result-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; width: 100%; margin: 8px 0; }
.rcard { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 12px; display: flex; flex-direction: column; gap: 2px; }
.rcard small { color: var(--muted); }
.rcard b { font-size: 22px; }
.new-ach { width: 100%; text-align: start; }
.new-ach h3 { margin: 6px 0 8px; }

/* ---------- achievements ---------- */
.ach-summary { display: flex; align-items: center; gap: 14px; margin-bottom: 16px; }
.ach-summary > div { flex: 1; }
.ach-summary small { color: var(--muted); }
.ach-list { display: flex; flex-direction: column; gap: 10px; }
.ach {
  display: flex; align-items: center; gap: 12px; padding: 12px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 16px;
}
.ach-ic { font-size: 26px; width: 50px; height: 50px; flex: none; display: grid; place-items: center; border-radius: 50%; background: var(--surface-2); }
.ach.locked .ach-ic { filter: grayscale(1); opacity: .5; }
.ach.locked .ach-txt b { color: var(--muted); }
.ach.got { border-color: #806015; background: linear-gradient(90deg, #2a2210, var(--surface)); }
.ach-txt { flex: 1; display: flex; flex-direction: column; }
.ach-txt small { color: var(--muted); }
.ach-gems { font-size: 13px; color: #7dd3fc; white-space: nowrap; }

/* ---------- review ---------- */
.review-hero { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.review-hero > div { display: flex; flex-direction: column; gap: 4px; }
.review-hero small { color: var(--muted); line-height: 1.5; }
.mistake-list { list-style: none; padding: 0; margin: 18px 0 0; display: flex; flex-direction: column; gap: 8px; }
.mistake-list li { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 10px 12px; display: flex; flex-direction: column; gap: 2px; }
.mistake-list small { color: var(--muted); direction: ltr; text-align: left; }
.mistake-list span { text-align: left; }
.empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 8px; padding: 40px 12px; color: var(--muted); line-height: 1.6; }

/* ---------- profile ---------- */
.profile-head { display: flex; align-items: center; gap: 14px; margin-bottom: 16px; }
.avatar { width: 64px; height: 64px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); border: 2px solid var(--brand); }
.profile-head h1 { margin: 0; font-size: 22px; }
.link { color: var(--brand); font-size: 14px; padding: 0; }
.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.stat-card { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 12px 14px; }
.stat-card span { font-size: 20px; }
.stat-card b { display: block; font-size: 24px; margin-top: 4px; font-variant-numeric: tabular-nums; }
.stat-card small { color: var(--muted); }
.section-h { font-size: 17px; margin: 24px 0 10px; }
.week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; align-items: end; height: 150px; padding: 14px; }
.week-col { display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; }
.week-bar { width: 100%; max-width: 26px; border-radius: 6px 6px 3px 3px; background: var(--brand); min-height: 3px; }
.week-bar.zero { background: var(--line); }
.week-col small { font-size: 11px; color: var(--muted); }
.week-col em { font-style: normal; font-size: 11px; color: var(--muted); }
.prog-list { display: flex; flex-direction: column; gap: 12px; }
.prog-row { display: flex; align-items: center; gap: 10px; }
.prog-row > div { flex: 1; }
.prog-row b { font-size: 14px; }
.prog-row small { color: var(--muted); }
.danger-zone { margin-top: 28px; display: flex; flex-direction: column; gap: 10px; }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--nav-h) + 20px + var(--safe-b)); z-index: 60;
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: #f1f5f9; color: #0b1020; font-weight: 600;
  padding: 10px 16px; border-radius: 14px; max-width: calc(100% - 32px);
  transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.mascot { flex: none; }
.error { padding: 40px 16px; text-align: center; color: var(--bad); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- learning phase ---------- */
.segments { flex: 1; display: flex; gap: 4px; }
.segments i { flex: 1; height: 8px; border-radius: 4px; background: var(--surface-2); transition: background .25s; }
.segments i.on { background: var(--sec, var(--brand)); }
.learn-card {
  display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center;
  width: 100%; margin-top: 18px; padding: 28px 20px;
  background: linear-gradient(180deg, color-mix(in srgb, var(--sec) 14%, var(--surface)), var(--surface));
  border: 1px solid color-mix(in srgb, var(--sec) 35%, var(--line)); border-radius: 24px;
  box-shadow: 0 6px 0 #0a0f1e;
}
.learn-card.enter { animation: slide-in .25s ease-out; }
.learn-ic {
  width: 72px; height: 72px; display: grid; place-items: center; font-size: 36px; border-radius: 50%;
  background: color-mix(in srgb, var(--sec) 25%, transparent);
  box-shadow: 0 0 0 6px color-mix(in srgb, var(--sec) 10%, transparent);
}
.learn-card small { color: var(--sec); font-weight: 600; }
.learn-card h2 { margin: 0; font-size: 22px; line-height: 1.4; }
.learn-card p { margin: 4px 0 0; font-size: 17px; line-height: 1.85; color: #d3daf0; }
button.learn-card.flash { cursor: pointer; }
.learn-card .hint { margin-top: 18px; padding: 8px 14px; border-radius: 999px; background: var(--surface-2); color: var(--muted); font-size: 14px; animation: bob 1.6s ease-in-out infinite; }
.flash-a {
  width: 100%; margin-top: 14px; padding: 14px 16px; border-radius: 16px; text-align: start;
  background: var(--bg); border: 1px dashed color-mix(in srgb, var(--sec) 60%, var(--line));
  animation: rise .2s ease-out;
}
.flash-a b { color: var(--gold); }
.flash-a p { margin: 6px 0 0; font-size: 16px; line-height: 1.8; color: var(--text); }
.learn-foot { flex-direction: row; }
.learn-foot .btn[data-act="learn-back"] { width: 64px; flex: none; font-size: 22px; }
.learn-foot .btn.primary { flex: 1; }

/* ---------- videos ---------- */
.video-frame {
  width: 100%; aspect-ratio: 16 / 9; border-radius: 18px; overflow: hidden;
  background: #000; border: 1px solid var(--line);
}
.video-frame video, .video-frame iframe { width: 100%; height: 100%; border: 0; display: block; }
.speed { display: flex; gap: 6px; justify-content: center; margin-top: 10px; direction: ltr; }
.speed .chip.on { background: var(--brand); color: var(--brand-ink); border-color: transparent; }
.video-card { display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; margin-top: 18px; }
.video-card.enter { animation: slide-in .25s ease-out; }
.video-card small { color: var(--sec); font-weight: 600; margin-top: 10px; }
.video-card h2 { margin: 0; font-size: 21px; line-height: 1.4; }
.video-list { display: flex; flex-direction: column; gap: 10px; }
.video-item {
  display: flex; align-items: center; gap: 12px; text-align: start; padding: 10px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 16px;
}
.video-thumb {
  position: relative; flex: none; width: 112px; aspect-ratio: 16 / 9; border-radius: 12px; overflow: hidden;
  background: linear-gradient(135deg, var(--sec), color-mix(in srgb, var(--sec) 40%, #000));
  display: grid; place-items: center;
}
.video-thumb img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.video-thumb i { position: relative; font-style: normal; width: 34px; height: 34px; display: grid; place-items: center; border-radius: 50%; background: #000a; color: #fff; font-size: 14px; }
.video-txt { flex: 1; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.video-txt small { color: var(--muted); text-align: right; }
.nav-btn { font-size: 11px; }

/* ---------- topic ring around lesson nodes ---------- */
.node-ring { position: relative; width: 108px; height: 108px; display: grid; place-items: center; }
.ring-segs { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; }
.ring-segs .seg { fill: none; stroke: #2a3352; stroke-width: 7; stroke-linecap: round; transition: stroke .3s; }
.ring-segs .seg.on { stroke: var(--sec); filter: drop-shadow(0 0 3px color-mix(in srgb, var(--sec) 60%, transparent)); }
.node-ring.locked .ring-segs .seg { stroke: #1d2440; }
.node-ring .node { position: relative; z-index: 1; width: 74px; height: 74px; }
.node-ring.current .node { animation: none; }
.node-ring.current .ring-segs { animation: ring-glow 1.8s ease-in-out infinite; }
@keyframes ring-glow { 50% { filter: drop-shadow(0 0 8px color-mix(in srgb, var(--sec) 55%, transparent)); } }
.node-wrap .node-tip { top: -26px; }
.node-stars { margin-top: 4px; }

.topic-list { list-style: none; padding: 0; margin: 0 0 16px; display: flex; flex-direction: column; gap: 8px; text-align: start; }
.topic-list li {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 14px;
  background: var(--surface-2); border: 1px solid var(--line); font-size: 15px; color: var(--muted);
}
.topic-list li.on { color: var(--text); border-color: color-mix(in srgb, var(--sec) 45%, var(--line)); }
.topic-dot {
  flex: none; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center;
  font-size: 13px; font-weight: 700; background: var(--line); color: var(--muted);
}
.topic-list li.on .topic-dot { background: var(--sec); color: #fff; }

/* ---------- reward chest node ---------- */
.ring-segs .seg.gold { stroke: #a16207; stroke-width: 6; }
.node-ring.chest.ready .ring-segs .seg.gold { stroke: var(--gold); filter: drop-shadow(0 0 6px #fbbf2499); }
.node-ring.chest.ready .ring-segs { animation: ring-glow-gold 1.6s ease-in-out infinite; }
@keyframes ring-glow-gold { 50% { filter: drop-shadow(0 0 12px #fbbf24aa); } }
.node-ring.chest.locked .ring-segs .seg.gold { stroke: #3a3220; }
.node.chest-node { font-size: 34px; background: linear-gradient(160deg, #3b2a0c, #1f1606); box-shadow: 0 7px 0 #120c02; }
.node.chest-node.ready { background: linear-gradient(160deg, #f59e0b, #b45309); box-shadow: 0 7px 0 #78350f; animation: wiggle 2.4s ease-in-out infinite; }
.node.chest-node.locked { opacity: .55; filter: grayscale(.6); }
@keyframes wiggle { 0%, 70%, 100% { transform: rotate(0); } 75% { transform: rotate(-8deg); } 85% { transform: rotate(8deg); } 95% { transform: rotate(-4deg); } }
.chest-sheet { text-align: center; padding: 6px 0 4px; }
.chest-sheet h3 { margin: 6px 0; font-size: 24px; }
.chest-sheet p { color: var(--muted); margin: 0 0 18px; font-size: 17px; }
.chest-sheet p b { color: var(--gold); }
.chest-burst { font-size: 72px; animation: pop .5s backwards; }
.lesson-sheet .muted { margin: -6px 0 14px; line-height: 1.6; }

/* ---------- question types ---------- */
.q-note { margin: -10px 0 14px; color: var(--muted); font-size: 14px; }
.fb-explain { white-space: pre-line; }

/* true / false cards */
.tf-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.tf-card {
  display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 22px 10px;
  border-radius: 20px; background: var(--surface); border: 2px solid var(--line); box-shadow: 0 5px 0 var(--line);
}
.tf-card b { font-size: 18px; }
.tf-ic { width: 52px; height: 52px; border-radius: 50%; display: grid; place-items: center; font-size: 26px; font-weight: 700; }
.tf-card.yes .tf-ic { background: #14532d; color: #4ade80; }
.tf-card.no .tf-ic { background: #4c0519; color: #fb7185; }
.tf-card.sel { border-color: #60a5fa; background: #13254a; box-shadow: 0 5px 0 #2b4f8f; }
.tf-card.right { border-color: var(--good); background: var(--good-bg); box-shadow: 0 5px 0 #166534; }
.tf-card.wrong { border-color: var(--bad); background: var(--bad-bg); box-shadow: 0 5px 0 #9f1239; animation: shake .3s; }
.tf-card.dim { opacity: .45; }

/* fill in the blank */
.blank {
  display: inline-flex; align-items: center; justify-content: center; vertical-align: middle;
  min-width: 96px; min-height: 38px; margin: 2px 6px; padding: 2px 12px; border-radius: 12px;
  border: 2px dashed #3b82f6; background: #0f1d3a; color: var(--text); font: inherit; font-weight: 700;
}
.blank.filled { border-style: solid; background: #13254a; }
.blank.right { border: 2px solid var(--good); background: var(--good-bg); color: #4ade80; }
.blank.wrong { border: 2px solid var(--bad); background: var(--bad-bg); color: #fb7185; }
.chips-row { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }
.word-chip {
  padding: 10px 16px; border-radius: 999px; font-weight: 600;
  background: var(--surface); border: 2px solid var(--line); box-shadow: 0 3px 0 var(--line);
}
.word-chip.used { visibility: hidden; }

/* multi select */
.opt.multi { display: flex; align-items: center; gap: 12px; }
.opt.multi .box {
  flex: none; width: 24px; height: 24px; border-radius: 7px; border: 2px solid var(--line);
  display: grid; place-items: center; font-size: 14px; font-weight: 700;
}
.opt.multi.sel .box { background: #3b82f6; border-color: #3b82f6; color: #fff; }
.opt.multi.right .box { background: var(--good); border-color: var(--good); color: #fff; }
.opt.multi.wrong .box { border-color: var(--bad); }

/* numeric answer */
.num-row { display: flex; gap: 10px; align-items: stretch; }
.num-input {
  flex: 1; min-width: 0; height: 64px; padding: 0 16px; border-radius: 18px; text-align: center;
  font: inherit; font-size: 28px; font-weight: 700; color: var(--text);
  background: var(--surface); border: 2px solid var(--line); outline: none;
}
.num-input:focus { border-color: #60a5fa; }
.num-input.right { border-color: var(--good); background: var(--good-bg); }
.num-input.wrong { border-color: var(--bad); background: var(--bad-bg); }
.num-unit {
  display: grid; place-items: center; min-width: 64px; padding: 0 12px; border-radius: 18px;
  background: var(--surface-2); border: 1px solid var(--line); font-weight: 700; color: var(--muted);
}

/* spell the term */
.spell-slots { display: flex; flex-wrap: wrap; justify-content: center; gap: 5px; margin-bottom: 18px; }
.slot {
  width: 26px; height: 34px; border-radius: 8px; display: grid; place-items: center; font-weight: 700;
  border-bottom: 3px solid var(--line); background: var(--surface);
}
.slot.on { border-color: #60a5fa; }
.slot.hinted { color: var(--gold); border-color: var(--gold); }
.spell-slots.right .slot { border-color: var(--good); color: #4ade80; }
.spell-slots.wrong .slot { border-color: var(--bad); color: #fb7185; }
.tiles { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.tile {
  width: 42px; height: 46px; border-radius: 12px; font-size: 18px; font-weight: 700;
  background: var(--surface); border: 2px solid var(--line); box-shadow: 0 3px 0 var(--line);
}
.tile:disabled { opacity: .2; box-shadow: none; }
.spell-tools { display: flex; justify-content: center; gap: 10px; margin-top: 16px; }
.spell-tools .chip:disabled { opacity: .4; }

/* ordering */
.order-list { display: flex; flex-direction: column; gap: 8px; }
.order-row {
  display: flex; align-items: center; gap: 10px; padding: 8px 8px 8px 12px; border-radius: 14px;
  background: var(--surface); border: 2px solid var(--line);
}
.order-row.right { border-color: var(--good); background: var(--good-bg); }
.order-row.wrong { border-color: var(--bad); background: var(--bad-bg); }
.order-n { flex: none; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); font-size: 13px; font-weight: 700; }
.order-txt { flex: 1; }
.order-btns { display: flex; gap: 4px; }
.order-btns button { width: 38px; height: 38px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--line); font-size: 13px; }
.order-btns button:disabled { opacity: .25; }

/* footer tools */
.reveal-btn {
  display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%;
  padding: 10px; border-radius: 14px; font-weight: 600; font-size: 14px;
  background: #2a1d05; border: 1px solid #854d0e; color: #fcd34d;
}
.reveal-btn span { background: #00000040; padding: 2px 8px; border-radius: 999px; }
.fb-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.report-btn { font-size: 13px; padding: 5px 10px; border-radius: 999px; background: #00000030; color: var(--muted); }
.fb-line { margin-top: 6px; font-weight: 600; line-height: 1.6; }
.fb-line.mine { color: #fda4af; }
.fb-line.right { color: #86efac; }
.lesson-foot.info { background: #2a1d05; border-color: #854d0e; animation: rise .2s ease-out; }
.lesson-foot.info .fb b { color: #fcd34d; }
.sheet-sub { text-align: center; color: var(--muted); margin: -6px 0 14px; }

/* ---------- language toggle ---------- */
.lang-toggle {
  flex: none; display: flex; padding: 3px; border-radius: 999px; direction: ltr;
  background: var(--surface); border: 1px solid var(--line);
}
.lang-toggle span { min-width: 32px; padding: 4px 8px; border-radius: 999px; font-size: 13px; font-weight: 700; color: var(--muted); text-align: center; }
.lang-toggle span.on { background: #38bdf8; color: #04121f; }
.lesson[dir="ltr"] .fb-head, .lesson[dir="ltr"] .fb-line, .lesson[dir="ltr"] .fb-explain { text-align: left; }

/* ---------- timed matching round ---------- */
.race-intro, .race-result {
  display: flex; flex-direction: column; align-items: center; text-align: center; gap: 10px;
  padding: 26px 18px; margin-top: 10px;
  background: linear-gradient(180deg, color-mix(in srgb, var(--brand) 12%, var(--surface)), var(--surface));
  border: 1px solid color-mix(in srgb, var(--brand) 40%, var(--line)); border-radius: 24px;
}
.race-ic, .race-seal {
  width: 86px; height: 86px; display: grid; place-items: center; border-radius: 50%; font-size: 40px;
  background: color-mix(in srgb, var(--brand) 22%, transparent);
  box-shadow: 0 0 0 8px color-mix(in srgb, var(--brand) 10%, transparent);
}
.race-seal.win { background: var(--good); color: #fff; }
.race-seal.timeout { background: var(--gold); color: var(--brand-ink); }
.race-intro h3, .race-result h3 { margin: 6px 0 0; font-size: 24px; }
.race-intro p, .race-result p { margin: 0; color: var(--muted); line-height: 1.7; max-width: 360px; }
.race-badge-time {
  margin: 4px 0 14px; padding: 8px 18px; border-radius: 999px; font-weight: 700; font-variant-numeric: tabular-nums;
  background: var(--surface-2); border: 1px solid var(--line); color: var(--gold);
}
.race-result .big-stars { margin: 4px 0 2px; }
.race-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; width: 100%; margin-top: 10px; }
.rstat {
  display: flex; flex-direction: column; gap: 2px; padding: 12px;
  background: var(--bg); border: 1px solid var(--line); border-radius: 16px;
}
.rstat small { color: var(--muted); font-size: 13px; }
.rstat b { font-size: 22px; font-variant-numeric: tabular-nums; }

.race-hud { display: flex; align-items: center; justify-content: center; gap: 10px; margin-bottom: 16px; }
.race-clock {
  min-width: 86px; padding: 8px 14px; border-radius: 999px; text-align: center;
  font-size: 20px; font-weight: 800; font-variant-numeric: tabular-nums;
  background: var(--surface); border: 1px solid var(--line); color: var(--text);
}
.race-clock.low { color: #fb7185; border-color: var(--bad); animation: tick 1s steps(2) infinite; }
@keyframes tick { 50% { background: var(--bad-bg); } }
.race-score {
  padding: 7px 12px; border-radius: 999px; font-size: 14px; font-weight: 600;
  background: var(--surface); border: 1px solid var(--line); color: var(--muted);
}
.race-score b { font-variant-numeric: tabular-nums; }
.race-score.good { color: #4ade80; border-color: #166534; }
.race-score.bad { color: #fb7185; border-color: #9f1239; }
.race-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; align-items: start; }
.race-cols .mcol > small {
  display: block; text-align: center; margin-bottom: 6px; font-size: 12px; font-weight: 700;
  letter-spacing: .06em; text-transform: uppercase; color: var(--brand);
}
.mcell.race { min-height: 58px; transition: opacity .25s, transform .25s; }
.mcell.race.gone { opacity: 0; transform: scale(.85); pointer-events: none; }

/* ---------- lesson parts (two cards + questions each, unlocked in order) ---------- */
.part-list { display: flex; flex-direction: column; gap: 10px; margin: 0 0 16px; text-align: start; }
.part-item {
  display: flex; align-items: center; gap: 12px; width: 100%; padding: 12px 14px; border-radius: 16px;
  background: var(--surface-2); border: 1px solid var(--line); color: var(--text); font: inherit; text-align: start; cursor: pointer;
}
.part-item.open { border-color: var(--sec); box-shadow: 0 4px 0 color-mix(in srgb, var(--sec) 45%, transparent); }
.part-item.done { border-color: color-mix(in srgb, var(--sec) 45%, var(--line)); }
.part-item.locked { opacity: .5; cursor: not-allowed; }
.part-num {
  flex: none; width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center;
  font-weight: 800; background: var(--line); color: var(--muted);
}
.part-item.open .part-num, .part-item.done .part-num { background: var(--sec); color: #fff; }
.part-txt { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.part-txt b { font-size: 16px; }
.part-txt small { color: var(--muted); font-size: 13px; line-height: 1.4; }
.part-txt em { font-style: normal; color: var(--muted); font-size: 12px; }
.part-stars { flex: none; font-size: 12px; }
.unlock-note { color: var(--sec, #22c55e); font-weight: 700; margin: 4px 0 10px; }

/* ---------- multiple choice as a grid of cards ---------- */
.options.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
@media (max-width: 330px) { .options.grid { grid-template-columns: 1fr; } }
.opt.ocard {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 8px; min-height: 96px; text-align: center; padding: 14px 10px;
}
.opt-ic {
  width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; font-size: 15px; color: #fff;
}
.opt-ic.s0 { background: #2563eb; } .opt-ic.s1 { background: #db2777; } .opt-ic.s2 { background: #d97706; }
.opt-ic.s3 { background: #059669; } .opt-ic.s4 { background: #7c3aed; } .opt-ic.s5 { background: #0891b2; }
.opt-txt { line-height: 1.4; }
.opt.ocard kbd {
  position: absolute; top: 6px; inset-inline-start: 8px; font: 600 11px/1 inherit; color: var(--muted); opacity: .7;
}

/* ---------- word-bank sentence ---------- */
.q-text .blank { min-width: 72px; margin: 4px 4px; vertical-align: middle; }
.chips-row.bank { margin-top: 6px; }
.word-chip.c0 { border-color: #3b82f6; color: #93c5fd; box-shadow: 0 3px 0 #1e40af; }
.word-chip.c1 { border-color: #10b981; color: #6ee7b7; box-shadow: 0 3px 0 #065f46; }
.word-chip.c2 { border-color: #f59e0b; color: #fcd34d; box-shadow: 0 3px 0 #92400e; }
.word-chip.c3 { border-color: #ec4899; color: #f9a8d4; box-shadow: 0 3px 0 #9d174d; }
.word-chip.c4 { border-color: #8b5cf6; color: #c4b5fd; box-shadow: 0 3px 0 #5b21b6; }

/* ---------- short typed answer ---------- */
.text-answer { display: flex; flex-direction: column; gap: 8px; }
.text-meta { display: flex; justify-content: space-between; color: var(--muted); }
.text-input {
  width: 100%; padding: 14px 16px; border-radius: 14px; font: 600 18px/1.3 inherit; color: var(--text);
  background: var(--surface); border: 2px solid var(--line); outline: none;
}
.text-input:focus { border-color: #60a5fa; }
.text-input.right { border-color: var(--good); background: var(--good-bg); }
.text-input.wrong { border-color: var(--bad); background: var(--bad-bg); }
.text-hint { margin: 0; color: var(--gold); font-size: 14px; }

/* ---------- daily quests ---------- */
.quest-card {
  position: relative; display: flex; align-items: center; gap: 12px; width: 100%; margin-top: 12px; text-align: start;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; color: var(--text); font: inherit;
}
.quest-card .badge { top: -6px; left: -6px; }
.quest-ic { flex: none; width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; font-size: 20px; background: var(--surface-2); }
.quest-txt { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.quest-txt small { color: var(--muted); }
.month-n { font-weight: 800; color: var(--muted); }
.quests-head { display: flex; align-items: center; gap: 10px; font-size: 28px; }
.quests-head .page-title { margin: 4px 0; }
.quest-list { display: flex; flex-direction: column; gap: 10px; margin: 10px 0 14px; }
.quest {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 16px;
  background: var(--surface); border: 1px solid var(--line);
}
.quest.done { border-color: color-mix(in srgb, var(--good) 55%, var(--line)); }
.quest.done .bar i { background: var(--good); }
.quest-gift { font-size: 20px; opacity: .45; }
.quest-got { color: var(--good); font-weight: 800; font-size: 20px; }
.chip.claim { background: var(--good); color: #052e16; border-color: transparent; }
.month-card {
  padding: 14px; border-radius: 16px; margin-bottom: 18px;
  background: linear-gradient(160deg, #2e1065, #1e1b4b); border: 1px solid #4c1d95;
}
.month-card.done { border-color: var(--gold); }
.month-top { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.month-top > div { flex: 1; display: flex; flex-direction: column; }
.month-top small { color: #c4b5fd; }
.month-card .bar i { background: linear-gradient(90deg, #a78bfa, #f472b6); }
.month-card .btn { margin-top: 12px; }
.month-got { color: var(--gold); margin: 10px 0 0; font-weight: 700; }

/* ---------- daily reward & ready popup ---------- */
.reward-sheet, .ready-sheet { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 4px 0; }
.reward-sheet h3, .ready-sheet h3 { margin: 2px 0; font-size: 24px; }
.streak-pill { background: #431407; color: #fdba74; border-radius: 999px; padding: 4px 12px; font-weight: 700; font-size: 13px; }
.reward-box {
  display: flex; flex-direction: column; align-items: center; padding: 10px 20px; border-radius: 14px;
  background: var(--surface-2); border: 1px solid var(--line);
}
.reward-box b { font-size: 26px; color: var(--gold); }
.reward-box small { color: var(--muted); }
.btn.gold { background: linear-gradient(180deg, #fbbf24, #f59e0b); color: #3b2300; border-color: transparent; box-shadow: 0 4px 0 #b45309; }
.ready-ic {
  width: 64px; height: 64px; border-radius: 50%; display: grid; place-items: center; font-size: 30px; font-weight: 800;
  background: linear-gradient(160deg, #6366f1, #8b5cf6); color: #fff; box-shadow: 0 0 0 8px #6366f122;
}
.ready-tag { background: var(--good-bg); color: var(--good); border-radius: 999px; padding: 3px 10px; font-size: 12px; font-weight: 700; }
.ready-sheet small { color: var(--muted); margin-bottom: 8px; }

/* ---------- mascot faces on map nodes ---------- */
.node { overflow: visible; }
.node-face { width: 70%; height: 70%; pointer-events: none; }
.node.locked .node-face { filter: grayscale(.35) brightness(.85); }
.node-badge {
  position: absolute; top: -4px; inset-inline-end: -4px; width: 26px; height: 26px; border-radius: 50%;
  display: grid; place-items: center; font-style: normal; font-size: 13px; font-weight: 800; pointer-events: none;
}
.node-badge.lock { background: #1d2440; border: 2px solid var(--bg, #0b1020); }
.node-badge.ok { background: var(--gold); color: #3b2300; border: 2px solid var(--bg, #0b1020); }

/* ---------- detailed points on a concept card ---------- */
.card-points {
  width: 100%; margin-top: 14px; padding: 12px 14px; border-radius: 14px; text-align: start;
  background: color-mix(in srgb, var(--sec) 10%, var(--surface-2)); border: 1px solid color-mix(in srgb, var(--sec) 30%, var(--line));
}
.card-points b { display: block; font-size: 14px; color: var(--sec); margin-bottom: 6px; }
.card-points ul { margin: 0; padding-inline-start: 20px; display: flex; flex-direction: column; gap: 7px; }
.card-points li { font-size: 15px; line-height: 1.7; color: #d3daf0; }
.card-points li::marker { color: var(--sec); }
