@font-face { font-family: 'Handicrafts'; src: url('../fonts/handicrafts-regular.woff2') format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Handicrafts'; src: url('../fonts/handicrafts-bold.woff2') format('woff2'); font-weight: 700; font-display: swap; }
/* LXGW WenKai (OFL), a textbook-style Kai face, subset to the characters in data/zh1.json. */
@font-face { font-family: 'WenKai'; src: url('../fonts/wenkai-zh.woff2') format('woff2'); font-display: swap; }

/* Night-Neon color system (TV Ops brand-kit/tokens.css). Navy surfaces ~85%, text ~10%, gradient/accent ~5%.
   Accents mark state only: primary action, selected/current, correct/wrong, stars. */
:root {
  --navy-deep: #081126;
  --navy: #0B1026;
  --surface: #121D3B;
  --surface-raised: #192542;
  --surface-received: #26324E;
  --border: #344363;

  --orange: #FF9F1C;
  --pink: #FF4D8D;
  --purple: #A855F7;
  --violet: #601CFF;
  --blue: #2386FF;

  --white: #F4F6FF;
  --muted: #AEB9D2;
  --label: #9DB8FF;
  --disabled: #68758F;

  --success: #00D98B;
  --danger: #FF6B7F;

  --gradient-brand: linear-gradient(115deg, #FF9F1C 0%, #FF4D8D 46%, #A855F7 77%, #601CFF 100%);
  --gradient-frame: linear-gradient(110deg, #2386FF 0%, #A855F7 67%, #FF4D8D 100%);
  --gradient-focus: linear-gradient(90deg, #FF9F1C, #FF4D8D, #A855F7);
  --gradient-level: linear-gradient(90deg, #FF4D8D, #A855F7);
  --gradient-backdrop: radial-gradient(circle at 25% 15%, #1A1F4A, #0B1026 55%, #081126);
  --focus-fill: linear-gradient(90deg, #3A1A2C, #261642);
  --disabled-fill: #0F1832;
  --disabled-border: #222D4A;
  --toast: #22305A;
  --glow-pink: 0 0 18px rgba(255, 77, 141, .35);
  --shadow-float: 0 8px 24px rgba(0, 0, 0, .35);

  --radius-card: 22px;
  --radius-control: 16px;
  --radius-field: 14px;

  /* The kit's Arabic face is Noto Sans Arabic; this project keeps The Year of Handicrafts. */
  --font: 'Handicrafts', 'Noto Sans Arabic', 'Geeza Pro', sans-serif;
  --font-zh: 'WenKai', 'Kaiti SC', 'STKaiti', 'PingFang SC', sans-serif;
  --font-pinyin: 'Avenir Next', 'Helvetica Neue', system-ui, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; background: var(--navy); }
body {
  margin: 0; min-height: 100dvh; color: var(--white);
  background: var(--gradient-backdrop) fixed, var(--navy);
  font-family: var(--font); font-size: 21px; line-height: 1.7;
  -webkit-tap-highlight-color: transparent; user-select: none; -webkit-user-select: none;
}
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
button:disabled { cursor: default; }
:focus-visible { outline: 3px solid var(--purple); outline-offset: 3px; }
h1, h2, p { margin: 0; }
[hidden] { display: none !important; }

.app { max-width: 920px; margin: 0 auto; padding: 18px 16px 48px; }

/* top bar */
.topbar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 10px; padding: 10px 16px; padding-top: max(10px, env(safe-area-inset-top)); background: rgba(11, 16, 38, .88); backdrop-filter: blur(10px); border-bottom: 1px solid var(--border); }
.topbar h1 { flex: 1; font-size: 20px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn { width: 48px; height: 48px; border-radius: var(--radius-control); background: var(--surface-raised); border: 1px solid var(--border); display: grid; place-items: center; flex: none; }
.icon-btn.ghost { background: none; border: 0; }
.pill { background: var(--surface-raised); border: 1px solid var(--border); border-radius: 999px; padding: 2px 14px; font-weight: 700; white-space: nowrap; }

/* buttons — primary = brand gradient with short bold labels (white over the orange end needs the shade) */
.btn { border-radius: var(--radius-control); padding: 12px 22px; font-weight: 700; min-height: 56px; transition: transform .12s ease, box-shadow .12s ease, opacity .12s; }
.btn:active:not(:disabled) { transform: scale(.97); }
.btn.big { font-size: 24px; min-height: 68px; padding: 12px 34px; }
.btn.primary { background: var(--gradient-brand); color: #fff; text-shadow: 0 1px 3px rgba(8, 17, 38, .55); box-shadow: 0 6px 18px -6px rgba(255, 77, 141, .55); }
.btn.soft, .btn.ghost { background: var(--surface-raised); border: 1px solid var(--border); color: var(--white); }
.btn:disabled { opacity: .35; box-shadow: none; }

.eyebrow { color: var(--label); font-weight: 700; font-size: 17px; }
.fine { color: var(--muted); font-size: 16px; }
.center { text-align: center; }

/* start */
.start { text-align: center; padding-top: 6vh; display: grid; justify-items: center; gap: 8px; }
.start .mascot { width: 170px; animation: bob 3s ease-in-out infinite; filter: drop-shadow(0 0 24px rgba(168, 85, 247, .35)); }
.start-title { font-size: clamp(44px, 9vw, 68px); font-weight: 700; line-height: 1.25; }
.start-sub { font-size: 22px; color: var(--muted); }
.start-actions { display: flex; flex-wrap: wrap; gap: 14px; justify-content: center; margin: 22px 0 8px; }
.name-form { display: grid; justify-items: center; gap: 10px; margin-top: 14px; width: min(440px, 100%); }
.name-form label { font-size: 26px; font-weight: 700; }
.name-form input {
  width: 100%; font: inherit; font-size: 28px; text-align: center; padding: 12px 18px; border-radius: var(--radius-control);
  border: 3px solid var(--border); background: var(--surface-raised); color: var(--white); outline: none;
  user-select: text; -webkit-user-select: text;
}
.name-form input::placeholder { color: var(--disabled); }
.name-form input:focus { border-color: transparent; background: linear-gradient(var(--surface-raised), var(--surface-raised)) padding-box, var(--gradient-focus) border-box; }
.name-form .start-actions { margin-top: 6px; }
@keyframes bob { 50% { transform: translateY(-8px) rotate(-2deg); } }

/* home */
.hero { display: flex; align-items: center; gap: 18px; background: var(--surface); border: 1px solid var(--surface-received); border-radius: var(--radius-card); padding: 16px 22px; }
.hero-mascot .mascot { width: 116px; display: block; }
.hero-text { flex: 1; }
.hero-text h2 { font-size: 28px; }
.meter { height: 12px; background: var(--surface-raised); border-radius: 99px; overflow: hidden; margin: 6px 0 2px; }
.meter span { display: block; height: 100%; background: var(--gradient-level); border-radius: 99px; }
.motto { text-align: center; color: var(--label); font-weight: 700; margin: 18px 0 6px; }

.path { list-style: none; margin: 0; padding: 0; display: grid; gap: 18px; position: relative; }
.path::before { content: ''; position: absolute; top: 40px; bottom: 40px; right: 52px; border-right: 3px dashed var(--border); }
.step { width: 100%; display: flex; align-items: center; gap: 18px; text-align: right; background: var(--surface); border: 1px solid var(--surface-received); border-radius: var(--radius-card); padding: 16px 18px; position: relative; transition: transform .12s; }
.step:active:not(:disabled) { transform: scale(.99); }
.step-icon { width: 72px; height: 72px; border-radius: 50%; display: grid; place-items: center; font-size: 36px; flex: none; overflow: hidden; border: 3px solid var(--border); background: var(--surface-raised); }
.step-body { display: grid; }
.step-label { color: var(--muted); font-size: 16px; }
.step-title { font-size: 26px; font-weight: 700; line-height: 1.35; }
.step-meta { font-size: 16px; color: var(--label); }
/* the lesson she should do next: the one gradient-led element on this screen */
.step.is-current { border: 3px solid transparent; background: linear-gradient(var(--surface), var(--surface)) padding-box, var(--gradient-brand) border-box; box-shadow: var(--glow-pink); }
.step.is-current .step-icon { border-color: transparent; background: linear-gradient(var(--surface-raised), var(--surface-raised)) padding-box, var(--gradient-focus) border-box; }
.step.is-done .step-icon { border-color: var(--success); }
.step.is-done .step-meta { color: var(--success); }
.step.is-locked { background: var(--disabled-fill); border-color: var(--disabled-border); color: var(--disabled); }
.step.is-locked .step-label, .step.is-locked .step-meta { color: var(--disabled); }
.step.is-locked .step-icon { background: var(--disabled-fill); border-color: var(--disabled-border); }

/* lesson */
.lesson-head { display: flex; gap: 16px; align-items: center; margin-bottom: 18px; }
.lesson-icon { font-size: 54px; }
.lesson-head h2 { font-size: 27px; }
.games { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 16px; }
.game-tile { background: var(--surface); border: 1px solid var(--surface-received); border-radius: var(--radius-card); padding: 18px; display: grid; justify-items: center; text-align: center; gap: 4px; transition: transform .12s; }
.game-tile:active { transform: scale(.98); }
.game-tile.is-locked { opacity: .55; cursor: default; }
.game-tile.is-locked:active { transform: none; }
.game-icon { font-size: 46px; }
.game-title { font-size: 25px; font-weight: 700; }
.game-goal { font-size: 16px; color: var(--muted); }
.stars { font-size: 26px; letter-spacing: 2px; }
.star { color: var(--border); }
.star.on { color: var(--orange); }
.new-tag { font-size: 15px; background: var(--pink); color: #fff; border-radius: 999px; padding: 0 12px; font-weight: 700; }

/* intro + results */
.intro, .results { text-align: center; display: grid; justify-items: center; gap: 10px; padding-top: 5vh; }
.intro-icon { font-size: 76px; }
.intro h2, .results h2 { font-size: 34px; }
.intro p { font-size: 23px; max-width: 34ch; color: var(--white); }
.results .mascot { width: 150px; }
.big-stars { font-size: 66px; letter-spacing: 6px; }
.big-stars .star.on { animation: pop .5s ease both; text-shadow: 0 0 18px rgba(255, 159, 28, .45); }
.big-stars .star.on:nth-child(2) { animation-delay: .15s; }
.big-stars .star.on:nth-child(3) { animation-delay: .3s; }
@keyframes pop { from { transform: scale(.2); opacity: 0; } 70% { transform: scale(1.25); } }
.score { font-size: 22px; color: var(--muted); }

/* play */
/* Progress bar stays on top; the question block sits in the middle of the remaining height. */
.play { display: flex; flex-direction: column; gap: 16px; min-height: calc(100dvh - 140px); }
.play > .progress { flex: none; margin-bottom: auto; }
.play::after { content: ''; margin-top: auto; }
.progress { height: 10px; background: var(--surface-raised); border-radius: 99px; overflow: hidden; }
.progress span { display: block; height: 100%; background: var(--gradient-level); border-radius: 99px; transition: width .4s ease; }
.round-title { text-align: center; font-size: 22px; font-weight: 700; color: var(--label); }
.prompt-card { position: relative; background: var(--surface); border: 1px solid var(--surface-received); border-radius: var(--radius-card); padding: 24px 22px 20px; text-align: center; display: grid; justify-items: center; gap: 6px; min-height: 180px; align-content: center; }
.prompt-card.is-retry { border: 2px dashed var(--orange); }
.retry-tag { position: absolute; top: 10px; right: 14px; font-size: 14px; color: var(--orange); background: var(--surface-raised); border: 1px solid var(--border); border-radius: 999px; padding: 0 10px; }
.prompt-icon { font-size: 54px; line-height: 1.1; }
.prompt-text { font-size: clamp(24px, 3.6vw, 32px); font-weight: 700; line-height: 1.6; max-width: 30ch; }
.blank { display: inline-block; min-width: 3.4em; border-bottom: 4px solid var(--pink); color: var(--pink); margin: 0 6px; }
.speak-btn.round { position: absolute; top: 12px; left: 12px; width: 52px; height: 52px; border-radius: 50%; background: var(--surface-raised); border: 1px solid var(--border); }

.options { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.options.wide { grid-template-columns: 1fr; }
.options.n3:not(.wide) { grid-template-columns: repeat(3, 1fr); }
.options.bins-3 { grid-template-columns: repeat(3, 1fr); }
.options.bins-4 { grid-template-columns: repeat(2, 1fr); }
.opt { min-height: 76px; padding: 12px 16px; border-radius: 18px; background: var(--surface-raised); border: 2px solid var(--border); color: var(--white); font-size: 23px; font-weight: 700; display: flex; align-items: center; justify-content: center; gap: 10px; text-align: center; line-height: 1.4; transition: transform .1s, background .2s, border-color .2s; }
.opt:active:not(:disabled) { transform: scale(.97); border-color: var(--purple); }
.bins .opt { flex-direction: column; min-height: 120px; gap: 2px; }
.opt-icon { font-size: 38px; }
.tf .opt { min-height: 96px; font-size: 30px; }
.tf .opt-true .ico { color: var(--success); width: 34px; height: 34px; stroke-width: 2.6; }
.tf .opt-false .ico { color: var(--danger); width: 34px; height: 34px; stroke-width: 2.6; }
.opt.is-right { background: rgba(0, 217, 139, .14); border-color: var(--success); }
.opt.is-wrong { background: rgba(255, 107, 127, .14); border-color: var(--danger); animation: shake .35s; }
.opt:disabled:not(.is-right):not(.is-wrong) { opacity: .4; }
@keyframes shake { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }

.feedback { background: var(--surface); border: 1px solid var(--surface-received); border-radius: var(--radius-card); padding: 16px 20px; display: grid; gap: 6px; justify-items: center; text-align: center; animation: rise .25s ease; }
.fb-title { font-size: 26px; font-weight: 700; }
.fb-title.good { color: var(--success); }
.fb-title.bad { color: var(--orange); } /* gentle "let's learn" for a child, not an error red */
.fb-answer { font-size: 22px; }
.fb-why { font-size: 21px; color: var(--white); max-width: 40ch; }
.feedback .btn { margin-top: 6px; min-width: 200px; }
.page-tag { display: inline-block; background: var(--surface-raised); border: 1px solid var(--border); border-radius: 999px; padding: 2px 14px; font-size: 17px; font-weight: 700; color: var(--label); }
@keyframes rise { from { transform: translateY(10px); opacity: 0; } }

/* flash cards */
.deck { display: grid; justify-items: center; gap: 16px; }
.deck-count { color: var(--muted); }
.flash { width: min(560px, 100%); aspect-ratio: 5 / 3.4; perspective: 1200px; }
.flash-inner { display: block; position: relative; width: 100%; height: 100%; transition: transform .5s ease; transform-style: preserve-3d; }
.flash.is-flipped .flash-inner { transform: rotateY(180deg); }
.flash-face { position: absolute; inset: 0; border-radius: 26px; backface-visibility: hidden; -webkit-backface-visibility: hidden; display: grid; place-content: center; justify-items: center; gap: 6px; padding: 20px 26px; box-shadow: var(--shadow-float); }
.flash-front { background: var(--surface); border: 1px solid var(--surface-received); }
.flash-back { border: 3px solid transparent; background: linear-gradient(var(--surface-raised), var(--surface-raised)) padding-box, var(--gradient-frame) border-box; transform: rotateY(180deg); }
.flash-icon { font-size: 72px; line-height: 1.1; }
.flash-term { font-size: clamp(30px, 5vw, 42px); font-weight: 700; }
.flash-term.small { font-size: 24px; color: var(--label); }
.flash-def { font-size: clamp(20px, 3vw, 25px); line-height: 1.7; }
.hint { color: var(--muted); font-size: 16px; }
.deck-nav { display: flex; gap: 12px; }

/* illustrations (generated on the --surface navy, shown as rounded tiles) and drawn icons */
/* The generated navy backgrounds are close to, not exactly, the surfaces they sit on (and the lighter buttons differ
   more), so each picture fades out toward its edges instead of showing a square tile. */
.pic {
  display: block; width: 100%; height: 100%; object-fit: contain; -webkit-user-drag: none;
  -webkit-mask-image: radial-gradient(closest-side, #000 80%, transparent 100%);
  mask-image: radial-gradient(closest-side, #000 80%, transparent 100%);
}
.step-icon .pic { -webkit-mask-image: none; mask-image: none; }
.emo { line-height: 1; }
.ico { width: 1.1em; height: 1.1em; vertical-align: -0.18em; flex: none; }
.ico.sm { width: .9em; height: .9em; }
.icon-btn .ico { width: 24px; height: 24px; }
.page-tag .ico, .step-meta .ico, .eyebrow .ico { margin-inline-end: 2px; }
.btn .ico { margin-inline-start: 4px; }

.prompt-icon { width: 96px; height: 96px; display: grid; place-items: center; }
.prompt-icon.is-subject { width: 170px; height: 170px; }
.flash-icon { width: 210px; height: 210px; display: grid; place-items: center; }
.opt-icon { width: 64px; height: 64px; display: grid; place-items: center; }
.bins .opt-icon { width: 96px; height: 96px; }
.game-icon { width: 104px; height: 104px; display: grid; place-items: center; }
.intro-icon { width: 150px; height: 150px; display: grid; place-items: center; }
.lesson-icon { width: 84px; height: 84px; display: grid; place-items: center; flex: none; }
.step-icon .pic { border-radius: 50%; transform: scale(1.12); }
.step-icon .ico { width: 30px; height: 30px; color: var(--disabled); }
.speak-btn.round .ico, .deck-nav .speak-btn .ico { width: 26px; height: 26px; color: var(--white); }
.pill .star { font-size: 18px; }

.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--toast); border: 1px solid var(--border); color: var(--white); padding: 10px 20px; border-radius: var(--radius-field); box-shadow: var(--shadow-float); z-index: 9; animation: rise .25s; }

/* ---- subjects ---- */
.mascot-pic { display: inline-block; aspect-ratio: 1; vertical-align: middle; }
.start-mascots { display: flex; gap: 6px; }
.start-mascots .mascot { width: 140px; }
.pick-title { text-align: center; font-size: 28px; margin: 10px 0 18px; }
.subjects { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 18px; }
.subject-tile { background: var(--surface); border: 1px solid var(--surface-received); border-radius: var(--radius-card); padding: 22px 18px; display: grid; justify-items: center; gap: 4px; text-align: center; transition: transform .12s; }
.subject-tile:active { transform: scale(.98); }
.subject-tile .mascot { width: 130px; }
.subject-tile .game-title { font-size: 30px; }
.motto-gap { height: 18px; }

/* ---- Chinese text: hanzi in the Kai face with pinyin above each word, as in the book ---- */
.zh { font-family: var(--font-zh); font-weight: 400; unicode-bidi: isolate; display: inline-block; line-height: 1.25; }
.zh ruby { ruby-position: over; margin: 0 .06em; }
.zh rt { font-family: var(--font-pinyin); font-size: .42em; font-weight: 500; color: var(--label); letter-spacing: .02em; line-height: 1.4; }
.zh-p { margin: 0 .04em; }
.zh-blank { display: inline-block; width: 2.2em; height: .95em; vertical-align: -.1em; margin: 0 .15em; border-bottom: 4px solid var(--pink); }
.zh-big .zh { font-size: clamp(54px, 11vw, 84px); }
.zh-char .zh { font-size: clamp(80px, 16vw, 120px); }
.prompt-text .zh { font-size: 1.35em; }
.opt .zh { font-size: 1.35em; }
.opt .zh rt { color: var(--muted); }
.opt-sub { display: block; font-size: 17px; color: var(--muted); font-weight: 400; }
.opt-emo { font-size: 1.3em; }
.zh-emoji { font-size: 64px; line-height: 1; width: auto; height: auto; }
.zh-emoji.is-scene { font-size: 40px; max-width: 12em; letter-spacing: 4px; line-height: 1.3; }
.step-title .zh { font-size: 1.15em; }
.step-ar, .lesson-ar { display: block; font-size: 18px; color: var(--muted); font-weight: 400; }
.lesson-head h2 .zh { font-size: 1.4em; }
.flash-zh .zh { font-size: clamp(54px, 10vw, 80px); }
.flash-zh.small .zh { font-size: 40px; }
.flash-def.zh-def { font-size: clamp(32px, 6vw, 46px); font-weight: 700; }
.flash .zh-emoji { font-size: 84px; }

/* dialogue */
.talk-people { display: flex; align-items: flex-end; gap: 14px; justify-content: center; }
.talk-person { display: grid; justify-items: center; gap: 2px; }
.avatar { width: 96px; height: 96px; display: block; }
.talk-person.is-other .avatar { width: 68px; height: 68px; opacity: .9; }
/* imported kawaii pictures: portraits are cropped round like the drawn faces; word pictures sit in the prompt */
.avatar-pic { border-radius: 50%; overflow: hidden; background: var(--surface-raised); }
.avatar-pic .pic { -webkit-mask-image: none; mask-image: none; object-fit: cover; transform: scale(1.08); }
.prompt-icon.zh-pic { width: 170px; height: 170px; }
.talk-people .prompt-icon.zh-pic { width: 120px; height: 120px; }
.talk-name .zh { font-size: 20px; }
.talk-says { display: block; font-size: 17px; color: var(--muted); font-weight: 400; }
.talk-hint { display: block; font-size: 18px; color: var(--label); font-weight: 400; margin-top: 4px; }

/* listening */
.listen-btn { width: 128px; height: 128px; border-radius: 50%; display: grid; place-items: center; background: var(--gradient-brand); box-shadow: 0 8px 26px -8px rgba(255, 77, 141, .7); animation: pulse 2.2s ease-in-out infinite; }
.listen-btn .ico { width: 56px; height: 56px; color: #fff; }
.listen-btn:active { transform: scale(.95); }
@keyframes pulse { 50% { box-shadow: 0 0 0 14px rgba(255, 77, 141, .12); } }

/* sentence order */
.mount { display: grid; gap: 14px; justify-items: center; }
.order { width: 100%; display: grid; gap: 14px; }
.order-line { min-height: 96px; border: 2px dashed var(--border); border-radius: 18px; padding: 10px; display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; align-items: center; background: var(--surface); }
.order-line.is-right { border: 2px solid var(--success); background: rgba(0, 217, 139, .1); }
.order-line.is-wrong { border: 2px solid var(--danger); animation: shake .35s; }
.order-hint { color: var(--disabled); font-size: 18px; }
.order-bank { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; min-height: 76px; }
.tile { min-height: 72px; min-width: 64px; padding: 6px 14px; border-radius: 16px; background: var(--surface-raised); border: 2px solid var(--border); box-shadow: 0 3px 0 var(--border); }
.tile .zh { font-size: 34px; }
.tile:active:not(:disabled) { transform: translateY(2px); box-shadow: none; }
.order-line .tile { border-color: var(--purple); }

/* writing */
.prompt-icon.is-stroke { width: 180px; height: 180px; }
.stroke-pic { width: 100%; height: 100%; }
.trace { display: grid; justify-items: center; gap: 10px; }
.trace-box { position: relative; background: var(--surface); border-radius: 12px; touch-action: none; }
.trace-box .grid, .trace-target { position: absolute; inset: 0; width: 100%; height: 100%; }
.trace-target svg { display: block; }
.trace-status { color: var(--label); font-weight: 700; min-height: 1.7em; }
.trace-title .zh { font-size: 40px; }

@media (max-width: 560px) {
  body { font-size: 19px; }
  .options.bins-3 { grid-template-columns: 1fr; }
  .bins .opt { flex-direction: row; min-height: 72px; }
  .opt { font-size: 21px; }
  .hero { padding: 12px 14px; }
  .hero-mascot .mascot { width: 88px; }
  .path::before { right: 46px; }
  .step-icon { width: 60px; height: 60px; font-size: 30px; }
  .prompt-icon.is-subject, .flash-icon { width: 130px; height: 130px; }
  .bins .opt-icon { width: 52px; height: 52px; }
  .start-mascots .mascot { width: 104px; }
  .avatar { width: 76px; height: 76px; }
  .tile .zh { font-size: 28px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* living book (الكتاب الحي): a card on the subject home, and the book itself full-bleed under the top bar */
.books { display: grid; gap: 18px; margin-bottom: 8px; }
.book-card { border-color: var(--purple); }
.book-icon { position: relative; flex: none; }
.book-badge { position: absolute; bottom: -4px; left: -4px; width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; background: var(--gradient-brand); color: #fff; box-shadow: var(--shadow-float); }
.book-badge svg, .book-badge .ico { width: 18px; height: 18px; color: #fff; }
body.reading .app { max-width: none; padding: 0; }
.book-frame { display: block; width: 100%; height: calc(100dvh - var(--bar-h, 64px)); border: 0; background: var(--navy); }

/* ---- math (Chapter 3): charts, tallies, bags, spinners, builders --------------------------------- */
.micon { width: 1.3em; height: 1.3em; display: block; }
.emo .micon { width: 1.25em; height: 1.25em; }
.prompt-icon.math-icon { width: 84px; height: 84px; font-size: 64px; }
.chart { margin: 0; width: 100%; max-width: 560px; display: grid; gap: 4px; }
.chart figcaption { font-weight: 700; color: var(--label); font-size: 18px; }
/* LTR so text-anchor start/end mean left/right; Arabic labels still render right-to-left inside. */
.chart-svg { width: 100%; height: auto; overflow: visible; font-family: inherit; direction: ltr; }
.chart-svg .grid { stroke: var(--border); stroke-width: 1; }
.chart-svg .axis { stroke: var(--muted); stroke-width: 2; }
.chart-svg .tick { fill: var(--muted); font-size: 14px; }
.chart-svg .cat { fill: var(--white); font-size: 14px; font-weight: 700; }
.chart-svg .axis-title { fill: var(--label); font-size: 13px; }
.chart-svg .bar { fill: var(--blue); }
.chart-svg .line { fill: none; stroke: var(--pink); stroke-width: 3.5; stroke-linejoin: round; }
.chart-svg .dot { fill: var(--blue); stroke: var(--white); stroke-width: 2; }
.chart-svg .slice { stroke: var(--surface); stroke-width: 2.5; }
.chart-svg .slice-label { fill: #fff; font-size: 15px; font-weight: 700; paint-order: stroke; stroke: rgba(11, 16, 38, .55); stroke-width: 3px; }
.chart-svg .slice-label.out { fill: var(--white); stroke: none; }
.chart-svg .hit-area { fill: transparent; }
.chart.is-pie { max-width: 460px; padding: 0 40px; }
/* Tap-to-answer: the whole column, row or slice is the target. */
.tap-chart { width: 100%; display: grid; justify-items: center; background: var(--surface); border: 1px solid var(--surface-received); border-radius: var(--radius-card); padding: 14px; }
.tap-chart .hit { cursor: pointer; }
.tap-chart:not(.is-done) .hit:hover .bar, .tap-chart:not(.is-done) .hit:hover .slice { filter: brightness(1.2); }
.tap-chart:not(.is-done) .hit:hover .hit-area { fill: rgba(168, 85, 247, .12); }
.hit.is-right .bar, .hit.is-right .dot { fill: var(--success); }
.hit.is-right .slice { stroke: var(--success); stroke-width: 6; }
.hit.is-right .hit-area { fill: rgba(0, 217, 139, .14); }
.hit.is-wrong .bar, .hit.is-wrong .dot { fill: var(--danger); }
.hit.is-wrong .slice { stroke: var(--danger); stroke-width: 6; }
.hit.is-wrong .hit-area { fill: rgba(255, 107, 127, .14); }
tr.hit.is-right td { background: rgba(0, 217, 139, .18); }
tr.hit.is-wrong td { background: rgba(255, 107, 127, .18); }
.data-table { border-collapse: collapse; margin: 0 auto; min-width: 260px; font-size: 19px; }
.data-table th { background: var(--blue); color: #fff; padding: 8px 14px; font-weight: 700; }
.data-table td { border: 1px solid var(--border); padding: 6px 14px; background: var(--surface-raised); text-align: center; }
.tap-chart tr.hit td { padding: 12px 16px; }
.tally { height: 34px; vertical-align: middle; }
.tally-line { stroke: var(--white); stroke-width: 3.2; stroke-linecap: round; }
.tally-line.slash { stroke: var(--pink); }
.tally-big { width: auto; min-width: 96px; }
.tally-big .tally { height: 64px; }
.opt .tally { height: 40px; }
.big-num { font-size: 64px; font-weight: 700; color: var(--orange); line-height: 1.2; }
.raw { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.raw-chip { min-height: 44px; padding: 4px 14px; border-radius: 12px; background: var(--surface-raised); border: 2px solid var(--border); color: var(--white); font-size: 18px; font-weight: 700; }
.raw-chip.is-counted { opacity: .4; text-decoration: line-through; border-style: dashed; }
.set { display: grid; place-items: center; }
.set .bag, .set .spinner { width: 190px; height: 190px; }
.bag-body { fill: rgba(244, 246, 255, .1); stroke: var(--muted); stroke-width: 2.5; }
.bag-neck { fill: rgba(244, 246, 255, .18); stroke: var(--muted); stroke-width: 2; }
.spinner .rim { stroke: var(--white); stroke-width: 3; }
.spinner .needle { stroke: var(--white); stroke-width: 6; stroke-linecap: round; }
.spinner .hub { fill: var(--white); }
.spin-label { fill: #fff; font-size: 26px; font-weight: 700; paint-order: stroke; stroke: rgba(11, 16, 38, .5); stroke-width: 3px; }
.cards-row { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; direction: rtl; }
.mini-card { min-width: 44px; height: 56px; padding: 0 8px; display: grid; place-items: center; border-radius: 8px; background: var(--white); color: var(--navy); font-size: 24px; font-weight: 700; box-shadow: 0 3px 0 var(--border); }
.pattern-wrap { width: 100%; overflow-x: auto; }
.data-table.pattern th { background: var(--surface-received); white-space: nowrap; font-size: 16px; }
.data-table.pattern td { min-width: 44px; padding: 10px 6px; font-size: 21px; }
.data-table.pattern td.gap { background: rgba(255, 77, 141, .18); border: 2px dashed var(--pink); color: var(--pink); font-weight: 700; }
.math-flash .micon { width: 150px; height: 150px; }
.math-flash .bag { width: 180px; height: 180px; }
/* bar builder */
.builder { --track: 220px; display: flex; gap: 10px; align-items: flex-end; justify-content: center; width: 100%; background: var(--surface); border: 1px solid var(--surface-received); border-radius: var(--radius-card); padding: 28px 12px 16px; direction: ltr; }
.builder-col.is-axis { flex: none; width: 34px; }
.is-axis .builder-track { background: none; border-bottom: none; }
.is-axis .builder-track span { position: absolute; inset-inline-end: 4px; transform: translateY(50%); color: var(--muted); font-size: 15px; }
.is-axis .builder-btns { visibility: hidden; }
.is-axis .builder-btns .icon-btn { width: 10px; }
.builder-col { display: grid; justify-items: center; gap: 6px; flex: 1; max-width: 96px; }
.builder-track { height: var(--track); width: 100%; position: relative; background: repeating-linear-gradient(to top, var(--border) 0 1px, transparent 1px calc(var(--track) / var(--rows))); border-bottom: 2px solid var(--muted); }
.builder-bar { position: absolute; bottom: 0; inset-inline: 18%; background: var(--blue); border-radius: 4px 4px 0 0; transition: height .15s; display: grid; place-items: start center; }
.builder-bar span { transform: translateY(-26px); font-weight: 700; color: var(--white); }
.builder-btns { display: grid; gap: 6px; }
.builder-btns .icon-btn { width: 44px; height: 40px; font-size: 16px; color: var(--white); }
.builder-cat { font-size: 15px; font-weight: 700; text-align: center; line-height: 1.3; min-height: 2.6em; }
.builder-col.is-right .builder-bar { background: var(--success); }
.builder-col.is-wrong .builder-bar { background: var(--danger); }
/* bag designer */
.designer { display: flex; flex-wrap: wrap; gap: 18px; align-items: center; justify-content: center; width: 100%; background: var(--surface); border: 2px solid var(--surface-received); border-radius: var(--radius-card); padding: 16px; }
.designer.is-right { border-color: var(--success); }
.designer.is-wrong { border-color: var(--danger); animation: shake .35s; }
.designer-rows { display: grid; gap: 10px; }
.designer-row { display: flex; align-items: center; gap: 10px; }
.designer-row .icon-btn { font-size: 26px; color: var(--white); }
.swatch { width: 28px; height: 28px; border-radius: 50%; }
.designer-name { min-width: 4.5em; font-weight: 700; }
.designer-n { min-width: 1.6em; text-align: center; font-size: 24px; }
@media (max-width: 560px) {
  .builder { --track: 180px; gap: 4px; padding: 12px 6px; }
  .builder-btns .icon-btn { width: 40px; height: 36px; }
  .builder-cat { font-size: 13px; }
  .data-table { font-size: 17px; min-width: 0; }
  .set .bag, .set .spinner { width: 160px; height: 160px; }
}
/* chapter 4: number sentences and counters */
.eq { display: inline-block; font-size: 44px; font-weight: 700; letter-spacing: 1px; line-height: 1.5; }
.eq-gap { display: inline-grid; place-items: center; min-width: 1.3em; margin: 0 4px; color: var(--pink); border-bottom: 4px solid var(--pink); }
.opt .eq { font-size: 26px; }
.fb-answer .eq { font-size: 24px; }
.opt.opt-sign { font-size: 40px; }
.counters { width: min(100%, 380px); height: auto; }
@media (max-width: 560px) { .eq { font-size: 34px; } }
/* enrichment: Product Hunter */
.hunt { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; width: min(100%, 420px); margin: 0 auto; }
.hunt-tile { min-height: 64px; border-radius: 16px; border: 2px solid var(--border); background: var(--surface-raised); color: var(--white); font: inherit; font-size: 28px; font-weight: 700; cursor: pointer; }
.hunt-tile.is-picked { border-color: var(--blue, #2386FF); background: rgba(35,134,255,.25); }
.hunt.is-done .hunt-tile { cursor: default; }
.hunt-tile.is-right { border-color: var(--green, #00D98B); background: rgba(0,217,139,.22); }
.hunt-tile.is-wrong { border-color: var(--pink, #FF4D8D); background: rgba(255,77,141,.22); }
/* chapter 6: area model */
.area-model { width: min(100%, 420px); height: auto; color: var(--muted); font-family: inherit; }
.area-model .area-lab { fill: var(--white); font-size: 17px; font-weight: 700; text-anchor: middle; }
.area-model .area-val { fill: var(--white); font-size: 19px; font-weight: 700; text-anchor: middle; }
.area-model .area-val.is-gap { fill: var(--pink); font-size: 26px; }
.prompt-text.small { font-size: 19px; color: var(--muted); margin: 0; }
/* chapter list (math) */
.chapter-num { font-size: 34px; font-weight: 700; color: var(--white); }
.path.chapters::before { display: none; }
.term-head { color: var(--label); font-size: 19px; margin: 22px 4px 10px; }
/* fractions and decimals (chapters 10–12) */
.frac { display: inline-flex; flex-direction: column; align-items: center; vertical-align: middle; line-height: 1.05; margin: 0 .12em; }
.frac > span:first-child { border-bottom: 2px solid currentColor; padding: 0 .15em; }
.fnum { white-space: nowrap; unicode-bidi: isolate; }
.frac-model { width: min(100%, 300px); height: auto; color: var(--muted); }
.frac-model.is-circle { width: min(60%, 170px); }
.number-line { width: min(100%, 420px); height: auto; color: var(--muted); }
.number-line .nl-lab { fill: var(--white); font-size: 18px; font-weight: 700; text-anchor: middle; }
.number-line .nl-lab.is-gap { fill: var(--pink); font-size: 22px; }
.shape-wrap { display: flex; justify-content: center; }
.shape-fig { width: min(70%, 230px); height: auto; color: var(--muted); }
.shape-fig .fig-lab { fill: var(--white); font-size: 18px; font-weight: 700; text-anchor: middle; }
.fig-row { display: flex; gap: 12px; justify-content: center; }
.fig-row .shape-fig { width: min(45%, 170px); }
.shape-fig .fig-lab.small { font-size: 14px; font-weight: 400; }
.shape-fig.is-wide { width: min(100%, 420px); }
/* accounts, dashboards, badges and the class board */
.auth-form h2 { margin: 0 0 4px; }
.auth-form label { font-size: 18px; }
.auth-form input { width: 100%; }
.form-error { color: var(--pink); min-height: 1.2em; margin: 0; font-weight: 700; }
.link-btn { background: none; border: 0; color: var(--label); font: inherit; font-size: 17px; text-decoration: underline; cursor: pointer; padding: 8px; }
.google-btn { text-decoration: none; display: inline-flex; margin: 4px auto 10px; }
.role-card, .achievements { display: grid; gap: 10px; justify-items: start; margin-bottom: 12px; }
.achievements .stats { width: 100%; }
.badges { display: flex; flex-wrap: wrap; gap: 8px; }
.badge { background: var(--surface-raised); border: 1px solid var(--border); border-radius: 999px; padding: 4px 12px; font-size: 15px; font-weight: 700; }
.board { list-style: none; padding: 0; display: grid; gap: 8px; max-width: 520px; margin: 12px auto; }
.board li { display: flex; align-items: center; gap: 12px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 10px 14px; font-size: 19px; }
.board li.is-me { border-color: var(--pink); background: var(--surface-raised); }
.board .rank { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; background: var(--surface-raised); }
.board .rank.top1 { background: #FFC93C; color: #0B1026; }
.board .rank.top2 { background: #C9D2E3; color: #0B1026; }
.board .rank.top3 { background: #E2945A; color: #0B1026; }
.board .who { flex: 1; font-weight: 700; }
.class-card { display: grid; gap: 10px; margin-bottom: 14px; }
.class-card h2 { margin: 0; }
.code { font-family: ui-monospace, monospace; letter-spacing: 2px; background: var(--surface-raised); padding: 2px 8px; border-radius: 8px; direction: ltr; unicode-bidi: isolate; }
.child { padding: 10px 14px; }
.child summary { cursor: pointer; font-size: 18px; }
.child-subject { margin: 8px 0; font-size: 16px; }
.weak { margin: 4px 0; padding-inline-start: 20px; font-size: 15px; }
.new-class, .student-invite { display: grid; gap: 8px; max-width: 420px; }
.student-invite .btn { justify-self: start; }
.btn.small { padding: 6px 12px; font-size: 15px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-card); padding: 16px 18px; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; text-align: center; }
.stats b { display: block; font-size: 30px; line-height: 1.3; color: var(--white); }
.stats span { color: var(--muted); font-size: 15px; }
.new-class input, .student-invite input { font: inherit; font-size: 19px; padding: 10px 14px; border-radius: var(--radius-control); border: 2px solid var(--border); background: var(--surface-raised); color: var(--white); }
