:root {
  --ink: #3a2e2a;
  --muted: #8a7b72;
  --brand: #ff8a3d;
  --good: #2fb36d;
  --hint: #f59f00;
  --card: #fffdf8;
  --radius: 22px;
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", "Noto Sans SC", system-ui, sans-serif;
  color: var(--ink);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: #fff8ec; }
body { display: flex; flex-direction: column; min-height: 100vh; overflow-x: hidden; user-select: none; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
a { color: #e8590c; }

/* header */
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 18px; background: #fff; box-shadow: 0 2px 0 #f1e4d3; flex-wrap: wrap; z-index: 2; }
.brand { display: flex; align-items: center; gap: 12px; }
.logo { font-size: 40px; }
h1 { margin: 0; font-size: 26px; letter-spacing: 1px; color: #e8590c; }
.mission { font-size: 14px; color: var(--muted); margin-top: 2px; }
.stats { display: flex; align-items: center; gap: 10px; }
.stat { display: flex; align-items: center; gap: 6px; background: #fff4e0; border-radius: 999px; padding: 6px 14px; font-size: 16px; position: relative; }
.stat b { font-size: 18px; }
.stat.friends { padding-bottom: 12px; }
.stat .bar { position: absolute; left: 14px; right: 14px; bottom: 5px; height: 4px; background: #f3dfc0; border-radius: 4px; overflow: hidden; }
.stat .bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #69db7c, #ffd43b); transition: width .6s; }
.icon-btn { width: 46px; height: 46px; border-radius: 50%; background: #fff4e0; font-size: 22px; box-shadow: 0 3px 0 #f1d9b5; transition: transform .1s; }
.icon-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 #f1d9b5; }

/* garden */
.garden { position: relative; height: 150px; overflow: hidden; background: linear-gradient(#bfe9ff 0%, #e8f8ff 55%, #9ad97a 55.5%, #7cc95c 100%); border-bottom: 4px solid #6ab04c; }
.sun { position: absolute; right: 30px; top: 6px; font-size: 40px; animation: spin 20s linear infinite; }
.cloud { position: absolute; font-size: 44px; opacity: .9; animation: drift 40s linear infinite; }
.cloud.c1 { top: 4px; left: -60px; }
.cloud.c2 { top: 20px; left: -60px; animation-delay: -20s; font-size: 34px; }
@keyframes drift { to { transform: translateX(110vw); } }
@keyframes spin { to { transform: rotate(360deg); } }
.critter { position: absolute; left: 0; top: 0; font-size: 40px; line-height: 1; padding: 0; will-change: transform; filter: drop-shadow(0 3px 2px rgba(0,0,0,.15)); }
.flower { position: absolute; font-size: 20px; }
.garden-empty { position: absolute; left: 50%; bottom: 18px; transform: translateX(-50%); background: rgba(255,255,255,.85); padding: 8px 16px; border-radius: 999px; font-size: 15px; white-space: nowrap; max-width: 95vw; overflow: hidden; text-overflow: ellipsis; }
.bubble { position: absolute; z-index: 3; background: #fff; border-radius: 16px; padding: 8px 12px; font-size: 14px; width: 220px; box-shadow: 0 4px 12px rgba(0,0,0,.15); animation: pop .25s; }

/* home views */
.tabs { display: flex; justify-content: center; gap: 10px; padding: 12px 10px 0; }
.tab { font-size: 18px; font-weight: 700; padding: 10px 22px; border-radius: 999px; background: #fff; color: var(--muted); box-shadow: 0 3px 0 #f1d9b5; }
.tab.active { background: #ff8a3d; color: #fff; box-shadow: 0 3px 0 #d9480f; }
.view { display: none !important; }
.view.active { display: flex !important; }
.today { flex: 1; justify-content: center; align-items: flex-start; padding: 18px 14px 10px; }
.today-card { background: #fff; border-radius: 32px; box-shadow: 0 10px 30px rgba(120, 80, 30, .12); padding: 26px 28px; width: min(760px, 100%); text-align: center; }
.today-card h2 { margin: 4px 0 14px; font-size: 30px; }
.today-card p { font-size: 18px; line-height: 1.6; }
.today-card .play { max-width: 420px; margin: 18px auto 8px; }
.big-emoji { font-size: 84px; line-height: 1.1; }
.tasks { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; margin: 8px 0; }
.task { width: 150px; padding: 16px 10px; border-radius: 24px; background: #fbf5ec; border: 4px solid transparent; }
.task-icon { font-size: 52px; line-height: 1.1; }
.task-name { font-size: 18px; font-weight: 800; margin-top: 6px; }
.task-mode { font-size: 14px; color: var(--muted); margin-top: 4px; }
.task.next { border-color: #ffd43b; background: #fffbe6; animation: breathe 1.6s ease-in-out infinite; }
.task.done { background: #ebfbee; }
.task.done .task-mode { color: var(--good); font-weight: 700; }
.home-task { background: #f0fbe9; border-radius: 20px; padding: 14px 18px; margin: 16px auto 4px; max-width: 520px; text-align: left; }
.home-task b { font-size: 18px; }
.home-task p { margin: 6px 0 0; font-size: 18px; }
.link { color: var(--muted); font-size: 14px; text-decoration: underline; margin-top: 10px; display: inline-block; }
.play.resting { background: linear-gradient(#b197fc, #845ef7); box-shadow: 0 6px 0 #5f3dc4; animation: none; }
.critter.egg { font-size: 34px; }

/* children & storage */
.kid-chip { font-weight: 700; font-size: 16px; }
.icon-btn { position: relative; }
.icon-btn.dot::after { content: ''; position: absolute; top: 4px; right: 4px; width: 11px; height: 11px; border-radius: 50%; background: #fa5252; border: 2px solid #fff; }
.parent-panel h3 { margin: 18px 0 8px; font-size: 18px; }
.kids { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.kid { display: flex; align-items: center; gap: 8px; background: #f7f3ee; border-radius: 16px; padding: 8px 10px; border: 3px solid transparent; }
.kid.cur { border-color: #ffd43b; background: #fffbe6; }
.kid-avatar { font-size: 30px; }
.kid-name { font: inherit; width: 96px; padding: 4px 8px; border-radius: 10px; border: 2px solid #e6d5c0; }
.kid-tag { font-size: 13px; color: #e8590c; font-weight: 700; }
.kid-del { font-size: 18px; }
.storage-tip { background: #e7f5ff; border-radius: 14px; padding: 10px 14px; font-size: 14px; }
.storage-tip.warn { background: #fff4e6; border: 2px solid #ffa94d; }
.code-box { width: 100%; height: 80px; font-family: monospace; font-size: 12px; border-radius: 12px; border: 2px solid #e6d5c0; padding: 8px; margin-top: 8px; word-break: break-all; }

/* parent gate */
.gate { position: fixed; inset: 0; z-index: 60; background: rgba(60, 40, 20, .45); display: none; align-items: center; justify-content: center; }
.gate.show { display: flex; }
.gate-box { background: #fff; border-radius: 24px; padding: 22px 26px; width: min(340px, 90vw); text-align: center; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.gate-box h3 { margin: 0 0 6px; font-size: 22px; }
.gate-box p { color: var(--muted); line-height: 1.6; }
.gate-box p b { color: var(--ink); font-size: 26px; }
.gate-box input { font: inherit; font-size: 26px; width: 140px; text-align: center; padding: 8px; border: 3px solid #e6d5c0; border-radius: 14px; }
.gate-actions { display: flex; gap: 12px; justify-content: center; margin-top: 14px; }
.gate-actions button { padding: 10px 22px; border-radius: 12px; background: #f5ece1; font-weight: 700; }
.gate-actions .primary { background: #ff8a3d; color: #fff; }
.gate-err { color: #c92a2a !important; min-height: 1.4em; margin: 8px 0 0; }

/* level phases */
.phase-tag { font-size: 15px; font-weight: 800; color: #e8590c; background: #fff4e0; padding: 6px 12px; border-radius: 999px; align-self: center; }
.phase-tag.practice { color: #2b8a3e; background: #ebfbee; }
.transition { text-align: center; animation: pop .4s; }
.transition h2 { font-size: 30px; max-width: 640px; }
.win-sub { font-size: 20px; color: var(--muted); margin: 4px 0 10px; }
.soft { background: #e7f5ff; color: #1864ab; padding: 8px 14px; border-radius: 10px; }
.settings select { font: inherit; padding: 4px 8px; border-radius: 10px; border: 2px solid #e6d5c0; }

/* map */
.map-wrap { flex: 1; position: relative; padding: 8px; display: flex; flex-direction: column; align-items: center; }
#map { width: 100%; max-width: 1200px; height: auto; max-height: calc(100vh - 260px); min-height: 360px; border-radius: 28px; background: #f6ffe9; box-shadow: inset 0 0 0 4px #fff, 0 6px 20px rgba(120, 80, 30, .12); }
.region-label { font-size: 26px; font-weight: 800; fill: #6b5a4e; opacity: .55; letter-spacing: 3px; }
.edge { fill: none; stroke: #c9b49b; stroke-width: 7; stroke-linecap: round; stroke-dasharray: 2 14; transition: opacity .2s, stroke .2s; }
.edge.soft { stroke-width: 4; stroke-dasharray: 10 10; opacity: .6; }
.edge.done { stroke: #f4b740; }
.node { cursor: pointer; transition: opacity .2s; }
.node .disc { fill: #fff; stroke: #e6d5c0; stroke-width: 5; transition: transform .15s; }
.node .halo { fill: none; }
.node .label { font-size: 21px; font-weight: 700; fill: var(--ink); paint-order: stroke; stroke: #fffdf6; stroke-width: 6px; stroke-linejoin: round; }
.node .stars { font-size: 18px; fill: #f5b301; letter-spacing: 2px; paint-order: stroke; stroke: #fffdf6; stroke-width: 4px; }
.node.locked .disc { fill: #eee9e3; stroke: #d6cec4; }
.node.locked .label { fill: #a39589; }
.node.locked .stars { opacity: .3; }
.node.done .disc { fill: #fff7d6; stroke: #f4b740; }
.node.next .halo { stroke: #ffd43b; stroke-width: 6; fill: rgba(255, 212, 59, .25); animation: pulse 1.4s ease-in-out infinite; transform-origin: center; transform-box: fill-box; }
.node:hover .disc { stroke-width: 7; }
@keyframes pulse { 0%,100% { transform: scale(1); opacity: 1; } 50% { transform: scale(1.18); opacity: .5; } }
#map.focus .node { opacity: .35; }
#map.focus .edge { opacity: .15; }
#map.focus .node.hl, #map.focus .node.hl-pre, #map.focus .node.hl-post { opacity: 1; }
#map.focus .node.hl .disc { stroke: #ff8a3d; stroke-width: 8; }
#map.focus .node.hl-pre .disc { stroke: #4dabf7; stroke-width: 7; }
#map.focus .node.hl-post .disc { stroke: #69db7c; stroke-width: 7; }
#map.focus .edge.hl { opacity: 1; stroke: #ff8a3d; }
.legend { display: flex; gap: 18px; flex-wrap: wrap; justify-content: center; font-size: 13px; color: var(--muted); margin-top: 6px; }
.lg { display: inline-block; width: 26px; height: 0; border-top: 5px dotted #c9b49b; vertical-align: middle; margin-right: 4px; }
.lg.dashed { border-top: 3px dashed #c9b49b; }
.credit { text-align: center; font-size: 11px; color: var(--muted); padding: 6px 10px 10px; }

/* overlays */
.scrim { position: fixed; inset: 0; background: rgba(60, 40, 20, .35); opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 10; }
.scrim.show { opacity: 1; pointer-events: auto; }
.card, .parent-panel { position: fixed; z-index: 11; background: var(--card); border-radius: 28px; box-shadow: 0 20px 60px rgba(60, 40, 20, .3); padding: 22px 24px; transition: transform .25s, opacity .25s; opacity: 0; pointer-events: none; overflow: auto; }
.card { right: 20px; top: 20px; bottom: 20px; width: min(420px, calc(100vw - 40px)); transform: translateX(30px); }
.card.show, .parent-panel.show { opacity: 1; pointer-events: auto; transform: none; }
.close { position: absolute; right: 14px; top: 12px; width: 38px; height: 38px; border-radius: 50%; background: #f5ece1; font-size: 18px; }
.card-head { display: flex; align-items: center; gap: 14px; }
.card-icon { font-size: 54px; }
.card h2 { margin: 0; font-size: 28px; }
.card-stars { color: #f5b301; font-size: 22px; letter-spacing: 3px; }
.tip { font-size: 18px; background: #fff4d6; border-radius: 16px; padding: 12px 14px; line-height: 1.5; }
.play { display: block; width: 100%; font-size: 28px; font-weight: 800; color: #fff; background: linear-gradient(#5fd17d, #2fb36d); border-radius: 999px; padding: 16px; box-shadow: 0 6px 0 #22884f; margin: 8px 0 14px; animation: breathe 1.6s ease-in-out infinite; }
.play:active { transform: translateY(4px); box-shadow: 0 2px 0 #22884f; }
@keyframes breathe { 50% { transform: scale(1.03); } }
.locked-msg { font-size: 17px; color: #c2410c; }
.rel { display: grid; gap: 12px; margin: 10px 0; }
.rel b { font-size: 15px; color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.chip { background: #eef6ff; border-radius: 999px; padding: 6px 12px; font-size: 15px; border: 2px solid #cfe5ff; }
.chip.got { background: #fff7d6; border-color: #f4d67a; }
.muted { color: var(--muted); font-size: 14px; }
.friend-line { font-size: 15px; background: #f0fbe9; padding: 10px 12px; border-radius: 14px; }
details.parent { margin-top: 14px; font-size: 14px; line-height: 1.55; background: #f7f3ee; border-radius: 14px; padding: 8px 12px; }
details.parent summary { cursor: pointer; font-weight: 700; }
.en { color: #5c5048; }
ul.en { margin: 4px 0 8px; padding-left: 20px; }
.src { font-size: 11px; color: var(--muted); word-break: break-all; }

.parent-panel { left: 50%; top: 50%; width: min(980px, calc(100vw - 30px)); max-height: calc(100vh - 30px); transform: translate(-50%, -46%); }
.parent-panel.show { transform: translate(-50%, -50%); }
.parent-panel h2 { margin-top: 0; }
.parent-panel p { line-height: 1.6; }
.settings { display: flex; flex-wrap: wrap; gap: 14px 22px; align-items: center; background: #f7f3ee; padding: 12px 14px; border-radius: 14px; }
.settings input[type=text], .settings input:not([type]) { font: inherit; padding: 6px 10px; border-radius: 10px; border: 2px solid #e6d5c0; width: 120px; }
.danger { background: #ffe3e3; color: #c92a2a; padding: 8px 14px; border-radius: 10px; }
table.report { width: 100%; border-collapse: collapse; font-size: 14px; margin-top: 10px; }
.report th, .report td { text-align: left; padding: 8px; border-bottom: 1px solid #efe4d6; vertical-align: top; }
.report td:nth-child(3) { color: #f5b301; white-space: nowrap; }

/* level */
.level { position: fixed; inset: 0; z-index: 20; background: radial-gradient(circle at 50% 0%, #fffbe6, #ffeccc); display: flex; flex-direction: column; transform: translateY(100%); transition: transform .3s cubic-bezier(.2,.8,.3,1); }
.level.show { transform: none; }
.lv-top { display: flex; align-items: center; gap: 14px; padding: 12px 16px; }
.lv-title { font-size: 24px; font-weight: 800; }
.lv-progress { flex: 1; display: flex; gap: 8px; justify-content: center; }
.pip { width: 34px; height: 34px; border-radius: 50%; background: #fff; border: 3px solid #f1d9b5; display: grid; place-items: center; font-size: 20px; }
.pip.cur { border-color: var(--brand); transform: scale(1.12); }
.pip.on { background: #fff4c2; border-color: #f4b740; }
.prompt { text-align: center; font-size: clamp(22px, 3.4vw, 34px); font-weight: 800; padding: 4px 20px 6px; min-height: 48px; }
.stage { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 22px; padding: 10px 16px; overflow: auto; }
.feedback { text-align: center; font-size: 22px; font-weight: 700; min-height: 60px; padding: 8px 16px 18px; }
.feedback.good { color: var(--good); animation: pop .3s; }
.feedback.hint { color: var(--hint); animation: pop .3s; }

.choices { display: flex; gap: 18px; flex-wrap: wrap; justify-content: center; }
.choice { min-width: 110px; min-height: 100px; padding: 10px 16px; background: #fff; border-radius: var(--radius); box-shadow: 0 6px 0 #ead7bd; border: 4px solid transparent; display: grid; place-items: center; transition: transform .1s; }
.choice:active { transform: translateY(4px); box-shadow: 0 2px 0 #ead7bd; }
.choice.yes { border-color: var(--good); background: #e9fbef; animation: pop .3s; }
.choice.nope { opacity: .45; animation: shake .35s; }
.choice .num { font-size: 52px; font-weight: 900; color: #4263eb; }
.choice.eq { font-size: 26px; font-weight: 800; min-height: 70px; }
.choices.eqs .choice { min-width: 220px; }
.eqtxt { font-size: 36px; font-weight: 800; letter-spacing: 2px; }

.scatter { position: relative; width: min(760px, 92vw); height: min(320px, 42vh); background: #fff; border-radius: 28px; box-shadow: inset 0 0 0 4px #f6e7d2; }
.scatter .thing { position: absolute; transform: translate(-50%, -50%); font-size: clamp(36px, 6vw, 56px); line-height: 1; }
.scatter.big .thing { cursor: pointer; font-size: clamp(44px, 7vw, 66px); transition: transform .15s; }
.thing.counted { filter: saturate(.6); transform: translate(-50%, -50%) scale(.9); }
.badge { position: absolute; right: -10px; top: -10px; background: #ff6b6b; color: #fff; font-size: 20px; width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; font-style: normal; box-shadow: 0 2px 0 #c92a2a; animation: pop .25s; }
.row-things { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; max-width: 760px; }
.row-things.big .thing-inline { font-size: clamp(40px, 6vw, 58px); }
.thing-inline { font-size: 36px; line-height: 1.1; display: inline-block; }
.thing-inline.crossed { position: relative; opacity: .4; }
.thing-inline.crossed::after { content: '✕'; position: absolute; inset: 0; color: #e03131; font-size: 1.1em; display: grid; place-items: center; font-weight: 900; }

.compare-rows { display: flex; flex-direction: column; gap: 14px; }
.row-pick { display: flex; gap: 6px; background: #fff; padding: 10px 14px; border-radius: 22px; box-shadow: 0 6px 0 #ead7bd; border: 4px solid transparent; }
.row-pick .slot { width: clamp(42px, 6vw, 62px); height: clamp(42px, 6vw, 62px); display: grid; place-items: center; font-size: clamp(32px, 5vw, 48px); border-radius: 14px; background: #fbf5ec; }
.row-pick.yes { border-color: var(--good); }
.row-pick.nope { animation: shake .35s; }

.big-numeral { font-size: 120px; font-weight: 900; color: #4263eb; line-height: 1; text-shadow: 0 6px 0 #dbe4ff; }
.frames { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; justify-content: center; }
.tenframe { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; background: #8d6e63; padding: 5px; border-radius: 10px; }
.tenframe .cell { width: 56px; height: 56px; background: #fff; border-radius: 6px; display: grid; place-items: center; }
.tenframe .cell.empty { cursor: pointer; background: #fffbea; box-shadow: inset 0 0 0 3px #ffe066; }
.tenframe.small .cell { width: 22px; height: 22px; }
.tenframe.small .dot { width: 16px; height: 16px; }
.choice .frames { flex-direction: column; gap: 6px; }
.dot { display: block; width: 40px; height: 40px; border-radius: 50%; }
.dot.red { background: radial-gradient(circle at 35% 35%, #ff8787, #e03131); }
.dot.gold { background: radial-gradient(circle at 35% 35%, #ffe066, #f59f00); }
.loose { display: flex; flex-wrap: wrap; gap: 8px; max-width: 260px; align-items: center; }
.qbox { display: inline-grid; place-items: center; width: 64px; height: 64px; border: 4px dashed #f59f00; border-radius: 16px; font-size: 38px; font-weight: 900; color: #f59f00; background: #fff; }
.qbox.filled { border-style: solid; border-color: var(--good); animation: pop .3s; }
.equation { font-size: 48px; font-weight: 900; letter-spacing: 3px; color: #4263eb; }
.equation b { color: #f59f00; }
.hint-line { color: var(--muted); font-size: 17px; }

.skip-row { display: flex; gap: 14px; flex-wrap: wrap; justify-content: center; }
.skip-g { background: #fff; border-radius: 18px; padding: 10px 12px; text-align: center; box-shadow: 0 4px 0 #ead7bd; }
.skip-g .vis { font-size: 40px; }
.skip-g .lbl { font-size: 30px; font-weight: 900; color: #4263eb; }
.skip-g:last-child .lbl { color: #f59f00; }

.pattern { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; align-items: center; background: #fff; padding: 14px 18px; border-radius: 24px; }
.pattern span { font-size: 54px; }
.choice .emoji { font-size: 56px; line-height: 1; }

.baskets { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; justify-content: center; }
.basket { background: #fff; border: 5px solid #d9a066; border-radius: 26px 26px 40px 40px; padding: 16px; min-width: 170px; max-width: 360px; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.basket.wide { max-width: 700px; }
.basket.new { border-color: #69db7c; }
.basket .cap { font-size: 30px; font-weight: 900; color: #4263eb; }
.basket .row-things, .basket.wide { flex-direction: row; flex-wrap: wrap; justify-content: center; }
.plus { font-size: 56px; font-weight: 900; color: #f59f00; }
.merged .basket { animation: pop .4s; }
.action { font-size: 28px; font-weight: 800; color: #fff; background: linear-gradient(#ffa94d, #ff8a3d); padding: 14px 34px; border-radius: 999px; box-shadow: 0 6px 0 #d9480f; }
.action:active { transform: translateY(4px); box-shadow: 0 2px 0 #d9480f; }

.branch { display: flex; gap: 8px; padding: 30px 26px 16px; border-bottom: 14px solid #8d6e63; border-radius: 0 0 20px 20px; flex-wrap: wrap; justify-content: center; max-width: 760px; }
.bird { font-size: clamp(46px, 7vw, 64px); cursor: pointer; transition: transform .9s ease-in, opacity .9s; display: inline-block; }
.bird.gone { transform: translate(120px, -260px) rotate(-20deg) scale(.6); opacity: 0; pointer-events: none; }

.partwhole { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.partwhole .whole, .partwhole .part { width: 84px; height: 84px; border-radius: 50%; background: #fff; border: 5px solid #74c0fc; display: grid; place-items: center; font-size: 40px; font-weight: 900; color: #4263eb; }
.partwhole .parts { display: flex; gap: 70px; }
.partwhole .part.q { border-style: dashed; border-color: #f59f00; color: #f59f00; }
.hands { display: flex; gap: 30px; }
.hand { background: #fff; border-radius: 22px; padding: 12px 18px; font-size: 34px; text-align: center; min-width: 170px; max-width: 280px; word-break: break-all; }
.hand div { font-size: 16px; color: var(--muted); }
.hand.hidden { font-size: 56px; }

.pile { min-height: 60px; display: flex; flex-wrap: wrap; gap: 4px; justify-content: center; max-width: 560px; font-size: 40px; background: #fff; padding: 10px 16px; border-radius: 22px; }
.plates { display: flex; gap: 18px; flex-wrap: wrap; justify-content: center; }
.plate { width: 210px; min-height: 190px; background: radial-gradient(circle, #fff 60%, #f1e7da 61%, #fff 70%); border-radius: 50%; border: 4px solid #e6d5c0; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 14px; cursor: pointer; position: relative; }
.plate .face { font-size: 46px; position: absolute; top: -26px; }
.plate .on { display: flex; flex-wrap: wrap; justify-content: center; font-size: 30px; max-width: 150px; margin-top: 16px; }
.plate .cnt { position: absolute; bottom: 4px; font-size: 22px; font-weight: 900; color: #4263eb; }

.target-shape { display: flex; align-items: center; gap: 10px; font-size: 22px; font-weight: 800; background: #fff; padding: 6px 18px; border-radius: 999px; }
.target-shape svg g { fill: #fff3bf; }
.shape-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.shape-btn { width: clamp(84px, 13vw, 120px); height: clamp(84px, 13vw, 120px); background: #fff; border-radius: 22px; display: grid; place-items: center; border: 4px solid transparent; box-shadow: 0 5px 0 #ead7bd; }
.shape-btn.yes { border-color: var(--good); background: #e9fbef; }

.pencils { display: flex; flex-direction: column; gap: 18px; width: min(720px, 90vw); }
.pencil { display: flex; align-items: center; background: #fff; border-radius: 18px; padding: 12px; border: 4px solid transparent; box-shadow: 0 5px 0 #ead7bd; }
.pencil .body { height: 34px; border-radius: 8px 0 0 8px; box-shadow: inset 0 -6px 0 rgba(0,0,0,.12); }
.pencil .tip { width: 0; height: 0; border-top: 17px solid transparent; border-bottom: 17px solid transparent; border-left: 30px solid #f2c48d; }
.towers { display: flex; align-items: flex-end; gap: 28px; padding: 10px; border-bottom: 8px solid #8d6e63; }
.tower { display: flex; flex-direction: column-reverse; gap: 3px; padding: 8px; border-radius: 14px; border: 4px solid transparent; }
.tower i { display: block; width: 66px; height: 30px; border-radius: 6px; box-shadow: inset 0 -5px 0 rgba(0,0,0,.15); }
.pencil.yes, .tower.yes { border-color: var(--good); background: #e9fbef; }
.pencil.nope, .tower.nope { animation: shake .35s; }

.sort-item { font-size: 96px; min-height: 120px; display: grid; place-items: center; }
.sort-q { font-size: 30px; font-weight: 800; }
.bins { display: flex; gap: 22px; flex-wrap: wrap; justify-content: center; }
.bin { width: min(320px, 42vw); min-height: 170px; background: #fff; border-radius: 26px; border: 4px dashed #d0bfa8; padding: 12px; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.bin .lbl { font-size: 24px; font-weight: 800; }
.bin .in { display: flex; flex-wrap: wrap; gap: 4px; justify-content: center; font-size: 36px; }
.bin .cnt { font-size: 34px; font-weight: 900; color: #4263eb; }
.bin.yes { border-style: solid; border-color: var(--good); background: #e9fbef; }

.pos-grid { display: grid; grid-template-columns: repeat(3, 58px); grid-template-rows: repeat(3, 58px); background: #f6fbff; border-radius: 14px; }
.pos-grid span { display: grid; place-items: center; font-size: 44px; }
.pos-grid .obj { font-size: 50px; }

.win { text-align: center; animation: pop .4s; }
.win-friend { font-size: 140px; animation: bounce 1s ease-in-out infinite; }
.win-stars { font-size: 56px; color: #f5b301; letter-spacing: 8px; }
.win h2 { font-size: 32px; margin: 8px 0; }
.unlocked { font-size: 20px; color: #2b8a3e; background: #ebfbee; padding: 10px 16px; border-radius: 16px; display: inline-block; }
.win-actions { display: flex; gap: 16px; justify-content: center; margin-top: 18px; flex-wrap: wrap; }
.win-actions .home { background: linear-gradient(#74c0fc, #339af0); box-shadow: 0 6px 0 #1864ab; }

.stage.celebrate .scatter, .stage.celebrate .branch, .stage.celebrate .tenframe { animation: pop .35s; }
.pop { animation: pop .3s; }
.new { animation: pop .5s; filter: drop-shadow(0 0 8px gold); }
.fly-away { transition: transform 1s, opacity 1s; transform: translate(80px, -120px); opacity: 0; }
.shake { animation: shake .35s; }
@keyframes pop { 0% { transform: scale(.6); opacity: 0; } 70% { transform: scale(1.08); } 100% { transform: scale(1); opacity: 1; } }
@keyframes shake { 20%, 60% { translate: -8px 0; } 40%, 80% { translate: 8px 0; } }
@keyframes bounce { 50% { transform: translateY(-18px); } }
.confetti { position: fixed; top: -40px; z-index: 50; pointer-events: none; animation: fall 2s ease-in forwards; }
@keyframes fall { to { transform: translateY(110vh) rotate(540deg); } }

@media (max-width: 720px) {
  h1 { font-size: 20px; }
  .mission { display: none; }
  .tenframe .cell { width: 40px; height: 40px; }
  .dot { width: 30px; height: 30px; }
  .shape-grid { grid-template-columns: repeat(3, 1fr); }
  .plate { width: 150px; min-height: 150px; }
  .equation { font-size: 36px; }
}

/* Keep navigation and controls usable on small phones. */
body { height: auto; }
body > .kids-nav, .top, .garden, .tabs { flex-shrink: 0; }
.stats { flex-wrap: wrap; max-width: 100%; }
.stat { white-space: nowrap; flex-shrink: 0; }
.icon-btn { flex-shrink: 0; }
.card:not(.show), .parent-panel:not(.show), .level:not(.show) { visibility: hidden; }
@media (max-width: 480px) {
  .top { padding: 10px 14px; }
  .stats { width: 100%; gap: 7px; }
  .stat { padding: 6px 10px; font-size: 14px; }
  .stat b { font-size: 16px; }
  .icon-btn { width: 44px; height: 44px; }
  .lv-top { gap: 7px; padding: 10px; }
  .lv-title { min-width: 0; font-size: 17px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
