/* Fogbound — the whole look of the game. No images, no webfonts. */

/* `hidden` is only a UA rule, so any author display rule would beat it.
   This one line keeps the attribute authoritative everywhere below. */
[hidden] { display: none !important; }

:root {
  --night: #08131b;
  --night-2: #0d1d26;
  --panel: #132630;
  --panel-2: #18333f;
  --line: #26505e;
  --ink: #d8e6ea;
  --ink-dim: #8fa8b2;
  --ink-faint: #63808b;
  --brass: #c99a44;
  --brass-lit: #f0c97e;
  --glow: #ffd98f;
  --paper: #e5dfcc;
  --paper-ink: #2f2a20;
  --good: #6fb28c;
  --bad: #cc6a5f;
  --ui: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --prose: Georgia, "Iowan Old Style", "Times New Roman", serif;
  --radius: 10px;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  background:
    radial-gradient(120% 90% at 50% 0%, #16303d 0%, var(--night) 60%, #04090d 100%);
  color: var(--ink);
  font-family: var(--ui);
  font-size: 15px;
  line-height: 1.5;
  overflow: hidden;
  -webkit-text-size-adjust: 100%;
}

kbd {
  font: inherit;
  font-size: .82em;
  padding: .05em .38em;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 5px;
  background: #0e222c;
  color: var(--ink-dim);
}

button { font: inherit; color: inherit; }

/* ------------------------------------------------------------------ layout */

.app {
  height: 100dvh;
  display: grid;
  grid-template-columns: minmax(0, 1fr) clamp(270px, 24vw, 350px);
  grid-template-rows: auto minmax(0, 1fr);
  grid-template-areas:
    "top  top"
    "room tray";
  gap: 10px;
  padding: 10px;
}

.topbar {
  grid-area: top;
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
  padding: 8px 14px;
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin: 0;
  font-family: var(--prose);
  font-size: 22px;
  font-weight: 600;
  letter-spacing: .04em;
}

.brand-mark {
  width: 14px;
  height: 22px;
  clip-path: polygon(50% 0, 100% 38%, 100% 100%, 0 100%, 0 38%);
  background: linear-gradient(180deg, var(--glow), var(--brass));
  box-shadow: 0 0 14px rgba(255, 217, 143, .55);
}

.brand-episode {
  font-family: var(--ui);
  font-size: 11px;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--ink-faint);
  padding-left: 10px;
  border-left: 1px solid var(--line);
  align-self: center;
}

.hud {
  position: relative;
  display: flex;
  gap: 18px;
  padding: 4px 14px 8px;
  margin-inline-start: auto;
}

.hud-cell { display: flex; flex-direction: column; align-items: center; min-width: 58px; }
.hud-label { font-size: 10px; letter-spacing: .14em; text-transform: uppercase; color: var(--ink-faint); }
.hud-value { font-variant-numeric: tabular-nums; font-size: 17px; color: var(--brass-lit); }

.progress-bar {
  position: absolute;
  inset-inline: 14px;
  bottom: 0;
  height: 3px;
  border-radius: 2px;
  background: #0b1a22;
  overflow: hidden;
}
.progress-bar::after {
  content: "";
  display: block;
  height: 100%;
  width: var(--fill, 0%);
  background: linear-gradient(90deg, var(--brass), var(--glow));
  transition: width .4s ease;
}

.tools { display: flex; gap: 8px; flex-wrap: wrap; }

.tool {
  padding: 7px 12px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #10242e;
  color: var(--ink-dim);
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
}
.tool:hover { background: #17323f; color: var(--ink); }
.tool[aria-pressed="true"] { border-color: var(--brass); color: var(--brass-lit); background: #1d2a24; }

/* -------------------------------------------------------------------- room */

.room {
  grid-area: room;
  display: grid;
  place-items: center;
  min-height: 0;
  min-width: 0;
}

.stage {
  position: relative;
  width: 100%;
  max-height: 100%;
  aspect-ratio: 16 / 10;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  overflow: hidden;
  background: var(--night);
  /* Overlay chrome is sized against the stage, not the viewport, so a
     letterboxed phone layout keeps the same proportions as a desktop one.
     The 3D lengths below are in the same units, so the room scales with it. */
  container-type: size;

  /* The room is a square box seen from the middle of it. `--room` is a wall's
     width, `--half` the distance from the eye to each wall, and `--eye` the
     focal length. A wall projects to --room * --eye / (--eye + --half) across,
     which at these numbers is 88% of the stage — the remaining 12% is the two
     side walls running back towards you. */
  --room: 140cqw;
  --wall-h: 87.5cqw;
  --half: 70cqw;
  --eye: 120cqw;
  box-shadow: 0 18px 60px rgba(0, 0, 0, .55), inset 0 0 120px rgba(0, 0, 0, .6);
}

/* The perspective lives here rather than on the stage: container units resolve
   against the nearest *ancestor* container, so `--eye` written on the stage
   itself would measure the viewport instead of the stage. */
.camera {
  position: absolute;
  inset: 0;
  perspective: var(--eye);
  perspective-origin: 50% 50%;
}

/* The 3D scaffolding must not be clickable. Each of these is a flat box at the
   camera plane covering the whole stage, so it wins the hit test against the
   very children it is there to position — `elementFromPoint` over a hotspot
   returns `.world`, and every click lands on nothing. Only the layer that
   actually holds buttons takes the pointer back. */
.camera,
.world-nudge,
.world,
.face {
  pointer-events: none;
}
.face-wall.facing .hotspots {
  pointer-events: auto;
}

.world-nudge,
.world {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
}

/* The camera. `--yaw` is the wall you are facing; the nudge layer carries the
   small live offset from the pointer, on its own faster transition. */
.world {
  transform: rotateY(var(--yaw, 0deg));
  transition: transform .66s cubic-bezier(.42, .04, .2, 1);
}
.world-nudge {
  transform: rotateX(var(--nudge-pitch, 0deg)) rotateY(var(--nudge-yaw, 0deg));
  transition: transform .25s ease-out;
}

.face {
  position: absolute;
  left: 50%;
  top: 50%;
  /* No overflow, opacity or filter on a face: any of them would silently
     flatten the 3D of everything inside it. */
  transform-style: preserve-3d;
}

.face-wall {
  width: var(--room);
  height: var(--wall-h);
  margin-left: calc(var(--room) / -2);
  margin-top: calc(var(--wall-h) / -2);
  transform: rotateY(var(--face-yaw)) translateZ(calc(var(--half) * -1));
  backface-visibility: hidden;
}

.face-floor,
.face-ceiling {
  width: var(--room);
  height: var(--room);
  margin-left: calc(var(--room) / -2);
  margin-top: calc(var(--room) / -2);
}
.face-floor {
  transform: translateY(calc(var(--wall-h) / 2)) rotateX(90deg);
  background:
    radial-gradient(78% 72% at 50% 100%, rgba(0, 0, 0, .5), transparent 72%),
    repeating-linear-gradient(90deg,
      rgba(0, 0, 0, .3) 0 3px,
      rgba(255, 230, 190, .03) 3px 6px,
      transparent 6px 8.5%),
    linear-gradient(var(--floor-far, #16100a), var(--floor-near, #3b2f22));
}
.face-ceiling {
  transform: translateY(calc(var(--wall-h) / -2)) rotateX(-90deg);
  background:
    radial-gradient(70% 70% at 50% 0%, rgba(255, 255, 255, .05), transparent 70%),
    repeating-linear-gradient(90deg,
      rgba(0, 0, 0, .45) 0 5px,
      transparent 5px 12%),
    var(--ceiling, #08131b);
}

.scene { position: absolute; inset: 0; }
.scene-svg { display: block; width: 100%; height: 100%; }

.stage::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(6, 18, 26, .55), rgba(4, 12, 18, .22) 45%, rgba(3, 9, 14, .6));
  transition: opacity .9s ease;
}
.stage.lit::after { opacity: .35; }
.stage.lamp-lit::after {
  background:
    radial-gradient(60% 45% at 50% 34%, rgba(255, 217, 143, .22), transparent 70%),
    linear-gradient(180deg, rgba(6, 18, 26, .3), transparent 50%, rgba(3, 9, 14, .45));
}

.hotspots { position: absolute; inset: 0; transform-style: preserve-3d; }

.hotspot {
  position: absolute;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  cursor: pointer;
  transform: translateZ(0);
  transition: background .18s, border-color .18s, transform .18s;
}
.hotspots.holding .hotspot { cursor: cell; }
.hotspot:hover,
.hotspot:focus-visible {
  outline: none;
  border-color: rgba(255, 217, 143, .75);
  background: radial-gradient(60% 60% at 50% 50%, rgba(255, 217, 143, .16), transparent 72%);
  transform: translateZ(2cqw);
}
.hotspots.outlined .hotspot {
  border-color: rgba(255, 217, 143, .3);
  border-style: dashed;
}

.hotspot-ring {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow: inset 0 0 0 1px rgba(255, 217, 143, 0);
}

.hotspot-tag {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 0.6cqh);
  transform: translateX(-50%);
  padding: .25em .6em;
  border-radius: 6px;
  white-space: nowrap;
  font-size: clamp(10px, 2.4cqh, 14px);
  background: rgba(6, 18, 26, .92);
  border: 1px solid var(--line);
  color: var(--brass-lit);
  opacity: 0;
  pointer-events: none;
  transition: opacity .15s;
}
.hotspot:hover .hotspot-tag,
.hotspot:focus-visible .hotspot-tag { opacity: 1; }

.projection {
  position: absolute;
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--glow);
  cursor: pointer;
  filter: drop-shadow(0 0 10px rgba(255, 217, 143, .8));
  animation: sweep 8s ease-in-out infinite;
}
.projection .glyph { width: 100%; height: 100%; opacity: .9; }
.projection.seen { animation: none; opacity: .8; }
.projection:hover, .projection:focus-visible { outline: none; transform: scale(1.06); }

@keyframes sweep {
  0%, 62% { opacity: .08; }
  72%, 88% { opacity: 1; }
  100% { opacity: .08; }
}

.turn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: clamp(34px, 7cqh, 52px);
  height: clamp(52px, 14cqh, 96px);
  display: grid;
  place-items: center;
  font-size: clamp(20px, 5cqh, 34px);
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(8, 20, 28, .68);
  color: var(--brass-lit);
  cursor: pointer;
  backdrop-filter: blur(2px);
  transition: background .15s, transform .15s;
}
.turn:hover { background: rgba(20, 44, 56, .9); }
.turn-left { left: 1.5cqw; }
.turn-right { right: 1.5cqw; }

.view-strip {
  position: absolute;
  left: 50%;
  bottom: 1.6cqh;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: .35em .7em;
  border-radius: 999px;
  background: rgba(8, 20, 28, .72);
  border: 1px solid var(--line);
  font-size: clamp(11px, 2.6cqh, 14px);
}
.view-name { color: var(--ink-dim); letter-spacing: .04em; white-space: nowrap; }
.compass { display: flex; gap: 4px; }
.compass-pip {
  width: 2.2em;
  height: 1.7em;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink-faint);
  font-size: inherit;
  cursor: pointer;
}
.compass-pip.on { background: var(--brass); border-color: var(--brass-lit); color: #1a1205; font-weight: 700; }

/* -------------------------------------------------------------------- tray */

.tray {
  grid-area: tray;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto auto;
  gap: 10px;
  min-height: 0;
}

.tray-block {
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 12px;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.tray-block h2 {
  margin: 0 0 8px;
  font-size: 10px;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--ink-faint);
  font-weight: 600;
}

.journal-block { min-height: 0; }
.journal {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding-right: 6px;
  font-family: var(--prose);
  font-size: 14px;
  line-height: 1.55;
  scrollbar-width: thin;
}
.entry {
  margin: 0 0 .8em;
  padding-left: 10px;
  border-left: 2px solid var(--line);
  color: var(--ink-dim);
}
.entry-act, .entry-get { border-left-color: var(--brass); color: var(--ink); }
.entry-fail { border-left-color: var(--bad); }
.entry-win { border-left-color: var(--good); color: var(--brass-lit); }
.entry-hint {
  border-left-color: #7a6bb0;
  color: #cbc0ea;
  font-style: italic;
}
.entry:last-child { margin-bottom: 0; }

#tray-extra .mark-row,
.mark-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.mark {
  display: grid;
  justify-items: center;
  gap: 4px;
  padding: 6px 2px;
  border-radius: 8px;
  border: 1px dashed var(--line);
  color: var(--ink-faint);
}
.mark.found { border-style: solid; border-color: var(--brass); color: var(--glow); }
.mark-compass { font-size: 10px; letter-spacing: .14em; }
.mark-glyph { display: grid; place-items: center; width: 26px; height: 26px; }
.mark-glyph .glyph { width: 100%; height: 100%; }
.mark-blank { color: var(--ink-faint); }

.inventory { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.inventory .empty { color: var(--ink-faint); font-style: italic; font-size: 13px; }

.item {
  width: 100%;
  text-align: left;
  display: grid;
  gap: 2px;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #10242e;
  cursor: pointer;
  transition: border-color .15s, background .15s, transform .1s;
}
.item:hover { background: #17323f; }
.item.held {
  border-color: var(--brass-lit);
  background: #24301f;
  box-shadow: 0 0 0 1px rgba(240, 201, 126, .35), 0 0 18px rgba(255, 217, 143, .18);
}
.item-name { color: var(--brass-lit); font-weight: 600; font-size: 13px; }
.item-desc { color: var(--ink-faint); font-size: 11.5px; line-height: 1.35; }

.tray-hint { margin: 8px 0 0; font-size: 11.5px; color: var(--ink-faint); }

.card-wide { width: min(820px, 100%); }
.card-lede { margin: 0 auto 8px; max-width: 52ch; }

.episode-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 14px;
  margin: 26px 0 20px;
  padding: 0;
  list-style: none;
  text-align: left;
}

.episode {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 18px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, #143039, #0d2029);
  transition: border-color .15s, transform .15s;
}
.episode:hover { border-color: var(--brass); transform: translateY(-2px); }

.episode-head { display: flex; align-items: baseline; gap: 10px; }
.episode-number {
  font-family: var(--prose);
  font-size: 13px;
  letter-spacing: .18em;
  color: var(--brass);
}
.episode-head h3 {
  margin: 0;
  font-family: var(--prose);
  font-size: 23px;
  font-weight: 600;
  color: var(--brass-lit);
}
.episode-blurb {
  margin: 0;
  flex: 1;
  font-family: var(--prose);
  font-size: 14.5px;
  line-height: 1.6;
  color: var(--ink-dim);
}
.episode-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.episode-actions .primary,
.episode-actions .secondary { padding: 9px 16px; font-size: 14px; }

/* ----------------------------------------------------------------- overlay */

.overlay {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(3, 10, 15, .78);
  backdrop-filter: blur(4px);
  z-index: 20;
}

.panel {
  width: min(760px, 100%);
  max-height: min(88dvh, 760px);
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, #1a3542, #102330);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, .6);
  animation: rise .22s ease;
}
@keyframes rise { from { transform: translateY(12px); opacity: 0; } }

.panel-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
}
.panel-head h2 {
  margin: 0;
  font-family: var(--prose);
  font-size: 19px;
  font-weight: 600;
  color: var(--brass-lit);
}
.panel-close {
  margin-inline-start: auto;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink-dim);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}
.panel-close:hover { background: #17323f; color: var(--ink); }

.panel-body { padding: 18px; overflow-y: auto; }

.primary, .secondary {
  padding: 11px 22px;
  border-radius: 9px;
  border: 1px solid var(--brass);
  background: linear-gradient(180deg, var(--brass-lit), var(--brass));
  color: #1a1205;
  font-weight: 700;
  letter-spacing: .02em;
  cursor: pointer;
  transition: filter .15s, transform .1s;
}
.primary:hover { filter: brightness(1.08); }
.primary:active { transform: translateY(1px); }
.secondary {
  background: transparent;
  border-color: var(--line);
  color: var(--ink);
  font-weight: 600;
}
.secondary:hover { background: #17323f; }
.secondary small { display: block; font-weight: 400; color: var(--ink-faint); font-size: 11px; }

/* --------------------------------------------------------------- documents */

.doc {
  background: var(--paper);
  color: var(--paper-ink);
  border-radius: 8px;
  padding: 24px 28px;
  font-family: var(--prose);
  line-height: 1.65;
  box-shadow: inset 0 0 60px rgba(120, 100, 60, .18);
}
.doc p { margin: 0 0 .9em; }
.doc hr { border: 0; border-top: 1px solid rgba(47, 42, 32, .25); margin: 1.2em 0; }
.log-page + .log-page { margin-top: 1.6em; padding-top: 1.2em; border-top: 1px solid rgba(47, 42, 32, .22); }
.log-page h3 {
  margin: 0 0 .5em;
  font-size: 13px;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: #6c604a;
}
.doc-chart p:first-child { font-weight: 700; letter-spacing: .08em; }

.doc-tides table,
.doc-table { width: 100%; border-collapse: collapse; }
.doc-tides caption,
.doc-table caption {
  text-align: left;
  padding-bottom: .7em;
  font-size: 13px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: #6c604a;
}
.doc-tides th, .doc-tides td,
.doc-table th, .doc-table td {
  text-align: left;
  padding: .5em .7em;
  border-bottom: 1px solid rgba(47, 42, 32, .2);
  font-variant-numeric: tabular-nums;
}
.doc-tides thead th,
.doc-table thead th { font-size: 12px; letter-spacing: .09em; text-transform: uppercase; color: #6c604a; }
.doc-tides tbody th,
.doc-table tbody th { width: 5em; font-size: 19px; }
.doc-tides td:last-child { text-align: right; font-weight: 700; }

/* ------------------------------------------------------------------ clock */

.panel-clock { display: flex; gap: 28px; align-items: center; flex-wrap: wrap; justify-content: center; }
.clock-holder { width: min(260px, 60vw); }
.clock-face { width: 100%; height: auto; display: block; filter: drop-shadow(0 10px 24px rgba(0, 0, 0, .5)); }
.dials { display: grid; gap: 14px; min-width: 220px; }
.dial-row { display: flex; align-items: center; gap: 10px; }
.dial-label { width: 4.4em; font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--ink-faint); }
.dial-value {
  min-width: 2.6em;
  text-align: center;
  font-size: 26px;
  font-variant-numeric: tabular-nums;
  color: var(--brass-lit);
}
.step {
  width: 38px;
  height: 38px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: #10242e;
  color: var(--brass-lit);
  font-size: 18px;
  cursor: pointer;
}
.step:hover { background: #1b3846; }

/* ------------------------------------------------------------------ books */

.panel-note { margin: 0 0 16px; color: var(--ink-dim); font-family: var(--prose); }
.book-row { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; align-items: end; }
.book {
  position: relative;
  display: grid;
  gap: 6px;
  justify-items: center;
  padding: 16px 6px 12px;
  height: 190px;
  align-content: start;
  border-radius: 6px 6px 3px 3px;
  border: 1px solid rgba(0, 0, 0, .55);
  background: linear-gradient(180deg, color-mix(in srgb, var(--book-hue) 85%, #fff 15%), var(--book-hue));
  color: #f0e6d2;
  cursor: pointer;
  transition: transform .18s ease, box-shadow .18s ease;
}
.book::before {
  content: "";
  position: absolute;
  inset: 10px 8px auto;
  height: 22px;
  background: rgba(201, 154, 68, .65);
  border-radius: 2px;
}
.book:hover { transform: translateY(-8px); }
.book.out { transform: translateY(-26px); box-shadow: 0 16px 30px rgba(0, 0, 0, .5); }
.book-num { position: relative; font-family: var(--prose); font-size: 22px; margin-top: 26px; }
.book-title { font-size: 11px; text-align: center; color: rgba(240, 230, 210, .8); line-height: 1.25; }
.book-order {
  position: absolute;
  bottom: 8px;
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--brass-lit);
  color: #1a1205;
  font-size: 12px;
  font-weight: 700;
}
.shake { animation: shake .4s; }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-8px); }
  40% { transform: translateX(7px); }
  60% { transform: translateX(-5px); }
  80% { transform: translateX(3px); }
}

/* ------------------------------------------------- down line: the van */

.doc-plate {
  background: linear-gradient(180deg, #e3c485, #c29a51);
  color: #3a2a0d;
  box-shadow: inset 0 0 50px rgba(90, 66, 20, .35);
  text-align: center;
  letter-spacing: .04em;
}
.doc-plate p:first-child { font-weight: 700; letter-spacing: .14em; }
.doc-table tbody th { width: auto; font-size: 16px; }

/* An unlit van is genuinely hard to read in, which is the first puzzle. */
.stage.ep-down-line:not(.lit) .scene-svg { filter: brightness(.58) saturate(.72); }
.stage.ep-down-line .scene-svg { transition: filter 1s ease; }
.stage.ep-down-line.lit::after {
  background:
    radial-gradient(52% 42% at 50% 26%, rgba(255, 208, 138, .24), transparent 72%),
    linear-gradient(180deg, rgba(10, 6, 2, .28), transparent 48%, rgba(4, 2, 0, .5));
}

/* the night going past the lookout */
.rush { animation: rush .6s linear infinite; }
@keyframes rush {
  from { transform: translateX(140px); opacity: .3; }
  50% { opacity: .95; }
  to { transform: translateX(-360px); opacity: .3; }
}
.stage.stopped .rush { animation: none; opacity: .3; }

/* sorting frame */
.sort-table {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  min-height: 84px;
  padding: 12px;
  margin-bottom: 16px;
  border-radius: 10px;
  border: 1px dashed var(--line);
  background: rgba(8, 20, 28, .4);
}
.sort-empty { margin: auto; color: var(--ink-faint); font-style: italic; }
.letter {
  display: grid;
  gap: 2px;
  padding: 10px 14px;
  border-radius: 4px;
  border: 1px solid #b9ad8d;
  background: linear-gradient(180deg, #f1e9d5, #ded3b8);
  color: #2f2a20;
  cursor: pointer;
  box-shadow: 0 4px 10px rgba(0, 0, 0, .35);
  transition: transform .12s, box-shadow .12s;
}
.letter:hover { transform: translateY(-3px); }
.letter.picked {
  transform: translateY(-6px) rotate(-2deg);
  box-shadow: 0 10px 20px rgba(0, 0, 0, .45), 0 0 0 2px var(--brass-lit);
}
.letter-to { font-size: 9px; letter-spacing: .18em; text-transform: uppercase; color: #7c7256; }
.letter-town { font-family: var(--prose); font-size: 15px; }

.sort-bags {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(118px, 1fr));
  gap: 10px;
  margin-bottom: 18px;
}
.bag {
  display: grid;
  gap: 6px;
  padding: 14px 8px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, #4a4335, #332e23);
  color: var(--ink);
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.bag:hover { border-color: var(--brass); }
.bag.full { background: linear-gradient(180deg, #5d5440, #3f382a); border-color: var(--brass); }
.bag-label { font-size: 10px; letter-spacing: .12em; color: var(--brass-lit); }
.bag-slot { font-family: var(--prose); font-size: 14px; color: var(--ink-dim); min-height: 1.3em; }
.bag.full .bag-slot { color: var(--ink); }

/* block bell */
.panel-bell { display: grid; gap: 14px; justify-items: center; }
.bell-readout {
  display: block;
  min-width: min(420px, 100%);
  padding: 18px 22px;
  border-radius: 10px;
  background: radial-gradient(120% 120% at 50% 0%, #1c150a, #0b0803);
  border: 1px solid #6d5121;
  color: var(--brass-lit);
  font-size: 30px;
  letter-spacing: .34em;
  text-align: center;
  word-break: break-word;
}
.bell-count {
  margin: 0;
  font-size: 12px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--ink-faint);
  font-variant-numeric: tabular-nums;
}
.bell-controls { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.step.wide { width: auto; min-width: 110px; padding: 0 18px; font-size: 15px; }

/* lever frame */
.panel-levers { display: grid; gap: 18px; justify-items: center; }
.lever-row {
  display: flex;
  gap: 14px;
  padding: 18px 22px 12px;
  border-radius: 12px;
  background: linear-gradient(180deg, #2b343a, #161d21);
  border: 1px solid var(--line);
}
.lever-stick {
  display: grid;
  justify-items: center;
  gap: 8px;
  width: 54px;
  padding: 0 0 8px;
  border: 0;
  background: transparent;
  cursor: pointer;
}
.lever-shaft {
  width: 14px;
  height: 96px;
  border-radius: 8px;
  background: linear-gradient(180deg, #b8443a, #6d241e);
  transform: rotate(-14deg);
  transform-origin: 50% 100%;
  transition: transform .18s ease, background .18s;
  box-shadow: 0 4px 10px rgba(0, 0, 0, .5);
}
.lever-stick.over .lever-shaft {
  transform: rotate(16deg);
  background: linear-gradient(180deg, #6fb28c, #2f6549);
}
.lever-number {
  width: 30px;
  height: 24px;
  display: grid;
  place-items: center;
  border-radius: 4px;
  background: #121a1e;
  border: 1px solid var(--line);
  color: var(--brass-lit);
  font-family: var(--prose);
  font-size: 14px;
}

/* the tray's running total */
.status-row { display: grid; gap: 6px; margin: 0; padding: 0; list-style: none; }
.status {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 12.5px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--ink-faint);
}
.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 1px solid var(--line);
}
.status.on { color: var(--glow); }
.status.on .status-dot {
  background: var(--brass-lit);
  border-color: var(--brass-lit);
  box-shadow: 0 0 10px rgba(255, 217, 143, .6);
}

/* ------------------------------------------------------------------- lock */

.panel-lock { display: grid; gap: 18px; justify-items: center; }
.lock-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  padding: 16px 18px;
  border-radius: 12px;
  background: linear-gradient(180deg, #3a2d13, #241b0c);
  border: 1px solid #6d5121;
}
.lock-dial { display: grid; justify-items: center; gap: 6px; }
.dial-window {
  width: clamp(56px, 14vw, 78px);
  height: clamp(56px, 14vw, 78px);
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: radial-gradient(120% 120% at 50% 0%, #1c150a, #0b0803);
  border: 1px solid #6d5121;
  color: var(--brass-lit);
  box-shadow: inset 0 6px 14px rgba(0, 0, 0, .7);
}
.dial-window .glyph { width: 72%; height: 72%; }
.dial-compass { font-size: 11px; letter-spacing: .18em; color: var(--brass); }

/* ------------------------------------------- slack water: the engine house */

/* An engine house with no fire in it is genuinely hard to see in. */
.stage.ep-slack-water:not(.lit) .scene-svg { filter: brightness(.6) saturate(.7); }
.stage.ep-slack-water .scene-svg { transition: filter 1s ease; }
.stage.ep-slack-water.lit::after {
  background:
    radial-gradient(46% 40% at 40% 60%, rgba(255, 138, 51, .2), transparent 72%),
    linear-gradient(180deg, rgba(6, 10, 9, .3), transparent 46%, rgba(3, 6, 5, .5));
}
.flywheel { animation: flywheel 2.6s linear infinite; }
@keyframes flywheel { to { transform: rotate(360deg); } }

/* the cipher wheel */
.panel-wheel { display: grid; gap: 14px; justify-items: center; }
.cipher-line {
  display: block;
  padding: 12px 20px;
  border-radius: 8px;
  background: #1b241f;
  border: 1px solid var(--line);
  color: var(--brass-lit);
  font-family: var(--prose);
  font-size: clamp(16px, 4vw, 24px);
  letter-spacing: .22em;
  text-align: center;
  word-break: break-word;
}
.wheel-holder { width: min(280px, 62vw); }
.wheel-face { width: 100%; height: auto; display: block; filter: drop-shadow(0 10px 24px rgba(0, 0, 0, .5)); }

/* the safety valve arm */
.weight-rack {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  margin-bottom: 16px;
}
.weight {
  display: grid;
  justify-items: center;
  gap: 1px;
  width: 66px;
  padding: 12px 6px 10px;
  clip-path: polygon(22% 0, 78% 0, 100% 100%, 0 100%);
  border: 0;
  background: linear-gradient(180deg, #5b6664, #39413f);
  color: var(--ink);
  cursor: pointer;
  transition: transform .15s, background .15s;
}
.weight:hover { transform: translateY(-3px); }
.weight.on {
  background: linear-gradient(180deg, #d8b878, #a8802f);
  color: #1e1607;
}
.weight-lb { font-family: var(--prose); font-size: 21px; line-height: 1; }
.weight-unit { font-size: 9px; letter-spacing: .14em; text-transform: uppercase; opacity: .75; }

.beam-sum {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 0 0 18px;
}
.beam-sum div {
  padding: 10px 6px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: #101a17;
  text-align: center;
}
.beam-sum dt { font-size: 10px; letter-spacing: .14em; text-transform: uppercase; color: var(--ink-faint); }
.beam-sum dd { margin: 4px 0 0; font-size: 18px; color: var(--ink); font-variant-numeric: tabular-nums; }
.beam-total { color: var(--brass-lit) !important; font-weight: 700; }

/* the steam manifold */
.panel-pipes { display: grid; gap: 16px; justify-items: center; }
.pipe-frame {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px;
  border-radius: 12px;
  background: linear-gradient(180deg, #1c2426, #111718);
  border: 1px solid var(--line);
}
.pipe-end {
  font-size: 10px;
  letter-spacing: .14em;
  color: var(--brass);
  writing-mode: vertical-rl;
}
.pipe-in { transform: rotate(180deg); }
.pipe-grid {
  display: grid;
  grid-template-columns: repeat(var(--cols, 4), minmax(0, 1fr));
  gap: 3px;
}
.union {
  width: clamp(52px, 13vw, 76px);
  aspect-ratio: 1;
  padding: 0;
  border: 1px solid #232c2e;
  border-radius: 4px;
  background: #0d1415;
  color: #5b6664;
  cursor: pointer;
  transition: color .2s, background .2s;
}
.union svg { width: 100%; height: 100%; display: block; }
.union:hover { background: #16211f; }
.union.live {
  color: var(--brass-lit);
  background: #1d1a10;
  box-shadow: inset 0 0 14px rgba(255, 207, 134, .25);
}

/* ------------------------------------------------ aphelion: the module */

/* Running on the battery, in the red, with nothing readable. */
.stage.ep-aphelion.emergency .scene-svg { filter: brightness(.72) saturate(.55); }
.stage.ep-aphelion .scene-svg { transition: filter 1.2s ease; }
.stage.ep-aphelion.emergency::after {
  background:
    radial-gradient(60% 50% at 50% 45%, rgba(200, 57, 47, .3), transparent 72%),
    linear-gradient(180deg, rgba(20, 4, 3, .4), transparent 45%, rgba(12, 2, 2, .55));
}
.stage.ep-aphelion.lit::after {
  background:
    radial-gradient(58% 46% at 50% 30%, rgba(120, 210, 235, .14), transparent 74%),
    linear-gradient(180deg, rgba(4, 8, 14, .3), transparent 48%, rgba(2, 4, 8, .5));
}
.tumble { animation: tumbleDrift 19s ease-in-out infinite alternate; }
@keyframes tumbleDrift { to { transform: translateX(-118px); } }
.stage.ep-aphelion.damped .tumble { animation: none; }

/* the restart panel */
.panel-restart { display: grid; gap: 16px; }
.breaker-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(96px, 1fr));
  gap: 10px;
  padding: 16px;
  border-radius: 12px;
  background: linear-gradient(180deg, #1f2836, #131a24);
  border: 1px solid var(--line);
}
.breaker {
  position: relative;
  display: grid;
  justify-items: center;
  gap: 8px;
  padding: 14px 6px 10px;
  border-radius: 8px;
  border: 1px solid #2c3849;
  background: #121924;
  color: var(--ink-dim);
  cursor: pointer;
  transition: background .15s, border-color .15s;
}
.breaker:hover { background: #1a2431; }
.breaker-lamp {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #22303c;
  border: 1px solid #33404f;
}
.breaker.on .breaker-lamp {
  background: #4fd98a;
  border-color: #4fd98a;
  box-shadow: 0 0 12px rgba(79, 217, 138, .6);
}
.breaker-lever {
  width: 26px;
  height: 52px;
  border-radius: 8px;
  background: linear-gradient(180deg, #c9d4e2, #7f8c9d);
  transform: translateY(10px);
  transition: transform .18s ease;
}
.breaker.on .breaker-lever { transform: translateY(-6px); }
.breaker-name {
  font-size: 10px;
  letter-spacing: .1em;
  text-align: center;
  color: var(--ink-faint);
}
.breaker.on .breaker-name { color: var(--ink); }
.breaker-order {
  position: absolute;
  top: 6px;
  right: 8px;
  font-size: 11px;
  color: #4fd98a;
  font-variant-numeric: tabular-nums;
}

/* the attitude panel */
.rate-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin: 0 0 16px; }
.rate {
  padding: 12px 6px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: #0b1620;
  text-align: center;
}
.rate dt { font-size: 10px; letter-spacing: .14em; color: var(--ink-faint); }
.rate dd {
  margin: 4px 0 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 26px;
  color: #e8b34a;
}
.rate.nulled { border-color: #4fd98a; }
.rate.nulled dd { color: #4fd98a; }

.coupling { margin: 0 0 16px; }
.coupling td { text-align: center !important; font-variant-numeric: tabular-nums; }

.thruster-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.thruster {
  display: grid;
  justify-items: center;
  gap: 6px;
  padding: 12px 6px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #101924;
}
.thruster-name { font-family: ui-monospace, monospace; font-size: 20px; color: var(--cyan, #5fd4e8); }
.thruster-count {
  font-family: ui-monospace, monospace;
  font-size: 22px;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

/* the hull map */
.panel-leak { display: grid; gap: 16px; justify-items: center; }
.hull-grid {
  display: grid;
  grid-template-columns: repeat(var(--cols, 5), minmax(0, 1fr));
  gap: 4px;
  padding: 14px;
  border-radius: 12px;
  background: linear-gradient(180deg, #1c2430, #10161e);
  border: 1px solid var(--line);
}
.section {
  width: clamp(46px, 11vw, 64px);
  aspect-ratio: 1;
  display: grid;
  place-content: center;
  gap: 2px;
  border-radius: 4px;
  border: 1px solid #2a3543;
  background: #0d141c;
  color: var(--ink-faint);
  cursor: pointer;
  transition: background .15s, border-color .15s;
}
.section:hover { background: #172230; border-color: #5fd4e8; }
.section.gauge { background: #16232f; border-color: #3f5568; cursor: default; }
.section.missed { background: #2a1a1a; border-color: #6b3630; }
.section-id { font-size: 11px; letter-spacing: .1em; color: #5fd4e8; }
.section-read {
  font-family: ui-monospace, monospace;
  font-size: 19px;
  color: #a6ecf8;
}

.doc-placard { background: #e4e9f0; }
.panel-note.quiet { color: var(--ink-faint); font-style: italic; }
.status.fault .status-dot { background: #c8392f; border-color: #c8392f; box-shadow: 0 0 10px rgba(200, 57, 47, .5); }

/* --------------------------------------------------------------- curtains */

.curtain {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  background:
    radial-gradient(90% 70% at 50% 20%, rgba(22, 48, 61, .9), rgba(4, 10, 15, .97));
  backdrop-filter: blur(6px);
  z-index: 30;
}

.card {
  width: min(640px, 100%);
  max-height: 92dvh;
  overflow-y: auto;
  padding: 34px 36px;
  text-align: center;
  background: linear-gradient(180deg, #16313e, #0d1f29);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 30px 90px rgba(0, 0, 0, .7);
}
.eyebrow { margin: 0; font-size: 11px; letter-spacing: .22em; text-transform: uppercase; color: var(--ink-faint); }
.card-title {
  margin: .2em 0 .5em;
  font-family: var(--prose);
  font-size: clamp(34px, 7vw, 52px);
  font-weight: 600;
  letter-spacing: .06em;
  color: var(--brass-lit);
  text-shadow: 0 0 34px rgba(255, 217, 143, .35);
}
.card-text { font-family: var(--prose); font-size: 16px; line-height: 1.7; color: var(--ink-dim); }
.card-text p { margin: 0 0 .7em; }
.card-text p:last-child { color: var(--ink); }
.card-actions { display: flex; gap: 12px; justify-content: center; margin: 26px 0 14px; flex-wrap: wrap; }
.card-foot { margin: 0; font-size: 12px; color: var(--ink-faint); }

.scoreboard {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin: 26px 0 0;
}
.scoreboard div {
  padding: 10px 6px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #0e222c;
}
.scoreboard dt { font-size: 10px; letter-spacing: .14em; text-transform: uppercase; color: var(--ink-faint); }
.scoreboard dd { margin: 4px 0 0; font-size: 17px; color: var(--brass-lit); font-variant-numeric: tabular-nums; }

/* ------------------------------------------------------------- responsive */

/* On a small stage the wall's name has nowhere to go, so the compass
   carries the whole job. Queried against the stage, not the viewport. */
@container (max-width: 560px) {
  .view-name { display: none; }
  .view-strip { bottom: 2.4cqh; }
}

@media (max-width: 900px) {
  body { overflow: auto; }
  .app {
    height: auto;
    min-height: 100dvh;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto auto auto;
    grid-template-areas: "top" "room" "tray";
  }
  .tray { grid-template-rows: none; }
  .journal { max-height: 34vh; }
  .hud { margin-inline-start: 0; }
  .topbar { gap: 10px; }
  .brand { font-size: 19px; }
}

@media (max-width: 560px) {
  .tools .tool { padding: 6px 9px; font-size: 13px; }
  .book-row { gap: 5px; }
  .book { height: 150px; padding-top: 12px; }
  .book-title { display: none; }
  .panel-body { padding: 12px; }
  .doc { padding: 18px; }
  .scoreboard { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (prefers-reduced-motion: reduce) {
  .world, .world-nudge { transition: none; }

  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
  .projection { opacity: .95; }
}

:focus-visible { outline: 2px solid var(--brass-lit); outline-offset: 2px; }
