@font-face { font-family: PS2P; src: url('/fonts/PressStart2P.woff2') format('woff2'); font-display: block; }
@font-face { font-family: VT; src: url('/fonts/VT323.woff2') format('woff2'); font-display: swap; }
:root {
  --bg: #05070d; --ink: #e9f2ff; --dim: #8492ad; --line: #1c2233;
  --a1: #3dffb0; --a2: #39c5ff; --hot: #ff3d81; --gold: #ffd23d;
  --px: PS2P, ui-monospace, monospace; --vt: VT, ui-monospace, monospace;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; background: var(--bg); color: var(--ink); overflow: hidden; overscroll-behavior: none; -webkit-tap-highlight-color: transparent; }
body { font: 20px/1.25 var(--vt); display: grid; grid-template-rows: auto 1fr auto; height: 100dvh; user-select: none; -webkit-user-select: none; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; margin: 0; cursor: pointer; touch-action: manipulation; }
button:focus-visible, a:focus-visible, input:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
[hidden] { display: none !important; }
#bg { position: fixed; inset: 0; width: 100%; height: 100%; image-rendering: pixelated; z-index: 0; }
#crt { position: fixed; inset: 0; pointer-events: none; z-index: 60;
  background: repeating-linear-gradient(0deg, rgba(0,0,0,.22) 0 1px, transparent 1px 3px), radial-gradient(ellipse at center, transparent 55%, rgba(0,0,0,.55) 100%); }
#flash { position: fixed; inset: 0; background: #fff; opacity: 0; pointer-events: none; z-index: 55; }
#flash.go { animation: flash .45s ease-out; }
@keyframes flash { 0% { opacity: .95 } 100% { opacity: 0 } }

/* ---- header ---- */
#top { position: relative; z-index: 2; display: flex; align-items: flex-start; gap: 10px; padding: max(10px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) 4px max(12px, env(safe-area-inset-left)); }
#logo { font: clamp(12px, 2.3vw, 30px)/1.25 var(--px); text-align: left; color: #fff; text-shadow: 2px 0 var(--hot), -2px 0 var(--a2), 0 3px 0 #000; }
#logo small { display: block; margin-top: 4px; font: clamp(13px, 1.5vw, 22px)/1 var(--vt); color: var(--dim); text-shadow: 0 2px 0 #000; }
#logo:active { transform: translateY(2px); }
#ctl { margin-left: auto; display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; max-width: 60%; }
.pill { font: clamp(7px, 1vw, 11px) var(--px); padding: 8px; border: 2px solid currentColor; color: var(--dim); background: rgba(5,7,13,.72); }
.pill:hover { color: var(--ink); }
.pill[aria-pressed=true] { color: var(--bg); background: var(--a1); border-color: var(--a1); }
#mute[aria-pressed=true] { background: var(--hot); border-color: var(--hot); }

/* ---- the rack of 24 boxes ---- */
#mid { position: relative; z-index: 2; min-height: 0; display: grid; }
#rack { --cols: 6; min-height: 0; display: grid; grid-template-columns: repeat(var(--cols), 1fr); grid-auto-rows: 1fr;
  gap: clamp(2px, 1vh, 12px) clamp(8px, 1.6vw, 26px); padding: 4px clamp(12px, 4vw, 70px); }
@media (max-aspect-ratio: 1/1) { #rack { --cols: 4; } }
@media (min-aspect-ratio: 5/2) { #rack { --cols: 8; } }
.box { position: relative; min-width: 0; min-height: 0; display: block; }
.box svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.box .shelf { fill: #2a3144; } .box .foot { fill: #4a5470; }
.box .hull { fill: #0b0d12; stroke: #2b3243; stroke-width: 1.5; }
.box .shell { fill: #171a21; stroke: #343c50; stroke-width: 1.5; }
.box .shine { fill: none; stroke: rgba(255,255,255,.16); stroke-width: 2; stroke-linecap: round; }
.box .brand { font: italic 900 7px Arial, sans-serif; fill: rgba(255,255,255,.55); letter-spacing: .5px; }
.box .n { font: 18px var(--px); fill: #414a60; text-anchor: middle; }
.box .glow { fill: var(--a1); opacity: 0; filter: blur(4px); }
.box .lid { transform-origin: 12px 40px; transition: transform .5s cubic-bezier(.2, 1.7, .4, 1); }
.box .lock { fill: #59637c; }
.box.ready .lock, .box.opened .lock { display: none; }
.box.ready .n { fill: var(--gold); }
.box.ready .shell { stroke: #6b5a1f; }
.box.ready svg { animation: bob 2.4s ease-in-out infinite; animation-delay: calc(var(--i) * -173ms); }
.box.today .n { animation: blink .8s steps(2) infinite; }
.box.today .shell { stroke: var(--gold); }
.box.opened .lid { transform: rotate(-9deg); }
.box.opened .glow { opacity: .85; }
.box.opened .n { fill: var(--a1); }
.box.opened .shell { stroke: #1f6b54; }
.box:hover svg { transform: translateY(-3px); }
.box.nope svg { animation: nope .35s linear; }
.box.spin svg { animation: spin 1s cubic-bezier(.3,.1,.3,1); }
@keyframes bob { 50% { transform: translateY(-4%); } }
@keyframes blink { 50% { fill: #fff; } }
@keyframes nope { 20% { transform: translateX(-7%) } 40% { transform: translateX(7%) } 60% { transform: translateX(-5%) } 80% { transform: translateX(4%) } }
@keyframes spin { to { transform: rotate(360deg) scale(1.1); } }
#info { margin: 0; padding: 4px 12px 2px; display: flex; flex-wrap: wrap; gap: 2px 18px; justify-content: center; font: clamp(7px, 1.05vw, 11px)/1.6 var(--px); color: var(--dim); text-shadow: 0 2px 0 #000; }
#iday { color: var(--gold); } #iclack { color: var(--a1); }
#foot { position: relative; z-index: 2; pointer-events: none; }
#scroll { display: block; width: 100%; height: clamp(20px, 3.6vh, 38px); image-rendering: pixelated; background: #000; }
/* 3D home: the boxes are drawn by WebGL, the buttons are invisible hit areas placed over them */
body.gl #mid { pointer-events: none; }
body.gl #rack { position: fixed; inset: 0; display: block; padding: 0; }
body.gl .box { position: absolute; left: 0; top: 0; pointer-events: auto; }
body.gl .box svg { display: none; }
/* no WebGL: flat rack on a still sky */
body:not(.gl) { background: linear-gradient(#03040b, #0a1430 55%, #3a0a3a 82%, #6b1257); }
body:not(.gl) #bg { display: none; }

/* ---- an open door ---- */
#door { position: fixed; inset: 0; z-index: 20; display: grid; grid-template-rows: auto 1fr; background: #030409; animation: pop .28s cubic-bezier(.2,1.4,.4,1); }
@keyframes pop { from { transform: scale(.82); opacity: 0; } }
#door > header { display: flex; align-items: center; gap: 10px; padding: max(8px, env(safe-area-inset-top)) 10px 8px; border-bottom: 2px solid var(--line); }
#doortitle { flex: 1; margin: 0; font: clamp(9px, 1.5vw, 15px)/1.4 var(--px); color: var(--gold); }
#door .x { font: 14px var(--px); padding: 9px 11px; border: 2px solid var(--hot); color: var(--hot); }
#door .x:hover { background: var(--hot); color: var(--bg); }
#doorbody { position: relative; min-height: 0; overflow: hidden auto; display: flex; flex-direction: column; -webkit-overflow-scrolling: touch; }
.stage { position: relative; flex: 1; min-height: 0; display: grid; place-items: center; overflow: hidden; }
.stage canvas { display: block; image-rendering: pixelated; touch-action: none; }
.page { width: 100%; max-width: 780px; margin: 0 auto; padding: 14px 14px 40px; font-size: clamp(19px, 2.2vw, 24px); user-select: text; -webkit-user-select: text; }
.page h3 { font: clamp(10px, 1.6vw, 15px)/1.5 var(--px); color: var(--a1); margin: 18px 0 8px; }
.page p { margin: 8px 0; }
.caps { text-transform: uppercase; } .dim { color: var(--dim); } .gold { color: var(--gold); } .hot { color: var(--hot); } .a1 { color: var(--a1); }
.center { text-align: center; }
.btn { display: inline-block; font: clamp(8px, 1.2vw, 12px)/1.3 var(--px); padding: 12px 14px; color: var(--bg); background: var(--a1); border: 0; box-shadow: 0 4px 0 #17805b; text-decoration: none; text-transform: uppercase; }
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 #17805b; }
.btn.alt { background: var(--gold); box-shadow: 0 4px 0 #94760f; }
.btn.red { background: var(--hot); box-shadow: 0 4px 0 #8f1c45; }
.btn.ghost { background: transparent; color: var(--ink); box-shadow: inset 0 0 0 2px var(--dim); }
.btn[disabled] { opacity: .4; pointer-events: none; }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: center; margin: 12px 0; }
.bar { display: flex; gap: 8px; padding: 8px; justify-content: center; flex-wrap: wrap; border-top: 2px solid var(--line); }
.msg { border-left: 4px solid var(--a2); background: #0b0f1a; padding: 8px 10px; margin: 8px 0; }
.msg b { font: 9px var(--px); color: var(--a2); display: block; margin-bottom: 4px; }
input[type=text], textarea { font: 22px var(--vt); color: var(--ink); background: #0b0f1a; border: 2px solid var(--dim); padding: 8px 10px; width: 100%; max-width: 420px; user-select: text; -webkit-user-select: text; }
input[type=range] { width: 100%; accent-color: var(--a1); }
/* game over panel + score table */
.panel { position: absolute; inset: 0; z-index: 5; display: grid; place-items: center; background: rgba(3,4,9,.88); padding: 10px; overflow: auto; animation: pop .25s; }
.panel > div { width: min(100%, 460px); text-align: center; }
.panel h3 { font: clamp(12px, 2.4vw, 20px)/1.4 var(--px); color: var(--hot); margin: 0 0 8px; }
.panel .sc { font: clamp(14px, 3vw, 26px) var(--px); color: var(--gold); margin: 8px 0 12px; }
.board { width: 100%; border-collapse: collapse; font-size: 21px; margin: 8px 0; }
.board td { padding: 1px 6px; text-align: left; } .board td:first-child { color: var(--dim); width: 2.2em; } .board td:last-child { text-align: right; color: var(--gold); }
.board tr.me td { color: var(--a1); }
.board caption { font: 9px var(--px); color: var(--a2); padding: 6px 0; }
/* toasts */
#toasts { position: fixed; z-index: 70; left: 50%; top: max(10px, env(safe-area-inset-top)); transform: translateX(-50%); width: min(94vw, 520px); display: grid; gap: 6px; pointer-events: none; }
.toast { background: #0b0f1a; border: 2px solid var(--a2); border-left-width: 8px; padding: 8px 10px; font-size: 20px; box-shadow: 0 6px 0 rgba(0,0,0,.5); animation: tin .25s cubic-bezier(.2,1.5,.4,1); }
.toast b { font: 8px var(--px); color: var(--a2); display: block; margin-bottom: 3px; }
.toast.out { transition: .3s; opacity: 0; transform: translateY(-12px); }
@keyframes tin { from { transform: translateY(-30px); opacity: 0 } }
/* boot screen */
#boot { position: fixed; inset: 0; z-index: 40; background: #000; display: grid; place-content: center; justify-items: center; gap: 2.2vh; text-align: center; padding: 16px; overflow: hidden; }
#boot .bars { position: absolute; inset: -50% 0; z-index: -1; opacity: .5;
  background: repeating-linear-gradient(0deg, transparent 0 40px, #06324a 40px 44px, #0b6f8f 44px 48px, #3dffb0 48px 50px, #0b6f8f 50px 54px, #06324a 54px 58px, transparent 58px 120px, #3a0a2a 120px 124px, #a01c5c 124px 128px, #ff3d81 128px 130px, #a01c5c 130px 134px, #3a0a2a 134px 138px, transparent 138px 200px);
  animation: bars 5s ease-in-out infinite alternate; }
@keyframes bars { from { transform: translateY(-12%) } to { transform: translateY(12%) } }
#boot h1 { margin: 0; font: clamp(20px, 6.4vw, 78px)/1.2 var(--px); color: #fff; text-shadow: 4px 0 var(--hot), -4px 0 var(--a2), 0 6px 0 #000; animation: wob 3s ease-in-out infinite; }
@keyframes wob { 50% { transform: skewX(-4deg) scale(1.03); } }
#boot .pres { margin: 0; font: clamp(8px, 1.5vw, 14px) var(--px); color: var(--gold); letter-spacing: .2em; }
#boot .sub { margin: 0; font: clamp(18px, 2.6vw, 30px)/1.1 var(--vt); color: var(--a1); }
#boot .warn { margin: 0; font: clamp(14px, 1.6vw, 19px)/1.2 var(--vt); color: var(--dim); }
#start { font: clamp(9px, 1.8vw, 18px)/1.4 var(--px); color: #000; background: var(--gold); padding: 16px 18px; box-shadow: 0 6px 0 #94760f; animation: blinkbg 1s steps(2) infinite; }
@keyframes blinkbg { 50% { background: #fff; } }
#boot.off { animation: crtoff .5s forwards; pointer-events: none; }
@keyframes crtoff { 40% { transform: scale(1, .008); filter: brightness(4); } 100% { transform: scale(0, .008); filter: brightness(8); opacity: 0; visibility: hidden; } }
body.booting #top, body.booting #mid { visibility: hidden; }
/* full-screen moderation */
#ban { position: fixed; inset: 0; z-index: 80; display: grid; place-content: center; text-align: center; gap: 3vh; padding: 16px; background: #b00020; color: #fff; animation: banbg .4s steps(2) 6; }
#ban h1 { margin: 0; font: clamp(22px, 9vw, 110px) var(--px); text-shadow: 0 8px 0 #000; }
#ban p { margin: 0; font: clamp(18px, 3vw, 34px)/1.15 var(--vt); }
@keyframes banbg { 50% { background: #000; } }
/* easter eggs */
body.enthule { animation: hue 2s linear infinite; }
@keyframes hue { to { filter: hue-rotate(360deg) saturate(1.6); } }
body.espas #mid { animation: espas 9s ease-in-out infinite alternate; }
@keyframes espas { from { transform: rotate(-5deg) translateY(-2%) scale(.94); } to { transform: rotate(6deg) translateY(3%) scale(.9); } }
.rain { position: fixed; top: -60px; z-index: 65; font-size: 34px; pointer-events: none; animation: rain linear forwards; }
@keyframes rain { to { transform: translateY(115vh) rotate(540deg); } }
/* 404 */
body.e404 { display: grid; place-items: center; text-align: center; grid-template-rows: 1fr; }
body.e404 h1 { font: clamp(40px, 16vw, 160px) var(--px); margin: 0; color: var(--hot); text-shadow: 6px 0 var(--a2); }
body.e404 .ban { font: clamp(14px, 3vw, 28px) var(--px); color: var(--gold); margin: 3vh 0; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
/* ---- doors: shared pieces ---- */
.s3d canvas { width: 100%; height: 100%; }
.hud { position: absolute; left: 8px; right: 8px; top: 8px; z-index: 2; display: flex; justify-content: space-between; gap: 10px; font: clamp(8px, 1.3vw, 12px)/1.5 var(--px); text-shadow: 0 2px 0 #000, 0 0 6px #000; pointer-events: none; }
.hud .big { font-size: 1.5em; color: var(--gold); }
.note { position: absolute; left: 0; right: 0; bottom: 10px; z-index: 2; text-align: center; padding: 0 10px; font: clamp(8px, 1.3vw, 12px)/1.6 var(--px); color: var(--a1); text-shadow: 0 2px 0 #000, 0 0 8px #000; pointer-events: none; }
.strip { display: flex; gap: 8px; padding: 8px; overflow-x: auto; min-height: 0; border-top: 2px solid var(--line); background: #070a12; }
.strip:empty { display: none; }
.strip figure { margin: 0; flex: 0 0 auto; width: clamp(92px, 16vw, 150px); background: #e9edf5; color: #111; padding: 4px 4px 2px; transform: rotate(var(--r, 0deg)); animation: pop .3s; }
.strip img { display: block; width: 100%; aspect-ratio: 4/3; object-fit: cover; image-rendering: pixelated; }
.strip figcaption { font: 15px/1.1 var(--vt); min-height: 2.2em; overflow: hidden; }
.strip small { display: block; font: 13px var(--vt); color: #555; }
/* poster carousel */
.gal { flex: 1; min-height: 0; display: grid; grid-template-rows: 1fr auto auto; }
.ring { position: relative; min-height: 0; perspective: 1100px; overflow: hidden; touch-action: pan-y; }
.ring figure { position: absolute; inset: 4% 0; margin: auto; height: 92%; aspect-ratio: 2/3; max-width: 78%; transition: transform .45s cubic-bezier(.2,.9,.3,1), opacity .45s; cursor: pointer; }
.ring img { width: 100%; height: 100%; object-fit: contain; filter: drop-shadow(0 14px 0 rgba(0,0,0,.5)); }
.ring figure.cur img { filter: drop-shadow(0 0 22px rgba(61,255,176,.45)); }
.ring::after { content: ''; position: absolute; left: 0; right: 0; height: 9%; top: -10%; background: linear-gradient(transparent, rgba(255,255,255,.14), transparent); animation: track 5s linear infinite; pointer-events: none; z-index: 30; }
@keyframes track { to { top: 110%; } }
.osd { position: absolute; left: 12px; top: 8px; z-index: 31; font: clamp(9px, 1.6vw, 15px) var(--px); color: #fff; text-shadow: 2px 0 var(--hot), -2px 0 var(--a2); animation: blinkop 1.4s steps(2) infinite; pointer-events: none; }
@keyframes blinkop { 50% { opacity: .25; } }
.galcap { text-align: center; padding: 6px 12px 0; min-height: 6.2em; }
.galcap h3 { margin: 0 0 4px; font: clamp(10px, 1.8vw, 16px)/1.4 var(--px); color: var(--a1); }
.galcap p { margin: 2px auto; max-width: 720px; font-size: clamp(18px, 2.2vw, 23px); line-height: 1.1; }
.dots { display: flex; gap: 8px; align-items: center; }
.dots button { width: 12px; height: 12px; background: var(--line); } .dots button.on { background: var(--gold); }
.zoom { position: absolute; inset: 0; z-index: 40; background: rgba(0,0,0,.95); display: grid; place-items: center; cursor: zoom-out; animation: pop .2s; }
.zoom img { max-width: 100%; max-height: 100%; object-fit: contain; }
/* swipe cards (door 3) */
.deck { flex: 1; min-height: 0; display: grid; place-items: center; position: relative; overflow: hidden; touch-action: none; }
.cardm { width: min(84vw, 420px); padding: 18px 14px; text-align: center; background: #0e1322; border: 3px solid var(--a2); box-shadow: 0 10px 0 rgba(0,0,0,.6); cursor: grab; will-change: transform; }
.cardm .who { font: 9px var(--px); color: var(--a2); margin-bottom: 10px; }
.cardm .pic { font-size: clamp(54px, 16vw, 110px); line-height: 1.15; }
.cardm .txt { font: clamp(10px, 2vw, 15px)/1.6 var(--px); margin-top: 10px; }
.tbar { height: 8px; background: var(--line); } .tbar i { display: block; height: 100%; background: var(--gold); transform-origin: left; }
.verdict { min-height: 3.4em; text-align: center; padding: 6px 10px; font: clamp(8px, 1.4vw, 12px)/1.6 var(--px); }
.stamp { position: absolute; inset: 0; z-index: 3; display: grid; place-items: center; pointer-events: none; font: clamp(30px, 12vw, 130px) var(--px); color: #fff; text-shadow: 6px 0 var(--hot), -6px 0 var(--a2), 0 10px 0 #000; animation: stamp .5s cubic-bezier(.2,2,.4,1); }
@keyframes stamp { from { transform: scale(3) rotate(-14deg); opacity: 0; } }
.log { max-height: 22vh; overflow: auto; padding: 6px 12px; font-size: 19px; line-height: 1.15; border-top: 2px solid var(--line); }
.log div b { color: var(--gold); font-weight: normal; }
.sw { width: 34px; height: 34px; border: 3px solid #fff; box-shadow: 0 4px 0 rgba(0,0,0,.6); }
