/* Math Boss Academy: Sticker style (ground #FFD84D, ink #111, orange #FF7A4D, 3px outlines, hard offset shadows). */
@font-face{font-family:"MBRubik";font-weight:500;font-display:swap;src:url("/academy/fonts/Rubik-Medium.ttf") format("truetype")}
@font-face{font-family:"MBRubik";font-weight:700;font-display:swap;src:url("/academy/fonts/Rubik-Bold.ttf") format("truetype")}
:root{
  --ground:#FFD84D;--card:#FFFFFF;--ink:#111111;--muted:#4a4638;--accent:#FF7A4D;--ok:#7CF0B4;--soft:#FFF4CC;--shadow:#111111;
  --red:#FF6B5E;--blue:#5AA9FF;--green:#1FA971;--scene:#FFFDF2;--bad:#FFD0C7;
  --font-display:"MBRubik","Alef","Arial Black",system-ui,sans-serif;--font-body:"MBRubik","Alef",system-ui,sans-serif;
}
/* the Academy always uses the app's sunny-yellow Sticker look; dark only when the host explicitly sends theme=dark */
:root[data-theme="dark"]{--ground:#17150c;--card:#25220f;--ink:#F6F0D2;--muted:#c2baa0;--accent:#FF8B63;--ok:#3fc98a;--soft:#322e14;--shadow:#000;--scene:#1d1b0e;--bad:#6b362b;color-scheme:dark}
*{box-sizing:border-box;-webkit-tap-highlight-color:transparent}
html,body{margin:0;height:100%;overflow:hidden}  /* the page itself never scrolls: the scene box scrolls */
/* the lesson is a fixed screen: nothing may pan or bounce while a finger drags (iOS moves the whole page otherwise) */
html,body{position:fixed;inset:0;width:100%;overscroll-behavior:none}
.modal{touch-action:pan-y}
body{background:var(--ground);color:var(--ink);font-family:var(--font-body);font-size:17px;line-height:1.4;
  padding:max(10px,env(safe-area-inset-top,0px)) max(12px,env(safe-area-inset-right,0px)) max(10px,env(safe-area-inset-bottom,0px)) max(12px,env(safe-area-inset-left,0px));
  -webkit-user-select:none;user-select:none;touch-action:none;overscroll-behavior:none}
button{font-family:inherit;color:var(--ink)}
button:focus-visible,input:focus-visible{outline:3px solid var(--ink);outline-offset:3px}
.phone{background:var(--card);border:3px solid var(--ink);border-radius:30px;box-shadow:6px 6px 0 var(--shadow);padding:12px;display:flex;flex-direction:column;gap:10px;width:100%;max-width:520px;height:100%;min-height:0;margin:0 auto}
.bar{display:flex;align-items:center;gap:8px}
.ib{min-width:40px;height:40px;border-radius:50%;border:3px solid var(--ink);background:var(--card);font:700 15px var(--font-body);cursor:pointer;padding:0 8px}
.ib[aria-pressed="true"]{background:var(--bad)}
.prog{flex:1;display:flex;gap:4px}
.prog i{flex:1;height:10px;border-radius:5px;border:2.5px solid var(--ink);background:var(--card)}
.prog i.on{background:var(--accent)}
.title{font:700 14px var(--font-display);color:var(--muted)}
.guide{display:flex;gap:8px;align-items:flex-start;flex:none;position:relative}
.mas{width:60px;height:60px;flex:none}
.bubble{flex:1;background:var(--soft);border:3px solid var(--ink);border-radius:18px;padding:10px 13px;font-size:19px;font-weight:700;line-height:1.3;min-height:62px}
.bubble small{display:block;font-weight:500;font-size:15px;color:var(--muted);margin-top:3px}
.scenebox{position:relative;flex:1 1 0;min-height:0;border:3px solid var(--ink);border-radius:18px;background:var(--scene);overflow:hidden;overflow:clip;display:flex;flex-direction:column}
/* the scene never scrolls: lib/fit.js scales it down (transform) until it fits the box */
.scene{position:relative;flex:1 0 auto;width:100%;min-height:100%;padding:12px;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:12px;direction:ltr;transform-origin:top center;will-change:transform}
.scene.top{justify-content:flex-start}
.scene>*{flex-shrink:0}
.ctl{display:flex;flex-wrap:wrap;gap:8px;justify-content:center;min-height:12px;direction:ltr;flex:none}
.foot{display:flex;gap:8px;flex:none}
.btn{font:700 17px var(--font-body);padding:11px 16px;border-radius:14px;border:3px solid var(--ink);background:var(--card);cursor:pointer;box-shadow:3px 3px 0 var(--shadow)}
.btn:active{transform:translate(2px,2px);box-shadow:1px 1px 0 var(--shadow)}
.btn.go{background:var(--accent);color:#111;font-size:20px;flex:1;padding:13px}
.btn[disabled]{opacity:.4;box-shadow:none;cursor:not-allowed}
.num{min-width:50px;min-height:50px;height:auto;border-radius:14px;font:700 23px var(--font-display);padding:2px 8px;display:inline-flex;align-items:center;justify-content:center;line-height:1.1}
.num .mf{font-size:.8em;line-height:1.05;margin:0}
.num.right{background:var(--ok);color:#111}.num.wrong{background:var(--bad)}
.row{display:flex;gap:8px;flex-wrap:wrap;justify-content:center;align-items:center}
.grp{display:flex;gap:6px;flex-wrap:wrap;justify-content:center;padding:8px;border-radius:14px;border:3px dashed transparent;min-width:60px}
.grp.drag{border-color:var(--ink);cursor:grab;touch-action:none;background:var(--soft)}
.cnt{position:relative;width:42px;height:42px;border-radius:50%;border:3px solid var(--ink);box-shadow:2px 2px 0 var(--shadow);flex:none;transition:transform .15s,background .2s}
.cnt.red{background:var(--accent)}.cnt.blue{background:var(--blue)}.cnt.tap{cursor:pointer}
.cnt.glow{box-shadow:0 0 0 5px var(--accent)}
.cnt b{position:absolute;inset:0;display:grid;place-items:center;font:700 19px var(--font-display);color:#111}
.pop{animation:pop .3s ease-out}
@keyframes pop{0%{transform:scale(.4)}70%{transform:scale(1.2)}100%{transform:scale(1)}}
.eq{font:700 34px var(--font-display);display:flex;gap:10px;align-items:center;justify-content:center;direction:ltr}
.eq .r{color:var(--red)}.eq .b{color:var(--blue)}.eq .t{color:var(--green)}
.big{font:700 40px var(--font-display)}
.cloth{width:100%;max-width:200px;height:70px;border-radius:14px;border:3px solid var(--ink);background:var(--soft);display:grid;place-items:center;font:700 36px var(--font-display)}
.tabs{display:grid;grid-template-columns:repeat(2,1fr);gap:10px;width:100%}
.tab{display:flex;flex-direction:column;align-items:center;gap:6px;border:3px solid var(--ink);border-radius:16px;background:var(--card);padding:10px 6px;cursor:pointer;font:700 16px var(--font-body);box-shadow:3px 3px 0 var(--shadow);position:relative}
.tab svg{width:64px;height:40px}
.tab.done{background:var(--ok);color:#111}
.tab.mini{width:auto;min-width:78px;flex:1 1 78px;max-width:34%;padding:3px 5px;gap:1px;font-size:12px;line-height:1.1;text-align:center;min-height:44px}
.tab.mini svg{width:58px;height:36px}
.tab.mini .mini-t{display:block;font-weight:700}
.tab.dim{opacity:.45;box-shadow:none}
.tab .tag{position:absolute;top:-9px;inset-inline-end:8px;background:var(--accent);color:#111;border:2px solid var(--ink);border-radius:99px;font-size:12px;padding:1px 8px}
.tab[disabled]{opacity:.45;cursor:not-allowed;box-shadow:none}
.frame{display:grid;grid-template-columns:repeat(5,46px);gap:6px;padding:8px;border:3px solid var(--ink);border-radius:12px;background:var(--card)}
.cell{width:46px;height:46px;border:2.5px solid var(--ink);border-radius:8px;display:grid;place-items:center;background:var(--scene);cursor:pointer;padding:0}
.cell .cnt{width:32px;height:32px;box-shadow:none}
.line{position:relative;width:100%;height:120px}
.line .frog{position:absolute;top:18px;background:none;border:0;padding:0;cursor:pointer;transition:left .35s}
.hand{display:flex;gap:4px;align-items:flex-end;height:80px}
.fing{width:30px;border:3px solid var(--ink);border-radius:15px 15px 8px 8px;background:var(--soft);cursor:pointer;transition:height .2s,background .2s;padding:0}
.fing.up{background:var(--accent)}
.fing{position:relative}.fing::after{content:"";position:absolute;inset:-14px -4px}
.card{border:3px solid var(--ink);border-radius:16px;padding:10px 14px;background:var(--card);text-align:center;font-weight:700}
.card.wide{width:100%}
.bar2{height:14px;border:2.5px solid var(--ink);border-radius:7px;margin:6px 0}
.bar2.r{background:var(--red);width:100%}.bar2.b{background:var(--blue);width:33%}
.hint{font-size:15px;color:var(--muted)}
.lvl{font:700 13px var(--font-display);border:2px solid var(--ink);border-radius:99px;padding:2px 10px;background:var(--soft)}
.err{background:var(--bad);border:3px solid var(--ink);border-radius:14px;padding:10px;font-weight:700}
.gl{width:100%;aspect-ratio:1/1;max-height:330px;border:3px solid var(--ink);border-radius:14px;touch-action:none;display:block;background:var(--scene)}
.sliders{display:grid;gap:6px;width:100%}
.sl{display:grid;grid-template-columns:34px 1fr 44px;gap:8px;align-items:center;font:700 16px var(--font-display)}
.sl input{width:100%;accent-color:var(--accent);height:30px}
.sl output{text-align:end}
[hidden]{display:none!important}
@media (prefers-reduced-motion:reduce){.pop{animation:none}.cnt,.fing,.line .frog{transition:none}}
:root[data-reduce-motion="1"] .pop{animation:none}
:root[data-reduce-motion="1"] .cnt,:root[data-reduce-motion="1"] .fing,:root[data-reduce-motion="1"] .line .frog{transition:none}

/* maths drawn like a school book: stacked fractions and raised exponents (lib/math.js) */
.mf{display:inline-flex;flex-direction:column;align-items:center;vertical-align:middle;margin:0 .18em;line-height:1.15;font-variant-numeric:tabular-nums}
.mf>span{padding:0 .25em}
.mf>span:first-child{border-bottom:.09em solid currentColor}
sup{font-size:.62em;line-height:0;vertical-align:super}
sub{font-size:.62em;line-height:0;vertical-align:sub}
/* legend chips under a scene + the "i" modal (lib/legend.js): one compact row, at most 2 lines, never grows the page */
.legend{flex:none;display:block}
.legend[hidden]{display:none}
.chips{display:flex;flex-wrap:wrap;gap:6px;align-items:center;justify-content:center;max-height:100px;overflow:hidden}
.chip{display:inline-flex;align-items:baseline;gap:4px;border:2.5px solid var(--ink);border-radius:12px;background:var(--soft);padding:2px 8px;font-size:13px;line-height:1.3;max-width:100%;white-space:nowrap;min-height:30px;align-items:center}
.chip .mean{overflow:hidden;text-overflow:ellipsis;max-width:36vw}
.chip .sym{font:700 15px var(--font-display);white-space:nowrap}
.chip .eqs{color:var(--muted)}
.chip .gname{color:var(--muted);font-size:12px}
.chip.more{font:700 14px var(--font-display);cursor:pointer;min-width:44px;min-height:34px;justify-content:center}
.ibtn,.mclose{flex:none;width:44px;height:44px;border-radius:50%;border:3px solid var(--ink);background:var(--card);font:700 20px var(--font-display);cursor:pointer;padding:0;box-shadow:2px 2px 0 var(--shadow)}
.ibtn{font-style:italic;font-family:Georgia,serif;background:var(--accent);color:#111;box-shadow:none}
@media (max-height:640px){.bubble{font-size:16px;min-height:0;padding:6px 10px}.mas{width:44px;height:44px}.btn.go{padding:9px;font-size:18px}.phone{padding:8px;gap:6px}.num{min-width:44px;min-height:44px}}
.mback{position:fixed;inset:0;z-index:50;background:rgba(0,0,0,.5);display:flex;align-items:center;justify-content:center;padding:14px}
.modal{background:var(--card);color:var(--ink);border:3px solid var(--ink);border-radius:22px;box-shadow:6px 6px 0 var(--shadow);padding:12px 14px 16px;width:100%;max-width:480px;max-height:86dvh;overflow:auto;-webkit-user-select:text;user-select:text}
.mhead{display:flex;align-items:center;justify-content:space-between;gap:10px;position:sticky;top:0;background:var(--card);padding-bottom:6px}
.mtitle{font:700 18px var(--font-display)}
.msec{border-top:2.5px dashed var(--ink);padding-top:8px;margin-top:8px}
.msec:first-of-type{border-top:0;margin-top:0}
.mh{display:flex;gap:8px;align-items:baseline;font:700 19px var(--font-display)}
.mh .sym{font-size:22px}
.mbody{margin:6px 0;font-size:17px;font-weight:500}
.mex{margin:6px 0;padding:8px 10px;border-radius:12px;background:var(--soft);border:2.5px solid var(--ink);font-weight:700}
.mrem{margin:6px 0;color:var(--muted);font-weight:500}

/* squeeze levels (lib/fit.js sets data-lvl on .phone when scaling alone is not enough): drop the least important things first */
.phone[data-lvl="1"] .title,.phone[data-lvl="2"] .title,.phone[data-lvl="3"] .title,.phone[data-lvl="1"] .bubble small,.phone[data-lvl="2"] .bubble small,.phone[data-lvl="3"] .bubble small{display:none}
.phone[data-lvl="2"] .legend .chip,.phone[data-lvl="3"] .legend .chip{display:none}
.phone[data-lvl="3"] .bubble{font-size:15px;padding:5px 9px;min-height:0;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden}
.phone[data-lvl="3"] .mas{width:36px;height:36px}
.phone{overflow:hidden}
/* stacked fractions never blow up: sized in em, capped */
.mf{font-size:min(1em,9vmin)}
.ctl .an-bar{width:100%}

#ctl .chip{white-space:normal;text-align:center;font-size:14px;padding:4px 10px}

/* squeezed phones (lvl 3) clamp the speech bubble to 2 lines; tapping it opens the whole sentence over the scene (it never pushes the layout) */
.phone[data-lvl="3"] .bubble{cursor:pointer}
.phone[data-lvl="3"] .bubble[data-open="1"]{position:absolute;inset-inline:0;top:0;z-index:30;-webkit-line-clamp:unset;display:block;overflow:auto;max-height:70vh;box-shadow:0 4px 0 var(--shadow);padding:8px 12px;font-size:16px}

/* "which way?" cards: one row of labelled method buttons per example; on short phones the icon is dropped so three cards fit without shrinking */
.card.wide .row .tab.mini{flex:1 1 64px;min-width:64px;max-width:none;justify-content:center}
@media (max-height:700px){.card.wide .row .tab.mini svg{display:none}.card.wide .row .tab.mini{min-height:40px;padding:2px 4px;font-size:13px}.card.wide .row .big{font-size:22px!important}}

/* voice: the mute toggle is shown only when the lesson has audio (player.js sets [hidden]) */
#mute[hidden]{display:none}
#mute{font-size:18px;padding:0}
.vgate{position:absolute;inset:0;z-index:60;border:0;background:rgba(255,216,77,.94);color:var(--ink);font:800 clamp(24px,7vw,34px) var(--font-display);cursor:pointer;display:flex;align-items:center;justify-content:center;text-align:center;padding:24px}
@media (max-width:340px){.tab.mini svg{width:44px!important;height:28px!important}.tab.mini{padding:3px 2px!important}}
@media (max-width:340px){.tab.mini .mini-t{overflow-wrap:anywhere;word-break:break-word;font-size:11px}}
@media (max-width:340px){.chips{max-height:100px}}

.getapp{display:flex;align-items:center;justify-content:center;gap:6px;margin:0;font-size:14px;line-height:1.3;text-align:center}.getapp[hidden]{display:none}.getapp a{color:inherit;font-weight:700;min-height:44px;display:inline-flex;align-items:center}.getapp .ib{min-width:44px;min-height:44px}

/* site bar (browser visitors only, see lib/sitebar.js): a normal flow row above the lesson card, never fixed/sticky. The card takes the remaining height. */
.sitebar[hidden]{display:none}
html.sb body{display:flex;flex-direction:column;gap:6px}
html.sb .phone{height:auto;flex:1 1 0;min-height:0}
.sitebar{display:flex;align-items:center;gap:4px 12px;width:100%;max-width:520px;height:40px;margin:0 auto;flex:none;font:700 14px var(--font-body);line-height:1}
.sitebar a{color:var(--ink);text-decoration:none;display:inline-flex;align-items:center;min-height:36px;white-space:nowrap}
.sb-back{order:1;font-size:15px}.sb-back::before{content:"\2190";margin-inline-end:6px}
.sitebar[dir="rtl"] .sb-back::before{content:"\2192"}
.sb-hub{order:2;font-weight:500;font-size:13px;text-decoration:underline!important;opacity:.85}
.sb-home{order:3;margin-inline-start:auto;gap:6px;font-weight:900;letter-spacing:.02em}.sb-home img{border-radius:6px;border:2px solid var(--ink)}
.sb-app{order:4;border:2px solid var(--ink);border-radius:99px;padding:0 12px;min-height:30px!important;background:var(--card);font-size:13px}
.sb-app.soon{border-style:dashed;opacity:.6;font-weight:500}
.sitebar a:focus-visible{outline:3px solid var(--ink);outline-offset:2px}
@media (max-width:430px){.sb-home span{display:none}.sitebar{gap:4px 8px}}
@media (max-width:360px){.sb-hub{display:none}.sb-app{padding:0 8px}}
@media (max-height:619px){.sitebar{height:28px;font-size:12px}.sitebar a{min-height:26px}.sb-back{font-size:13px}.sb-app{min-height:24px!important;font-size:12px}.sb-home img{width:20px;height:20px}html.sb body{gap:4px}}
.wrapx{display:flex;flex-wrap:wrap;align-items:center;justify-content:center;gap:0 18px;flex:none}.wrapx[hidden]{display:none}
.moreles{margin:0;text-align:center;font-size:14px;font-weight:700}.moreles[hidden]{display:none}.moreles a{color:inherit;min-height:44px;display:inline-flex;align-items:center}


/* the explanation caption sits where the (still disabled) Next button is, so the 3D board keeps the whole top of the stage; it goes back to the stage bubble while the child works on a task */
.capbar{flex:1;display:flex;flex-direction:column;justify-content:center;gap:4px;min-height:52px;background:var(--card);border:3px solid var(--ink);border-radius:16px;box-shadow:3px 3px 0 var(--shadow);padding:8px 12px;font:700 17px/1.3 var(--font-body);color:var(--ink);overflow:visible;overflow-wrap:anywhere}
.capbar:not([hidden])~#next{display:none}
@media (min-width:700px){.capbar{font-size:21px;padding:10px 16px}}
.capchg{display:flex;align-items:center;gap:8px;font-size:.85em;font-weight:700;color:var(--ink);opacity:.85}.capchg i{flex:none;width:14px;height:14px;border-radius:50%;border:2px solid var(--ink)}
.foot .wopts{position:static;inset:auto;bottom:auto;flex:1;display:flex;flex-wrap:wrap;gap:6px;justify-content:center;align-items:center;min-height:52px}.foot .wopts.wnudges{direction:ltr}.foot .wopts:not([hidden])~#next{display:none}
.foot .wopts .wopt{height:auto;min-height:48px;padding-block:4px;min-width:0;flex:1 1 auto;max-width:100%;font:700 min(22px,5.4vw) var(--font-display);white-space:normal;overflow-wrap:anywhere;line-height:1.15}
/* a disabled Next button only takes room: it is hidden until the step is done (the caption or the answer buttons use the bar meanwhile) */
.foot #next:disabled{display:none}
@media (max-height:640px){.capbar{font-size:13px;line-height:1.15;padding:3px 8px;min-height:36px;border-width:2px;gap:1px}.capchg{font-size:.78em}.capchg i{width:10px;height:10px}.foot .wopts{min-height:40px}.foot .wopts .wopt{height:auto;min-height:42px;font-size:min(18px,5vw)}}

/* E14: on a short phone the footer (answers, caption) grows and the 3D stage keeps its real, smaller height (lib/fit.js, no scaling): the rows between them stay slim */
@media (max-height:640px){
  .phone.is-world .ctl:empty{display:none}
  .phone.is-world .wctl.inrow{padding:0}
  .phone.is-world .wctl.inrow .wbtn{height:38px;min-width:38px;font-size:18px}
  .phone.is-world .legend{min-height:0}
  .phone.is-world .legend .chip.more,.phone.is-world .legend .ib{min-width:36px;min-height:36px;width:36px;height:36px}
}
