html,body{height:100%;overflow-x:hidden}
#stage{position:fixed;inset:0;z-index:0}#stage canvas{display:block}
#app{position:relative;z-index:1;min-height:100vh;min-height:100dvh;display:flex;flex-direction:column;pointer-events:none}
#app button,#app input,#app .panel,#app table{pointer-events:auto}
header,.screen{text-align:center;padding:0 16px}header h1{margin:12px 0 0}
body.in-battle header,body.in-battle footer{display:none}
.panel{background:var(--c-hud-bg);border:var(--border);border-radius:var(--radius);padding:12px 16px}
.card{max-width:360px;margin:12px auto;text-align:left;background:rgba(8,5,26,.25)}
#preview{height:150px}
.row{display:flex;gap:12px;justify-content:center;margin:12px 0;align-items:center}
.muted{color:var(--c-muted)}.small{font-size:14px}
.chip{border:1px solid var(--c-cyan);border-radius:12px;padding:2px 10px}
#code{font:700 18px var(--font);text-transform:uppercase;width:5em;text-align:center;min-height:48px;background:var(--c-panel);color:var(--c-text);border:var(--border);border-radius:4px}
.brow{display:flex;align-items:center;gap:8px}.brow span{width:6.5em}.brow i{display:block;height:8px;background:var(--c-cyan);box-shadow:var(--glow-cyan)}.brow b{width:1.5em}
.brow .track{flex:1;background:var(--c-panel-2);height:8px}
.code{font-size:36px;color:var(--c-yellow);text-shadow:var(--glow-yellow);letter-spacing:.1em}
#seats{list-style:none;padding:0;display:flex;gap:12px;justify-content:center}
#seats li{border:1px dashed var(--c-muted);padding:12px 16px;border-radius:4px;min-width:5em}
#seats li.you{border:2px solid var(--c-yellow)}#seats li.bot{border:1px solid var(--c-cyan)}
.error{color:var(--c-enemy);min-height:1.4em;text-align:center;margin:0}
.error:not(:empty)::before{content:"⚠ "}
footer{margin-top:auto;padding:16px;text-align:center;font-size:14px;color:var(--c-muted)}
.overlay{position:fixed;inset:0;background:var(--c-bg);z-index:10;display:flex;align-items:center;justify-content:center;text-align:center}
.overlay[hidden]{display:none}
#battle{position:fixed;inset:0;pointer-events:none}
.hud{position:absolute}.tl{top:12px;left:12px}.tc{top:8px;left:50%;transform:translateX(-50%)}.tr{top:12px;right:12px}.bl{bottom:12px;left:12px;width:260px}.bc{bottom:12px;left:50%;transform:translateX(-50%);min-height:24px}.br{bottom:12px;right:12px;background:var(--c-hud-bg);border:var(--border)}
.bcc{top:35%;left:0;right:0;text-align:center;font-size:96px;font-weight:700;color:var(--c-yellow);text-shadow:var(--glow-yellow)}
.timer{font-size:var(--fs-timer);font-weight:700;color:var(--c-yellow);text-shadow:var(--glow-yellow)}
.timer.blink{animation:bl 1s steps(1) infinite}@keyframes bl{50%{opacity:.3}}
#mini{margin:0;padding:0 0 0 1.4em}#mini li.me{background:var(--c-panel-2)}
.bar{height:10px;background:var(--c-panel-2);margin:4px 0}.bar i{display:block;height:100%;background:var(--c-hp);width:100%}
.cd{position:relative;width:120px;height:48px;border:1px solid var(--c-hud-edge);display:flex;align-items:center;justify-content:center;overflow:hidden;border-radius:4px}
.cd i{position:absolute;left:0;right:0;bottom:0;background:rgba(46,230,214,.45);height:0}.cd span{position:relative}
#cdr.ready{border-color:var(--c-yellow)}#cdr.is-illegal{animation:sh .25s}@keyframes sh{25%{transform:translateX(-4px)}75%{transform:translateX(4px)}}
@media (prefers-reduced-motion:reduce){.timer.blink,#cdr.is-illegal{animation:none}}
#results table{border-collapse:collapse;margin:12px auto;min-width:300px}#results td,#results th{padding:6px 12px;text-align:left}
tr.me{outline:3px solid var(--c-yellow);box-shadow:var(--glow-yellow)}
body.in-battle{cursor:crosshair}

/* touch controls (T-0035): shown only on devices with a touch screen */
.tbtn{display:none}
body.in-battle{overscroll-behavior:none}
body.in-battle,body.in-battle #stage,body.in-battle #battle{touch-action:none;-webkit-user-select:none;user-select:none;-webkit-touch-callout:none;-webkit-tap-highlight-color:transparent}
body.in-battle{overflow:hidden;position:fixed;width:100%}
body.touch #battle:not([hidden]) .tbtn{display:flex;position:absolute;width:76px;height:76px;min-width:64px;min-height:64px;border-radius:50%;align-items:center;justify-content:center;pointer-events:auto;touch-action:none;overflow:hidden;font:700 14px var(--font);color:var(--c-text);background:var(--c-hud-bg);border:2px solid var(--c-hud-edge);padding:0;z-index:5}
body.touch .tabil{width:64px;height:64px;right:calc(118px + env(safe-area-inset-right));bottom:calc(130px + env(safe-area-inset-bottom))}
.tbtn.down{background:var(--c-panel-2)}.tbtn.ready{border-color:var(--c-yellow)}
.tbtn i{position:absolute;left:0;right:0;bottom:0;background:rgba(46,230,214,.45);height:0}.tbtn span{position:relative}
body.touch .hud.tl{top:calc(8px + env(safe-area-inset-top));left:calc(8px + env(safe-area-inset-left))}
body.touch .hud.tc{top:calc(6px + env(safe-area-inset-top))}
body.touch .hud.tr{top:calc(8px + env(safe-area-inset-top));right:calc(8px + env(safe-area-inset-right));font-size:12px;padding:4px 8px;max-width:34vw;overflow:hidden}
body.touch .hud.bl{bottom:calc(8px + env(safe-area-inset-bottom));left:calc(8px + env(safe-area-inset-left));width:min(170px,40vw);padding:6px 10px}
body.touch .hud.bl .row{display:none}
body.touch .hud.br{display:none}
body.touch .hud.bc{bottom:calc(60px + env(safe-area-inset-bottom));max-width:50vw}
body.touch .bcc{font-size:64px}
body.touch .timer{font-size:22px}
.hud.rot{display:none;top:calc(46px + env(safe-area-inset-top));left:50%;transform:translateX(-50%);font-size:13px;text-align:center;max-width:60vw}
@media (orientation:portrait){body.touch.in-battle .hud.rot{display:block}body.touch .hud.bl{bottom:calc(8px + env(safe-area-inset-bottom))}}

/* floating stick (T-0040) */
#stick{display:none}
body.touch #battle:not([hidden]) #stick{display:block;position:fixed;width:140px;height:140px;border-radius:50%;left:calc(16px + env(safe-area-inset-left));bottom:calc(16px + env(safe-area-inset-bottom));border:2px solid var(--c-hud-edge);background:var(--c-hud-bg);opacity:.55;pointer-events:none;z-index:4}
body.touch #stick.active{opacity:.85}
#stick i{position:absolute;left:50px;top:50px;width:40px;height:40px;border-radius:50%;background:rgba(46,230,214,.7);border:2px solid var(--c-hud-edge)}
body.touch .hud.bl{left:calc(172px + env(safe-area-inset-left))}
html,body{-webkit-touch-callout:none;-webkit-text-size-adjust:100%}
body.touch{-webkit-user-select:none;user-select:none;-webkit-touch-callout:none}
.music{position:fixed;top:8px;right:8px;z-index:5;display:flex;gap:8px;align-items:center;font-size:14px}.music input[type=range]{width:90px}
body.in-battle .music{display:none}
@media (max-width:700px){.music{position:static;flex-wrap:wrap;justify-content:center;padding:8px 8px 0}}

/* controls hint (T-0042): desktop only; the battle copy fades after 5 s of fight */
.hud.bc2{bottom:96px;left:50%;transform:translateX(-50%);font-size:13px;text-align:center;white-space:nowrap}
body.touch .ctl-hint{display:none}
.hud.bc2.gone{display:none}

/* aiming stick (T-0044): floating, appears under the right thumb; radius 60 px */
#aimstick{display:none}
body.touch #battle:not([hidden]) #aimstick.active{display:block;position:fixed;width:120px;height:120px;border-radius:50%;border:2px solid var(--c-enemy);background:var(--c-hud-bg);opacity:.7;pointer-events:none;z-index:4}
#aimstick i{position:absolute;left:40px;top:40px;width:40px;height:40px;border-radius:50%;background:rgba(255,90,90,.7);border:2px solid var(--c-hud-edge)}
.touch-hint{display:none}
body.touch .touch-hint{display:block;bottom:calc(8px + env(safe-area-inset-bottom));font-size:12px;max-width:60vw;white-space:normal}
body.touch .touch-hint.gone{display:none}

/* T-0068: visible area, no page shift, full screen button, home-screen hint */
:root{--vh:100dvh;--vw:100vw}
.fsbtn{pointer-events:auto}
#fs-battle{display:none}
body.touch #battle:not([hidden]) #fs-battle:not([hidden]){display:flex;position:absolute;top:calc(56px + env(safe-area-inset-top));left:calc(8px + env(safe-area-inset-left));width:auto;height:32px;min-width:0;min-height:0;border-radius:4px;padding:0 10px;font-size:12px;z-index:5}
#fs-battle:not([hidden]){display:flex}
.a2hs{position:fixed;left:50%;transform:translateX(-50%);bottom:calc(8px + env(safe-area-inset-bottom));z-index:8;display:flex;gap:8px;align-items:center;font-size:13px;max-width:min(560px,calc(100vw - 24px));padding:6px 10px;background:var(--c-hud-bg);border:var(--border);border-radius:var(--radius);pointer-events:auto}
.a2hs[hidden]{display:none}
.a2hs .btn{min-height:32px;padding:0 10px;font-size:13px}
html.touch-root,body.touch{overscroll-behavior:none}
body.touch{position:fixed;inset:0;width:100%;height:var(--vh);overflow:hidden}
body.touch #stage{height:var(--vh);width:var(--vw)}
body.touch #app{height:var(--vh);min-height:0;overflow:hidden}
body.touch #battle{height:var(--vh);width:var(--vw)}
/* garage on a phone in landscape: two columns, nothing scrolls */
@media (max-height:520px) and (orientation:landscape){
  body.touch #app{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1fr);grid-template-rows:auto 1fr auto;column-gap:8px;padding:0 calc(8px + env(safe-area-inset-right)) 0 calc(8px + env(safe-area-inset-left))}
  /* hotfix 21.11: these two rules set `display` and used to beat `[hidden]` and `body.in-battle header{display:none}` — the garage and the title stayed on top of the battle on phones */
  body.touch:not(.in-battle) header{grid-column:1/3;display:flex;gap:12px;align-items:baseline;justify-content:center;padding:0}
  body.touch header h1{font-size:20px;margin:2px 0}
  body.touch #home:not([hidden]){grid-column:1/3;display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1fr);gap:0 12px;align-content:center;padding:0;min-height:0}
  body.touch #home>.muted:first-child,body.touch #home .ctl-hint,body.touch #home .glow{display:none}
  body.touch #home .card{grid-row:1/6;margin:0 auto;padding:6px 10px;max-width:none;width:100%;box-sizing:border-box;font-size:12px}
  body.touch #home .card p{margin:2px 0}
  body.touch #preview{height:64px}
  body.touch #home h2{font-size:16px;margin:2px 0}
  body.touch #home .row{margin:4px 0}
  body.touch #home .btn{min-height:40px;font-size:14px;padding:0 10px}
  body.touch #bars .brow{font-size:11px;gap:4px}
  body.touch #bars{display:grid;grid-template-columns:1fr 1fr;gap:0 8px}
  body.touch .music{position:static;grid-column:1/3;justify-content:center;padding:0;font-size:12px;flex-wrap:nowrap}
  body.touch footer{grid-column:1/3;padding:2px 0 calc(2px + env(safe-area-inset-bottom));font-size:11px}
  body.touch .error{grid-column:1/3;min-height:0}
  body.touch #lobby,body.touch #results{grid-column:1/3;overflow:hidden;font-size:13px;padding:0}
  body.touch #lobby h2,body.touch #results h2{margin:2px 0;font-size:18px}
  body.touch #results table{margin:4px auto}body.touch #results td,body.touch #results th{padding:2px 10px}
}
