/* v13 UI theme: Space Grotesk (OFL, self-hosted), glassy dark panels, glow accents. Loaded last on every page. */
@font-face{font-family:'Space Grotesk';src:url('/lib/fonts/SpaceGrotesk-var.woff2') format('woff2');font-weight:300 700;font-display:swap}
:root{--glass:rgba(12,10,30,.55);--line:rgba(120,240,255,.35);--glow:0 0 12px rgba(34,240,255,.25);--txt:#e6fbff;--acc:#22f0ff;--pink:#ff3df0}
body,button,select,input,a.btn{font-family:'Space Grotesk',system-ui,sans-serif!important;letter-spacing:.02em}
button,select,input,.btn,#hud,#dist,#tokens,.keys,.guide,#texit,#tpad button{color:var(--txt)}
button,select,input,.btn,.hudtog,#snd,#skintag,#aura,#walletBtn,#texit{appearance:none;-webkit-appearance:none;background:var(--glass)!important;border:1px solid var(--line)!important;border-radius:12px!important;
 backdrop-filter:blur(10px);-webkit-backdrop-filter:blur(10px);box-shadow:var(--glow);font-size:12px!important;font-weight:600;padding:6px 12px;cursor:pointer;transition:background .15s,box-shadow .15s}
button:hover,select:hover,.btn:hover{background:rgba(34,240,255,.16)!important;box-shadow:0 0 16px rgba(34,240,255,.45)}
select{padding-right:26px;background-image:linear-gradient(45deg,transparent 50%,var(--acc) 50%),linear-gradient(135deg,var(--acc) 50%,transparent 50%)!important;background-position:calc(100% - 14px) 50%,calc(100% - 9px) 50%!important;background-size:5px 5px!important;background-repeat:no-repeat!important}
select option{background:#0c0a1e;color:var(--txt)}
#hud,#dist,#tokens,.box,#panel .box,#gallery .gtop,#bound .bbox,#warp,#call,[class*=hint],[id*=hint],[id*=prompt]{background:var(--glass);border:1px solid var(--line);border-radius:14px;backdrop-filter:blur(12px);-webkit-backdrop-filter:blur(12px);box-shadow:var(--glow)}
#hud,#dist,#tokens{padding:4px 10px;font-size:12px}
.box h1,h1,h2{font-weight:700;letter-spacing:.04em;text-shadow:0 0 14px rgba(34,240,255,.45)}
#tpad button{font-family:'Space Grotesk',sans-serif;backdrop-filter:blur(6px);box-shadow:var(--glow)}
#tpad button{border-radius:50%!important;padding:0!important}#tpad .s-l1,#tpad .s-r1{border-radius:17px!important}
#gclose,#nclose{min-height:44px;font-size:13px!important}
:root{--hud-scale:1;--hud-op:.55}
#hub,#hud,.hudtog,#skintag,#aura,#walletBtn,#joy,#keys,#texit{opacity:var(--hud-op);transition:opacity .15s}
#hub:active,#hud:active,.hudtog:active,#skintag:active,#aura:active,#walletBtn:active,#joy:active,#hub:focus-within{opacity:1}
#hub{zoom:var(--hud-scale)}#joy{transform:scale(var(--hud-scale));transform-origin:bottom left}
#hudset{position:fixed;right:10px;top:40px;z-index:40;width:220px;padding:12px;display:none;background:var(--glass);border:1px solid var(--line);border-radius:14px;backdrop-filter:blur(12px);color:var(--txt);font:500 12px 'Space Grotesk',sans-serif}
#hudset.on{display:block}#hudset label{display:block;margin:6px 0}#hudset input{width:100%;padding:0;accent-color:var(--acc);box-shadow:none;background:none!important;border:0!important}
/* v14 polish-preview */
.gcard,#mpanel,#hudset,#callpop,#skinpanel{background:var(--glass)!important;border:1px solid var(--line)!important;border-radius:14px!important;backdrop-filter:blur(12px);-webkit-backdrop-filter:blur(12px);box-shadow:var(--glow);color:var(--txt);font:500 13px/1.4 'Space Grotesk',sans-serif}
.gcard b,#mpanel b{font-size:14px;letter-spacing:.04em}.gsub{font-size:11px;opacity:.7;margin:4px 0 8px}
#tvhint{display:none!important}
#pchip{position:fixed;left:50%;bottom:22%;transform:translate(-50%,6px);display:flex;gap:8px;align-items:center;padding:6px 12px 6px 6px;border-radius:999px;background:var(--glass);border:1px solid var(--line);backdrop-filter:blur(10px);color:var(--txt);font:600 14px 'Space Grotesk',sans-serif;opacity:0;transition:opacity .2s,transform .2s;pointer-events:none;z-index:20}
#pchip.on{opacity:1;transform:translate(-50%,0)}#pchip kbd{display:inline-grid;place-items:center;min-width:24px;height:24px;border-radius:7px;background:var(--txt);color:#0c0a1e;font:700 13px 'Space Grotesk',sans-serif;box-shadow:0 2px 0 rgba(0,0,0,.4)}
#hub{right:10px!important;top:10px!important}#mmrow{order:2;margin:2px 0 0!important}#mmrow button,#mmrow #mic{padding:2px 8px!important;font-size:11px!important;min-height:24px!important}
#hudset{top:auto!important;bottom:16px;right:180px!important}
#wallet{top:auto!important;bottom:10px;right:auto!important;left:50%;transform:translateX(-50%);text-align:center!important}
#tnbadge{position:fixed;top:8px;left:50%;transform:translateX(-50%);z-index:60;padding:3px 12px;border-radius:999px;background:rgba(255,170,0,.85);color:#1a1000;font:700 11px 'Space Grotesk',sans-serif;letter-spacing:.12em;pointer-events:none}
.wpick hr{width:100%;border:0;border-top:1px solid rgba(120,240,255,.25);margin:2px 0}.wmn{margin:4px 0 0;padding-left:16px;max-height:140px;overflow:auto;font-size:11px;text-align:left}
.wpick{padding:10px;margin-bottom:6px;display:flex;flex-direction:column;gap:6px;width:240px}.wpick input{width:100%;box-sizing:border-box}
#mpanel{position:fixed;right:10px;top:250px;width:230px;padding:12px;display:none;z-index:41}#mpanel.on{display:block}#mpanel p{margin:4px 0}#mnow{font-size:12px;opacity:.85;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.mpick{display:inline-block;padding:6px 12px;border:1px solid var(--line);border-radius:12px;cursor:pointer;font-weight:600}.mrow{display:flex;gap:6px;align-items:center;margin-top:6px}.mrow input{flex:1;padding:0!important;box-shadow:none;background:none!important;border:0!important;accent-color:var(--acc)}
#tpad button{width:58px!important;height:58px!important;touch-action:none;background:rgba(6,24,40,.28)!important;opacity:.5}#tpad button:active,#tpad button.on{opacity:1;background:rgba(34,240,255,.4)!important}#tpad{transform:none!important}#tpad .s-bottom{width:64px!important;height:64px!important}#tpad .s-l1,#tpad .s-r1{width:76px!important;height:36px!important}
.hsave{margin:10px 0 6px;padding-top:8px;border-top:1px solid var(--line);display:flex;flex-wrap:wrap;gap:6px;align-items:center}.hsave b{width:100%}.hsave .gsub{width:100%;margin:2px 0 0}
/* v14b: HUD ~75%, right-aligned; fixed comfy joystick; egg card; portrait fixes */
:root{--hud-scale:.75}#hub{align-items:flex-end!important;right:8px!important}
#joy{--j:clamp(110px,18vmin,160px);width:var(--j)!important;height:var(--j)!important;transform:none!important}
#knob{width:calc(var(--j)*.36)!important;height:calc(var(--j)*.36)!important;left:calc(var(--j)*.32)!important;top:calc(var(--j)*.32)!important}
#tstick{width:clamp(110px,18vmin,160px)!important;height:clamp(110px,18vmin,160px)!important;transform:none!important}
#eggcard{position:fixed;left:50%;top:auto;bottom:12%;transform:translateX(-50%);max-width:min(420px,86vw);padding:12px 16px;display:none;z-index:42;text-align:center}#eggcard.on{display:block}#eggcard p{margin:6px 0 0}
@media (orientation:portrait){#hub{zoom:calc(var(--hud-scale)*.8)!important}#minimap{width:120px!important;height:120px!important}#hub .guide,#hub .keys{display:none}}
#dist:empty{display:none}#hudset #snd{position:static;display:block;margin:4px 0}
/* v15: keep TEST CALL clear of the touch joystick in fullscreen / short landscape */
:fullscreen #calltest,:fullscreen~* #calltest{top:calc(10px + env(safe-area-inset-top));left:auto;right:auto}
@media (max-height:600px){#calltest{top:calc(10px + env(safe-area-inset-top))!important;left:calc(178px + env(safe-area-inset-left))!important}}
html:fullscreen #calltest{top:calc(10px + env(safe-area-inset-top))!important;left:calc(178px + env(safe-area-inset-left))!important}
@media (orientation:portrait){body.touch #tpad{bottom:calc(66px + env(safe-area-inset-bottom))!important}#tnbadge{top:auto;bottom:calc(8px + env(safe-area-inset-bottom));left:12px;transform:none;font-size:9px}}
@media (max-height:500px) and (orientation:landscape){#tpad{height:190px!important;width:200px!important}#tpad .s-top{top:0!important}#tpad .s-left,#tpad .s-right{top:60px!important}#tpad .s-bottom{top:122px!important}#tpad .s-l1,#tpad .s-r1{left:-86px!important}#tpad .s-l1{top:100px!important}#tpad .s-r1{top:150px!important}}

/* v15b: any fullscreen (API, browser F11/PWA, any element) moves TEST CALL off the joystick */
@media (display-mode:fullscreen){#calltest{top:calc(10px + env(safe-area-inset-top))!important;left:calc(178px + env(safe-area-inset-left))!important}}
html.isfs #calltest{top:calc(10px + env(safe-area-inset-top))!important;left:calc(178px + env(safe-area-inset-left))!important}
/* v15b: skin picker fits the viewport (fullscreen, phone landscape): capped height + inner scroll, whole thumbnails */
#skinpanel{top:max(86px,calc(10px + env(safe-area-inset-top)));left:calc(14px + env(safe-area-inset-left));max-width:calc(100vw - 28px - env(safe-area-inset-left) - env(safe-area-inset-right));max-height:calc(100dvh - 96px - env(safe-area-inset-bottom));overflow-y:auto;overscroll-behavior:contain;box-sizing:border-box}
.skintile img{aspect-ratio:16/10;object-fit:contain!important;background:#0b0820}
@media (max-height:600px){#skinpanel{top:calc(48px + env(safe-area-inset-top));max-height:calc(100dvh - 58px - env(safe-area-inset-top) - env(safe-area-inset-bottom))}}
.wspin{display:inline-block;width:14px;height:14px;border:2px solid rgba(111,247,255,.3);border-top-color:#6ff7ff;border-radius:50%;animation:wsp .8s linear infinite;vertical-align:middle}@keyframes wsp{to{transform:rotate(360deg)}}
/* v17 thumb-size touch controls: action buttons 60-64px, >=12px gaps, stick >=120px */
body #tpad{width:216px!important;height:262px!important}
body #tpad button{width:60px!important;height:60px!important}
body #tpad .s-top{left:78px!important;top:56px!important}body #tpad .s-left{left:0!important;top:128px!important}body #tpad .s-right{left:156px!important;top:128px!important}
body #tpad .s-bottom{left:76px!important;top:198px!important;width:64px!important;height:64px!important}
body #tpad .s-l1,body #tpad .s-r1{top:0!important;width:96px!important;height:44px!important;border-radius:22px!important}body #tpad .s-l1{left:0!important}body #tpad .s-r1{left:120px!important}
body #tstick{width:clamp(124px,20vmin,160px)!important;height:clamp(124px,20vmin,160px)!important}
body #tstick i{left:calc(50% - 22px)!important;top:calc(50% - 22px)!important;width:44px!important;height:44px!important}
