/* ===== "Block World" theme: bright sky, blocky city, white cards, chunky green buttons ===== */
:root {
  --sky-top: #1f6fe0;
  --sky-mid: #4a97f5;
  --sky-low: #9fd0ff;
  --bg: #eef6ff;          /* inner panels inside cards */
  --card: #ffffff;
  --ink: #142640;
  --muted: #566a86;
  --line: #d5e4f6;
  --brand: #12b05b;        /* chunky green */
  --brand-dark: #0a8a45;
  --brand-ink: #ffffff;
  --brand-soft: #e2f8eb;
  --blue: #1f6fe0;
  --sun: #ffc61a;
  --ok: #12b05b;
  --ok-soft: #e2f8eb;
  --bad: #e03131;
  --bad-soft: #ffe8e8;
  --accent: #1f6fe0;
  --accent-soft: #e4efff;
  --shadow: 0 2px 0 rgba(20, 38, 64, .06), 0 10px 24px rgba(20, 60, 130, .14);
  --radius: 16px;
  --zh: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  --fun: "Fredoka", "Baloo 2", -apple-system, "Segoe UI", sans-serif;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--sky-mid); color: var(--ink);
  font: 17px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, var(--zh);
  -webkit-text-size-adjust: 100%;
  min-height: 100vh;
}
/* fixed sky + blocky city (pseudo-element so it also stays put on iPad Safari) */
body::before {
  content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    url("/static/city.svg") center bottom / auto 42vh repeat-x,
    radial-gradient(ellipse 60% 22% at 18% 16%, rgba(255,255,255,.55), transparent 70%),
    radial-gradient(ellipse 50% 18% at 82% 26%, rgba(255,255,255,.45), transparent 70%),
    linear-gradient(180deg, var(--sky-top) 0%, var(--sky-mid) 45%, var(--sky-low) 100%);
}
a { color: var(--accent); }
button { font: inherit; color: inherit; }
.zh { font-family: var(--zh); }
h1, h2, .brand, .btn, .tabs button, .unit .num, .theme, .score { font-family: var(--fun); }

/* header: solid blue bar */
.top {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 8px max(16px, env(safe-area-inset-left));
  background: linear-gradient(180deg, #2a7cf0, #1c64d1);
  box-shadow: 0 3px 0 #164fa8, 0 6px 16px rgba(10, 40, 100, .25);
}
.brand { display: flex; align-items: center; gap: 8px; text-decoration: none; color: #fff; font-size: 24px; font-weight: 700; letter-spacing: .5px; }
.brand b { color: var(--sun); }
.brand .wm { display: flex; flex-direction: column; line-height: 1.05; text-shadow: 0 2px 0 #123f88; }
.brand .site-name { font-size: 14px; font-weight: 600; color: #fff; letter-spacing: .3px; opacity: .95; }
.brand .site-name:empty { display: none; }
.logo {
  width: 36px; height: 36px; border-radius: 8px; background: var(--sun); color: #7a3d00;
  display: grid; place-items: center; font-family: var(--zh); font-size: 21px; font-weight: 800;
  box-shadow: inset 0 -4px 0 rgba(0,0,0,.18), 0 3px 0 #b8860b; transform: rotate(-6deg);
}
#nav { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
#nav a, #nav button {
  border: 0; background: rgba(255,255,255,.14); padding: 8px 12px; border-radius: 10px; color: #fff;
  text-decoration: none; font-size: 15px; cursor: pointer; font-family: var(--fun); font-weight: 500;
}
#nav a:hover, #nav button:hover { background: rgba(255,255,255,.28); }
#nav .who { color: #fff; font: 500 15px var(--fun); padding: 8px 4px 8px 8px; }
#nav button.logout { background: #fff; color: var(--blue); font-weight: 600; box-shadow: 0 3px 0 #164fa8; }
#nav button.logout:hover { background: #ffe8e8; color: var(--bad); }
@media (max-width: 560px) {
  #nav { gap: 4px; }
  #nav a, #nav button { padding: 7px 9px; font-size: 14px; }
  #nav .who { display: none; } /* phones: keep the Log out button, hide the name to save space */
  #nav a .lbl { display: none; } /* phones: Chapters / Progress / Families become icon-only */
  #nav { flex-wrap: nowrap; }
}

main { max-width: 860px; margin: 0 auto; padding: 18px 16px 80px; }
h1 { font-size: 30px; line-height: 1.2; margin: 6px 0 4px; font-weight: 700; }
h2 { font-size: 21px; margin: 0 0 6px; font-weight: 600; }
h3 { font-size: 17px; margin: 14px 0 6px; }
.sub { color: var(--muted); margin: 0 0 16px; }
/* headings sitting directly on the sky are white */
main > h1, main > .sub, main > a.muted, #app > h1, #app > .sub, #app > a.muted, #app > .muted, .theme { color: #fff; text-shadow: 0 2px 0 rgba(15, 60, 140, .45); }
#app > .muted[style*="brand"] { color: var(--sun) !important; }

.card {
  background: var(--card); border: 0; border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 18px; margin: 0 0 14px;
}
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 10px 18px; border-radius: 12px; border: 2px solid var(--line);
  background: var(--card); cursor: pointer; text-decoration: none; color: var(--ink); font-weight: 600;
  box-shadow: 0 3px 0 var(--line); transition: transform .08s, box-shadow .08s;
}
.btn:active { transform: translateY(3px); box-shadow: 0 0 0 var(--line); }
.btn.primary { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); box-shadow: 0 4px 0 var(--brand-dark); font-size: 18px; }
.btn.primary:hover { background: #17c266; }
.btn.primary:active { box-shadow: 0 0 0 var(--brand-dark); }
.btn.ok { background: var(--ok-soft); color: var(--ok); border-color: #b2ebc8; box-shadow: 0 3px 0 #b2ebc8; }
.btn.small { min-height: 36px; padding: 6px 12px; font-size: 15px; }
.btn.small.primary { font-size: 15px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.muted { color: var(--muted); }
.pill {
  display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 13px;
  background: var(--accent-soft); color: var(--accent);
}

/* login */
/* login: split hero like a game landing page */
.welcome { display: grid; gap: 22px; align-items: center; grid-template-columns: 1.1fr .9fr; margin-top: 4vh; }
.welcome .hero-text { text-align: center; color: #fff; }
.welcome h1 { font-size: clamp(30px, 5vw, 46px); color: #fff; text-shadow: 0 3px 0 #164fa8; margin: 0; }
.welcome .tag { font: 600 clamp(18px, 2.6vw, 24px) var(--fun); text-shadow: 0 2px 0 #164fa8; margin: 6px 0 16px; }
.welcome .island { width: 100%; max-width: 420px; margin: 0 auto; display: block; border-radius: 18px; border: 4px solid #fff; box-shadow: 0 10px 26px rgba(10, 40, 100, .3); }
.welcome .ask { font: 600 22px var(--fun); margin-top: 12px; text-shadow: 0 2px 0 #164fa8; }
.login { max-width: 380px; width: 100%; margin: 0 auto; background: rgba(255,255,255,.94); }
.login h2 { font-size: 24px; color: var(--ink); text-align: center; }
.login label { display: block; font-size: 15px; color: var(--muted); margin: 12px 0 4px; font-weight: 600; }
.login .hint { font-size: 13px; color: var(--muted); margin: 4px 0 0; }
.kick { background: #fff4d6; border: 2px solid var(--sun); color: #5a3a00; border-radius: 12px; padding: 10px 12px; margin-bottom: 12px; font-weight: 600; }
.kick small { font-weight: 400; }
/* families admin */
.acct-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); margin: 12px 0; }
fieldset.acct { border: 2px solid var(--line); border-radius: 12px; padding: 8px 12px 12px; margin: 0; }
fieldset.acct legend { font-weight: 700; padding: 0 6px; }
fieldset.acct label, form.mf label, #ff > label { display: block; font-size: 14px; color: var(--muted); margin: 8px 0 4px; font-weight: 600; }
.fam td.row { gap: 6px; }
details.addm { margin-top: 10px; }
details.addm summary { cursor: pointer; font-weight: 600; color: var(--accent); }
form.mf { max-width: 360px; }
@media (max-width: 760px) {
  .welcome { grid-template-columns: 1fr; margin-top: 0; }
  .welcome .island { max-width: 320px; }
}
input, select {
  width: 100%; min-height: 48px; font: inherit; padding: 10px 14px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--bg); color: var(--ink);
}
input:focus, select:focus { outline: 2px solid var(--brand); outline-offset: 1px; }
.err { color: var(--bad); min-height: 1.4em; margin: 10px 0 0; }

/* home: units */
.units { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.unit {
  display: block; text-decoration: none; color: var(--ink); background: var(--card);
  border: 0; border-top: 8px solid var(--blue); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow);
  transition: transform .12s;
}
.unit:hover { transform: translateY(-3px); }
.unit.locked { opacity: .7; pointer-events: none; border-top-color: #b7c7dc; background: rgba(255,255,255,.82); }
.unit .num { font-size: 14px; color: var(--blue); font-weight: 700; letter-spacing: .04em; }
.unit .t-zh { font-family: var(--zh); font-size: 20px; margin: 4px 0 0; }
.unit .t-en { color: var(--muted); font-size: 15px; }
.bar { height: 12px; border-radius: 99px; background: var(--line); overflow: hidden; margin-top: 12px; box-shadow: inset 0 2px 0 rgba(0,0,0,.06); }
.bar > i { display: block; height: 100%; background: linear-gradient(180deg, #2fd27a, var(--brand)); border-radius: 99px; }
.theme { margin: 24px 0 10px; font-size: 17px; font-weight: 600; }

/* unit page */
.tabs {
  position: sticky; top: 52px; z-index: 5; display: flex; gap: 8px; overflow-x: auto;
  background: transparent; padding: 10px 2px 12px; margin: 8px -2px 8px; scrollbar-width: none;
}
.tabs button {
  flex: 0 0 auto; border: 0; background: #fff; border-radius: 12px; color: var(--ink);
  padding: 8px 16px; cursor: pointer; min-height: 42px; font-weight: 600;
  box-shadow: 0 3px 0 #b9cde8, 0 6px 12px rgba(20, 60, 130, .12);
}
.tabs button[aria-selected="true"] { background: var(--sun); color: #5a3300; box-shadow: 0 3px 0 #c99700, 0 6px 12px rgba(20, 60, 130, .15); }

.section-head { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.section-head .zh { font-size: 20px; }
.book-ref { flex: 0 0 auto; font-size: 13px; padding: 4px 10px; border-radius: 8px; background: var(--brand-soft); color: var(--brand); font-weight: 600; white-space: nowrap; }
.section.done { border-color: var(--ok); }
.explain p { margin: 8px 0; }
.points { margin: 8px 0; padding-left: 20px; }
.points li { margin: 4px 0; }
.quote {
  border-left: 4px solid var(--brand); background: var(--brand-soft); padding: 10px 14px;
  border-radius: 0 12px 12px 0; margin: 10px 0;
}
.quote .zh { font-size: 18px; }
.quote .py { font-size: 13px; color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; }
.chip {
  border: 1px solid var(--line); background: var(--bg); border-radius: 999px; padding: 6px 12px;
  cursor: pointer; font-family: var(--zh); font-size: 16px; min-height: 38px;
}
.chip:hover { border-color: var(--brand); }
details.faq { border-top: 1px solid var(--line); padding: 10px 0 0; margin-top: 10px; }
details.faq summary { cursor: pointer; font-weight: 600; color: var(--accent); }
.qa { margin: 10px 0; }
.qa b { display: block; }

/* glossary */
.terms { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); }
.term { position: relative; }
.term .zh { font-size: 22px; }
.term .py { color: var(--muted); font-size: 14px; }
.term .en { font-weight: 600; margin-top: 4px; }
.term .bm { font-size: 14px; color: var(--muted); font-style: italic; }
.term .def { font-size: 15px; margin-top: 6px; }
.term .acts { position: absolute; top: 12px; right: 12px; display: flex; gap: 4px; }
.icon {
  width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--line); background: var(--card);
  cursor: pointer; display: grid; place-items: center; font-size: 17px;
}
.icon.on { background: #fff3bf; border-color: #fab005; }

/* flashcards */
.flash { perspective: 1000px; max-width: 460px; margin: 0 auto; }
.flash .inner {
  position: relative; height: 260px; transition: transform .45s; transform-style: preserve-3d; cursor: pointer;
}
.flash.flipped .inner { transform: rotateY(180deg); }
.flash .face {
  position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden;
  display: grid; place-items: center; text-align: center; padding: 20px;
  background: var(--card); border: 1px solid var(--line); border-radius: 20px; box-shadow: var(--shadow);
}
.flash .back { transform: rotateY(180deg); }
.flash .big { font-family: var(--zh); font-size: 40px; }

/* timeline */
.timeline { position: relative; margin-left: 10px; padding-left: 22px; border-left: 3px solid var(--line); }
.tl { position: relative; margin: 0 0 16px; }
.tl::before {
  content: ""; position: absolute; left: -31px; top: 6px; width: 15px; height: 15px; border-radius: 50%;
  background: var(--brand); border: 3px solid var(--bg);
}
.tl .yr { font-weight: 800; color: var(--brand); font-size: 18px; }

/* quiz */
.opt {
  display: block; width: 100%; text-align: left; border: 2px solid var(--line); background: var(--card);
  border-radius: 14px; padding: 12px 16px; margin: 8px 0; cursor: pointer; min-height: 52px;
}
.opt:hover:not(:disabled) { border-color: var(--accent); }
.opt.right { border-color: var(--ok); background: var(--ok-soft); }
.opt.wrong { border-color: var(--bad); background: var(--bad-soft); }
.opt:disabled { cursor: default; }
.why { border-radius: 12px; padding: 12px 14px; margin-top: 10px; }
.why.right { background: var(--ok-soft); }
.why.wrong { background: var(--bad-soft); }
.qprog { height: 6px; border-radius: 9px; background: var(--line); overflow: hidden; margin-bottom: 12px; }
.qprog i { display: block; height: 100%; background: var(--brand); transition: width .3s; }
.score { font-size: 48px; font-weight: 800; color: var(--brand); text-align: center; }
.en-toggle { font-size: 14px; }
.q-en { color: var(--muted); font-size: 15px; margin-top: 4px; }

/* ask box */
.ask input { margin-bottom: 8px; }
.hit { border-top: 1px solid var(--line); padding: 10px 0; }
.hit small { color: var(--muted); }

/* popover */
.pop {
  position: fixed; left: 50%; bottom: max(18px, env(safe-area-inset-bottom)); transform: translateX(-50%);
  width: min(440px, calc(100vw - 32px)); z-index: 50; background: var(--card); border: 1px solid var(--line);
  border-radius: 18px; box-shadow: 0 10px 40px rgba(0,0,0,.25); padding: 16px 18px;
}
.pop .zh { font-size: 26px; }
.pop .close { position: absolute; top: 10px; right: 10px; }

table { width: 100%; border-collapse: collapse; font-size: 15px; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
.form-grid { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }

@media (max-width: 560px) {
  body { font-size: 16px; }
  h1 { font-size: 22px; }
  .card { padding: 14px; }
  .brand .wm-name { display: none; }   /* phones: keep the logo and the site name, drop the wordmark */
  .brand .site-name { font-size: 13px; max-width: 110px; line-height: 1.15; }
  .tabs { top: 53px; }
  .flash .inner { height: 220px; }
}

/* ===== clay art ===== */
svg.clay { display: block; overflow: visible; }
svg.clay g, svg.clay path, svg.clay text { transform-box: fill-box; transform-origin: center; }
svg.clay .lzh { font: 600 13px var(--zh); fill: #3a2a20; }
svg.clay .len { font: 500 11px -apple-system, "Segoe UI", sans-serif; fill: #5b4a3d; }
.hero, .scene-wrap { margin: 0 0 14px; }
/* cap width (not height) so the svg box always matches the drawing and clipping lines up with the rounded edges */
.hero svg, .scene-wrap svg { width: 100%; height: auto; max-width: 560px; margin: 0 auto; }
.scene-wrap { margin: 10px 0 4px; }
svg.clay .bob { animation: bob 2.6s ease-in-out infinite; }
svg.clay .hop { animation: hop 1.6s ease-in-out infinite; }
svg.clay .hop.d1 { animation-delay: .2s; } svg.clay .hop.d2 { animation-delay: .4s; }
svg.clay .tilt { animation: tilt 3s ease-in-out infinite; }
svg.clay .rise { animation: rise 3s ease-in-out infinite; }
svg.clay .pop { animation: popin 3.2s ease-out infinite; }
svg.clay .pop.p2 { animation-delay: .25s; } svg.clay .pop.p3 { animation-delay: .5s; } svg.clay .pop.p4 { animation-delay: .75s; }
svg.clay .glow { animation: glow 2.2s ease-in-out infinite; }
svg.clay .nod.a { animation: nod 2s ease-in-out infinite; } svg.clay .nod.b { animation: nod 2s ease-in-out 1s infinite; }
svg.clay .waves { animation: glow 1.2s ease-in-out infinite; }
svg.clay .shake { animation: shake 2.4s ease-in-out infinite; }
svg.clay .flash { animation: flash 2s steps(1) infinite; }
svg.clay .spin { animation: spin 8s linear infinite; } svg.clay .spin.slow { animation-duration: 16s; }
svg.clay .write { animation: write 1.4s ease-in-out infinite; }
svg.clay g.orbit { transform-box: view-box; transform-origin: 200px 78px; animation: spin 10s linear infinite; }
svg.clay .rock { animation: rock 3s ease-in-out infinite; }
svg.clay g.rock { transform-origin: 50% 90%; }
svg.clay .wave.w1 { animation: wave 3s linear infinite; }
svg.clay .wave.w2 { animation: wave 5s linear infinite reverse; opacity: .85; }
/* scenes are clipped to their rounded box so nothing (waves, sliding pieces) pokes outside */
svg.clay.scene { overflow: hidden; border-radius: 18px; }
svg.clay .storm-cloud { animation: bob 3s ease-in-out infinite; }
svg.clay .shakeArm { animation: shakeArm 1s ease-in-out infinite; }
svg.clay .spark { animation: popin 2s ease-out infinite; } svg.clay .spark.s2 { animation-delay: 1s; }
svg.clay .pen { animation: write 1.2s ease-in-out infinite; }
svg.clay .sig { stroke-dasharray: 160; animation: draw 3s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-4px); } }
@keyframes hop { 0%, 60%, 100% { transform: translateY(0); } 30% { transform: translateY(-6px); } }
@keyframes tilt { 0%, 100% { transform: rotate(-7deg); } 50% { transform: rotate(7deg); } }
@keyframes rise { 0% { transform: translateY(26px); } 45%, 85% { transform: translateY(0); } 100% { transform: translateY(26px); } }
@keyframes popin { 0% { transform: scale(0); opacity: 0; } 15% { transform: scale(1.15); opacity: 1; } 22%, 85% { transform: scale(1); opacity: 1; } 100% { transform: scale(0); opacity: 0; } }
@keyframes glow { 50% { opacity: .55; } }
@keyframes nod { 0%, 100% { transform: rotate(0); } 25% { transform: rotate(-6deg); } 50% { transform: rotate(4deg); } }
@keyframes shake { 0%, 50%, 100% { transform: translateX(0); } 10%, 30% { transform: translateX(-4px); } 20%, 40% { transform: translateX(4px); } }
@keyframes flash { 0%, 70% { opacity: 1; } 75%, 85% { opacity: 0; } 90% { opacity: 1; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes write { 50% { transform: translate(-6px, 3px) rotate(-6deg); } }
@keyframes rock { 0%, 100% { transform: rotate(-5deg) translateY(0); } 50% { transform: rotate(5deg) translateY(4px); } }
@keyframes wave { to { transform: translateX(-100px); } }
@keyframes shakeArm { 50% { transform: translateY(8px); } }
@keyframes draw { 0% { stroke-dashoffset: 160; } 60%, 100% { stroke-dashoffset: 0; } }

/* merge scene: 12s story loop */
.merge .m-piece, .merge .m-badge { animation-duration: 12s; animation-timing-function: ease-in-out; animation-iteration-count: infinite; }
.merge .m-malaya { animation-name: inLeft; }
.merge .m-sg { animation-name: sgStory; }
.merge .m-swk { animation-name: inRight; }
.merge .m-sbh { animation-name: inTopRight; }
.merge .m-brn { animation-name: brnStory; }
.merge .m-badge { animation-name: badge; }
.merge .yr65 { font: 700 11px sans-serif; fill: #b02a1a; animation: yr65 12s infinite; }
@keyframes inLeft { 0% { transform: translateX(-140px); opacity: 0; } 14%, 92% { transform: none; opacity: 1; } 100% { opacity: 0; } }
@keyframes inRight { 0% { transform: translate(160px, 50px); opacity: 0; } 16%, 92% { transform: none; opacity: 1; } 100% { opacity: 0; } }
@keyframes inTopRight { 0% { transform: translate(120px, -80px); opacity: 0; } 18%, 92% { transform: none; opacity: 1; } 100% { opacity: 0; } }
@keyframes sgStory { 0% { transform: translate(-130px, 40px); opacity: 0; } 14%, 60% { transform: none; opacity: 1; } 72%, 92% { transform: translate(14px, 26px); opacity: .55; } 100% { opacity: 0; } }
@keyframes yr65 { 0%, 62% { opacity: 0; } 70%, 92% { opacity: 1; } 100% { opacity: 0; } }
@keyframes brnStory { 0% { transform: translate(120px, 0); opacity: 0; } 16% { transform: none; opacity: 1; } 22% { transform: translateX(-5px); } 26% { transform: translateX(5px); } 30% { transform: translateX(-5px); } 34% { transform: none; } 46%, 92% { transform: translate(60px, 66px); opacity: .55; } 100% { opacity: 0; } }
@keyframes badge { 0%, 36% { transform: scale(0); opacity: 0; } 44% { transform: scale(1.15); opacity: 1; } 50%, 92% { transform: scale(1); opacity: 1; } 100% { transform: scale(.6); opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
  svg.clay *, .merge * { animation: none !important; opacity: 1 !important; }
}

/* ===== bubble map ===== */
.bmap { position: relative; width: 100%; max-width: 520px; aspect-ratio: 1; margin: 6px auto 0; }
.bm-lines { position: absolute; inset: 0; width: 100%; height: 100%; }
.bm-lines line { stroke: var(--brand); stroke-width: .6; stroke-dasharray: 1.6 1.2; opacity: .55; }
.bm-center, .bm-b {
  position: absolute; transform: translate(-50%, -50%); border-radius: 50%;
  display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center;
  padding: 4px; line-height: 1.15;
}
.bm-center {
  left: 50%; top: 50%; width: 32%; aspect-ratio: 1; background: var(--brand); color: var(--brand-ink);
  box-shadow: inset -6px -8px 14px rgba(0,0,0,.18), inset 6px 8px 14px rgba(255,255,255,.35), 0 6px 16px rgba(217,72,15,.35);
}
.bm-center .zh { font-size: clamp(13px, 3.4vw, 19px); font-weight: 700; }
.bm-center small { font-size: clamp(10px, 2.4vw, 13px); opacity: .9; margin-top: 2px; }
.bm-b {
  width: 29%; aspect-ratio: 1; background: var(--card); border: 2px solid var(--line); cursor: pointer; color: var(--ink);
  box-shadow: inset -5px -7px 12px rgba(0,0,0,.08), inset 5px 6px 10px rgba(255,255,255,.6), 0 4px 12px rgba(60,40,20,.12);
  animation: bubbleIn .5s cubic-bezier(.3,1.6,.5,1) both; transition: transform .15s, border-color .15s;
}
.bm-b:hover { transform: translate(-50%, -50%) scale(1.05); }
.bm-b.on { border-color: var(--brand); background: var(--brand-soft); }
.bm-art { width: 46%; aspect-ratio: 1; display: grid; place-items: center; margin-bottom: 2px; }
.bm-art svg { width: 100%; height: 100%; }
.bm-art img { width: 100%; height: 100%; object-fit: cover; object-position: top; border-radius: 50%; border: 2px solid var(--card); }
.bm-b .zh { font-size: clamp(11px, 2.9vw, 16px); font-weight: 700; }
.bm-b small { font-size: clamp(9px, 2.2vw, 12px); color: var(--muted); }
@keyframes bubbleIn { from { opacity: 0; transform: translate(-50%, -50%) scale(.3); } }
.bm-detail { background: var(--bg); border-radius: 12px; padding: 12px 14px; margin-top: 8px; color: var(--muted); text-align: center; }
.bm-detail.show { color: var(--ink); text-align: left; border-left: 4px solid var(--brand); animation: fadeUp .3s; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(6px); } }

/* bright, kid-friendly bubble style (map.style = "bright") */
.bmap.bright .bm-lines line { stroke-width: 1.4; stroke-dasharray: none; opacity: .9; stroke-linecap: round; }
.bmap.bright .bm-center {
  background: radial-gradient(circle at 32% 26%, #ffe8a3 0%, #ff9f43 38%, #ff5e7e 100%);
  color: #fff; border: 4px solid #fff; text-shadow: 0 1px 2px rgba(120, 30, 0, .45);
  box-shadow: inset -8px -10px 16px rgba(160, 20, 60, .3), inset 6px 8px 14px rgba(255,255,255,.5), 0 8px 22px rgba(255, 94, 126, .45);
  animation: pulse 3s ease-in-out infinite;
}
.bmap.bright .bm-b {
  background: radial-gradient(circle at 32% 26%, #ffffff 0%, color-mix(in srgb, var(--bc) 35%, #fff) 30%, var(--bc) 78%);
  border: 4px solid #fff; color: #2b1d12;
  box-shadow: inset -7px -9px 14px rgba(0,0,0,.14), inset 6px 7px 12px rgba(255,255,255,.7), 0 6px 16px color-mix(in srgb, var(--bc) 55%, transparent);
  animation: bubbleIn .5s cubic-bezier(.3,1.6,.5,1) both, floaty 3.2s ease-in-out infinite;
}
.bmap.bright .bm-b small { color: #4a3526; font-weight: 600; }
.bmap.bright .bm-b.on { border-color: #2b1d12; box-shadow: 0 0 0 5px var(--bc), 0 8px 22px color-mix(in srgb, var(--bc) 60%, transparent); }
.bmap.bright .bm-b:hover { animation-play-state: paused; }
@keyframes floaty { 0%, 100% { transform: translate(-50%, -50%); } 50% { transform: translate(-50%, calc(-50% - 6px)); } }
@keyframes pulse { 50% { transform: translate(-50%, -50%) scale(1.04); } }

/* bubble detail: 中文 → pinyin → English (hidden) */
.bm-detail.show { border-left-color: var(--bc, var(--brand)); }
.bd-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.bd-head .zh { font-size: 19px; color: var(--ink); border-bottom: 4px solid var(--bc); }
.bd-zh { font-size: 19px; line-height: 1.75; margin: 10px 0 4px; color: var(--ink); }
.bd-py { font-size: 14px; line-height: 1.6; color: var(--muted); margin: 0 0 10px; }
.bd-en { margin-top: 10px; padding: 10px 12px; border-radius: 10px; background: var(--card); border: 1px dashed var(--line); animation: fadeUp .25s; }

/* read-along highlight */
.s { border-radius: 6px; transition: background .2s, color .2s, box-shadow .2s; }
.zh .s.reading, .zh.s.reading { background: #ffe066; color: #2b1d12; box-shadow: 0 0 0 3px #ffe066; }
.qa-py .s.reading, .bd-py .s.reading { background: color-mix(in srgb, #ffe066 35%, transparent); color: var(--ink); box-shadow: 0 0 0 2px color-mix(in srgb, #ffe066 35%, transparent); }
[data-read] { flex: 0 0 auto; }

/* Mandarin-first blocks */
[data-enroot]:not(.en-on) .en-only { display: none !important; }
.en-all { margin-top: 10px; }
.zblock { margin: 4px 0; }
.zb-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.zb-head h2 { margin: 0; }
.zb-zh { font-size: 18px; line-height: 1.75; margin: 10px 0 2px; }
.zb-py, .fl-py, .pr-py { font-size: 13.5px; line-height: 1.6; color: var(--muted); margin: 0 0 6px; }
.fl-py { font-size: 12.5px; }
.pr-py { font-size: 11px; }
.zb-py .s.reading { background: color-mix(in srgb, #ffe066 35%, transparent); color: var(--ink); }

/* quiz + flashcards in 中文 */
.q-py { font-size: 14px; color: var(--muted); margin-bottom: 6px; }
.opt-py { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.why .zb-head .zh { font-size: 17px; }
.why-zh { font-size: 17px; line-height: 1.75; margin: 8px 0 2px; }
.why-py { font-size: 13px; line-height: 1.6; color: var(--muted); margin: 0 0 8px; }
.why-py .s.reading { background: color-mix(in srgb, #ffe066 35%, transparent); color: var(--ink); }
.why .bd-en { text-align: left; }
.flash .face.back { overflow-y: auto; align-items: center; }
/* Flat 2D flip (no 3D, so it renders the same on every device incl. iPad Safari):
   the card squeezes to a line, JS swaps the face at the midpoint, then it opens again. */
.flash .inner, .flash.flipped .inner { transform: none; transition: none; transform-style: flat; }
.flash .face, .flash .face.back { transform: none; backface-visibility: visible; -webkit-backface-visibility: visible; }
.flash .face.front { visibility: visible; }
.flash .face.back { visibility: hidden; }
.flash.flipped .face.front { visibility: hidden; }
.flash.flipped .face.back { visibility: visible; }
.flash.turn .inner { animation: cardTurn .44s ease-in-out; }
@keyframes cardTurn { 0% { transform: scaleX(1); } 50% { transform: scaleX(.02); } 100% { transform: scaleX(1); } }
.fc-word { font-size: 30px; font-weight: 700; }
.fc-py { color: var(--muted); font-size: 16px; margin-bottom: 8px; }
.fc-def { font-size: 17px; line-height: 1.65; margin: 6px 0 2px; }
.fc-dpy { font-size: 12.5px; line-height: 1.5; color: var(--muted); margin: 0; }
.fc-py .s.reading, .fc-dpy .s.reading { background: color-mix(in srgb, #ffe066 35%, transparent); color: var(--ink); }
.fc-en { max-width: 460px; margin: 12px auto 0; text-align: center; }
.fc-en .bd-en { text-align: left; }

/* Q&A in 中文 */
.zhqa { background: var(--bg); border-radius: 12px; padding: 12px 14px; border-left: 4px solid var(--accent); }
.qa-q { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.qa-q .zh { font-size: 18px; }
.qa-a { font-size: 17px; line-height: 1.75; margin: 10px 0 2px; }
.qa-py { font-size: 13.5px; line-height: 1.6; color: var(--muted); margin-bottom: 8px; }

/* ===== flow map (laid out 5 + 5 like the book on wide screens) ===== */
.flow { list-style: none; padding: 0; margin: 10px 0 0; display: grid; gap: 22px 10px; grid-template-columns: 1fr; }
.fl-step {
  position: relative; background: var(--bg); border: 1px solid var(--line); border-radius: 14px; padding: 12px 12px 12px 48px;
  animation: fadeUp .4s both;
}
.fl-step:not(:last-child)::after {
  content: "↓"; position: absolute; left: 50%; bottom: -21px; transform: translateX(-50%); color: var(--brand); font-weight: 800;
}
.fl-n {
  position: absolute; left: 10px; top: 12px; width: 28px; height: 28px; border-radius: 50%; background: var(--brand); color: var(--brand-ink);
  display: grid; place-items: center; font-weight: 800; font-size: 14px;
  box-shadow: inset -3px -4px 6px rgba(0,0,0,.2), inset 3px 3px 6px rgba(255,255,255,.35);
}
.fl-date { font-weight: 800; color: var(--brand); }
.fl-step .zh { font-size: 15px; margin-top: 2px; }
.fl-en { font-size: 14px; color: var(--muted); }
.fl-photo { margin: 8px 0 0; }
.fl-photo img, .photos img { width: 100%; border-radius: 10px; display: block; filter: sepia(.15); }
figcaption { font-size: 12px; color: var(--muted); margin-top: 4px; }
@media (min-width: 720px) {
  .flow { grid-template-columns: repeat(5, 1fr); }
  .fl-step { padding: 40px 10px 10px; }
  .fl-n { left: 10px; top: 8px; }
  .fl-step:not(:last-child)::after { content: "→"; left: auto; right: -12px; top: 14px; bottom: auto; transform: none; }
  .fl-step:nth-child(5)::after { content: "↓"; right: 50%; top: auto; bottom: -21px; }
}

/* ===== people map ===== */
.people { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); margin-top: 10px; }
.person {
  display: flex; flex-direction: column; align-items: center; text-align: center; gap: 2px; cursor: pointer;
  background: var(--bg); border: 1px solid var(--line); border-top: 5px solid var(--rc); border-radius: 14px; padding: 12px 8px;
  animation: fadeUp .4s both; color: var(--ink);
}
.person:hover { border-color: var(--rc); }
.ph { width: 86px; height: 86px; border-radius: 50%; overflow: hidden; border: 3px solid var(--rc); margin-bottom: 6px; background: var(--card); }
.ph img { width: 100%; height: 100%; object-fit: cover; object-position: top; }
.noph {
  width: 100%; height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-weight: 800; font-size: 26px; color: #fff; background: var(--rc);
  box-shadow: inset -6px -8px 14px rgba(0,0,0,.2), inset 6px 8px 14px rgba(255,255,255,.35);
}
.noph small { font-size: 11px; font-weight: 600; }
.pn, .pe { font-size: 14px; }
.tags { display: flex; gap: 4px; flex-wrap: wrap; justify-content: center; margin: 4px 0; }
.tag { font-size: 11px; padding: 1px 8px; border-radius: 99px; color: #fff; font-weight: 700; }
.tag.ghost { background: var(--line); color: var(--ink); }
.pr { font-size: 12px; color: var(--muted); }

.photos { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); margin: 12px 0; }
.photos figure { margin: 0; }
details.more { margin-top: 10px; border-top: 1px solid var(--line); padding-top: 10px; }
details.more summary { cursor: pointer; font-weight: 600; color: var(--accent); }
.pop-word { display: flex; align-items: center; gap: 10px; padding-right: 44px; }
.pop .pop-word .zh { font-size: 28px; }
.pop-py { color: var(--muted); font-size: 15px; margin: 2px 0 8px; }
.pop .zh.pop-def { font-size: 18px; line-height: 1.7; margin: 6px 0 2px; }
.pop-dpy { font-size: 13.5px; line-height: 1.6; color: var(--muted); margin: 0 0 8px; }
.pop-py .s.reading, .pop-dpy .s.reading { background: color-mix(in srgb, #ffe066 35%, transparent); color: var(--ink); }
.pop { max-height: calc(100vh - 90px); overflow-y: auto; }
.pop-photo { width: 84px; height: 84px; border-radius: 50%; object-fit: cover; object-position: top; float: right; margin: 18px 4px 0 10px; }
.credits summary { cursor: pointer; font-weight: 600; }
.credits ul { font-size: 13px; padding-left: 18px; }

/* ===== teaser feedback (admin) ===== */
.fb-counts { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.fb-counts .fb-yes, .fb-counts .fb-no { font-weight: 700; font-size: 18px; padding: 6px 14px; border-radius: 12px; }
.fb-counts .fb-yes { background: #e3f6e3; color: #2f7a31; }
.fb-counts .fb-no { background: #eef1f6; color: #4c5d77; }
.fb-notes { list-style: none; padding: 0; margin: 12px 0 0; max-height: 320px; overflow: auto; }
.fb-notes li { display: flex; gap: 10px; padding: 8px 0; border-top: 1px solid #e6edf6; overflow-wrap: anywhere; }

/* ===== English books (book.lang = "en") ===== */
/* main text is already English: no "Show in English" buttons, rounded kid-friendly font */
body.lang-en [data-en-toggle], body.lang-en .bd-toggle, body.lang-en [data-en-all], body.lang-en #ent { display: none !important; }
body.lang-en .zh, body.lang-en .unit .t-zh { font-family: "Fredoka", -apple-system, "Segoe UI", sans-serif; letter-spacing: .2px; }
body.lang-en .zb-zh, body.lang-en .bd-zh, body.lang-en .qa-a, body.lang-en .why-zh, body.lang-en .pop-def, body.lang-en .fc-def { line-height: 1.6; }

/* ===== book shelf ===== */
.shelf { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.book-tile { display: block; text-decoration: none; color: inherit; background: #fff; border-radius: 20px; padding: 20px;
  box-shadow: 0 7px 0 rgba(0, 40, 100, .2); border-top: 8px solid var(--brand); transition: transform .1s; }
.book-tile:hover { transform: translateY(-3px); }
.book-tile .bk-icon { font-size: 42px; }
.book-tile .t-zh { font-size: 22px; font-weight: 700; margin-top: 8px; }
.book-tile .t-zh.zh { font-family: var(--zh); }
.book-tile .t-en { color: var(--muted); margin-top: 2px; }

/* clock scene: the long hand swings from 12 (o'clock) to 6 (half past) and back */
svg.clay g.clockhand { animation: clockhand 6s ease-in-out infinite; }
@keyframes clockhand { 0%, 35% { transform: rotate(0deg); } 50%, 85% { transform: rotate(180deg); } 100% { transform: rotate(360deg); } }
