/* Fonts are served from this site (no Google Fonts), so visitors' browsers don't contact third parties. SIL Open Font License, see fonts/.
   Fredoka is used for the whole site: rounded and friendly for 8-14 year olds, still easy to read. */
@font-face { font-family: "Fredoka"; font-style: normal; font-weight: 400; font-display: swap; src: url("../fonts/fredoka-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "Fredoka"; font-style: normal; font-weight: 500; font-display: swap; src: url("../fonts/fredoka-latin-500-normal.woff2") format("woff2"); }
@font-face { font-family: "Fredoka"; font-style: normal; font-weight: 500; font-display: swap; src: url("../fonts/fredoka-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "Fredoka"; font-style: normal; font-weight: 600; font-display: swap; src: url("../fonts/fredoka-latin-700-normal.woff2") format("woff2"); }

/* CoinSprouts theme: "Sprout" (day, default) and "Night Garden" (night).
   Brand colors from the CoinSprouts logo: deep ocean blue + sprout green, with a coin-gold accent. */
:root,
:root[data-theme="light"] {
  --bg: #f3f9ee;
  --bg-glow: radial-gradient(circle at 100% 0%, rgba(47, 125, 37, .10) 0, transparent 40%), #f3f9ee;
  --card: #ffffff;
  --card-2: #fbfdf9;
  --soft: #eaf4e3;
  --line: #d3e4c9;
  --text: #0d3346;
  --muted: #557080;
  --brand: #013d56;
  --green: #2f7d25;
  --green-soft: #e3f2dc;
  --gold: #b07d12;
  --gold-soft: #fbf1d6;
  --good: #23874a;
  --warn: #c7731a;
  --bad: #c93a3a;
  --btn: #2f7d25;
  --btn-text: #ffffff;
  --bar-a: #2f7d25;
  --bar-b: #e2b13c;
  --nav: #ffffff;
  --hero: linear-gradient(150deg, #013d56 0%, #0b5a5f 100%);
  --hero-text: #ffffff;
  --hero-muted: #cde4e8;
  --hero-hi: #ffd66b;
  --hero-btn: linear-gradient(180deg, #ffe08a, #e2b13c);
  --hero-btn-text: #2b1d00;
  --shadow: 0 10px 28px rgba(1, 61, 86, .12);
  --card-shadow: 0 3px 12px rgba(1, 61, 86, .06);
  --r: 22px;
  --font: "Fredoka", ui-rounded, -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --font-display: "Fredoka", ui-rounded, -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
}
:root[data-theme="dark"] {
  --bg: #0b1d24;
  --bg-glow: radial-gradient(circle at 0% 0%, rgba(77, 201, 110, .13) 0, transparent 45%), #0b1d24;
  --card: #12303a;
  --card-2: #163844;
  --soft: rgba(255, 255, 255, .06);
  --line: #23505c;
  --text: #e8f5f2;
  --muted: #9cbcc2;
  --brand: #8fd8ea;
  --green: #5ed37a;
  --green-soft: rgba(94, 211, 122, .14);
  --gold: #ffd166;
  --gold-soft: rgba(255, 209, 102, .14);
  --good: #5ed37a;
  --warn: #ffb04f;
  --bad: #ff7f73;
  --btn: #5ed37a;
  --btn-text: #06281a;
  --bar-a: #5ed37a;
  --bar-b: #ffd166;
  --nav: rgba(11, 29, 36, .96);
  --hero: linear-gradient(150deg, #0f4b5c 0%, #12303a 70%);
  --hero-text: #e8f5f2;
  --hero-muted: #b7d5da;
  --hero-hi: #ffd166;
  --shadow: 0 10px 28px rgba(0, 0, 0, .4);
  --card-shadow: none;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; touch-action: manipulation; }
html, body { margin: 0; padding: 0; overflow-x: hidden; }
body { font-family: var(--font); background: var(--bg-glow); background-attachment: fixed; color: var(--text); min-height: 100vh; -webkit-font-smoothing: antialiased; }
body.locked { overflow: hidden; }
button, input, select, textarea { font-family: inherit; }
button, a, .tab { -webkit-tap-highlight-color: transparent; }
input, select, textarea { font-size: 16px; }
h1, h2, h3, h4 { margin: 0 0 8px; font-family: var(--font-display); font-weight: 600; letter-spacing: 0; line-height: 1.2; }
.level-name, .big-num, .result-big, .town-stat .n, .sum .n, .party-emoji + h1, .shop-name, .badge-name, .gate-card h1 { font-family: var(--font-display); font-weight: 600; letter-spacing: 0; }
h1 { font-size: 28px; } h2 { font-size: 22px; } h3 { font-size: 17px; }
p { line-height: 1.55; margin: 0 0 10px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
a { color: var(--green); }
img, svg, table, pre, video { max-width: 100%; }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(12px + env(safe-area-inset-top)) calc(22px + env(safe-area-inset-right)) 12px calc(22px + env(safe-area-inset-left));
  background: var(--nav); border-bottom: 1px solid var(--line);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-logo { height: 38px; width: auto; display: block; }
.brand-fallback { font-size: 28px; }
:root[data-theme="dark"] .brand-logo { filter: brightness(1.15); }
.stats { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
.stat { display: flex; align-items: center; gap: 6px; padding: 7px 13px; border-radius: 999px; background: var(--card); border: 1px solid var(--line); font-weight: 600; font-size: 14px; }
.stat-lbl { color: var(--muted); font-weight: 500; font-size: 12px; }
.ghost-btn { background: var(--card); color: var(--text); border: 1px solid var(--line); border-radius: 999px; padding: 7px 13px; font-size: 13px; font-weight: 600; cursor: pointer; }
.ghost-btn:hover { border-color: var(--muted); }
.ghost-btn.danger { color: var(--bad); }
.me-btn { display: none; }

/* ---------- Tabs ---------- */
.tabs {
  display: flex; gap: 6px; padding: 10px calc(22px + env(safe-area-inset-right)) 10px calc(22px + env(safe-area-inset-left));
  background: var(--nav); border-bottom: 1px solid var(--line);
  overflow-x: auto; scrollbar-width: none; position: sticky; top: 63px; z-index: 29;
}
.tabs::-webkit-scrollbar { display: none; }
.tab { flex: 0 0 auto; display: flex; align-items: center; gap: 6px; white-space: nowrap; background: transparent; border: 1px solid transparent; color: var(--muted); padding: 9px 16px; border-radius: 999px; font-size: 14px; font-weight: 600; cursor: pointer; }
.tab:hover { color: var(--text); background: var(--card); }
.tab.active { background: var(--btn); color: var(--btn-text); }

/* ---------- Layout ---------- */
main { max-width: 1100px; margin: 0 auto; padding: 26px 22px calc(80px + env(safe-area-inset-bottom)); }
main, .card { min-width: 0; overflow-wrap: anywhere; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 20px; margin-bottom: 16px; box-shadow: var(--card-shadow); }
.card-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; margin-bottom: 16px; }
.card-row > .card { margin: 0; }
.row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.spread { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; }
.big-num { font-size: 30px; font-weight: 700; margin: 4px 0; }
.gold { color: var(--gold); } .green { color: var(--green); }
.pos { color: var(--good); } .neg { color: var(--bad); }
.page-title { margin-bottom: 4px; }
.page-lead { color: var(--muted); margin-bottom: 18px; }

/* ---------- Buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; background: var(--btn); color: var(--btn-text); border: none; padding: 13px 24px; border-radius: 999px; font-size: 15px; font-weight: 600; cursor: pointer; transition: transform .06s ease, opacity .2s ease; }
.btn:hover { opacity: .9; }
.btn:active { transform: scale(.98); }
.btn.secondary { background: var(--card); color: var(--text); border: 1px solid var(--line); }
.btn.gold-btn { background: var(--hero-btn); color: var(--hero-btn-text); }
.btn.small-btn { padding: 9px 14px; font-size: 14px; }
.btn[disabled] { background: var(--soft); color: var(--muted); cursor: default; opacity: .7; }
.link-btn { background: none; border: none; padding: 4px 0; color: var(--green); font-weight: 600; text-decoration: underline; cursor: pointer; font-size: 14px; }

/* ---------- Hero (today's lesson) ---------- */
.hero { background: var(--hero); color: var(--hero-text); border-radius: var(--r); padding: 26px; margin-bottom: 18px; box-shadow: 0 12px 30px rgba(1, 61, 86, .25); }
.hero h1 { font-size: 30px; color: var(--hero-text); }
.hero p { color: var(--hero-muted); }
.hero .muted { color: var(--hero-muted); }
.hero .teaser { color: var(--hero-hi); font-weight: 600; margin: 12px 0 0; }
.hero .btn { background: var(--hero-btn); color: var(--hero-btn-text); }

/* ---------- Level ---------- */
.level-card { background: linear-gradient(135deg, var(--green-soft), var(--gold-soft)); border: 1px solid var(--line); border-radius: var(--r); padding: 18px 22px; margin-bottom: 16px; }
.level-name { font-size: 20px; font-weight: 700; }
.level-name small { font-size: 13px; color: var(--muted); font-weight: 600; }
.level-next { color: var(--muted); font-size: 13px; }
.bar { background: var(--soft); border-radius: 999px; height: 10px; overflow: hidden; margin-top: 10px; }
:root[data-theme="light"] .level-card .bar { background: rgba(255,255,255,.7); }
.bar > span { display: block; height: 100%; background: linear-gradient(90deg, var(--bar-a), var(--bar-b)); border-radius: 999px; transition: width .5s ease; }
.bar-row { display: flex; align-items: center; gap: 10px; margin-top: 10px; }
.bar-row .bar { flex: 1; margin: 0; }
.bar-text { font-size: 12px; color: var(--muted); font-weight: 600; white-space: nowrap; }

/* ---------- Units & lessons ---------- */
.unit-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.unit-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 18px; cursor: pointer; transition: transform .12s ease, border-color .15s ease; box-shadow: var(--card-shadow); }
.unit-card:hover { transform: translateY(-2px); border-color: var(--green); }
.unit-card.locked { opacity: .5; cursor: not-allowed; }
.unit-card.locked:hover { transform: none; border-color: var(--line); }
.unit-card.done { border-color: color-mix(in srgb, var(--good) 60%, transparent); }
.pill { display: inline-block; border: 1px solid var(--gold); color: var(--gold); border-radius: 999px; padding: 2px 10px; font-size: 11px; font-weight: 700; letter-spacing: .6px; text-transform: uppercase; margin-bottom: 8px; }
.unit-card .desc { color: var(--muted); font-size: 13px; }
.lesson-list { display: flex; flex-direction: column; gap: 10px; margin-top: 16px; }
.lesson-item { display: flex; align-items: center; gap: 14px; background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 14px 18px; cursor: pointer; transition: transform .12s ease; }
.lesson-item:hover { transform: translateY(-1px); border-color: var(--green); }
.lesson-item.locked { opacity: .5; cursor: not-allowed; }
.lesson-item.locked:hover { transform: none; border-color: var(--line); }
.lesson-item.done { border-color: color-mix(in srgb, var(--good) 55%, transparent); }
.lesson-num { width: 38px; height: 38px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 700; background: var(--soft); border: 1px solid var(--line); color: var(--muted); flex: 0 0 38px; }
.lesson-item.done .lesson-num { background: var(--good); border-color: var(--good); color: #fff; }
.lesson-meta { flex: 1; min-width: 0; }
.lesson-title { font-weight: 600; }
.lesson-sub { color: var(--muted); font-size: 13px; }
.mm-chip { color: var(--gold); font-weight: 600; }
.lesson-state { color: var(--muted); font-size: 13px; font-weight: 600; white-space: nowrap; }

/* ---------- Lesson player ---------- */
.dots { display: flex; gap: 5px; margin: 6px 0 18px; }
.dots span { flex: 1; height: 7px; border-radius: 999px; background: var(--soft); }
.dots span.done { background: var(--green); }
.dots span.now { background: var(--gold); }
.stage { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 26px; min-height: 280px; box-shadow: var(--card-shadow); }
.tag { display: inline-block; border: 1.5px solid currentColor; border-radius: 999px; padding: 3px 11px; font-size: 11px; font-weight: 700; letter-spacing: .8px; text-transform: uppercase; margin-bottom: 12px; color: var(--gold); }
.tag.t-activity, .tag.t-decide { color: var(--green); }
.tag.t-input, .tag.t-reflect { color: var(--warn); }
.tag.t-story { color: var(--brand); }
.step-body { font-size: 16px; line-height: 1.7; }
.step-body p { margin: 0 0 12px; }
.step-body ul, .step-body ol { padding-left: 22px; margin: 6px 0 12px; }
.step-body li { margin-bottom: 5px; }
.step-body strong { color: var(--gold); }
.step-body em { color: var(--green); font-style: normal; font-weight: 600; }
.callout { background: var(--soft); border-left: 4px solid var(--gold); border-radius: 0 14px 14px 0; padding: 14px 18px; margin: 12px 0; }
.callout.warn { border-left-color: var(--warn); }
.choices { display: flex; flex-direction: column; gap: 10px; margin-top: 14px; }
.choice { text-align: left; background: var(--card-2); border: 2px solid var(--line); border-radius: 16px; padding: 14px 16px; font-size: 15px; color: var(--text); cursor: pointer; transition: border-color .15s ease, background .15s ease; }
.choice:hover { border-color: var(--green); }
.choice.right { border-color: var(--good); background: color-mix(in srgb, var(--good) 15%, transparent); }
.choice.wrong { border-color: var(--bad); background: color-mix(in srgb, var(--bad) 12%, transparent); }
.choice.picked { border-color: var(--gold); background: var(--gold-soft); }
.choice[disabled] { cursor: default; }
.choice.mm[disabled]:not(.picked) { opacity: .55; }
.text-input { width: 100%; background: var(--card-2); border: 2px solid var(--line); border-radius: 14px; padding: 12px 14px; color: var(--text); }
.text-input:focus { outline: none; border-color: var(--green); }
textarea.text-input { min-height: 110px; resize: vertical; }
.input-row { display: flex; gap: 8px; margin-top: 12px; }
.input-row .text-input { flex: 1; }
.feedback { display: none; margin-top: 14px; padding: 12px 16px; border-radius: 14px; font-size: 14px; font-weight: 500; }
.feedback.show { display: block; }
.feedback.good { background: color-mix(in srgb, var(--good) 14%, transparent); color: var(--good); border: 1px solid color-mix(in srgb, var(--good) 35%, transparent); }
.feedback.bad { background: color-mix(in srgb, var(--bad) 12%, transparent); color: var(--bad); border: 1px solid color-mix(in srgb, var(--bad) 30%, transparent); }
.feedback.plain { display: block; background: none; border: none; color: var(--muted); padding: 8px 0 0; }
.bonus { color: var(--gold); font-weight: 700; }
.controls { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 22px; padding-top: 16px; border-top: 1px solid var(--line); }
.mm-out, .mm-why { margin-top: 16px; padding: 16px; border-radius: 16px; background: var(--soft); border: 1px solid var(--line); }
.mm-out { border-color: color-mix(in srgb, var(--gold) 55%, transparent); }
.mm-label { font-size: 12px; font-weight: 700; letter-spacing: .6px; text-transform: uppercase; color: var(--gold); margin-bottom: 6px; }
.fx { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.fx span { font-size: 13px; font-weight: 600; padding: 4px 10px; border-radius: 999px; background: var(--card); border: 1px solid var(--line); }
.mm-why details { margin-top: 10px; }
.mm-why summary { cursor: pointer; font-weight: 600; font-size: 14px; }
.mm-other { margin-top: 10px; font-size: 14px; }
.mm-other strong { display: block; color: var(--text); }

/* ---------- Lesson complete ---------- */
.party { text-align: center; background: linear-gradient(135deg, var(--green-soft), var(--gold-soft)); border: 1px solid var(--line); border-radius: var(--r); padding: 30px 22px; animation: glow 2.4s ease infinite; }
.party-emoji { font-size: 64px; display: block; animation: hop 1.2s ease infinite; }
.party h1 { color: var(--text); }
.levelup { display: inline-block; margin-top: 14px; background: color-mix(in srgb, var(--good) 15%, transparent); color: var(--good); border-left: 4px solid var(--good); border-radius: 0 12px 12px 0; padding: 10px 16px; font-weight: 600; }
.explain-box { margin: 22px auto 0; max-width: 520px; text-align: left; background: var(--card); border: 2px solid var(--gold); border-radius: var(--r); padding: 18px 20px; }
.explain-box.done { border-color: var(--good); }
.explain-done { color: var(--good); font-weight: 600; }
@keyframes glow { 0%, 100% { box-shadow: 0 0 0 rgba(0,0,0,0); } 50% { box-shadow: 0 0 34px color-mix(in srgb, var(--gold) 28%, transparent); } }
@keyframes hop { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-10px); } }

/* ---------- Badges ---------- */
.badge-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; }
.badge { background: var(--card); border: 1px solid var(--line); border-radius: 20px; padding: 18px 12px; text-align: center; }
.badge.earned { border-color: color-mix(in srgb, var(--gold) 60%, transparent); box-shadow: 0 0 22px color-mix(in srgb, var(--gold) 25%, transparent); }
.badge.locked { opacity: .38; filter: grayscale(85%); }
.badge-ic { font-size: 38px; display: block; margin-bottom: 6px; }
.badge-name { font-weight: 700; font-size: 13px; margin-bottom: 4px; }
.badge-desc { font-size: 11.5px; color: var(--muted); line-height: 1.4; }
.toasts { position: fixed; top: 96px; right: 22px; z-index: 100; display: flex; flex-direction: column; align-items: flex-end; gap: 10px; pointer-events: none; }
.toast { display: flex; align-items: center; gap: 12px; background: var(--btn); color: var(--btn-text); padding: 13px 20px; border-radius: 18px; box-shadow: var(--shadow); font-weight: 600; max-width: 320px; animation: slideIn .4s ease, slideOut .4s ease 4.4s forwards; }
.toast .t-ic { font-size: 30px; }
.toast .t-small { font-size: 11px; opacity: .85; text-transform: uppercase; letter-spacing: .5px; }
@keyframes slideIn { from { transform: translateX(120%); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes slideOut { from { transform: none; opacity: 1; } to { transform: translateX(120%); opacity: 0; } }

/* ---------- Coin Town ---------- */
.town-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); gap: 10px; margin-bottom: 16px; }
.town-stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; text-align: center; }
.town-stat .n { font-size: 22px; font-weight: 700; }
.town-stat .l { font-size: 12px; color: var(--muted); margin-top: 4px; font-weight: 600; }
.line { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.line:last-child { border-bottom: none; }
.line > span:last-child { font-weight: 700; white-space: nowrap; }
.line.total { font-weight: 700; }
.event { background: var(--soft); border-radius: 12px; padding: 8px 12px; margin: 8px 0; font-size: 14px; }
.payday { border-color: color-mix(in srgb, var(--gold) 60%, transparent); }
.owned { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.owned:last-child { border-bottom: none; }
.owned-ic { font-size: 28px; }
.owned-meta { flex: 1; min-width: 0; }
.chip { display: inline-block; font-size: 11px; font-weight: 700; padding: 2px 9px; border-radius: 999px; margin-left: 4px; white-space: nowrap; background: var(--soft); color: var(--muted); vertical-align: middle; }
.chip.active { color: var(--gold); background: var(--gold-soft); }
.chip.passive, .chip.residual, .chip.invest { color: var(--good); background: color-mix(in srgb, var(--good) 14%, transparent); }
.chip.bill, .chip.debt { color: var(--bad); background: color-mix(in srgb, var(--bad) 12%, transparent); }
.shop-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.shop-item { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; display: flex; flex-direction: column; gap: 8px; }
.shop-item.locked { opacity: .6; }
.shop-top { display: flex; justify-content: space-between; align-items: center; }
.shop-ic { font-size: 32px; }
.shop-name { font-weight: 700; font-size: 16px; }
.shop-desc { font-size: 13px; color: var(--muted); line-height: 1.45; }
.shop-item .btn, .shop-lock { margin-top: auto; }
.shop-lock { font-size: 12px; color: var(--muted); }
.btns { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.btns .btn { padding: 10px 15px; font-size: 14px; }

/* tour */
.tour-shade { position: fixed; inset: 0; z-index: 55; background: rgba(0, 0, 0, .55); }
.tour-box { position: absolute; left: 50%; transform: translateX(-50%); z-index: 60; width: calc(100% - 32px); max-width: 460px; background: var(--card); border: 2px solid var(--gold); border-radius: var(--r); padding: 16px; box-shadow: var(--shadow); }
.tour-box.center { position: fixed; top: 50% !important; transform: translate(-50%, -50%); }
.tour-box.below::before, .tour-box.above::after { content: ""; position: absolute; left: 50%; margin-left: -9px; border: 9px solid transparent; }
.tour-box.below::before { top: -20px; border-bottom-color: var(--gold); }
.tour-box.above::after { bottom: -20px; border-top-color: var(--gold); }
.tour-text { font-size: 16px; line-height: 1.5; }
.tour-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 14px; font-size: 13px; }
.tour-hl { outline: 3px solid var(--gold); outline-offset: 4px; border-radius: var(--r); position: relative; z-index: 56; background: var(--bg); box-shadow: 0 0 0 4px var(--bg); }

/* ---------- Tools ---------- */
.tool-card { cursor: pointer; transition: transform .12s ease, border-color .15s ease; }
.tool-card:hover { transform: translateY(-2px); border-color: var(--green); }
.tool-card.open { border-color: var(--gold); }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.field label { font-size: 12px; color: var(--muted); font-weight: 600; }
.field-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
.result { background: var(--soft); border-radius: 16px; padding: 18px; margin-top: 14px; }
.result-row { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.result-row:last-child { border-bottom: none; }
.result-big { font-size: 34px; font-weight: 700; color: var(--gold); line-height: 1.1; }
table.tbl { width: 100%; border-collapse: collapse; margin-top: 12px; font-size: 13px; }
.tbl th, .tbl td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.tbl th { color: var(--muted); font-weight: 600; }
.scroll-x { overflow-x: auto; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.chip-btn { background: var(--card); border: 1px solid var(--line); color: var(--text); border-radius: 999px; padding: 7px 13px; font-weight: 600; cursor: pointer; font-size: 13px; }
.chip-btn.on { background: var(--gold); border-color: var(--gold); color: #2b1d00; }

/* ---------- Parents ---------- */
.kid-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 10px; margin: 6px 0 14px; }
.kid-card { display: flex; flex-direction: column; gap: 3px; text-align: left; background: var(--card); border: 2px solid var(--line); border-radius: 18px; padding: 12px 14px; cursor: pointer; color: var(--text); font: inherit; }
.kid-card.viewing { border-color: var(--gold); }
.kid-card.add { border-style: dashed; }
.kid-card b { font-size: 16px; }
.here { font-size: 11px; color: var(--green); font-weight: 700; margin-left: 4px; }
.summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; margin-bottom: 16px; }
.sum { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 14px; text-align: center; }
.sum .n { font-size: 26px; font-weight: 700; color: var(--gold); line-height: 1.15; }
.sum .l { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; font-weight: 600; }
.note-card { background: var(--card); border: 1px solid var(--line); border-left: 4px solid var(--gold); border-radius: var(--r); padding: 18px 20px; margin-bottom: 16px; }
.note-label { font-size: 12px; font-weight: 700; letter-spacing: .6px; text-transform: uppercase; color: var(--gold); margin-bottom: 8px; }
.big-q { font-size: 18px; font-weight: 600; line-height: 1.4; margin: 0; }
.qa { display: grid; grid-template-columns: 1fr 2fr; gap: 14px; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.qa:last-child { border-bottom: none; }
.qa .q { color: var(--muted); }
.qa .a { white-space: pre-wrap; }
.ok { color: var(--good); font-weight: 700; } .ko { color: var(--bad); font-weight: 700; }
.unit-answers h3 { border-bottom: 1px solid var(--line); padding-bottom: 8px; margin-bottom: 10px; }
.unit-answers details { margin-bottom: 6px; }
.unit-answers summary { cursor: pointer; padding: 8px 0; font-weight: 600; }

/* ---------- Modals & gate ---------- */
.modal { position: fixed; inset: 0; z-index: 70; display: flex; align-items: center; justify-content: center; padding: 20px; background: rgba(4, 20, 26, .62); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }
.modal-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 32px 28px; width: 100%; max-width: 460px; max-height: calc(100vh - 40px); overflow-y: auto; text-align: center; box-shadow: var(--shadow); }
.modal-card.wide { max-width: 580px; text-align: left; }
.modal-card .choices { margin-top: 16px; }
.welcome-dots { display: flex; justify-content: center; gap: 6px; margin-bottom: 18px; }
.welcome-dots span { width: 9px; height: 9px; border-radius: 50%; background: var(--line); }
.welcome-dots span.on { background: var(--gold); }
.skip { margin-top: 14px; background: none; border: none; color: var(--muted); font-size: 13px; text-decoration: underline; cursor: pointer; }
.gate { position: fixed; inset: 0; z-index: 90; overflow-y: auto; display: flex; align-items: center; justify-content: center; padding: calc(24px + env(safe-area-inset-top)) 20px 24px; background: var(--bg-glow); background-color: var(--bg); }
.gate[hidden] { display: none; }
.gate-card { width: 100%; max-width: 400px; background: var(--card); border: 1px solid var(--line); border-radius: 26px; padding: 30px 24px; box-shadow: var(--shadow); text-align: center; }
.gate-logo { display: block; width: min(230px, 75%); margin: 0 auto 14px; }
.gate-card h1 { font-size: 24px; }
.gate-card input { width: 100%; margin-bottom: 12px; }
.gate-card .btn { width: 100%; }
.gate-card .btn + .btn { margin-top: 10px; }
.gate-links { display: flex; flex-direction: column; gap: 8px; margin-top: 16px; font-size: 14px; }
.gate-links a { color: var(--green); font-weight: 600; text-decoration: none; }
.gate-msg { margin-top: 14px; font-size: 14px; font-weight: 600; }
.gate-msg.bad { color: var(--bad); } .gate-msg.good { color: var(--good); }
.gate-help { font-size: 12px; color: var(--muted); margin: 18px 0 0; }
.pass-wrap { position: relative; }
.pass-wrap input { padding-right: 76px; }
.pass-toggle { position: absolute; right: 8px; top: 8px; padding: 6px 10px; font-size: 13px; font-weight: 600; background: transparent; color: var(--muted); border: 1px solid var(--line); border-radius: 10px; cursor: pointer; }
.kid-list { display: flex; flex-direction: column; gap: 10px; margin: 6px 0 12px; }
.kid-pick { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; text-align: left; background: var(--card-2); color: var(--text); border: 2px solid var(--line); border-radius: 16px; padding: 12px 16px; cursor: pointer; font: inherit; }
.kid-pick.current { border-color: var(--gold); }
.kid-pick b { font-size: 17px; }
.kid-pick small { color: var(--muted); font-size: 13px; }
.add-kid { text-align: left; margin-top: 8px; }
.add-kid summary { cursor: pointer; font-weight: 600; padding: 8px 0; }
.add-kid select { width: 100%; margin-bottom: 12px; }
.demo-banner { position: fixed; left: 14px; bottom: 14px; pointer-events: none; opacity: .92; z-index: 45; background: var(--gold); color: #2b1d00; font-weight: 600; font-size: 12px; padding: 6px 14px; border-radius: 999px; box-shadow: var(--shadow); }

/* ---------- Phone sheet ---------- */
.sheet { position: fixed; inset: 0; z-index: 80; }
.sheet[hidden] { display: none; }
.sheet-shade { position: absolute; inset: 0; background: rgba(0, 0, 0, .4); opacity: 0; transition: opacity .2s ease; }
.sheet-panel { position: absolute; left: 0; right: 0; bottom: 0; max-width: 520px; margin: 0 auto; background: var(--card); border-radius: 26px 26px 0 0; padding: 8px 16px calc(16px + env(safe-area-inset-bottom)); transform: translateY(100%); transition: transform .22s ease; box-shadow: var(--shadow); }
.sheet.open .sheet-shade { opacity: 1; }
.sheet.open .sheet-panel { transform: none; }
.sheet-grab { width: 40px; height: 5px; border-radius: 999px; background: var(--line); margin: 0 auto 14px; }
.sheet-who { display: flex; align-items: center; gap: 12px; padding: 0 4px 14px; border-bottom: 1px solid var(--line); }
.sheet-who b { display: block; font-size: 18px; }
.sheet-who small { color: var(--muted); font-size: 13px; }
.sheet-avatar { width: 44px; height: 44px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; background: var(--btn); color: var(--btn-text); font-weight: 700; font-size: 18px; }
.sheet-item { display: block; width: 100%; text-align: left; padding: 15px 6px; font-size: 16px; font-weight: 600; background: none; border: none; border-bottom: 1px solid var(--line); color: var(--text); cursor: pointer; }
.sheet-close { border-bottom: none; text-align: center; color: var(--muted); }

/* ---------- Phones ---------- */
@media (max-width: 640px) {
  h1 { font-size: 24px; } h2 { font-size: 19px; }
  .topbar { padding: calc(10px + env(safe-area-inset-top)) calc(12px + env(safe-area-inset-right)) 10px calc(12px + env(safe-area-inset-left)); gap: 8px; }
  .brand-logo { height: 30px; }
  .stats { flex-wrap: nowrap; gap: 6px; flex: 1; justify-content: flex-end; }
  .stat { padding: 6px 9px; font-size: 13px; }
  .stat-lbl, .top-only { display: none !important; }
  .me-btn { display: inline-flex; align-items: center; justify-content: center; flex: 0 0 38px; width: 38px; height: 38px; border-radius: 50%; background: var(--btn); color: var(--btn-text); border: none; font-weight: 700; font-size: 16px; cursor: pointer; }
  .tabs { position: fixed; top: auto; left: 0; right: 0; bottom: 0; z-index: 40; justify-content: space-around; gap: 0; padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); border-bottom: none; border-top: 1px solid var(--line); overflow: visible; }
  .tabs .tab-extra { display: none; }
  .tab { flex: 1 1 0; flex-direction: column; gap: 2px; padding: 4px 0; font-size: 11px; border-radius: 0; background: transparent !important; color: var(--muted); }
  .tab .tab-ic { font-size: 20px; width: 50px; height: 30px; display: flex; align-items: center; justify-content: center; border-radius: 999px; }
  .tab.active { color: var(--text); }
  .tab.active .tab-ic { background: var(--btn); }
  main { padding: 18px 14px calc(100px + env(safe-area-inset-bottom)); }
  .hero { padding: 20px; } .hero h1 { font-size: 24px; } .hero .btn { width: 100%; }
  .stage { padding: 18px 16px; }
  .step-body { font-size: 15px; }
  .card-row { grid-template-columns: 1fr; }
  .qa { grid-template-columns: 1fr; gap: 4px; }
  .badge-grid { grid-template-columns: repeat(auto-fill, minmax(128px, 1fr)); gap: 10px; }
  body.in-lesson .tabs { display: none; }
  body.in-lesson main { padding-bottom: 24px; }
  .controls { position: sticky; bottom: 0; z-index: 5; margin: 20px -16px -18px; padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); background: var(--nav); border-radius: 0 0 var(--r) var(--r); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px); }
  .toasts { top: 76px; right: 12px; left: 12px; align-items: stretch; }
  .toast { max-width: none; }
  .demo-banner { bottom: calc(78px + env(safe-area-inset-bottom)); }
}
.in-lesson .demo-banner { display: none; }
@media (min-width: 641px) and (max-width: 900px) {
  .stat-lbl { display: none; }
  .topbar .ghost-btn { padding-left: 10px; padding-right: 10px; }
}

/* ---------- Footer with legal links ---------- */
.site-foot { max-width: 1100px; margin: -40px auto 0; padding: 0 22px calc(96px + env(safe-area-inset-bottom)); text-align: center; color: var(--muted); font-size: 13px; }
.site-foot nav { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 18px; margin-bottom: 6px; }
.site-foot a { color: var(--muted); font-weight: 600; text-decoration: none; }
.site-foot a:hover { color: var(--green); text-decoration: underline; }
.site-foot p { margin: 0; font-size: 12px; }
.in-lesson .site-foot { display: none; }
.gate-legal { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 12px; margin-top: 14px; font-size: 12px; }
.gate-legal a { color: var(--muted); text-decoration: none; font-weight: 600; }
.gate-legal a:hover { text-decoration: underline; }

/* ---------- Legal & contact pages ---------- */
.doc-top { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 22px; background: var(--card); border-bottom: 1px solid var(--line); }
.doc-top .brand-logo { height: 40px; width: auto; display: block; }
.doc-top .doc-nav { display: flex; gap: 8px; align-items: center; }
.doc { max-width: 780px; margin: 0 auto; padding: 30px 22px 40px; line-height: 1.65; font-size: 16px; }
.doc h1 { font-size: 34px; margin-bottom: 4px; }
.doc .updated { color: var(--muted); font-size: 14px; margin: 0 0 22px; }
.doc h2 { font-size: 22px; margin: 30px 0 8px; }
.doc h3 { font-size: 17px; margin: 20px 0 6px; }
.doc p, .doc li { color: var(--text); }
.doc ul, .doc ol { padding-left: 22px; }
.doc li { margin: 4px 0; }
.doc a { color: var(--green); font-weight: 600; }
.doc .summary-box { background: var(--card); border: 1px solid var(--line); border-left: 5px solid var(--gold); border-radius: 18px; padding: 16px 20px; margin: 0 0 22px; box-shadow: var(--shadow); }
.doc .summary-box p:last-child, .doc .summary-box ul:last-child { margin-bottom: 0; }
.doc .toc { background: var(--card-2); border: 1px solid var(--line); border-radius: 16px; padding: 12px 18px; margin: 0 0 10px; font-size: 15px; }
.doc .toc ol { margin: 6px 0 0; }
.doc table { width: 100%; border-collapse: collapse; margin: 10px 0 16px; font-size: 15px; }
.doc th, .doc td { text-align: left; vertical-align: top; padding: 9px 10px; border-bottom: 1px solid var(--line); }
.doc th { font-weight: 600; }
.doc .caps { text-transform: uppercase; font-size: 14px; }
.form-card { background: var(--card); border: 1px solid var(--line); border-radius: 22px; padding: 22px; box-shadow: var(--shadow); margin-top: 18px; }
.form-card label { display: block; font-weight: 600; margin: 12px 0 6px; }
.form-card .btn { margin-top: 16px; }
.form-card .hp { position: absolute; left: -9999px; }
.form-card .check { display: flex; gap: 10px; align-items: flex-start; font-weight: 500; font-size: 14px; margin-top: 14px; }
.form-card .check input { margin-top: 4px; width: 18px; height: 18px; flex: 0 0 18px; }
.doc-foot { margin: 0 auto; padding: 10px 22px 40px; }
@media (max-width: 640px) { .doc h1 { font-size: 27px; } .doc { padding-top: 22px; } }

/* ---------- Typography ----------
   One rounded family everywhere; the hierarchy comes from weight and size:
   400 body text · 500 answers and secondary UI · 600 menus, buttons, labels · 700 titles. */
body { font-size: 16px; font-weight: 400; }
p { line-height: 1.6; }
h1, h2, h3, h4 { font-family: var(--font-display); font-weight: 700; line-height: 1.2; letter-spacing: 0; }
h1 { font-size: 30px; }
h2 { font-size: 24px; }
h3 { font-size: 19px; }
h4 { font-size: 16px; }
b, strong { font-weight: 700; }

/* titles of the open section */
.page-title { font-size: 34px; margin-bottom: 6px; }
.page-lead { font-size: 17px; }
.hero h1 { font-size: 34px; }
.lesson-h { font-size: 30px; margin: 14px 0 6px; }
.stage h3 { font-size: 21px; }
#tool-box h2 { font-size: 26px; }
.party h1 { font-size: 32px; }
.gate-card h1, .modal-card h1 { font-size: 26px; }
.level-name { font-size: 22px; font-weight: 700; }

/* menus and buttons */
.tab { font-size: 15px; font-weight: 600; }
.sheet-item { font-size: 17px; font-weight: 600; }
.sheet-who b { font-weight: 700; }
.stat { font-size: 15px; font-weight: 600; }
.stat-lbl { font-weight: 500; }
.ghost-btn { font-size: 14px; font-weight: 600; }
.btn { font-size: 16px; font-weight: 600; }
.btn.small-btn, .btns .btn { font-size: 15px; }
.gate-links { font-size: 15px; }

/* lesson, unit, tool and item titles: bold and clearly above body text */
.lesson-title { font-size: 17px; font-weight: 700; }
.lesson-sub, .unit-card .desc { font-size: 14px; }
.lesson-num { font-weight: 700; }
.shop-name { font-size: 17px; font-weight: 700; }
.badge-name { font-size: 14px; font-weight: 700; }
.kid-card b, .kid-pick b { font-weight: 700; }
summary { font-weight: 600; }

/* reading */
.step-body { font-size: 17px; line-height: 1.7; }
.step-body em { font-weight: 600; }
.choice { font-size: 16px; font-weight: 400; }
.feedback { font-size: 15px; font-weight: 500; }
.big-q { font-size: 20px; font-weight: 600; }
.pill, .tag { font-size: 12px; font-weight: 600; }

/* legal pages */
.doc { font-size: 16px; }
.doc h1 { font-size: 36px; }
.doc h2 { font-size: 24px; }
.doc h3 { font-size: 19px; }
.doc .toc a { font-weight: 500; }
a.btn, .doc-top a { text-decoration: none; }
.doc-top .btn { white-space: nowrap; }

@media (max-width: 640px) {
  h1 { font-size: 26px; } h2 { font-size: 21px; } h3 { font-size: 18px; }
  .page-title { font-size: 28px; }
  .page-lead { font-size: 16px; }
  .hero h1 { font-size: 27px; }
  .lesson-h { font-size: 24px; }
  .stage h3 { font-size: 19px; }
  #tool-box h2 { font-size: 22px; }
  .party h1 { font-size: 26px; }
  .gate-card h1, .modal-card h1 { font-size: 23px; }
  .step-body { font-size: 16px; }
  .tab { font-size: 12px; }
  .lesson-title { font-size: 16px; }
  .doc h1 { font-size: 29px; }
  .doc h2 { font-size: 21px; }
  .doc-top { padding: 10px 14px; }
  .doc-top .brand-logo { height: 32px; }
  .doc-top .brand-fallback { font-size: 22px; }
}
