/* Echo Archive — cold documentary UI: system sans for interface, mono for case
   labels, and documents printed as paper so the story reads like evidence. */

:root {
  --ink: #e9e6df;
  --muted: #9ba1a6;
  --dim: #6b7176;
  --line: rgba(233, 230, 223, 0.16);
  --paper: #e7e2d6;
  --paper-ink: #22201c;
  --accent: #cfd6da;
  --cold: #93c4d4;
  --warn: #c4665a;
  --bg: #0b0c0d;
  --ui: ui-sans-serif, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--ui);
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-font-smoothing: antialiased;
}
/* Phones: nothing should rubber-band or pull-to-refresh, but inner scrollers
   (pause, settings, case papers) keep their own momentum. */
.screen, #papers-body { overscroll-behavior: contain; }

#app { position: fixed; inset: 0; }
#game { position: absolute; inset: 0; width: 100%; height: 100%; display: block; background: #050607; cursor: crosshair; filter: saturate(.93) contrast(1.05); }
.hidden { display: none !important; }

#vignette {
  position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(ellipse at 50% 48%, rgba(0,0,0,0) 40%, rgba(0,0,0,0.5) 78%, rgba(0,0,0,0.9) 100%);
  mix-blend-mode: multiply;
}
#grain {
  position: absolute; inset: 0; pointer-events: none; opacity: 0.05;
  animation: grainShift 7s steps(3) infinite;
  background-image: repeating-linear-gradient(0deg, rgba(255,255,255,.08) 0 1px, transparent 1px 2px),
                    repeating-linear-gradient(90deg, rgba(255,255,255,.05) 0 1px, transparent 1px 3px);
}
#fade { position: absolute; inset: 0; background: #000; opacity: 0; pointer-events: none; transition: opacity .55s ease; }
#fade.on { opacity: 1; }
/* Consumer tape, not clean digital: the picture breathes a little. */
@keyframes grainShift {
  0%, 100% { opacity: .045; }
  38% { opacity: .062; }
  57% { opacity: .032; }
  81% { opacity: .055; }
}

#loading {
  position: absolute; inset: 0; display: grid; place-items: center; background: var(--bg); z-index: 80;
  font-family: var(--mono); font-size: .7rem; letter-spacing: .26em; text-transform: uppercase; color: var(--dim);
}

/* ---------------- HUD ---------------- */
#hud { position: absolute; inset: 0; pointer-events: none; }
#hud-top {
  position: absolute; top: 22px; left: 26px; right: 26px;
  display: flex; justify-content: space-between; gap: 24px;
  font-family: var(--mono); font-size: .64rem; letter-spacing: .16em; text-transform: uppercase; color: var(--muted);
}
#hud-note { max-width: 46ch; color: #e3e6e7; font-size: .72rem; }
#hud-time { color: #a6acaf; text-align: right; white-space: nowrap; }

#rec {
  position: absolute; top: 44px; right: 26px; display: flex; align-items: center; gap: 8px;
  font-family: var(--mono); font-size: .62rem; letter-spacing: .18em; color: #b3b9bc;
}
.rec-dot {
  width: 6px; height: 6px; border-radius: 50%; background: #c4665a;
  box-shadow: 0 0 7px rgba(196,102,90,.7); animation: recBlink 2.4s steps(1) infinite;
}
.rec-word { color: #c4665a; }
#rec-time { color: #6f7579; }
@keyframes recBlink { 0%, 62% { opacity: 1; } 63%, 100% { opacity: .25; } }

#echo-pips { position: absolute; left: 28px; bottom: 30px; display: flex; gap: 7px; }
.pip { width: 26px; height: 3px; background: #2b2f31; border-radius: 2px; transition: background .2s ease, box-shadow .2s ease; }
.pip.full { background: var(--cold); box-shadow: 0 0 12px rgba(147,196,212,.55); }
.pip.spent { background: #23262a; }

/* Prompt and subtitle share one column so they can never land on each other,
   however the text wraps. On touch the whole column is lifted above the
   thumb zones instead of being placed by percentage. */
#hud-stack {
  position: absolute; left: 0; right: 0; bottom: 15%;
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  pointer-events: none;
}
#prompt {
  font-family: var(--mono); font-size: .78rem; letter-spacing: .13em; text-transform: uppercase;
  color: #f4f6f7; background: rgba(9,10,11,.88); border: 1px solid rgba(233,230,223,.32);
  padding: 8px 14px; white-space: nowrap; max-width: 88vw; text-align: center;
}
#prompt b { color: var(--cold); font-weight: 600; margin-right: 6px; }
#subtitle {
  max-width: min(720px, 86vw); text-align: center; font-size: 1.04rem; line-height: 1.55;
  color: #f3efe6; text-shadow: 0 2px 8px #000, 0 0 26px #000, 0 0 3px #000;
}
#caption {
  position: absolute; left: 26px; bottom: 64px; max-width: 40ch;
  font-family: var(--mono); font-size: .68rem; letter-spacing: .13em; text-transform: uppercase;
  color: #c3c8cb; text-shadow: 0 1px 5px #000, 0 0 2px #000;
}
#crosshair {
  position: absolute; left: 50%; top: 50%; width: 3px; height: 3px; margin: -1.5px 0 0 -1.5px;
  border-radius: 50%; background: rgba(230,228,220,.4); box-shadow: 0 0 4px #000;
}
#hud-buttons { position: absolute; right: 24px; bottom: 26px; display: flex; gap: 8px; pointer-events: auto; }
#hud-buttons button {
  font-family: var(--mono); font-size: .68rem; letter-spacing: .15em; text-transform: uppercase;
  background: rgba(10,11,12,.82); border: 1px solid rgba(233,230,223,.28); color: #d2d6d8;
  padding: 7px 11px; cursor: pointer;
}
#hud-buttons button:hover { color: #f0eeea; border-color: rgba(233,230,223,.4); }

/* ---------------- screens ---------------- */
.screen {
  position: absolute; inset: 0; display: flex; align-items: safe center; justify-content: center;
  background: radial-gradient(ellipse at 50% 40%, rgba(9,10,11,.72), rgba(4,5,5,.96));
  z-index: 30; overflow: auto; padding: 32px;
}
#screen-title {
  background:
    linear-gradient(180deg, rgba(4,5,5,.2), rgba(4,5,5,.86) 62%, rgba(4,5,5,.98)),
    radial-gradient(ellipse at 50% 28%, rgba(28,30,32,.42), rgba(4,5,5,.92) 72%);
}
.title-wrap { text-align: center; max-width: 620px; }
.eyebrow {
  font-family: var(--mono); font-size: .62rem; letter-spacing: .3em; text-transform: uppercase;
  color: var(--muted); margin: 0 0 20px;
}
h1 {
  margin: 0; font-weight: 300; font-size: clamp(2.6rem, 7vw, 4.4rem);
  letter-spacing: .22em; text-transform: uppercase; color: #f1efea;
  text-shadow: 0 0 50px rgba(147,196,212,.08), 0 2px 0 #000;
}
h1 span { display: block; font-size: .4em; letter-spacing: .52em; color: var(--muted); margin-top: 6px; }
.subtitle-line { margin: 16px 0 0; letter-spacing: .4em; text-transform: uppercase; font-size: .66rem; color: var(--dim); }
.blurb { margin: 30px auto 0; max-width: 460px; font-size: .96rem; line-height: 1.7; color: #b8bcbe; }
.evidence-line {
  margin: 16px auto 0; max-width: 440px; font-family: var(--mono); font-size: .57rem;
  letter-spacing: .12em; line-height: 1.9; text-transform: uppercase; color: #5c6165;
}

/* An ink stamp on the cover, the way a case folder gets one. */
.case-stamp {
  position: absolute; top: 32px; right: 36px; transform: rotate(-7deg);
  border: 2px solid rgba(196, 102, 90, .5); padding: 10px 16px 8px; text-align: center;
  color: rgba(196, 102, 90, .66); font-family: var(--mono); text-transform: uppercase;
  pointer-events: none; opacity: .9;
}
.case-stamp b {
  display: block; font-size: .58rem; font-weight: 400; letter-spacing: .2em;
  border-bottom: 1px solid rgba(196,102,90,.35); padding-bottom: 5px; margin-bottom: 6px;
}
.case-stamp span { display: block; font-size: .92rem; letter-spacing: .26em; }
.case-stamp i { display: block; font-style: normal; font-size: .5rem; letter-spacing: .16em; margin-top: 6px; color: rgba(196,102,90,.45); }
.menu { margin: 32px auto 0; display: flex; flex-direction: column; gap: 8px; max-width: 320px; }
button { font-family: inherit; }
.menu button, .panel button, .case-actions button {
  background: rgba(12,13,14,.72); border: 1px solid var(--line); color: #c9cccd;
  padding: 13px 19px; font-size: .8rem; letter-spacing: .15em; text-transform: uppercase;
  cursor: pointer; transition: all .16s ease;
}
.menu button:hover, .panel button:hover, .case-actions button:hover {
  border-color: rgba(233,230,223,.45); color: #f4f2ee; background: rgba(26,28,30,.8);
}
.menu button.primary, .panel button.primary, .case-actions button.primary {
  border-color: rgba(207,214,218,.55); color: #f4f2ee;
  background: linear-gradient(180deg, rgba(44,48,50,.72), rgba(16,18,19,.8));
}
.fineprint { margin: 30px auto 0; font-size: .72rem; line-height: 1.75; color: #82888c; letter-spacing: .02em; max-width: 460px; }
.corner-mark {
  position: absolute; bottom: 26px; left: 30px; font-family: var(--mono); font-size: .58rem;
  letter-spacing: .26em; text-transform: uppercase; color: #4d5256;
}

.panel {
  width: min(600px, 94vw); position: relative;
  background: linear-gradient(180deg, rgba(16,17,18,.97), rgba(9,10,11,.98));
  border: 1px solid var(--line); padding: 34px 36px;
  box-shadow: 0 30px 90px rgba(0,0,0,.7);
  max-height: calc(100vh - 48px); overflow-y: auto;
  scrollbar-width: thin; scrollbar-color: #3a4044 transparent;
}
.panel::-webkit-scrollbar { width: 8px; }
.panel::-webkit-scrollbar-thumb { background: #3a4044; }
.panel.wide { width: min(760px, 95vw); }
#screen-settings .panel { width: min(800px, 95vw); }
.panel h2 {
  margin: 0 0 16px; font-weight: 300; letter-spacing: .2em; text-transform: uppercase;
  font-size: 1.2rem; color: #eeecE6;
}
.panel p { line-height: 1.72; color: #c6cacc; font-size: .94rem; }
.panel > button { display: block; width: 100%; margin-top: 10px; }
.panel p.small, .small { font-size: .74rem; color: #7b8085; }
.panel .quote {
  font-family: var(--serif); font-style: italic; color: #9aa0a3;
  border-left: 2px solid var(--line); padding-left: 15px; margin: 20px 0;
  font-size: .92rem;
}

/* settings */
.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 2px 28px; }
.settings-grid > .row { min-width: 0; }
@media (max-width: 640px) {
  .settings-grid { grid-template-columns: 1fr; }
  .settings-grid .row span { flex: 0 0 118px; }
  .settings-grid .row { gap: 10px; }
}
.row { display: flex; align-items: center; gap: 12px; margin: 8px 0; font-size: .8rem; color: #c2c7ca; min-height: 26px; }
.row span { flex: 0 0 158px; }
.row input[type=range] { flex: 1 1 auto; min-width: 0; accent-color: #9aa3a8; height: 18px; }
.row input[type=checkbox] { width: 16px; height: 16px; accent-color: #9aa3a8; }
.row select { background: #121414; color: #cfd3d5; border: 1px solid #33383b; padding: 6px; font-family: inherit; }
.row output { flex: 0 0 46px; text-align: right; color: #a2a8ac; font-family: var(--mono); font-size: .72rem; }
.row.buttons { gap: 10px; margin-top: 22px; }
.row.buttons button { flex: 1; }

.bindings-block { margin-top: 20px; border-top: 1px solid var(--line); padding-top: 14px; }
.bindings-block summary {
  cursor: pointer; font-family: var(--mono); font-size: .64rem; letter-spacing: .2em;
  text-transform: uppercase; color: #a4aaad; padding: 6px 0;
}
#bindings { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 18px; margin: 12px 0; }
.bind-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: .72rem; color: #9aa0a3; }
.bind-key {
  font-family: var(--mono); font-size: .64rem; padding: 4px 8px; min-width: 74px; text-align: center;
  background: #111314; border: 1px solid #2e3336; color: #cfd3d5; cursor: pointer;
}
.bind-key:hover { border-color: #596065; }
.bind-key.listening { border-color: var(--cold); color: var(--cold); }
.small-button {
  font-family: var(--mono); font-size: .62rem; letter-spacing: .14em; text-transform: uppercase;
  background: transparent; border: 1px solid #2e3336; color: #9aa0a3; padding: 6px 10px; cursor: pointer;
}

/* papers: the documents are paper */
.papers-panel { background: linear-gradient(180deg, rgba(14,15,16,.98), rgba(8,9,10,.99)); }
.papers-count { font-family: var(--mono); font-size: .62rem; letter-spacing: .18em; text-transform: uppercase; color: var(--dim); margin: 0 0 16px; }
#papers-body { max-height: 56vh; overflow: auto; margin-bottom: 20px; padding-right: 6px; scrollbar-width: thin; scrollbar-color: #3a4044 transparent; }
#papers-body::-webkit-scrollbar { width: 8px; }
#papers-body::-webkit-scrollbar-thumb { background: #3a4044; }
.paper {
  background: var(--paper); color: var(--paper-ink);
  padding: 22px 24px 40px; margin: 0 0 14px; position: relative;
  box-shadow: 0 14px 30px rgba(0,0,0,.5);
  border-left: 3px solid #b9b09a;
}
/* Every document is a thing that was recovered and filed. */
.paper::after {
  content: 'RECOVERED · VESS ABBEY';
  position: absolute; right: 16px; bottom: 14px; transform: rotate(-3deg);
  font-family: var(--mono); font-size: .46rem; letter-spacing: .22em;
  color: rgba(120, 60, 50, .5); border: 1px solid rgba(120, 60, 50, .28); padding: 3px 7px;
}
.paper:nth-child(3n) { transform: rotate(-0.15deg); }
.paper:nth-child(3n+1) { transform: rotate(0.2deg); }
.paper .doc-kind {
  font-family: var(--mono); font-size: .58rem; letter-spacing: .22em; text-transform: uppercase;
  color: #7a7160; margin: 0 0 8px;
}
.paper h3 { margin: 0 0 10px; font-family: var(--serif); font-weight: 600; font-size: 1.05rem; color: #1c1a16; letter-spacing: .01em; }
.paper p { margin: 0; font-family: var(--serif); font-size: .92rem; line-height: 1.75; color: #2b2823; white-space: pre-wrap; }
.empty { color: #6f7579; font-style: italic; }

/* case card */
.case-card {
  width: min(620px, 94vw); background: linear-gradient(180deg, rgba(17,18,19,.98), rgba(9,10,11,.99));
  border: 1px solid var(--line); padding: 38px 38px 28px; position: relative; text-align: left;
  box-shadow: 0 30px 90px rgba(0,0,0,.8);
}
.case-card::after {
  content: "CASE 04-117"; position: absolute; top: -9px; left: 26px; background: #101112; padding: 0 9px;
  font-family: var(--mono); font-size: .56rem; letter-spacing: .28em; color: #6d7276;
}
.case-line { font-family: var(--mono); font-size: .6rem; letter-spacing: .26em; text-transform: uppercase; color: var(--muted); margin: 0 0 10px; }
.case-line.small { font-size: .56rem; color: var(--dim); margin-bottom: 12px; }
.case-card h2 { margin: 0 0 6px; font-weight: 300; font-size: clamp(1.7rem, 4vw, 2.2rem); letter-spacing: .16em; text-transform: uppercase; color: #f0eeea; }
.case-meta { font-family: var(--mono); font-size: .64rem; letter-spacing: .14em; color: var(--dim); margin: 0 0 22px; text-transform: uppercase; }
.case-body { font-size: 1.02rem; line-height: 1.8; color: #c6c9ca; margin: 0 0 24px; }
.case-note { font-size: .68rem; line-height: 1.7; color: #666b6f; border-top: 1px solid var(--line); padding-top: 14px; margin: 0 0 24px; }
.case-actions { display: flex; flex-direction: column; gap: 8px; }

/* chapter card */
#chapter-card::before {
  content: '● REC'; position: absolute; top: 40px; left: 44px;
  font-family: var(--mono); font-size: .58rem; letter-spacing: .26em; color: rgba(196,102,90,.75);
}
#chapter-card::after {
  content: 'VESS ABBEY · MINIDV · AUDIO ONLY'; position: absolute; bottom: 40px; right: 44px;
  font-family: var(--mono); font-size: .5rem; letter-spacing: .2em; color: #4d5256;
}
#chapter-card {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: #060707; z-index: 20; pointer-events: none; text-align: center; padding: 30px;
  animation: chapterIn .7s ease;
}
#chapter-eyebrow { font-family: var(--mono); font-size: .6rem; letter-spacing: .3em; text-transform: uppercase; color: var(--muted); margin: 0 0 18px; }
#chapter-title { font-size: clamp(1.6rem, 4.2vw, 2.5rem); font-weight: 300; letter-spacing: .24em; text-transform: uppercase; margin: 0 0 20px; color: #f0eeea; }
#chapter-intro { max-width: 540px; font-size: .95rem; line-height: 1.75; color: #a8adaf; margin: 0; }
@keyframes chapterIn { from { opacity: 0; } to { opacity: 1; } }

/* death */
.panel.death { border-color: rgba(120,60,50,.45); }
.panel.death h2 { color: #e3c3ba; margin-bottom: 8px; }
.death-sub { margin-bottom: 18px; }

/* ending */
#end-body p { margin: 0 0 14px; }
#epilogue { margin: 26px 0 0; border-top: 1px solid var(--line); padding-top: 18px; }
#epilogue h3 {
  font-family: var(--mono); font-size: .62rem; letter-spacing: .28em; text-transform: uppercase;
  color: var(--muted); margin: 0 0 12px; font-weight: 400;
}
#epilogue p { margin: 0 0 10px; }
.case-status {
  font-family: var(--mono); font-size: .64rem; letter-spacing: .16em; text-transform: uppercase;
  margin: 20px 0 10px; padding: 10px 12px; border: 1px solid var(--line); color: #a4aaad;
  background: rgba(0,0,0,.3);
}
.case-status.open { border-color: rgba(196,102,90,.55); color: #d9a093; }
.case-status.closed { border-color: rgba(150,160,165,.35); color: #a9b0b3; }
#end-stats { margin-bottom: 20px; }

.credits-title { color: #e6e4de; font-size: 1rem; margin: 0 0 2px; }
.credits-sub { font-family: var(--mono); font-size: .62rem; letter-spacing: .18em; text-transform: uppercase; color: var(--dim); margin: 0 0 18px; }
.credits-people, .credits-built { font-size: .86rem; }

/* ---------------- touch controls ---------------- */
/* Rendered by src/ui/touch.js. Hidden unless the game decides touch is active
   (auto-detected, or forced in Settings); shown only while you are in a
   chamber, so screens keep the full screen to themselves. */
.touch-ui { display: none; }
body.touch .touch-ui { display: block; }
.touch-ui {
  position: absolute; inset: 0; z-index: 12; pointer-events: none;
  opacity: 0; transition: opacity .25s ease;
  -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent;
}
.touch-ui.active { opacity: 1; }
.touch-ui.active .touch-look,
.touch-ui.active .touch-stick,
.touch-ui.active .touch-button { pointer-events: auto; }

.touch-look {
  position: absolute; top: 0; right: 0; width: 58%; height: 100%;
  z-index: 1; touch-action: none; pointer-events: none;
}

.touch-stick {
  position: absolute; left: calc(14px + env(safe-area-inset-left, 0px)); bottom: calc(14px + env(safe-area-inset-bottom, 0px));
  width: 136px; height: 136px;
  z-index: 6; touch-action: none; border-radius: 50%;
  display: grid; place-items: center;
}
.touch-stick-ring {
  position: absolute; inset: 0; border-radius: 50%;
  border: 1px solid rgba(233, 230, 223, .22);
  background: radial-gradient(circle at 50% 50%, rgba(12,13,14,.34), rgba(12,13,14,.12) 62%, rgba(12,13,14,0));
  transition: border-color .15s ease;
}
.touch-stick.engaged .touch-stick-ring { border-color: rgba(147,196,212,.55); }
.touch-stick-knob {
  width: 54px; height: 54px; border-radius: 50%;
  border: 1px solid rgba(233,230,223,.45);
  background: radial-gradient(circle at 50% 42%, rgba(58,64,68,.85), rgba(14,16,17,.8));
  box-shadow: 0 3px 14px rgba(0,0,0,.55);
  transition: border-color .15s ease;
}
.touch-stick.engaged .touch-stick-knob { border-color: rgba(147,196,212,.7); }

/* Four buttons in a 2x2 grid with real separation: sprint and crouch on the
   left column, echo and the contextual Use on the right. Use is hidden until
   something is in reach, so the pad is usually three buttons and never covers
   more of the screen than it needs to. */
.touch-pad {
  position: absolute; right: calc(18px + env(safe-area-inset-right, 0px)); bottom: calc(18px + env(safe-area-inset-bottom, 0px)); z-index: 6;
  display: grid; grid-template-columns: 70px 78px; grid-template-rows: 70px 78px;
  gap: 16px; align-items: center; justify-items: center;
}
.touch-button[data-touch="run"]    { grid-area: 1 / 1; }
.touch-button[data-touch="echo"]   { grid-area: 1 / 2; }
.touch-button[data-touch="use"]    { grid-area: 2 / 1; }
.touch-button[data-touch="crouch"] { grid-area: 2 / 2; }

.touch-button {
  font-family: var(--mono); font-size: .62rem; letter-spacing: .16em; text-transform: uppercase;
  color: #d3d7d9; width: 70px; height: 70px; border-radius: 50%;
  border: 1px solid rgba(233,230,223,.3);
  background: radial-gradient(circle at 50% 40%, rgba(24,27,28,.78), rgba(9,10,11,.8));
  cursor: pointer; touch-action: none; padding: 0;
  transition: border-color .12s ease, color .12s ease, background .12s ease, opacity .16s ease, transform .16s ease;
  pointer-events: none;
}
.touch-button.small { font-size: .56rem; color: #b6bcbf; }
.touch-button.echo {
  width: 78px; height: 78px; font-size: .66rem; color: #e6edef;
  border-color: rgba(147,196,212,.5);
  box-shadow: 0 0 24px rgba(147,196,212,.16) inset;
}
.touch-button.use {
  color: #f2eee4; border-color: rgba(224,206,170,.6);
  background: radial-gradient(circle at 50% 40%, rgba(38,34,28,.82), rgba(11,10,9,.82));
}
.touch-button.hidden {
  opacity: 0; transform: scale(.86); pointer-events: none;
}
.touch-button.active, .touch-button:active {
  color: #f8f6f2; border-color: rgba(207,214,218,.9);
  background: radial-gradient(circle at 50% 40%, rgba(52,58,61,.92), rgba(14,16,17,.92));
}
.touch-button.echo.active { border-color: rgba(147,196,212,.95); }

/* Papers sits above the stick, out of both thumbs' reach. */
.touch-papers {
  position: absolute; left: calc(18px + env(safe-area-inset-left, 0px));
  bottom: calc(172px + env(safe-area-inset-bottom, 0px));
  width: 74px; height: 42px; border-radius: 21px; z-index: 6;
}

/* HUD keeps its layout; on touch only the corners it shares move clear of the
   thumbs. The clock and objective stay where they are. */
body.touch #hud-top {
  top: calc(22px + env(safe-area-inset-top, 0px));
  left: calc(26px + env(safe-area-inset-left, 0px));
  right: calc(26px + env(safe-area-inset-right, 0px));
}
body.touch #echo-pips { left: calc(24px + env(safe-area-inset-left, 0px)); bottom: calc(228px + env(safe-area-inset-bottom, 0px)); }
body.touch #caption { left: 24px; top: 52px; bottom: auto; max-width: 44vw; }
body.touch #hud-stack { bottom: calc(186px + env(safe-area-inset-bottom, 0px)); gap: 9px; }
body.touch #subtitle { max-width: 70vw; }
body.touch #prompt { max-width: 74vw; white-space: normal; }
/* Pause lives in the top-right corner on touch, clear of both thumbs and of
   the action pad, where it stays reachable with either hand. The HUD has to
   sit above the look-capture layer or the button is tapped through to a drag. */
body.touch #hud { z-index: 15; }
/* The recording chrome would sit under the Menu button on touch screens. */
body.touch #rec { display: none; }
body.touch #hud-buttons {
  right: calc(14px + env(safe-area-inset-right, 0px)); top: calc(54px + env(safe-area-inset-top, 0px)); bottom: auto;
}
body.touch #hud-buttons .hud-papers { display: none; }
body.touch #hud-buttons button {
  min-width: 72px; min-height: 44px; padding: 0 12px; font-size: .6rem;
}
body.touch #crosshair { opacity: .55; }

@media (max-height: 520px) {
  .touch-stick { width: 112px; height: 112px; }
  .touch-stick-knob { width: 46px; height: 46px; }
  .touch-pad { grid-template-columns: 66px 54px; grid-template-rows: 54px 66px; gap: 8px; }
  .touch-button { width: 54px; height: 54px; }
  .touch-button.echo { width: 66px; height: 66px; }
  body.touch #echo-pips { bottom: calc(132px + env(safe-area-inset-bottom, 0px)); }
  body.touch #hud-buttons { top: calc(44px + env(safe-area-inset-top, 0px)); }
  body.touch #hud-stack { bottom: calc(154px + env(safe-area-inset-bottom, 0px)); }
  body.touch #subtitle { max-width: 58vw; font-size: .86rem; }
  body.touch #prompt { max-width: 52vw; font-size: .62rem; padding: 6px 10px; }
}

/* Narrow phones: the stick and the pad together are wider than the screen and
   grow into each other. Shrink both and lift the text column to match. */
@media (max-width: 350px) {
  .touch-stick { width: 108px; height: 108px; }
  .touch-stick-knob { width: 44px; height: 44px; }
  .touch-pad { grid-template-columns: 60px 52px; grid-template-rows: 52px 60px; gap: 8px; }
  .touch-button { width: 52px; height: 52px; font-size: .54rem; }
  .touch-button.echo { width: 60px; height: 60px; font-size: .58rem; }
  body.touch #echo-pips { bottom: calc(136px + env(safe-area-inset-bottom, 0px)); }
  body.touch #hud-stack { bottom: calc(148px + env(safe-area-inset-bottom, 0px)); }
}

/* Short windows: the cover is a single sheet and should not scroll. */
@media (max-height: 780px) {
  h1 { font-size: clamp(2rem, 5.4vw, 3.3rem); }
  h1 span { font-size: .36em; letter-spacing: .46em; }
  .eyebrow { margin-bottom: 12px; }
  .blurb { margin-top: 16px; font-size: .9rem; line-height: 1.6; }
  .evidence-line { margin-top: 10px; font-size: .53rem; line-height: 1.7; }
  .menu { margin-top: 20px; gap: 6px; }
  .menu button { padding: 10px 16px; }
  .fineprint { margin-top: 16px; font-size: .63rem; line-height: 1.6; }
  .case-stamp { top: 22px; right: 24px; padding: 8px 13px 6px; }
}

@media (max-width: 720px) {
  .case-stamp { display: none; }
  #rec { display: none; }
  #chapter-card::before { top: 24px; left: 24px; }
  #chapter-card::after { bottom: 24px; right: 24px; }
  #hud-top { flex-direction: column; gap: 4px; }
  #hud-note { max-width: 100%; }
  #hud-time { display: none; }
  #bindings { grid-template-columns: 1fr; }
  .row span { flex: 0 0 128px; }
  .panel, .case-card { padding: 26px 20px; }
  #echo-pips { left: 18px; bottom: 22px; }
  #hud-buttons { right: 14px; bottom: 16px; }
  .paper { padding: 18px 18px; }
}

/* ---------- accessibility: type scale, contrast, reduced fright ---------- */
:root { --ui-scale: 1; }
html { font-size: calc(16px * var(--ui-scale)); }

body.high-contrast #hud-note,
body.high-contrast #hud-time,
body.high-contrast #prompt,
body.high-contrast #subtitle,
body.high-contrast #caption,
body.high-contrast .panel p,
body.high-contrast .panel h2 { color: #fff; text-shadow: 0 1px 3px #000, 0 0 10px #000; }
body.high-contrast #prompt { border-color: rgba(255,255,255,.6); background: rgba(0,0,0,.94); }
body.high-contrast .paper { box-shadow: 0 0 0 1px rgba(0,0,0,.35), 0 14px 30px rgba(0,0,0,.5); }
body.high-contrast #crosshair { width: 5px; height: 5px; margin: -2.5px 0 0 -2.5px; background: #fff; }

/* Reduced fright softens light and grain, never information. */
body.reduced-fright #vignette { opacity: .5; }
body.reduced-fright #grain { animation: none; opacity: .025; }
body.reduced-fright #fade { transition-duration: .25s; }

/* ---------- papers: filed by descent ---------- */
.papers-group { font-family: var(--mono); font-size: .62rem; letter-spacing: .24em; text-transform: uppercase; color: #8d9499; margin: 26px 0 10px; }
.papers-group:first-child { margin-top: 4px; }
.paper .doc-where { font-family: var(--mono); font-size: .54rem; letter-spacing: .14em; text-transform: uppercase; color: #857c6a; margin: -4px 0 12px; }
.paper.is-new { border-left-color: var(--cold); }
.new-tag { display: inline-block; margin-left: 6px; padding: 1px 5px; border: 1px solid rgba(90, 140, 155, .8); color: #2c6675; font-size: .5rem; letter-spacing: .18em; }
.glyph-legend { background: rgba(11,12,13,.55); border: 1px solid var(--line); padding: 16px 20px; margin: 22px 0 6px; }
.glyph-legend h3 { font-family: var(--mono); font-size: .62rem; letter-spacing: .22em; text-transform: uppercase; color: var(--cold); margin: 0 0 12px; }
.glyph-legend ul { list-style: none; margin: 0 0 10px; padding: 0; display: grid; gap: 6px; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.glyph-legend li { font-family: var(--serif); color: #cfd4d6; font-size: .9rem; }
.glyph-legend b { font-family: var(--mono); color: #eef6f8; margin-right: 4px; }
.glyph-legend .doc-where { margin: 6px 0 0; }
#pause-note { min-height: 1.2em; }

/* ---------- posture ---------- */
#posture {
  position: absolute;
  left: 28px;
  bottom: 58px;
  font-family: var(--mono);
  font-size: .58rem;
  letter-spacing: .28em;
  text-transform: uppercase;
  color: #7f9aa3;
  opacity: .8;
  pointer-events: none;
}
#posture.hidden { display: none; }
body.touch #posture { display: none; }

/* ---------------- the handset ----------------
   An object held in front of the face. It sits over the middle of the screen
   on purpose: while you are reading it you cannot see the corridor, and
   nothing about the room has stopped. */
#handset {
  position: absolute; inset: 0; z-index: 25;
  display: grid; place-items: center;
  pointer-events: none;
}
#handset.hidden { display: none; }
.hs-case {
  pointer-events: auto;
  width: min(384px, 80vw);
  max-height: min(78vh, 620px);
  display: flex; flex-direction: column;
  transform: rotate(-1.2deg);
  background: linear-gradient(168deg, #1a1c1d, #101213 62%, #0b0c0d);
  border: 1px solid rgba(233, 230, 223, .18);
  border-radius: 18px;
  padding: 10px 10px 8px;
  box-shadow: 0 26px 60px rgba(0, 0, 0, .72), inset 0 1px 0 rgba(255, 255, 255, .04);
  animation: hs-raise .26s ease-out;
}
@keyframes hs-raise {
  from { opacity: 0; transform: rotate(-1.2deg) translateY(14px); }
  to { opacity: 1; transform: rotate(-1.2deg) translateY(0); }
}
.hs-screen {
  display: flex; flex-direction: column;
  min-height: 0; flex: 1;
  background: #0a0c0d;
  border: 1px solid rgba(233, 230, 223, .09);
  border-radius: 12px;
  overflow: hidden;
}
.hs-status {
  display: flex; justify-content: space-between; align-items: center;
  padding: 6px 10px;
  font-family: var(--mono); font-size: .58rem; letter-spacing: .16em;
  color: var(--dim);
  border-bottom: 1px solid rgba(233, 230, 223, .07);
}
.hs-carrier { color: #8b8577; }
.hs-batt { color: #7d8489; }
.hs-peer {
  padding: 9px 12px 7px;
  font-family: var(--mono); font-size: .66rem; letter-spacing: .22em;
  color: var(--muted);
  border-bottom: 1px solid rgba(233, 230, 223, .06);
  background: rgba(233, 230, 223, .015);
}
.hs-thread {
  flex: 1; min-height: 0; overflow-y: auto;
  padding: 12px 10px 14px;
  display: flex; flex-direction: column; gap: 8px;
  scrollbar-width: thin;
}
.hs-msg { display: flex; }
.hs-msg[data-tone="self"] { justify-content: flex-end; }
.hs-body {
  max-width: 86%;
  padding: 8px 10px;
  font-size: .84rem; line-height: 1.38;
  color: #d8d6cf;
  background: rgba(233, 230, 223, .075);
  border-radius: 10px 10px 10px 3px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.hs-msg[data-tone="self"] .hs-body {
  background: rgba(147, 196, 212, .14);
  color: #cfdfe4;
  border-radius: 10px 10px 3px 10px;
}
.hs-msg[data-tone="unknown"] .hs-body {
  background: rgba(196, 102, 90, .16);
  color: #e2cecb;
  border: 1px solid rgba(196, 102, 90, .28);
  font-family: var(--mono);
  font-size: .76rem;
  letter-spacing: .04em;
}
/* A message that arrived while the ringer was off: marked, so the player can
   see exactly what not being told cost them. */
.hs-msg[data-quiet="1"] .hs-body::after {
  content: ' · unheard';
  font-family: var(--mono); font-size: .56rem; letter-spacing: .12em;
  color: var(--warn); opacity: .75;
}
.hs-msg.settle { animation: hs-settle .4s ease-out; }
@keyframes hs-settle {
  from { opacity: 0; transform: translateY(7px); }
  to { opacity: 1; transform: translateY(0); }
}
body.reduced-fright .hs-msg.settle,
body.reduced-fright .hs-case { animation: none; }
.hs-foot {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 7px 10px 8px;
  border-top: 1px solid rgba(233, 230, 223, .07);
}
.hs-silence {
  font-family: var(--mono); font-size: .58rem; letter-spacing: .14em; text-transform: uppercase;
  background: rgba(233, 230, 223, .06);
  border: 1px solid rgba(233, 230, 223, .2);
  color: #b9bdc0; padding: 5px 8px; cursor: pointer;
}
.hs-silence.off { color: var(--warn); border-color: rgba(196, 102, 90, .45); }
.hs-silence:hover { color: #ece9e3; }
.hs-stamp {
  font-family: var(--mono); font-size: .54rem; letter-spacing: .12em; color: var(--dim);
}
.hs-hint {
  padding: 7px 4px 1px;
  text-align: center;
  font-family: var(--mono); font-size: .55rem; letter-spacing: .14em;
  color: var(--dim);
}
.hs-hint b { color: var(--muted); font-weight: 500; }

/* Unread count, next to the crosshair: the only thing the handset puts on the
   HUD, and the only reason to look down at it. */
#handset-badge {
  position: absolute; left: 50%; top: calc(50% + 34px);
  transform: translateX(-50%);
  z-index: 12; pointer-events: none;
  min-width: 20px; height: 20px; padding: 0 5px;
  display: grid; place-items: center;
  font-family: var(--mono); font-size: .6rem; letter-spacing: .08em;
  color: #0c0e0f; background: #cbb98f;
  border-radius: 10px;
  box-shadow: 0 0 16px rgba(203, 185, 143, .28);
  animation: badge-in .3s ease-out;
}
#handset-badge.hidden { display: none; }
@keyframes badge-in {
  from { opacity: 0; transform: translateX(-50%) scale(.7); }
  to { opacity: 1; transform: translateX(-50%) scale(1); }
}
body.reduced-fright #handset-badge { animation: none; }
body.touch #handset-badge { top: calc(50% + 44px); }
