/* One screen: a full-bleed canvas basement; menus read like a typed note pinned low on the left */
:root {
  --void: #060708;
  --soot: #111315;
  --ink: #ddd6c4;
  --dim: #8d887a;
  --beam: #ffe3a3;
  --blood: #b5141f;
  --display: "IM Fell English SC", "IM Fell English", Georgia, "Times New Roman", serif;
  --type: "Special Elite", "Courier New", Courier, monospace;
  color-scheme: dark;
}

html, body { height: 100%; }
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--void);
  color: var(--ink);
  font-family: var(--type);
  font-size: 15px;
  line-height: 1.55;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

#stage {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  cursor: none;
}

/* Menus */
.screen {
  position: fixed;
  inset: 0;
  z-index: 5;
  display: flex;
  align-items: flex-start;
  padding-block: max(24px, env(safe-area-inset-top, 0px)) max(32px, env(safe-area-inset-bottom, 0px));
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  background: linear-gradient(to top, rgb(6 7 8 / 0.92) 0%, rgb(6 7 8 / 0.55) 45%, rgb(6 7 8 / 0) 80%);
  overflow-y: auto;
  touch-action: pan-y;
}
.screen-over { background: radial-gradient(ellipse at 30% 80%, rgb(90 4 10 / 0.75), rgb(6 7 8 / 0.96) 70%); }
.screen-win { background: linear-gradient(to top, rgb(6 7 8 / 0.9), rgb(6 7 8 / 0.2) 70%); }

.note {
  /* Sits at the bottom, but scrolls whole when the screen is too short for it. */
  margin-top: auto;
  display: grid;
  gap: 14px;
  max-width: 34rem;
  min-width: 0;
  margin-left: clamp(0px, 4vw, 48px);
  animation: rise 900ms ease-out both;
}

.note p, .note ul { margin: 0; max-width: 62ch; }

.eyebrow {
  color: var(--dim);
  font-size: 12px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-family: var(--display);
  font-weight: 400;
  font-size: clamp(2.7rem, 10vw, 5.4rem);
  line-height: 0.92;
  letter-spacing: 0.01em;
  text-wrap: balance;
  color: var(--ink);
  text-shadow: 0 0 28px rgb(255 227 163 / 0.18);
}
.screen-over h1 { color: #f1d6d0; text-shadow: 0 0 30px rgb(181 20 31 / 0.6); }

.rules {
  padding: 0;
  list-style: none;
  display: grid;
  gap: 4px;
  color: var(--ink);
}
.rules li::before { content: "\2014\00a0"; color: var(--dim); }
.rules em { color: var(--beam); font-style: normal; }
.lede { font-size: 16px; max-width: 46ch; }
.howto summary {
  cursor: pointer;
  color: var(--dim);
  font-size: 13px;
  letter-spacing: 0.08em;
  width: max-content;
  padding: 6px 0;
}
.howto summary:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; }
.howto[open] summary { color: var(--ink); }
.howto .rules { padding-top: 6px; font-size: 14px; }

.warn {
  color: #e6a9a3;
  font-size: 13px;
  border-left: 2px solid var(--blood);
  padding-left: 10px;
}

.check {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--dim);
  cursor: pointer;
}
.check input { width: 18px; height: 18px; accent-color: var(--beam); margin: 0; }
.check.vol input { width: auto; flex: 1; max-width: 220px; height: 18px; }

.actions { display: flex; flex-wrap: wrap; gap: 12px; padding-top: 6px; }

.go {
  font: inherit;
  font-size: 16px;
  letter-spacing: 0.06em;
  color: var(--void);
  background: var(--beam);
  border: 0;
  border-radius: 2px;
  padding: 14px 22px;
  cursor: pointer;
  box-shadow: 0 0 0 0 rgb(255 227 163 / 0.5), 0 0 34px rgb(255 227 163 / 0.25);
  transition: transform 120ms ease, box-shadow 200ms ease;
}
.go:hover { box-shadow: 0 0 0 4px rgb(255 227 163 / 0.18), 0 0 44px rgb(255 227 163 / 0.35); }
.go:active { transform: translateY(1px) scale(0.99); }
.go:focus-visible, .mute:focus-visible, .check input:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; }

/* In-game HUD */
.hud {
  position: fixed;
  z-index: 3;
  top: calc(env(safe-area-inset-top, 0px) + 12px);
  left: max(16px, env(safe-area-inset-left, 0px));
  display: grid;
  gap: 6px;
  pointer-events: none;
}
.hud-row { display: flex; align-items: center; gap: 10px; }
.objective {
  margin: 0;
  font-size: 12px;
  color: var(--ink);
  opacity: 0.75;
  text-shadow: 0 1px 4px #000;
}
.loadnote { color: #e6a9a3; font-size: 13px; }
.go:disabled { opacity: 0.6; cursor: progress; box-shadow: none; }
.go-quiet {
  color: var(--ink);
  background: transparent;
  box-shadow: inset 0 0 0 1px rgb(221 214 196 / 0.45);
}
.go-quiet:hover { box-shadow: inset 0 0 0 1px var(--ink); }

/* Chapter list on the title: a column of typed index-card lines */
.chapters { display: grid; gap: 4px; max-width: 26rem; }
.chapter {
  font: inherit;
  font-size: 14px;
  display: flex;
  align-items: baseline;
  gap: 12px;
  width: 100%;
  min-height: 40px;
  padding: 8px 12px;
  text-align: left;
  color: var(--ink);
  background: rgb(17 19 21 / 0.55);
  border: 0;
  border-left: 2px solid rgb(141 136 122 / 0.5);
  border-radius: 0;
  cursor: pointer;
}
.chapter .num { color: var(--dim); font-size: 12px; letter-spacing: 0.12em; min-width: 1.2em; }
.chapter .name { flex: 1; }
.chapter .lock { color: var(--dim); font-size: 12px; letter-spacing: 0.08em; }
.chapter[aria-pressed="true"] { border-left-color: var(--beam); background: rgb(255 227 163 / 0.1); }
.chapter[aria-pressed="true"] .num { color: var(--beam); }
.chapter:hover:not(:disabled) { background: rgb(255 227 163 / 0.08); }
.chapter:disabled { opacity: 0.5; cursor: default; }
.chapter:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

/* Crosshair with a ring that fills while you take a fuse */
.cross {
  position: fixed;
  z-index: 3;
  left: 50%;
  top: 50%;
  width: 40px;
  height: 40px;
  margin: -20px 0 0 -20px;
  pointer-events: none;
}
.cross svg { width: 100%; height: 100%; display: block; }
.cross .dot { fill: rgb(221 214 196 / 0.55); }
.cross .ring-bg, .cross .ring { fill: none; stroke-width: 2; opacity: 0; transition: opacity 150ms ease; }
.cross .ring-bg { stroke: rgb(221 214 196 / 0.2); }
.cross .ring {
  stroke: var(--beam);
  stroke-dasharray: 94.25;
  stroke-dashoffset: 94.25;
  transform: rotate(-90deg);
  transform-origin: 50% 50%;
}
.cross.busy .ring-bg, .cross.busy .ring { opacity: 1; }

/* Touch joystick, shown where the left thumb lands */
.joy {
  position: fixed;
  z-index: 3;
  left: 0;
  top: 0;
  width: 110px;
  height: 110px;
  margin: -55px 0 0 -55px;
  border-radius: 50%;
  border: 1.5px solid rgb(221 214 196 / 0.25);
  background: rgb(6 7 8 / 0.25);
  pointer-events: none;
}
.knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 46px;
  height: 46px;
  margin: -23px 0 0 -23px;
  border-radius: 50%;
  background: rgb(221 214 196 / 0.22);
  border: 1.5px solid rgb(221 214 196 / 0.4);
}
.hud-label {
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--dim);
}
.slots { display: flex; gap: 6px; }
.slot {
  width: 9px;
  height: 22px;
  border: 1px solid rgb(141 136 122 / 0.6);
  border-radius: 3px;
  background: rgb(17 19 21 / 0.6);
}
.slot.got {
  border-color: var(--beam);
  background: linear-gradient(to bottom, #c9c3b2 0 22%, rgb(255 227 163 / 0.9) 22% 78%, #c9c3b2 78%);
  box-shadow: 0 0 10px rgb(255 227 163 / 0.6);
}

.mute {
  position: fixed;
  z-index: 6;
  top: calc(env(safe-area-inset-top, 0px) + 8px);
  right: max(16px, env(safe-area-inset-right, 0px));
  font: inherit;
  font-size: 12px;
  letter-spacing: 0.08em;
  color: var(--dim);
  background: rgb(17 19 21 / 0.7);
  border: 1px solid rgb(141 136 122 / 0.35);
  border-radius: 2px;
  padding: 7px 10px;
  cursor: pointer;
}
.mute[aria-pressed="true"] { color: var(--blood); border-color: rgb(181 20 31 / 0.6); }

/* The flashlight switch: low on the right, where a thumb rests. */
.lamp {
  position: fixed;
  z-index: 6;
  right: max(16px, env(safe-area-inset-right, 0px));
  bottom: calc(env(safe-area-inset-bottom, 0px) + 56px);
  min-width: 64px;
  min-height: 44px;
  font: inherit;
  font-size: 12px;
  letter-spacing: 0.08em;
  color: var(--beam);
  background: rgb(17 19 21 / 0.6);
  border: 1px solid rgb(255 227 163 / 0.35);
  border-radius: 2px;
  padding: 8px 12px;
  cursor: pointer;
}
.lamp[aria-pressed="false"] { color: var(--dim); border-color: rgb(141 136 122 / 0.3); }
.lamp:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; }

.hint {
  position: fixed;
  z-index: 3;
  left: max(16px, env(safe-area-inset-left, 0px));
  right: max(16px, env(safe-area-inset-right, 0px));
  bottom: calc(env(safe-area-inset-bottom, 0px) + 18px);
  margin: 0;
  font-size: 14px;
  color: var(--ink);
  text-shadow: 0 1px 6px #000;
  opacity: 0;
  transition: opacity 600ms ease;
  pointer-events: none;
}
.hint.show { opacity: 0.85; }

/* Cold-open captions: centred, spaced out, slow to fade. */
.caption {
  position: fixed;
  z-index: 4;
  left: max(16px, env(safe-area-inset-left, 0px));
  right: max(16px, env(safe-area-inset-right, 0px));
  bottom: 30%;
  margin: 0;
  text-align: center;
  font-size: clamp(15px, 2.2vw, 20px);
  letter-spacing: 0.14em;
  color: var(--ink);
  text-shadow: 0 0 12px #000, 0 1px 3px #000;
  opacity: 0;
  transition: opacity 900ms ease;
  pointer-events: none;
}
.caption.show { opacity: 0.9; }

/* Sound captions: what you would have heard, and from where */
.cues {
  position: fixed;
  z-index: 3;
  left: max(16px, env(safe-area-inset-left, 0px));
  right: max(16px, env(safe-area-inset-right, 0px));
  bottom: calc(env(safe-area-inset-bottom, 0px) + 50px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  pointer-events: none;
}
.cue {
  font-size: 13px;
  letter-spacing: 0.04em;
  color: var(--ink);
  background: rgba(0, 0, 0, 0.55);
  padding: 3px 9px;
  border-radius: 2px;
  opacity: 0.9;
  transition: opacity 700ms ease;
}
.cue.gone { opacity: 0; }

@keyframes rise {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  .note { animation: none; }
  .go, .hint, .caption { transition: none; }
}

/* Loading: the name, a thin filament warming up as the work gets done, and what is being done.
   The title's note waits underneath and rises as this fades. */
.loading {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 14px;
  padding: 16px;
  background: var(--void);
  transition: opacity 700ms ease;
}
.loading.done { opacity: 0; pointer-events: none; }
.loading p { margin: 0; text-align: center; }
.loading-name {
  font-family: var(--display);
  font-size: clamp(1.6rem, 6vw, 2.2rem);
  line-height: 1;
  color: var(--ink);
  text-shadow: 0 0 28px rgb(255 227 163 / 0.18);
}
.loading-bar {
  position: relative;
  width: min(220px, 60vw);
  height: 2px;
  border-radius: 1px;
  background: rgb(221 214 196 / 0.12);
}
.loading-bar span {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: var(--beam);
  box-shadow: 0 0 10px rgb(255 227 163 / 0.55);
  transform: scaleX(0);
  transform-origin: left;
  /* Only a short ease per step: anything that animates for the whole load keeps the page
     redrawing while the shaders compile, and makes loading much slower on weak GPUs. */
  transition: transform 400ms ease-out;
}
.loading-step {
  min-height: 1.55em;
  color: var(--dim);
  font-size: 12px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}
.booting #title .note { animation: none; opacity: 0; }

@media (prefers-reduced-motion: reduce) {
  .loading, .loading-bar span { transition: none; }
}

/* Her drawings: small sheets in a row at the top right, under the sound button */
.papers {
  position: fixed;
  z-index: 6;
  top: calc(env(safe-area-inset-top, 0px) + 50px);
  right: max(16px, env(safe-area-inset-right, 0px));
  display: flex;
  gap: 6px;
}
.paper-btn {
  position: relative;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px dashed rgb(141 136 122 / 0.45);
  border-radius: 2px;
  background: rgb(17 19 21 / 0.55);
  cursor: pointer;
  overflow: hidden;
}
.paper-btn:disabled { cursor: default; }
.paper-btn.found { border: 0; background: #e9e3d3; box-shadow: 0 2px 8px rgb(0 0 0 / 0.6); }
.paper-btn img { width: 100%; height: 100%; object-fit: cover; display: block; opacity: 0.92; }
.paper-num {
  position: absolute;
  left: 3px;
  top: 1px;
  font-size: 12px;
  color: #c42a22;
  text-shadow: 0 0 3px #e9e3d3;
}
.paper-btn:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

/* Reading one: the sheet held up close, the house still dark around it */
.viewer {
  position: fixed;
  inset: 0;
  z-index: 8;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 10px;
  padding: 16px;
  background: rgb(6 7 8 / 0.55);
  cursor: pointer;
}
.viewer-sheet img {
  display: block;
  width: min(88vw, 640px, calc((100vh - 140px) * 1.28));
  height: auto;
  transform: rotate(var(--tilt, 0deg));
  box-shadow: 0 10px 40px rgb(0 0 0 / 0.8);
  border-radius: 1px;
}
.viewer-cap { margin: 0; font-size: 14px; color: var(--ink); text-shadow: 0 1px 4px #000; }
.viewer-close {
  font: inherit;
  font-size: 13px;
  color: var(--dim);
  background: transparent;
  border: 1px solid rgb(141 136 122 / 0.45);
  border-radius: 2px;
  padding: 8px 14px;
  min-height: 40px;
  cursor: pointer;
}

/* The number lock: four wheels on a scrap of card at the bottom of the screen */
.lockbox {
  position: fixed;
  z-index: 7;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 16px);
  transform: translateX(-50%);
  width: min(360px, calc(100vw - 32px));
  display: grid;
  gap: 10px;
  padding: 14px 16px 16px;
  background: rgb(17 19 21 / 0.88);
  border-left: 2px solid var(--beam);
  box-shadow: 0 10px 40px rgb(0 0 0 / 0.7);
}
.lockbox.shake { animation: shake 360ms ease; }
.lockbox .actions { padding-top: 0; }
.lockbox .go { padding: 12px 18px; font-size: 15px; }
.wheels { display: flex; gap: 10px; justify-content: center; }
.wheel { display: grid; justify-items: center; gap: 2px; }
.wheel-btn {
  width: 52px;
  height: 40px;
  font: inherit;
  font-size: 14px;
  color: var(--ink);
  background: rgb(255 227 163 / 0.08);
  border: 1px solid rgb(141 136 122 / 0.4);
  border-radius: 2px;
  cursor: pointer;
}
.wheel-btn:active { background: rgb(255 227 163 / 0.2); }
.wheel-btn:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.wheel-num {
  display: block;
  width: 52px;
  padding: 4px 0;
  text-align: center;
  font-family: var(--display);
  font-size: 34px;
  line-height: 1.1;
  color: var(--beam);
  background: linear-gradient(#000 0%, #1d1a14 30%, #2a251c 50%, #1d1a14 70%, #000 100%);
  border-radius: 2px;
}
.lock-msg { margin: 0; font-size: 13px; color: var(--dim); min-height: 1.5em; }
@keyframes shake {
  0%, 100% { transform: translateX(-50%); }
  25% { transform: translateX(calc(-50% - 6px)); }
  50% { transform: translateX(calc(-50% + 5px)); }
  75% { transform: translateX(calc(-50% - 3px)); }
}
@media (prefers-reduced-motion: reduce) {
  .lockbox.shake { animation: none; }
}
