/* Bar Model Buddy — one stylesheet.
 * Everything is built from the tokens below: three corner sizes, six type sizes, one hairline
 * edge, two shadows and a handful of tints. Components (button, field, pill, card, panel, notice,
 * row) are defined once and reused on every page. */

/* ================================ 1. tokens ================================ */
:root {
  /* colour — the first four are replaced by the player's colour theme (js/rewards.js) */
  --bg: #FFF8EC; --primary: #FF7A45; --primary-dark: #E05A24; --line: #ecdfc8;
  --card: #fff; --ink: #23263a; --muted: #6b7187;
  --blue: #2E86DE; --green: #14975a; --red: #E8492F; --gold: #FFB800;
  --good-ink: #0d6b3f; --bad-ink: #b3321c; --gold-ink: #7a5200;
  --tint: #FBF6EC; --tint-blue: #F0F7FF; --tint-gold: #FFF3D6; --good-bg: #E3F8EC; --bad-bg: #FFE9E3;
  --edge: rgba(120, 90, 40, .14);          /* hairline around every surface */
  --field: #DCCFB8;                        /* outline of a text box */
  --press: rgba(120, 90, 40, .18);         /* the bottom edge of a light button */
  --grade: var(--primary); --grade-soft: var(--tint);
  /* shape */
  --r-sm: 12px; --r-md: 16px; --r-lg: 24px; --r-pill: 999px;
  --shadow: 0 1px 2px rgba(80, 55, 20, .06), 0 6px 18px rgba(80, 55, 20, .07);
  --shadow-lift: 0 2px 4px rgba(80, 55, 20, .07), 0 14px 32px rgba(80, 55, 20, .12);
  --ring: 0 0 0 4px color-mix(in srgb, var(--primary) 20%, transparent);
  /* type */
  --f-display: 'Baloo 2', 'Nunito', system-ui, sans-serif;
  --f-text: 'Nunito', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --t-xs: 13px; --t-sm: 15px; --t-md: 18px; --t-lg: 22px; --t-xl: clamp(22px, 2.4vw, 26px); --t-2xl: clamp(30px, 5vw, 44px);
  --track: .05em;                          /* letter-spacing of the small capital labels */
  /* control heights */
  --h-sm: 34px; --h-md: 46px; --h-lg: 56px;
}
:root:lang(zh-Hans) {
  --f-display: 'Baloo 2', 'Nunito', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', 'Noto Sans SC', system-ui, sans-serif;
  --f-text: 'Nunito', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', 'Noto Sans SC', system-ui, sans-serif;
  --track: 0;
}

/* ================================= 2. base ================================= */
/* touch screens: scrolling only (no pinch or double-tap zoom), and text cannot be selected by a stray press.
   On every element, because Safari decides by the element under the finger; the first value is for old Safari. */
* { box-sizing: border-box; touch-action: manipulation; touch-action: pan-x pan-y; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; overflow-x: clip; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; color: var(--ink); font: 500 var(--t-md)/1.55 var(--f-text); background: var(--bg) radial-gradient(1200px 500px at 50% -120px, rgba(255, 255, 255, .9), transparent 70%) no-repeat; }
input, textarea, .can-select { -webkit-user-select: text; user-select: text; }
main { max-width: 900px; margin: 0 auto; padding: 22px 16px 80px; }
h1, h2, h3 { font-family: var(--f-display); }
h1 { font-size: var(--t-2xl); line-height: 1.1; margin: 0 0 12px; }
h2 { font-size: var(--t-lg); margin: 0 0 14px; display: flex; align-items: center; gap: 10px; }
h3 { font-size: var(--t-lg); margin: 2px 0; line-height: 1.2; }
a { color: inherit; }
:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; }
.muted { color: var(--muted); }
.unit { color: var(--muted); }
.qmark { color: var(--red); }
.more { margin-left: auto; font: 700 var(--t-sm) var(--f-text); color: var(--blue); }
.back { display: inline-block; margin-bottom: 12px; font-weight: 700; text-decoration: none; color: color-mix(in srgb, var(--grade) 70%, var(--muted)); }
/* small capital label above a group */
.label, .welcome label, .lh-grade, .world-kicker, .stop-label small, .continue small { font: 800 var(--t-xs) var(--f-text); text-transform: uppercase; letter-spacing: var(--track); color: var(--muted); }
.label, .welcome label { margin: 12px 0 6px; }
.ico { width: 1.3em; height: 1.3em; vertical-align: -0.3em; flex: none; }
.btn .ico { width: 1.25em; height: 1.25em; }
/* the round marker in front of a section title: a step number, or an icon */
.num, h2 > .ico:first-child { width: 34px; height: 34px; flex: none; border-radius: 50%; }
.num { display: grid; place-items: center; background: var(--ink); color: #fff; font-size: 17px; }
h2 > .ico:first-child { padding: 6px; background: var(--tint); }

/* ================================ 3. top bar ================================ */
.topbar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 8px; padding: 10px 20px; background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--edge); box-shadow: 0 2px 12px rgba(80, 55, 20, .05); }
.brand { display: flex; align-items: center; gap: 10px; margin-right: auto; font: 800 24px var(--f-display); text-decoration: none; }
.brand span { white-space: nowrap; }
.icon-btn, .chip { display: inline-flex; align-items: center; gap: 6px; min-height: 38px; background: #fff; border: 1px solid var(--edge); border-radius: var(--r-pill); box-shadow: var(--shadow); font: 800 var(--t-sm) var(--f-text); color: var(--ink); white-space: nowrap; text-decoration: none; }
.icon-btn { padding: 0 14px; cursor: pointer; }
.lang-btn { flex-shrink: 0; }
.share-btn, .fs-btn { flex: none; width: 38px; padding: 0; justify-content: center; }
.share-btn .ico, .fs-btn .ico { width: 20px; height: 20px; }
.fs-btn[hidden] { display: none; }
.chip { gap: 8px; padding: 3px 14px 3px 4px; }
.chip[hidden] { display: none; }
.chip b { max-width: 8em; overflow: hidden; text-overflow: ellipsis; }
.chip span { display: inline-flex; align-items: center; gap: 3px; }
.chip-face { width: 30px; height: 30px; display: grid; place-items: center; border-radius: 50%; }

/* ================================ 4. buttons ================================
   One button, three looks (primary, ghost, danger), three sizes (small, default, big).
   Every button sits on a 3px edge and sinks when pressed. */
.btn { --edge-c: var(--press); display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: var(--h-md); padding: 0 18px; border: 1px solid var(--edge); border-radius: var(--r-md); background: #fff; color: var(--ink); font: 800 var(--t-md) var(--f-display); text-decoration: none; cursor: pointer; box-shadow: 0 3px 0 var(--edge-c); transition: transform .08s, box-shadow .08s, filter .08s; }
.btn.primary { --edge-c: var(--primary-dark); background: var(--primary); border-color: transparent; color: #fff; }
.btn.danger { --edge-c: color-mix(in srgb, var(--red) 35%, transparent); background: var(--bad-bg); border-color: color-mix(in srgb, var(--red) 35%, transparent); color: var(--bad-ink); }
.btn:hover:not(:disabled) { filter: brightness(1.04); }
.btn:active:not(:disabled) { transform: translateY(2px); box-shadow: 0 1px 0 var(--edge-c); }
.btn:disabled { opacity: .45; cursor: default; }
.btn.small { min-height: var(--h-sm); padding: 0 12px; border-radius: var(--r-sm); font-size: var(--t-sm); box-shadow: 0 2px 0 var(--edge-c); }
.btn.big { min-height: var(--h-lg); padding: 0 28px; font-size: var(--t-lg); }
/* inside a world, the main button takes the world's colour */
.stop-card .btn.primary, .today.compact .btn.primary { --edge-c: color-mix(in srgb, var(--g, var(--primary)) 70%, #000); background: var(--g, var(--primary)); }
.cta { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; margin-top: 18px; }
.cta .muted { align-self: center; }

/* ================================= 5. fields ================================ */
.welcome input, .login input, .wish-form input, .kid-form input, .kid-form select, .answer-row input { min-width: 0; min-height: var(--h-md); padding: 0 14px; border: 1.5px solid var(--field); border-radius: var(--r-md); background: #fff; color: var(--ink); font: 700 var(--t-md) var(--f-text); transition: border-color .12s, box-shadow .12s; }
.welcome input:focus, .login input:focus, .wish-form input:focus, .kid-form input:focus, .kid-form select:focus, .answer-row input:focus { outline: none; border-color: var(--primary); box-shadow: var(--ring); }
::placeholder { color: #a79f8d; opacity: 1; }
.welcome input { text-align: center; width: 100%; max-width: 320px; }
.login input { width: 100%; max-width: 320px; }
/* the answer box: same field, bigger numbers */
.answer-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 16px; font-weight: 800; font-size: var(--t-lg); }
.answer-row input { width: 130px; min-height: var(--h-lg); padding: 0 8px; text-align: center; font: 800 26px var(--f-display); }
.answer-row .btn { min-height: var(--h-lg); padding: 0 22px; font-size: var(--t-lg); }
.whole-in { width: 84px !important; }
.frac-in { display: inline-flex; flex-direction: column; align-items: center; gap: 4px; }
.frac-in input { width: 84px; }
.frac-in i { width: 96px; height: 4px; background: var(--ink); border-radius: 2px; }
/* number-sentence blanks: dashed until filled in */
.eq-form { display: flex; flex-direction: column; gap: 14px; align-items: flex-start; }
.eq-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font: 800 26px var(--f-display); }
.eq-row .unit { font: 800 var(--t-lg) var(--f-text); }
.blank { width: 92px; height: 58px; padding: 0 4px; border: 2px dashed #a9b0c0; border-radius: var(--r-md); background: #fff; color: var(--ink); font: 800 26px var(--f-display); text-align: center; text-align-last: center; }
.blank:focus { outline: none; border-style: solid; border-color: var(--primary); box-shadow: var(--ring); }
.blank.op { width: 58px; border-radius: 50%; appearance: none; -webkit-appearance: none; cursor: pointer; color: var(--blue); }
.blank.ok { border: 2px solid var(--green); background: var(--good-bg); }
.blank.no { border: 2px solid var(--red); background: var(--bad-bg); }

/* =============================== 6. surfaces ===============================
   card   = a white sheet with a hairline and a soft shadow
   panel  = a tinted area inside a card (diagram stage, figure, hero picture)
   row    = a tinted line inside a card (a task, a family reward)
   tile   = a small white box you can pick (badge, shop item, buddy, player)
   notice = a tinted message (answer banner, feedback, hints)
   pill   = a small rounded label */
.card, .hero, .world, .today.compact { background: var(--card); border: 1px solid var(--edge); border-radius: var(--r-lg); box-shadow: var(--shadow); }
.card { padding: 24px; margin-bottom: 16px; }
.card h2.gap { margin-top: 22px; }
.today h2, .card h2.gap { flex-wrap: wrap; }
.tips { background: var(--tint-blue); border-color: color-mix(in srgb, var(--blue) 18%, transparent); }
.stage, figure, .hero-art { background: var(--tint); border-radius: var(--r-md); }
.task, .wishes li { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-radius: var(--r-md); background: var(--tint); font-weight: 700; }
.badge, .shop-item, .face-pick, .player-pick, .choice { background: #fff; border: 1px solid var(--edge); border-radius: var(--r-md); }
.banner, .feedback.good, .feedback.bad, .no-login, .caption { border-radius: var(--r-md); }
.pill, .gains span, .me-stats span, .eq-step, .here { display: inline-flex; align-items: center; gap: 5px; min-height: 28px; padding: 0 12px; border-radius: var(--r-pill); font: 800 var(--t-sm) var(--f-text); white-space: nowrap; }
.pill { background: var(--tint); color: var(--ink); }
.pill.paper, .gains span { background: var(--tint-gold); color: var(--gold-ink); }
.me-stats span { background: #fff; border: 1px solid var(--edge); }
.eq-step, .here { background: var(--ink); color: #fff; font-size: var(--t-xs); text-transform: uppercase; letter-spacing: var(--track); }
/* messages */
.feedback { margin: 12px 0 0; font-weight: 800; }
.feedback:empty { display: none; }
.feedback.good, .feedback.bad { padding: 10px 14px; }
.feedback.good { background: var(--good-bg); color: var(--good-ink); }
.feedback.bad { background: var(--bad-bg); color: var(--bad-ink); }
.banner { display: flex; align-items: center; gap: 12px; padding: 8px 16px 8px 10px; margin-bottom: 16px; font-size: var(--t-lg); font-weight: 700; }
.banner.good { background: var(--good-bg); color: var(--good-ink); }
.banner.bad { background: var(--tint-gold); color: var(--gold-ink); }
.banner-bao, .banner-bao .bao { width: 58px; height: 58px; flex: none; }
.no-login { max-width: 440px; margin: 0 auto 14px; padding: 10px 14px; background: var(--tint-blue); font-size: var(--t-sm); line-height: 1.45; text-align: left; }
/* bars: task progress, world progress */
.task-bar, .world-bar { height: 10px; border-radius: var(--r-pill); overflow: hidden; }
.task-bar i, .world-bar i { display: block; height: 100%; border-radius: var(--r-pill); transition: width .4s; }
.stars span { color: #dcd6c8; font-size: 21px; }
.stars span.on { color: var(--gold); }

/* ================================= 7. home ================================= */
.hero { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; align-items: center; padding: 26px; background: linear-gradient(135deg, #fff 55%, color-mix(in srgb, var(--bg) 75%, #fff)); box-shadow: var(--shadow-lift); }
.hero h1 em { font-style: normal; color: var(--primary); }
.hero p { margin: 0 0 8px; color: var(--muted); }
.hero-art { position: relative; padding: 4px; }
.hero-bars { padding-right: 70px; }
.hero-bao { position: absolute; right: -18px; bottom: -26px; filter: drop-shadow(0 6px 8px rgba(60, 40, 10, .12)); }
.hero-bao img.bao { width: 120px; height: 120px; }
/* the big way in */
.continue { display: inline-flex; align-items: center; gap: 14px; max-width: 100%; margin-top: 14px; padding: 12px 22px 12px 12px; border-radius: var(--r-lg); background: var(--g); color: #fff; text-decoration: none; box-shadow: 0 5px 0 color-mix(in srgb, var(--g) 70%, #000), var(--shadow); transition: transform .1s, box-shadow .1s; }
.continue:hover { transform: translateY(-2px); }
.continue:active { transform: translateY(3px); box-shadow: 0 2px 0 color-mix(in srgb, var(--g) 70%, #000); }
.continue-play { width: 48px; height: 48px; flex: none; display: grid; place-items: center; border-radius: 50%; background: rgba(255, 255, 255, .22); font-size: 20px; padding-left: 3px; }
.continue small { display: block; color: inherit; opacity: .9; }
.continue b { display: block; font: 800 var(--t-lg)/1.15 var(--f-display); }
/* today's tasks */
.today.compact { margin: 16px 0 0; padding: 14px 18px; }
.today-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.today-head h2 { margin: 0; flex: none; white-space: nowrap; }   /* the title stays on one line; a long link wraps instead */
.today-head .more { text-align: right; }
.today.compact .tasks { grid-template-columns: repeat(3, 1fr); }
.today.compact .task { flex-wrap: wrap; gap: 6px 10px; padding: 10px 12px; align-content: space-between; }
.today.compact .task-main { flex-basis: 100%; font-size: var(--t-sm); }
.today.compact .task-count { min-width: 0; margin-right: auto; text-align: left; }
/* level tabs: each world has its colour */
.grade-tabs { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; margin: 22px 0 16px; }
.grade-tabs button { position: relative; display: flex; flex-direction: column; align-items: center; text-align: center; padding: 10px 10px 12px; background: #fff; border: 1px solid var(--edge); border-radius: var(--r-md); box-shadow: var(--shadow); color: var(--ink); font: inherit; cursor: pointer; transition: transform .12s; }
.grade-tabs button:hover { transform: translateY(-2px); border-color: var(--g); }
.grade-tabs i { font-style: normal; font-size: 22px; line-height: 1; margin-bottom: 2px; }
.grade-tabs b { font: 800 var(--t-lg) var(--f-display); }
.grade-tabs button span { font-size: var(--t-xs); line-height: 1.25; color: var(--muted); }
.grade-tabs button.on { background: var(--g); border-color: var(--g); color: #fff; box-shadow: 0 4px 0 color-mix(in srgb, var(--g) 70%, #000), var(--shadow); }
.grade-tabs button.on span { color: rgba(255, 255, 255, .85); }
/* the world: banner + map */
.world { overflow: hidden; }
.world-head { display: flex; gap: 16px; align-items: center; padding: 22px 24px; background: linear-gradient(135deg, var(--gs), color-mix(in srgb, var(--gs) 40%, #fff)); border-bottom: 1px solid var(--edge); }
.world-head > div:first-child { flex: 1; min-width: 0; }
.world-kicker { color: var(--g); }
.world-head h2 { margin: 2px 0 8px; font-size: 30px; }
.world-stats { display: flex; gap: 8px 16px; flex-wrap: wrap; font-weight: 700; font-size: var(--t-sm); }
.world-stats span { display: inline-flex; align-items: center; gap: 5px; }
.world-bar { margin-top: 10px; background: rgba(255, 255, 255, .8); max-width: 420px; }
.world-bar i { background: var(--g); }
.world-deco { font-size: 0; }
.world-deco img.world-badge { width: 112px; height: 112px; animation: bob 3.2s ease-in-out infinite; filter: drop-shadow(0 6px 10px rgba(40, 30, 10, .15)); }
.map { --spread: 26%; position: relative; list-style: none; margin: 0; padding: 30px 16px 40px; background: radial-gradient(circle at 20% 10%, var(--gs) 0, transparent 35%), radial-gradient(circle at 85% 70%, var(--gs) 0, transparent 30%); }
.map-line { position: absolute; inset: 0; pointer-events: none; overflow: visible; }
.map-line path { fill: none; stroke-linecap: round; }
.map-line .base { stroke: color-mix(in srgb, var(--g) 22%, #e8e1d4); stroke-width: 10; stroke-dasharray: 2 18; }
.map-line .walked { stroke: var(--g); stroke-width: 10; opacity: .55; }
.stop { position: relative; display: flex; flex-direction: column; align-items: center; padding: 6px 0 18px; }
.stop-inner { position: relative; left: calc(var(--dx) * var(--spread)); display: flex; flex-direction: column; align-items: center; width: 220px; z-index: 1; }
.node { width: 84px; height: 84px; border-radius: 50%; border: 0; cursor: pointer; display: grid; place-items: center; background: #fff; box-shadow: 0 6px 0 color-mix(in srgb, var(--g) 35%, #d9d0bf), 0 0 0 5px #fff, var(--shadow); transition: transform .12s; }
.node:hover { transform: translateY(-3px) scale(1.04); }
.node:active { transform: translateY(3px); }
.node-emoji { font-size: 40px; line-height: 1; }
.stop.done .node { background: var(--gs); box-shadow: 0 6px 0 var(--g), 0 0 0 5px #fff, var(--shadow); }
.stop.now .node { width: 100px; height: 100px; background: #fff; box-shadow: 0 7px 0 var(--g), 0 0 0 6px var(--g), 0 0 0 14px color-mix(in srgb, var(--g) 25%, transparent); animation: nodepulse 2s ease-in-out infinite; }
.stop.later .stop-label { opacity: .65; }
.stop.boss .node { width: 104px; height: 104px; border-radius: var(--r-lg); background: var(--tint-gold); box-shadow: 0 7px 0 #E0B04B, 0 0 0 6px #fff, var(--shadow); }
.stop.boss.now .node { background: #FFD45C; }
.here { position: absolute; top: -24px; z-index: 2; min-height: 22px; }
.here::after { content: ""; position: absolute; left: 50%; bottom: -5px; margin-left: -5px; border: 5px solid transparent; border-bottom: 0; border-top-color: var(--ink); }
.stop-label { margin-top: 12px; padding: 4px 10px 2px; border-radius: var(--r-sm); background: rgba(255, 255, 255, .88); text-align: center; line-height: 1.2; cursor: pointer; }
.stop-label small { display: block; }
.stop-label b { display: block; font: 800 var(--t-md) var(--f-display); }
.stop-label .stars span { font-size: 17px; }
.stop-card { position: relative; z-index: 2; width: min(360px, 100%); margin-top: 10px; padding: 14px 16px; background: #fff; border: 2px solid var(--g); border-radius: var(--r-md); box-shadow: var(--shadow-lift); text-align: center; animation: cardin .18s ease-out; }
.stop-card p { margin: 0 0 10px; color: var(--muted); }
.lc-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.stop-card .lc-actions { justify-content: center; }

/* ============================== 8. lesson page ============================== */
.lesson-head { display: flex; align-items: center; gap: 16px; margin-bottom: 16px; }
.lesson-head h1 { margin: 0; }
.lh-emoji { width: 84px; height: 84px; flex: none; display: grid; place-items: center; background: var(--grade-soft); border: 1px solid var(--edge); border-radius: var(--r-lg); }
.lh-grade { display: flex; align-items: center; gap: 6px; color: var(--grade); }
.lh-grade img.lh-world { width: 22px; height: 22px; display: inline-block; }
.idea { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: center; margin-bottom: 10px; }
.ideas, .tips ul { margin: 0; padding-left: 22px; }
.ideas li, .tips li { margin-bottom: 8px; }
figure { margin: 0; padding: 6px 6px 12px; text-align: center; }
figcaption { font: 800 var(--t-lg) var(--f-display); color: var(--blue); }
.qtext { font-size: var(--t-xl); font-weight: 700; line-height: 1.5; margin: 0; }
.card > .qtext { margin-bottom: 12px; }

/* ====================== 9. the step-by-step player ====================== */
.stage { padding: 10px 6px; min-height: 150px; }
.caption { display: flex; gap: 12px; align-items: flex-start; min-height: 96px; margin: 12px 0; padding: 12px 16px 12px 12px; background: var(--tint-blue); }
.cap-bao, .cap-bao .bao { width: 72px; height: 72px; flex: none; }
.cap-bao { margin-top: -4px; }
.cap-text { flex: 1; min-width: 0; padding-top: 4px; }
.say { font-weight: 700; }
.eq { font: 800 0px var(--f-display); color: var(--blue); }
.eq.show { font-size: 26px; margin-top: 2px; }
.eq.final { color: var(--green); }
.pcontrols { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.dots { display: flex; gap: 6px; margin: 0 auto; }
.dots i { width: 12px; height: 12px; border-radius: 50%; background: var(--line); transition: background .3s; }
.dots i.on { background: var(--primary); }

/* =============================== 10. practice =============================== */
.qpath { list-style: none; display: flex; align-items: center; padding: 4px 2px 0; margin: 0 0 16px; }
.qpath li { flex: 1; display: flex; align-items: center; }
.qpath li:last-child { flex: none; }
.qpath li:not(:last-child)::after { content: ""; flex: 1; height: 4px; margin: 0 6px; border-radius: 4px; background: var(--edge); }
.qpath li.clean::after, .qpath li.done::after, .qpath li.shown::after { background: var(--green); opacity: .45; }
.qpath span { width: 34px; height: 34px; flex: none; display: grid; place-items: center; border-radius: 50%; background: #fff; border: 2px solid var(--edge); font: 800 16px var(--f-display); color: var(--muted); }
.qpath .now span { width: 42px; height: 42px; font-size: 19px; background: var(--grade); border-color: var(--grade); color: #fff; box-shadow: 0 0 0 6px color-mix(in srgb, var(--grade) 22%, transparent); animation: nowpulse 1.8s ease-in-out infinite; }
.qpath .clean span { background: var(--gold); border-color: var(--gold); color: #fff; font-size: 18px; }
.qpath .done span { background: var(--green); border-color: var(--green); color: #fff; }
.qpath .shown span { background: #9aa3b5; border-color: #9aa3b5; color: #fff; }
.qcard { box-shadow: var(--shadow-lift); }
.qmeta { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.qmeta #readQ { margin-left: auto; }
.qmeta:not(:has(.pill)) #readQ { margin-left: 0; }
.choices { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 12px; }
.choice { position: relative; padding: 10px 8px 4px; box-shadow: var(--shadow); font: inherit; cursor: pointer; transition: transform .1s, border-color .1s, box-shadow .1s; }
.choice:hover:not(:disabled) { border-color: var(--blue); transform: translateY(-2px); box-shadow: var(--shadow-lift); }
.choice .tag { position: absolute; top: 6px; left: 8px; width: 28px; height: 28px; display: grid; place-items: center; border-radius: 50%; background: var(--ink); color: #fff; font: 800 var(--t-sm) var(--f-display); }
.choice.right { border-color: var(--green); background: var(--good-bg); box-shadow: 0 0 0 2px var(--green), var(--shadow); }
.choice.wrong { border-color: var(--red); background: var(--bad-bg); opacity: .6; animation: shake .35s; }
.paper-steps { margin: 0 0 16px; padding-left: 24px; }
.paper-steps li { margin-bottom: 6px; }
.results { text-align: center; padding: 36px 22px; }
.big-emoji { display: flex; justify-content: center; }
.big-emoji .bao { width: 150px; height: 150px; }
.big-stars .stars span { font-size: 56px; }
.gains { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin: 6px 0 4px; }
.gains span { min-height: 32px; }
#showHow { margin-top: 12px; }

/* ============================ 11. bar model svg ============================ */
.bm { display: block; width: 100%; height: auto; }
.bm-seg { stroke: var(--ink); stroke-width: 2.5; }
.bm-seg.ghost { stroke: #8a93a6; stroke-dasharray: 7 6; }
.bm-seg-text, .bm-brace-text { font: 800 23px var(--f-display); fill: var(--ink); }
.bm-row-label { font: 800 18px var(--f-text); fill: #3b3f5c; }
.bm-sub { font: 700 14px var(--f-text); fill: var(--muted); }
.bm-brace { fill: none; stroke: var(--ink); stroke-width: 2.5; stroke-linecap: round; }
.bm .q { fill: var(--red); font-size: 27px; }
.bm .ans { fill: var(--green); }
.bm-badge circle { fill: var(--ink); }
.bm-badge text { fill: #fff; font: 800 11px var(--f-text); }
.bm .grow { transform-box: fill-box; transform-origin: left center; animation: grow .55s cubic-bezier(.3, 1.3, .6, 1) both; }
.bm .draw { stroke-dasharray: 1; stroke-dashoffset: 1; animation: draw .6s ease-out forwards; }
.bm .fade { animation: fade .45s both; }
.bm .reveal { transform-box: fill-box; transform-origin: center; animation: pop .6s cubic-bezier(.3, 1.6, .6, 1) both; }
.bm-shape { fill: #EAF4FF; stroke: var(--ink); stroke-width: 2.5; stroke-linejoin: round; }
.bm-shape.top { fill: #D6E9FF; }
.bm-shape.side { fill: #C3DCF8; }
.bm-outline { fill: none; stroke: var(--primary); stroke-width: 4; }
.bm-ray { stroke: var(--ink); stroke-width: 2.5; stroke-linecap: round; }
.bm-dash { stroke: var(--ink); stroke-width: 2; stroke-dasharray: 6 5; fill: none; }
.bm-dash.solid { stroke-dasharray: none; }

/* ================== 12. players, tasks, badges, shop, rewards ================== */
.welcome { max-width: 560px; margin: 24px auto; text-align: center; }
.welcome form { display: flex; flex-direction: column; gap: 10px; align-items: center; }
.welcome h2 { justify-content: center; margin-top: 8px; }
.welcome-bao { display: flex; justify-content: center; margin: -8px 0 4px; }
.welcome-bao .bao { animation: baobob 3s ease-in-out infinite; }
.players, .faces { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-bottom: 8px; }
.player-pick { display: flex; flex-direction: column; align-items: center; gap: 2px; min-width: 110px; padding: 12px 18px; color: var(--ink); font: inherit; cursor: pointer; box-shadow: var(--shadow); transition: transform .1s, border-color .1s; }
.player-pick:hover { border-color: var(--primary); transform: translateY(-2px); }
.face-pick { width: 64px; height: 64px; display: grid; place-items: center; padding: 6px; cursor: pointer; transition: transform .1s; }
.face-pick:hover { transform: translateY(-2px); }
.face-pick.on { border-color: var(--primary); background: var(--tint); box-shadow: 0 0 0 2px var(--primary); }
.me-stats { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.me-stats span { min-height: 34px; padding: 0 14px; font-weight: 700; }
.me-stats.left { margin: 0 0 4px; justify-content: flex-start; }
.tasks, .wishes { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.task-main { flex: 1; min-width: 0; }
.task-bar { margin-top: 5px; background: color-mix(in srgb, var(--line) 70%, #fff); }
.task-bar i { background: var(--primary); }
.task.done .task-bar i, .task.claimed .task-bar i { background: var(--green); }
.task.claimed .task-main { color: var(--muted); }
.task-count { min-width: 42px; text-align: right; font-weight: 800; font-size: var(--t-sm); color: var(--muted); }
.task-got { font-weight: 800; font-size: var(--t-sm); color: var(--green); white-space: nowrap; }
.badges { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.badge { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 12px 8px; text-align: center; background: var(--tint); border-color: transparent; color: var(--muted); }
.badge span { font-size: 0; filter: grayscale(1); opacity: .55; }
.badge b { font-family: var(--f-display); line-height: 1.25; }
.badge small { font-size: var(--t-xs); line-height: 1.25; }
.badge.on { background: var(--tint-gold); color: var(--ink); }
.badge.on span { filter: none; opacity: 1; }
.badge.on small { color: var(--gold-ink); }
.shop { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 10px; }
.shop-item { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 10px 6px; }
.shop-item.using { border-color: var(--green); background: var(--good-bg); box-shadow: 0 0 0 2px var(--green); }
.shop-item .task-got { min-height: var(--h-sm); display: inline-flex; align-items: center; }
.swatch { display: block; width: 40px; height: 40px; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 0 0 2px var(--line); }
.wishes li { gap: 10px; flex-wrap: wrap; }
.wishes li span:first-child { flex: 1; min-width: 120px; }
.wishes li.given { opacity: .6; }
/* nothing here yet: Bao keeps the place */
.empty { display: flex; align-items: center; gap: 10px; margin: 0; color: var(--muted); font-weight: 700; }
.empty img.bao { flex: none; }
.wish-form { display: grid; grid-template-columns: 1fr 110px 130px auto; gap: 8px; align-items: center; margin-top: 14px; }
.wish-form .label, .wish-form .feedback { grid-column: 1 / -1; margin: 0; }
.wish-form.two { grid-template-columns: 1fr 110px auto; }
.wish-form.two[data-form="pass"] { grid-template-columns: 1fr auto auto; }

/* ====================== 13. sign-in and the parents' area ====================== */
.login { display: flex; flex-direction: column; gap: 10px; align-items: center; margin-bottom: 18px; }
.login h2, .login .more { margin: 0; }
.kid-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 8px; align-items: center; }
.kid-form .feedback { grid-column: 1 / -1; margin: 0; }
.kid-head { display: flex; align-items: center; gap: 14px; margin-bottom: 10px; }
.kid-head h2 { margin: 0; }

/* ============================== 14. pictures ============================== */
img.bao, img.face-img, img.lesson-img, img.world-img, img.medal-img { display: block; object-fit: contain; user-select: none; }
.chip-face .face-svg { width: 28px; height: 28px; }
.chip-face img.face-img { width: 30px; height: 30px; }
.face .face-svg { width: 60px; height: 60px; }
.face img.face-img { width: 64px; height: 64px; }
.face-pick .face-svg { width: 46px; height: 46px; }
.face-pick img.face-img { width: 50px; height: 50px; }
.shop-face .face-svg { width: 54px; height: 54px; }
.shop-face img.face-img { width: 60px; height: 60px; }
.kid-head .face .face-svg { width: 54px; height: 54px; }
.lh-emoji .face-svg, .lh-emoji .ico { width: 58px; height: 58px; }
.lh-emoji img.face-img { width: 64px; height: 64px; }
.lh-emoji img.lesson-img { width: 66px; height: 66px; }
.node-emoji .ico { width: 48px; height: 48px; vertical-align: 0; }
.node-emoji img.lesson-img { width: 58px; height: 58px; }
.stop.now .node-emoji .ico { width: 58px; height: 58px; }
.stop.now .node-emoji img.lesson-img { width: 70px; height: 70px; }
.stop.boss .node-emoji .ico { width: 60px; height: 60px; }
.stop.boss .node-emoji img.lesson-img { width: 72px; height: 72px; }
.stop.later .node-emoji .ico, .stop.later .node-emoji img.lesson-img { filter: grayscale(.7); opacity: .6; }
.stop.boss .node-emoji .ico, .stop.boss .node-emoji img.lesson-img { filter: none; opacity: 1; }
.grade-tabs i .ico { width: 32px; height: 32px; vertical-align: 0; }
.grade-tabs i img.world-img { width: 42px; height: 42px; margin-bottom: 2px; }
.grade-tabs button.on i img.world-img { box-shadow: 0 0 0 3px rgba(255, 255, 255, .85); border-radius: 50%; }
.badge .medal-svg { width: 62px; height: 70px; }
.badge img.medal-img { width: 78px; height: 78px; }
.gains .medal-svg { width: 22px; height: 25px; }
.gains img.medal-img { width: 26px; height: 26px; display: inline-block; }
.fly-coin .ico { width: 30px; height: 30px; }
.toast .ico { width: 1.2em; height: 1.2em; }

/* =============================== 15. effects =============================== */
.toast { position: fixed; left: 50%; top: 78px; transform: translateX(-50%); z-index: 30; max-width: calc(100vw - 24px); padding: 6px 20px; border-radius: var(--r-pill); background: var(--ink); color: #fff; font: 800 var(--t-md) var(--f-display); white-space: nowrap; pointer-events: none; animation: toast 1.9s both; }
.fly-coin { position: fixed; z-index: 40; font-size: 26px; pointer-events: none; will-change: transform; }
.coin-plus { position: fixed; z-index: 40; transform: translateX(-50%); padding: 0 10px; border-radius: var(--r-pill); background: var(--tint-gold); color: var(--gold-ink); font: 800 var(--t-md) var(--f-display); pointer-events: none; animation: plusup 1.7s ease-out both; }
.confetti { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 20; }
.confetti i { position: absolute; top: -20px; width: 10px; height: 16px; border-radius: 3px; animation: fall linear forwards; }
@keyframes grow { from { transform: scaleX(0); } to { transform: scaleX(1); } }
@keyframes draw { to { stroke-dashoffset: 0; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop { 0% { transform: scale(0); opacity: 0; } 70% { transform: scale(1.35); opacity: 1; } 100% { transform: scale(1); } }
@keyframes shake { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }
@keyframes fall { to { top: 105%; transform: rotate(720deg); } }
@keyframes toast { 0% { opacity: 0; margin-top: 16px; } 15%, 75% { opacity: 1; margin-top: 0; } 100% { opacity: 0; margin-top: -14px; } }
@keyframes plusup { 0% { opacity: 0; margin-top: 8px; } 15%, 70% { opacity: 1; margin-top: 0; } 100% { opacity: 0; margin-top: -6px; } }
@keyframes nowpulse { 50% { box-shadow: 0 0 0 10px color-mix(in srgb, var(--grade) 10%, transparent); } }
@keyframes nodepulse { 50% { box-shadow: 0 7px 0 var(--g), 0 0 0 6px var(--g), 0 0 0 22px color-mix(in srgb, var(--g) 10%, transparent); } }
@keyframes bob { 50% { transform: translateY(-6px); } }
@keyframes baobob { 50% { transform: translateY(-5px); } }
@keyframes cardin { from { opacity: 0; transform: translateY(-6px); } }

/* share card dialog */
.share-dlg { position: fixed; width: min(430px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); padding: 20px; border: 0; border-radius: var(--r-lg); background: var(--card); color: var(--ink); box-shadow: var(--shadow-lift); text-align: center; }
.share-dlg::backdrop { background: rgba(35, 38, 58, .5); backdrop-filter: blur(3px); }
.share-dlg h2 { justify-content: center; margin-bottom: 12px; }
.share-img { -webkit-touch-callout: default; -webkit-user-select: auto; user-select: auto; display: block; width: auto; max-width: 100%; height: auto; max-height: min(56dvh, 520px); margin: 0 auto; aspect-ratio: 3 / 4; border: 1px solid var(--edge); border-radius: var(--r-md); background: var(--tint); }
.share-name[hidden] { display: none; }
.share-name { display: inline-flex; align-items: center; gap: 8px; margin-top: 12px; font-weight: 700; font-size: var(--t-sm); cursor: pointer; }
.share-name input { width: 20px; height: 20px; accent-color: var(--primary); }
.share-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }
.share-actions .btn.primary { grid-column: 1 / -1; }
.share-x { position: absolute; top: 12px; right: 12px; width: 36px; height: 36px; border: 1px solid var(--edge); border-radius: 50%; background: #fff; color: var(--muted); font: 800 var(--t-sm) var(--f-text); cursor: pointer; }
.share-tip { margin: 12px 0 0; font-size: var(--t-xs); }
.share-dlg > p { margin: 0 0 12px; font-size: var(--t-sm); line-height: 1.5; text-align: left; }
.share-dlg > p.share-tip { margin: 12px 0 0; font-size: var(--t-xs); text-align: center; }

/* =============================== 15b. loading ===============================
 * One look for every wait:
 *   .loading   the three bars of the logo drawing themselves, with a line of text. On a whole page
 *              (.page: first open, before the scripts have drawn anything) or inside a card.
 *   .skel      grey placeholder shapes where content is on its way (the parents' list).
 *   .net-bar   a thin moving line under the top bar while the app talks to the server.
 *   .is-busy   a button that is working: a small spinner next to its label.
 *   pictures   a soft pulse where a picture has not arrived yet.
 * Nothing here appears for waits shorter than about a quarter of a second. */
.loading { display: grid; justify-items: center; gap: 12px; padding: 36px 16px; color: var(--muted); font: 700 var(--t-sm) var(--f-text); text-align: center; }
.loading.page { min-height: 56vh; align-content: center; }
.loading p { margin: 0; }
.loader { width: 66px; height: 48px; overflow: visible; }
.loading.small { grid-auto-flow: column; justify-content: center; align-items: center; padding: 14px; }
.loading.small .loader { width: 33px; height: 24px; }
.loader rect { stroke: var(--ink); stroke-width: 2; transform-box: fill-box; transform-origin: left center; animation: loadbar 1.5s cubic-bezier(.3, .7, .3, 1) infinite backwards; }
.loader rect:nth-child(2) { animation-delay: .18s; }
.loader rect:nth-child(3) { animation-delay: .36s; }
@keyframes loadbar { 0% { transform: scaleX(0); opacity: 1; } 28%, 72% { transform: scaleX(1); opacity: 1; } 100% { transform: scaleX(1); opacity: 0; } }
#soundBtn:empty { visibility: hidden; }   /* the voice button has no face until the scripts run */
.loading-slow { display: none; max-width: 320px; line-height: 1.45; }
.loading.slow .loading-slow { display: grid; justify-items: center; gap: 10px; }
.loading.slow .loading-text { display: none; }

.skel, img.share-img { --skel: color-mix(in srgb, var(--line) 55%, #fff); }
.skel { display: block; border-radius: var(--r-sm); background: linear-gradient(100deg, var(--skel) 30%, #fff 50%, var(--skel) 70%) 0 0 / 300% 100%; animation: shimmer 1.4s linear infinite; }
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: 0 0; } }
.skel.line { height: 14px; margin: 10px 0; }
.skel.title { width: 42%; height: 24px; margin: 2px 0 8px; }
.skel.circle { flex: none; width: 64px; height: 64px; border-radius: 50%; }
.skel.block { height: 46px; margin: 10px 0; border-radius: var(--r-md); }
.skel-head { display: flex; align-items: center; gap: 14px; margin-bottom: 6px; }
.skel-head > div { flex: 1; }

.net-bar { position: absolute; left: 0; right: 0; bottom: -2px; height: 3px; overflow: hidden; opacity: 0; pointer-events: none; transition: opacity .2s; }
.net-bar::before { content: ''; position: absolute; top: 0; bottom: 0; left: 0; width: 38%; border-radius: 3px; background: var(--primary); animation: netbar 1.15s ease-in-out infinite paused; }
html.busy .net-bar { opacity: 1; transition-delay: .25s; }
html.busy .net-bar::before { animation-play-state: running; }
@keyframes netbar { from { transform: translateX(-100%); } to { transform: translateX(265%); } }

.btn.is-busy { cursor: progress; }
.btn.is-busy::before { content: ''; flex: none; width: 1em; height: 1em; border: .16em solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* a picture that has not arrived: app.js marks each one data-ok when it loads */
img.bao:not([data-ok]), img.lesson-img:not([data-ok]) { border-radius: var(--r-md); animation: imgwait 1s .25s ease-in-out infinite alternate; }
img.face-img:not([data-ok]), img.world-img:not([data-ok]), img.medal-img:not([data-ok]) { border-radius: 50%; animation: imgwait 1s .25s ease-in-out infinite alternate; }
img.share-img:not([src]) { background: linear-gradient(100deg, var(--skel) 30%, #fff 50%, var(--skel) 70%) 0 0 / 300% 100%; animation: shimmer 1.4s linear infinite; }
@keyframes imgwait { from { background-color: color-mix(in srgb, var(--ink) 5%, transparent); } to { background-color: color-mix(in srgb, var(--ink) 11%, transparent); } }

/* ============================== 16. small screens ============================== */
@media (max-width: 900px) {   /* tablets upright: the top bar holds five buttons, so each takes less */
  .brand { font-size: 20px; }
  .chip b { max-width: 5em; }
  #soundBtn { font-size: 0; padding: 0 9px; gap: 0; }
  #soundBtn .ico { width: 22px; height: 22px; }
}
@media (max-width: 720px) {
  :root { --t-md: 17px; }
  .hero, .idea { grid-template-columns: 1fr; }
  .card { padding: 18px; }
  .brand { font-size: 20px; }
  .chip b { display: none; }
  #soundBtn { font-size: 0; padding: 0 9px; gap: 0; }
  #soundBtn .ico { width: 22px; height: 22px; }
  .hero-bao { right: -8px; bottom: -18px; }
  .hero-bao img.bao { width: 96px; height: 96px; }
  .hero-bars { padding-right: 60px; }
  .continue b { font-size: 19px; }
  .continue-play { width: 40px; height: 40px; }
  .today.compact .tasks { grid-template-columns: 1fr; }
  .grade-tabs { gap: 5px; }
  .grade-tabs button { padding: 8px 2px; border-radius: var(--r-sm); }
  .grade-tabs b { font-size: var(--t-md); }
  .grade-tabs button span { display: none; }
  .grade-tabs i { font-size: 18px; }
  .grade-tabs i img.world-img { width: 34px; height: 34px; }
  .world-head { padding: 18px; }
  .world-head h2 { font-size: 24px; }
  .world-deco img.world-badge { width: 72px; height: 72px; }
  .map { --spread: 19%; padding: 26px 8px 30px; }
  .stop-inner { width: 160px; }
  .node { width: 70px; height: 70px; }
  .node-emoji { font-size: 32px; }
  .node-emoji .ico { width: 40px; height: 40px; }
  .node-emoji img.lesson-img { width: 48px; height: 48px; }
  .stop.now .node { width: 84px; height: 84px; }
  .stop.now .node-emoji .ico { width: 48px; height: 48px; }
  .stop.now .node-emoji img.lesson-img { width: 58px; height: 58px; }
  .stop.boss .node { width: 88px; height: 88px; }
  .stop-label b { font-size: 16px; }
  .lesson-head { flex-wrap: wrap; }
  .me-stats { margin-left: 0; justify-content: flex-start; width: 100%; }
  .cap-bao, .cap-bao .bao { width: 56px; height: 56px; }
  .dots { order: -1; width: 100%; justify-content: center; }
  .qpath span { width: 28px; height: 28px; font-size: 14px; }
  .qpath .now span { width: 34px; height: 34px; font-size: 16px; }
  .qmeta #readQ { margin-left: 0; }
  .blank { width: 72px; height: 52px; font-size: 22px; }
  .blank.op { width: 52px; }
  .task { flex-wrap: wrap; }
  .wish-form { grid-template-columns: 1fr 1fr; }
  .wish-form.two, .wish-form.two[data-form="pass"] { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .topbar { padding: 8px 12px; gap: 6px; }
  .brand { font-size: 17px; gap: 6px; }
  .brand svg { width: 32px; height: 24px; }
  .lang-btn { padding: 0 10px; font-size: var(--t-xs); }
  .chip { padding-right: 10px; gap: 6px; }
}
@media (max-width: 560px) { .brand span { display: none; } }   /* logo only: room for the buttons */
@media (max-width: 440px) {
  .topbar { padding: 8px 10px; gap: 5px; }
  .brand { font-size: 15px; gap: 5px; }
  .brand svg { width: 28px; height: 21px; }
  .icon-btn, .chip { min-height: 36px; }
  .lang-btn { padding: 0 9px; }
  #soundBtn { padding: 0 8px; }
  .share-btn, .fs-btn { width: 36px; }
}
@media (max-width: 389px) { .chip .chip-streak { display: none; } }   /* the narrowest phones: five buttons and the coins */

/* ============================== 17. less motion ============================== */
@media (prefers-reduced-motion: reduce) {
  .loader rect { animation: loadpulse 1.6s ease-in-out infinite alternate; }
  .skel, img.share-img:not([src]) { animation: none; }
  .net-bar::before { width: 100%; animation: none; opacity: .6; }
  .bm .grow, .bm .draw, .bm .fade, .bm .reveal, .confetti i { animation-duration: .01s; animation-delay: 0s !important; }
  .qpath .now span, .stop.now .node, .world-deco img.world-badge, .welcome-bao .bao { animation: none; }
  .grade-tabs button:hover, .player-pick:hover, .face-pick:hover, .choice:hover:not(:disabled) { transform: none; }
}
@keyframes loadpulse { from { opacity: 1; } to { opacity: .45; } }
