[hidden] { display: none !important; }
:root {
  --bg: #fff6dc;
  --bg2: #ffeec2;
  --ink: #4a3b35;
  --ink-soft: #8a776c;
  --card: #ffffff;
  --line: #f1dfb8;
  --primary: #ff8a5b;
  --primary-dark: #e86a3a;
  --good: #3fbf7f;
  --bad: #ff6b6b;
  --accent: #ffd23f;
  --pet: #ffb3c7;
  --pet-shade: #f08aa6;
  --radius: 22px;
  --shadow: 0 6px 0 rgba(74, 59, 53, .08), 0 10px 24px rgba(74, 59, 53, .08);
  font-family: "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", system-ui, sans-serif;
  color-scheme: light;
}

.pet-cat { --pet: #e3b08f; --pet-shade: #c98c66; }
.pet-dog { --pet: #ddd0bd; --pet-shade: #a88b72; }
.pet-bird { --pet: #e8cd85; --pet-shade: #c9a54f; }
.pet-dragon { --pet: #a9c0a3; --pet-shade: #7f9a78; }
.pet-bunny { --pet: #eadfe0; --pet-shade: #d4a6b0; }
.pet-bear { --pet: #8d8792; --pet-shade: #4d4952; }
.pet-leopard { --pet: #d6b48d; --pet-shade: #a98560; }
.pet-magpie { --pet: #9fb6cf; --pet-shade: #5f80ad; }
.pet-clouded { --pet: #dcc29c; --pet-shade: #a98d67; }

/* 寵物待機動畫（同打字寵物村）：眨眼、尾巴輕搖 */
.p5 .eye { transform-box: fill-box; transform-origin: center; animation: blink 5s infinite; }
.p5 .tail, .p5 .wag { transform-box: fill-box; transform-origin: 0% 100%; animation: sway 1.6s ease-in-out infinite alternate; }
@keyframes blink { 0%, 94%, 100% { transform: scaleY(1); } 97% { transform: scaleY(.1); } }
@keyframes sway { from { transform: rotate(-4deg); } to { transform: rotate(5deg); } }
.think-mark { animation: popin .4s ease-out; transform-box: fill-box; transform-origin: center; }
@media (prefers-reduced-motion: reduce) { .p5 * { animation: none !important; } }

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; min-height: 100%; }
body {
  background: var(--bg);
  background-image: radial-gradient(#ffe3a3 1.6px, transparent 1.6px);
  background-size: 28px 28px;
  color: var(--ink);
  -webkit-user-select: none; user-select: none;
  -webkit-touch-callout: none;
  overscroll-behavior: none;
}
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; cursor: pointer; }
input, select { font: inherit; -webkit-user-select: text; user-select: text; }

.screen { min-height: 100vh; min-height: 100dvh; padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left)); max-width: 1200px; margin: 0 auto; }

/* ---------- 共用元件 ---------- */
.btn { border: 0; border-radius: 999px; padding: 12px 22px; font-size: 20px; font-weight: 800; background: #fff; box-shadow: 0 4px 0 var(--line); transition: transform .1s; min-height: 52px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--line); }
.btn.primary { background: var(--primary); color: #fff; box-shadow: 0 4px 0 var(--primary-dark); }
.btn.primary:disabled { background: #e7d9c6; box-shadow: 0 4px 0 #d6c4ad; color: #fff; cursor: default; }
.btn.ghost { background: #fff; border: 3px solid var(--line); }
.btn.big { font-size: 24px; padding: 14px 28px; min-height: 60px; }
.btn.round { width: 64px; height: 64px; padding: 0; font-size: 32px; border-radius: 50%; }
.btn.correct { background: var(--good) !important; color: #fff; border-color: var(--good) !important; }
.btn.bad { background: #ffe0e0 !important; border-color: var(--bad) !important; }
.btn.glow { animation: glow 1.2s ease-in-out infinite; }
@keyframes glow { 0%,100% { box-shadow: 0 4px 0 var(--primary-dark), 0 0 0 0 rgba(255,138,91,.6); } 50% { box-shadow: 0 4px 0 var(--primary-dark), 0 0 0 12px rgba(255,138,91,0); } }
.icon-btn { width: 52px; height: 52px; border-radius: 16px; background: #fff; display: grid; place-items: center; font-size: 26px; box-shadow: var(--shadow); flex: none; }

.bar { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.bar-title { flex: 1; font-size: 24px; font-weight: 900; text-align: center; }
.bar-right { min-width: 52px; text-align: right; font-weight: 800; font-size: 20px; }

.mascot { display: block; width: 100%; height: auto; overflow: visible; }
.bob .mascot, .mascot.bob { animation: bob 2.4s ease-in-out infinite; }
@keyframes bob { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
.mascot.jump, .jump-loop .mascot { animation: jump .7s cubic-bezier(.3,1.6,.5,1); }
.jump-loop .mascot { animation-iteration-count: infinite; animation-duration: 1.1s; }
@keyframes jump { 0% { transform: translateY(0) scale(1, 1); } 30% { transform: translateY(-22px) scale(.95, 1.05); } 60% { transform: translateY(0) scale(1.08, .92); } 100% { transform: translateY(0) scale(1); } }
.mascot.pop { animation: popin .35s ease-out; }
.pop { animation: popin .35s ease-out; }
@keyframes popin { 0% { transform: scale(.6); opacity: 0; } 70% { transform: scale(1.08); } 100% { transform: scale(1); opacity: 1; } }

.toast { position: fixed; left: 50%; bottom: 32px; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 12px 22px; border-radius: 999px; font-size: 18px; z-index: 100; max-width: 90vw; text-align: center; }
.toast[hidden] { display: none; }

/* ---------- 首頁 ---------- */
.home-head { text-align: center; position: relative; padding-top: 24px; }
.home-head h1 { font-size: clamp(40px, 7vw, 64px); margin: 0; color: var(--primary); letter-spacing: 4px; text-shadow: 0 4px 0 #ffd3bf; }
.home-head .sub { font-size: 24px; margin: 8px 0 0; color: var(--ink-soft); font-weight: 700; }
.head-actions { position: absolute; top: 0; right: 0; display: flex; gap: 10px; align-items: center; }
.sync-badge { font-size: 15px; background: #fff; padding: 8px 12px; border-radius: 999px; box-shadow: var(--shadow); font-weight: 700; white-space: nowrap; }
.kid-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 28px; margin: 40px auto 0; max-width: 860px; }
.kid-card { background: #fff; border-radius: 36px; padding: 28px 24px 24px; text-align: center; box-shadow: var(--shadow); border: 5px solid var(--pet); transition: transform .15s; position: relative; overflow: hidden; }
.kid-card::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 46%; background: var(--pet); opacity: .35; }
.kid-card:active { transform: scale(.97); }
.kid-pet { width: 190px; margin: 0 auto; position: relative; }
.kid-name { font-size: 36px; font-weight: 900; margin-top: 6px; }
.kid-meta { color: var(--ink-soft); font-size: 18px; font-weight: 700; margin-top: 4px; }
.kid-stars { display: inline-block; margin-top: 12px; background: #fff7d6; padding: 6px 16px; border-radius: 999px; font-weight: 800; font-size: 20px; }

/* ---------- 地圖 ---------- */
.map-hero { display: flex; align-items: center; gap: 20px; background: #fff; border-radius: var(--radius); padding: 16px 24px; box-shadow: var(--shadow); border: 4px solid var(--pet); }
.hero-pet { width: 150px; flex: none; }
.hero-text { flex: 1; }
.bubble { background: var(--bg); border-radius: 18px; padding: 12px 16px; font-size: 20px; font-weight: 700; line-height: 1.5; }
.book { margin-top: 10px; font-weight: 800; font-size: 18px; }
.book-note { color: var(--ink-soft); font-size: 15px; margin-top: 2px; }
.sec-title { font-size: 22px; margin: 26px 4px 12px; }
.lesson-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 14px; }
.lesson-grid.featured { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.lesson-card { background: #fff; border-radius: 18px; padding: 14px; display: flex; flex-direction: column; gap: 6px; box-shadow: var(--shadow); min-height: 110px; position: relative; }
.lesson-card .wk { font-size: 14px; color: var(--ink-soft); font-weight: 700; }
.lesson-card .lt { font-size: 19px; font-weight: 900; line-height: 1.3; }
.lesson-card.locked { opacity: .55; box-shadow: none; border: 2px dashed var(--line); background: rgba(255,255,255,.6); }
.lesson-card .soon { margin-top: auto; font-size: 13px; color: var(--ink-soft); }
.lesson-card.open { border: 4px solid var(--pet); }
.lesson-card.open.big { padding: 20px; min-height: 150px; background: linear-gradient(135deg, #fff 60%, var(--pet)); }
.lesson-card.big .lt { font-size: 28px; }
.prog { margin-top: auto; height: 12px; background: #f3ead8; border-radius: 99px; overflow: hidden; }
.prog span { display: block; height: 100%; background: var(--good); border-radius: 99px; }
.prog-text { font-weight: 800; font-size: 16px; color: var(--primary-dark); }

/* ---------- 課程 ---------- */
.lesson { display: flex; flex-direction: column; gap: 10px; padding-bottom: 0; }
.dots { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; max-width: 40%; }
.dot { width: 22px; height: 22px; border-radius: 50%; border: 3px solid var(--line); background: #fff; padding: 0; }
.dot.done { background: var(--accent); border-color: #f0b800; }
.dot.cur { outline: 3px solid var(--primary); outline-offset: 2px; }
.step-head { display: flex; align-items: baseline; gap: 12px; padding: 0 4px; }
.step-no { font-size: 15px; font-weight: 800; color: var(--ink-soft); background: #fff; border-radius: 99px; padding: 4px 12px; white-space: nowrap; }
.step-title { margin: 0; font-size: 28px; }
.stage { flex: 1; background: #fff; border-radius: 28px; box-shadow: var(--shadow); padding: 20px; min-height: 420px; position: relative; }

.coach { position: sticky; bottom: 0; display: grid; grid-template-columns: 110px 1fr auto; gap: 14px; align-items: center; background: rgba(255, 246, 220, .96); padding: 10px 4px max(10px, env(safe-area-inset-bottom)); backdrop-filter: blur(6px); }
.coach-pet { width: 110px; }
.coach-bubble { background: #fff; border-radius: 22px; padding: 14px 18px; font-size: 21px; line-height: 1.55; font-weight: 600; box-shadow: var(--shadow); position: relative; border: 3px solid var(--pet); min-height: 70px; display: flex; align-items: center; }
.coach-bubble::before { content: ""; position: absolute; left: -14px; top: 50%; transform: translateY(-50%); border: 10px solid transparent; border-right: 14px solid var(--pet); border-left: 0; }
.coach-text b { color: var(--primary-dark); }
.coach-nav { display: flex; flex-direction: column; gap: 8px; }
.coach-nav .btn { font-size: 18px; padding: 10px 18px; min-height: 48px; }

/* 算式 */
.equation { display: inline-flex; align-items: flex-start; gap: 10px; background: #fffaf0; border: 3px dashed var(--line); border-radius: 20px; padding: 12px 20px; margin: 8px auto; }
.eq-part { display: flex; flex-direction: column; align-items: center; }
.eq-part b { font-size: 44px; line-height: 1.1; }
.eq-part small { font-size: 14px; color: var(--ink-soft); font-weight: 800; background: #fff; padding: 2px 8px; border-radius: 99px; margin-top: 4px; }
.eq-part.q b { color: #2f8fd8; }
.eq-part.r b { color: var(--bad); }
.eq-op { font-size: 40px; font-weight: 900; line-height: 1.2; }
.share-result { text-align: center; font-size: 22px; font-weight: 700; }
.share-result p { margin: 10px 0; }
.share-result .note { font-size: 19px; color: var(--ink-soft); }
.share-result .btn { margin-top: 8px; }

/* 糖果 */
.candy { width: 52px; height: 36px; flex: none; touch-action: none; transition: opacity .2s; }
.candy-svg { width: 100%; height: 100%; display: block; pointer-events: none; }
.candy.dragging { opacity: .25; }
.drag-ghost { position: fixed; z-index: 50; pointer-events: none; filter: drop-shadow(0 6px 6px rgba(0,0,0,.2)); }
.candy.leftover { animation: wiggle 1s ease-in-out infinite; filter: drop-shadow(0 0 6px rgba(255,107,107,.9)); }
@keyframes wiggle { 0%,100% { transform: rotate(0); } 25% { transform: rotate(-10deg); } 75% { transform: rotate(10deg); } }

/* 分糖果 */
.share { display: flex; flex-direction: column; gap: 10px; }
.jar { background: #fff3f6; border: 4px dashed #ffc2d1; border-radius: 26px; padding: 8px 14px; min-height: 90px; }
.jar-label { font-weight: 800; font-size: 18px; color: var(--ink-soft); }
.jar-label b { font-size: 26px; color: var(--primary-dark); }
.jar-items, .plate-items { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; align-content: flex-start; }
.jar-items { min-height: 50px; }
.plates { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; }
.plate-wrap { display: flex; flex-direction: column; align-items: center; }
.friend { width: 86px; margin-bottom: -10px; position: relative; z-index: 1; }
.plate { width: 100%; max-width: 320px; min-height: 104px; border-radius: 50%/38%; background: radial-gradient(ellipse at center, #fff 55%, #f4ead6 56%, #fff 70%); border: 4px solid #eadcc0; padding: 26px 18px 18px; transition: transform .15s, border-color .15s; }
.plate-items .candy { width: 40px; height: 28px; }
.drop-hover { border-color: var(--primary) !important; transform: scale(1.04); background-color: #fff2ea; }
.plate-count { font-weight: 900; font-size: 22px; margin-top: 4px; }
.share-tools { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }

/* 圈一圈 */
.group-field { display: flex; flex-wrap: wrap; gap: 14px 10px; justify-content: center; padding: 16px; background: #f7fbff; border-radius: 24px; border: 3px dashed #cfe5ff; }
.group-field .candy { width: 72px; height: 50px; border-radius: 16px; padding: 4px; cursor: pointer; transition: transform .15s, background .2s; }
.group-field .candy.picked { background: #fff1b8; transform: scale(1.12); outline: 3px solid var(--accent); }
.group-field .candy.bagged { background: var(--bag); outline: 3px solid rgba(0,0,0,.08); transform: scale(.92); }
.group-bags { text-align: center; font-size: 22px; font-weight: 800; margin: 12px 0; }
.group-bags b { font-size: 34px; color: var(--primary-dark); }

/* 餘數實驗 */
.remlab { display: flex; flex-direction: column; align-items: center; gap: 14px; }
.rem-ctrl { display: flex; align-items: center; gap: 22px; }
.rem-n { font-size: 24px; font-weight: 800; min-width: 160px; text-align: center; }
.rem-n b { font-size: 44px; color: var(--primary-dark); }
.rem-rows { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; min-height: 140px; max-width: 900px; }
.rem-row { display: flex; align-items: center; gap: 2px; padding: 8px 10px 22px; border-radius: 16px; position: relative; }
.rem-row.bag { background: #eaf7ef; border: 3px solid #b9e6c9; }
.rem-row.left { background: #ffecec; border: 3px dashed var(--bad); }
.rem-row .candy-svg { width: 40px; height: 28px; }
.rem-row .tag { position: absolute; bottom: 2px; left: 0; right: 0; text-align: center; font-size: 13px; font-weight: 800; color: var(--ink-soft); }
.rem-eq { font-size: 34px; font-weight: 800; }
.rem-eq b { color: #2f8fd8; } .rem-eq b.r { color: var(--bad); }
.rem-track { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; justify-content: center; }
.rem-track span { width: 54px; height: 54px; border-radius: 50%; background: #f3ead8; display: grid; place-items: center; font-size: 26px; font-weight: 900; transition: all .2s; }
.rem-track span.on { background: var(--bad); color: #fff; transform: scale(1.15); }
.rem-track em { font-style: normal; color: var(--ink-soft); font-weight: 700; }
.quiz { background: #fffaf0; border: 3px solid var(--accent); border-radius: 20px; padding: 10px 20px; text-align: center; font-size: 22px; }
.quiz-opts { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; margin: 8px 0; }

/* 乘法表找商 */
.tablelab { display: flex; flex-direction: column; gap: 16px; align-items: center; }
.tl-q { font-size: 44px; font-weight: 900; }
.tl-line { position: relative; width: 100%; max-width: 900px; height: 70px; }
.tl-bar { position: absolute; left: 0; right: 0; top: 40px; height: 6px; background: repeating-linear-gradient(90deg, #d8c7a6 0 2px, transparent 2px calc(100% / 60)); border-bottom: 3px solid #d8c7a6; }
.tl-hops { position: absolute; inset: 0; }
.hop { position: absolute; top: 14px; height: 30px; border: 4px solid #2f8fd8; border-bottom: 0; border-radius: 50% 50% 0 0; animation: popin .3s; }
.hop.over { border-color: var(--bad); }
.tl-target { position: absolute; top: 0; height: 60px; border-left: 4px dashed var(--primary-dark); }
.tl-target span { position: absolute; top: 46px; left: -18px; background: var(--primary); color: #fff; font-weight: 900; border-radius: 10px; padding: 0 8px; font-size: 18px; }
.tl-rows { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; width: 100%; max-width: 760px; margin-top: 10px; }
.tl-row { border: 3px solid var(--line); background: #fff; border-radius: 16px; padding: 12px; font-size: 22px; font-weight: 700; min-height: 60px; }
.tl-row b { color: #2f8fd8; }
.tl-row.bad { background: #ffe0e0; border-color: var(--bad); }
.tl-row.meh { background: #fff6d6; border-color: var(--accent); }
.tl-row.good { background: var(--good); border-color: var(--good); color: #fff; }
.tl-row.good b { color: #fff; }

/* 直式除法 */
.ld { display: grid; grid-template-columns: minmax(260px, 1fr) minmax(300px, 1.1fr); gap: 24px; align-items: start; }
.ld-problem { font-size: 24px; font-weight: 800; margin-bottom: 10px; }
.ld-grid { display: grid; grid-template-columns: repeat(var(--cols), 64px); grid-template-rows: repeat(var(--rows), 66px); background: repeating-linear-gradient(#fff 0 65px, #eef3fb 65px 66px); border-radius: 18px; padding: 10px 16px; width: max-content; border: 3px solid #e3ebf7; position: relative; }
.ld-cell { display: grid; place-items: center; font-size: 46px; font-weight: 800; font-variant-numeric: tabular-nums; position: relative; z-index: 1; }
.ld-cell.hidden, .ld-line.hidden { visibility: hidden; }
.ld-cell.q { color: #2f8fd8; }
.ld-cell.rem { color: var(--bad); }
.ld-cell.bring { color: #8a5cd6; }
.ld-cell.divisor { color: var(--primary-dark); }
.bracket-cell { justify-items: start; }
.bracket { display: block; width: 18px; height: 60px; border-right: 5px solid var(--ink); border-radius: 0 0 30px 0 / 0 0 60px 0; transform: translateX(-10px); }
.ld-over { border-bottom: 5px solid var(--ink); align-self: end; margin-left: -44px; }
.ld-line { border-bottom: 4px solid var(--ink); align-self: end; margin-bottom: 2px; }
.ld-answer { font-size: 28px; font-weight: 900; margin-top: 12px; color: var(--good); min-height: 40px; }
.ld-steps { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.ld-chip { padding: 6px 12px; border-radius: 99px; background: #f3ead8; font-weight: 800; font-size: 17px; color: var(--ink-soft); transition: all .2s; }
.ld-chip.on { background: var(--primary); color: #fff; transform: scale(1.08); }
.ld-prompt { font-size: 23px; line-height: 1.6; font-weight: 700; background: #fffaf0; border-radius: 18px; padding: 12px 16px; border: 3px solid var(--line); min-height: 80px; }
.ld-prompt b { color: var(--primary-dark); }
.ld-input { margin-top: 12px; display: flex; gap: 12px; flex-wrap: wrap; }
.ld-hint { margin-top: 10px; font-size: 17px; min-height: 44px; }
.ld-table { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-top: 8px; font-size: 18px; font-weight: 700; background: #f7fbff; padding: 10px; border-radius: 14px; }
.ld-table[hidden] { display: none; }

/* 數字鍵盤 */
.numpad { width: 100%; max-width: 340px; }
.np-display { height: 64px; border-radius: 16px; border: 4px solid var(--primary); background: #fff; display: flex; align-items: center; justify-content: center; font-size: 40px; font-weight: 900; margin-bottom: 10px; }
.np-caret { width: 3px; height: 38px; background: var(--primary); margin-left: 3px; animation: blink 1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.np-keys { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.np-key { height: 62px; border-radius: 16px; border: 0; background: #fff; box-shadow: 0 4px 0 var(--line); font-size: 30px; font-weight: 800; border: 2px solid var(--line); }
.np-key:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--line); }
.np-ok { background: var(--good); color: #fff; font-size: 22px; border-color: var(--good); box-shadow: 0 4px 0 #2e9a63; }
.np-del { font-size: 26px; }

/* 應用題 */
.story { display: flex; flex-direction: column; gap: 16px; align-items: center; text-align: center; }
.story-q { font-size: 28px; font-weight: 800; line-height: 1.6; }
.story-vis { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; }
.story-group { display: flex; align-items: center; gap: 6px; padding: 10px 14px; border-radius: 18px; background: #eaf3ff; border: 3px solid #bcd8fb; }
.story-group.part { background: #ffecec; border: 3px dashed var(--bad); }
.story-group i { width: 22px; height: 22px; border-radius: 50%; background: #ffb347; display: block; box-shadow: inset 0 -3px 0 rgba(0,0,0,.12); }
.sg-icon { font-size: 30px; }

/* 完成畫面 */
.finish { text-align: center; position: relative; overflow: hidden; padding-top: 40px; }
.finish-pet { width: 220px; margin: 0 auto; }
.finish h1 { font-size: 44px; margin: 10px 0; color: var(--primary); }
.finish p { font-size: 22px; font-weight: 700; }
.finish-stars { font-size: 40px; letter-spacing: 4px; }
.summary-card { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 28px; max-width: 640px; margin: 20px auto; text-align: left; font-size: 20px; line-height: 1.7; border: 4px solid var(--pet); }
.summary-card h3 { margin: 4px 0; }
.finish-actions { display: flex; gap: 16px; justify-content: center; margin-top: 16px; }
.confetti { position: absolute; inset: 0; pointer-events: none; }
.confetti i { position: absolute; top: -20px; width: 12px; height: 18px; border-radius: 3px; animation: fall linear infinite; }
@keyframes fall { to { transform: translateY(110vh) rotate(720deg); } }
.star-burst { position: fixed; z-index: 60; font-size: 48px; transform: translate(-50%, 0); animation: burst 1.2s ease-out forwards; pointer-events: none; }
@keyframes burst { 0% { transform: translate(-50%, 0) scale(.4); opacity: 0; } 30% { transform: translate(-50%, -60px) scale(1.4); opacity: 1; } 100% { transform: translate(-50%, -160px) scale(1); opacity: 0; } }

.loading { display: grid; place-items: center; align-content: center; gap: 10px; font-size: 22px; }
.loading .mascot { width: 160px; }

/* 設定 */
.card { background: #fff; border-radius: var(--radius); padding: 18px 22px; box-shadow: var(--shadow); margin-bottom: 18px; }
.card h2 { margin: 0 0 12px; }
.kid-edit { display: grid; grid-template-columns: 90px 1fr 1fr; gap: 10px 16px; align-items: center; padding: 12px 0; border-top: 2px dashed var(--line); }
.kid-edit:first-of-type { border-top: 0; }
.kid-edit label { font-weight: 800; display: flex; flex-direction: column; gap: 4px; font-size: 16px; }
.kid-edit input, .kid-edit select, .sync-code { font-size: 20px; padding: 10px 12px; border-radius: 14px; border: 3px solid var(--line); background: #fffdf7; }
.pet-pick { grid-column: 1 / -1; display: flex; gap: 10px; flex-wrap: wrap; }
.pet-opt { width: 96px; border: 3px solid var(--line); background: #fff; border-radius: 18px; padding: 6px; font-weight: 800; font-size: 15px; }
.pet-opt.sel { border-color: var(--primary); background: #fff2ea; }
.pet-opt .mascot { width: 70px; margin: 0 auto; }
.ke-pet { width: 90px; grid-row: span 1; }
.hint { color: var(--ink-soft); line-height: 1.6; font-size: 17px; }
.sync-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-top: 10px; }
.sync-code { flex: 1; min-width: 240px; }
.err { color: var(--bad); font-weight: 700; }

/* 直向 iPad 與較窄畫面 */
@media (max-width: 900px) {
  .ld { grid-template-columns: 1fr; }
  .ld-left { display: flex; flex-direction: column; align-items: center; }
  .ld-right { display: flex; flex-direction: column; align-items: center; }
  .ld-prompt { width: 100%; }
  .ld-input { justify-content: center; }
}
@media (max-width: 640px) {
  .coach { grid-template-columns: 70px 1fr; }
  .coach-pet { width: 70px; }
  .coach-nav { grid-column: 1 / -1; flex-direction: row; justify-content: space-between; }
  .coach-bubble { font-size: 18px; }
  .step-title { font-size: 22px; }
  .tl-rows { grid-template-columns: repeat(2, 1fr); }
  .ld-grid { grid-template-columns: repeat(var(--cols), 48px); grid-template-rows: repeat(var(--rows), 52px); background: repeating-linear-gradient(#fff 0 51px, #eef3fb 51px 52px); }
  .ld-cell { font-size: 36px; }
  .bracket { height: 46px; }
  .eq-part b { font-size: 32px; } .eq-op { font-size: 28px; }
  .head-actions { position: static; justify-content: center; margin-top: 10px; }
  .kid-edit { grid-template-columns: 70px 1fr; }
  .map-hero { flex-direction: column; text-align: center; }
  .dots { max-width: 50%; }
}

/* ================= 小一課程 ================= */
.g1 { display: flex; flex-direction: column; align-items: center; gap: 16px; text-align: center; }
.g1-count { align-self: flex-end; font-size: 15px; font-weight: 800; color: var(--ink-soft); background: var(--bg); border-radius: 99px; padding: 4px 12px; }
.g1-show { max-width: 100%; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.g1-answer { width: 100%; display: flex; justify-content: center; }
.tip { margin: 0; font-size: 18px; color: var(--ink-soft); font-weight: 700; }
.row-center { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; align-items: center; }
.big-q { font-size: 64px; font-weight: 900; color: #2f8fd8; }
.eq-line { font-size: 36px; font-weight: 900; margin: 0; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: center; }
.house { font-size: 34px; }

/* 作答區 */
.ask { display: flex; flex-direction: column; align-items: center; gap: 10px; background: #fffaf0; border: 3px solid var(--accent); border-radius: 22px; padding: 14px 20px; max-width: 100%; }
.ask-q { font-size: 26px; font-weight: 800; line-height: 1.5; }
.ask-q b { color: var(--primary-dark); }
.ask.ok { border-color: var(--good); background: #eefaf2; }
.ask-ok { font-size: 30px; font-weight: 900; color: var(--good); }
.ask .opt .shp { display: block; }

/* 圖形規律 */
.pat-row { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.pat-item { width: 64px; height: 64px; border-radius: 16px; background: #fffaf0; border: 3px solid var(--line); display: grid; place-items: center; font-size: 30px; font-weight: 900; color: var(--primary-dark); padding: 0; }
.pat-item.q { border-style: dashed; border-color: var(--primary); }
.pat-item.slot:not(.on) { border-style: dashed; border-color: var(--primary); background: #fff; }
.pat-item.slot small { font-size: 16px; color: var(--ink-soft); }
.pat-item.slot.on { animation: popin .25s; }
@keyframes popin { from { transform: scale(.4); } to { transform: scale(1); } }

/* 數列 */
.seq { display: flex; align-items: center; flex-wrap: wrap; justify-content: center; gap: 4px; }
.seq-n { min-width: 64px; height: 64px; padding: 0 8px; border-radius: 18px; background: #eaf3ff; border: 3px solid #bcd8fb; display: grid; place-items: center; font-size: 30px; font-weight: 900; }
.seq-n.blank { background: #fff; border: 3px dashed var(--primary); color: var(--primary-dark); }
.seq-gap { border: 0; background: none; padding: 0 2px; }
.seq-gap span { display: inline-grid; place-items: center; min-width: 48px; height: 36px; border-radius: 99px; background: #fff; border: 2px dashed var(--ink-soft); font-size: 18px; font-weight: 900; color: var(--ink-soft); }
.seq-gap.up span { border: 2px solid var(--primary); color: var(--primary-dark); background: #fff2ea; }
.seq-gap.down span { border: 2px solid #5aa9ff; color: #2f8fd8; background: #eaf3ff; }

/* 數線 */
.nline-wrap { width: 100%; overflow-x: auto; padding-bottom: 6px; }
.nline { display: block; margin: 0 auto; }
.jump-count { font-size: 22px; font-weight: 800; }

/* 數字卡、百數表 */
.cards { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; }
.ncard { width: 84px; height: 84px; border-radius: 20px; border: 0; background: #fff; box-shadow: 0 4px 0 var(--line), 0 0 0 3px var(--line) inset; font-size: 34px; font-weight: 900; }
.ncard.used { opacity: .25; }
.slots-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; justify-content: center; font-size: 24px; color: var(--ink-soft); }
.nslot { width: 70px; height: 60px; border-radius: 16px; border: 3px dashed var(--line); display: grid; place-items: center; font-size: 28px; font-weight: 900; color: var(--ink); }
.chart { display: grid; grid-template-columns: repeat(10, minmax(0, 46px)); gap: 4px; max-width: 100%; }
.ch { aspect-ratio: 1; border-radius: 10px; background: #fffaf0; border: 2px solid var(--line); display: grid; place-items: center; font-size: 17px; font-weight: 800; }
.ch.hole { background: #fff; border-style: dashed; }
.ch.ask { border: 3px solid var(--primary); color: var(--primary-dark); font-size: 22px; }
.ch.path { background: #ffe8a8; }
.ch.cur { background: var(--primary); color: #fff; border-color: var(--primary-dark); transform: scale(1.1); }
.arrows { display: flex; gap: 10px; }
.arrows .btn { width: 72px; font-size: 32px; padding: 0; }
.arrow-now { font-size: 24px; font-weight: 800; }
.arrow-now b { color: var(--primary-dark); font-size: 32px; }
.arrow-q { font-size: 40px; font-weight: 900; display: flex; gap: 10px; align-items: center; }
.arrow-q span { color: var(--primary-dark); }

/* 三角形、信封 */
.tri { max-width: 100%; height: auto; }
.env { background: #fff3d6; border: 3px solid #e3b08f; border-radius: 16px; padding: 12px 18px; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.env-top { font-size: 34px; font-weight: 900; background: #fff; border-radius: 12px; padding: 2px 18px; color: var(--primary-dark); }
.env-cards { display: flex; gap: 8px; align-items: center; font-size: 24px; }
.env-cards span { width: 56px; height: 66px; background: #fff; border-radius: 10px; border: 2px solid var(--line); display: grid; place-items: center; font-size: 30px; font-weight: 900; }
.env-cards span.q { border: 3px dashed var(--primary); color: var(--primary-dark); }

/* 十位積木 */
.blocks { display: flex; gap: 20px; align-items: flex-end; justify-content: center; flex-wrap: wrap; min-height: 60px; }
.b-tens { display: flex; gap: 6px; flex-wrap: wrap; }
.rod { display: flex; flex-direction: column; gap: 1px; background: #2f8fd8; padding: 2px; border-radius: 4px; }
.rod i { width: 20px; height: 20px; background: #6cb8ff; border-radius: 2px; display: block; }
.b-ones { display: grid; grid-template-columns: repeat(5, 22px); gap: 3px; }
.cube { width: 22px; height: 22px; background: #ffc93c; border: 2px solid #e8a23a; border-radius: 3px; transition: transform .4s, opacity .4s; }
.cube.tying { transform: translateX(-30px) scale(.6); opacity: 0; }
.blocks.small .rod i { width: 12px; height: 12px; }
.blocks.small .cube { width: 14px; height: 14px; }
.blocks.small .b-ones { grid-template-columns: repeat(5, 14px); }
.plus { font-size: 30px; }
.build-goal { font-size: 28px; font-weight: 800; }
.build-goal b { color: var(--primary-dark); font-size: 40px; }
.build-area { min-height: 240px; display: grid; place-items: center; }
.build-read { font-size: 24px; font-weight: 700; }
.build-read b { color: #2f8fd8; }
.build-read b.big { font-size: 40px; color: var(--primary-dark); }

/* 直式 */
.col-layout { width: 100%; }
.col-wrap { display: flex; gap: 28px; align-items: center; justify-content: center; flex-wrap: wrap; width: 100%; }
.colcalc { background: #fffaf0; border: 3px solid var(--line); border-radius: 22px; padding: 14px 22px; }
.cc-row { display: grid; grid-template-columns: 50px 66px 66px; gap: 6px; }
.cc-row.carry { height: 34px; }
.cc { height: 72px; display: grid; place-items: center; font-size: 50px; font-weight: 900; border-radius: 12px; position: relative; transition: background .2s; }
.cc.op { font-size: 42px; }
.cc-row.carry .cc { height: 34px; font-size: 24px; color: var(--bad); }
.cc.box { border: 3px dashed var(--primary); background: #fff; }
.cc.box.filled { border-style: solid; color: var(--primary-dark); }
.cc.hl { background: #ffe8a8; }
.cc-row .cc.filled { color: #2f8fd8; }
.cc-row.carry .cc.filled { color: var(--bad); }
.cc.borrowed s { color: var(--ink-soft); text-decoration-thickness: 4px; text-decoration-color: var(--bad); }
.cc.borrowed sup { position: absolute; top: -10px; right: -6px; font-size: 24px; color: var(--bad); }
.cc-line { height: 5px; background: var(--ink); border-radius: 3px; margin: 4px 0 4px 50px; }
.cc-panel { min-width: 0; }
.cc-panel:empty { display: none; }

/* 長條（整體與部分） */
.bar-model { width: min(460px, 100%); display: flex; flex-direction: column; gap: 6px; font-size: 30px; font-weight: 900; }
.bm-whole { background: #ffe8a8; border-radius: 14px; padding: 8px; border: 3px solid #e8a23a; }
.bm-parts { display: flex; gap: 6px; }
.bm-parts span { flex: 1; border-radius: 14px; padding: 8px; }
.bm-parts .p1 { background: #eaf3ff; border: 3px solid #5aa9ff; flex: 1.4; }
.bm-parts .p2 { background: #eefaf2; border: 3px solid var(--good); }
.bar-model b.q { color: var(--primary-dark); }

/* 排隊 */
.queue-box { display: flex; align-items: center; gap: 8px; max-width: 100%; }
.q-end { writing-mode: vertical-rl; font-weight: 900; color: var(--ink-soft); background: var(--bg); border-radius: 99px; padding: 8px 4px; font-size: 16px; flex: none; }
.queue { display: flex; flex-wrap: wrap; gap: 4px; justify-content: center; padding: 6px; background: #fffaf0; border-radius: 18px; min-width: 0; }
.qp { width: var(--sz); display: flex; flex-direction: column; align-items: center; border-radius: 10px; padding: 2px 0; position: relative; cursor: pointer; transition: opacity .2s, background .2s; }
.qp-ico { width: var(--sz); height: var(--sz); display: block; }
.qp-ico svg { width: 100%; height: 100%; display: block; }
.qp.mk { background: color-mix(in srgb, var(--mk, #ff8a5b) 22%, #fff); outline: 3px solid var(--mk, #ff8a5b); }
.qp-name { font-size: 12px; font-weight: 900; color: var(--mk, var(--primary-dark)); white-space: nowrap; line-height: 1.2; }
.qp-no { font-size: 13px; font-weight: 900; min-height: 16px; line-height: 16px; color: #2f8fd8; }
.qp.counted { background: #eaf3ff; }
.qp.counted .qp-no { color: #fff; background: #2f8fd8; border-radius: 99px; padding: 0 5px; }
.qp.shade { opacity: .3; }
.qp.shade.mk { opacity: .7; }
[data-num].on { border-color: var(--primary); background: #fff2ea; }

@media (max-width: 700px) {
  .ask-q { font-size: 21px; }
  .cc-row { grid-template-columns: 40px 54px 54px; }
  .cc { height: 60px; font-size: 40px; }
  .cc-line { margin-left: 40px; }
  .chart { grid-template-columns: repeat(10, minmax(0, 1fr)); width: 100%; }
  .ch { font-size: 13px; }
}
.cc.box[data-ph]:empty::before { content: attr(data-ph); font-size: 34px; opacity: .55; }
@media (min-width: 900px) {
  .g1:not(.col-layout) { display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: 28px; row-gap: 14px; align-items: start; justify-items: center; }
  .g1:not(.col-layout) > * { grid-column: 1; max-width: 100%; }
  .g1:not(.col-layout) > .g1-answer { grid-column: 2; grid-row: 1 / span 6; align-self: center; width: auto; }
  .g1:not(.col-layout) > .g1-answer:empty { display: none; }
  .g1:not(.col-layout) > .share-result { grid-column: 1 / -1; }
  .g1:not(.col-layout) > .g1-count { justify-self: end; }
}
