/* THE IN BETWEEN
   Photoreal night plate, cold steel, paper, one lamp. */

:root {
  --night: #060a10;
  --slate: #101b25;
  --teal: #1e3a3e;
  --ink: #7c93a0;
  --bone: #c9c2b4;
  --amber: #d9a347;
  --green: #4f8e6b;
  --red: #8e2b24;
  --paper: #c9c2b4;
  --paper-2: #bab1a0;
  --manila: #b9ab8f;
  --ink-dark: #101b25;
  --plate-w: min(100vw, 66.6667vh);
  --mono: "IBM Plex Mono", ui-monospace, monospace;
  --sans: "IBM Plex Sans Condensed", "Helvetica Neue", sans-serif;
  --stencil: "Allerta Stencil", "Arial Black", sans-serif;
  --ease: cubic-bezier(.2, .9, .15, 1);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  overflow: hidden;
  touch-action: none;
  background: #04070a;
  color: var(--bone);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; }
img { display: block; max-width: 100%; -webkit-user-drag: none; user-select: none; }
[hidden] { display: none !important; }
.mono { font-family: var(--mono); font-weight: 400; letter-spacing: .08em; }

#app { position: fixed; inset: 0; overflow: hidden; isolation: isolate; }

.page-steel {
  position: absolute;
  inset: -4%;
  background: #05080c url(../assets/scene/table_night.webp) center / cover no-repeat;
  filter: brightness(.22) saturate(.62) contrast(1.1);
}
.page-steel::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(90% 80% at 50% 45%, rgba(3,6,9,.12) 0%, rgba(3,6,9,.92) 100%);
}

/* ---------- the plate ---------- */

.plate {
  position: absolute;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: var(--plate-w);
  aspect-ratio: 2 / 3;
  overflow: hidden;
  background: #060a10;
  box-shadow: 0 0 0 1px rgba(201,194,180,.12), 0 40px 90px rgba(0,0,0,.85);
  z-index: 2;
  perspective: 1150px;
  perspective-origin: 50% 46%;
}

/* the plate is one camera: layers sit at different depths and move apart */
.stage {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
  transform:
    translate3d(calc(var(--camx, 0px) * -.10), calc(var(--camy, 0px) * -.07), 0)
    rotateX(calc(var(--pitch, 0deg) * -.55))
    rotateY(calc(var(--yaw, 0deg) * .55));
  transition: transform .12s linear;
  will-change: transform;
}
body.dragging .stage { transition: none; }

.plate-world {
  position: absolute; left: 0; top: 0; width: 100%; height: 50.4%; overflow: hidden;
  transform: translate3d(calc(var(--camx, 0px) * -.34), calc(var(--camy, 0px) * -.22), -110px) scale(1.2);
  transform-origin: 50% 50%;
  background: #04070a;
}
.plate-world img.world-img {
  width: 100%; height: 100%;
  object-fit: cover;
  object-position: 50% 40%;
  transform: scale(1.12) translate3d(calc(var(--px, 0px) * .4), calc(var(--py, 0px) * .3), 0);
  will-change: transform;
}
.world-ledge {
  position: absolute;
  left: -8%;
  bottom: -3%;
  width: 116%;
  height: auto;
  opacity: .72;
  filter: brightness(.5) saturate(.6) contrast(1.05) blur(1px);
  transform: translate3d(calc(var(--camx, 0px) * -.55), calc(var(--camy, 0px) * -.35), 0);
  pointer-events: none;
}
.fog {
  position: absolute;
  inset: -30% -20%;
  pointer-events: none;
  background: url(../assets/scene/fog.webp) 0 0 / 62% auto repeat;
  mix-blend-mode: screen;
  will-change: transform, opacity;
}
.fog-a {
  opacity: .16;
  z-index: 2;
  animation: fogDrift 74s linear infinite;
  filter: blur(2px);
}
.fog-b {
  opacity: .11;
  z-index: 2;
  background-size: 42% auto;
  animation: fogDrift2 118s linear infinite reverse;
  transform: translateY(-8%);
}
@keyframes fogDrift {
  from { background-position: 0 0; }
  to { background-position: 1200px 0; }
}
@keyframes fogDrift2 {
  from { background-position: 0 0; }
  to { background-position: -900px 0; }
}
.world-fx { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 4; pointer-events: none; }
.world-fade {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(4,7,10,.55) 0%, rgba(4,7,10,0) 26%, rgba(4,7,10,0) 82%, rgba(4,7,10,.65) 100%);
}

.masthead {
  position: absolute;
  left: 4.2%;
  top: 3.2%;
  width: 58%;
  z-index: 12;
  pointer-events: none;
}
.title {
  margin: 0;
  font-family: var(--stencil);
  font-weight: 400;
  text-transform: uppercase;
  font-size: calc(var(--plate-w) * .106);
  line-height: .8;
  letter-spacing: .012em;
  color: var(--paper);
  transform: rotate(-.55deg);
  transform-origin: left top;
  text-shadow: .03em .028em 0 rgba(142,43,36,.92), 0 2px 18px rgba(0,0,0,.45);
}
.title span { display: block; }
.title span + span { margin-left: .1em; }
.kicker {
  margin: 2.4% 0 0;
  display: flex;
  flex-wrap: wrap;
  gap: .8em;
  font-family: var(--mono);
  font-size: calc(var(--plate-w) * .0115);
  letter-spacing: .18em;
  color: #9fb0b8;
  text-shadow: 0 1px 4px rgba(0,0,0,.9);
}
.kicker i { font-style: normal; color: var(--red); }

/* ---------- table / board ---------- */

.table-zone {
  position: absolute; left: 0; top: 50%; width: 100%; height: 50%; z-index: 3;
  transform-origin: 50% 6%;
  transform:
    translate3d(calc(var(--camx, 0px) * -.16), calc(var(--camy, 0px) * -.11), 0)
    rotateX(var(--tiltx, 0deg))
    rotateY(var(--tilty, 0deg));
  will-change: transform;
}
.table-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: 50% 0; transform: scale(1.10); transform-origin: 50% 0; }
.table-dark { display: none; }
html.nightmode .table-lamp { display: none; }
html.nightmode .table-dark { display: block; }
html.nightmode .plate-world img { filter: brightness(.64) saturate(.66); }
html.nightmode .table-img { filter: brightness(.58) saturate(.5) contrast(1.08); }
html.nightmode .hands img { filter: brightness(.6) saturate(.42); }
html.nightmode .case-paper { filter: brightness(.78) saturate(.6) contrast(1.05); }
html.nightmode .map-bg img, html.nightmode .cavern-img { filter: brightness(.82) saturate(.78); }

.board-bar {
  position: absolute;
  left: 2%;
  right: 2%;
  top: .4%;
  height: 4.4%;
  display: flex;
  justify-content: flex-start;
  align-items: center;
  gap: 2.2em;
  z-index: 8;
  padding: 0 8px;
  font-size: calc(var(--plate-w) * .0112);
  letter-spacing: .14em;
  color: #c3ccce;
  text-shadow: 0 1px 3px #000;
  background: linear-gradient(90deg, rgba(4,7,10,.8), rgba(4,7,10,.42));
  border-bottom: 1px solid rgba(201,194,180,.25);
  pointer-events: none;
}
.board-bar::before {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: -1px;
  height: 1px;
  background: rgba(201,194,180,.18);
}

.board {
  position: absolute;
  left: 4%;
  right: 24%;
  top: 6.5%;
  height: 54%;
  z-index: 6;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-template-rows: .86fr 1.14fr;
  gap: 3.2% 4.5%;
  align-items: center;
  justify-items: center;
  perspective: 820px;
  transform-style: preserve-3d;
}
#app[data-phase="title"] .case-card { pointer-events: none; }

.case-card {
  position: relative;
  width: 100%;
  height: 100%;
  transform: rotate(var(--rot, 0deg));
  transition: transform .3s var(--ease), filter .3s ease, z-index 0s;
  filter: drop-shadow(3px 5px 0 rgba(2,4,7,.5));
  outline: none;
}
.case-card:hover, .case-card:focus-within {
  transform: rotate(0deg) translateY(-2%) translateZ(26px) scale(1.015);
  z-index: 7;
  filter: drop-shadow(6px 12px 9px rgba(2,4,7,.66));
}
.case-paper {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: 50% 50%;
  -webkit-user-drag: none;
}
.card-open {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  background: transparent;
  border: 0;
  padding: 0;
  z-index: 4;
}
.card-open:focus-visible { outline: 2px solid var(--paper); outline-offset: 3px; }
.board.linking .card-open { cursor: crosshair; }
.case-card.selected { transform: rotate(0) translateY(-2%) translateZ(30px) scale(1.02); z-index: 7; }
.case-card.selected .card-open { outline: 2px solid var(--red); outline-offset: 3px; }
.case-card.selected::after {
  content: "";
  position: absolute;
  top: 3%;
  right: 3%;
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--red);
  box-shadow: 0 0 0 3px rgba(142,43,36,.25);
  z-index: 8;
  animation: pinPulse 1.2s steps(2,end) infinite;
}
@keyframes pinPulse { 50% { box-shadow: 0 0 0 7px rgba(142,43,36,.05); } }
.case-card.wrong { animation: wrongShake .45s steps(4, end); }
@keyframes wrongShake {
  0%,100% { transform: rotate(var(--rot,0deg)) translateX(0); }
  25% { transform: rotate(var(--rot,0deg)) translateX(-5px); }
  50% { transform: rotate(var(--rot,0deg)) translateX(5px); }
  75% { transform: rotate(var(--rot,0deg)) translateX(-3px); }
}
.linked-stamp {
  position: absolute;
  left: 4%;
  top: 4%;
  z-index: 5;
  font-family: var(--stencil);
  font-size: calc(var(--plate-w) * .019);
  letter-spacing: .1em;
  color: var(--red);
  border: 2px solid var(--red);
  padding: .08em .28em;
  transform: rotate(-7deg);
  opacity: .92;
  pointer-events: none;
  mix-blend-mode: multiply;
}

.threads {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 9;
  overflow: visible;
  pointer-events: none;
}
.threads line { stroke: #a32f25; stroke-width: 2; }
.threads circle { fill: #a32f25; }

.hint {
  position: absolute;
  left: 10%;
  right: 10%;
  top: 60.9%;
  z-index: 8;
  margin: 0;
  text-align: center;
  font-family: var(--mono);
  font-size: calc(var(--plate-w) * .011);
  letter-spacing: .14em;
  color: #c9c1b1;
  text-shadow: 0 1px 4px #000, 0 0 12px rgba(0,0,0,.9);
  pointer-events: none;
}
.hint.alert { color: #d8a49e; }
#app[data-phase="title"] .hint { display: none; }

.hands {
  position: absolute;
  left: 0;
  bottom: 0;
  width: 100%;
  z-index: 10;
  pointer-events: none;
}
.hands img { width: 100%; height: auto; display: block; }

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

.ruler {
  position: absolute;
  left: 9%;
  right: 9%;
  bottom: 7.6%;
  height: 5.4%;
  z-index: 14;
  transform: translate3d(calc(var(--camx, 0px) * -0.4), calc(var(--camy, 0px) * -0.24), 105px) scale(0.92);
  transform-origin: 50% 100%;
  will-change: transform;
  display: flex;
  align-items: center;
  gap: 1.2%;
  pointer-events: none;
  font-size: calc(var(--plate-w) * .0102);
  letter-spacing: .12em;
  color: #e0d7c6;
  text-shadow: 0 1px 4px #000;
}
.ruler-day, .ruler-week { flex: 0 0 auto; white-space: nowrap; }
.ruler-track {
  position: relative;
  flex: 1 1 auto;
  height: 100%;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border-top: 1px solid rgba(201,194,180,.55);
  border-bottom: 1px solid rgba(201,194,180,.4);
  background: rgba(6,10,16,.18);
}
.seg { position: relative; border-right: 1px solid rgba(201,194,180,.28); }
.seg:last-of-type { border-right: 0; }
.seg b {
  position: absolute;
  left: 4px;
  top: 2px;
  font-family: var(--mono);
  font-weight: 500;
  font-size: calc(var(--plate-w) * .0084);
  letter-spacing: .1em;
  color: rgba(215,207,192,.62);
}
.seg.active b { color: #f0e8d8; }
.seg.active { background: rgba(79,142,107,.16); }
.marker { position: absolute; z-index: 3; transition: left 1.1s var(--ease); pointer-events: none; }
.marker-day {
  bottom: 1px;
  width: 0; height: 0;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-bottom: 11px solid #e6dece;
  transform: translateX(-50%);
  filter: drop-shadow(0 1px 2px #000);
}
.marker-night {
  top: 1px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #cdbf9e;
  box-shadow: inset -4px 0 0 #12100c;
  transform: translateX(-50%);
}

/* ---------- HUD ---------- */

.hud {
  position: fixed;
  top: 10px;
  right: 12px;
  z-index: 52;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 4px;
  max-width: 46vw;
}
.hud-btn {
  font-family: var(--mono);
  font-size: clamp(7px, .8vw, 9px);
  letter-spacing: .14em;
  padding: 8px 9px;
  background: rgba(7,11,16,.72);
  border: 1px solid rgba(201,194,180,.28);
  color: #bfb8a9;
  transition: color .15s ease, border-color .15s ease, background .15s ease;
}
.hud-btn:hover { border-color: rgba(201,194,180,.75); color: var(--paper); }
.hud-btn:focus-visible { outline: 2px solid var(--paper); outline-offset: 1px; }
.hud-btn[aria-pressed="true"] { color: #f0e8d8; border-color: var(--paper); }
.hud-btn.on { background: var(--red); border-color: var(--red); color: #f3ece0; }
.hud-btn:disabled { opacity: .26; }
.hud-btn.pulse { animation: hudPulse 1.8s steps(2, end) infinite; }
@keyframes hudPulse { 0%,100% { border-color: rgba(201,194,180,.28); } 50% { border-color: var(--red); } }

/* ---------- start ---------- */

.start-layer {
  position: absolute;
  left: 0; right: 0; bottom: 2.2%;
  z-index: 20;
  display: flex;
  justify-content: center;
  pointer-events: none;
  transition: opacity .3s ease;
}
.start-slip {
  pointer-events: none;
  width: min(310px, 68%);
  background: var(--paper);
  color: var(--ink-dark);
  border: 1px solid #1a1c18;
  box-shadow: 5px 7px 0 rgba(2,4,7,.62);
  padding: 8px 13px 7px;
  text-align: center;
  position: relative;
  transform: rotate(-.5deg);
}
.start-slip .btn-solid, .start-slip .btn-text { pointer-events: auto; }
.start-slip .btn-solid { font-size: clamp(9px, 1vw, 11px); padding: .58em .9em; }
.start-slip::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0; height: 2px;
  background: var(--red);
}
.start-line {
  margin: 0 0 6px;
  font-size: clamp(6px, .7vw, 8px);
  letter-spacing: .14em;
  color: var(--red);
}
.start-copy {
  margin: 0 0 10px;
  font-size: 12px;
  line-height: 1.4;
  color: var(--paper);
  max-width: 42ch;
}
.btn-solid {
  display: inline-block;
  font-family: var(--stencil);
  font-size: clamp(10px, 1.25vw, 14px);
  letter-spacing: .09em;
  text-transform: uppercase;
  background: var(--paper);
  color: var(--ink-dark);
  border: 1px solid #0b0e12;
  padding: .72em 1.1em;
  box-shadow: 3px 3px 0 rgba(142,43,36,.82);
  transition: transform .15s var(--ease), box-shadow .15s var(--ease);
}
.btn-solid:hover { transform: translate(-1px,-1px); box-shadow: 4px 4px 0 rgba(142,43,36,.82); }
.btn-solid:active { transform: translate(1px,1px); box-shadow: 1px 1px 0 rgba(142,43,36,.82); }
.btn-solid:focus-visible { outline: 2px solid var(--paper); outline-offset: 3px; }
.btn-solid.red { background: var(--red); border-color: var(--red); color: #f2e9db; box-shadow: 3px 3px 0 rgba(6,10,16,.7); }
.btn-solid.small { font-size: 10px; padding: .62em .9em; }
.btn-text {
  margin: 8px 0 0;
  background: none;
  border: 0;
  padding: 0;
  font-family: var(--mono);
  font-size: 8px;
  letter-spacing: .14em;
  color: var(--ink-dark);
  text-decoration: underline;
  text-underline-offset: 3px;
}
.btn-text:hover { color: #d8a49e; }
.start-note { display: none; }
#app:not([data-phase="title"]) .start-layer { opacity: 0; pointer-events: none; }

/* ---------- radio ---------- */

.radio-caption {
  position: fixed;
  left: 4vw;
  bottom: calc(17vh + 42px);
  z-index: 34;
  max-width: 52ch;
  font-family: var(--mono);
  font-size: clamp(9px, 1.05vw, 12px);
  letter-spacing: .05em;
  color: var(--paper);
  border-left: 2px solid var(--red);
  padding-left: 12px;
  text-shadow: 0 1px 5px #000;
}
.radio-caption::before { content: "RADIO / SHERIFF'S OFFICE"; display: block; font-size: 7px; letter-spacing: .2em; color: var(--ink); margin-bottom: 4px; }
.radio-caption.voice::before { content: "FATHER / 1971"; }
.board-radio {
  top: 20.5%;
  bottom: auto;
  left: 5.5%;
  max-width: min(48ch, 52%);
  background: rgba(3,6,9,.5);
  border-left: 2px solid var(--red);
  padding: 8px 10px 8px 12px;
  pointer-events: none;
}

/* ---------- screens ---------- */

.screen { position: fixed; inset: 0; z-index: 30; }
.prologue { z-index: 56; background: #05090e; overflow: hidden; touch-action: none; }
.prologue-bg { position: absolute; inset: 0; }
.prologue-bg img { width: 100%; height: 100%; object-fit: cover; object-position: 50% 46%; }
.prologue-bg::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(4,7,10,.9) 0%, rgba(4,7,10,.25) 26%, rgba(4,7,10,0) 55%, rgba(4,7,10,.55) 100%),
    radial-gradient(90% 70% at 50% 50%, rgba(4,7,10,0) 40%, rgba(4,7,10,.64) 100%);
}
.hands-child {
  position: absolute;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: min(1100px, 106vw);
  z-index: 3;
  filter: drop-shadow(0 -4px 18px rgba(0,0,0,.45));
  transition: transform .35s var(--ease);
}
.hands-child.step { transform: translateX(-50%) translateY(2%) scale(1.01); }
.prologue-card {
  position: absolute;
  top: 8vh; left: 0; right: 0;
  text-align: center;
  z-index: 6;
  padding: 0 6vw;
  animation: cutIn .4s steps(2, end);
}
.prologue-card .mono { margin: 0 0 1.2em; font-size: clamp(8px, 1vw, 11px); letter-spacing: .3em; color: var(--amber); }
.prologue-card-line {
  margin: 0 auto;
  max-width: 24ch;
  font-family: var(--stencil);
  font-size: clamp(24px, 4.4vw, 48px);
  line-height: 1.06;
  letter-spacing: .05em;
  color: var(--paper);
  text-transform: uppercase;
}
@keyframes cutIn { 0% { opacity: 0; } 48% { opacity: 1; } 60% { opacity: .3; } 100% { opacity: 1; } }
.prologue-copy {
  position: absolute;
  left: clamp(18px, 6vw, 86px);
  bottom: 43vh;
  z-index: 7;
  max-width: min(46ch, 82vw);
  font-size: clamp(16px, 2vw, 25px);
  line-height: 1.35;
  color: var(--paper);
  text-shadow: 0 2px 8px rgba(0,0,0,.85);
}
.prologue-copy .line { display: block; margin: 0 0 .55em; }
.walk-bar {
  position: absolute;
  left: 50%;
  bottom: calc(2.6vh + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 9;
  display: flex;
  align-items: center;
  gap: 12px;
}
.walk-hint { font-size: 7px; color: var(--ink); letter-spacing: .14em; }
.skip {
  position: absolute;
  top: 2.4vmin; right: 2.4vmin;
  z-index: 10;
  background: none;
  border: 0;
  font-family: var(--mono);
  font-size: 8px;
  letter-spacing: .16em;
  color: #96a3a9;
  padding: 8px;
}
.skip:hover { color: var(--paper); }
.benchmark {
  position: absolute;
  left: 50%;
  bottom: 32vh;
  transform: translateX(-50%);
  z-index: 8;
  width: min(330px, 84vw);
  background: linear-gradient(180deg, #8e8a7d, #6e6b61);
  color: #151a1d;
  border: 1px solid #2a2b26;
  box-shadow: 0 0 0 3px #514e46, 10px 12px 24px rgba(0,0,0,.7);
  padding: 14px 16px 12px;
  text-align: center;
  font-family: var(--mono);
  animation: plateUp .45s var(--ease);
}
@keyframes plateUp { from { transform: translate(-50%, 22px); opacity: 0; } to { transform: translate(-50%, 0); opacity: 1; } }
.benchmark-kicker { display: block; font-size: 7px; letter-spacing: .18em; }
.benchmark-code { display: block; font-family: var(--stencil); font-size: clamp(24px, 4vw, 36px); letter-spacing: .08em; margin: 6px 0 2px; }
.benchmark-year { display: block; font-size: 8px; letter-spacing: .3em; opacity: .7; }
.benchmark-hit { display: inline-block; margin-top: 9px; font-size: 7px; letter-spacing: .18em; border-top: 1px solid rgba(22,28,30,.35); padding-top: 6px; color: #5a2a24; }
.benchmark:focus-visible { outline: 2px solid var(--paper); outline-offset: 4px; }

#app[data-phase="prologue"] .hud { display: none; }

/* ---------- map ---------- */

.map-screen { z-index: 30; background: #05090e; }
.map-bg { position: absolute; inset: 0; }
.map-bg img { position: absolute; left: -6%; top: -6%; width: 112%; height: 112%; object-fit: cover; object-position: 50% 50%; filter: brightness(.9) contrast(1.03); }
.map-bg::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(4,7,10,.82) 0%, rgba(4,7,10,.1) 22%, rgba(4,7,10,.05) 60%, rgba(4,7,10,.85) 100%),
    radial-gradient(80% 70% at 60% 55%, rgba(4,7,10,0) 35%, rgba(4,7,10,.6) 100%);
}
.map-screen-head {
  position: absolute;
  left: 3.5%; top: 3.2%;
  z-index: 4;
  display: flex;
  align-items: center;
  gap: 1.4em;
  color: var(--ink);
  font-size: 8px;
}
.screen-close {
  background: rgba(7,11,16,.72);
  border: 1px solid rgba(201,194,180,.4);
  color: var(--paper);
  font-family: var(--mono);
  font-size: 8px;
  letter-spacing: .14em;
  padding: 8px 11px;
}
.screen-close:hover { background: var(--paper); color: var(--ink-dark); }
.map-stage { position: absolute; inset: 0; z-index: 1; }
.map-site {
  position: absolute;
  left: 51.5%; top: 53%;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  color: #e3b5aa;
  font-size: 7px;
  letter-spacing: .16em;
  text-shadow: 0 1px 4px #000;
}
.site-pip {
  width: 1px;
  height: 30px;
  background: var(--red);
  position: relative;
  box-shadow: 0 0 12px rgba(142,43,36,.5);
}
.site-pip::before {
  content: "";
  position: absolute;
  left: 0; top: 0;
  width: 17px; height: 10px;
  background: var(--red);
  clip-path: polygon(0 0, 100% 0, 72% 50%, 100% 100%, 0 100%);
}
.site-pip::after {
  content: "";
  position: absolute;
  left: -4px; bottom: 0;
  width: 9px; height: 2px;
  background: var(--red);
}
.map-console {
  position: absolute;
  left: 4%;
  top: 17%;
  z-index: 5;
  width: min(340px, 42vw);
  max-height: 74vh;
  overflow-y: auto;
  background: var(--paper);
  color: var(--ink-dark);
  border: 1px solid #242822;
  box-shadow: 10px 12px 30px rgba(0,0,0,.7), inset 0 0 0 1px rgba(255,255,255,.12);
  padding: clamp(14px, 2.4vw, 24px);
  transform: rotate(-.4deg);
}
.map-console::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0; height: 3px;
  background: var(--red);
}
.console-kicker { margin: 0 0 1em; font-size: 8px; letter-spacing: .18em; color: var(--red); }
.tag-list { list-style: none; margin: 0 0 1.2em; padding: 0; border-top: 1px solid rgba(16,27,37,.35); border-bottom: 1px solid rgba(16,27,37,.35); }
.tag-list li { display: flex; justify-content: space-between; gap: 1em; padding: .55em 0; font-size: 8px; letter-spacing: .12em; color: #4b4a40; border-bottom: 1px dotted rgba(16,27,37,.25); }
.tag-list li:last-child { border-bottom: 0; }
.tag-list b { font-size: 11px; color: var(--ink-dark); letter-spacing: .08em; }
.tag-list li.locked { opacity: .3; }
.survey-form { display: grid; gap: 8px; }
.survey-form label { display: flex; justify-content: space-between; align-items: center; gap: 1em; font-size: 8px; letter-spacing: .14em; }
.survey-form input {
  width: 128px;
  background: #d9d1c1;
  border: 1px solid rgba(16,27,37,.5);
  color: var(--ink-dark);
  padding: 7px 8px;
  font-family: var(--mono);
  font-size: 16px;
  letter-spacing: .12em;
  text-align: right;
}
.survey-form input:focus { outline: 2px solid var(--red); outline-offset: 1px; }
.survey-form .btn-solid { margin-top: 6px; }
.console-msg { margin: 1em 0 0; font-family: var(--mono); font-size: 8px; letter-spacing: .1em; color: #4b4a40; min-height: 2.4em; line-height: 1.5; }
.console-msg.bad { color: var(--red); }
.console-msg.good { color: #2f6b4d; }
.map-located { margin-top: 1.2em; border-top: 1px solid rgba(16,27,37,.4); padding-top: 1em; }
.map-located p { margin: 0 0 .9em; font-size: 8px; letter-spacing: .12em; color: var(--red); }

/* ---------- descent ---------- */

.descent { z-index: 30; background: #030608; overflow: hidden; }
.cavern-wrap {
  position: absolute;
  touch-action: none;
  left: 50%; top: 50%;
  width: 100vmax;
  height: 100vmax;
  transform: translate(-50%, -50%);
  overflow: hidden;
  border: 1px solid rgba(201,194,180,.14);
}
.cavern-img { width: 100%; height: 100%; object-fit: cover; filter: saturate(.9) contrast(1.02); }
.torch {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background: rgba(2,4,7,.78);
  -webkit-mask-image: radial-gradient(circle var(--torch, 26vmin) at var(--mx, 50%) var(--my, 34%), transparent 0%, rgba(0,0,0,.3) 52%, #000 100%);
  mask-image: radial-gradient(circle var(--torch, 26vmin) at var(--mx, 50%) var(--my, 34%), transparent 0%, rgba(0,0,0,.3) 52%, #000 100%);
}
html.nightmode .torch { background: rgba(1,3,5,.86); }
#app.light-off .torch {
  -webkit-mask-image: radial-gradient(circle calc(var(--torch, 26vmin) * .28) at var(--mx,50%) var(--my,34%), transparent 0, #000 100%);
  mask-image: radial-gradient(circle calc(var(--torch, 26vmin) * .28) at var(--mx,50%) var(--my,34%), transparent 0, #000 100%);
}
.house {
  position: absolute;
  left: var(--hx);
  top: var(--hy);
  transform: translate(-50%, -50%);
  z-index: 3;
  width: 46px; height: 46px;
  background: transparent;
  border: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
}
.house::before {
  content: "";
  position: absolute;
  left: 50%; top: 50%;
  width: 28px; height: 34px;
  border: 1px solid rgba(201,194,180,.72);
  background: rgba(8,12,14,.82);
  transform: translate(-50%, -50%) rotate(-3deg);
  transition: border-color .2s ease, background .2s ease, transform .2s var(--ease);
  box-shadow: 0 3px 8px rgba(0,0,0,.55);
}
.house-window {
  position: relative;
  z-index: 1;
  width: 15px; height: 6px;
  background: #86c79a;
  box-shadow: 0 0 12px rgba(79,142,107,.8);
  animation: windowFlicker 5s steps(2, end) infinite;
}
.house-num { position: relative; z-index: 1; font-size: 7px; color: var(--paper); letter-spacing: .06em; text-shadow: 0 1px 2px #000; }
@keyframes windowFlicker { 0%,85%,100% { opacity: 1; } 90% { opacity: .45; } 94% { opacity: 1; } 96% { opacity: .6; } }
.house:hover::before, .house:focus-visible::before { border-color: var(--paper); background: rgba(20,42,32,.9); transform: translate(-50%, -50%) rotate(0deg) scale(1.08); }
.house:focus-visible { outline: 2px solid var(--paper); outline-offset: 2px; }
.house.found { opacity: .4; }
.house.found::before { border-color: var(--red); background: rgba(30,12,10,.9); transform: translate(-50%, -50%) rotate(-3deg) scale(.92); }
.house.found .house-window { background: var(--red); box-shadow: none; animation: none; }
.house.found .house-num { color: #d8a49e; }
.descent-head {
  position: absolute;
  left: 3.5%; top: 3.2%;
  z-index: 5;
  display: flex;
  gap: 2em;
  padding: 8px 10px;
  background: rgba(4,7,10,.6);
  border-bottom: 1px solid rgba(201,194,180,.2);
  color: #b7c1c5;
  font-size: 8px;
  letter-spacing: .12em;
}
#foundCount { color: var(--green); }
.descent-foot {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.2em;
  padding: 10px 3.5% calc(10px + env(safe-area-inset-bottom));
  background: linear-gradient(180deg, rgba(3,6,9,0), rgba(3,6,9,.9) 40%);
}
.descent-foot .hint { position: static; text-align: left; text-shadow: 0 1px 4px #000; }
.foot-buttons { display: flex; flex-wrap: wrap; gap: 8px; }
.btn-line {
  font-family: var(--mono);
  font-size: clamp(8px, .95vw, 10px);
  letter-spacing: .14em;
  text-transform: uppercase;
  padding: .68em .95em;
  background: rgba(7,11,16,.6);
  border: 1px solid rgba(201,194,180,.42);
  color: var(--paper);
  transition: background .18s ease, color .18s ease, border-color .18s ease;
}
.btn-line:hover { background: var(--paper); color: var(--ink-dark); border-color: var(--paper); }
.btn-line:focus-visible { outline: 2px solid var(--paper); outline-offset: 2px; }
.btn-line.on { background: var(--red); border-color: var(--red); color: #f3ece0; }
.btn-line[disabled] { opacity: .35; }

/* ---------- overlays ---------- */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  perspective: 1200px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(10px, 2.4vmin, 28px);
  background: rgba(3,5,8,.9);
}
.sheet-close {
  position: absolute;
  top: 0; right: 0;
  z-index: 20;
  background: var(--ink-dark);
  color: var(--paper);
  border: 0;
  font-family: var(--mono);
  font-size: 8px;
  letter-spacing: .16em;
  padding: 8px 12px;
}
.sheet-close:hover { background: var(--red); }

/* dossier: the opened case file on the table, not a flat panel */

.dossier-overlay { background: #04070a; overflow: hidden; }
.dossier-scene { position: fixed; inset: 0; z-index: 0; overflow: hidden; background: #04070a; }
.dossier-world {
  position: absolute; left: 0; top: 0; width: 100%; height: 58%;
  object-fit: cover; object-position: 50% 40%;
  filter: brightness(.6) saturate(.7) contrast(1.04);
  transform: translate3d(calc(var(--camx, 0px) * -.18), calc(var(--camy, 0px) * -.12), 0) scale(1.07);
  will-change: transform;
}
.dossier-scene::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(3,6,9,.28) 0%, rgba(3,6,9,0) 26%, rgba(3,6,9,.62) 46%, rgba(3,6,9,.16) 62%, rgba(3,6,9,.72) 100%),
    radial-gradient(96% 84% at 50% 48%, rgba(3,6,9,0) 36%, rgba(3,6,9,.62) 100%);
  pointer-events: none;
}
.dossier-world-cut { display: none; }
.dossier-table-img {
  position: absolute; left: -3%; bottom: -4%; width: 106%; height: 62%;
  object-fit: cover; object-position: 50% 20%;
  transform: translate3d(calc(var(--camx, 0px) * -.10), calc(var(--camy, 0px) * -.06), 0) scale(1.04);
  filter: brightness(.9) saturate(.86);
}
.dossier-table-dark { display: none; }
html.nightmode .dossier-table-lamp { display: none; }
html.nightmode .dossier-table-dark { display: block; }
html.nightmode .dossier-world { filter: brightness(.5) saturate(.58) contrast(1.06); }
html.nightmode .dossier-lamp { opacity: .28; }
.dossier-print {
  position: absolute;
  left: 2.5%; top: 14%;
  width: 30%; max-width: 330px;
  margin: 0;
  padding: 6px 6px 18px;
  background: #c9c2b4;
  box-shadow: 8px 12px 24px rgba(0,0,0,.68);
  transform: rotate(-2.6deg) translate3d(calc(var(--camx, 0px) * -.14), calc(var(--camy, 0px) * -.08), 0);
  z-index: 1;
}
.dossier-print img { width: 100%; aspect-ratio: 2 / 3; object-fit: cover; display: block; filter: brightness(.82) contrast(1.03); }
.dossier-print figcaption { margin-top: 5px; font-size: 6px; letter-spacing: .12em; color: #4b4a40; }
html.nightmode .dossier-print { filter: brightness(.72) saturate(.8); }
.dossier-lamp {
  position: absolute; right: 0; top: 16%; width: 36%; height: 46%;
  background: radial-gradient(ellipse at 60% 40%, rgba(217,163,71,.20), rgba(217,163,71,.05) 46%, transparent 72%);
  mix-blend-mode: screen;
  pointer-events: none;
}
.dossier-hands-wrap {
  position: absolute; left: 0; right: 0; bottom: 0; height: 20vh;
  overflow: hidden; z-index: 3; pointer-events: none;
}
.dossier-hands {
  position: absolute; left: 50%; top: 0; width: min(1300px, 110%); height: auto;
  transform: translateX(-50%);
  filter: brightness(.84) contrast(1.05);
  -webkit-mask-image: linear-gradient(180deg, transparent 0%, #000 20%);
  mask-image: linear-gradient(180deg, transparent 0%, #000 20%);
}

.dossier-sheet {
  position: relative;
  z-index: 4;
  width: min(1120px, 98%);
  max-height: 92dvh;
  display: grid;
  grid-template-columns: minmax(0, 42%) minmax(0, 58%);
  align-items: center;
  gap: clamp(10px, 2vw, 28px);
  background: transparent;
  border: 0;
  box-shadow: none;
  overflow: visible;
  perspective: 1200px;
}
.dossier-left {
  display: flex; align-items: center; justify-content: center;
  padding: clamp(6px, 1.5vw, 18px);
}
.dossier-file {
  position: relative;
  overflow: visible;
  z-index: 1;
  width: min(100%, 440px);
  aspect-ratio: var(--ar, 1);
  filter: drop-shadow(8px 12px 14px rgba(0,0,0,.68));
  perspective: 900px;
  transform-style: preserve-3d;
  transform: rotate(-1.2deg);
}
.dossier-file::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(160deg, #b9ab8f, #8e826b);
  transform: translate(7px, 8px) rotate(1.8deg);
  z-index: -1;
  box-shadow: 6px 10px 16px rgba(0,0,0,.55);
}
.dossier-file::before {
  content: "";
  position: absolute;
  left: var(--pl, 18%);
  top: calc(var(--pt, 5%) + var(--ph, 18%) + 1px);
  width: var(--pw, 62%);
  height: 8px;
  background: #020406;
  box-shadow: inset 0 3px 5px rgba(0,0,0,.9);
  z-index: 1;
}
.dossier-paper { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: fill; }
.dossier-photo {
  position: absolute;
  left: var(--pl, 18%);
  top: var(--pt, 5%);
  width: var(--pw, 62%);
  height: var(--ph, 18%);
  overflow: hidden;
  background: #05080b;
  z-index: 1;
}
.dossier-photo img { width: 100%; height: 100%; object-fit: cover; object-position: 50% 46%; filter: brightness(1.55) contrast(1.04) saturate(.72); }
.dossier-redact {
  position: absolute;
  left: var(--pl, 18%);
  top: var(--pt, 5%);
  width: var(--pw, 62%);
  height: var(--ph, 18%);
  background: #05080a;
  border: 1px solid rgba(201,194,180,.12);
  z-index: 2;
  color: #8d969b;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 4px;
  font-family: var(--mono);
  font-size: 6px;
  letter-spacing: .18em;
  transform-origin: 50% 100%;
  transition: transform .7s cubic-bezier(.2,.9,.15,1), box-shadow .7s ease;
  box-shadow: 0 4px 10px rgba(0,0,0,.7);
}
.dossier-redact:hover { background: #080d11; }
.dossier-redact:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }
.dossier-file.lifted .dossier-redact {
  transform: translateY(-108%) rotateX(-16deg) translateZ(36px) scale(1.03);
  box-shadow: 0 26px 34px rgba(0,0,0,.82), 0 8px 12px rgba(0,0,0,.7);
}
.photo-caption {
  position: absolute;
  left: var(--pl, 18%);
  width: var(--pw, 62%);
  top: calc(var(--pt, 5%) + var(--ph, 18%) + 6px);
  font-size: 6px;
  letter-spacing: .12em;
  color: #3e3b32;
  z-index: 3;
  text-shadow: 0 1px 0 rgba(255,255,255,.12);
}
.dossier-file.lifted .photo-caption { color: #6e2c24; }

.dossier-notes {
  position: relative;
  align-self: center;
  height: min(78dvh, 760px);
  max-height: 88dvh;
  overflow: hidden;
  background: transparent;
  color: var(--ink-dark);
  transform: rotate(.4deg);
}
.dossier-notes-paper {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover;
  filter: drop-shadow(10px 15px 18px rgba(0,0,0,.6));
  pointer-events: none;
}
.dossier-notes-inner {
  position: absolute; inset: 0;
  overflow-y: auto;
  padding: clamp(34px, 4.4vw, 56px) clamp(26px, 3.4vw, 48px) clamp(40px, 5vw, 64px);
  scrollbar-width: thin;
}
.dossier-letterhead {
  margin: 0 0 1.15em;
  padding: 0 0 .7em 46px;
  border-bottom: 1px solid rgba(16,27,37,.35);
}
.dossier-letterhead .mono { display: block; font-size: 7px; letter-spacing: .2em; color: #4b4a40; margin-bottom: .5em; }
.dossier-letterhead strong {
  display: block;
  font-family: var(--stencil);
  font-weight: 400;
  font-size: clamp(20px, 2.5vw, 31px);
  line-height: 1;
  letter-spacing: .02em;
  color: var(--ink-dark);
  transform: rotate(-.35deg);
  transform-origin: left center;
  text-shadow: 1px 1px 0 rgba(142,43,36,.5);
}
.dossier-cid { margin: 0 0 .5em; font-size: 8px; letter-spacing: .18em; color: #4b4a40; }
.dossier-notes h2 { margin: 0; font-family: var(--stencil); font-weight: 400; font-size: clamp(24px, 3.1vw, 36px); line-height: .98; letter-spacing: .01em; }
.dossier-role { margin: .45em 0 1.1em; font-family: var(--mono); font-size: 9px; letter-spacing: .15em; color: var(--red); }
.facts { display: grid; grid-template-columns: auto 1fr; gap: .35em 1em; margin: 0 0 1.3em; font-family: var(--mono); font-size: 8px; letter-spacing: .06em; border-top: 1px solid rgba(16,27,37,.3); border-bottom: 1px solid rgba(16,27,37,.3); padding: .8em 0; }
.facts dt { color: #4b4a40; }
.facts dd { margin: 0; }
.prose p { margin: 0 0 .75em; font-size: clamp(13px, 1.3vw, 15px); line-height: 1.48; max-width: 58ch; animation: typeRun .4s steps(3, end) both; }
.prose p:nth-child(2) { animation-delay: .1s; }
.prose p:nth-child(3) { animation-delay: .2s; }
.anomaly { margin: 1.1em 0 .7em; padding: .7em .8em; border: 1px solid var(--red); font-size: 12px; display: flex; gap: .9em; align-items: baseline; }
.anomaly span { color: var(--red); font-size: 7px; letter-spacing: .18em; }
.anomaly b { font-family: var(--mono); font-size: 10px; letter-spacing: .08em; }
.dossier-hint { margin: 0; font-size: 7px; letter-spacing: .14em; color: #55534a; }
.dossier-stamp {
  display: inline-block;
  margin: 2.4em 0 0;
  padding: .14em .42em;
  border: 2px solid var(--red);
  color: var(--red);
  font-family: var(--stencil);
  font-size: clamp(11px, 1.3vw, 15px);
  line-height: 1.05;
  letter-spacing: .13em;
  transform: rotate(-4deg);
  opacity: .55;
  mix-blend-mode: multiply;
}

/* notebook */
.notebook-overlay { z-index: 76; }
.notebook {
  position: relative;
  width: min(560px, 100%);
  max-height: 90dvh;
  overflow-y: auto;
  background:
    repeating-linear-gradient(180deg, transparent 0 31px, rgba(16,27,37,.14) 31px 32px),
    #d3cbbd;
  color: var(--ink-dark);
  border: 1px solid #2b2b24;
  box-shadow: 12px 16px 36px rgba(0,0,0,.7);
  padding: clamp(20px, 4vmin, 40px) clamp(20px, 4vmin, 42px) 34px;
  transform: rotate(-.4deg);
}
.notebook::before { content: ""; position: absolute; left: 16px; top: 0; bottom: 0; width: 1px; background: rgba(142,43,36,.35); }
.notebook::after { content: ""; position: absolute; left: 22px; top: 26px; width: 10px; height: 10px; border-radius: 50%; background: #9e9585; box-shadow: inset 0 0 0 1px rgba(16,27,37,.4); }
.notebook-kicker { margin: 0 0 1.3em; font-size: 8px; letter-spacing: .2em; color: var(--red); }
.notebook h2 { margin: 0 0 .6em; font-family: var(--stencil); font-weight: 400; font-size: clamp(26px, 4vw, 38px); }
.notebook .note { font-size: 14px; line-height: 1.55; margin: 0 0 1em; max-width: 42ch; }
.notebook-code { margin: .5em 0 .8em; font-family: var(--stencil); font-size: clamp(44px, 8vw, 76px); letter-spacing: .12em; border-top: 2px solid var(--ink-dark); border-bottom: 2px solid var(--ink-dark); padding: .1em 0; transform: rotate(-.5deg); display: inline-block; }
.notebook-ledger { margin-top: 1.4em; border-top: 1px solid rgba(16,27,37,.4); padding-top: .8em; }
.notebook-ledger p { margin: 0 0 .6em; font-size: 8px; letter-spacing: .14em; color: #4b4a40; }
.notebook-ledger ul { margin: 0; padding: 0; list-style: none; font-family: var(--mono); font-size: 9px; letter-spacing: .04em; }
.notebook-ledger li { display: flex; justify-content: space-between; gap: 1em; padding: .35em 0; border-bottom: 1px dotted rgba(16,27,37,.3); }
.notebook-ledger li span:last-child { color: var(--red); }
.notebook-ledger li.unknown { opacity: .4; }

/* found */
.found-overlay { z-index: 64; background: rgba(2,4,7,.95); }
.found-sheet {
  width: min(1080px, 100%);
  max-height: 92dvh;
  display: grid;
  grid-template-columns: minmax(0, 54%) minmax(0, 46%);
  background: #070a0d;
  border: 1px solid rgba(201,194,180,.24);
  box-shadow: 12px 16px 40px rgba(0,0,0,.8);
  overflow: hidden;
}
.found-photo {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(12px, 2.6vw, 30px);
  background: #05080b url(../assets/scene/table_night.webp) center / cover no-repeat;
  border-right: 1px solid rgba(201,194,180,.18);
}
.found-photo img:first-child {
  width: 100%;
  height: auto;
  aspect-ratio: 4 / 5;
  max-width: 100%;
  max-height: 78dvh;
  object-fit: cover;
  object-position: 50% 35%;
  border: 6px solid #d9d2c4;
  box-shadow: 0 14px 34px rgba(0,0,0,.8);
  filter: contrast(1.02) saturate(.85);
}
.found-stamp { position: absolute; right: 4%; bottom: 9%; top: auto; width: 38%; height: auto; transform: rotate(-5deg); filter: drop-shadow(0 2px 4px rgba(0,0,0,.45)); mix-blend-mode: multiply; }
.found-caption { position: absolute; left: 0; right: 0; bottom: 0; padding: 8px 14px; background: rgba(4,7,10,.85); color: var(--green); font-size: 7px; letter-spacing: .16em; }
.found-copy { padding: clamp(18px, 3.2vw, 40px); overflow-y: auto; background: var(--paper); color: var(--ink-dark); }
.found-copy > .mono { margin: 0; font-size: 8px; letter-spacing: .18em; color: #4b4a40; }
.found-copy h2 { margin: .35em 0 .2em; font-family: var(--stencil); font-weight: 400; font-size: clamp(26px, 3.3vw, 40px); line-height: 1; }
.found-role { margin: 0 0 1.3em; font-family: var(--mono); font-size: 8px; letter-spacing: .15em; color: var(--red); }
.found-copy blockquote { margin: 0 0 1.3em; padding: 0 0 0 14px; border-left: 2px solid var(--red); font-size: clamp(14px, 1.5vw, 17px); line-height: 1.45; max-width: 34ch; }
.found-note { font-family: var(--mono); font-size: 8px; letter-spacing: .12em; color: #3f6f57; margin: 0 0 1.6em; }

/* console */
.console-overlay { z-index: 66; background: rgba(2,4,7,.95); }
.console-sheet {
  position: relative;
  width: min(820px, 100%);
  max-height: 92dvh;
  overflow-y: auto;
  background:
    linear-gradient(180deg, rgba(0,0,0,.18), rgba(0,0,0,0) 12%),
    var(--paper);
  color: var(--ink-dark);
  border: 1px solid #252a25;
  box-shadow: 12px 16px 40px rgba(0,0,0,.8);
  padding: clamp(18px, 3.2vw, 40px);
}
.console-kicker { margin: 0 0 .8em; font-size: 8px; letter-spacing: .2em; color: var(--red); }
.console-sheet h2 { margin: 0 0 1em; font-family: var(--stencil); font-weight: 400; font-size: clamp(28px, 4vw, 44px); line-height: 1; }
.console-locked > .mono { font-size: 8px; letter-spacing: .16em; color: #4b4a40; }
.code-display { margin: .4em 0 .8em; font-size: clamp(30px, 5vw, 46px); letter-spacing: .28em; background: #0c1a15; color: #7fd0a1; border: 2px inset #3c4a40; padding: .2em .3em; text-align: center; text-shadow: 0 0 8px rgba(79,142,107,.6); }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; max-width: 330px; }
.keypad button { font-family: var(--mono); font-size: 17px; padding: 13px 0; background: #c2b9a8; border: 1px solid rgba(16,27,37,.6); color: var(--ink-dark); box-shadow: 2px 2px 0 rgba(16,27,37,.4); transition: transform .08s ease, background .12s ease; }
.keypad button:hover { background: #d3caba; }
.keypad button:active { transform: translate(1px,1px); box-shadow: none; }
.keypad .key-small { font-size: 10px; letter-spacing: .1em; }
#consoleLocked .btn-text { color: var(--ink-dark); margin-top: 1em; }
.console-armed .purge { color: var(--red); font-size: 9px; letter-spacing: .16em; border: 1px solid var(--red); padding: .6em .8em; display: inline-block; }
.memo { border-top: 1px solid rgba(16,27,37,.35); border-bottom: 1px solid rgba(16,27,37,.35); padding: 1em 0; margin: 1em 0 1.4em; }
.memo p { margin: 0 0 .6em; font-size: 13px; line-height: 1.45; max-width: 62ch; }
.memo p.mono { font-size: 8px; letter-spacing: .16em; color: #4b4a40; }
.memo .memo-close { font-family: var(--stencil); font-size: 16px; letter-spacing: .03em; color: var(--red); margin-top: .8em; }
.switches { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.switch { text-align: left; padding: 14px; border: 1px solid var(--ink-dark); background: #c2b9a8; color: var(--ink-dark); font-family: var(--stencil); font-size: 15px; letter-spacing: .04em; line-height: 1.15; box-shadow: 3px 3px 0 rgba(16,27,37,.45); transition: transform .12s ease, box-shadow .12s ease; }
.switch small { display: block; font-family: var(--mono); font-size: 7px; letter-spacing: .1em; margin-top: .7em; line-height: 1.5; color: #4b4a40; }
.switch:hover { transform: translate(-1px,-1px); box-shadow: 5px 5px 0 rgba(16,27,37,.45); }
.switch.warn { border-color: var(--green); }
.switch.seal { border-color: var(--red); }
.switch.seal small { color: var(--red); }
.console-armed .console-msg { color: #4b4a40; }
.console-sheet.shake, .map-console.shake { animation: wrongShake .4s steps(4, end); }

/* ending */
.ending-overlay { z-index: 68; background: rgba(2,4,7,.96); }
.ending-sheet {
  position: relative;
  width: min(780px, 100%);
  max-height: 92dvh;
  overflow-y: auto;
  background: var(--paper);
  color: var(--ink-dark);
  border: 1px solid #262a24;
  box-shadow: 14px 18px 44px rgba(0,0,0,.8);
  padding: clamp(22px, 4.2vw, 50px);
}
.ending-sheet > .mono:first-of-type { margin: 0 0 1.4em; font-size: 8px; letter-spacing: .18em; color: #4b4a40; }
.ending-sheet h2 { margin: 0 0 .6em; font-family: var(--stencil); font-weight: 400; font-size: clamp(30px, 4.4vw, 54px); line-height: .96; max-width: 16ch; }
.ending-prose p { margin: 0 0 .9em; font-size: clamp(14px, 1.45vw, 16px); line-height: 1.55; max-width: 58ch; }
.ending-stamp { position: absolute; right: 4%; top: 4%; width: 30%; height: auto; transform: rotate(6deg); mix-blend-mode: multiply; opacity: .95; }
.ending-stats { display: flex; flex-wrap: wrap; gap: 1.6em; border-top: 1px solid rgba(16,27,37,.4); border-bottom: 1px solid rgba(16,27,37,.4); padding: 1em 0; margin: 1.4em 0; }
.ending-stats div { display: flex; flex-direction: column; gap: 3px; }
.ending-stats dt { font-family: var(--mono); font-size: 7px; letter-spacing: .14em; color: #4b4a40; }
.ending-stats dd { margin: 0; font-family: var(--mono); font-size: 16px; letter-spacing: .06em; }
.ending-buttons { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.ending-sheet .btn-line { color: var(--ink-dark); border-color: rgba(16,27,37,.55); background: transparent; }
.ending-sheet .btn-line:hover { background: var(--ink-dark); color: var(--paper); }
.ending-tag { margin: 1.4em 0 0; font-size: 8px; letter-spacing: .16em; color: var(--red); }

/* confirm, toast, flash */
.confirm-overlay { z-index: 78; background: rgba(2,4,7,.9); }
.confirm-box { width: min(440px, 100%); background: var(--paper); color: var(--ink-dark); padding: clamp(20px, 3.6vw, 34px); border: 1px solid var(--ink-dark); box-shadow: 10px 14px 34px rgba(0,0,0,.7); }
.confirm-box > .mono { margin: 0 0 .8em; font-size: 8px; letter-spacing: .18em; color: var(--red); }
.confirm-box h2 { margin: 0 0 .7em; font-family: var(--stencil); font-weight: 400; font-size: 28px; }
.confirm-box p { margin: 0 0 1.4em; font-size: 14px; line-height: 1.5; }
.confirm-buttons { display: flex; flex-wrap: wrap; gap: 10px; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translate(-50%, 10px);
  z-index: 80;
  background: var(--paper);
  color: var(--ink-dark);
  border: 1px solid var(--ink-dark);
  box-shadow: 4px 4px 0 rgba(0,0,0,.55);
  padding: 9px 14px;
  font-family: var(--mono);
  font-size: 8px;
  letter-spacing: .12em;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease, transform .2s var(--ease);
  max-width: min(560px, 88vw);
  text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.flash { position: fixed; inset: 0; z-index: 90; pointer-events: none; opacity: 0; background: var(--amber); }
.flash.amber { animation: amberFlash .55s steps(3, end) forwards; }
.flash.black { background: #000; animation: blackCut .25s steps(2, end) forwards; }
@keyframes amberFlash { 0% { opacity: 0; } 12% { opacity: .92; } 40% { opacity: .5; } 58% { opacity: .85; } 100% { opacity: 0; } }
@keyframes blackCut { 0% { opacity: 0; } 40% { opacity: 1; } 100% { opacity: 0; } }

.noscript { padding: 20px; font-family: var(--mono); }


.cut-scale {
  position: absolute;
  right: 4.5%;
  bottom: 5.5%;
  z-index: 4;
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 7px;
  letter-spacing: .14em;
  color: #93a3aa;
  pointer-events: none;
  text-shadow: 0 1px 3px #000;
}
.scale-bar { display: flex; width: 116px; height: 7px; }
.scale-bar i { flex: 1; border-left: 1px solid rgba(201,194,180,.8); border-top: 1px solid rgba(201,194,180,.8); }
.scale-bar i:last-child { border-right: 1px solid rgba(201,194,180,.8); }
.cut-section {
  position: absolute;
  right: 4.5%;
  top: 8.5%;
  z-index: 4;
  margin: 0;
  font-size: 7px;
  letter-spacing: .14em;
  color: #8fa0a8;
  pointer-events: none;
  text-shadow: 0 1px 3px #000;
}
@media (max-width: 700px) {
  .cut-scale, .cut-section { display: none; }
}


/* the paper sheets are on the same table, so the same small camera move
   shifts them. Also keeps every open file answering a finger. */
.overlay .dossier-sheet,
.overlay .notebook,
.overlay .console-sheet,
.overlay .found-sheet,
.overlay .ending-sheet,
.overlay .confirm-box {
  transform:
    translate3d(calc(var(--camx, 0px) * -.22), calc(var(--camy, 0px) * -.15), 0)
    rotateY(calc(var(--yaw, 0deg) * .24))
    rotateX(calc(var(--pitch, 0deg) * -.16));
  transform-origin: 50% 50%;
  transition: transform .14s linear;
  will-change: transform;
}
body.dragging .overlay .dossier-sheet,
body.dragging .overlay .notebook,
body.dragging .overlay .console-sheet,
body.dragging .overlay .found-sheet,
body.dragging .overlay .ending-sheet,
body.dragging .overlay .confirm-box { transition: none; }

/* ---------- the camera the person holds ---------- */

.look-hint {
  position: fixed;
  left: 12px;
  bottom: calc(10px + env(safe-area-inset-bottom));
  z-index: 57;
  margin: 0;
  font-family: var(--mono);
  font-size: 8px;
  letter-spacing: .16em;
  color: #adb8bd;
  background: rgba(4,7,10,.60);
  border-left: 2px solid var(--red);
  padding: 6px 9px;
  pointer-events: none;
  text-shadow: 0 1px 3px #000;
  transition: opacity .2s ease;
}
#app[data-phase="ending"] .look-hint,
#app.overlay-open .look-hint { opacity: 0; }
#app[data-phase="map"] .look-hint,
#app[data-phase="descent"] .look-hint {
  top: 92px;
  bottom: auto;
  left: 3.5%;
}
@media (max-width: 700px) {
  #app[data-phase="map"] .look-hint,
  #app[data-phase="descent"] .look-hint { top: 86px; left: 4%; }
}
html.nightmode .look-hint { color: #8a9aa2; }
html.nightmode .world-fx { opacity: .5; }

/* prologue: the last street, alive under the camera */
.prologue-bg { perspective: 1000px; }
.prologue-bg img {
  transform:
    translate3d(calc(var(--camx, 0px) * -.30), calc(var(--camy, 0px) * -.20), 0)
    scale(var(--walkscale, 1.18));
  transform-origin: 50% 45%;
  transition: transform .55s var(--ease);
  will-change: transform;
}
.hands-child {
  transform:
    translateX(-50%)
    translate3d(calc(var(--camx, 0px) * -.60), calc(var(--camy, 0px) * -.34), 0)
    scale(var(--walkscale, 1.18));
  transform-origin: 50% 100%;
  will-change: transform;
}
.hands-child.step {
  transform:
    translateX(-50%)
    translate3d(calc(var(--camx, 0px) * -.60), calc(var(--camy, 0px) * -.34 + 10px), 0)
    scale(calc(var(--walkscale, 1.18) + .018));
}
#screenPrologue .benchmark {
  transform: translateX(-50%) translate3d(calc(var(--camx, 0px) * -.34), calc(var(--camy, 0px) * -.22), 0);
}

/* map: the plate leans under the light */
.map-bg { perspective: 1100px; }
.map-screen.descending .map-bg img {
  transform: scale(2.15) !important;
  transform-origin: 50% 78%;
  filter: brightness(.28) saturate(.7);
  transition: transform .9s cubic-bezier(.5,.02,.7,1), filter .9s ease;
}
.map-screen.descending .map-console,
.map-screen.descending .map-screen-head,
.map-screen.descending .cut-scale,
.map-screen.descending .cut-section { opacity: 0; transition: opacity .35s ease; }
.map-screen.descending .cut-glow { opacity: 1; transform: translate(-50%, -50%) scale(1.8); transition: transform .9s ease, opacity .9s ease; }
.map-screen.descending { pointer-events: none; }

.cut-glow {
  position: absolute;
  left: 50%;
  top: 76%;
  width: 52%;
  height: 22%;
  transform: translate(-50%, -50%) translate3d(calc(var(--camx, 0px) * -.52), calc(var(--camy, 0px) * -.34), 0);
  background: radial-gradient(ellipse at 50% 55%, rgba(79,142,107,.34) 0%, rgba(79,142,107,.10) 42%, rgba(79,142,107,0) 72%);
  filter: blur(16px);
  mix-blend-mode: screen;
  pointer-events: none;
  animation: glowBreath 8s ease-in-out infinite;
  z-index: 0;
}
@keyframes glowBreath { 0%, 100% { opacity: .62; } 50% { opacity: .95; } }
html.nightmode .cut-glow { opacity: .45; }
.map-bg img {
  transform:
    translate3d(calc(var(--camx, 0px) * -.26), calc(var(--camy, 0px) * -.18), 0)
    rotateX(calc(var(--tiltx, 0deg) * .55))
    rotateY(calc(var(--tilty, 0deg) * .55))
    scale(1.06);
  transform-origin: 52% 56%;
  transition: transform .18s linear;
  will-change: transform;
}

/* descent: the cavern is one deep room */
.cavern-wrap { perspective: 1000px; }
.cavern-stack {
  position: absolute;
  inset: 0;
  transform:
    translate3d(calc(var(--camx, 0px) * -.46), calc(var(--camy, 0px) * -.30), 0)
    scale(1.12);
  transform-origin: 50% 50%;
  will-change: transform;
}
.cavern-ledge {
  position: absolute;
  left: -9%;
  bottom: -7%;
  width: 118%;
  height: auto;
  z-index: 2;
  opacity: .55;
  filter: brightness(.36) saturate(.45) blur(1.6px);
  transform: translate3d(calc(var(--camx, 0px) * -.78), calc(var(--camy, 0px) * -.44), 0);
  pointer-events: none;
}
.cavern-fx {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 3;
  pointer-events: none;
}
.torch { z-index: 4; }
.house { z-index: 5; }
.cavern-wrap::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 6;
  pointer-events: none;
  box-shadow: inset 0 0 120px 40px rgba(2,4,7,.72);
}

/* ---------- narrow / landscape ---------- */

@media (max-width: 700px) {
  .hud { max-width: 58vw; gap: 3px; }
  .hud-btn { padding: 6px 6px; font-size: 6px; }
  .board { left: 6%; right: 6%; gap: 2% 3%; }
  .title { font-size: calc(var(--plate-w) * .112); }
  .kicker { font-size: calc(var(--plate-w) * .014); gap: .4em; }
  .kicker span:nth-child(4), .kicker span:nth-child(5), .kicker i { display: none; }
  .start-slip { width: 84%; padding: 10px; }
  .start-line { font-size: 6px; }
  .dossier-sheet { grid-template-columns: 1fr; max-height: 84dvh; overflow-y: auto; gap: 8px; }
  .dossier-left { padding: 6px; }
  .dossier-file { width: min(100%, 270px); }
  .dossier-notes { height: 46dvh; max-height: none; }
  .dossier-notes-inner { padding: 26px 20px 34px; }
  .dossier-letterhead { padding-left: 40px; }
  .dossier-print { display: none; }
  .dossier-world { display: none; }
  .dossier-world-cut { display: block; object-position: 50% 0; }
  .found-sheet { grid-template-columns: 1fr; max-height: 94dvh; overflow-y: auto; }
  .found-photo { border-right: 0; border-bottom: 1px solid rgba(201,194,180,.2); }
  .found-photo img:first-child { max-height: 44dvh; }
  .found-copy { overflow: visible; }
  .map-console { left: 4%; top: auto; bottom: 16px; width: 92%; max-height: 46dvh; }
  .map-screen-head { font-size: 7px; gap: .7em; }
  .maplabel { display: none; }
  .switches { grid-template-columns: 1fr; }
  .prologue-copy { bottom: 40vh; font-size: 15px; left: 16px; }
  .benchmark { bottom: 35vh; }
  .descent-foot { flex-direction: column; align-items: stretch; gap: 6px; }
  .descent-head { flex-direction: column; gap: 2px; }
  .cavern-wrap { width: 120vmax; height: 120vmax; }
  .ruler { left: 5%; right: 5%; font-size: 5px; }
  .radio-caption { font-size: 9px; bottom: 22vh; }
}

@media (min-aspect-ratio: 1/1) {
  .hud { top: 8px; right: 10px; }
  .radio-caption { bottom: 15vh; left: 3vw; }
  .board-radio { bottom: 20vh; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}


/* adult cut card after the memory */
.prologue.cut-card { background: #04070a; }
.prologue.cut-card .prologue-bg,
.prologue.cut-card .hands-child,
.prologue.cut-card .prologue-copy,
.prologue.cut-card .walk-bar,
.prologue.cut-card .benchmark,
.prologue.cut-card .skip,
.prologue.cut-card .radio-caption { display: none !important; }
.prologue.cut-card .prologue-card {
  top: 50%;
  transform: translateY(-50%);
  padding-top: 0;
}
.prologue.cut-card .prologue-card-line { max-width: 28ch; }


/* keep scrolling inside paper and lists working on touch */
.dossier-sheet, .dossier-notes, .notebook, .console-sheet, .ending-sheet,
.found-sheet, .found-copy, .map-screen, .map-console,
.dossier-overlay, .found-overlay, .ending-overlay, .console-overlay { touch-action: pan-y; }


.grain {
  position: fixed;
  inset: -20%;
  z-index: 3;
  pointer-events: none;
  opacity: .055;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='180' height='180' filter='url(%23n)'/%3E%3C/svg%3E");
}
