/* VOICE: a kit on the living-room table, playful but technical
   IDEA: motorised construction-kit marble run: black struts, red accents, grey base plate
   PICTURE: the whole 3D run filling the screen, real physics: marbles roll, collide, derail
   COLOUR and TYPE: light studio grey or night anthracite, black, signal red #e3261b; Baloo 2 + Nunito
   LAYOUT: full-screen scene, small title top left, counters top right, control bar at the bottom */
:root{color-scheme:light dark;--bg:#dfe4e8;--ink:#15181b;--panel:rgba(255,255,255,.82);--btn:#eef1f3;--line:rgba(0,0,0,.1);--acc:#e3261b}
@media (prefers-color-scheme:dark){:root:not([data-theme=light]){--bg:#15191d;--ink:#eef1f3;--panel:rgba(24,28,32,.84);--btn:#262c32;--line:rgba(255,255,255,.12)}}
:root[data-theme=light]{color-scheme:light}
:root[data-theme=dark]{color-scheme:dark;--bg:#15191d;--ink:#eef1f3;--panel:rgba(24,28,32,.84);--btn:#262c32;--line:rgba(255,255,255,.12)}
*{box-sizing:border-box;min-width:0}
html,body{margin:0;height:100%;overflow:hidden;background:var(--bg);color:var(--ink);font:16px/1.4 Nunito,system-ui,sans-serif}
@media (prefers-reduced-motion:reduce){*,*::before,*::after{animation:none!important;transition:none!important}}

#c{position:fixed;inset:0;width:100%;height:100%;display:block;touch-action:none}
.fade{transition:opacity .5s,transform .5s}
body.idle .fade{opacity:0;pointer-events:none}
body.idle .ctl{transform:translate(-50%,16px)}
.title{position:fixed;top:10px;left:12px;pointer-events:none}
.title h1{margin:0;font:800 clamp(18px,2.6vw,24px)/1.1 "Baloo 2",system-ui,sans-serif}
.title p{margin:2px 0 0;font-size:13px;opacity:.75;transition:opacity .8s}
.title p.gone{opacity:0}
.stat{position:fixed;top:10px;right:12px;background:var(--panel);border:1px solid var(--line);border-radius:10px;padding:3px 10px;font-weight:700;font-size:13px;white-space:nowrap;backdrop-filter:blur(8px);font-variant-numeric:tabular-nums}
.stat span{display:inline-flex;align-items:center;gap:4px;margin:0 2px}.stat svg{width:14px;height:14px}
.hud{position:fixed;top:42px;right:12px;background:var(--panel);border:1px solid var(--line);border-radius:10px;padding:4px 10px;backdrop-filter:blur(8px);font-variant-numeric:tabular-nums;color:var(--ink);font:inherit;font-size:13px;text-align:left;cursor:pointer}
.hud[hidden]{display:none}
.hud .line{font-weight:700;white-space:nowrap}.hud .line b{font-size:16px;font-weight:800}
.hud .full{display:none;width:136px;margin-top:4px}
.hud.open .line{display:none}.hud.open .full{display:block;margin-top:0}
.hud .big{font-size:28px;font-weight:800;line-height:1}.hud .big small{font-size:13px;font-weight:700}.hud .sub{font-size:12px;opacity:.75;margin-bottom:4px}
.hud dl{display:grid;grid-template-columns:auto 1fr;gap:1px 8px;margin:0;font-size:13px}.hud dt{opacity:.75}.hud dd{margin:0;text-align:right;font-weight:700}.hud .where{margin-top:5px;font-size:12px;font-weight:700;opacity:.85}
#load{position:fixed;inset:0;display:grid;place-items:center;font-weight:700;font-size:17px;pointer-events:none;text-align:center;padding:20px}

.ctl{position:fixed;left:50%;bottom:max(10px,env(safe-area-inset-bottom));transform:translateX(-50%);background:var(--panel);border:1px solid var(--line);border-radius:16px;padding:5px;display:flex;gap:4px;align-items:center;backdrop-filter:blur(10px)}
.ctl>button,.pop button{min-height:44px;min-width:44px;padding:0 10px;border:0;border-radius:11px;background:transparent;color:var(--ink);font:700 15px Nunito,sans-serif;cursor:pointer;white-space:nowrap;display:inline-flex;align-items:center;justify-content:center;gap:7px}
.ctl>button:hover,.pop button:hover{background:var(--btn)}
.ctl svg{width:22px;height:22px;flex:none}
.ctl>button[aria-pressed=true],.ctl>button[aria-expanded=true]{background:var(--btn)}
#snd[aria-pressed=true]{color:var(--acc)}
.ctl>button span{display:none}
@media(min-width:700px){.ctl>button span{display:inline}.ctl>button{padding:0 14px}}
.ctl button:focus-visible,.pop button:focus-visible,.pop input:focus-visible,.hud:focus-visible{outline:3px solid #f5b400;outline-offset:2px}
.pop{position:absolute;bottom:calc(100% + 8px);background:var(--panel);border:1px solid var(--line);border-radius:16px;padding:6px;backdrop-filter:blur(14px);box-shadow:0 8px 30px rgba(0,0,0,.18)}
.pop[hidden],.pop [hidden]{display:none!important}
#camMenu{left:0;display:grid;min-width:200px}
#camMenu button{justify-content:space-between}
#camMenu button[aria-checked=true]{background:var(--acc);color:#fff}
kbd{font:700 12px Nunito,sans-serif;opacity:.6;border:1px solid currentColor;border-radius:5px;padding:0 5px}
@media(hover:none){kbd{display:none}}
#setSheet{left:50%;transform:translateX(-50%);width:min(340px,calc(100vw - 20px));max-height:calc(100vh - 90px);overflow:auto;padding:12px 14px}
#setSheet h2{margin:10px 0 6px;font:800 13px Nunito,sans-serif;text-transform:uppercase;letter-spacing:.06em;opacity:.6}
#setSheet h2:first-child{margin-top:0}
#setSheet label{display:grid;grid-template-columns:62px 1fr 100px;align-items:center;gap:8px;font-size:14px;font-weight:700;min-height:40px}
#setSheet input{width:100%;accent-color:var(--acc)}
#setSheet output{text-align:right;white-space:nowrap;font-variant-numeric:tabular-nums}
@media(max-height:520px) and (min-width:600px){#setSheet{width:min(640px,calc(100vw - 20px));display:grid;grid-template-columns:1fr 1fr;gap:18px}#setSheet[hidden]{display:none}}
.tinfo{margin:0 0 6px;font-size:13px;font-weight:700;opacity:.8}.tinfo.err{color:var(--acc);opacity:1}
.seg{display:flex;background:var(--btn);border-radius:12px;padding:3px;gap:3px}
.seg button{flex:1;min-height:38px;font-size:14px}
.seg button[aria-pressed=true]{background:var(--acc);color:#fff}
