:root {
  /* the screen's safe area (notch, home bar, rounded corners). Everything fixed to an edge adds these. */
  --sa-t: env(safe-area-inset-top, 0px); --sa-r: env(safe-area-inset-right, 0px); --sa-b: env(safe-area-inset-bottom, 0px); --sa-l: env(safe-area-inset-left, 0px);
  --night: #0a0705;
  --amber: #ffb23e;
  --amber-dim: rgba(255, 178, 62, 0.55);
  --amber-faint: rgba(255, 178, 62, 0.16);
  --paper: #ece3cf;
  --ink: #1b1814;
  --ink-2: #3d352c;
  --ink-soft: rgba(27, 24, 20, 0.62);
  --ink-faint: rgba(27, 24, 20, 0.18);
  --mono: "Space Mono", ui-monospace, monospace;
  --crt: "VT323", "Space Mono", monospace;
  --cond: "Archivo", "Arial Narrow", sans-serif;
  --out: cubic-bezier(0.16, 0.84, 0.24, 1);
  --inout: cubic-bezier(0.65, 0, 0.35, 1);
  --grain: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='220' height='220'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.1  0 0 0 0 0.08  0 0 0 0 0.05  0 0 0 0.55 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--night); color: var(--amber); font-family: var(--mono); overflow: hidden; }
canvas#gl { position: fixed; inset: 0; width: 100%; height: 100%; display: block; transition: filter 0.5s var(--out); touch-action: none; }   /* fingers on the room are ours: no scroll, no zoom */
html, body { overscroll-behavior: none; }
body { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }   /* no double-tap zoom on the page itself */
body.dim canvas#gl { filter: blur(6px) brightness(0.5) saturate(0.85); }
button, a, select, input { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.screen { position: fixed; inset: 0; z-index: 10; }

/* ---------- show / hide: elements fade; their inner card moves (see JS show()/hide()) */
.fx { opacity: 0; transition: opacity 0.32s var(--out); }
.fx.in { opacity: 1; }

/* ---------- newsprint */
.paper { background-color: var(--paper); background-image: var(--grain); color: var(--ink); }
.pbtn {
  position: relative; display: inline-flex; justify-content: space-between; align-items: baseline; gap: 14px; text-decoration: none; cursor: pointer;
  border: 2px solid var(--ink); color: var(--ink); padding: 10px 16px; text-align: left; overflow: hidden;
  font-family: var(--cond); font-stretch: 75%; font-weight: 800; font-size: 17px; letter-spacing: 0.04em; text-transform: uppercase;
  background-color: transparent; background-image: linear-gradient(var(--ink), var(--ink)); background-repeat: no-repeat;
  background-position: left center; background-size: 0% 100%;
  transition: background-size 0.42s var(--out), color 0.25s, transform 0.2s var(--out);
}
.pbtn span::after { content: "→"; display: inline-block; margin-left: 10px; transition: transform 0.35s var(--out); }   /* always there; it steps forward on hover */
.pbtn[data-act="back"] span::after { content: none; }
.pbtn[data-act="back"] span::before { content: "←"; display: inline-block; margin-right: 10px; transition: transform 0.35s var(--out); }   /* back points back */
.pbtn[data-act="close"] span::after, .pbtn[data-act="arcade-close"] span::after { content: none; }   /* closing goes nowhere: no arrow */
.cover-actions .pbtn span::after { content: none; }   /* the main menu's four choices: no arrows */
.pbtn small { font-family: var(--mono); font-weight: 400; font-size: 11px; letter-spacing: 0.06em; text-transform: none; color: var(--ink-soft); transition: color 0.25s; }
/* Hover belongs to a pointer that can hover: on a touch screen it would stick after a tap, so every :hover in
   this sheet sits under (hover: hover) and is off in touch mode. A finger gets :active instead, which lasts
   only while it is down. Ink and fill always change together, so a label never sits on its own colour. */
.pbtn:focus-visible, .pbtn:active:not([disabled]) { background-size: 100% 100%; color: var(--paper); outline: none; }
.pbtn:focus-visible span::after { transform: translateX(4px); }
.pbtn:focus-visible span::before { transform: translateX(-4px); }
.pbtn:focus-visible small, .pbtn:active:not([disabled]) small { color: rgba(236, 227, 207, 0.75); }
@media (hover: hover) {
  :where(body:not(.touch)) .pbtn:hover:not([disabled]) { background-size: 100% 100%; color: var(--paper); outline: none; }
  :where(body:not(.touch)) .pbtn:hover:not([disabled]) span::after { transform: translateX(4px); }
  :where(body:not(.touch)) .pbtn:hover:not([disabled]) span::before { transform: translateX(-4px); }
  :where(body:not(.touch)) .pbtn:hover:not([disabled]) small { color: rgba(236, 227, 207, 0.75); }
}
.pbtn:active:not([disabled]) { transform: translateY(1px) scale(0.995); }
.pbtn.primary { background-color: var(--ink); color: var(--paper); background-image: linear-gradient(var(--ink-2), var(--ink-2)); }
.pbtn.primary small { color: rgba(236, 227, 207, 0.7); }
.pbtn[disabled] { cursor: progress; }
.pbtn[disabled] span::after { content: none; }
.pbtn.small { font-size: 13px; padding: 6px 10px; border-width: 1.5px; }
.pbtn.big { font-size: 20px; padding: 16px 28px; }

/* ---------- menu: the clipping over the room */
/* the clipping is only as tall as what is printed on it, and sits a little below the middle of the left side;
   on a short screen it scrolls inside itself */
#menu { pointer-events: none; display: flex; align-items: center; padding: calc(clamp(16px, 5vh, 56px) + var(--sa-t)) calc(clamp(16px, 4vw, 64px) + var(--sa-r)) calc(clamp(16px, 5vh, 56px) + var(--sa-b)) calc(clamp(16px, 4vw, 64px) + var(--sa-l)); }
#menu > * { pointer-events: auto; }
.menu-shade { position: absolute; inset: 0; pointer-events: none !important; background: linear-gradient(90deg, rgba(6, 4, 3, 0.75) 0%, rgba(6, 4, 3, 0.35) 38%, rgba(6, 4, 3, 0) 62%); }
.cover {
  position: relative; flex: none; margin-top: 4vh; max-height: 100%; overflow-y: auto; scrollbar-width: thin; scrollbar-color: var(--ink-faint) transparent;
  width: min(500px, 42vw); padding: clamp(20px, 3.4vh, 36px) clamp(22px, 2.4vw, 34px);
  display: grid; grid-template-rows: auto auto auto; grid-template-columns: minmax(0, 1fr); gap: clamp(16px, 2.8vh, 28px);
  container-type: inline-size; box-shadow: 0 30px 80px rgba(0, 0, 0, 0.55), 0 2px 0 rgba(0, 0, 0, 0.2);
  clip-path: polygon(0 0, 100% 0, 99.3% 4%, 100% 9%, 99.1% 15%, 100% 22%, 99.4% 29%, 100% 37%, 99.2% 44%, 100% 52%, 99.5% 60%, 100% 67%, 99.1% 74%, 100% 82%, 99.4% 89%, 100% 95%, 99.6% 100%, 0 100%);
  transform: translateX(-24px) rotate(-1.2deg); transform-origin: 0 100%;
  transition: transform 0.7s var(--out), opacity 0.5s;
}
#menu.in .cover { transform: rotate(-0.4deg); }
.cover > * { opacity: 0; transform: translateY(16px); transition: opacity 0.6s var(--out), transform 0.7s var(--out); }
#menu.in .cover > * { opacity: 1; transform: none; }
#menu.in .cover > :nth-child(1) { transition-delay: 0.08s; }
#menu.in .cover > :nth-child(2) { transition-delay: 0.18s; }
#menu.in .cover > :nth-child(3) { transition-delay: 0.28s; }
.cover-head { border-bottom: 3px solid var(--ink); padding-bottom: 8px; }
/* optical alignment: both lines start with a B, each with its own side bearing (0.075em in the kicker's
   width, 0.04em in the condensed title). Pulling each back by its bearing puts the two stems, and the rule
   under them, on one vertical. The margins are set on the two rules below. */

.cover-kicker { margin: 0 0 4px -0.075em; font-family: var(--cond); font-stretch: 100%; font-weight: 800; font-size: clamp(12px, 1.2vw, 16px); letter-spacing: 0.24em; text-transform: uppercase; }
.cover-title {
  margin: 0 0 0 -0.04em; font-family: var(--cond); font-stretch: 62%; font-weight: 900; text-transform: uppercase; overflow: hidden;
  font-size: min(84px, 6.4vw, 13vh); font-size: min(17.85cqi, 13vh); line-height: 0.86; letter-spacing: -0.005em;
}
.cover-title span { display: block; transform: translateY(100%); transition: transform 0.9s var(--out) 0.15s; }
#menu.in .cover-title span { transform: none; }
.cover-actions { display: grid; gap: 10px; align-content: center; }
.cover-actions .pbtn { padding: 13px 16px; font-size: clamp(16px, 1.5vw, 19px); }
.cover-actions .pbtn:nth-child(n) { transition: background-size 0.42s var(--out), color 0.25s, transform 0.2s var(--out); }
.cover-error { margin: 0; padding: 10px 14px; border: 2px solid #8e1a12; color: #8e1a12; font-size: 13px; line-height: 1.5; }
.cover-foot { display: flex; justify-content: space-between; align-items: flex-end; gap: 14px; border-top: 1.5px solid var(--ink); padding-top: 14px; flex-wrap: wrap; }
.ic-cta {
  display: block; border: 2px dashed var(--ink); padding: 10px 14px; text-decoration: none; color: var(--ink);
  font-family: var(--cond); font-stretch: 70%; font-weight: 900; font-size: 18px; text-transform: uppercase; line-height: 1.05;
  background-image: linear-gradient(var(--ink), var(--ink)); background-repeat: no-repeat; background-size: 0% 100%;
  transition: background-size 0.42s var(--out), color 0.25s;
}
.ic-cta:focus-visible, .ic-cta:active { background-size: 100% 100%; color: var(--paper); outline: none; }
@media (hover: hover) { :where(body:not(.touch)) .ic-cta:hover { background-size: 100% 100%; color: var(--paper); outline: none; } }
.cover-meta { margin-top: 6px; }
.quality { display: flex; align-items: center; justify-content: flex-start; gap: 4px; font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; }
.q-label { margin-right: 6px; color: var(--ink-soft); }
.quality button { background: transparent; border: 1.5px solid var(--ink-faint); padding: 5px 9px; cursor: pointer; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink); transition: background-color 0.25s, color 0.25s, border-color 0.25s; }
@media (hover: hover) { :where(body:not(.touch)) .quality button:hover { border-color: var(--ink); } }
.quality button[aria-checked="true"] { border-color: var(--ink); background: var(--ink); color: var(--paper); }

/* ---------- loading: the masthead on plain newsprint with a thin ink rule that fills. It covers everything
   until the room is ready, then dissolves into the menu. */
#loader { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: 24px; transition: opacity 0.9s var(--inout), visibility 0s linear 0.9s; }
#loader.done { opacity: 0; visibility: hidden; pointer-events: none; }
.loader-inner { width: min(620px, 100%); container-type: inline-size; }
.loader-inner .cover-kicker { opacity: 0; transition: opacity 0.6s var(--out) 0.1s; }
.loader-title { margin: 0 0 0 -0.04em; padding-bottom: 12px; overflow: hidden; font-family: var(--cond); font-stretch: 62%; font-weight: 900; text-transform: uppercase;
  font-size: 15vw; font-size: 17.85cqi; line-height: 0.86; letter-spacing: -0.005em; }
.loader-title span { display: block; transform: translateY(104%); transition: transform 0.9s var(--out); }
#loader.type .loader-title span { transform: none; }
#loader.type .cover-kicker { opacity: 1; }
.loader-bar { height: 3px; background: var(--ink-faint); overflow: hidden; }
.loader-bar i { display: block; height: 100%; background: var(--ink); transform-origin: 0 50%; transform: scaleX(0); transition: transform 0.4s var(--out); }
.loader-meta { display: flex; justify-content: space-between; margin: 10px 0 0; font-size: 12px; letter-spacing: 0.14em; text-transform: uppercase; }
.loader-meta output { font-variant-numeric: tabular-nums; }
#loader .cover-error { margin-top: 18px; }
#loader .pbtn { margin-top: 12px; }
#loader.failed .loader-bar i { background: #8e1a12; }

/* ---------- sheets: settings, controls, panels, pause (clippings dropped over the blurred room) */
.sheet { display: grid; place-items: center; background: rgba(6, 4, 3, 0.35); padding: calc(16px + var(--sa-t)) calc(16px + var(--sa-r)) calc(16px + var(--sa-b)) calc(16px + var(--sa-l)); }
.sheet-inner {
  width: min(560px, 100%); max-height: calc(100vh - 32px); max-height: calc(100dvh - 32px - var(--sa-t) - var(--sa-b)); overflow: auto; padding: 28px; box-shadow: 0 30px 90px rgba(0, 0, 0, 0.6);
  transform: translateY(26px) rotate(-1.4deg) scale(0.97); transition: transform 0.55s var(--out);
}
.sheet.in .sheet-inner { transform: rotate(-0.3deg); }
.sheet-inner.wide { width: min(980px, 100%); }
/* the DCS kits: a wider sheet, the first two renders large and the other three in a row under them */
#panel[data-panel="kits"] .sheet-inner { width: min(1400px, 100%); }
#panel[data-panel="kits"] .grid { grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 16px; }
#panel[data-panel="kits"] .grid > * { grid-column: span 2; }
#panel[data-panel="kits"] .grid > :nth-child(-n+2) { grid-column: span 3; }
@media (max-width: 720px) { #panel[data-panel="kits"] .grid { grid-template-columns: minmax(0, 1fr); } #panel[data-panel="kits"] .grid > *, #panel[data-panel="kits"] .grid > :nth-child(-n+2) { grid-column: auto; } }
.sheet h2 { margin: 0 0 18px; font-family: var(--cond); font-stretch: 62%; font-weight: 900; font-size: 44px; line-height: 0.9; text-transform: uppercase; }
.sheet header { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; position: sticky; top: -28px; margin: -28px -28px 20px; padding: 22px 28px 14px; border-bottom: 3px solid var(--ink); background-color: var(--paper); background-image: var(--grain); z-index: 1; }
.sheet header h2 { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.sheet header .pbtn { flex: none; }
.key { font-style: normal; }   /* the key that does the same thing: shown with a keyboard, dropped on touch */
body.touch .key { display: none; }
body.touch .mouse-only { display: none; }
#sa-probe { position: fixed; left: 0; top: 0; width: 0; height: 0; visibility: hidden; pointer-events: none; padding: var(--sa-t) var(--sa-r) var(--sa-b) var(--sa-l); }   /* main.js reads the insets off this */
.row { display: grid; grid-template-columns: 1fr 1fr auto; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--ink-faint); font-size: 13px; text-transform: uppercase; letter-spacing: 0.06em; }
.row select { background: var(--paper); border: 1.5px solid var(--ink); padding: 4px 6px; }
.row input[type=range], .row input[type=checkbox] { accent-color: var(--ink); }
.row input[type=checkbox] { width: 18px; height: 18px; justify-self: start; }
.row output { min-width: 3.5em; text-align: right; color: var(--ink-soft); }
.sheet [data-act="back"] { margin-top: 22px; }
.pause-list { display: grid; gap: 8px; }
.pause-list .pbtn { opacity: 0; transform: translateX(-10px); transition: opacity 0.4s var(--out), transform 0.5s var(--out), background-size 0.42s var(--out), color 0.25s; }
#pause.in .pause-list .pbtn { opacity: 1; transform: none; }
#pause.in .pause-list .pbtn:nth-child(2) { transition-delay: 0.05s, 0.05s, 0s, 0s; }
#pause.in .pause-list .pbtn:nth-child(3) { transition-delay: 0.1s, 0.1s, 0s, 0s; }
#pause.in .pause-list .pbtn:nth-child(4) { transition-delay: 0.15s, 0.15s, 0s, 0s; }
#pause.in .pause-list .pbtn:nth-child(5) { transition-delay: 0.2s, 0.2s, 0s, 0s; }

#panel-body { font-size: 14px; line-height: 1.55; }
#panel-body h3 { font-family: var(--cond); font-stretch: 70%; font-weight: 900; font-size: 22px; text-transform: uppercase; margin: 26px 0 8px; }
#panel-body .lead { font-size: 18px; }
#panel-body .note { color: var(--ink-soft); }
/* links out of a panel ("Read the ad", "Fill out the interest check"): paper buttons with their own class,
   nothing shared with the amber HUD buttons (.btn), whose dark ground used to show through here */
.plink { display: inline-block; margin: 4px 8px 0 0; padding: 10px 16px; border: 2px solid var(--ink); color: var(--ink); text-decoration: none; cursor: pointer;
  font-family: var(--cond); font-stretch: 75%; font-weight: 800; font-size: 17px; text-transform: uppercase; letter-spacing: 0.04em;
  background-color: transparent; background-image: linear-gradient(var(--ink), var(--ink)); background-repeat: no-repeat; background-position: left center; background-size: 0% 100%;
  transition: background-size 0.42s var(--out), color 0.25s; }
.plink:focus-visible, .plink:active { background-size: 100% 100%; color: var(--paper); outline: none; }
@media (hover: hover) { :where(body:not(.touch)) .plink:hover { background-size: 100% 100%; color: var(--paper); outline: none; } }
.plink:active { transform: translateY(1px); }
@media (prefers-reduced-motion: reduce) { .plink { transition: none; } }
.spec { display: grid; grid-template-columns: minmax(120px, 34%) 1fr; margin: 0; }
.spec dt, .spec dd { margin: 0; padding: 8px 0; border-bottom: 1px solid var(--ink-faint); }
.spec dt { font-family: var(--cond); font-stretch: 75%; font-weight: 800; text-transform: uppercase; font-size: 14px; letter-spacing: 0.04em; padding-right: 12px; }
.list { columns: 2; padding-left: 1.1em; margin: 0; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
figure { margin: 14px 0 0; }
figure img { width: 100%; height: auto; display: block; }
figcaption { font-size: 12px; color: var(--ink-soft); text-transform: uppercase; letter-spacing: 0.08em; margin-top: 6px; }
figcaption:empty { display: none; }
/* the photographs: the wide one across the top, the three square ones in a row, each kept whole */
.photos { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.photos figure { margin: 0; }
.photos figure:first-child { grid-column: 1 / -1; }
@media (max-width: 620px) { .photos { grid-template-columns: 1fr; } }
/* every picture in a panel lifts a little under the pointer or the focus ring */
#panel-body .fig-open { transition: transform 0.45s var(--out), box-shadow 0.45s var(--out); }
#panel-body .fig-open:focus-visible { transform: translateY(-4px) scale(1.012); box-shadow: 0 14px 26px rgba(27, 24, 20, 0.28); z-index: 1; }
@media (hover: hover) { :where(body:not(.touch)) #panel-body .fig-open:hover { transform: translateY(-4px) scale(1.012); box-shadow: 0 14px 26px rgba(27, 24, 20, 0.28); z-index: 1; } }
@media (prefers-reduced-motion: reduce) { #panel-body .fig-open { transition: none; } #panel-body .fig-open:hover, #panel-body .fig-open:focus-visible { transform: none; } }
/* the drawings: four cards of one shape (the spec sheet's, an A-series landscape). Each drawing is shown
   whole on white, never cropped. */
.sheets { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.sheets figure { margin-top: 0; }
.sheets .fig-open { aspect-ratio: 1191 / 842; background-color: #fff; }
.sheets .fig-open img { width: 100%; height: 100%; object-fit: contain; }
@media (max-width: 620px) { .sheets { grid-template-columns: 1fr; } }
/* panel images open full size in a new tab: the whole picture is the link, the magnifier says so */
.fig-open { position: relative; display: block; color: var(--ink); outline-offset: 3px; }
.fig-open:focus-visible { outline: 2px solid var(--ink); }
.fig-zoom { position: absolute; top: 8px; right: 8px; display: flex; align-items: center; gap: 0; height: 34px; padding: 0 7px;
  background-color: var(--paper); border: 2px solid var(--ink); color: var(--ink); font-family: var(--mono); font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase;
  transition: background-color 0.25s, color 0.25s; }
.fig-tip { max-width: 0; overflow: hidden; white-space: nowrap; opacity: 0; transition: max-width 0.3s var(--out), opacity 0.25s, margin 0.3s var(--out); }
.fig-open:focus-visible .fig-zoom, .fig-open:active .fig-zoom { background-color: var(--ink); color: var(--paper); }
.fig-open:focus-visible .fig-tip { max-width: 14em; opacity: 1; margin-left: 7px; }
@media (hover: hover) {
  :where(body:not(.touch)) .fig-open:hover .fig-zoom { background-color: var(--ink); color: var(--paper); }
  :where(body:not(.touch)) .fig-open:hover .fig-tip { max-width: 14em; opacity: 1; margin-left: 7px; }
}
@media (hover: none) { .fig-tip { max-width: 14em; opacity: 1; margin-left: 7px; } }
@media (prefers-reduced-motion: reduce) { .fig-zoom, .fig-tip { transition: none; } }

/* ---------- intro: letterbox and title card, like a commercial */
#letterbox { position: fixed; inset: 0; pointer-events: none; z-index: 8; }
#letterbox i { position: absolute; left: 0; right: 0; height: 11vh; background: #000; transform: scaleY(0); transition: transform 0.8s var(--inout); }
#letterbox i:first-child { top: 0; transform-origin: top; }
#letterbox i:last-child { bottom: 0; transform-origin: bottom; }
body.cinema #letterbox i { transform: none; }
#titlecard { position: fixed; inset: 0; z-index: 9; pointer-events: none; display: grid; place-content: start center; padding-top: 17vh; text-align: center;   /* top third: the board stays clear as it powers on */ opacity: 0; transition: opacity 0.9s var(--out); }
#titlecard.on { opacity: 1; }
#titlecard::before { content: ''; position: absolute; left: 0; right: 0; top: 0; height: 62vh; z-index: -1;   /* a dark fall-off behind the title, so the lit strip does not fight it */
  background: radial-gradient(ellipse 75% 62% at 50% 38%, rgba(5, 4, 3, 0.86) 0%, rgba(5, 4, 3, 0.6) 45%, rgba(5, 4, 3, 0) 100%); }
#titlecard p { margin: 0; color: var(--amber); text-shadow: 0 0 24px rgba(255, 160, 40, 0.55); }
.tc-kicker { font-family: var(--cond); font-weight: 800; font-size: clamp(12px, 1.4vw, 18px); letter-spacing: 0.5em; text-transform: uppercase; }
.tc-title { font-family: var(--cond); font-stretch: 62%; font-weight: 900; font-size: clamp(56px, 11vw, 168px); line-height: 0.9; text-transform: uppercase; letter-spacing: 0.18em; transition: letter-spacing 3.2s var(--out); }
#titlecard.on .tc-title { letter-spacing: 0.01em; }

/* ---------- HUD (amber, in the room) */
.btn {
  display: inline-block; border: 1px solid var(--amber-dim); color: var(--amber); padding: 0.55em 1em; text-transform: uppercase; letter-spacing: 0.08em; font-size: 13px; cursor: pointer; text-decoration: none;
  background-color: rgba(10, 7, 5, 0.75); background-image: linear-gradient(var(--amber), var(--amber)); background-repeat: no-repeat; background-size: 0% 100%;
  transition: background-size 0.38s var(--out), color 0.2s, border-color 0.2s;
}
.btn:focus-visible, .btn:active, .btn[aria-pressed="true"] { background-size: 100% 100%; color: var(--night); border-color: var(--amber); outline: none; }
@media (hover: hover) { :where(body:not(.touch)) .btn:hover { background-size: 100% 100%; color: var(--night); border-color: var(--amber); outline: none; } }
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 5; }
#crosshair { position: absolute; left: 50%; top: 50%; width: 6px; height: 6px; margin: -3px 0 0 -3px; border-radius: 50%; background: var(--amber); box-shadow: 0 0 8px var(--amber); opacity: 0.7; transition: transform 0.25s var(--out), opacity 0.25s; }
#hud.target #crosshair { transform: scale(2.2); opacity: 1; }
#prompt, #intro-prompt { font-family: var(--crt); font-size: 26px; letter-spacing: 0.06em; text-shadow: 0 0 10px rgba(255,178,62,0.7); white-space: nowrap; color: var(--amber); }
#prompt { position: absolute; left: 50%; top: 70%;   /* lower third: under the crosshair, clear of the chip and the music button */ transform: translate(-50%, 8px); opacity: 0; transition: opacity 0.25s, transform 0.35s var(--out); }
#hud.target #prompt { opacity: 1; transform: translate(-50%, 0); }
#prompt b, #intro-prompt b { border: 1px solid var(--amber); padding: 0 7px; margin-right: 10px; font-weight: 400; }
#hint { position: absolute; left: calc(24px + var(--sa-l)); bottom: calc(22px + var(--sa-b)); font-size: 12px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--amber-dim); transition: opacity 1s; }
#hint.gone { opacity: 0; }
/* ---------- touch (phones and tablets): body.touch is set by main.js. In the room nothing is selectable and
   a long press brings up no menu; the prompt becomes a chip to tap; a stick comes up under the left thumb;
   Pause (top left) and Next station (bottom right, over the music button) stand in for Esc and Tab. */
#stick, #touch-keys, #touch-next { display: none; }
body.touch:not(.dim) { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
body.touch #look-hint { display: none; }
/* the stick: a ring with a dark fill and an outlined knob, in the HUD's own line weight */
/* It is always there while walking, at rest where the left thumb lands (inside the safe area); it comes to the
   thumb that touches the left of the screen and goes home when the thumb lifts. Anything open hides it: a
   panel, the board, the arcade, pause, settings, and the intro before the plug goes in. */
body.touch #stick { display: block; position: fixed; left: calc(var(--sa-l) + clamp(76px, 14vw, 120px)); top: calc(100% - var(--sa-b) - clamp(104px, 16vh, 150px)); width: 0; height: 0; opacity: 0; transition: opacity 0.25s, left 0.2s var(--out), top 0.2s var(--out); pointer-events: none; }
body.touch[data-state="play"] #stick { opacity: 0.55; }
body.touch[data-state="play"] #stick.on { opacity: 1; transition: opacity 0.15s; }
body.touch.cinema #stick { opacity: 0; }
#stick::before { content: ''; position: absolute; left: -54px; top: -54px; width: 108px; height: 108px; border-radius: 50%; border: 1.5px solid rgba(255, 178, 62, 0.75); background: rgba(10, 8, 4, 0.3); }
#stick i { position: absolute; left: -22px; top: -22px; width: 44px; height: 44px; border-radius: 50%; border: 1.5px solid var(--amber); background: rgba(255, 178, 62, 0.3); }
/* Pause top left; Next station bottom right, over the music button, where a thumb is */
body.touch #touch-keys { display: block; position: absolute; left: calc(16px + var(--sa-l)); top: calc(16px + var(--sa-t)); pointer-events: auto; }   /* on the chip's line, with its margin */
body.touch #touch-next { display: block; position: absolute; right: calc(16px + var(--sa-r)); bottom: calc(70px + var(--sa-b)); pointer-events: auto; }
#touch-keys .btn, #touch-next.btn { min-width: 44px; min-height: 44px; padding: 0 14px; font-family: var(--mono); font-size: 12px; border-color: rgba(255, 178, 62, 0.8); background-color: rgba(10, 8, 4, 0.78); }
body.touch #music-toggle { width: 44px; height: 44px; right: calc(16px + var(--sa-r)); }
/* a press shows at once and is gone at once: no sweep caught half-way under a label */
body.touch :is(.btn, .pbtn, .plink, .ic-cta, #ic-chip) { transition-duration: 0s; }
body.touch .pbtn small { transition: none; }
body.touch #music-toggle { transition: opacity 0.3s; }
body.touch .inspect-bar .btn { transition: transform 0.5s var(--out), opacity 0.4s; }
/* the prompt is a chip; taps on it are read by the room (main.js), so it never swallows a thumb that lands there */
body.touch #prompt { top: 60%; pointer-events: none; padding: 9px 16px; min-height: 44px; display: flex; align-items: center; border: 1px solid var(--amber); background-color: rgba(10, 7, 5, 0.78); }
body.touch #intro-prompt b { display: none; }
body.touch #intro-ui .link { min-height: 44px; padding: 0 22px; font-size: 12px; color: var(--amber); border: 1px solid rgba(255, 178, 62, 0.8); background-color: rgba(10, 8, 4, 0.78); }
body.touch .inspect-bar .btn { min-height: 44px; }
body.touch .inspect-hint { font-size: 11px; letter-spacing: 0.1em; padding: 4px 8px; margin-bottom: 2px; background-color: rgba(10, 8, 4, 0.55); color: rgba(255, 178, 62, 0.85); }
body.touch #hint { left: calc(12px + var(--sa-l)); right: auto; max-width: calc(100% - 84px); bottom: calc(18px + var(--sa-b)); font-size: 10px; letter-spacing: 0.06em; white-space: nowrap;
  padding: 5px 8px; color: rgba(255, 178, 62, 0.85); background-color: rgba(10, 8, 4, 0.55); text-shadow: 0 1px 0 rgba(10, 8, 4, 0.9); }
@media (max-width: 760px) {   /* a narrow screen: the inspector's bar is two rows of the same width, clear of the music button */
  body.touch #inspect-ui { bottom: calc(84px + var(--sa-b)); }
  body.touch #inspect-ui { flex-direction: column-reverse; }   /* the gesture line above the buttons, off the music button's corner */
  body.touch .inspect-bar { display: grid; grid-template-columns: repeat(6, 1fr); width: 100%; padding: 0 20px; }
  body.touch .inspect-bar .btn:nth-child(-n+2) { grid-column: span 3; }
  body.touch .inspect-bar .btn:nth-child(n+3) { grid-column: span 2; padding: 0 4px; }
}
@media (max-height: 480px) {  /* a phone on its side: the prompt and the intro's two lines sit low, off the board */
  body.touch #prompt { top: auto; bottom: calc(70px + var(--sa-b)); }   /* level with Next station */
  body.touch #inspect-ui { flex-direction: row-reverse; justify-content: center; align-items: center; gap: 12px; bottom: calc(16px + var(--sa-b)); right: calc(var(--sa-r) + 68px); }   /* one line, low, the gesture hint first; all of it left of the music button */
  body.touch #intro-ui { bottom: calc(22px + var(--sa-b)); flex-direction: row; justify-content: center; align-items: center; gap: 18px; }
}
body.cinema #ic-chip { opacity: 0; pointer-events: none; }   /* out of the way of the intro's black bars */
@media (max-width: 900px) { body.dim #ic-chip { opacity: 0; pointer-events: none; } }   /* on a small screen a sheet takes the width: the chip would sit half under it (the sheets carry the same link) */
/* the pointer is free in the room (after Esc closed something): a quiet line under the crosshair; a click on the room takes it back */
#look-hint { position: absolute; left: 50%; top: calc(50% + 20px); transform: translateX(-50%); font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase; white-space: nowrap;
  color: var(--amber-dim); text-shadow: 0 0 8px rgba(10, 7, 5, 0.9); opacity: 0; transition: opacity 0.3s; }
body.look-free #look-hint { opacity: 1; }
body.look-free #crosshair { opacity: 0.35; }
body.look-free canvas#gl { cursor: pointer; }
#ic-chip {
  position: fixed; top: calc(16px + var(--sa-t)); right: calc(16px + var(--sa-r)); z-index: 7; display: flex; gap: 10px; align-items: baseline; text-decoration: none;
  background-color: var(--paper); color: var(--ink); border: 2px solid var(--ink); padding: 8px 12px;
  font-family: var(--cond); font-stretch: 75%; font-weight: 900; text-transform: uppercase; font-size: 14px; letter-spacing: 0.03em;
  background-image: linear-gradient(var(--ink), var(--ink)); background-repeat: no-repeat; background-size: 0% 100%;
  transition: opacity 0.32s var(--out), background-size 0.42s var(--out), color 0.25s;
}
#ic-chip span { font-family: var(--mono); font-weight: 400; font-size: 11px; text-transform: none; }
/* the game on the home computer: a beige monitor shell round a bulging tube, with scanlines */
#arcade { display: grid; place-content: center; justify-items: center; gap: 16px; background: rgba(4, 6, 6, 0.55); padding: var(--sa-t) var(--sa-r) var(--sa-b) var(--sa-l); }
#arcade .tube { position: relative; padding: clamp(14px, 3vw, 34px); border-radius: 26px; background: linear-gradient(#cfc5a8, #a89d80); box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6), inset 0 0 0 2px rgba(0, 0, 0, 0.18), inset 0 -10px 24px rgba(0, 0, 0, 0.25); }
#arcade canvas { display: block; width: min(86vw, 960px, 132vh); width: min(86vw, 960px, calc((100dvh - var(--sa-t) - var(--sa-b) - 130px) * 1.78), calc(100vw - var(--sa-l) - var(--sa-r) - 84px)); aspect-ratio: 16 / 9; image-rendering: pixelated; border-radius: 5% / 8%; background: #020706; cursor: pointer; touch-action: none;
  box-shadow: 0 0 0 6px #17140f, 0 0 42px rgba(99, 245, 212, 0.22); }
#arcade .tube::after { content: ''; position: absolute; inset: clamp(14px, 3vw, 34px); border-radius: 5% / 8%; pointer-events: none;
  background: repeating-linear-gradient(rgba(0, 0, 0, 0) 0 2px, rgba(0, 0, 0, 0.28) 2px 4px), radial-gradient(ellipse at center, rgba(0, 0, 0, 0) 55%, rgba(0, 0, 0, 0.55) 100%); }
#arcade .pbtn { justify-self: center; background-color: var(--paper); }
/* the unseen field for the initials: over the top of the tube, where the page has no need to move to show it; 16px so a phone does not zoom in on it */
#arcade-initials { position: absolute; left: 50%; top: 22%; width: 3em; height: 1.5em; margin: 0 0 0 -1.5em; padding: 0; border: 0; outline: 0; background: transparent; color: transparent; caret-color: transparent; font-size: 16px; opacity: 0; pointer-events: none; }
/* music on/off, bottom right: on the menu and in the room */
#music-toggle { position: fixed; right: calc(16px + var(--sa-r)); bottom: calc(16px + var(--sa-b)); z-index: 7; width: 40px; height: 40px; display: grid; place-items: center; padding: 0; cursor: pointer;
  background-color: var(--paper); color: var(--ink); border: 2px solid var(--ink);
  background-image: linear-gradient(var(--ink), var(--ink)); background-repeat: no-repeat; background-size: 0% 100%;
  transition: background-size 0.42s var(--out), color 0.25s, opacity 0.3s; }
#music-toggle:focus-visible, #music-toggle:active { background-size: 100% 100%; color: var(--paper); outline: none; }
@media (hover: hover) { :where(body:not(.touch)) #music-toggle:hover { background-size: 100% 100%; color: var(--paper); outline: none; } }
#music-toggle .slash { display: none; }
#music-toggle[aria-pressed="false"] .slash { display: block; }
#music-toggle[aria-pressed="false"] .waves { opacity: 0.25; }
body.cinema #music-toggle { opacity: 0; pointer-events: none; }
#ic-chip:focus-visible, #ic-chip:active { background-size: 100% 100%; color: var(--paper); outline: none; }
@media (hover: hover) { :where(body:not(.touch)) #ic-chip:hover { background-size: 100% 100%; color: var(--paper); outline: none; } }
#intro-ui { position: fixed; left: 0; right: 0; bottom: calc(15vh + var(--sa-b)); z-index: 10; display: flex; flex-direction: column; align-items: center; gap: 12px; pointer-events: none; }
#intro-ui .link { pointer-events: auto; background: none; border: 0; color: var(--amber-dim); font-size: 12px; letter-spacing: 0.14em; text-transform: uppercase; cursor: pointer; transition: color 0.2s; }
#intro-ui .link:focus-visible, #intro-ui .link:active { color: var(--amber); }
@media (hover: hover) { :where(body:not(.touch)) #intro-ui .link:hover { color: var(--amber); } }
#intro-prompt { margin: 0; animation: pulse 1.6s ease-in-out infinite; transition: opacity 0.3s; }
@keyframes pulse { 50% { opacity: 0.45; } }

/* ---------- inspect */
#inspect-ui, #safe-ui { position: fixed; left: var(--sa-l); right: var(--sa-r); bottom: calc(22px + var(--sa-b)); z-index: 6; display: flex; flex-direction: column; align-items: center; gap: 10px; pointer-events: none; }
.inspect-bar { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; pointer-events: auto; padding: 0 16px; }
.inspect-bar .btn { transform: translateY(14px); opacity: 0; transition: transform 0.5s var(--out), opacity 0.4s, background-size 0.38s var(--out), color 0.2s, border-color 0.2s; }
#inspect-ui.in .inspect-bar .btn, #safe-ui.in .inspect-bar .btn { transform: none; opacity: 1; }
#inspect-ui.in .inspect-bar .btn:nth-child(2) { transition-delay: 0.04s, 0.04s, 0s, 0s, 0s; }
#inspect-ui.in .inspect-bar .btn:nth-child(3) { transition-delay: 0.08s, 0.08s, 0s, 0s, 0s; }
#inspect-ui.in .inspect-bar .btn:nth-child(4) { transition-delay: 0.12s, 0.12s, 0s, 0s, 0s; }
#inspect-ui.in .inspect-bar .btn:nth-child(5) { transition-delay: 0.16s, 0.16s, 0s, 0s, 0s; }
#inspect-ui.in .inspect-bar .btn:nth-child(6) { transition-delay: 0.2s, 0.2s, 0s, 0s, 0s; }
.inspect-hint { margin: 0; font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--amber-dim); }
/* ---------- easter eggs (eggs.js): what the visitor carries, the safe's close-up, the alert */
#egg-hud { position: absolute; left: calc(24px + var(--sa-l)); bottom: calc(52px + var(--sa-b)); display: flex; align-items: center; gap: 12px; color: var(--amber); filter: drop-shadow(0 0 6px rgba(255, 178, 62, 0.6)); }
#egg-hud span { display: grid; animation: egg-in 0.5s var(--out); }
#egg-cup .steam { animation: pulse 1.6s ease-in-out infinite; }
@keyframes egg-in { from { opacity: 0; transform: translateY(8px) scale(1.5); } }
body.touch #egg-hud { left: calc(18px + var(--sa-l)); top: calc(72px + var(--sa-t)); bottom: auto; }   /* under Pause: the bottom corner is the walking thumb's */
body.touch #safe-ui .inspect-bar { display: flex; width: auto; }
body.touch #safe-ui { flex-direction: column-reverse; bottom: calc(22px + var(--sa-b)); right: var(--sa-r); }
/* the room on alert: red closes in from the edges of the view and beats slowly (well under three times a second) */
#alert-veil { position: fixed; inset: 0; z-index: 4; pointer-events: none; opacity: 0; transition: opacity 1.2s; background: radial-gradient(ellipse at center, rgba(255, 30, 10, 0) 42%, rgba(255, 30, 10, 0.34) 100%); }
body.alert #alert-veil { opacity: 1; animation: alert-beat 1.12s ease-in-out infinite; }
@keyframes alert-beat { 50% { opacity: 0.35; } }
@media (prefers-reduced-motion: reduce) { body.alert #alert-veil { animation: none; opacity: 0.7; } #egg-hud span, #egg-cup .steam { animation: none; } }
#labels { position: fixed; inset: 0; pointer-events: none; z-index: 4; }
.part-num {
  position: absolute; left: 0; top: 0; width: 24px; height: 24px; margin: -12px 0 0 -12px; border-radius: 50%; opacity: 0;
  display: grid; place-items: center; font-family: var(--cond); font-weight: 900; font-size: 13px; transition: opacity 0.3s;
  background: var(--paper); color: var(--ink); border: 1.5px solid var(--ink);
}
#parts-list {
  position: fixed; right: calc(16px + var(--sa-r)); top: calc(72px + var(--sa-t)); z-index: 6; width: 250px; padding: 14px 16px; border: 2px solid var(--ink);
  font-size: 12px; line-height: 1.5; opacity: 0; transform: translateX(16px) rotate(1deg); transition: opacity 0.35s, transform 0.5s var(--out); pointer-events: none;
}
#parts-list.on { opacity: 1; transform: rotate(0.3deg); }
#parts-list ol { margin: 0; padding-left: 1.4em; }

@media (max-width: 900px) {
  #parts-list { display: none; }
}
@media (max-width: 760px) {
  .menu-shade { background: linear-gradient(0deg, rgba(6, 4, 3, 0.8) 0%, rgba(6, 4, 3, 0.2) 60%); }
  #menu { align-items: flex-end; padding: calc(12px + var(--sa-t)) calc(12px + var(--sa-r)) calc(12px + var(--sa-b)) calc(12px + var(--sa-l)); }
  .cover { width: 100%; margin-top: 0; clip-path: none; }
  .cover-title { font-size: min(64px, 15vw); font-size: min(64px, 17.85cqi); }
}
@media (max-width: 640px) {
  .list { columns: 1; }
  .row { grid-template-columns: 1fr 1fr; }
  .row output { display: none; }
  #ic-chip span { display: none; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition-duration: 0.01ms !important; animation: none !important; } }

/* ---------- small screens: the sheets give up some margin, their titles shrink to leave the Close button whole,
   and on touch everything that can be pressed is at least 44 px */
@media (max-width: 480px) {
  .sheet-inner { padding: 20px; }
  .sheet h2 { font-size: clamp(26px, 8.6vw, 44px); }
  .row { grid-template-columns: 1.6fr 1fr; letter-spacing: 0.03em; }
  .sheet header { top: -20px; margin: -20px -20px 16px; padding: 16px 20px 12px; gap: 12px; align-items: center; }
}
body.touch .pbtn.small { min-height: 44px; min-width: 44px; padding: 0 14px; align-items: center; }
body.touch .quality button { min-height: 44px; min-width: 44px; }
body.touch .row { min-height: 44px; }
body.touch #ic-chip { min-height: 44px; align-items: center; }
body.touch #panel header { touch-action: none; }   /* a swipe down on a panel's header closes it, while the panel is at its top (main.js) */
body.touch .ic-cta { min-height: 44px; display: flex; align-items: center; }
body.touch .row input[type=range] { height: 44px; }
@media (hover: none) { .fig-zoom { top: auto; bottom: 8px; opacity: 0.9; } }   /* on touch the tag is always open: keep it off the picture's subject */
/* a phone: the music button would sit half under a sheet, the game or the clipping. It goes while one is up (Settings has the same switch). */
@media (max-width: 900px), (max-height: 480px) {
  body.dim #music-toggle, body[data-state="menu"] #music-toggle, body[data-state="settings"] #music-toggle, body[data-state="controls"] #music-toggle { opacity: 0; pointer-events: none; }
}
@media (max-height: 480px) {  /* a phone on its side: the sheets are as tight as on a narrow one */
  .sheet-inner { padding: 20px; }
  .sheet h2 { font-size: 28px; }
  .sheet header { top: -20px; margin: -20px -20px 14px; padding: 12px 20px 10px; gap: 12px; align-items: center; }
}
