:root { color-scheme: light; --page:#fbf5ec; --ink:#493c31; --muted:#796c60; --panel:#fffaf2; --hover:#eadecc; }
:root.night { color-scheme:dark; --page:#101722; --ink:#e2e4ee; --muted:#adb4c4; --panel:#252e3b; --hover:#344153; }
* { box-sizing:border-box; }
body { margin:0; min-height:100svh; display:grid; place-items:center; padding:8px 10px; background:var(--page); color:var(--ink); font:1rem/1.5 "Segoe UI","Microsoft YaHei",sans-serif; transition:background .5s,color .5s; }
main { width:min(100%,1200px,calc((100svh - 96px) * 1.62)); }
.stage { position:relative; width:100%; aspect-ratio:1.62; overflow:hidden; isolation:isolate; border-radius:16px; background:#ba9d77; }
.stage { touch-action:none; user-select:none; }
.stage[data-pressed="true"] { cursor:none; }
#scene { display:block; width:100%; height:100%; }
.stage:not([data-ready="true"]) #scene { visibility:hidden; }
#retry { position:absolute; bottom:12px; left:12px; border-radius:8px; background:var(--panel); padding:8px 14px; }
button { -webkit-tap-highlight-color:transparent; font:inherit; color:inherit; border:0; cursor:pointer; }
button:focus-visible,input:focus-visible,.stage:focus-visible { outline:3px solid #bb8344; outline-offset:2px; }
.stage:focus-visible { outline-offset:-4px; border-radius:inherit; }
button svg { width:21px; height:21px; fill:none; stroke:currentColor; stroke-width:1.8; stroke-linecap:round; stroke-linejoin:round; }
.theme,.actions button { display:grid; place-items:center; width:44px; height:44px; border-radius:50%; background:transparent; }
.theme { position:absolute; top:10px; right:10px; z-index:1; background:var(--panel); opacity:.91; }
.toolbar,.actions { display:flex; align-items:center; }
.toolbar { position:relative; justify-content:space-between; padding-top:7px; }
.actions button:hover,.actions button[aria-expanded="true"],.actions button[aria-pressed="true"] { background:var(--hover); }
#guide { color:var(--muted); font-size:.85rem; margin:0 8px 0 2px; }
#settings { position:absolute; right:6px; bottom:calc(100% + 8px); width:min(250px,95%); border-radius:14px; padding:16px 18px; background:var(--panel); box-shadow:0 6px 26px #251b1838; }
label { display:flex; justify-content:space-between; font-size:.9rem; }
output { color:var(--muted); font-variant-numeric:tabular-nums; }
input { width:100%; margin:7px 0 14px; accent-color:#997449; }
#reset { width:100%; border-radius:8px; padding:7px; background:var(--hover); font-size:.88rem; }
.symbols,.sr { position:absolute; width:1px; height:1px; overflow:hidden; clip-path:inset(50%); }
main:fullscreen,main.wide { width:100%; height:100%; padding:8px max(10px,env(safe-area-inset-right)); background:var(--page); display:flex; flex-direction:column; }
main.wide { position:fixed; inset:0; z-index:2; }
main:fullscreen .stage,main.wide .stage { width:min(100%,calc((100dvh - 68px) * 1.62)); align-self:center; flex:none; margin-block:auto; }
@media (max-width:650px) and (orientation:portrait) {
  main { width:100%; }
  .stage { aspect-ratio:1.56; }
  #guide span { display:none; }
}
@media (max-height:450px) and (orientation:landscape) {
  body { padding:3px; }
  main { width:min(100%,calc((100svh - 52px) * 1.62)); }
  .toolbar { padding:0; } #guide span { display:none; }
}
@media (prefers-reduced-motion:reduce) { *,*::after { transition:none!important; } }
