/* VOICE  playful 1-bit arcade on a sunny afternoon desk
   IDEA   a 1984 compact computer running the game, a thermal receipt printer beside it
   PICTURE the machine itself: a real Normie inside the CRT, your receipt rising out of the printer
   COLOUR+TYPE greys only, paper #f1f1ec and ink #151515; Silkscreen pixels + IBM Plex Mono
   LAYOUT the TV leads; on phones a full-screen play mode with a paddle controller under it */

@font-face { font-family: 'Silkscreen'; font-style: normal; font-weight: 400; font-display: swap; src: url('/fonts/silkscreen-400.woff2') format('woff2'); }
@font-face { font-family: 'Silkscreen'; font-style: normal; font-weight: 700; font-display: swap; src: url('/fonts/silkscreen-700.woff2') format('woff2'); }
@font-face { font-family: 'IBM Plex Mono'; font-style: normal; font-weight: 400; font-display: swap; src: url('/fonts/plex-mono-400.woff2') format('woff2'); }
@font-face { font-family: 'IBM Plex Mono'; font-style: normal; font-weight: 600; font-display: swap; src: url('/fonts/plex-mono-600.woff2') format('woff2'); }

:root { color-scheme: light; --ink: #151515; --paper: #f1f1ec; --desk: #232322; }
* { box-sizing: border-box; min-width: 0; }
html, body { margin: 0; }
body { background: var(--desk); color: var(--ink); font: 15px/1.55 'IBM Plex Mono', ui-monospace, Menlo, monospace; overflow-x: clip; -webkit-tap-highlight-color: transparent; -webkit-text-size-adjust: 100%; }
body.lock { overflow: hidden; }
button, a, input { touch-action: manipulation; }
/* Touch screens: the page never zooms, it only pans. A pinch would leave the
   player stuck in play mode, where every touch belongs to the game. Safari
   ignores user-scalable=no, but touch-action without pinch-zoom is honoured
   (iOS 13+, Android). Scroll containers restart the touch-action chain, so
   the sheets repeat it; buttons and links use pan-x pan-y as well. Double-tap
   zoom is already off at scale 1 thanks to width=device-width, and comes back
   once zoomed, which helps a player zoom out. Mouse devices are untouched. */
html { min-height: 100%; }
@media (pointer: coarse) {
  html, button, a, input, .sheet, .panel { touch-action: pan-x pan-y; }
}
/* If the page is zoomed anyway (an old tab, a browser setting), give the
   gestures back so the player can pinch out. public/js/touch.js sets .zoomed. */
html.zoomed, html.zoomed body, html.zoomed button, html.zoomed a, html.zoomed input,
html.zoomed .sheet, html.zoomed .panel, html.zoomed #cv, html.zoomed .ctl-pad { touch-action: auto; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.noscript { color: #fff; text-align: center; padding: 20px; }

/* ---------- scene ---------- */
/* The whole page is one screen: header, the TV and the printer, one row of keys.
   The TV takes whatever height is left (container units on .rig or .tvbox). */
.scene {
  --gap: clamp(20px, 2.4vw, 34px);
  --cp: clamp(12px, 2.6vw, 26px); /* case padding */
  --bp: clamp(8px, 1.8vw, 18px); /* bezel padding */
  --chin: 46px;
  --foot: 16px;
  --prnw: 240px;
  /* The case adds these around the 4:3 picture. */
  --tvx: calc(2 * var(--cp) + 2 * var(--bp));
  --tvy: calc(var(--cp) + 2 * var(--bp) + var(--chin) + var(--foot));
  display: grid;
  grid-template-columns: minmax(12px, 1fr) minmax(0, 1440px) minmax(12px, 1fr);
  grid-template-rows: auto minmax(0, 1fr) auto;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  overflow: clip;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) 0 env(safe-area-inset-left);
}
.bgw { grid-area: 1 / 1 / 3 / -1; position: relative; overflow: hidden; background: linear-gradient(180deg, #a7a6a0 0%, #c1c0ba 40%, #cfcec8 100%); }
.bgw::before, .bgw::after { content: ''; position: absolute; top: -20%; height: 150%; pointer-events: none; background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .3) 18%, rgba(255, 255, 255, .3) 82%, transparent); transform: skewX(-24deg); filter: blur(10px); }
.bgw::before { left: 52%; width: 22%; }
.bgw::after { left: 79%; width: 11%; }
.bgd { grid-area: 3 / 1 / -1 / -1; background: linear-gradient(180deg, #3b3a38 0, #272625 26px, #1c1b1a 100%); border-top: 1px solid #5d5c58; }

.top { grid-area: 1 / 2 / 2 / 3; position: relative; z-index: 2; display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 8px 18px; padding: 14px 0 12px; }
.plaque { background: #0d0d0d; padding: 7px 11px; border-radius: 5px; box-shadow: -8px 10px 18px -8px rgba(0, 0, 0, .45), inset 0 0 0 1px #2b2b2b; line-height: 0; }
.plaque svg { display: block; height: clamp(28px, 3.2vw, 36px); width: auto; }
.tag { margin: 0; font: 700 14px/1.4 Silkscreen, monospace; color: #2a2a29; }
.credit { margin: 0; font: 400 13px/1 Silkscreen, monospace; color: #2f2f2c; letter-spacing: .02em; white-space: nowrap; }
.credit b { font-weight: 700; color: #151515; font-size: 15px; }
/* The Normies project: small badges that match the plaque. */
.links { display: flex; gap: 8px; }
.chip { position: relative; display: inline-flex; align-items: center; gap: 7px; height: 30px; padding: 0 11px; border-radius: 6px; background: #151515; color: #f1f1ec; font: 600 12px/1 'IBM Plex Mono', monospace; text-decoration: none; white-space: nowrap; box-shadow: -5px 7px 12px -7px rgba(0, 0, 0, .5); }
.chip svg { width: 13px; height: 13px; flex: none; fill: currentColor; }
.chip:hover { background: #2c2c2a; }
.chip:focus-visible { outline: 3px solid #151515; outline-offset: 2px; }
/* Small things to tap get a bigger invisible target. */
.chip::after, .install::after { content: ''; position: absolute; inset: -7px -3px; }
/* Phones only, and quiet: an outlined pill that doesn't compete with the game. */
.install { position: relative; display: inline-flex; align-items: center; gap: 6px; min-height: 30px; padding: 0 11px 0 9px; border: 1.5px solid rgba(21, 21, 21, .32); border-radius: 15px; background: rgba(255, 255, 255, .16); color: #3a3a37; font: 600 12px/1 'IBM Plex Mono', monospace; cursor: pointer; }
.install[hidden] { display: none; }
.install svg { width: 14px; height: 14px; flex: none; }
.install:focus-visible { outline: 3px solid #151515; outline-offset: 3px; }
body.play .install, body.play .links { display: none; }

/* ---------- the TV ---------- */
.rig { grid-area: 2 / 2 / 3 / 3; position: relative; z-index: 1; container-type: size; display: flex; justify-content: center; align-items: flex-end; gap: var(--gap); margin-bottom: -18px; }
.tvbox { display: contents; }
/* Browsers without container query units (iOS < 16, Chrome < 105) get a close
   estimate from the viewport; the others fit the TV to the exact room left. */
.mac { position: relative; flex: none; width: min(1100px, calc(100vw - 300px), calc((100vh - 270px) * 4 / 3 + 88px)); }
@supports (width: 1cqw) {
  .mac { width: min(1100px, 100cqw - var(--prnw) - var(--gap), (100cqh - var(--tvy)) * 4 / 3 + var(--tvx)); }
}
.case { background: linear-gradient(165deg, #ebe9e1, #d3d0c6 62%, #c6c3b8); border-radius: 24px 24px 12px 12px; padding: var(--cp) var(--cp) 0; box-shadow: inset 2px 3px 0 rgba(255, 255, 255, .75), inset -3px -5px 12px rgba(0, 0, 0, .16), -34px 30px 54px -22px rgba(0, 0, 0, .6); }
.bezel { position: relative; background: linear-gradient(180deg, #b7b4a9, #cbc8be 30%, #cfccc2); border-radius: 22px; padding: var(--bp); box-shadow: inset 0 6px 14px rgba(0, 0, 0, .42), inset 0 -2px 0 rgba(255, 255, 255, .6), inset 0 0 0 1px rgba(0, 0, 0, .1); }
.screen { position: relative; aspect-ratio: 4 / 3; border-radius: 5.5% / 7.4%; overflow: hidden; background: #0e100f; box-shadow: 0 0 0 2px #6f6c63, 0 0 0 4px #a9a599, 0 2px 0 4px rgba(255, 255, 255, .35); container-type: inline-size; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.screen canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
#crt { pointer-events: none; }
#cv { touch-action: none; outline: none; cursor: pointer; }
.screen.gl #cv { opacity: 0; }
.screen:not(.gl) #crt { display: none; }
.screen:not(.gl)::before { content: ''; position: absolute; inset: 0; z-index: 1; pointer-events: none; background: radial-gradient(130% 100% at 50% 50%, transparent 60%, rgba(0, 0, 0, .26) 100%), repeating-linear-gradient(0deg, rgba(0, 0, 0, .06) 0 1px, transparent 1px 3px); }
.screen::after { content: ''; position: absolute; inset: 0; z-index: 3; pointer-events: none; border-radius: inherit; box-shadow: inset 0 0 28px 6px rgba(0, 0, 0, .55), inset 0 0 3px 1px rgba(0, 0, 0, .8); background: radial-gradient(ellipse 58% 38% at 27% 16%, rgba(255, 255, 255, .17), rgba(255, 255, 255, 0) 70%), linear-gradient(112deg, rgba(255, 255, 255, 0) 56%, rgba(255, 255, 255, .07) 60%, rgba(255, 255, 255, .02) 66%, rgba(255, 255, 255, 0) 70%), radial-gradient(ellipse 40% 12% at 50% 101%, rgba(255, 255, 255, .08), rgba(255, 255, 255, 0) 70%); }
.screen:focus-within { box-shadow: 0 0 0 2px #6f6c63, 0 0 0 4px #151515; }
.nick { position: absolute; left: 10%; width: 80%; top: 67.4%; height: 10.5%; display: none; z-index: 2; margin: 0; padding: 0 4px; background: #fbfbf8; border: 2px solid #151515; border: max(2px, .5cqw) solid #151515; border-radius: 3px; box-shadow: inset 0 2px 0 rgba(0, 0, 0, .08); color: var(--ink); caret-color: var(--ink); font: 700 18px/1 Silkscreen, monospace; font: 700 max(16px, 3.4cqw)/1 Silkscreen, monospace; text-align: center; outline: none; -webkit-user-select: text; user-select: text; }
.nick::placeholder { color: #6a6a66; opacity: 1; }
/* The empty box pulses until it is used; a press on Print without a name shakes it. */
.nick:placeholder-shown:not(:focus):not(:read-only) { animation: nick-call 1.2s ease-in-out infinite; }
/* Once printed it can't change: a tap goes through to the screen (play again). */
.nick:read-only { pointer-events: none; }
.nick:focus { box-shadow: inset 0 2px 0 rgba(0, 0, 0, .08), 0 0 0 4px rgba(21, 21, 21, .2); }
.nick.ask { animation: nick-shake .45s ease-in-out; }
@keyframes nick-call { 50% { box-shadow: inset 0 2px 0 rgba(0, 0, 0, .08), 0 0 0 5px rgba(21, 21, 21, .25); } }
@keyframes nick-shake { 20%, 60% { transform: translateX(-2%); } 40%, 80% { transform: translateX(2%); } }
body.over .nick { display: block; }
.pmenu { position: absolute; inset: 0; z-index: 4; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 10px; gap: max(8px, 1.6cqw); padding-bottom: 9%; }
.pmenu[hidden] { display: none; }
.pmenu button { min-width: min(240px, 48%); min-height: 44px; padding: 0 14px; border: 2px solid var(--ink); border-radius: 10px; background: var(--paper); color: var(--ink); font: 700 14px/1 Silkscreen, monospace; font: 700 max(13px, 2.4cqw)/1 Silkscreen, monospace; cursor: pointer; }
.pmenu button.primary { background: var(--ink); color: var(--paper); }
.pmenu button:focus-visible { outline: 3px solid var(--ink); outline-offset: 2px; }
.chin { display: flex; align-items: center; gap: 14px; height: var(--chin); padding: 0 6px 2px; }
.badge { font: 700 11px Silkscreen, monospace; color: #7b786f; text-shadow: 0 1px 0 rgba(255, 255, 255, .7); }
.slot { flex: 0 0 32%; height: 9px; border-radius: 5px; margin-left: auto; background: #34332f; box-shadow: inset 0 2px 3px #000, 0 1px 0 rgba(255, 255, 255, .8); }
.pwr { flex: none; display: grid; place-items: center; width: 32px; height: 32px; margin: -11px -10px -11px -6px; padding: 0; border: 0; border-radius: 50%; background: none; cursor: pointer; }
.pwr:focus-visible { outline: 2px solid #151515; outline-offset: -4px; }
.led { width: 9px; height: 9px; border-radius: 50%; background: #fff; box-shadow: 0 0 0 2px #9a978d, 0 0 10px 2px rgba(255, 255, 255, .9); transition: background .2s, box-shadow .2s; }
/* Standby: a dim LED that breathes until someone presses power. */
body:not(.tv-on) .led { background: #8f8c83; box-shadow: 0 0 0 2px #9a978d; animation: standby 2.4s ease-in-out infinite; }

/* ---------- power ---------- */
.screen.off #cv { opacity: 0; }
.screen.off .pmenu, .screen.off .nick { display: none !important; }
.power-on { position: absolute; inset: 0; z-index: 2; display: none; flex-direction: column; align-items: center; justify-content: center; gap: 14px; gap: max(10px, 2.2cqw); margin: 0; padding: 0; border: 0; border-radius: inherit; background: transparent; color: #a3a6a2; font: 700 14px/1 Silkscreen, monospace; font: 700 max(11px, 2.6cqw)/1 Silkscreen, monospace; cursor: pointer; }
.screen.off .power-on { display: flex; }
.power-on svg { width: 44px; height: 44px; width: max(30px, 7.5cqw); height: max(30px, 7.5cqw); }
.power-on svg, .power-on span { animation: standby-soft 2.4s ease-in-out infinite; }
.power-on:focus-visible { outline: none; }
.power-on:focus-visible span { outline: 2px solid #a3a6a2; outline-offset: 6px; }
@keyframes standby { 50% { opacity: .3; } }
/* The words on the dark screen never fade below a readable contrast. */
@keyframes standby-soft { 50% { opacity: .62; } }
/* Without WebGL the plain canvas does the switch-on and switch-off itself. */
.screen:not(.gl).warming #cv { animation: tube-on 1s cubic-bezier(.25, .8, .3, 1) both; }
.screen:not(.gl).cooling #cv { animation: tube-off .4s ease-in both; }
@keyframes tube-on {
  0% { transform: scale(.02, .006); filter: brightness(6); }
  28% { transform: scale(1, .006); filter: brightness(5); }
  70% { transform: none; filter: brightness(1.6); }
  100% { transform: none; filter: none; }
}
@keyframes tube-off {
  0% { transform: none; filter: none; }
  55% { transform: scale(1, .006); filter: brightness(5); }
  100% { transform: scale(0, .006); filter: brightness(6); }
}
.foot { height: var(--foot); margin: 0 16%; background: linear-gradient(#b9b6ab, #a5a297); border-radius: 0 0 12px 12px; box-shadow: 0 10px 16px -6px rgba(0, 0, 0, .6); }

/* ---------- touch controller (phones, play mode) ---------- */
.ctl { display: none; gap: 10px; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.ctl-pad { position: relative; flex: 1; min-height: 96px; border-radius: 20px; background: linear-gradient(180deg, #2e2e2d, #151515); box-shadow: inset 0 2px 0 rgba(255, 255, 255, .12), inset 0 -6px 14px rgba(0, 0, 0, .65), 0 12px 22px -10px rgba(0, 0, 0, .7); touch-action: none; overflow: hidden; cursor: grab; }
.ctl-pad::before { content: ''; position: absolute; inset: 14px 18px; border-radius: 12px; background: repeating-linear-gradient(90deg, rgba(255, 255, 255, .07) 0 2px, transparent 2px 10px); }
.ctl-knob { position: absolute; top: 50%; left: 50%; width: 64px; height: 64px; margin: -32px 0 0 -32px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #f7f7f3, #c3c2bb 58%, #8e8d87); box-shadow: 0 8px 14px rgba(0, 0, 0, .65), inset 0 -3px 0 rgba(0, 0, 0, .2); pointer-events: none; }
.ctl-hint { position: absolute; left: 0; right: 0; bottom: 8px; text-align: center; font: 400 11px/1 'IBM Plex Mono', monospace; color: #8f8f89; pointer-events: none; }
.ctl-side { display: flex; flex-direction: column; gap: 10px; }
.ctl-btn { flex: 1; width: 58px; min-height: 44px; display: grid; place-items: center; border: 0; border-radius: 14px; background: linear-gradient(#efeee8, #d0cfc8); color: #151515; font: 700 16px Silkscreen, monospace; box-shadow: 0 3px 0 #8a8984, 0 6px 10px rgba(0, 0, 0, .45); cursor: pointer; }
.ctl-btn[hidden] { display: none; }
.ctl-btn svg { width: 22px; height: 22px; }
.ctl-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 #8a8984; }
/* A wider invisible hit area for the controls used during a run: a tap just
   next to them still lands on them (the page around them ignores touches). */
.ctl-btn, .pmenu button { position: relative; }
.ctl-btn::after { content: ''; position: absolute; inset: -10px; }
.pmenu button::after { content: ''; position: absolute; inset: -4px -12px; }

/* ---------- printer ---------- */
.prn { position: relative; z-index: 3; flex: none; width: var(--prnw); margin-bottom: 24px; }
.chute { position: absolute; left: 13%; width: 74%; bottom: calc(100% - 13px); clip-path: inset(-200vh -60vw 0 -60vw); pointer-events: none; }
.chute img { display: block; width: 100%; height: auto; transform: translateY(100%); filter: drop-shadow(0 6px 10px rgba(0, 0, 0, .25)); }
.chute img.torn { transform: translateY(-16%) rotate(-5deg) !important; opacity: 0; transition: transform .5s cubic-bezier(.2, .8, .2, 1), opacity .4s .1s; }
.pbody { position: relative; background: linear-gradient(170deg, #2e2e2d, #121212); border-radius: 22px 22px 16px 16px; padding: 30px 16px 16px; box-shadow: inset 0 2px 0 rgba(255, 255, 255, .16), inset 0 -6px 14px rgba(0, 0, 0, .7), -26px 24px 40px -16px rgba(0, 0, 0, .7); }
.pbody::before { content: ''; position: absolute; left: 11%; right: 11%; top: 9px; height: 10px; border-radius: 3px; background: repeating-linear-gradient(90deg, #d6d6d0 0 3px, #8f8f8a 3px 5px); box-shadow: inset 0 3px 2px rgba(0, 0, 0, .6); }
.prow { display: flex; flex-direction: column; gap: 12px; }
.lcd { min-height: 54px; border-radius: 9px; padding: 8px 10px; background: linear-gradient(#c9cbc2, #b4b7ad); box-shadow: inset 0 2px 7px rgba(0, 0, 0, .5); color: #2a2c27; display: flex; flex-direction: column; justify-content: center; gap: 4px; overflow: hidden; }
.lcd span { font: 400 8px/1 Silkscreen, monospace; }
.lcd b { font: 700 16px/1.05 Silkscreen, monospace; white-space: nowrap; }
.lcd i { display: none; height: 10px; width: 0; background: repeating-linear-gradient(90deg, #2a2c27 0 5px, transparent 5px 7px); }
.lcd.prog b { display: none; }
.lcd.prog i { display: block; }
.pbtn { white-space: nowrap; min-height: 50px; border: 0; border-radius: 11px; background: #f5f5f1; color: #151515; font: 600 14px/1.2 'IBM Plex Mono', monospace; display: flex; align-items: center; justify-content: center; gap: 8px; padding: 6px 10px; box-shadow: 0 4px 0 #9a9a94, 0 7px 12px rgba(0, 0, 0, .55); cursor: pointer; }
.pbtn:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 1px 0 #9a9a94, 0 3px 6px rgba(0, 0, 0, .5); }
.pbtn:disabled { background: #2b2b2a; color: #9a9a94; box-shadow: inset 0 2px 6px rgba(0, 0, 0, .7), 0 1px 0 rgba(255, 255, 255, .08); cursor: default; }
.pbtn:focus-visible { outline: 3px solid #fff; outline-offset: 3px; }
.pbtn.go { animation: nudge 1.1s ease-in-out infinite; }
@keyframes nudge { 50% { box-shadow: 0 4px 0 #9a9a94, 0 7px 12px rgba(0, 0, 0, .55), 0 0 0 4px rgba(255, 255, 255, .6); } }
.pbtn svg { width: 18px; height: 18px; flex: none; display: none; }
.pbtn[data-ic='print'] .i-print, .pbtn[data-ic='tear'] .i-tear, .pbtn[data-ic='again'] .i-again { display: block; }
.holes { display: flex; gap: 6px; margin: 12px 0 0 6px; }
.holes i { width: 5px; height: 5px; border-radius: 50%; background: #050505; box-shadow: 0 1px 0 rgba(255, 255, 255, .14); }

/* ---------- desk: one row of keys ---------- */
.desk { grid-area: 3 / 2 / 4 / 3; position: relative; z-index: 2; container-type: inline-size; display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 10px 30px; padding: 32px 0 calc(16px + env(safe-area-inset-bottom)); }
.keys { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }
.key { position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 16px; border: 0; border-radius: 9px; background: linear-gradient(#efeee8, #d6d5ce); color: #151515; font: 600 14px 'IBM Plex Mono', monospace; white-space: nowrap; box-shadow: 0 3px 0 #8a8984, 0 6px 10px rgba(0, 0, 0, .45); cursor: pointer; }
.key[hidden] { display: none; }
.key svg { width: 16px; height: 16px; flex: none; }
.key.full span { display: none; }
.key.full { padding: 0 13px; }
.key:active:not(:disabled) { transform: translateY(2px); box-shadow: 0 1px 0 #8a8984; }
.key:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }
.key:disabled { opacity: .5; cursor: default; }
.keys.nav .key { background: linear-gradient(#3a3a38, #262625); color: #f1f1ec; box-shadow: 0 3px 0 #0b0b0b, 0 6px 10px rgba(0, 0, 0, .45), inset 0 1px 0 rgba(255, 255, 255, .12); }
.keys.nav .key:active { box-shadow: 0 1px 0 #0b0b0b; }
/* The keys shrink with the room they get: smaller type, then icons only, then labels on two lines. */
/* The printer in a narrow column: smaller LCD digits, then no icon on the button. */
@container (max-width: 340px) {
  .lcd b { font-size: 14px; }
}
@container (max-width: 290px) {
  .lcd b { font-size: 12px; }
  .pbtn svg { display: none !important; }
}
@container (max-width: 420px) {
  .keys .key { font-size: 12px; }
  .keys.nav svg { display: none; }
}
@container (max-width: 330px) {
  .keys.game .key { white-space: normal; line-height: 1.1; text-align: center; }
}
@container (max-width: 290px) {
  .keys.nav svg { display: block; width: 18px; height: 18px; }
  .keys.nav .key span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
}

/* ---------- share sheet ---------- */
.ov { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: max(14px, env(safe-area-inset-top)) 14px max(14px, env(safe-area-inset-bottom)); background: rgba(10, 10, 10, .8); backdrop-filter: blur(4px); }
.ov[hidden] { display: none; }
.sheet { width: min(520px, 100%); max-height: 100%; overflow: auto; background: #f1f1ec; color: #151515; border-radius: 16px; padding: 16px 18px 18px; box-shadow: 0 30px 60px rgba(0, 0, 0, .5); animation: rise .45s cubic-bezier(.2, .8, .2, 1); }
@keyframes rise { from { transform: translateY(30px) scale(.96); opacity: 0; } }
.sh { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.sh h2 { font: 700 16px Silkscreen, monospace; margin: 0; }
.x { border: 0; background: none; color: #151515; font: 600 24px/1 'IBM Plex Mono', monospace; width: 44px; height: 44px; cursor: pointer; border-radius: 8px; }
.sheet img { display: block; width: 100%; height: auto; max-height: 56vh; object-fit: contain; border-radius: 8px; background: #e3e5e4; -webkit-touch-callout: default; }
.acts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 14px; }
.btn { min-height: 44px; border-radius: 10px; border: 2px solid #151515; background: #fff; color: #151515; font: 600 14px 'IBM Plex Mono', monospace; display: flex; align-items: center; justify-content: center; text-align: center; text-decoration: none; cursor: pointer; padding: 0 10px; }
.btn[hidden] { display: none; }
.btn.primary { grid-column: 1 / -1; background: #151515; color: #f1f1ec; }
.btn:focus-visible, .x:focus-visible { outline: 3px solid #151515; outline-offset: 2px; }
.msg { min-height: 1.5em; margin: 12px 2px 0; font-size: 13px; color: #4a4a47; }
.vict { display: flex; flex-wrap: wrap; gap: 4px 12px; margin: 8px 2px 0; font-size: 13px; color: #4a4a47; }
.vict a { color: #151515; }
.steps { margin: 4px 0 20px; padding: 0 0 0 26px; display: grid; gap: 14px; font-size: 15px; line-height: 1.5; color: #2a2a29; }
.steps li::marker { font: 700 14px Silkscreen, monospace; }
.share-ico { display: inline-grid; place-items: center; width: 30px; height: 30px; margin: -4px 3px 0; vertical-align: middle; border-radius: 8px; background: #fff; box-shadow: inset 0 0 0 1.5px #151515; color: #151515; }
.share-ico svg { width: 18px; height: 18px; }
.install-sheet .btn.primary { width: 100%; }

/* ---------- info sheet: leaderboard, how to play, power-ups ---------- */
.info { container-type: inline-size; display: flex; flex-direction: column; width: min(780px, 100%); height: min(660px, 100%); padding: 12px 18px 16px; }
.info .sh { margin-bottom: 8px; }
.info .sh h2 { font-size: 15px; font-size: clamp(13px, 4.6cqw, 16px); }
.tabs { flex: none; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 3px; padding: 3px; border-radius: 11px; background: #dfded7; }
.tab { min-height: 40px; padding: 0 2px; border: 0; border-radius: 8px; background: none; color: #4a4a47; font: 600 12px/1.1 'IBM Plex Mono', monospace; font: 600 clamp(11px, 3.6cqw, 14px)/1.1 'IBM Plex Mono', monospace; white-space: nowrap; cursor: pointer; }
.tab[aria-selected='true'] { background: #151515; color: #f1f1ec; }
.tab:focus-visible { outline: 3px solid #151515; outline-offset: 2px; }
.panel { flex: 1; min-height: 0; overflow: auto; padding: 14px 2px 2px; overscroll-behavior: contain; }
.panel:focus-visible { outline: 2px solid #151515; outline-offset: 2px; border-radius: 6px; }
.panel h3 { font: 700 13px/1.2 Silkscreen, monospace; margin: 4px 0 10px; color: #151515; }
.panel h3 ~ h3 { margin-top: 20px; }
.panel .note { margin: 0; color: #4a4a47; font-size: 13px; line-height: 1.55; }
.panel .note a { color: #151515; }
.about { list-style: none; margin: 0 0 12px; padding: 0; display: grid; gap: 6px; font-size: 14px; color: #4a4a47; }
.about a { color: #151515; font-weight: 600; }
.board .cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); gap: 6px 28px; }
.board ol { list-style: none; margin: 0 0 14px; padding: 0; display: grid; counter-reset: r; }
.board li { display: grid; grid-template-columns: 2em minmax(0, 1fr) auto; column-gap: 8px; align-items: baseline; font-size: 14px; line-height: 1.4; padding: 5px 0; border-bottom: 1px solid #d9d8d1; counter-increment: r; }
.board li::before { content: counter(r); font: 700 15px Silkscreen, monospace; color: #151515; }
.board .n { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #151515; }
.board .s { font-weight: 600; color: #151515; font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.board .k { grid-column: 2 / -1; color: #6a6a66; font-size: 12px; }
.board li.empty { display: block; border: 0; counter-increment: none; color: #6a6a66; }
.board li.empty::before { content: none; }
.lbnote { margin: 0; color: #4a4a47; font-size: 13px; }
.linkbtn { padding: 0; border: 0; background: none; color: #151515; font: 600 13px 'IBM Plex Mono', monospace; text-decoration: underline; cursor: pointer; }
.linkbtn:focus-visible { outline: 2px solid #151515; outline-offset: 2px; }
.hints, .tiers, .caps { list-style: none; margin: 0 0 14px; padding: 0; display: grid; gap: 9px; }
.hints li, .tiers li, .caps li { display: flex; align-items: center; gap: 12px; font-size: 14px; color: #2a2a29; }
.hints li > span { flex: none; display: flex; gap: 4px; min-width: 92px; }
.coll { list-style: none; margin: 0 0 18px; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); gap: 10px 28px; }
.coll li { display: grid; grid-template-columns: minmax(0, 1fr) auto; row-gap: 5px; font-size: 14px; color: #2a2a29; }
.coll .c { font-weight: 600; font-variant-numeric: tabular-nums; }
.coll .bar { grid-column: 1 / -1; height: 6px; background: #dfded7; border-radius: 3px; overflow: hidden; }
.coll .bar i { display: block; height: 100%; background: #151515; }
.legs { list-style: none; margin: 0 0 14px; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 12px 10px; }
.legs li { display: grid; justify-items: center; gap: 4px; font-size: 11px; line-height: 1.25; color: #4a4a47; text-align: center; }
.legs canvas { width: 64px; height: 64px; image-rendering: pixelated; border-radius: 4px; box-shadow: inset 0 0 0 1px #d4d3cc; }
kbd { display: inline-grid; place-items: center; min-width: 26px; height: 24px; padding: 0 6px; border-radius: 5px; background: #fff; box-shadow: inset 0 0 0 1.5px #151515, inset 0 -3px 0 #151515; color: #151515; font: 600 12px 'IBM Plex Mono', monospace; }
.caps { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
.cap { flex: none; display: grid; place-items: center; width: 40px; height: 20px; border-radius: 10px; background: #151515; color: #f1f1ec; font: 700 16px/1 Silkscreen, monospace; }
.cap.bad { background: transparent; color: #151515; box-shadow: inset 0 0 0 2px #151515; }
.pips { flex: none; display: flex; gap: 3px; width: 52px; }
.pips i { width: 10px; height: 10px; border: 2px solid #151515; }
.pips i.on { background: #151515; }
/* Keyboard hints mean nothing on a touch screen, and the touch line means nothing with a mouse. */
.touch-only { display: none; }
@media (pointer: coarse) {
  /* On a touch screen a long press on the TV, the printer or the keys selects nothing.
     The nickname field and the sheets keep their text selection. */
  .scene { -webkit-user-select: none; user-select: none; }
  .hints { display: none; }
  .touch-only { display: block; margin-bottom: 14px !important; }
}

/* ---------- compact screens: phones, small tablets, short windows ----------
   Portrait stacks the logo, the TV, the printer and two rows of keys.
   Wide and short (phones on their side) puts the TV left and the rest beside it. */
@media (max-width: 900px), (max-height: 560px) {
  .scene { --cp: 10px; --bp: 8px; --chin: 36px; --foot: 14px; grid-template-rows: auto minmax(0, 1fr) auto auto; }
  .top { padding: 10px 0 8px; gap: 6px 14px; }
  .tag { display: none; }
  .plaque { padding: 5px 9px; }
  .plaque svg { height: 26px; }
  .credit { font-size: 11px; }
  .credit b { font-size: 13px; }
  .chip .handle { display: none; }
  .chip { padding: 0 10px; }
  .rig { display: contents; }
  .tvbox { grid-area: 2 / 2 / 3 / 3; position: relative; z-index: 1; container-type: size; display: flex; justify-content: center; align-items: flex-end; }
  .mac { width: min(100%, calc((100vh - 400px) * 4 / 3 + 36px)); margin-bottom: -14px; }
  @supports (width: 1cqw) {
    .mac { width: min(100cqw, (100cqh - var(--tvy)) * 4 / 3 + var(--tvx)); }
  }
  .case { border-radius: 20px 20px 10px 10px; }
  .bezel { border-radius: 16px; }
  .prn { grid-area: 3 / 2 / 4 / 3; justify-self: center; width: min(400px, 100%); margin: 26px 0 0; }
  .pbody { padding: 24px 12px 12px; border-radius: 18px 18px 14px 14px; }
  .pbody::before { top: 7px; }
  .holes { display: none; }
  .prow { flex-direction: row; gap: 10px; }
  .prn { container-type: inline-size; }
  .lcd { flex: 0 0 auto; min-width: 40%; min-height: 52px; }
  .pbtn { flex: 1 1 0; min-height: 52px; padding: 6px 10px; gap: 7px; white-space: normal; text-align: left; font-size: 13px; line-height: 1.15; }
  .desk { grid-area: 4 / 2 / 5 / 3; justify-self: center; width: min(100%, 520px); flex-direction: column; flex-wrap: nowrap; align-items: stretch; gap: 8px; padding: 12px 0 calc(10px + env(safe-area-inset-bottom)); }
  .keys { flex-wrap: nowrap; gap: 8px; }
  .keys .key { flex: 1 1 0; padding: 0 6px; gap: 6px; font-size: 13px; }
  .keys .key.full { flex: 0 0 44px; }
  /* Here the desk only shows between runs (a live run is in play mode), so Pause has nothing to do. */
  #bPause { display: none; }
  .bgd { grid-area: 3 / 1 / -1 / -1; }
}
@media (max-width: 900px) and (min-aspect-ratio: 4 / 3), (max-height: 560px) and (min-aspect-ratio: 4 / 3) {
  .scene {
    --side: 240px; /* the least the side column gets; it grows to 340px when the TV leaves room */
    --cg: clamp(12px, 3vw, 28px);
    grid-template-columns: minmax(8px, 1fr) max-content minmax(var(--side), 340px) minmax(8px, 1fr);
    grid-template-rows: minmax(8px, 1fr) auto auto auto minmax(8px, 1fr);
    column-gap: var(--cg);
  }
  .bgw { grid-area: 1 / 1 / 4 / -1; }
  .bgd { grid-area: 4 / 1 / -1 / -1; }
  .top { grid-area: 2 / 3 / 3 / 4; padding: 0 0 4px; gap: 6px 8px; }
  .install { padding: 0 9px 0 7px; }
  .tvbox { grid-area: 1 / 2 / -1 / 3; container-type: normal; align-items: center; }
  .mac { margin: 0; width: min(calc(100vw - 340px), calc((100vh - 92px) * 4 / 3 + 36px)); }
  @supports (height: 1dvh) {
    .mac {
      width: min(
        100vw - env(safe-area-inset-left) - env(safe-area-inset-right) - var(--side) - 3 * var(--cg) - 16px,
        (100dvh - env(safe-area-inset-top) - env(safe-area-inset-bottom) - 16px - var(--tvy)) * 4 / 3 + var(--tvx)
      );
    }
  }
  .prn { grid-area: 3 / 3 / 4 / 4; width: 100%; margin: 14px 0 6px; }
  .pbody { padding-top: 20px; }
  .lcd, .pbtn { min-height: 46px; }
  .desk { grid-area: 4 / 3 / 5 / 4; width: 100%; gap: 6px; padding: 10px 0 calc(2px + env(safe-area-inset-bottom)); }
  .keys { gap: 6px; }
  .key { min-height: 40px; }
}

/* Full-screen play mode on compact screens while a run is live.
   Portrait reads like an arcade cabinet: marquee on top, the screen, the controls in the thumb zone.
   Landscape puts the controls beside the screen. */
body.play { overflow: hidden; overscroll-behavior: none; touch-action: none; }
/* On a touch screen nothing can be selected, magnified or long-pressed during a
   run, except text fields and a sheet opened over the game. */
@media (pointer: coarse) {
  body.play { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
  body.play input, body.play .ov { -webkit-user-select: text; user-select: text; -webkit-touch-callout: default; }
}
.ctl, .ctl * { -webkit-user-drag: none; }
body.play .tag, body.play .desk, body.play .prn, body.play .chin, body.play .foot, body.play .bgd { display: none; }
body.play .bgw { position: fixed; inset: 0; }
body.play .tvbox { display: contents; }
body.play .scene {
  --padt: max(8px, env(safe-area-inset-top));
  --padb: max(8px, env(safe-area-inset-bottom));
  --padl: max(8px, env(safe-area-inset-left));
  --padr: max(8px, env(safe-area-inset-right));
  --ctlh: clamp(130px, 26dvh, 240px);
  --ctlw: clamp(150px, 26vw, 240px);
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 12px;
  height: 100dvh; padding: var(--padt) var(--padr) var(--padb) var(--padl);
}
body.play .top { display: flex; justify-content: center; width: auto; margin: 0 0 auto; padding: 4px 0 0; }
body.play .plaque svg { height: clamp(24px, 5dvh, 44px); }
/* The case adds 24px around a 4:3 screen; 110px leaves room for the marquee and the gaps. */
body.play .mac { width: min(100%, calc((100dvh - var(--padt) - var(--padb) - var(--ctlh) - 110px) * 4 / 3 + 24px)); margin: 0 0 auto; }
body.play .case { padding: 6px; border-radius: 16px; }
body.play .bezel { padding: 6px; border-radius: 12px; }
body.play .ctl { display: flex; position: relative; z-index: 2; width: min(100%, 560px); height: var(--ctlh); flex: none; }
@media (orientation: landscape) {
  body.play .scene { flex-direction: row; justify-content: center; }
  body.play .top { display: none; }
  body.play .mac { margin: 0; }
  body.play .mac {
    width: min(calc(100vw - var(--padl) - var(--padr) - var(--ctlw) - 12px), calc((100dvh - var(--padt) - var(--padb) - 24px) * 4 / 3 + 24px));
  }
  body.play .ctl { flex-direction: column; width: var(--ctlw); height: min(100%, 420px); }
  body.play .ctl-side { flex-direction: row; }
  body.play .ctl-btn { width: auto; flex: 1; }
}
/* A short desktop window: no touch controls, just the screen. */
@media (pointer: fine) {
  body.play .ctl, body.play .top { display: none; }
  body.play .scene { flex-direction: column; justify-content: center; }
  body.play .mac { margin: 0; }
  body.play .mac {
    width: min(calc(100vw - var(--padl) - var(--padr)), calc((100dvh - var(--padt) - var(--padb) - 24px) * 4 / 3 + 24px));
  }
}

@media (prefers-reduced-motion: reduce) {
  .pbtn.go, .sheet, .led, .power-on svg, .power-on span, .nick { animation: none !important; }
  .screen:not(.gl).warming #cv { animation: tube-fade .3s both; }
  .screen:not(.gl).cooling #cv { animation: tube-fade .2s reverse both; }
  @keyframes tube-fade { from { opacity: 0; } }
}
