/* The room is one 16:9 stage that covers the window (cropped top/bottom on wide screens, scrollable sideways on
   narrow ones), with the idle video under absolutely placed, perspective-warped slots. One warm look by choice. */
:root {
  color-scheme: dark;
  --ink: #1b120b;
  --paper: #f6ead9;
  --muted: #cdb79e;
  --lamp: #f2a541;
  --glass: rgba(18, 11, 6, 0.78);
  --ui: "Atkinson Hyperlegible", system-ui, -apple-system, "Segoe UI", sans-serif;
  --display: "Big Shoulders Display", "Arial Narrow", Impact, sans-serif;
  --pixel: "Press Start 2P", ui-monospace, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: #120c08; color: var(--paper); font-family: var(--ui); overflow: hidden; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--lamp); outline-offset: 3px; }

.room { position: fixed; inset: 0; overflow: hidden; }
.room.pan { overflow-x: auto; overflow-y: hidden; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.room.pan::-webkit-scrollbar { display: none; }
.stage { position: absolute; left: 0; top: 0; overflow: hidden; }
.room:not(.pan) .stage { left: 50%; transform: translateX(-50%); }
.plate, .idle { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; user-select: none; }
.slots { position: absolute; inset: 0; }

.slot { position: absolute; inset: 0; pointer-events: none; -webkit-mask-size: 100% 100%; mask-size: 100% 100%;
  -webkit-mask-repeat: no-repeat; mask-repeat: no-repeat; transition: filter .25s ease; }
.content { position: absolute; left: 0; top: 0; transform-origin: 0 0; pointer-events: auto; overflow: hidden; display: block; text-decoration: none; }
.slot-screen .content { background: #05070c; }
.scr video, .scr img, .pst img, .box img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* CRT glass: scanlines, a soft vignette and a highlight, over whatever plays on a screen */
.crt { position: absolute; inset: 0; pointer-events: none;
  background:
    radial-gradient(120% 90% at 30% 18%, rgba(255, 255, 255, .13), transparent 42%),
    radial-gradient(ellipse at center, transparent 58%, rgba(0, 0, 0, .55) 100%),
    /* scanlines sized to the screen (about 60 per screen): 1 px lines shimmered once the screens were shrunk into the room */
    repeating-linear-gradient(to bottom, rgba(0, 0, 0, .2) 0 .6%, transparent .6% 1.7%); }

/* attract screen for a game without a preview clip */
.slot-screen .title-card { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .9em; padding: 8%;
  text-align: center; font-family: var(--pixel); line-height: 1.35;
  background: radial-gradient(circle at 50% 40%, hsl(var(--h) 70% 30%), hsl(var(--h) 75% 9%) 70%); }
.tc-title { color: hsl(var(--h) 90% 82%); text-shadow: 0 0 .4em hsl(var(--h) 100% 60%), .12em .12em 0 hsl(var(--h) 80% 20%); text-wrap: balance; }
.tc-start { font-size: .42em; color: #fff7d6; letter-spacing: .1em; text-transform: uppercase; }
@media (prefers-reduced-motion: no-preference) { .tc-start { animation: blink 1.2s steps(2, start) infinite; } }
@keyframes blink { to { visibility: hidden; } }

/* posters and boxes sit under the room's warm light */
.light { position: absolute; inset: 0; pointer-events: none; mix-blend-mode: multiply;
  background: linear-gradient(180deg, rgba(255, 214, 160, .95), rgba(214, 150, 92, .9)); }
.pst::after { content: ""; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(115deg, rgba(255, 255, 255, .08) 20%, transparent 45%); }
.spine { display: flex; align-items: center; padding: 0 4%; font-family: var(--display); letter-spacing: .04em;
  text-transform: uppercase; white-space: nowrap; color: hsl(var(--h) 80% 75%); background: hsl(var(--h) 45% 14%); }

/* UI */
.brand { position: fixed; top: calc(env(safe-area-inset-top, 0px) + 14px); left: max(16px, env(safe-area-inset-left, 0px)); z-index: 5; }
.logo { font-family: var(--display); font-size: 26px; text-transform: uppercase; letter-spacing: .02em; text-decoration: none;
  background: var(--glass); padding: 4px 12px 2px; border-radius: 4px; backdrop-filter: blur(6px); }
.logo span { color: var(--lamp); }

.card { position: fixed; z-index: 6; left: max(16px, env(safe-area-inset-left, 0px)); bottom: calc(env(safe-area-inset-bottom, 0px) + 64px);
  width: min(360px, calc(100vw - 32px)); background: var(--glass); backdrop-filter: blur(10px); border: 1px solid rgba(242, 165, 65, .35);
  border-radius: 6px; padding: 14px 16px; pointer-events: none; }
/* a screen on the left gets its card on the right, so the card never covers the screen it describes */
.card.right { left: auto; right: max(16px, env(safe-area-inset-right, 0px)); }
.card-top { display: flex; align-items: center; gap: 8px; }
.card-kicker { font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--lamp); }
.card-title { font-family: var(--display); font-size: 34px; line-height: 1; text-transform: uppercase; margin: 4px 0 6px; }
.card-tag { margin: 0 0 10px; color: var(--muted); font-size: 14px; line-height: 1.4; }
.card-cta { font-size: 13px; font-weight: 700; color: var(--lamp); }

.bar { position: fixed; z-index: 5; left: 0; right: 0; bottom: 0; display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 10px max(16px, env(safe-area-inset-right, 0px)) calc(env(safe-area-inset-bottom, 0px) + 12px) max(16px, env(safe-area-inset-left, 0px));
  pointer-events: none; }
.hint { font-size: 13px; color: var(--paper); background: var(--glass); padding: 5px 10px; border-radius: 4px; backdrop-filter: blur(6px); }
.all { pointer-events: auto; font: 700 13px var(--ui); color: var(--ink); background: var(--lamp); border: 0; border-radius: 4px; padding: 8px 14px; cursor: pointer; }

.all-panel { position: fixed; z-index: 7; right: max(16px, env(safe-area-inset-right, 0px)); bottom: calc(env(safe-area-inset-bottom, 0px) + 60px);
  width: min(420px, calc(100vw - 32px)); max-height: min(70vh, 640px); overflow: auto; background: rgba(18, 11, 6, .92);
  backdrop-filter: blur(12px); border: 1px solid rgba(242, 165, 65, .35); border-radius: 6px; padding: 12px 14px; }
.all-head { display: flex; justify-content: space-between; align-items: center; position: sticky; top: -12px; background: inherit; padding: 4px 0 8px; }
.all-head h2 { margin: 0; font-family: var(--display); font-size: 26px; text-transform: uppercase; }
.close { font: 13px var(--ui); color: var(--paper); background: transparent; border: 1px solid rgba(255, 255, 255, .25); border-radius: 4px; padding: 4px 10px; cursor: pointer; }
.all-panel ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.all-panel a { display: block; text-decoration: none; padding: 8px 8px; border-radius: 4px; }
.all-panel a:hover, .all-panel a:focus-visible { background: rgba(242, 165, 65, .14); }
.all-panel b { display: block; font-size: 15px; }
.all-panel span { display: block; font-size: 13px; color: var(--muted); line-height: 1.35; }

.slots { opacity: 0; transition: opacity .6s ease; }
.ready .slots { opacity: 1; }
@media (prefers-reduced-motion: reduce) { .slots, .slot { transition: none; } }
.all-page { display: block; margin-top: 8px; font-size: 13px; color: var(--lamp); }
.noscript { position: fixed; z-index: 9; left: 16px; right: 16px; bottom: 80px; background: var(--glass); padding: 12px 14px; border-radius: 6px; }

/* stills used to drift slowly; 13 masked, warped screens animating at once made the room flicker, so they hold still */
@keyframes drift { from { transform: scale(1.04) translate(0, 0); } to { transform: scale(1.12) translate(-2.5%, -1.5%); } }

/* clicking a screen: rush into it, then fade to black while the game loads */
.stage { transition: transform .65s cubic-bezier(.55, 0, .85, .35); }
.stage.diving { transform: scale(var(--dive, 4)); }
.room:not(.pan) .stage.diving { transform: translateX(-50%) scale(var(--dive, 4)); }
body::after { content: ""; position: fixed; inset: 0; z-index: 20; background: #000; opacity: 0; pointer-events: none; transition: opacity .35s ease .35s; }
body.leaving::after { opacity: 1; }
body.leaving .brand, body.leaving .bar, body.leaving .card { opacity: 0; transition: opacity .2s; }

/* cabinet marquee: a backlit sign with the game's title */
.marquee { display: flex; align-items: center; justify-content: center; overflow: hidden;
  background:
    radial-gradient(120% 140% at 50% 50%, hsl(var(--h) 70% 22%), hsl(var(--h) 80% 7%) 75%),
    #0a0610; box-shadow: inset 0 0 18px rgba(0, 0, 0, .7); }
.marquee span { font-family: var(--display); text-transform: uppercase; letter-spacing: .02em; line-height: 1; white-space: nowrap;
  font-style: italic; padding: 0 4%;
  background: linear-gradient(180deg, #fff6c9 0%, hsl(calc(var(--h) + 40) 100% 66%) 45%, hsl(var(--h) 95% 52%) 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  -webkit-text-stroke: .035em rgba(25, 8, 40, .85);
  filter: drop-shadow(0 0 .12em hsl(var(--h) 100% 60% / .9)) drop-shadow(.06em .06em 0 rgba(0, 0, 0, .7)); }
.slot-marquee.hot .content { filter: brightness(1.25); }

/* the camera layer: parallax moves it, the dive scales the stage around it */
.cam { position: absolute; inset: 0; will-change: transform; }

/* screen glow: light from each screen spilling onto its bezel and the room, coloured by what's playing */
.glows { position: absolute; inset: 0; pointer-events: none; mix-blend-mode: screen; }
.glow { position: absolute; left: 0; top: 0; transform-origin: 0 0; opacity: .6; filter: blur(5px) saturate(1.5);
  -webkit-mask-image: radial-gradient(closest-side, #000 58%, transparent 100%); mask-image: radial-gradient(closest-side, #000 58%, transparent 100%);
  transition: opacity .35s ease; }
.glows.focus .glow { opacity: .35; }
.glows .glow.hot { opacity: .9; }

/* hover: the chosen screen powers up, the rest of the wall dims a little */
.content.scr { cursor: pointer; }
.slots.focus .slot-screen:not(.hot) .content { filter: brightness(.72) saturate(.85); }
.slots.focus .slot-marquee:not(.hot) .content { filter: brightness(.8); }
.slot-screen.hot .content { filter: brightness(1.16) saturate(1.12); }
/* filters, fades and masks go on each slot's own content (small layers), never on the room-sized .slot wrapper */
.slot-screen .content, .slot-marquee .content { transition: filter .25s ease, opacity .3s ease; }
.scr::before { content: ""; position: absolute; inset: 0; z-index: 2; pointer-events: none; opacity: 0;
  background-image: var(--noise); background-size: 96px 96px; mix-blend-mode: screen; }
@media (prefers-reduced-motion: no-preference) {
  .slot-screen.zap .scr::before { animation: zap .32s steps(6) 1; }
  .slot-screen.zap .tube > video, .slot-screen.zap .tube > img { animation: surge .45s ease-out 1; }
}
@keyframes zap { 0% { opacity: .9; background-position: 0 0; } 50% { opacity: .55; background-position: 37px 61px; } 100% { opacity: 0; background-position: 71px 13px; } }
@keyframes surge { 0% { filter: brightness(2.1) contrast(.7); } 100% { filter: none; } }

/* sound toggle */
.sound { position: fixed; z-index: 6; top: calc(env(safe-area-inset-top, 0px) + 14px); right: max(16px, env(safe-area-inset-right, 0px));
  display: inline-flex; align-items: center; gap: 6px; font: 700 13px var(--ui); color: var(--paper); background: var(--glass);
  border: 1px solid rgba(242, 165, 65, .35); border-radius: 999px; padding: 6px 12px 6px 9px; backdrop-filter: blur(6px); cursor: pointer; }
.sound svg { width: 20px; height: 20px; }
.sound .waves { display: none; }
.sound.on { color: var(--ink); background: var(--lamp); border-color: var(--lamp); }
.sound.on .waves { display: inline; }
.sound.on .cross { display: none; }

/* development stage labels: WIP (striped, like site tape) and Beta */
.badge { display: inline-block; font: 800 11px/1 var(--ui); letter-spacing: .1em; text-transform: uppercase; padding: 4px 7px 3px;
  border-radius: 3px; vertical-align: middle; font-style: normal; }
.badge-wip { color: #1b120b; background: repeating-linear-gradient(-45deg, #f2c14e 0 6px, #e8a93a 6px 12px); }
.badge-beta { color: #08202a; background: #6fd3e6; }
.all-panel b .badge { margin-left: 6px; font-size: 10px; padding: 3px 6px 2px; }
/* the sticker on a screen: a bit of tape stuck to the glass, shown while the screen is pointed at */
.sticker { position: absolute; z-index: 3; top: 6%; right: 5%; font-size: 34px; padding: 8px 14px 6px; transform: rotate(6deg);
  box-shadow: 0 2px 6px rgba(0, 0, 0, .45); opacity: 0; transition: opacity .2s ease, transform .25s ease; pointer-events: none; }
.slot-screen.hot .sticker, .scr:focus-visible .sticker { opacity: 1; transform: rotate(3deg) scale(1.04); }

/* the game's name on its screen picture, like an attract screen */
.scr-title { position: absolute; z-index: 1; left: 0; right: 0; bottom: 0; padding: 1.4em 5% .9em; pointer-events: none;
  font: var(--tsize, 22px)/1.25 var(--pixel); text-transform: uppercase; text-align: center; color: #fff7dc; text-wrap: balance;
  text-shadow: .12em .12em 0 hsl(var(--h, 30) 80% 18%), 0 0 .5em hsl(var(--h, 30) 100% 55% / .8);
  background: linear-gradient(180deg, transparent, rgba(4, 3, 10, .72) 55%); }

/* About me: a sign at the room's left edge, toward the room next door */
.bar-left { display: flex; align-items: center; gap: 10px; min-width: 0; }
.door { pointer-events: auto; flex: none;
  font: 700 13px var(--ui); color: var(--paper); background: var(--glass); border: 1px solid rgba(242, 165, 65, .45);
  border-radius: 4px; padding: 7px 13px 7px 10px; backdrop-filter: blur(6px); cursor: pointer; transition: opacity .3s ease, background .2s; }
.door:hover { background: rgba(242, 165, 65, .22); }
.door span { color: var(--lamp); }
@media (prefers-reduced-motion: no-preference) { .door span { display: inline-block; animation: nudge 2.4s ease-in-out infinite; } }
@keyframes nudge { 0%, 70%, 100% { transform: none; } 80% { transform: translateX(-4px); } 90% { transform: translateX(1px); } }

/* walking over: the room's UI steps aside (the screens switch off with the remote, crtSwitch in room.js) */
body.away .slots .content { pointer-events: none; } /* on the way to the About Me room (or back), a tap skips ahead */
body.away .bar, body.away .card, body.away .all-panel { opacity: 0; visibility: hidden; transition: opacity .25s, visibility 0s .25s; }

.about { position: fixed; inset: 0; z-index: 4; overflow: hidden; background: #120c08; transition: opacity .25s ease; }
/* the walk fades in over the room (and out on the way back), so the cut between the page and the clip doesn't jump */
.about.fading { opacity: 0; }
.about-stage { position: absolute; left: 0; top: 0; overflow: hidden; }
.about .walk, .desk-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
.about .walk { opacity: 0; }
.about .walk.on { opacity: 1; }
.desk-img { opacity: 0; transition: opacity .2s ease; }
.about.at-desk .desk-img { opacity: 1; }
.about-back { position: fixed; z-index: 6; right: max(16px, env(safe-area-inset-right, 0px)); bottom: calc(env(safe-area-inset-bottom, 0px) + 16px);
  font: 700 14px var(--ui); color: var(--ink); background: var(--lamp); border: 0; border-radius: 999px; padding: 10px 16px; cursor: pointer;
  opacity: 0; pointer-events: none; transition: opacity .3s ease; }
.about.at-desk .about-back { opacity: 1; pointer-events: auto; }

/* what lies on the desk: papers drawn flat on the desktop (warped onto it), filled from room.json `about` */
.desk-top { position: absolute; left: 0; top: 0; transform-origin: 0 0; display: flex; align-items: center; justify-content: center;
  gap: 7%; padding: 4% 12%; opacity: 0; pointer-events: none; transition: opacity .6s ease .1s; }
.about.at-desk .desk-top { opacity: 1; pointer-events: auto; }
.paper { background: #f3e8d4; color: var(--ink); border-radius: 4px; box-shadow: 0 14px 30px rgba(40, 18, 4, .45), 0 2px 0 rgba(0, 0, 0, .12);
  background-image: linear-gradient(180deg, rgba(255, 255, 255, .5), rgba(180, 140, 90, .15)); }
.paper.note { width: 46%; padding: 46px 54px; transform: rotate(-2.5deg); }
.paper.note h2 { margin: 0 0 18px; font: 800 82px/1 var(--display); text-transform: uppercase; color: #3a2210; }
.paper.note p { margin: 0; font-size: 34px; line-height: 1.4; color: #4a3220; }
.paper.stats { width: 26%; padding: 40px 44px; display: flex; flex-direction: column; gap: 8px; transform: rotate(3deg); }
.paper.stats b { font: 800 150px/.9 var(--display); color: #b5541e; }
.paper.stats span { font-size: 32px; color: #4a3220; }
.paper.stats a { margin-top: 14px; font-size: 30px; font-weight: 700; color: #b5541e; }
/* a phone held upright: the papers sit flat over the desk instead of on its cropped sides */
.desk-top.flat { position: fixed; inset: auto max(16px, env(safe-area-inset-left, 0px)) calc(env(safe-area-inset-bottom, 0px) + 76px);
  width: auto !important; height: auto !important; transform: none; flex-direction: column; gap: 14px; padding: 0; }
.desk-top.flat .paper { width: 100%; transform: none; padding: 18px 20px; }
.desk-top.flat .paper.note h2 { font-size: 34px; margin-bottom: 8px; }
.desk-top.flat .paper.note p, .desk-top.flat .paper.stats span { font-size: 15px; }
.desk-top.flat .paper.stats { flex-direction: row; align-items: baseline; flex-wrap: wrap; gap: 6px 10px; }
.desk-top.flat .paper.stats b { font-size: 44px; }
.desk-top.flat .paper.stats a { margin: 0 0 0 auto; font-size: 15px; }
@media (prefers-reduced-motion: reduce) { .desk-top, .desk-img, .about-back, .slots, .glows { transition: none; } }

/* the TV remote clip plays over the idle loop, under the screens */
.remote { display: none; }
.remote.on { display: block; }
/* a clip that is starting stays invisible until its first frame is up (no blank or black frames) */
.remote.on.warming, .about .walk.on.warming { opacity: 0; }

/* everything on a screen's glass sits in one tube that can switch off like an old CRT */
.tube { position: absolute; inset: 0; display: block; transform-origin: 50% 50%; }
.slot-screen .title-card .tube { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .9em; padding: 8%; }
.slot-screen .title-card { padding: 0; }
.slot-screen .content::after { content: none; }
.slot-screen.crt-off .content::after, .slot-screen.crt-on .content::after { content: ""; position: absolute; inset: 42% 38%; z-index: 4; pointer-events: none; opacity: 0;
  background: radial-gradient(closest-side, #fffdf4, rgba(200, 225, 255, .9) 35%, transparent 70%); transform: scale(0); }
.slot-screen.crt-off .tube { animation: crtOff .5s cubic-bezier(.5, 0, .9, .5) forwards; }
.slot-screen.crt-off .content::after { animation: crtDot .56s ease-out forwards; }
.slot-screen.crt-on .tube { animation: crtOn .5s cubic-bezier(.2, .6, .4, 1) both; }
.slot-screen.crt-on .content::after { animation: crtDot .4s ease-out reverse both; }
.slot-screen.crt-dark .content { opacity: 0; }
.slot-screen.crt-off .content, .slot-screen.crt-on .content { opacity: 1; }
/* transform and opacity only (no filters): 13 screens switching at once stay cheap for the GPU. The white of the
   collapsing line comes from a white layer inside the tube (.tube::before) fading in as it squeezes. */
@keyframes crtOff {
  0% { transform: none; }
  40% { transform: scale(1.03, .015); }
  75% { transform: scale(.02, .015); }
  100% { transform: scale(0, 0); opacity: 0; } }
@keyframes crtOn {
  0% { transform: scale(0, 0); opacity: 1; }
  30% { transform: scale(.02, .015); }
  60% { transform: scale(1.03, .015); }
  100% { transform: none; } }
.slot-screen.crt-off .tube::before, .slot-screen.crt-on .tube::before { content: ""; position: absolute; inset: 0; z-index: 5;
  pointer-events: none; background: #fff6e8; opacity: 0; }
.slot-screen.crt-off .tube::before { animation: crtWhite .5s ease-in forwards; }
.slot-screen.crt-on .tube::before { animation: crtWhite .5s ease-out reverse both; }
@keyframes crtWhite { 0% { opacity: 0; } 35% { opacity: .9; } 100% { opacity: 1; } }
@keyframes crtDot { 0%, 55% { opacity: 0; transform: scale(0); } 70% { opacity: 1; transform: scale(.38, .75); } 100% { opacity: 0; transform: scale(.04); } }
.glows.dark { opacity: 0 !important; transition: opacity .45s ease; }

/* narrow phones: the About me and All games buttons keep one line; the hint gives way */
.all, .door { white-space: nowrap; }
@media (max-width: 440px) { .bar-left .hint { display: none; } }

/* the remote hand alone (VP9 with alpha), above the screens so it passes in front of them */
/* the bits of the room's video that pass in front of a screen (feet, Safari's remote hand), copied above the screens */
.occluder { position: absolute; display: block; pointer-events: none; }
.hand { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; pointer-events: none; display: none; }
.hand.on { display: block; }
.hand.on.warming { opacity: 0; }
