/* ============================================================================
   WASM-4 ARCADE  ·  stylesheet
   ----------------------------------------------------------------------------
   The page is one full-window 3D view (#view) with UI over it: the top bar,
   the HUD (cart name), the Play button, the touch pad, the dock of buttons
   at the base, and a sheet with tabs. Fonts come from ../../lib/sci.css.
   The palette follows pages/sstv (phosphor green accent, warm plastic).

   PHONE FIRST. The dock is one row of icon buttons at the base. The sheet
   is a bottom sheet (max 62 % of the height). On a coarse pointer the
   touch pad shows over the dock. main.js reads the boxes of the dock, the
   pad and the sheet (insets) and the camera frames the TV in the clear
   area above them.
   WIDE (min-width 900 px, landscape). The sheet is a drawer at the right,
   and the dock buttons show their names.
   FLAT. With no WebGL, #flat shows the square CRT canvas of crt.js in the
   clear area instead of #view.
     grep -n 'VIEW'  'HUD'  'DOCK'  'PAD'  'SHEET'  'SHELF'  'FLAT'  'TOUCH'  'WIDE'
   ========================================================================== */
[hidden]{display:none!important}
:root{
  --bg:#05070a; --card:#0b0e14; --card2:#111620;
  --ink:#e8eaf0; --ink2:#c0c6d4; --dim:#858ca2; --faint:#394155;
  --line:rgba(255,255,255,0.075); --line2:rgba(255,255,255,0.15);
  --acc:#7fe0a8; --acc-bg:rgba(127,224,168,0.13); --acc-line:rgba(127,224,168,0.5);
  --plastic:#2b2925; --plastic2:#1b1a18; --warm:#ffb35c;
  --serif:var(--sci-serif,'STIX Two Text',Georgia,serif);
  --sans:var(--sci-sans,Inter,system-ui,-apple-system,sans-serif);
  --mono:var(--sci-mono,ui-monospace,'SF Mono',Menlo,monospace);
  --top:52px; --dock:58px;
  --sl:env(safe-area-inset-left,0px); --sr:env(safe-area-inset-right,0px); --sb:env(safe-area-inset-bottom,0px);
}
*,*::before,*::after{box-sizing:border-box;margin:0;padding:0}
/* overflow-x stays on html only: on the body it breaks position:sticky. */
html{background:var(--bg);overflow-x:hidden;overflow-y:hidden;height:100%;-webkit-text-size-adjust:100%}
body{background:var(--bg);color:var(--ink);font-family:var(--sans);font-size:14px;line-height:1.55;-webkit-font-smoothing:antialiased;height:100%}
html.in-frame{--top:0px}
button,select,input{font-family:inherit;touch-action:manipulation;-webkit-tap-highlight-color:transparent}
button{cursor:pointer}
a{color:var(--acc);text-decoration:none}
@media (hover:hover){a:hover{text-decoration:underline}}
code,kbd{font-family:var(--mono);font-size:0.86em}
kbd{display:inline-block;min-width:1.6em;text-align:center;padding:0 4px;margin:0 1px;border:1px solid var(--line2);border-bottom-width:2px;border-radius:4px;color:var(--ink);background:var(--card2)}

.topbar{position:fixed;top:0;left:0;right:0;height:52px;z-index:30;display:flex;align-items:center;gap:18px;
  padding:0 calc(20px + var(--sr)) 0 calc(20px + var(--sl));background:rgba(5,7,10,0.86);border-bottom:1px solid var(--line);pointer-events:none}
.brand{font:500 0.85rem/1 var(--sans);color:var(--dim);white-space:nowrap}
.pagetitle{font:400 1.1rem/1 var(--serif);color:var(--ink);margin-left:auto;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
html.in-frame .topbar{display:none}

/* ---------------------------------------------------------------- VIEW */
#view{position:fixed;inset:0;width:100vw;height:100vh;height:100dvh;display:block;touch-action:none;outline:none;cursor:grab;background:#10161b}
#view:focus-visible{box-shadow:inset 0 0 0 2px var(--acc-line)}
html.flat #view{display:none}

/* ---------------------------------------------------------------- HUD */
.hud{position:fixed;z-index:20;left:calc(12px + var(--sl));top:calc(var(--top) + 10px);max-width:min(62vw,360px);display:flex;flex-direction:column;align-items:flex-start;gap:1px;
  padding:7px 12px 8px;border-radius:10px;border:1px solid var(--line);background:rgba(8,10,14,0.66);color:var(--ink);text-align:left;
  -webkit-backdrop-filter:blur(6px);backdrop-filter:blur(6px)}
.hud-k{font:500 0.66rem/1.2 var(--sans);color:var(--acc);letter-spacing:0.04em}
.hud-t{font:700 0.86rem/1.25 var(--mono);letter-spacing:0.1em;color:var(--warm);text-shadow:0 0 10px rgba(255,179,92,0.45);max-width:100%;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.hud-b{font:400 0.72rem/1.3 var(--sans);color:var(--ink2);max-width:100%;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.play{position:fixed;z-index:21;left:50%;bottom:calc(var(--dock) + var(--sb) + 22px);transform:translateX(-50%);padding:11px 26px;border-radius:999px;border:1px solid var(--acc-line);
  background:rgba(5,10,8,0.84);color:var(--acc);font:600 0.95rem/1 var(--sans);letter-spacing:0.04em;box-shadow:0 0 18px rgba(127,224,168,0.25)}
@media (hover:hover){.play:hover{background:rgba(20,40,30,0.9)}}
.tip{position:fixed;z-index:25;pointer-events:none;padding:6px 10px;border-radius:8px;background:rgba(8,10,14,0.9);border:1px solid var(--line2);font-size:0.78rem;color:var(--ink);max-width:260px;transform:translate(14px,14px)}
.tip b{display:block;color:var(--warm);font:700 0.8rem var(--mono);letter-spacing:0.06em}

/* ---------------------------------------------------------------- DOCK */
.dock{position:fixed;z-index:22;left:0;right:0;bottom:0;height:calc(var(--dock) + var(--sb));display:flex;align-items:center;justify-content:center;gap:4px;
  padding:0 calc(6px + var(--sr)) var(--sb) calc(6px + var(--sl));background:rgba(8,10,14,0.88);border-top:1px solid var(--line);
  -webkit-backdrop-filter:blur(8px);backdrop-filter:blur(8px)}
.dock button{display:inline-flex;flex-direction:column;align-items:center;justify-content:center;gap:1px;min-width:44px;height:48px;padding:0 6px;border-radius:9px;
  border:1px solid transparent;background:transparent;color:#d8d0c0;font-size:1.05rem;line-height:1}
.dock button span{font-size:0.6rem;color:var(--dim)}
.dock button[aria-pressed="true"]{color:var(--acc)}
.dock button[aria-expanded="true"]{background:var(--acc-bg);border-color:var(--acc-line)}
#power[aria-pressed="false"]{color:#ff6a5c}
@media (hover:hover){.dock button:hover{background:rgba(255,255,255,0.06)}}

/* ---------------------------------------------------------------- PAD */
.pad{display:none;position:fixed;z-index:21;left:0;right:0;bottom:calc(var(--dock) + var(--sb));align-items:center;justify-content:space-between;gap:18px;
  padding:10px calc(18px + var(--sr)) 12px calc(18px + var(--sl));user-select:none;-webkit-user-select:none;pointer-events:none}
.pad>*{pointer-events:auto}
.dpad{position:relative;width:132px;height:132px;border-radius:50%;touch-action:none;background:radial-gradient(circle,rgba(26,25,23,0.9) 55%,rgba(15,14,13,0.9) 100%);box-shadow:inset 0 2px 6px rgba(0,0,0,0.7),0 4px 14px rgba(0,0,0,0.4)}
.dpad .arm{position:absolute;background:linear-gradient(180deg,#3a3833,#22211e);border-radius:8px;box-shadow:0 2px 3px rgba(0,0,0,0.6)}
.dpad .h{left:12px;right:12px;top:50%;height:42px;transform:translateY(-50%)}
.dpad .v{top:12px;bottom:12px;left:50%;width:42px;transform:translateX(-50%)}
.dpad .hub{position:absolute;left:50%;top:50%;width:20px;height:20px;transform:translate(-50%,-50%);border-radius:50%;background:radial-gradient(circle,#2a2925,#1a1917)}
.ab{display:flex;gap:14px;transform:rotate(-18deg)}
.ab button{width:64px;height:64px;border-radius:50%;border:1px solid rgba(0,0,0,0.7);touch-action:none;
  background:radial-gradient(circle at 35% 30%,#ffb35c,#b8611a);color:#2a1300;font:700 1.05rem var(--mono);box-shadow:0 4px 6px rgba(0,0,0,0.6),inset 0 1px 0 rgba(255,255,255,0.25)}
.ab button.down{transform:translateY(2px);box-shadow:0 1px 2px rgba(0,0,0,0.6)}
html.pad-on .pad{display:flex}
html.sheet-open .pad{display:none!important}

/* ---------------------------------------------------------------- SHEET */
.sheet{position:fixed;z-index:24;left:0;right:0;bottom:calc(var(--dock) + var(--sb));max-height:62vh;max-height:62dvh;display:flex;flex-direction:column;
  background:rgba(11,14,20,0.97);border-top:1px solid var(--line2);border-radius:16px 16px 0 0;box-shadow:0 -10px 30px rgba(0,0,0,0.5)}
.sheet-head{display:flex;align-items:center;gap:8px;padding:8px calc(10px + var(--sr)) 6px calc(10px + var(--sl));border-bottom:1px solid var(--line)}
.tabs{display:flex;gap:4px;overflow-x:auto;flex:1;scrollbar-width:none}
.tabs button{flex:0 0 auto;height:36px;padding:0 13px;border-radius:999px;border:1px solid var(--line2);background:transparent;color:var(--ink2);font-size:0.82rem}
.tabs button[aria-selected="true"]{background:var(--acc-bg);border-color:var(--acc-line);color:var(--acc)}
.close{width:40px;height:40px;border-radius:50%;border:1px solid var(--line2);background:transparent;color:var(--ink2);font-size:0.95rem}
.sheet-body{overflow-y:auto;-webkit-overflow-scrolling:touch;overscroll-behavior:contain;padding:12px calc(16px + var(--sr)) 18px calc(16px + var(--sl))}
.panel h2{font:400 1.3rem/1.2 var(--serif);margin:2px 0 8px}
.panel p{color:var(--ink2);margin-bottom:10px}
.panel>p:not(.kicker):not(.status):not(.tubekind):not(.hint){font:400 0.98rem/1.6 var(--serif)}
.lead{font-size:0.9rem}
.kicker{font-size:0.78rem;font-weight:500;color:var(--acc);margin-bottom:0!important}
#info h1{font:400 clamp(1.4rem,4vw,1.9rem)/1.15 var(--serif);margin:2px 0 4px}
.by{color:var(--ink2)}
.ctl{font-size:0.86rem}
.ctl b{color:var(--dim);font-weight:500;margin-right:6px}
.links{font-size:0.86rem}
.status{color:var(--warm);font-size:0.86rem;min-height:1em}
.hint{font-size:0.8rem;color:var(--dim);line-height:1.9}
.tubekind{font:400 0.72rem var(--mono);color:var(--faint)}
.str{display:flex;align-items:center;gap:10px;margin:4px 0 12px;color:var(--ink2);font-size:0.84rem;min-height:40px}
.str input{flex:1;accent-color:var(--acc);min-width:80px}
.str input:disabled{opacity:0.35}
.str output{font:500 0.76rem var(--mono);color:var(--dim);min-width:3.4em;text-align:right}

/* ---------------------------------------------------------------- SHELF */
.shelf{display:grid;grid-template-columns:repeat(auto-fill,minmax(112px,1fr));gap:10px;padding:2px 0 8px}
.cart{display:flex;flex-direction:column;align-items:stretch;gap:4px;padding:8px 8px 9px;border-radius:8px 8px 4px 4px;text-align:left;
  border:1px solid rgba(0,0,0,0.6);background:linear-gradient(180deg,#4a4740,#2e2c28 12%,#26241f);color:var(--ink);
  box-shadow:0 4px 10px rgba(0,0,0,0.5),inset 0 1px 0 rgba(255,255,255,0.12)}
.cart .label{width:100%;aspect-ratio:1/1;image-rendering:pixelated;border-radius:3px;background:#0d0c0b;border:2px solid #d8d0c0}
.cart .ct{font:600 0.8rem/1.25 var(--sans);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.cart .cb{font:400 0.68rem/1.3 var(--sans);color:var(--dim);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.cart.on{outline:2px solid var(--acc);outline-offset:2px}
@media (hover:hover){.cart:hover{transform:translateY(-2px)}}
.own{position:relative;display:flex;flex-wrap:wrap;align-items:center;gap:6px 10px;margin-top:12px;padding:12px 14px;border:1px dashed var(--line2);border-radius:12px;cursor:pointer}
.own input{position:absolute;opacity:0;width:1px;height:1px}
.own span{color:var(--acc);font-weight:600}
.own small{color:var(--dim);font-size:0.8rem}
.own:focus-within{border-color:var(--acc-line)}
.tbl{overflow-x:auto;border:1px solid var(--line);border-radius:12px}
table{border-collapse:collapse;width:100%;font-size:0.82rem}
th,td{padding:7px 10px;text-align:left;border-bottom:1px solid var(--line);white-space:nowrap}
th{color:var(--dim);font-weight:500}

/* ---------------------------------------------------------------- FLAT */
.flat{position:fixed;inset:var(--top) 0 calc(var(--dock) + var(--sb)) 0;display:grid;place-items:center;padding:12px}
#tube{width:min(92vw,calc(100dvh - var(--top) - var(--dock) - 40px));aspect-ratio:1/1;display:block;touch-action:none;outline:none;cursor:crosshair}
html.pad-on .flat,html.coarse .flat{bottom:calc(var(--dock) + var(--sb) + 160px)}

/* ---------------------------------------------------------------- TOUCH */
@media (pointer:coarse){
  .pad{display:flex}
  .hint{display:none}
  .dock button span{display:none}
  .dock button{min-width:42px}
}
@media (max-width:420px){
  .dock{gap:0}
  .dock button{min-width:40px;padding:0 3px}
}

/* ---------------------------------------------------------------- WIDE */
@media (min-width:900px) and (min-aspect-ratio:1/1){
  .sheet{left:auto;right:0;top:var(--top);bottom:calc(var(--dock) + var(--sb));width:min(420px,40vw);max-height:none;border-radius:0;border-top:0;border-left:1px solid var(--line2)}
  .dock{gap:6px}
  .dock button{min-width:56px}
}
html.pseudo-fs .topbar{display:none}
html.pseudo-fs{--top:0px}
