/* LC12 - Penguin: Ten and Some More. Layout for tablet landscape and portrait, phone and laptop.
 * Ice Bay Deluxe pass (18.10.2026): sculpted glacier-blue rims with milky snow insets,
 * soft blue contact shadows and strong navy Fredoka numerals. Both nine-slice tokens
 * use assets/ui/ice-surface.webp, cropped to its alpha bounds and sliced at 10%.
 * Layout, 56px controls, 44px fish wells, live en-US labels and all game wiring unchanged. */
@font-face{font-family:"Fredoka";font-style:normal;font-weight:400;font-display:swap;src:url("assets/fonts/fredoka-400.woff2") format("woff2")}
@font-face{font-family:"Fredoka";font-style:normal;font-weight:600;font-display:swap;src:url("assets/fonts/fredoka-600.woff2") format("woff2")}

:root{
  --wm-navy:#174A7E;
  --wm-navy-deep:#0f3358;
  --wm-paper:#fbfffd;
  --wm-ink:#174A7E;
  --wm-ink-soft:#3d6686;
  --wm-ok:#3fae2a;
  --wm-ok-dark:#1f7a12;
  --bar-h:96px;
  /* Legacy token names stay because the existing geometry consumes them. */
  --wm-frame-art:url("assets/ui/ice-surface.webp");
  --wm-tray-art:url("assets/ui/ice-surface.webp");
  --wm-contact:0 10px 20px #174a7e24;
  --wm-contact-soft:0 5px 10px #174a7e1f;
  --wm-character-light:drop-shadow(-2px -2px 1px #fff1c8a8) drop-shadow(2px 2px 1px #7cc8eb8c) drop-shadow(0 7px 5px #0f33585c);
}
*{box-sizing:border-box}
html,body{height:100%}
body{
  margin:0;padding:0;overflow:hidden;
  font-family:"Fredoka",system-ui,-apple-system,"Segoe UI",sans-serif;
  color:var(--wm-navy);background:#0f3358;
  -webkit-tap-highlight-color:transparent;
  -webkit-user-select:none;user-select:none;
}
button{font-family:inherit;color:inherit}
img{-webkit-user-drag:none;user-drag:none}
.sr-only{position:absolute!important;width:1px;height:1px;margin:-1px;padding:0;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap;border:0}

.app{
  --leaf:62px;--gap:8px;--ok:96px;
  --bar-h:calc(var(--ok) + 34px);
  --eq-h:64px;--top-chrome:124px;--speech-max:300px;
  position:fixed;inset:0;display:flex;flex-direction:column;
  overflow:hidden;background:#0f3358;
}

/* ---------------- HUD: one cohesive ice-shelf progress strip ----------------
 * The frame is painted by a pseudo-element that does not take part in layout, so the
 * five level props, the four task stars and the Levels button keep their exact boxes. */
.hud{
  position:fixed;z-index:205;top:max(12px,env(safe-area-inset-top));right:max(12px,env(safe-area-inset-right));
  display:flex;align-items:center;flex-wrap:wrap;justify-content:flex-end;gap:7px;max-width:calc(100vw - 24px);
  padding:0;
}
.hud::before{
  content:"";position:absolute;inset:-6px;z-index:-1;border-radius:20px;
  border-style:solid;border-color:transparent;border-width:14px;
  border-image-source:var(--wm-tray-art);border-image-slice:10% fill;border-image-width:1.6;border-image-outset:0;border-image-repeat:stretch;
  background:none;background-clip:padding-box;
  box-shadow:var(--wm-contact);
}
.hud[hidden]{display:none}
.hud-level,.hud-levels{
  display:inline-flex;align-items:center;justify-content:center;
  min-height:44px;border-radius:14px;border:0;
  font-size:clamp(15px,1.7vh,19px);font-weight:600;letter-spacing:.2px;
}
.hud-level{padding:0 12px;background:none;color:var(--wm-navy)}
.hud-levels{
  min-height:48px;padding:0 6px;cursor:pointer;touch-action:manipulation;color:var(--wm-navy);
  border-style:solid;border-color:transparent;border-width:8px;
  border-image-source:var(--wm-frame-art);border-image-slice:10% fill;border-image-width:1.6;border-image-outset:0;border-image-repeat:stretch;
  background:var(--wm-paper);background-clip:padding-box;
  box-shadow:inset 0 2px 3px #174a7e24;
}
.hud-levels:active{transform:translateY(2px)}
.hud-levels:focus-visible{outline:3px solid #fff;outline-offset:3px}
.hud-stars,.hud-props{
  display:inline-flex;align-items:center;gap:4px;padding:4px 8px;border-radius:14px;
  background:#f8fdfe;
  box-shadow:inset 0 2px 3px #174a7e1a;
}
.hud-stars img{display:block;width:clamp(20px,2.6vh,28px);height:clamp(20px,2.6vh,28px);object-fit:contain}
.hud-stars img.earned{animation:starPop .5s ease-out both}
@keyframes starPop{0%{transform:scale(.4) rotate(-18deg);opacity:0}70%{transform:scale(1.18) rotate(6deg)}100%{transform:scale(1) rotate(0);opacity:1}}

/* Five level progress props: a glacier-blue orb when open, a fish when the level is done. */
.hud-prop{
  position:relative;width:clamp(26px,3.4vh,34px);height:clamp(26px,3.4vh,34px);padding:0;margin:0;
  border:2px solid #6aaed5;border-radius:50%;cursor:pointer;touch-action:manipulation;
  background:radial-gradient(circle at 35% 30%,#f4fdff,#9fd7ee 62%,#5d9fca);
  box-shadow:inset 0 -3px 0 #376d9780,0 2px 4px #174a7e26;
}
.hud-prop[data-state="done"]{
  background:url("assets/fish.webp") center/74% no-repeat radial-gradient(circle at 35% 30%,#f5feff,#c4eafb 62%,#7dbddd);
  border-color:#6aaed5;
}
.hud-prop[data-state="locked"]{background:#dceaf0;border-color:#a8c6d4;filter:grayscale(.55);opacity:.65;cursor:default}
.hud-prop.is-current{box-shadow:0 0 0 3px #174A7E,inset 0 -3px 0 #376d9780}
.hud-prop:focus-visible{outline:3px solid var(--wm-navy);outline-offset:2px}

/* ---------------- Stage: illustrated world + board ---------------- */
.stage{
  position:relative;flex:1 1 auto;min-height:0;overflow:hidden;
  display:grid;align-content:start;justify-items:center;
  /* --top-chrome is measured in JS so the message lane always clears the fixed
     controls and the HUD; the bottom reserves the equation lane plus the OK bar. */
  padding:var(--top-chrome) 12px calc(var(--bar-h) + var(--eq-h) + 8px);
  grid-template-columns:minmax(0,1fr);
  grid-template-rows:auto minmax(0,1fr);
  grid-template-areas:"message" "board";
}
.world-bg{position:absolute;inset:0;z-index:0}
.world-bg img,.intro-art img{display:block;width:100%;height:100%;object-fit:cover;object-position:center}
/* Decorative scene layer: Penguin sits above the equation lane on Ice Bay. */
.world{position:absolute;inset:0;z-index:1;pointer-events:none}
.sloth,.sloth-loop{position:absolute;left:0;bottom:calc(var(--bar-h) + var(--eq-h) + 4px);height:clamp(64px,17vh,230px);width:auto;max-width:44%;aspect-ratio:1;object-fit:contain;filter:var(--wm-character-light)}
/* Animated WebP idle in the exact static-penguin box. Non-live states remove
 * its source, so decoding stops and the canonical static frame shows through. */
.sloth-loop{visibility:hidden;background:transparent;pointer-events:none}
.world.loop-on .sloth-loop{visibility:visible}
.world.loop-on #sloth{visibility:hidden}
/* Message lane: Sopo + speech on the left, the order card on the right. They are
   two separate flex boxes so a wider bubble can never sit under the target. */
.message{
  grid-area:message;z-index:3;width:100%;min-width:0;
  display:flex;align-items:flex-start;justify-content:space-between;gap:clamp(6px,1.4vw,16px);
}
.message>.guide{display:flex;align-items:flex-start;gap:6px;flex:1 1 auto;min-width:0}
.guide-art{height:clamp(72px,10.5vh,108px);width:auto;flex:0 0 auto;filter:var(--wm-character-light)}
/* Speech: a milky snow surface inside the glacier-blue ice rim. The text is real flow content, so it is
   always painted inside the frame on every viewport. */
.speech{
  position:relative;display:flex;align-items:center;justify-content:center;
  flex:1 1 auto;min-width:0;max-width:min(100%,var(--speech-max));
  padding:clamp(15px,2vh,24px) clamp(18px,2.4vw,30px);
}
.speech-art{
  position:absolute;inset:0;z-index:0;pointer-events:none;border-radius:20px;
  border-style:solid;border-color:transparent;border-width:13px;
  border-image-source:var(--wm-frame-art);border-image-slice:10% fill;border-image-width:1.6;border-image-outset:0;border-image-repeat:stretch;
  background:var(--wm-paper);background-clip:padding-box;
  box-shadow:var(--wm-contact);
}
.speech-text{
  position:relative;z-index:1;display:flex;align-items:center;justify-content:center;
  font-size:clamp(12.5px,1.66vh,18px);line-height:1.2;font-weight:600;color:var(--wm-navy);text-align:center;
}
.order-card{
  position:relative;flex:0 0 auto;display:grid;justify-items:center;gap:0;min-width:clamp(74px,10.5vw,140px);
  padding:0;border-radius:22px;
  border-style:solid;border-color:transparent;
  border-width:clamp(5px,1vh,12px) clamp(9px,1.5vw,22px);
  border-image-source:var(--wm-frame-art);border-image-slice:10% fill;border-image-width:1.6;border-image-outset:0;border-image-repeat:stretch;
  background:var(--wm-paper);background-clip:padding-box;
  box-shadow:var(--wm-contact);
}
.order-top{font-size:clamp(12px,1.5vh,15px);letter-spacing:1.6px;text-transform:uppercase;color:var(--wm-ink-soft);font-weight:600}
.order-num{font-size:clamp(36px,6.6vh,74px);line-height:.98;font-weight:600;color:var(--wm-navy)}
.order-word{font-size:clamp(13px,1.8vh,20px);color:var(--wm-navy)}
.order-unit{font-size:clamp(12px,1.5vh,15px);color:var(--wm-ink-soft)}
.order-card.bump{animation:cardBump .5s ease-out}
@keyframes cardBump{0%{transform:scale(1)}40%{transform:scale(1.07) rotate(-1.5deg)}100%{transform:scale(1)}}

/* ---------------- Board: three independent ice trays ----------------
 * The outer border remains only as transparent geometry. Ten, ones and supply each
 * carry their own ice texture, while the fish wells stay 44px+ tappable. */
.board{
  grid-area:board;position:relative;z-index:3;
  display:grid;align-items:center;justify-items:center;
  gap:clamp(6px,1.1vh,16px);
  justify-self:center;align-self:center;max-width:100%;min-width:0;
  padding:0;
  border-style:solid;border-color:transparent;
  border-width:clamp(9px,1.5vh,18px) clamp(11px,1.6vw,22px);
  border-image:none;
  border-radius:var(--wm-radius-panel);
  background:none;box-shadow:none;
}
.block{display:grid;justify-items:center;gap:clamp(3px,.7vh,8px)}
.ten-block,.ones-block{position:relative;isolation:isolate}
.ten-block::before,.ones-block::before{
  content:"";position:absolute;inset:-4px -2px -3px;z-index:-1;pointer-events:none;
  border:18px solid transparent;border-image:url("assets/ui/ice-surface.webp") 10% fill / 1;border-radius:24px;
  background:none;box-shadow:0 8px 18px #174a7e2b;
}
.block-label{
  margin:0;font-size:clamp(12px,1.42vh,16px);font-weight:600;letter-spacing:.4px;
  width:max-content;max-width:100%;padding:1px 9px;border-radius:10px;
  color:var(--wm-navy);text-align:center;background:none;
  box-shadow:none;
}

.ten-frame{
  position:relative;display:grid;grid-template-columns:repeat(5,var(--leaf));grid-auto-rows:var(--leaf);
  gap:var(--gap);padding:0;border-radius:18px;
  border-style:solid;border-color:transparent;border-width:var(--gap);
  border-image-source:var(--wm-tray-art);border-image-slice:10% fill;border-image-width:1.2;border-image-repeat:stretch;
  background:#fffdf7;background-clip:padding-box;
  box-shadow:inset 0 0 12px #5faed840;
}
.ones-grid{
  display:grid;grid-template-columns:repeat(3,var(--leaf));grid-auto-rows:var(--leaf);
  gap:var(--gap);padding:0;border-radius:18px;
  border-style:solid;border-color:transparent;border-width:var(--gap);
  border-image-source:var(--wm-frame-art);border-image-slice:10% fill;border-image-width:1.2;border-image-repeat:stretch;
  background:#fffdf7;background-clip:padding-box;
  box-shadow:inset 0 0 12px #5faed840;
}
.slot{
  position:relative;display:grid;place-items:center;
  width:var(--leaf);height:var(--leaf);padding:0;margin:0;border:0;background:none;
  border-radius:14px;cursor:pointer;touch-action:none;overflow:visible;
}
.slot:focus-visible{outline:3px solid var(--wm-navy);outline-offset:2px}
/* Quiet glacier-blue wells distinguish empty, occupied and ghosted fish. */
.slot::before{
  content:"";position:absolute;inset:6%;border-radius:32%;
  background:#eaf8fd;
  box-shadow:inset 0 2px 3px #174a7e24,inset 0 -1px 0 #fff;
  border:0;opacity:.85;
}
.slot.filled::before,.slot.ghost::before{opacity:0}
.slot .leaf{position:relative;width:96%;height:96%;object-fit:contain;pointer-events:none;opacity:0;
  filter:drop-shadow(0 3px 2px #2c3f1a4d);transition:opacity .16s ease-out}
.slot.filled .leaf{opacity:1}
.slot.ghost .leaf{opacity:.3;filter:grayscale(.55) drop-shadow(0 2px 1px #2c3f1a33)}
.slot.filled{animation:leafDrop .22s ease-out}
.slot.filled .leaf,.slot.ghost .leaf{animation:leafSway 3.6s ease-in-out infinite}
.slot.filled .leaf{animation-delay:calc(var(--i,0) * -0.23s)}
@keyframes leafDrop{from{transform:translateY(-14%) scale(.86);opacity:.4}to{transform:none;opacity:1}}
@keyframes leafSway{0%,100%{transform:rotate(calc(var(--rot,0deg) - 2deg))}50%{transform:rotate(calc(var(--rot,0deg) + 2deg))}}
.slot.mark::after{
  content:"";position:absolute;inset:-4%;border-radius:16px;
  box-shadow:inset 0 0 0 3px #5faed8,inset 0 2px 6px #174a7e1f;
}
.ones-grid.drop-active{box-shadow:inset 0 0 0 4px #7fc25f,inset 0 2px 4px #174a7e24}
.pile.drop-active{box-shadow:inset 0 2px 0 #ffffff6b,0 0 0 4px #7fc25f,0 8px 12px #174a7e2e}
.drag-ghost{position:fixed;z-index:240;left:0;top:0;width:clamp(44px,7vh,80px);height:clamp(44px,7vh,80px);pointer-events:none;display:none}
.drag-ghost img{display:block;width:100%;height:100%;object-fit:contain;filter:drop-shadow(0 7px 6px #174a7e66)}
/* The demonstration carries this same fish from the pile to its well; the real
 * drag follows the pointer with no transition. */
.drag-ghost.carry{transition:transform .55s cubic-bezier(.4,1.2,.5,1)}
.pile-block{align-self:center}
.pile{
  display:flex;flex-direction:column;align-items:center;gap:2px;
  min-width:calc(var(--leaf) * 1.5);min-height:max(56px,calc(var(--leaf) * 1.05));
  padding:0;border-radius:18px;cursor:pointer;touch-action:none;
  border-style:solid;border-color:transparent;border-width:8px 12px;
  border-image-source:var(--wm-tray-art);border-image-slice:10% fill;border-image-width:1.6;border-image-outset:0;border-image-repeat:stretch;
  background:var(--wm-paper);background-clip:padding-box;
  box-shadow:0 6px 12px #174a7e1f;
}
.pile:active{transform:translateY(3px)}
.pile:focus-visible{outline:3px solid var(--wm-navy);outline-offset:3px}
.pile-stack{position:relative;width:calc(var(--leaf) * .86);height:calc(var(--leaf) * .82)}
.pile-leaf{position:absolute;inset:0;width:100%;height:100%;object-fit:contain;filter:drop-shadow(0 2px 2px #2c3f1a4d)}
.pile-leaf.p1{transform:rotate(-15deg) translate(-8%,5%)}
.pile-leaf.p2{transform:rotate(2deg)}
.pile-leaf.p3{transform:rotate(16deg) translate(8%,-3%)}
.pile-plus{font-size:clamp(14px,1.9vh,20px);font-weight:600;color:var(--wm-navy)}
.pile-text{font-size:clamp(12px,1.35vh,15px);color:var(--wm-navy)}
.pile[disabled]{opacity:.55;cursor:default}
.pile[disabled]:active{transform:none}
.board.is-full .pile{filter:saturate(.6)}

/* ---------------- equation + OK ---------------- */
/* The equation is one compact ice strip in its own lane directly above the OK bar,
 * so every navy numeral stays visible and unchanged in size. */
.equation{
  position:fixed;z-index:204;bottom:var(--bar-h);left:50%;transform:translateX(-50%);
  display:flex;align-items:center;justify-content:center;flex-wrap:nowrap;
  gap:clamp(4px,.8vw,12px);width:max-content;max-width:calc(100vw - 8px);
  padding:0;
  border-style:solid;border-color:transparent;
  border-width:clamp(8px,1.2vh,13px) clamp(12px,1.4vw,20px);
  border-image-source:var(--wm-tray-art);border-image-slice:10% fill;border-image-width:1.6;border-image-outset:0;border-image-repeat:stretch;
  border-radius:18px;
  background:none;background-clip:padding-box;
  box-shadow:var(--wm-contact);
}
.eq-num{
  min-width:clamp(38px,4.6vh,58px);padding:3px 12px;border-radius:14px;border:0;
  background:#f5fcfe;
  box-shadow:inset 0 2px 3px #174a7e1f;
  font-size:clamp(20px,3.1vh,34px);font-weight:600;color:var(--wm-navy);text-align:center;
}
.eq-num.eq-whole{background:#dff4fb;color:var(--wm-navy);box-shadow:inset 0 2px 3px #174a7e1f}
.eq-num.pulse{animation:eqPulse .5s ease-out}
@keyframes eqPulse{0%{transform:scale(1)}45%{transform:scale(1.16)}100%{transform:scale(1)}}
.eq-op{
  display:inline-flex;align-items:center;justify-content:center;
  min-width:clamp(24px,3vh,34px);padding:0 8px;border-radius:12px;
  background:#f8fdfe;box-shadow:inset 0 2px 3px #174a7e1a;
  font-size:clamp(18px,2.7vh,30px);font-weight:600;color:var(--wm-navy-deep);
}
/* Captions stay crisp navy text on the ice strip, never tiny. */
.eq-cap{font-size:clamp(12px,1.4vh,16px);font-weight:600;color:var(--wm-navy);padding:0 2px}

.bar{
  position:fixed;z-index:206;left:0;right:0;bottom:0;
  height:var(--bar-h);display:flex;align-items:center;justify-content:center;
  padding-bottom:max(6px,env(safe-area-inset-bottom));pointer-events:none;
}
.ok{
  pointer-events:auto;position:relative;display:flex;align-items:center;flex-direction:column;gap:2px;
  width:var(--ok);min-width:var(--ok);padding:0;border:0;background:none;cursor:pointer;
  border-radius:50%;touch-action:manipulation;
}
.ok img{display:block;width:var(--ok);height:var(--ok);object-fit:contain;filter:drop-shadow(0 7px 6px #1d3c0e66);transition:transform .12s ease-out}
.ok:active img{transform:translateY(3px) scale(.97)}
.ok:focus-visible{outline:4px solid #fff;outline-offset:4px}
.ok-text{
  font-size:clamp(13px,1.7vh,18px);font-weight:600;color:var(--wm-navy);
  background:#fbfffd;border:0;border-radius:12px;padding:2px 12px;
  box-shadow:inset 0 2px 3px #174a7e1a,0 3px 6px #174a7e24;
}
.app[data-screen="intro"] .bar,.app[data-screen="intro"] .equation,.app[data-screen="intro"] .hud,
.app[data-screen="intro"] .compare{display:none}
.app[data-screen="levelDone"] .bar,.app[data-screen="finale"] .bar,
.app[data-frozen="1"] .bar{display:none}

/* ---------------- comparison helper ---------------- */
.compare{
  z-index:208;display:flex;flex-direction:column;gap:7px;
  padding:8px 10px;border-radius:20px;
  border-style:solid;border-color:transparent;border-width:14px;
  border-image-source:var(--wm-frame-art);border-image-slice:10% fill;border-image-width:1.6;border-image-outset:0;border-image-repeat:stretch;
  background:var(--wm-paper);background-clip:padding-box;
  box-shadow:var(--wm-contact);
}
.compare[hidden]{display:none}
.compare-text{margin:0;font-size:clamp(13px,1.8vh,19px);font-weight:600;color:var(--wm-navy);flex:0 0 auto}
.compare-actions{display:flex;gap:8px;flex-wrap:wrap}
.compare-btn{
  min-height:48px;padding:0 16px;border-radius:14px;cursor:pointer;touch-action:manipulation;
  background:#dff4fb;border:0;color:var(--wm-navy);
  font-size:clamp(13px,1.6vh,17px);font-weight:600;
  box-shadow:inset 0 2px 0 #ffffffb3,0 5px 10px #174a7e26;
}
.compare-btn.ghost{background:#fff;color:var(--wm-navy);box-shadow:inset 0 2px 0 #ffffffb3,0 4px 9px #174a7e1f}
.compare-btn:active{transform:translateY(2px)}
.compare-btn:focus-visible{outline:3px solid var(--wm-navy);outline-offset:3px}
.compare-grid{display:flex;justify-content:center;gap:4px}
.pair{display:flex;flex-direction:column;gap:4px;align-items:center}
.pair .cell{
  width:clamp(20px,3.1vh,30px);height:clamp(20px,3.1vh,30px);border-radius:50%;
  display:grid;place-items:center;font-size:14px;font-weight:600;line-height:1;
}
.cell.on{background:#dff0cf url("assets/fish.webp") center/82% no-repeat;box-shadow:inset 0 0 0 2px #7fc25f}
.cell.off{background:#eaf8fd;box-shadow:inset 0 2px 3px #174a7e24}
.cell.miss{box-shadow:inset 0 0 0 3px #5faed8;background:#f4fbfd}
.cell.extra{background:#ffe2da;box-shadow:inset 0 0 0 3px #e2624a}
.pair.flag .cell{outline:2px solid #e2624a;outline-offset:1px}
.pair.flag-miss .cell{outline:2px solid #408cbb;outline-offset:1px}

/* ---------------- demo hand + big level transition ---------------- */
/* The level reward uses one large arrow control, so the next level is obvious
 * without reading its label. */
.level-next{display:flex;align-items:center;gap:8px}
.level-next img{display:block;width:clamp(30px,4.6vh,46px);height:auto;object-fit:contain}
.hand{position:fixed;z-index:207;left:0;top:0;width:clamp(56px,8.6vh,92px);pointer-events:none;transition:transform .55s cubic-bezier(.4,1.2,.5,1)}
.hand[hidden]{display:none}
.hand img{display:block;width:100%;height:auto;filter:drop-shadow(0 5px 6px #00000045)}
.hand.tap{animation:handTap .5s ease-in-out}
@keyframes handTap{0%,100%{transform:scale(1)}50%{transform:scale(.86)}}

/* ---------------- rune ---------------- */
.rune{
  position:fixed;z-index:320;left:max(6px,env(safe-area-inset-left));bottom:max(6px,env(safe-area-inset-bottom));
  width:clamp(52px,7.4vh,86px);height:auto;opacity:.94;pointer-events:none;
  filter:drop-shadow(0 3px 4px #00000042);
}
.app[data-screen="intro"] .rune{z-index:330}

/* ---------------- intro ---------------- */
.intro{position:fixed;inset:0;z-index:250;background:#0f3358}
.intro[hidden]{display:none}
.intro-art{position:absolute;inset:0;display:block;width:100%;height:100%;margin:0}
.intro-caption{
  position:absolute;left:auto;right:max(20px,env(safe-area-inset-right));
  top:max(112px,calc(env(safe-area-inset-top) + 112px));bottom:auto;transform:none;
  z-index:252;margin:0;width:max-content;max-width:min(320px,32vw);padding:3px 8px;border-radius:16px;
  border-style:solid;border-color:transparent;border-width:10px 18px;
  border-image-source:var(--wm-frame-art);border-image-slice:10% fill;border-image-width:1.6;border-image-outset:0;border-image-repeat:stretch;
  background:var(--wm-paper);background-clip:padding-box;
  color:var(--wm-ink);text-align:left;font-size:clamp(13px,1.9vh,19px);font-weight:600;
  box-shadow:var(--wm-contact);pointer-events:none;
}
/* Keep the caption in clear sky, away from the countable trays. */
@media (orientation:portrait),(max-width:600px){
  .intro-caption{
    left:auto;right:max(12px,env(safe-area-inset-right));
    top:max(104px,calc(env(safe-area-inset-top) + 104px));bottom:auto;
    width:min(56vw,210px);max-width:210px;font-size:13px;text-align:right;
  }
}
/* Local deluxe override of the shared opening title: milky ice plaque in Fredoka.
 * Kept in game.css so the shared story-opening.css stays untouched. */
#intro.wm-story-opening > .wm-story-title{
  padding:12px 28px 14px!important;
  border-style:solid!important;border-color:transparent!important;border-width:16px 26px!important;
  border-image-source:var(--wm-frame-art)!important;border-image-slice:10% fill!important;
  border-image-width:1.6!important;border-image-outset:0!important;border-image-repeat:stretch!important;
  border-radius:26px!important;
  background:var(--wm-paper)!important;background-clip:padding-box!important;
  color:var(--wm-ink)!important;
  font:600 clamp(26px,3.1vw,42px)/1.12 "Fredoka",system-ui,-apple-system,"Segoe UI",sans-serif!important;
  box-shadow:var(--wm-contact)!important;
}
@media (orientation:portrait),(max-width:600px){
  #intro.wm-story-opening > .wm-story-title{font-size:clamp(22px,5.6vw,30px)!important;padding:11px 18px 13px!important;border-width:14px 20px!important}
}
/* Short landscape phones (e.g. 844x390): the shared opening ships a 176px play
 * disc and a display-size title, which here sit on the characters' faces and the
 * illustrated fish trays. Local overrides only; the shared CSS stays untouched. */
@media (orientation:landscape) and (max-height:460px){
  #intro.wm-story-opening > .wm-story-title{
    top:8px!important;
    max-width:calc(100% - 24px)!important;
    padding:3px 8px!important;
    border-width:8px 14px!important;
    border-radius:18px 16px 20px 17px!important;
    font:600 20px/1.1 "Fredoka",system-ui,-apple-system,"Segoe UI",sans-serif!important;
  }
  #intro.wm-story-opening > button.wm-story-play{
    left:auto!important;right:14px!important;top:auto!important;bottom:12px!important;
    width:72px!important;height:72px!important;min-width:72px!important;min-height:72px!important;
    transform:none!important;
  }
  #intro.wm-story-opening > button.wm-story-play:active:not(:disabled){transform:none!important}
  #intro .intro-caption{
    left:max(12px,env(safe-area-inset-left))!important;right:auto!important;top:56px!important;bottom:auto!important;transform:none!important;
    max-width:calc(100vw - 210px)!important;
    padding:3px 8px!important;border-width:8px 14px!important;
    font-size:13px!important;
  }
}

/* ---------------- overlays ---------------- */
.overlay{
  position:fixed;inset:0;z-index:300;display:grid;place-items:center;padding:16px;
  background:#0c1c2ed1;
}
.overlay[hidden]{display:none}
.panel{
  width:min(680px,94vw);max-height:92vh;overflow:auto;padding:clamp(8px,1.6vh,16px) clamp(10px,1.8vw,20px);
  border-radius:26px;
  border-style:solid;border-color:transparent;border-width:22px;
  border-image-source:var(--wm-frame-art);border-image-slice:10% fill;border-image-width:1.6;border-image-outset:0;border-image-repeat:stretch;
  background:var(--wm-paper);background-clip:padding-box;
  box-shadow:var(--wm-contact);
  text-align:center;
}
.panel h2{margin:0 0 8px;font-size:clamp(20px,3.1vh,32px);color:var(--wm-navy)}
.panel p{margin:6px 0;font-size:clamp(14px,1.75vh,19px);line-height:1.4;color:var(--wm-ink-soft)}
.panel .row{display:flex;gap:10px;flex-wrap:wrap;justify-content:center;margin-top:14px}
.panel button.btn{
  min-height:56px;padding:0 20px;border-radius:16px;cursor:pointer;touch-action:manipulation;
  background:#dff4fb;border:0;color:var(--wm-navy);
  font-size:clamp(14px,1.8vh,19px);font-weight:600;
  box-shadow:inset 0 2px 0 #ffffffb3,0 6px 12px #174a7e26;
}
.panel button.btn.alt{background:#fff;color:var(--wm-navy);box-shadow:inset 0 2px 0 #ffffffb3,0 5px 10px #174a7e1f}
.panel button.btn.cool{background:#f1fbfe;color:var(--wm-navy);box-shadow:inset 0 2px 0 #ffffffb3,0 5px 10px #174a7e1f}
.panel button.btn:active{transform:translateY(2px)}
.panel button.btn:focus-visible{outline:3px solid var(--wm-navy);outline-offset:3px}
.panel button.btn[disabled]{opacity:.5;cursor:default}
.panel .levels-list{display:flex;gap:10px;flex-wrap:wrap;justify-content:center;margin-top:10px}
.level-btn{
  position:relative;display:grid;gap:2px;justify-items:center;
  min-width:92px;min-height:86px;padding:3px 4px;border-radius:18px;cursor:pointer;touch-action:manipulation;
  border-style:solid;border-color:transparent;border-width:10px;
  border-image-source:var(--wm-frame-art);border-image-slice:10% fill;border-image-width:1;border-image-repeat:stretch;
  background:var(--wm-paper);background-clip:padding-box;
  font-size:clamp(13px,1.6vh,17px);font-weight:600;color:var(--wm-navy);
  box-shadow:var(--wm-contact-soft);
}
.level-btn .lvl-num{font-size:clamp(20px,2.8vh,28px)}
.level-btn .lvl-targets{font-size:clamp(12px,1.35vh,15px);color:var(--wm-ink-soft);font-weight:400}
.level-btn .lvl-stars{display:flex;gap:3px}
.level-btn .lvl-stars img{width:clamp(14px,1.9vh,20px);height:clamp(14px,1.9vh,20px);object-fit:contain}
.level-btn[aria-disabled="true"]{opacity:.55;filter:grayscale(.5);cursor:default}
.level-btn:focus-visible{outline:3px solid var(--wm-navy);outline-offset:3px}
.highfive{display:block;width:min(100%,clamp(200px,42vh,380px));height:auto;margin:0 auto 6px}
.recap{display:flex;flex-wrap:wrap;gap:6px;justify-content:center;margin-top:10px}
.recap span{padding:4px 10px;border-radius:12px;background:#e9f7fb;box-shadow:inset 0 1px 2px #174a7e1a;font-size:clamp(12px,1.5vh,16px);font-weight:600;color:var(--wm-navy)}
.stars-big{display:flex;gap:6px;justify-content:center;margin:8px 0}
.stars-big img{width:clamp(26px,4.2vh,46px);height:clamp(26px,4.2vh,46px);object-fit:contain}
.help-list{margin:10px auto 0;max-width:520px;text-align:left;padding-left:22px}
.help-list li{margin:6px 0;font-size:clamp(13px,1.65vh,18px);line-height:1.35}
.help-lead{margin:10px auto 0!important;max-width:520px;text-align:left;font-weight:600!important}
.help-hints{margin-top:6px}
.help-now{margin-top:12px;display:flex;gap:8px;justify-content:center;flex-wrap:wrap}
.help-now .btn{background:#dff4fb;color:var(--wm-navy)}
/* Read-free help sequence: the real fish and the real green OK button. */
.help-visual{display:flex;align-items:center;justify-content:center;gap:10px;flex-wrap:wrap;margin:8px auto 2px}
.help-visual .hv-group{display:flex;flex-direction:column;align-items:center;gap:2px}
.help-visual .hv-frame{
  display:grid;grid-template-columns:repeat(5,auto);gap:2px;padding:2px;border-radius:10px;
  border-style:solid;border-color:transparent;border-width:6px;
  border-image-source:var(--wm-tray-art);border-image-slice:10% fill;border-image-width:1;border-image-repeat:stretch;
  background:var(--wm-paper);background-clip:padding-box;
}
.help-visual .hv-frame img{width:15px;height:15px;object-fit:contain}
.help-visual .hv-leaf{width:26px;height:26px;object-fit:contain}
.help-visual .hv-ok{width:38px;height:38px;object-fit:contain;filter:drop-shadow(0 2px 2px #1d3c0e55)}
.help-visual .hv-cap{font-size:12px;font-weight:600;color:var(--wm-navy)}
.help-visual .hv-op{font-size:18px;font-weight:600;color:var(--wm-navy)}

/* ---------------- layout: landscape ---------------- */
@media (orientation:landscape){
  .app{--leaf:clamp(26px,min(9.2vh,6vw),92px);--gap:clamp(4px,.9vh,12px);--ok:clamp(64px,11.6vh,104px);--speech-max:min(100%,320px)}
  /* Left column holds speech above the target card; the board keeps the wide
     right column. The two message boxes are separate rows, never overlapping. */
  .stage{
    grid-template-columns:minmax(150px,.82fr) minmax(0,2.1fr);grid-template-rows:minmax(0,1fr);
    grid-template-areas:"message board";align-content:stretch;
    padding-left:max(12px,env(safe-area-inset-left));padding-right:max(12px,env(safe-area-inset-right));
  }
  .message{flex-direction:column;align-items:flex-start;justify-content:flex-start;align-self:start;gap:clamp(6px,1.2vh,14px);max-width:100%}
  .message>.guide{max-width:100%}
  .board{grid-template-columns:auto auto auto;grid-template-areas:"ten ones pile"}
  .ten-block{grid-area:ten}.ones-block{grid-area:ones}.pile-block{grid-area:pile}
  .sloth,.sloth-loop{height:clamp(72px,min(24vh,30vw),240px);max-width:40%}
  .app.compare-open .sloth,.app.compare-open .sloth-loop{
    left:auto;right:max(12px,env(safe-area-inset-right));bottom:max(12px,env(safe-area-inset-bottom));
  }
  .compare{
    position:fixed;left:max(12px,env(safe-area-inset-left));top:auto;bottom:calc(var(--bar-h) + var(--eq-h) + 6px);transform:none;
    width:min(440px,calc((100vw - 24px) * .28 - 8px));
    max-height:calc(100vh - var(--top-chrome) - var(--bar-h) - var(--eq-h) - 16px);overflow:auto;
  }
}

/* ---------------- layout: portrait ---------------- */
@media (orientation:portrait){
  .app{--leaf:clamp(48px,min(12.2vw,7vh),92px);--gap:clamp(5px,1.3vw,10px);--ok:clamp(56px,9.6vh,96px);--bar-h:calc(var(--ok) + 76px);--speech-max:clamp(150px,44vw,320px)}
  /* A compact one-row HUD below the control row leaves the most vertical space
     for the board on small phones. */
  .hud{left:max(8px,env(safe-area-inset-left));right:max(8px,env(safe-area-inset-right));justify-content:flex-end;flex-wrap:nowrap;gap:6px;max-width:calc(100vw - 16px);top:calc(max(8px,env(safe-area-inset-top)) + 62px)}
  .hud::before{inset:-5px;border-width:12px}
  .hud-level,.hud-levels{min-height:36px;padding:0 10px;font-size:13px}
  .hud-levels{min-height:38px;padding:0 4px;border-width:7px}
  .hud-prop{width:26px;height:26px}
  .hud-stars{padding:3px 7px}
  .hud-stars img{width:18px;height:18px}
  /* Board: ten frame on top, then the nine ones and the pile side by side. */
  .board{grid-template-columns:auto auto;grid-template-areas:"ten ten" "ones pile";gap:clamp(5px,1vh,12px);border-width:clamp(7px,1.2vh,14px) clamp(8px,1.6vw,16px)}
  .ten-block{grid-area:ten}.ones-block{grid-area:ones}.pile-block{grid-area:pile}
  .ones-grid{grid-template-columns:repeat(5,var(--leaf))}
  .pile{min-width:calc(var(--leaf) * 1.4)}
  .pile-text{font-size:clamp(12px,3vw,15px)}
  .message{flex-direction:row;align-items:flex-start;justify-content:space-between}
  .sloth,.sloth-loop{height:clamp(92px,14vh,168px);max-width:44%}
  .equation{gap:clamp(3px,1.1vw,8px);border-width:clamp(7px,1vh,11px) clamp(9px,2vw,14px)}
  .eq-num{min-width:clamp(30px,9vw,52px);padding:2px 7px;font-size:clamp(18px,5.4vw,32px)}
  .eq-op{font-size:clamp(16px,4.6vw,28px);padding:0 6px}
  .eq-cap{font-size:clamp(11px,2.9vw,14px);padding:0 1px}
  .compare{
    position:fixed;left:50%;top:auto;bottom:calc(var(--bar-h) + var(--eq-h) + 6px);transform:translateX(-50%);
    width:min(600px,calc(100vw - 16px));
    max-height:calc(100vh - var(--top-chrome) - var(--bar-h) - var(--eq-h) - 6px - 16px);overflow:auto;
  }
  .app.compare-open .stage{padding-bottom:calc(var(--bar-h) + var(--eq-h) + var(--compare-h,96px) + 12px)}
  .app.compare-open .board{align-self:end}
}

/* Short portrait: actions share the message lane, so the board keeps its normal
 * footprint and the order card and every fish stay clear of the helper. */
@media (orientation:portrait) and (max-height:800px){
  .app.compare-open .stage{padding-bottom:calc(var(--bar-h) + var(--eq-h) + 8px)}
  .app.compare-open .board{align-self:center}
  .app.compare-open .message>.guide{visibility:hidden}
  .app.compare-open .compare{
    position:fixed;left:max(8px,env(safe-area-inset-left));
    right:calc(max(8px,env(safe-area-inset-right)) + clamp(86px,27vw,148px));
    top:var(--top-chrome);bottom:auto;transform:none;width:auto;max-height:none;
    padding:2px 6px;border-width:8px;gap:0;overflow:visible;
  }
  .app.compare-open .compare-text,.app.compare-open .compare-grid{display:none}
  .app.compare-open .compare-actions{flex-wrap:nowrap;gap:6px}
  .app.compare-open .compare-btn{flex:1 1 0;min-height:48px;padding:0 8px;font-size:12px;white-space:nowrap}
}

/* Short portrait views keep the spoken explanation and the real fish, while the
 * redundant summary and miniature comparison grid give the trays their space. */
@media (orientation:portrait) and (max-height:1200px){
  .compare{gap:0;padding:6px 8px}
  .compare-text,.compare-grid{display:none}
}

@media (orientation:landscape) and (max-height:700px){
  .compare-text,.compare-grid{display:none}
}

/* Narrow portrait phones (360-480): the auxiliary HUD must fit the ~344px of
 * inner width with the full "Level 1" label, five progress props, four task
 * stars and the Levels button. Only the small HUD chips shrink; the five big
 * controls keep their 56px targets and the leaf wells keep their 44px floor. */
@media (orientation:portrait) and (max-width:480px){
  .app{--gap:4px;--bar-h:calc(var(--ok) + 68px)}
  .board{gap:4px;border-width:6px}
  .ones-grid{border-width:4px}
  .pile{width:clamp(48px,calc(100vw - 304px),86px);min-width:0;border-width:6px}
  .hud{gap:4px;flex-wrap:wrap}
  .hud::before{inset:-4px;border-width:10px}
  .hud-level,.hud-levels{min-height:32px;padding:0 6px;font-size:12px;letter-spacing:0}
  .hud-level{white-space:nowrap}
  .hud-levels{min-height:34px;padding:0 3px;border-width:6px}
  .hud-props,.hud-stars{gap:2px;padding:2px 4px}
  .hud-prop{width:20px;height:20px}
  .hud-stars img{width:14px;height:14px}
  .guide-art{height:clamp(72px,9.2vh,80px)}
}

/* short screens in either orientation: keep everything inside */
@media (max-height:460px){
  .app{--leaf:clamp(48px,min(10vh,4.8vw),54px);--ok:clamp(56px,16vh,80px)}
  .hud-level,.hud-levels{min-height:40px;padding:0 10px;font-size:clamp(12px,3.2vh,16px)}
  .hud-levels{min-height:44px;padding:0 5px;border-width:7px}
  .guide-art{height:clamp(44px,14vh,72px)}
  .order-num{font-size:clamp(26px,9vh,44px)}
  .sloth,.sloth-loop{height:clamp(70px,36vh,150px)}
  .block-label{font-size:clamp(11px,2.6vh,14px)}
  .eq-num{min-width:clamp(30px,7vh,44px);font-size:clamp(16px,4.6vh,26px)}
  .eq-cap{font-size:clamp(10px,2.4vh,13px);padding:0 1px}
  .compare{overflow:auto}
}

@media (orientation:portrait){
  .sloth,.sloth-loop{left:auto;right:max(8px,env(safe-area-inset-right));bottom:max(4px,env(safe-area-inset-bottom));height:clamp(92px,14vh,168px);max-width:calc(100vw - 16px)}
}

@media (orientation:portrait) and (max-width:480px) and (max-height:700px){
  .app{--bar-h:calc(var(--ok) + 34px)}
  .sloth,.sloth-loop{bottom:max(8px,env(safe-area-inset-bottom));height:clamp(82px,13.2vh,88px)}
}

@media (orientation:landscape) and (max-height:520px){
  /* Short landscape phones (e.g. 844x390): keep the fish wells tappable instead
   * of shrinking them into unusable dots. The decorative sloth steps aside, the
   * speech and the order card stay in the left column as two rows, and the nine
   * extra leaves fold into a five-wide row. */
  .app{--leaf:clamp(48px,min(10vh,5.2vw),56px);--gap:4px;--speech-max:min(26vw,132px);--eq-h:0px;--bar-h:calc(var(--ok) + 12px)}
  .stage{
    grid-template-columns:minmax(96px,.5fr) minmax(0,2.5fr);grid-template-rows:minmax(0,1fr);grid-template-areas:"message board";
    padding-left:max(8px,env(safe-area-inset-left));padding-right:max(8px,env(safe-area-inset-right));
    padding-bottom:calc(var(--bar-h) + var(--eq-h) + 8px);
  }
  .sloth,.sloth-loop{display:none}
  .message{gap:6px}
  .message>.guide{gap:4px}
  .order-card{min-width:clamp(72px,10vw,110px)}
  .order-num{font-size:clamp(22px,7vh,36px)}
  .ones-grid{grid-template-columns:repeat(5,var(--leaf))}
  .pile{min-height:56px}
  .speech-text{font-size:clamp(12px,2.5vh,13px)}
  /* Put the equation and green OK in one bottom row, leaving the tray its full 96px. */
  .equation{
    left:calc(max(6px,env(safe-area-inset-left)) + clamp(52px,7.4vh,86px) + 8px);
    bottom:max(6px,env(safe-area-inset-bottom));
    transform:none;
    max-width:calc(100vw - var(--ok) - 100px);
  }
  /* The compact bar is shorter than the green disc plus its caption. */
  .bar{
    left:auto;right:max(6px,env(safe-area-inset-right));
    width:calc(var(--ok) + 12px);height:var(--bar-h);
    bottom:max(10px,env(safe-area-inset-bottom));padding:0;
  }
  /* A one-row helper fits between the trays and equation without covering fish. */
  .compare{
    left:50%;transform:translateX(-50%);
    bottom:calc(max(6px,env(safe-area-inset-bottom)) + 54px);
    width:max-content;max-width:calc(100vw - 24px);
    padding:2px 6px;border-width:8px;gap:0;overflow:visible;
  }
  .compare-actions{flex-wrap:nowrap;gap:6px}
  .compare-btn{min-height:48px;padding:0 10px;font-size:12px}
}

/* A dialog or a pause freezes the decorative animation with the game clock.
 * Declared before the reduced-motion block, which keeps animation:none winning. */
.app[data-frozen="1"] *{animation-play-state:paused!important}

@media (prefers-reduced-motion:reduce){
  .slot.filled,.slot.filled .leaf,.slot.ghost .leaf,.hud-stars img.earned,.order-card.bump{animation:none!important}
  .hand,.hand.tap,.drag-ghost.carry{transition:none;animation:none!important}
}
