html:has(body[data-screen=child]) {scrollbar-gutter:stable}
body[data-screen=child] {
  --lesson-wash:#f4effb;
  --lesson-paper:#fffdfa;
  --lesson-line:#efebf2;
  --lesson-highlight:#eee5fa;
  --lesson-mark:#6644a4;
  --lesson-rewrite:#553586;
  --lesson-font:Nunito,ui-rounded,"Arial Rounded MT Bold","Trebuchet MS",system-ui,sans-serif;
  --teacher-wash:#f2eaff;
  --teacher-border:#d8c5f0;
  --choice-wash:#ffead5;
  background:radial-gradient(ellipse at 50% 10%,var(--lesson-wash),var(--canvas) 62%);
  min-height:100dvh;
}
body[data-screen=child][data-theme=mint] {
  --lesson-wash:#e7f4e9;
  --lesson-highlight:#e2f0e6;
  --lesson-mark:#346b58;
  --lesson-rewrite:#255847;
  --lesson-line:#e5eee7;
  --teacher-wash:#e9f5ed;
  --teacher-border:#bddbc9;
}
body[data-screen=child][data-theme=peach] {
  --lesson-wash:#faeddf;
  --lesson-highlight:#f8e8df;
  --lesson-mark:#935744;
  --lesson-rewrite:#784333;
  --lesson-line:#f4e8e0;
  --teacher-wash:#f9eae1;
  --teacher-border:#e9cbbb;
}
body[data-screen=child][data-contrast=true] {
  --lesson-paper:#fff;
  --lesson-highlight:#ebdfff;
  --lesson-line:#dbd4e3;
  --lesson-mark:#40206f;
  --lesson-rewrite:#321453;
  --teacher-wash:#fff;
  --teacher-border:var(--border);
  --choice-wash:var(--soft);
}
body[data-screen=child] .rail,
body[data-screen=child] .top-nav,
body[data-screen=child] .brand small {display:none}
body[data-screen=child] .topbar {background:transparent;border:0}
body[data-screen=child] .top-inner {min-height:61px;justify-content:center}
body[data-screen=child] .brand {font:800 1.21rem/1.2 var(--lesson-font);cursor:default;pointer-events:none;opacity:1}
body[data-screen=child] .brand-mark {width:34px;height:34px;font-size:1.3rem;border-radius:10px}
body[data-screen=child] .layout {display:block;width:min(100%,1120px);padding:1rem clamp(1rem,3vw,2rem) 1.5rem}
.child-lesson {
  display:grid;
  grid-template-columns:minmax(0,1.2fr) minmax(0,1fr);
  grid-template-areas:"paper teacher";
  gap:clamp(1rem,3vw,2.6rem);
  align-items:start;
  text-align:center;
}
.child-teacher {
  grid-area:teacher;
  min-width:0;
  padding:clamp(1rem,3vw,1.7rem);
  border:2px solid var(--teacher-border);
  border-radius:24px;
  background:var(--teacher-wash);
  box-shadow:0 3px 0 var(--teacher-border);
  font-family:var(--lesson-font);
}
.child-prompt {display:grid;justify-items:center;gap:.48rem;margin:0 auto;text-align:center}
.child-prompt > * {animation:show-instruction 190ms ease-out both}
@keyframes show-instruction {from{opacity:.35;transform:translateY(3px)}to{opacity:1;transform:none}}
.child-prompt h1 {
  font:800 clamp(1.75rem,1.45rem + 1.5vw,2.45rem)/1.12 var(--lesson-font);
  letter-spacing:-.025em;
  color:var(--ink);
  max-width:23ch;
  text-wrap:balance;
}
.child-prompt h1:focus:not(:focus-visible){outline:none}
.child-prompt p {color:var(--ink);font-size:clamp(1.1875rem,1.04rem + .65vw,1.375rem);font-weight:600;line-height:1.32;max-width:32ch;text-wrap:balance}
.child-prompt .child-question {font-size:clamp(1.5rem,1.25rem + 1.35vw,1.875rem);font-weight:730;line-height:1.2}
.child-compare .place-word {text-transform:uppercase}
.child-prompt .child-question .place-word {white-space:nowrap}
.child-paper {
  grid-area:paper;
  width:100%;
  margin:0;
  padding:clamp(.65rem,2vh,1.25rem) clamp(.42rem,3vw,1.35rem);
  border:1px solid var(--border);
  border-radius:24px;
  box-shadow:0 5px 16px #30254812;
  background:repeating-linear-gradient(to bottom,var(--lesson-paper) 0 24px,var(--lesson-line) 24px 25px);
}
.child-columns {
  --label-h:25px;
  --rewrite-h:clamp(36px,4.5vh,42px);
  --upper-rewrite-h:var(--rewrite-h);
  --digit-h:clamp(53px,8.3vh,72px);
  --answer-h:clamp(56px,7.7vh,68px);
  position:relative;
  display:grid;
  grid-template-columns:clamp(23px,7.8vw,44px) repeat(3,minmax(0,108px));
  justify-content:center;
  width:min(100%,368px);
  margin:auto;
}
.child-column {
  display:grid;
  grid-template-rows:var(--label-h) var(--upper-rewrite-h) var(--rewrite-h) repeat(2,var(--digit-h)) 5px var(--answer-h);
  justify-items:center;
  align-items:center;
  border-radius:15px;
  position:relative;
  isolation:isolate;
}
.child-column.child-active:before,.child-column.child-changed:before{
  content:"";
  position:absolute;
  inset:0 3px;
  border-radius:15px;
  background:var(--lesson-highlight);
  z-index:-1;
}
.child-column.child-changed:before{opacity:.58}
.child-column.child-active:before{border:1.5px solid var(--lesson-mark)}
.child-column.child-blocked:before{content:"";position:absolute;inset:1px 3px;border:1px dashed var(--lesson-mark);border-radius:15px;pointer-events:none}
.child-new-value{border-radius:8px;background:var(--lesson-highlight);padding:.04em .2em .08em;font-weight:760}
.child-place {
  font-size:clamp(.7rem,2.23vw,1.03rem);
  font-weight:700;
  color:var(--muted);
  white-space:nowrap;
  letter-spacing:0;
}
.child-active .child-place {color:var(--lesson-rewrite)}
.child-digit,.child-answer {
  font:650 clamp(3rem,9vh,4.75rem)/.94 system-ui,sans-serif;
  font-variant-numeric:lining-nums tabular-nums;
  letter-spacing:-.08em;
  position:relative;
  padding-right:.08em;
}
.child-digit {display:grid;place-items:center;min-width:1ch;color:var(--ink)}
.child-rewrite {font-size:clamp(1.85rem,4.8vh,2.6rem);color:var(--lesson-rewrite)}
.child-stroke:after {
  position:absolute;
  content:"";
  inset:49% 0 auto 0;
  height:3px;
  background:var(--lesson-mark);
  border-radius:50% 43% 45% 50%;
  transform:rotate(-15deg);
  transform-origin:left center;
}
.child-rule {
  position:absolute;
  z-index:1;
  top:calc(var(--label-h) + var(--upper-rewrite-h) + var(--rewrite-h) + 2 * var(--digit-h));
  height:3px;
  background:var(--ink);
  left:3px;
  right:3px;
  border-radius:4px;
}
.child-minus {grid-row:5;font:600 clamp(2.25rem,7vh,3.5rem)/1 system-ui;color:var(--ink)}
.child-borrow {
  border:2px solid var(--accent);
  border-radius:13px;
  background:var(--lesson-paper);
  min-width:66%;
  min-height:calc(var(--digit-h) - 4px);
  outline-offset:2px;
}
.child-borrow.child-rewrite {min-height:44px}
.child-borrow:hover,.child-borrow:focus-visible {background:var(--lesson-highlight)}
.child-answer {
  min-width:0;
  width:72%;
  height:max(44px,calc(var(--answer-h) - 9px));
  text-align:center;
  border-radius:12px;
  border:2px solid var(--accent);
  background:var(--lesson-paper);
  color:var(--lesson-rewrite);
}
.child-answer::selection{background:var(--lesson-highlight)}
.child-empty {
  width:48%;
  height:52%;
  max-width:45px;
  border-bottom:2px dashed #9c8eaa;
  opacity:.52;
}
.child-actions {display:flex;justify-content:center;flex-wrap:wrap;gap:.7rem;margin-top:.9rem}
.child-primary {
  min-width:min(100%,128px);
  min-height:54px;
  border-radius:16px;
  padding:.52rem .8rem;
  background:var(--accent);
  color:white;
  font-weight:740;
  font-size:clamp(1.25rem,1.15rem + .52vw,1.5rem);
}
.child-primary:hover {background:var(--strong)}
.child-actions:has([data-child=yes]) {display:grid;grid-template-columns:repeat(2,minmax(0,1fr))}
.child-actions:has([data-child=yes]) button {min-width:0}
.child-primary[data-child=not-yet] {background:var(--choice-wash);color:var(--ink);box-shadow:inset 0 0 0 1px var(--teacher-border)}
.child-primary[data-child=not-yet]:hover {background:var(--lesson-paper)}
.child-support {margin-top:.55rem;display:flex;flex-wrap:wrap;justify-content:center;gap:0 .38rem}
.child-trade-notes{display:grid;gap:.34rem;margin-top:.28rem;padding:.55rem .8rem;border-radius:12px;background:var(--lesson-paper);color:var(--ink);font-size:1.1875rem;line-height:1.3}
.trade-donor-note{animation:show-instruction var(--speed) ease-out calc(var(--speed) * .48) both}
.trade-receiver-note{animation:show-instruction var(--speed) ease-out calc(var(--speed) * 1.35) both}
.child-help {
  min-height:44px;
  padding:.35rem .55rem;
  border-radius:10px;
  font-size:1.04rem;
  font-weight:650;
  color:var(--strong);
  text-decoration:underline;
  text-underline-offset:.19em;
}
.child-help:hover{background:var(--lesson-highlight)}
.voice-notice{flex-basis:100%;margin:.35rem 0;color:var(--muted);font-size:1rem}
.child-footer {text-align:center;margin:.22rem auto 0}
.child-footer button {border-radius:8px;min-height:44px;padding:.42rem .8rem;color:var(--muted);font-size:.78rem}
.child-footer button:hover {background:var(--lesson-highlight);color:var(--ink)}
.child-check {margin:.62rem auto 0;color:var(--strong);font-size:clamp(1.15rem,3.5vw,1.45rem);font-weight:750}
.child-count {display:grid;grid-template-columns:auto 1fr;align-items:center;text-align:left;gap:.25rem .65rem;font-weight:650;color:var(--muted)}
.child-dots {display:flex;align-items:center;flex-wrap:wrap;gap:5px;min-height:13px}
.child-dots i,.child-packet i {width:12px;height:12px;border-radius:50%;background:var(--accent);border:1px solid var(--accent);position:relative}
.child-dots.needed i {background:var(--lesson-paper)}
.child-dots i.taken {background:var(--lesson-paper)}
.child-dots i.taken:after {content:"";position:absolute;top:45%;left:-2px;width:14px;height:1.5px;background:var(--accent);transform:rotate(-45deg)}
.child-dots.count-back {max-width:260px;justify-content:center}
.child-bundle{display:flex;justify-content:center;align-items:center;gap:.5rem;flex-wrap:wrap}
.child-packet{display:grid;grid-template-columns:repeat(5,8px);gap:2px;padding:.24rem;border:1.5px solid var(--accent);border-radius:6px}
.child-packet i{width:8px;height:8px;border-radius:2px}
.child-packet.opened{grid-template-columns:repeat(10,8px);border-color:transparent;gap:4px}
.child-bundle-label {color:var(--muted);font-size:.85rem}
.child-stroke.cross-donor:after {animation:draw-strike var(--speed) ease-out both}
.child-stroke.cross-receiver:after {animation:draw-strike var(--speed) ease-out calc(var(--speed) * .85) both}
.child-rewrite.write-donor {animation:write-rewrite var(--speed) ease-out calc(var(--speed) * .48) both}
.child-rewrite.write-receiver {animation:write-rewrite var(--speed) ease-out calc(var(--speed) * 1.35) both}
@keyframes draw-strike {from{transform:rotate(-15deg) scaleX(0)}to{transform:rotate(-15deg) scaleX(1)}}
@keyframes write-rewrite {from{opacity:0;clip-path:inset(0 100% 0 0)}to{opacity:1;clip-path:inset(0)}}
body[data-screen=child][data-reading=true] {--lesson-font:Verdana,system-ui,sans-serif}
body[data-screen=child][data-reading=true] .child-prompt h1,
body[data-screen=child][data-reading=true] .child-digit,
body[data-screen=child][data-reading=true] .child-answer {font-family:Verdana,system-ui,sans-serif;letter-spacing:0}
@media (max-width:820px){
  body[data-screen=child] .layout{width:min(100%,560px);padding:0 .7rem 1.25rem}
  body[data-screen=child] .top-inner{min-height:53px}
  body[data-screen=child] .brand {font-size:1.1rem}
  body[data-screen=child] .brand-mark {width:29px;height:29px;border-radius:9px}
  .child-lesson{grid-template-columns:minmax(0,1fr);grid-template-areas:"paper" "teacher";gap:.65rem}
  .child-teacher{padding:.95rem clamp(.7rem,3.5vw,1.2rem) .55rem;border-radius:21px}
  .child-actions{margin-top:.75rem;gap:.6rem}
  .child-paper{padding-block:.45rem;border-radius:19px}
  .child-columns{--label-h:22px;--upper-rewrite-h:35px;--rewrite-h:44px;--digit-h:clamp(47px,12.6vw,58px);--answer-h:48px}
  .child-place{font-size:clamp(.79rem,2.65vw,.95rem)}
  .child-answer{font-size:clamp(2.35rem,10.8vw,3rem)}
  .child-digit:not(.child-rewrite){font-size:clamp(2.75rem,13vw,3.65rem)}
  .child-rewrite{font-size:clamp(1.85rem,7vw,2.15rem)}
  .child-help{font-size:1rem}
}
@media print{.child-lesson,.child-footer{display:none!important}}
