/* harNES website, v2: a game running on a CRT television in a dark room.
   The page is the room. The set is drawn in CSS. Everything you read is on the picture tube, inside the glass;
   the booklet is paper, held in front of the set. Colours on the picture are the app's NES DARK palette
   (src/systems/nes.ts); the room and the furniture are their own browns and charcoals. */

:root {
  color-scheme: dark;
  /* the room */
  --room: #07070a;
  --wall: #0d0e14;
  --wood-a: #6b4425; --wood-b: #4a2d17; --wood-c: #34200f;
  --plastic: #1c1c1e; --plastic-hi: #2c2c30; --plastic-lo: #111113;
  /* the picture (NES DARK) */
  --screen: #101010; --paper: #000000; --ink: #dcdcdc; --dim: #bcbcbc; --frame: #7c7c7c;
  --sky: #3cbcfc; --red: #f83800; --coral: #f87858; --green: #58d854; --gold: #f8b800;
  --sand: #f8d878; --violet: #9878f8; --pink: #f878f8; --done: #7ecd7c;

  --display: 'Press Start 2P', 'Courier New', monospace;
  --label: 'Silkscreen', 'Courier New', monospace;
  --read: 'Helvetica Neue', Helvetica, Arial, system-ui, sans-serif;
  --term: 'VT323', ui-monospace, 'Courier New', monospace;
  --notch: 4px;

  /* THE SET'S SIZE is worked out by js/site.js from the frame and its screen rectangle (assets/tv/screen.json):
     --tvw and --tvh are the set, --S and --W the picture. These are only the values before it runs. */
  --tvw: min(calc(100vw - 32px), calc((100dvh - 46px) * 1.25));
  --tvh: calc(var(--tvw) / 1.25);
  --T: var(--tvw);
  --S: calc(var(--tvw) * .687);
  --W: calc(var(--tvw) * .916);
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--room); color: var(--ink); font: 16px/1.5 var(--read);
  -webkit-font-smoothing: antialiased; overflow: hidden;
}
img { display: block; max-width: 100%; height: auto; }
button { font: inherit; color: inherit; }
a { color: var(--sky); }
:focus-visible { outline: 3px solid var(--sand); outline-offset: 3px; }
[tabindex='-1']:focus { outline: none; }
/* THE KEY CAP. One component everywhere: a fixed height, the content centred both ways by flex (no baseline
   guessing), word keys padded evenly, single keys (.k1) square. Arrows are a 7 x 7 pixel shape in SVG, drawn in
   the key's own colour, so they match the letters' weight instead of falling back to a thin system glyph. */
kbd {
  display: inline-flex; align-items: center; justify-content: center; box-sizing: border-box; vertical-align: middle;
  height: 1.9em; min-width: 1.9em; padding: 0 .55em; margin: 0 .12em;
  font: 700 .78em/1 var(--read); letter-spacing: .06em; color: var(--ink); white-space: nowrap;
  border: 2px solid #8c8c8c; border-radius: 0; background: rgba(255, 255, 255, .05);
  position: relative; top: -.06em;
}
kbd.k1 { padding: 0; width: 1.9em; }
.ka { display: block; width: 1em; height: 1em; fill: currentColor; shape-rendering: crispEdges; }
.ka-d { transform: rotate(180deg); }
.ka-l { transform: rotate(-90deg); }
.ka-r { transform: rotate(90deg); }
.pgbtn { display: inline-flex; align-items: center; justify-content: center; }
.pgbtn .ka { width: .7em; height: .7em; }
code { font: 1.2em/1 var(--term); color: var(--sand); }
.sr { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; margin: -1px; padding: 0; border: 0; }
.defs { position: absolute; width: 0; height: 0; }

/* ================================================================== the room */
.room { position: fixed; inset: 0; z-index: 0; pointer-events: none; }
.wall {
  position: absolute; inset: 0 0 18% 0;
  background:
    radial-gradient(ellipse 48% 52% at 50% 44%, rgba(70, 120, 220, .13), transparent 70%),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, .012) 0 2px, transparent 2px 46px),
    linear-gradient(180deg, #08080c, var(--wall) 70%, #101119);
}
html.tv-off .wall { background: repeating-linear-gradient(90deg, rgba(255, 255, 255, .008) 0 2px, transparent 2px 46px), linear-gradient(180deg, #060608, #0a0a0e); }
.floor { display: none; }

.set { position: relative; z-index: 1; height: 100vh; height: 100dvh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 12px 16px 0; }

/* ================================================================== the television */
/* One layout for both looks. .tv is the frame's box; --gx --gy --gw --gh are the screen rectangle in percent of
   it, set by js/site.js from assets/tv/screen.json (or from the drawn set's own numbers). The glass sits on that
   rectangle. A photographed frame (.tv-frame) lies on top of the glass, its screen keyed out, with the glare
   (.tv-glare) over both; neither takes clicks. Without one, .tv-drawn draws the cabinet in CSS. */
.tv { position: relative; flex: 0 0 auto; width: var(--tvw); height: var(--tvh); --gx: 4.2; --gy: 5; --gw: 91.6; --gh: 85.9; }
.glass {
  position: absolute; z-index: 2; overflow: hidden; isolation: isolate; background: #000;
  left: calc(var(--gx) * 1%); top: calc(var(--gy) * 1%); width: calc(var(--gw) * 1%); height: calc(var(--gh) * 1%);
  border-radius: 4% / 5.4%;
}
.tv-frame, .tv-glare { position: absolute; inset: 0; width: 100%; height: 100%; max-width: none; pointer-events: none; user-select: none; }
.tv-frame { z-index: 3; }
.tv-glare { z-index: 5; }
.tv-frame[hidden], .tv-glare[hidden] { display: none; }
html.tv-image .tv-drawn, html.tv-image .tv-chin { display: none; }
html.tv-image .glass { left: calc(var(--gx) * 1% - 2px); top: calc(var(--gy) * 1% - 2px); width: calc(var(--gw) * 1% + 4px); height: calc(var(--gh) * 1% + 4px); }
.hot { position: absolute; z-index: 6; border: 0; padding: 0; border-radius: 50%; background: transparent; cursor: pointer; }
.hot:hover { box-shadow: 0 0 0 2px rgba(248, 216, 120, .45); }
.hot:focus-visible { outline: 3px solid var(--sand); outline-offset: 2px; }
/* THE POWER LIGHT, drawn here in both states (the photo's own light is retouched out): a grey socket ring, a
   maroon glass dome that is dark when off, and a lit dome with its halo laid over it that fades in and out. */
.hot-led {
  position: absolute; z-index: 6; border-radius: 50%; pointer-events: none; font-size: calc(var(--T) * .009);
  background: radial-gradient(circle at 46% 40%, #74706a 0 60%, #9a958f 66%, #5f5b57 74%, rgba(70, 67, 63, .6) 79%, transparent 83%);
}
.hot-led::before, .hot-led::after { content: ''; position: absolute; inset: 19%; border-radius: 50%; }
.hot-led::before {
  background:
    radial-gradient(circle at 34% 30%, rgba(255, 255, 255, .55) 0 9%, rgba(255, 255, 255, 0) 20%),
    radial-gradient(circle at 50% 58%, #6e211a, #4a120d 55%, #2c0805 90%);
  box-shadow: inset 0 -1px 2px rgba(0, 0, 0, .6), inset 0 1px 1px rgba(255, 180, 170, .12);
}
.hot-led::after {
  background:
    radial-gradient(circle at 34% 30%, rgba(255, 255, 255, .9) 0 9%, rgba(255, 255, 255, 0) 20%),
    radial-gradient(circle at 50% 54%, #ff8a66 0 10%, #ff4a26 34%, #e2220c 66%, #a01507 100%);
  box-shadow: 0 0 .5em .15em rgba(255, 60, 30, .75), 0 0 1.6em .7em rgba(255, 60, 30, .28);
  opacity: 1; transition: opacity .35s ease-out;
}
html.tv-off .hot-led::after { opacity: 0; transition-duration: .5s; }
@media (prefers-reduced-motion: reduce) { .hot-led::after { transition: none; } }
html.tv-image .fx-glare { background: none; }
/* PICTURE, VOLUME, POWER: printed on the strip, light and a little debossed */
.tv-label {
  position: absolute; z-index: 6; transform: translate(-50%, -50%); pointer-events: none; white-space: nowrap;
  font: 700 max(7px, calc(var(--tvh) * var(--lh) * .72))/1 var(--read); letter-spacing: .22em; margin-left: .11em;
  color: rgba(226, 220, 208, .62); text-shadow: 0 1px 0 rgba(0, 0, 0, .55), 0 -1px 0 rgba(255, 255, 255, .06);
}
html.tv-loading .tv { visibility: hidden; animation: tv-show 0s 2.5s forwards; }
@keyframes tv-show { to { visibility: visible; } }

/* the drawn set: wood cabinet, plastic front, a deep well round the glass, controls in the chin */
.tv-drawn {
  position: absolute; inset: 0; z-index: 1; border-radius: calc(var(--T) * .02);
  background:
    repeating-linear-gradient(180deg, rgba(0, 0, 0, .14) 0 1px, transparent 1px 7px, rgba(255, 220, 170, .035) 7px 8px, transparent 8px 19px),
    repeating-linear-gradient(176deg, rgba(40, 20, 6, .35) 0 2px, transparent 2px 41px),
    linear-gradient(180deg, var(--wood-a), var(--wood-b) 55%, var(--wood-c));
  box-shadow:
    0 40px 80px rgba(0, 0, 0, .75), 0 12px 24px rgba(0, 0, 0, .6),
    inset 0 2px 0 rgba(255, 230, 190, .18), inset 0 -4px 0 rgba(0, 0, 0, .35);
}
.tv-drawn::before {
  content: ''; position: absolute; inset: calc(var(--T) * .012); border-radius: calc(var(--T) * .012);
  background: linear-gradient(180deg, var(--plastic-hi), var(--plastic) 30%, var(--plastic-lo));
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, .09), inset 0 -2px 0 rgba(0, 0, 0, .6), 0 0 0 2px rgba(0, 0, 0, .55);
}
.tv-well {
  position: absolute;
  left: calc(var(--gx) * 1% - var(--T) * .014); top: calc(var(--gy) * 1% - var(--T) * .014);
  width: calc(var(--gw) * 1% + var(--T) * .028); height: calc(var(--gh) * 1% + var(--T) * .028);
  border-radius: calc(var(--T) * .05) / calc(var(--T) * .055);
  background: radial-gradient(ellipse at 50% 40%, #151515, #070707);
  box-shadow: inset 0 0 0 2px #000, inset 0 8px 22px rgba(0, 0, 0, .95), 0 1px 0 rgba(255, 255, 255, .08), 0 -1px 0 rgba(0, 0, 0, .6);
}
.tv-chin {
  position: absolute; z-index: 3; display: flex; align-items: center; gap: calc(var(--T) * .022);
  left: calc(var(--gx) * 1% + var(--T) * .01); right: calc((100 - var(--gx) - var(--gw)) * 1% + var(--T) * .01);
  top: calc((var(--gy) + var(--gh)) * 1% + var(--T) * .016); bottom: calc(var(--T) * .016);
}
.tv-badge { font: calc(var(--T) * .009)/1 var(--label); letter-spacing: .32em; color: rgba(255, 225, 180, .45); white-space: nowrap; }
.chan {
  display: flex; align-items: baseline; gap: .3em; padding: .15em .5em .05em;
  background: #0a0504; box-shadow: inset 0 2px 6px rgba(0, 0, 0, .9), 0 1px 0 rgba(255, 255, 255, .06);
  font: calc(var(--T) * .022)/1 var(--term); color: #ff4a2a; text-shadow: 0 0 6px rgba(255, 70, 30, .8);
}
.chan-l { font-size: .5em; letter-spacing: .1em; opacity: .7; }
html.tv-off .chan { color: #2a0f0a; text-shadow: none; }
.grille { flex: 1 1 auto; align-self: stretch; margin: 12% 0; background: repeating-linear-gradient(90deg, #0b0b0c 0 3px, #26262a 3px 5px); border-radius: 3px; box-shadow: inset 0 0 0 2px #0b0b0c; }
.knobs { display: flex; gap: calc(var(--T) * .018); }
.knob { background: none; border: 0; padding: 0; cursor: pointer; display: flex; align-items: center; gap: .6em; }
.knob i {
  display: block; width: calc(var(--T) * .03); height: calc(var(--T) * .03); border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #5a5a60, #2a2a2e 55%, #151517);
  box-shadow: 0 3px 6px rgba(0, 0, 0, .7), inset 0 1px 0 rgba(255, 255, 255, .2); position: relative;
  transition: transform .25s steps(4, end);
}
.knob i::after { content: ''; position: absolute; left: 50%; top: 8%; width: 3px; height: 38%; margin-left: -1.5px; background: #d8d8d8; }
.knob span { font: max(8px, calc(var(--T) * .0075))/1 var(--label); letter-spacing: .12em; color: #8b8b90; }
.knob:hover span { color: #ddd; }
.knob[data-pos='1'] i { transform: rotate(60deg); }
.knob[data-pos='2'] i { transform: rotate(120deg); }
.power { display: flex; align-items: center; gap: .8em; }
.pwr {
  cursor: pointer; border: 0; padding: 0 1em; height: calc(var(--T) * .024);
  background: linear-gradient(180deg, #3a3a3f, #222225); border-radius: 3px;
  box-shadow: 0 3px 0 #0a0a0b, inset 0 1px 0 rgba(255, 255, 255, .18);
  font: max(8px, calc(var(--T) * .0075))/1 var(--label); letter-spacing: .12em; color: #a0a0a6;
}
.pwr:active, .pwr[aria-pressed='false'] { transform: translateY(2px); box-shadow: 0 1px 0 #0a0a0b, inset 0 1px 0 rgba(255, 255, 255, .1); }
.led { width: 8px; height: 8px; border-radius: 50%; background: #3a0b06; box-shadow: inset 0 1px 1px rgba(0, 0, 0, .6); }
html:not(.tv-off) .led { background: #ff3b1f; box-shadow: 0 0 6px 2px rgba(255, 60, 30, .7); }

/* ================================================================== the picture tube */
.picture {
  position: absolute; inset: 0; z-index: 0; overflow: hidden;
  background: radial-gradient(ellipse 70% 65% at 50% 45%, #161917, #0b0c0b 75%); color: var(--ink);
  font-size: max(12px, calc(var(--S) / 38));
}
.picture.reading { background: radial-gradient(ellipse 70% 65% at 50% 45%, #181a19, #101110 80%); }
html.crt-off .picture { background: var(--paper); }
html.crt-off .picture.reading { background: var(--screen); }
html.crt-full .picture { filter: url(#crt-full); }
html.crt-full .picture.reading, html.crt-soft .picture { filter: url(#crt-soft); }
html.no-tube .picture { filter: none !important; }
html.tv-off .picture { visibility: hidden; }

.fx { position: absolute; inset: 0; pointer-events: none; z-index: 2; border-radius: inherit; }
.fx-scan { background: repeating-linear-gradient(to bottom, rgba(0, 0, 0, .58) 0 1px, rgba(0, 0, 0, .18) 1px 2px, transparent 2px 3px); }
.picture.reading ~ .fx-scan, html.crt-soft .fx-scan { background: repeating-linear-gradient(to bottom, rgba(0, 0, 0, .3) 0 1px, transparent 1px 3px); }
.fx-mask {
  background: repeating-linear-gradient(90deg, rgba(255, 40, 70, .16) 0 1px, rgba(40, 255, 100, .16) 1px 2px, rgba(50, 100, 255, .16) 2px 3px);
  mix-blend-mode: multiply;
}
.picture.reading ~ .fx-mask, html.crt-soft .fx-mask { display: none; }
.fx-roll {
  inset: auto 0 auto 0; top: -30%; height: 30%;
  background: linear-gradient(180deg, transparent, rgba(255, 255, 255, .06) 45%, rgba(255, 255, 255, .02) 60%, transparent);
  animation: roll 6.5s linear infinite;
}
.picture.reading ~ .fx-roll, html.crt-soft .fx-roll { opacity: .45; }
@keyframes roll { to { transform: translateY(440%); } }
.fx-flick { background: rgba(255, 255, 255, .03); animation: flick .14s steps(2, end) infinite; }
.picture.reading ~ .fx-flick, html.crt-soft .fx-flick { display: none; }
@keyframes flick { 50% { opacity: .15; } }
.fx-vig { background: radial-gradient(ellipse 72% 68% at 50% 50%, transparent 52%, rgba(0, 0, 0, .5) 86%, rgba(0, 0, 0, .9) 100%); }
.picture.reading ~ .fx-vig, html.crt-soft .fx-vig { background: radial-gradient(ellipse 78% 74% at 50% 50%, transparent 62%, rgba(0, 0, 0, .38) 90%, rgba(0, 0, 0, .75) 100%); }
.fx-glare {
  background:
    radial-gradient(ellipse 55% 40% at 26% 16%, rgba(255, 255, 255, .085), transparent 62%),
    linear-gradient(162deg, rgba(255, 255, 255, .045), transparent 34%);
  box-shadow: inset 0 0 40px 8px rgba(0, 0, 0, .8), inset 0 0 3px 3px rgba(0, 0, 0, .95);
}
.fx-static { z-index: 3; width: 100%; height: 100%; image-rendering: pixelated; opacity: 0; mix-blend-mode: screen; }
.fx-static.on { opacity: .9; }
html.crt-off .fx-scan, html.crt-off .fx-mask, html.crt-off .fx-roll, html.crt-off .fx-flick, html.crt-off .fx-vig { display: none; }
html.crt-off .fx-glare { background: none; box-shadow: inset 0 0 0 2px #000; }

/* the tube off, and the power-on: a dot, a line, then the picture */
.tube { position: absolute; inset: 0; z-index: 4; display: grid; place-items: center; pointer-events: none; background: transparent; }
html.tv-off .tube, html.tv-booting .tube { background: radial-gradient(ellipse at 40% 30%, #1a1d1c, #0b0d0c 70%); }
.beam { display: block; width: 0; height: 0; background: #fff; box-shadow: 0 0 18px 6px rgba(200, 230, 255, .8); border-radius: 50%; opacity: 0; }
.tube.bright { background: #000 !important; }

/* ================================================================== screens */
.scr { position: absolute; inset: 0; display: flex; flex-direction: column; padding: 5.5% 8% 4.6%; }
.scr[hidden] { display: none; }
.picture .jolt { animation: jolt .18s steps(3, end); }
@keyframes jolt { 33% { transform: translate(0, -6px) skewX(2deg); } 66% { transform: translate(3px, 4px); } }

/* TITLE */
.scr-title { padding: 4.5% 8% 4%; }
/* THE TITLE'S GRID. One spacing scale (--s1 to --s5); the hero in the upper third, the party and its line as one
   unit, PRESS START in a slot of its own height in the lower middle (so the blink never moves anything), the fine
   print as a block, and the copyright alone on the last line, clear of the curved bottom edge. The three gaps
   share what is left: more above PRESS START than around it. */
.title-in {
  --s1: .5em; --s2: 1em; --s3: 1.5em; --s4: 2.5em; --s5: 4em;
  flex: 1; min-height: 0; display: flex; flex-direction: column; align-items: center; text-align: center;
  padding: var(--s2) 0; transition: opacity .4s steps(4, end);
}
.t-hero { width: 100%; display: flex; flex-direction: column; align-items: center; }
.t-gap { display: block; flex: 1 1 0; min-height: var(--s3); }
.t-gap.g2 { flex-grow: 1.3; min-height: var(--s4); }
.t-party { display: flex; flex-direction: column; align-items: center; gap: var(--s3); }
.wordmark { margin: 0; width: 64%; line-height: 0; }
.wordmark img { width: 100%; image-rendering: pixelated; }
.subtitle {
  /* the rule sits one wordmark block below the letters (the wordmark is 48 blocks wide, so a block is its width
     / 48; vertical margins and padding in % are of the width too), and AGENT CONSOLE one block below the rule */
  --wm: 64%;
  margin: calc(var(--wm) / 48) 0 0; width: var(--wm); border-top: .26em solid var(--red); padding-top: calc(var(--wm) / 48); text-align: right;
  font: .95em/1 var(--display); letter-spacing: .5em; margin-right: -.5em; color: var(--ink);
}
.lede { margin: 0 auto; max-width: 36em; font: .78em/1.8 var(--label); letter-spacing: .05em; color: #cfcfcf; }
.party { --s: 1; display: grid; grid-template-columns: repeat(12, auto); gap: .3em; margin: 0; justify-content: center; }
.party.two { grid-template-columns: repeat(6, auto); gap: .4em .9em; }
.spr {
  --row: 0; --col: 0;
  width: calc(48px * var(--s)); height: calc(52px * var(--s));
  background: url(../assets/sprites/party.png) no-repeat;
  background-size: calc(336px * var(--s)) calc(624px * var(--s));
  background-position: calc(-48px * var(--s) * var(--col)) calc(-52px * var(--s) * var(--row));
  image-rendering: pixelated;
}
.title-action { height: 3.4em; display: flex; flex-direction: column; align-items: center; justify-content: center; }
html.started .title-action { height: auto; }
/* once the menu is up, the line about the console has done its job; the menu takes its room */
html.started .lede { display: none; }
html.started .t-gap { min-height: var(--s2); }
.press-start {
  font: 1.15em/1 var(--display); color: var(--ink); background: none; border: 0; padding: .7em 1em; cursor: pointer;
  display: inline-flex; align-items: center; gap: .8em; animation: blink 1.06s steps(1, end) infinite;
}
.press-start .cur { color: var(--sand); font-size: .8em; }
@keyframes blink { 50% { opacity: 0; } }
html.started .press-start { display: none; }
html.js .menu { display: none; }
html.js.started .menu, html.no-js .menu { display: block; }
html.no-js .press-start { display: none; }
.menu { position: relative; isolation: isolate; padding: 1.1em 2em 1em 1.4em; text-align: left; }
.menu::before, .win::before {
  content: ''; position: absolute; inset: 0; z-index: -1; background: var(--paper); border: 2px solid var(--ink);
  clip-path: polygon(var(--notch) 0, calc(100% - var(--notch)) 0, 100% var(--notch), 100% calc(100% - var(--notch)), calc(100% - var(--notch)) 100%, var(--notch) 100%, 0 calc(100% - var(--notch)), 0 var(--notch));
}
.menu ul { list-style: none; margin: 0; padding: 0; }
.menu a { display: flex; align-items: center; gap: .8em; padding: .52em .2em; color: var(--ink); text-decoration: none; font: .82em/1 var(--display); }
.menu a:focus-visible { outline: none; }
.menu .cur { color: var(--sand); font-size: .8em; visibility: hidden; }
.menu a.on .cur, .menu a:focus-visible .cur { visibility: visible; animation: blink .8s steps(1, end) infinite; }
.menu a.on, .menu a:focus-visible { color: var(--sand); }
.title-foot { font: .72em/2 var(--label); letter-spacing: .14em; color: var(--dim); }
.title-foot p { margin: 0; }
.title-foot .sp { display: inline-block; width: 1.6em; }
.t-copy { margin: var(--s3) 0 0; font: .72em/1 var(--label); letter-spacing: .14em; color: #9a9a9a; }
.brand { font: .9em/1 var(--display); letter-spacing: 0; }
/* attract */
.attract { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 1em; padding: 6% 8%; opacity: 0; visibility: hidden; }
.scr-title.attracting .title-in { opacity: 0; }
.scr-title.attracting .attract { opacity: 1; visibility: visible; }
.attract-tag { margin: 0; font: .8em/1 var(--display); color: var(--sand); letter-spacing: .3em; }
.attract-frame { width: 100%; border: 2px solid var(--frame); overflow: hidden; }
.attract-frame img { width: 100%; transform-origin: 30% 30%; }
.scr-title.attracting .attract-frame img { animation: pan 9s ease-in-out forwards; }
@keyframes pan { from { transform: scale(1.4) translate(8%, 8%); } to { transform: scale(1); } }
.attract-start { margin: 0; font: .8em/1 var(--display); animation: blink 1.06s steps(1, end) infinite; }

/* READING SCREENS */
.bar { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 1.2em; padding-bottom: .7em; margin-bottom: .9em; border-bottom: 2px solid #3a3a3a; }
.bar h2 { margin: 0; font: .95em/1.3 var(--display); color: var(--ink); display: flex; align-items: center; gap: .7em; }
.tri { color: var(--red); font-size: .7em; }
.back { font: .8em/1 var(--label); letter-spacing: .12em; color: var(--dim); text-decoration: none; display: inline-flex; align-items: center; gap: .5em; padding: .3em 0; }
.back:hover { color: var(--sand); }
.pg { margin: 0; font: .8em/1 var(--label); letter-spacing: .14em; color: var(--dim); }
.body { color: #e6e6e6; flex: 1 1 auto; overflow-y: auto; overflow-x: hidden; padding-right: .6em; scrollbar-width: thin; scrollbar-color: #555 transparent; font-size: .95em; }
.body::-webkit-scrollbar { width: 8px; }
.body::-webkit-scrollbar-thumb { background: #555; }
.body p { margin: 0 0 .8em; max-width: 42em; }
.hint { display: flex; align-items: center; justify-content: center; gap: 1.2em; margin-top: .7em; padding-top: .6em; border-top: 2px solid #2c2c2c; font: .72em/1 var(--label); letter-spacing: .12em; color: #a8a8a8; }
.hint { gap: 1.4em; }
.hint span { display: inline-flex; align-items: center; gap: .3em; }
.hint kbd { font-size: .95em; margin: 0 .1em; color: #d6d6d6; }
.hint kbd + :not(kbd) { margin-left: .2em; }
.pgbtn { background: none; border: 2px solid #555; color: var(--ink); cursor: pointer; font: 1.2em/1 var(--display); padding: .3em .55em; }
.pgbtn:hover { border-color: var(--ink); }
.pgbtn:disabled { opacity: .3; cursor: default; }

.page { display: none; }
.page.on { display: block; }
.page.cols.on { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 1.6em; align-items: start; }
.page h3 { margin: 0 0 .8em; font: .9em/1.4 var(--display); display: flex; align-items: center; gap: .7em; }
.n { display: inline-grid; place-items: center; width: 1.8em; height: 1.8em; background: var(--red); color: #fff; font: .85em/1 var(--display); padding-top: .1em; flex: 0 0 auto; }
.shout { margin: 0 0 .6em; font: 700 italic 2.2em/1 var(--read); letter-spacing: -.035em; color: #f1ede2; padding-bottom: .3em; border-bottom: .14em solid var(--red); }
.tag { font: 700 italic 1.25em/1.1 var(--read) !important; letter-spacing: -.02em; color: #f1ede2; }
.shot { margin: .4em 0 0; }
.shot img { border: 2px solid #2c2c2c; max-height: calc(var(--S) * .5); width: auto; }
.shot.tall img { max-height: calc(var(--S) * .62); }
.shot.narrow img { max-height: calc(var(--S) * .3); }
.shot figcaption { font-size: .8em; color: var(--dim); margin-top: .4em; }
.roster { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: .8em .4em; padding: .9em .4em .7em; border: 2px solid #2c2c2c; margin-top: .4em; }
.roster-i { display: flex; flex-direction: column; align-items: center; gap: .4em; }
.roster-i .spr { --s: 1; }
.roster-i span { font: .6em/1.2 var(--label); letter-spacing: .06em; color: var(--dim); text-align: center; }
.status { list-style: none; margin: 2.6em 0 0; padding: 0; display: grid; gap: .55em; font-size: .9em; color: var(--dim); }
.status li { display: grid; grid-template-columns: .8em 6.2em 1fr; gap: .7em; align-items: baseline; }
.status b { font: 400 .85em/1 var(--label); letter-spacing: .08em; }
.sq { width: .65em; height: .65em; display: inline-block; }
.sq.working { background: var(--green); } b.working { color: var(--green); }
.sq.idle { background: var(--gold); } b.idle { color: var(--gold); }
.sq.standby { background: var(--dim); } b.standby { color: var(--dim); }
.sq.alert { background: var(--coral); } b.alert { color: var(--coral); }
.sq.done { background: var(--done); } b.done { color: var(--done); }
.alpha { font: .6em/1 var(--label); color: var(--pink); border: 2px solid var(--pink); padding: .25em .35em .15em; letter-spacing: .1em; }
.keys { margin: .4em 0 0; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 0 2em; }
.keys > div { display: grid; grid-template-columns: 6.5em 1fr; align-items: center; gap: .8em; padding: .7em 0; border-bottom: 2px dotted #333; }
.keys dt { display: flex; gap: .35em; }
.keys dd { margin: 0; }

.booklet-screen { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); gap: 1.6em; align-items: center; }
.bk-cover { padding: 0; border: 0; background: none; cursor: pointer; transform: rotate(-2deg); box-shadow: .5em .5em 0 #000; }
.bk-cover:hover { transform: rotate(0); }
.a-btn {
  display: inline-flex; align-items: center; gap: .7em; margin-top: .6em;
  font: .78em/1.2 var(--display); color: var(--ink); background: var(--paper); text-decoration: none; cursor: pointer;
  border: 2px solid var(--ink); padding: .8em 1em;
}
.a-btn .cur { color: var(--sand); font-size: .8em; }
.a-btn:hover, .a-btn:focus-visible { color: var(--sand); border-color: var(--sand); }
.a-btn.go { background: var(--red); border-color: var(--red); color: #fff; }
.a-btn.go .cur { color: #fff; }
.a-btn.go:hover { background: #fff; color: #000; border-color: #fff; }
.cta { display: flex; flex-wrap: wrap; gap: .8em; }
.small { font-size: .82em; color: var(--dim); }
.steps { list-style: none; margin: 1em 0; padding: 0; display: grid; gap: .9em; }
.steps li { display: grid; grid-template-columns: auto 1fr; gap: 1em; align-items: start; padding: .8em 1em; border: 2px solid #3a3a3a; }
.steps h3 { margin: .2em 0 .5em; font: .85em/1.3 var(--display); }
.steps p { margin: 0; }
.term { margin: 0 0 1em; padding: .8em 1em; background: #000; border: 2px solid #2c2c2c; overflow-x: auto; font: 1.3em/1.25 var(--term); color: var(--ink); white-space: pre; }
.term code { font: inherit; color: inherit; }
.term .ps { color: var(--green); }
.fine { margin-top: 1.4em; padding-top: 1em; border-top: 2px solid #2c2c2c; font-size: .85em; color: var(--dim); }
.opts { list-style: none; margin: .6em 0 1.4em; padding: 0; display: grid; gap: .5em; }
.opt { display: grid; grid-template-columns: 9em 1fr; align-items: center; gap: 1em; padding: .6em .8em; border: 2px solid transparent; }
.opt.on { border-color: #555; }
.opt-name { font: .8em/1 var(--display); display: flex; align-items: center; gap: .6em; }
.opt.on .opt-name::before { content: '\25B6'; color: var(--sand); font-size: .8em; }
.opt-vals { display: flex; gap: .5em; flex-wrap: wrap; }
.opt-vals button { background: none; border: 2px solid #444; color: var(--dim); cursor: pointer; font: .7em/1 var(--display); padding: .6em .8em; }
.opt-vals button[aria-checked='true'] { border-color: var(--sand); color: var(--sand); }
.opt-vals button:hover { color: var(--ink); border-color: var(--ink); }

.placard { position: relative; z-index: 2; margin: 0; padding: 8px 16px 10px; text-align: center; font: 12px/1.5 var(--read); color: #8f8f96; }
.placard span { display: inline-block; margin-left: 1em; color: #6f6f76; }

/* ================================================================== the booklet, in front of the set */
.bk-overlay {
  position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(ellipse 80% 70% at 50% 45%, rgba(22, 22, 28, .985), rgba(4, 4, 6, .99) 75%);
  padding: 16px max(16px, env(safe-area-inset-right, 0px)) 16px max(16px, env(safe-area-inset-left, 0px));
}
.bk-overlay[hidden] { display: none; }
.bk { width: min(1240px, 100%); display: flex; flex-direction: column; gap: 14px; }
.bk-stage { position: relative; width: 100%; overflow: visible; }
.bk-stage:focus { outline: none; }
.bk-book { position: relative; height: 100%; transition: transform .55s cubic-bezier(.3, .7, .3, 1); }
.stf__parent { min-width: 0 !important; min-height: 0 !important; max-width: none !important; }
.stf__block { filter: drop-shadow(0 18px 22px rgba(0, 0, 0, .7)) drop-shadow(0 3px 4px rgba(0, 0, 0, .7)); }
.bk-page { background: #fdfcf9; overflow: hidden; }
.bk-page img { display: block; width: 100%; height: 100%; object-fit: cover; user-select: none; -webkit-user-drag: none; pointer-events: none; }
.bk-page.left::after, .bk-page.right::after { content: ''; position: absolute; top: 0; bottom: 0; width: 9%; pointer-events: none; }
.bk-page.left::after { right: 0; background: linear-gradient(to left, rgba(0, 0, 0, .22), rgba(0, 0, 0, .06) 30%, transparent); }
.bk-page.right::after { left: 0; background: linear-gradient(to right, rgba(0, 0, 0, .22), rgba(0, 0, 0, .06) 30%, transparent); }
.bk-page.blank { display: flex; align-items: center; justify-content: center; }
.bk-page.blank span { font: 600 clamp(6px, 1.1vw, 12px)/1 var(--read); letter-spacing: .04em; color: #8b867c; }
.bk-book.instant { transition: none; }
.bk-book.with-turn { transition: transform .9s cubic-bezier(.45, .05, .55, .95); }
.bk-book.fade-l { animation: bkslidel .18s ease-out; }
.bk-book.fade-r { animation: bkslider .18s ease-out; }
@keyframes bkslidel { from { opacity: .35; translate: -10px 0; } to { opacity: 1; translate: 0 0; } }
@keyframes bkslider { from { opacity: .35; translate: 10px 0; } to { opacity: 1; translate: 0 0; } }
.bk-xfade { position: absolute; top: 0; left: 50%; height: 100%; transform: translateX(-50%); z-index: 5; pointer-events: none; }
.bk-controls { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 8px 22px; }
.bk-group { display: flex; align-items: center; gap: 6px; }
.bk-ind { font: 10px/1 var(--display); min-width: 15ch; text-align: center; white-space: nowrap; }
.bk-hint { margin: 0; text-align: center; font-size: 12px; color: #9a9a9a; }
.touch-hint { display: none; }
@media (hover: none) {
  .touch-hint { display: inline; } .mouse-hint { display: none; }
  .back kbd, .hint span, #bk-close kbd { display: none; }
  .back::before { content: '\25C0'; font-size: .8em; }
  .hint { min-height: 0; }
}
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: 10px/1.2 var(--display); color: var(--ink); background: #141414; text-decoration: none;
  border: 2px solid var(--frame); border-radius: 0; padding: 10px 12px; min-height: 38px; min-width: 38px; cursor: pointer;
}
.btn kbd { font-size: 9px; height: 18px; min-width: 18px; padding: 0 4px; margin: 0 2px 0 0; top: 0; }
.btn:hover { border-color: var(--ink); background: #222; }
.btn:disabled { opacity: .35; cursor: default; border-color: var(--frame); background: #141414; }
.sq-btn { padding: 10px 9px; }
.dlg { background: #000; color: var(--ink); border: 2px solid var(--ink); border-radius: 0; padding: 0; width: min(460px, calc(100vw - 32px)); max-height: calc(100dvh - 48px); }
.dlg::backdrop { background: rgba(0, 0, 0, .7); }
.dlg-head { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; border-bottom: 2px solid var(--frame); }
.dlg-head h3 { font: 12px/1.4 var(--display); margin: 0; }
.toc { list-style: none; margin: 0; padding: 8px 0; overflow: auto; max-height: calc(100dvh - 150px); }
.toc button { width: 100%; display: flex; align-items: baseline; background: none; border: 0; border-left: 3px solid transparent; color: var(--ink); font: 15px/1.3 var(--read); padding: 7px 16px; text-align: left; cursor: pointer; }
.toc button:hover, .toc button[aria-current='page'] { background: #1c1c1c; border-left-color: var(--red); }
.toc .num { font: 10px/1 var(--display); color: var(--dim); width: 3.2em; flex: 0 0 auto; }

/* ================================================================== phones: the set is the whole window */
@media (max-width: 760px), (max-height: 480px) and (max-width: 1000px) {
  .set { display: block; padding: 0; }
  .room, .tv-chin, .tv-frame, .tv-glare, .hot, .hot-led, .tv-label { display: none !important; }
  /* On a phone the set is the window: a thin drawn bezel and the glass edge to edge. A photographed
     landscape frame would leave a portrait screen small, so phones keep the drawn bezel. */
  .tv { position: fixed; inset: 0; width: auto; height: auto; --T: 400px; }
  html.tv-image .tv-drawn { display: block; }
  /* with the photographed set in place, the phone bezel takes its grey plastic instead of the drawn wood */
  html.tv-image .tv-drawn { background: linear-gradient(180deg, #cfcac1, #aaa59c 60%, #8f8a82); box-shadow: inset 0 2px 0 rgba(255, 255, 255, .35); }
  html.tv-image .tv-drawn::before { background: linear-gradient(180deg, #333335, #262628 40%, #1c1c1e); }
  html.tv-image .placard { color: #3a3a3c; }
  .tv-drawn { border-radius: 0; }
  .tv-drawn::before { inset: max(4px, env(safe-area-inset-top, 0px)) 4px 26px; border-radius: 12px; }
  .tv-well { display: none; }
  .glass {
    left: max(10px, env(safe-area-inset-left, 0px)) !important; right: max(10px, env(safe-area-inset-right, 0px)) !important;
    top: max(10px, env(safe-area-inset-top, 0px)) !important; bottom: 32px !important;
    width: auto !important; height: auto !important; border-radius: 16px / 18px !important;
  }
  .picture { font-size: 14px; }
  .scr { padding: 6% 6% 5%; }
  .scr-title { padding: 6% 6% 5%; }
  .wordmark, .subtitle { width: 88%; }
  .subtitle { --wm: 88%; }
  .subtitle { font-size: .8em; letter-spacing: .42em; margin-right: -.42em; }
  .lede { font-size: .8em; }
  .menu a { font-size: .86em; padding: .5em .2em; }
  .title-foot .sp { display: block; height: 0; }
  .bar { grid-template-columns: auto 1fr; gap: .4em .8em; }
  .bar h2 { grid-column: 1 / -1; grid-row: 2; font-size: .82em; }
  .pg { justify-self: end; }
  .page.cols.on, .booklet-screen, .keys { grid-template-columns: minmax(0, 1fr); }
  .status { margin-top: 1em; }
  .roster { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .shot img { max-height: none; width: 100%; }
  .shot.tall img, .shot.narrow img { width: auto; max-height: 60vh; }
  .bk-cover { width: 70%; }
  .opt { grid-template-columns: minmax(0, 1fr); gap: .6em; }
  .fx-mask { display: none; }
  .fx-scan { background: repeating-linear-gradient(to bottom, rgba(0, 0, 0, .42) 0 1px, transparent 1px 3px); }
  .hint .pgbtn { padding: .5em .8em; }

  .placard { position: fixed; z-index: 4; left: 0; right: 0; bottom: 0; margin: 0; padding: 4px 12px max(8px, env(safe-area-inset-bottom, 0px)); font-size: 9px; line-height: 1.3; color: #9a9aa0; }
  .placard span { display: none; }
  .bk-controls .lbl { display: none; }
  .bk-controls { gap: 8px 10px; }
  .bk-ind { font-size: 9px; min-width: 12ch; }
}

/* ================================================================== reduced motion: a still picture */
@media (prefers-reduced-motion: reduce) {
  .fx-roll, .fx-flick, .fx-static, .fx-mask { display: none !important; }
  .fx-scan { background: repeating-linear-gradient(to bottom, rgba(0, 0, 0, .22) 0 1px, transparent 1px 3px) !important; }
  .press-start, .attract-start, .menu a.on .cur, .menu a:focus-visible .cur { animation: none; }
  .picture .jolt { animation: none; }
  .knob i, .bk-book, .bk-book.with-turn { transition: none; }
  html.crt-full .picture, html.crt-full .picture.reading { filter: url(#crt-soft); }
}
