*{box-sizing:border-box}
:root{color-scheme:light;--paper:#fff6df;--ink:#402943;--muted:#654b62;--rule:#d8b9ab;--green:#12635c;--berry:#8f345c;--rounded:ui-rounded,'Arial Rounded MT Bold','Trebuchet MS',system-ui,sans-serif;font-family:var(--rounded);color:var(--ink);background:var(--paper)}
html,body{height:100%;margin:0;overflow:hidden;overscroll-behavior:none}
body{background:radial-gradient(ellipse at 8% 0,#ffead7 0,transparent 43%),radial-gradient(ellipse at 94% 92%,#fff0be 0,transparent 48%),#fff8e7;position:fixed;inset:0;-webkit-text-size-adjust:100%;-webkit-tap-highlight-color:transparent}
main{width:min(100%,850px);height:100%;height:100dvh;margin:0 auto;display:flex;flex-direction:column;padding:max(1px,env(safe-area-inset-top)) max(8px,env(safe-area-inset-right)) max(4px,env(safe-area-inset-bottom)) max(8px,env(safe-area-inset-left))}
button,input,select{font:inherit;color:inherit}
button{min-width:44px;min-height:44px;border:1px solid var(--rule);background:#fffdf5;border-radius:15px;cursor:pointer;touch-action:manipulation}
button:active{filter:brightness(.94)}
button:focus-visible,a:focus-visible,[tabindex]:focus-visible,input:focus-visible,select:focus-visible{outline:3px solid #126a9e;outline-offset:2px}
button svg{width:21px;height:21px;vertical-align:middle}
header{height:46px;flex:none;display:grid;grid-template-columns:1fr auto 1fr;align-items:center;padding:0 6px;border-bottom:1px solid #e7cfc0}
header a{justify-self:start;display:flex;align-items:center;min-height:44px;color:var(--muted);font-size:13px;font-weight:650;text-decoration:none}
header b{font:850 21px/1 var(--rounded);letter-spacing:-.9px;color:var(--berry)}#sound{justify-self:end;border:0;background:transparent;color:var(--green)}
#play{flex:1;min-height:0;display:flex;flex-direction:column;touch-action:none;overscroll-behavior:none}
.heading-tools{display:flex;align-items:center;gap:2px}.heading{flex:none;display:flex;justify-content:space-between;align-items:center;gap:8px;padding:9px 6px 10px}
#number{display:block;color:var(--muted);font:750 clamp(9px,2.3vw,11px)/1.35 var(--rounded);letter-spacing:.8px}
h1,h2{font-family:var(--rounded);font-weight:820;margin:0;letter-spacing:-.045em;text-wrap:balance}
h1{font-size:clamp(24px,6.4vw,37px);line-height:1.07;margin-top:1px}
#shelf{flex:none;display:flex;align-items:center;justify-content:center;gap:7px;padding:0 12px;font-size:14px;font-weight:750;background:#ffdf80;color:#533a45;border-color:#d8ab5e;box-shadow:0 2px 0 #e9c573}
#stage{position:relative;flex:1;min-height:0;overflow:hidden;isolation:isolate;border-radius:22px;border:1px solid #6f52604a;box-shadow:0 2px 0 #d8baa0;touch-action:none;-webkit-touch-callout:none}
#scene{position:absolute;inset:0;width:100%;height:100%;display:block;touch-action:none;user-select:none;-webkit-user-select:none}
#backdrop,#pieces{pointer-events:none}#touch-plane{touch-action:none;cursor:grab}#touch-plane:active{cursor:grabbing}
#guide{position:static;min-width:44px;height:44px;background:transparent;border:0;font-size:0}
#guide::before{content:'?';display:inline-grid;place-items:center;width:25px;height:25px;background:#f5e9ff;color:#5d447c;border:1px solid #ccabd9;border-radius:50%;font:800 16px var(--rounded)}
#guide[aria-pressed=true]::before{color:white;background:#694b84}
#stage[data-result] #guide{display:none}
#start{position:absolute;left:50%;bottom:12px;transform:translateX(-50%);background:var(--berry);color:#fffdf4;white-space:nowrap;border:1px solid #ffffff80;border-radius:24px;padding:0 18px;box-shadow:0 3px 0 #773453,0 4px 9px #502c4920}
#start span{font-size:12px;margin-right:4px}
.caption{flex:none;display:grid;grid-template-columns:44px minmax(0,1fr) 44px;gap:6px;align-items:center;min-height:58px;padding:5px 3px}
.message{grid-column:2;grid-row:1;display:flex;align-items:center;justify-content:center;gap:6px}
#hint{margin:0;color:var(--ink);text-align:center;font-size:clamp(13px,3.3vw,16px);line-height:1.28;font-weight:650}
#success{color:var(--green);font-size:19px}
#again,.caption #next{height:44px;padding:0;display:grid;place-items:center;background:#fffaf0;border-color:#d6b9aa;color:#71405e}
#again{grid-row:1;grid-column:1}.caption #next{grid-row:1;grid-column:3}
#again-label,.caption #next-label,.sr{position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap}
.control-icon{font-size:23px;line-height:1}
#board-result{position:absolute;inset:auto 8px 8px;display:flex;align-items:center;justify-content:space-between;gap:6px;padding:6px 7px 6px 12px;color:var(--ink);background:#fff9db;border:1px solid #c99a66;border-radius:15px;box-shadow:0 3px 14px #56334424}
#board-result strong{flex:1;font:800 clamp(16px,4.3vw,23px)/1.12 var(--rounded)}
.result-medal{width:24px;height:24px;display:grid;place-items:center;background:#ffd35c;color:#74441e;border-radius:50%;flex:none}
#stage[data-result=step] .result-medal{background:var(--green);color:white}
#board-result #next{min-height:44px;max-width:54%;padding:5px 11px;display:flex;align-items:center;justify-content:center;gap:7px;background:var(--green);color:white;border:0;border-radius:12px;font-size:clamp(13px,3.2vw,16px);font-weight:700}
#stage[data-result] #scene{height:calc(100% - 60px)}
#drawer{width:min(94vw,680px);max-height:85dvh;padding:14px;color:var(--ink);background:#fff8e9;border:1px solid #d4a8a9;border-radius:20px;overflow:auto;overscroll-behavior:contain;touch-action:pan-y;box-shadow:0 20px 70px #50324c45}
dialog::backdrop{background:#4c365783}
.drawer-head{display:flex;justify-content:space-between;align-items:center;gap:12px}
.drawer-head h2{font-size:28px}#close{font-size:24px}
.drawer-tools{display:grid;grid-template-columns:minmax(0,1.15fr) minmax(0,1fr);gap:7px;margin:8px 0}
.drawer-tools input,.drawer-tools select{width:100%;min-width:0;min-height:44px;background:#fffdf8;border:1px solid var(--rule);border-radius:8px;padding:6px 9px;font-size:16px}
#drawer-count{margin:6px 1px;color:var(--muted);font-size:13px}
#choices{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:8px}
#choices h3{grid-column:1/-1;margin:9px 0 0;font:800 15px/1.3 var(--rounded);color:var(--berry)}
#choices button{padding:0 0 7px;min-width:0;display:flex;flex-direction:column;align-items:stretch;gap:5px;overflow:hidden;font:720 clamp(11px,2.65vw,14px)/1.18 var(--rounded);border-color:#e1c9b8;background:#fffdf8}
#choices button[aria-current=true]{outline:3px solid var(--green);outline-offset:0}
.drawer-photo{position:relative;width:100%;aspect-ratio:1.2;overflow:hidden}
.drawer-photo img{position:absolute;max-width:none;object-fit:fill}
.played .drawer-photo::after{content:'✓';position:absolute;right:4px;top:4px;width:20px;height:20px;display:grid;place-items:center;background:var(--green);color:white;border-radius:50%;font-weight:700}
@media(min-width:700px){#choices{grid-template-columns:repeat(4,minmax(0,1fr))}}
@media(max-height:650px){header{height:44px}.heading{padding-block:4px}.caption{min-height:51px}}
@media(orientation:landscape) and (max-height:540px){
 main{width:min(100%,1120px)}#play{display:grid;grid-template-columns:minmax(105px,1fr) minmax(0,3.3fr) minmax(108px,1fr);gap:8px;align-items:center}
 .heading-tools{justify-content:center;flex-wrap:wrap}.heading,.caption{display:flex;flex-direction:column;align-items:center;text-align:center}.heading{padding:0}h1{font-size:clamp(19px,3.2vw,28px)}#stage{height:100%;width:100%}.caption{gap:7px;padding:0}.caption #again,.caption #next{width:52px}
}
@media(prefers-reduced-motion:no-preference){.tape-meter{transform-box:fill-box;transform-origin:center bottom;animation:tape-level .36s ease-in-out 4 alternate}.falling-snow{animation:snow-settle 3.5s ease-out both}}
@keyframes tape-level{from{transform:scaleY(.35)}to{transform:scaleY(1)}}
@keyframes snow-settle{from{transform:translate(-4px,-14px)}45%{transform:translate(3px,1px)}to{transform:translate(0,11px)}}
[hidden]{display:none!important}
