:root {
  color-scheme: dark;
  --ink: #d5d9d6;
  --muted: #65736f;
  --dim: #283330;
  --void: #06090a;
  --panel: #090d0e;
  --line: #27312f;
  --cyan: #83d6ce;
  --violet: #b98bc8;
  --amber: #e0aa55;
  --green: #8dca7e;
  --red: #d76d72;
  --blue: #6f9fd8;
  --gold: #d8b66f;
  --pink: #d27aa7;
  --signal-noise-opacity: .02;
  --signal-crt-opacity: .08;
  --signal-sweep-opacity: 1;
  --signal-vignette: radial-gradient(ellipse, transparent 66%, rgba(0,0,0,.3) 115%);
  --signal-viewport-background: #020505;
  font-family: "IBM Plex Mono", "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  background: var(--void);
}

html[data-visual-profile="verity"] {
  --void: #090c0e;
  --panel: #0d1113;
  --line: #32383a;
  --cyan: #79b9c2;
  --violet: #a29aac;
  --amber: #c7a66f;
  --green: #91aa88;
  --red: #bc7672;
  --blue: #7898bc;
  --gold: #c6ae7b;
  --pink: #b98298;
  --signal-vignette: radial-gradient(ellipse, transparent 73%, rgba(3,5,6,.22) 118%);
  --signal-viewport-background: #0b0f11;
}

html[data-visual-profile="verity"][data-signal-stage="0"] { --signal-noise-opacity: .014; --signal-crt-opacity: .052; --signal-sweep-opacity: .68; }
html[data-visual-profile="verity"][data-signal-stage="1"] { --signal-noise-opacity: .009; --signal-crt-opacity: .036; --signal-sweep-opacity: .46; }
html[data-visual-profile="verity"][data-signal-stage="2"] { --signal-noise-opacity: .004; --signal-crt-opacity: .019; --signal-sweep-opacity: .22; }
html[data-visual-profile="verity"][data-signal-stage="3"] { --signal-noise-opacity: 0; --signal-crt-opacity: .008; --signal-sweep-opacity: 0; }

* { box-sizing: border-box; }

html { background: var(--void); }

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  color: var(--ink);
  background:
    radial-gradient(circle at 71% 10%, rgba(74, 255, 228, 0.055), transparent 29rem),
    linear-gradient(180deg, #080c0d 0%, #050708 100%);
}

button, input { font: inherit; }
button { color: inherit; }

.noise {
  position: fixed;
  inset: 0;
  z-index: 10;
  pointer-events: none;
  opacity: var(--signal-noise-opacity);
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 160 160' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.91' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.7'/%3E%3C/svg%3E");
}

.shell {
  width: min(1540px, calc(100% - 48px));
  margin: 0 auto;
}

.masthead {
  height: 84px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  border-bottom: 1px solid var(--line);
  font-size: 10px;
  letter-spacing: 0.14em;
}

.wordmark {
  display: flex;
  align-items: center;
  gap: 14px;
  color: var(--ink);
  text-decoration: none;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.wordmark-mark {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border: 1px solid var(--cyan);
  color: var(--cyan);
  box-shadow: inset 0 0 18px rgba(104, 247, 231, 0.08);
}

.network-state { color: var(--muted); }
.network-state i, .terminal-latency i {
  display: inline-block;
  width: 5px;
  height: 5px;
  margin-right: 7px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 10px var(--green);
}
.header-meta { justify-self: end; color: var(--muted); line-height: 1.7; text-align: right; }
.header-meta span { color: var(--ink); }

.hero {
  min-height: 220px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 42px;
  padding: 38px 0 34px;
}

.eyebrow, .panel-kicker {
  margin: 0 0 14px;
  color: var(--cyan);
  font-size: 9px;
  letter-spacing: 0.24em;
}

.hero h1 {
  margin: 0;
  color: #eef7f3;
  font-family: Arial, Helvetica, sans-serif;
  font-size: clamp(44px, 6vw, 88px);
  font-weight: 800;
  line-height: 0.84;
  letter-spacing: -0.065em;
}

.hero h1 em { color: transparent; font-style: normal; -webkit-text-stroke: 1px var(--cyan); text-shadow: 0 0 30px rgba(104, 247, 231, 0.1); }
.lede { max-width: 640px; margin: 28px 0 0; color: #8b9994; font-family: Arial, Helvetica, sans-serif; font-size: 15px; line-height: 1.6; }
.coordinates { min-width: 270px; border-top: 1px solid var(--line); }
.coordinates div { display: flex; justify-content: space-between; gap: 32px; padding: 12px 0; border-bottom: 1px solid var(--line); font-size: 10px; }
.coordinates span { color: var(--muted); }
.coordinates strong { color: var(--amber); font-weight: 500; }

.game-layout { display: grid; grid-template-columns: minmax(0, 1fr) 316px; gap: 18px; }
.terminal-column { min-width: 0; }
.terminal-frame { border: 1px solid #36413f; background: var(--signal-viewport-background); box-shadow: 0 22px 70px rgba(0, 0, 0, 0.48), inset 0 0 70px rgba(61, 211, 190, 0.025); }
.terminal-frame:focus-within { border-color: #526d67; }
.terminal-bar { height: 39px; display: grid; grid-template-columns: 1fr auto auto auto 1fr; gap: 18px; align-items: center; padding: 0 13px; border-bottom: 1px solid #303a38; background: #0e1314; color: #71807b; font-size: 9px; letter-spacing: 0.09em; }
.terminal-latency { justify-self: center; }
.terminal-seed { justify-self: end; }
.terminal-seed b { color: var(--amber); font-weight: 500; }

.viewport { position: relative; min-height: 650px; display: grid; place-items: stretch; overflow: hidden; outline: none; cursor: crosshair; container-type: inline-size; background: var(--signal-viewport-background); }
.viewport::before { content: ""; position: absolute; inset: 0; z-index: 2; pointer-events: none; background: var(--signal-vignette); }
.viewport::after { content: ""; position: absolute; inset: 0; z-index: 2; pointer-events: none; opacity: var(--signal-crt-opacity); background: repeating-linear-gradient(0deg, rgba(255,255,255,.05) 0, rgba(255,255,255,.05) 1px, transparent 1px, transparent 4px); }

#screen { display: block; width: 100%; height: 100%; min-height: 650px; }
.visually-hidden { position: absolute !important; width: 1px !important; height: 1px !important; padding: 0 !important; margin: -1px !important; overflow: hidden !important; clip: rect(0, 0, 0, 0) !important; white-space: nowrap !important; border: 0 !important; }
.audio-toggle { border: 0; padding: 4px 7px; background: transparent; color: var(--green); font-size: 8px; letter-spacing: .1em; cursor: pointer; }
.audio-toggle[aria-pressed="false"] { color: var(--muted); }
.audio-toggle:hover, .audio-toggle:focus-visible { color: var(--cyan); outline: 1px solid var(--cyan); outline-offset: 2px; }
.expand-toggle { color: var(--amber); }

.terminal-frame:fullscreen { width: 100vw; height: 100dvh; border: 0; background: #020505; }
.terminal-frame:fullscreen .viewport, .terminal-frame:fullscreen #screen { min-height: 0; height: calc(100dvh - 39px); }

.citynet-dialog {
  width: min(900px, calc(100vw - 32px));
  height: min(650px, calc(100dvh - 32px));
  max-width: none;
  max-height: none;
  margin: auto;
  padding: 0;
  overflow: hidden;
  border: 1px solid #4b8b7d;
  background: #030807;
  color: #b9d2ca;
  box-shadow: 0 0 0 1px #07110f, 0 0 80px rgba(70, 231, 204, .16), 0 34px 90px #000;
}
.citynet-dialog::backdrop { background: rgba(0, 4, 3, .84); backdrop-filter: blur(3px); }
.citynet-dialog[open] { animation: citynet-connect .16s steps(2, end); }
.citynet-dialog:not([open]) { display: none; }
@keyframes citynet-connect {
  0% { opacity: 0; transform: scaleY(.03) scaleX(.78); filter: brightness(2); }
  45% { opacity: 1; transform: scaleY(.03) scaleX(1); }
  100% { transform: scale(1); filter: brightness(1); }
}
.citynet-shell {
  position: relative;
  height: 100%;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto auto auto;
  isolation: isolate;
  background:
    linear-gradient(rgba(16, 65, 55, .055) 1px, transparent 1px),
    linear-gradient(90deg, rgba(16, 65, 55, .035) 1px, transparent 1px),
    radial-gradient(circle at 82% 18%, rgba(90, 255, 218, .08), transparent 19rem),
    #030807;
  background-size: 100% 22px, 22px 100%, auto, auto;
}
.citynet-shell::after {
  content: "";
  position: absolute;
  z-index: -1;
  inset: 0;
  pointer-events: none;
  opacity: .13;
  background: repeating-linear-gradient(0deg, transparent 0 3px, rgba(137, 255, 224, .12) 3px 4px);
}
.citynet-header { display: flex; align-items: center; justify-content: space-between; gap: 24px; padding: 20px 24px 17px; border-bottom: 1px solid #245146; background: rgba(4, 15, 12, .92); }
.citynet-kicker { color: #579b8b; font-size: 8px; letter-spacing: .2em; }
.citynet-header h2 { margin: 5px 0 0; color: #dbfff4; font-size: 19px; font-weight: 600; letter-spacing: .06em; text-shadow: 0 0 16px rgba(109, 255, 221, .3); }
.citynet-link-state { display: flex; align-items: center; gap: 9px; color: var(--green); font-size: 8px; letter-spacing: .13em; text-align: right; }
.citynet-link-state i { width: 6px; height: 6px; border-radius: 50%; background: var(--green); box-shadow: 0 0 12px var(--green); }
.citynet-status { display: flex; gap: 28px; padding: 8px 24px; border-bottom: 1px solid #18372f; color: #426a61; background: rgba(6, 20, 16, .8); font-size: 8px; letter-spacing: .12em; }
.citynet-status b { color: var(--amber); font-weight: 500; }
.citynet-workspace { min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) 236px; overflow: hidden; }
.citynet-output { min-height: 0; overflow: auto; padding: 20px 24px 28px; scrollbar-color: #356a5d #07110e; scrollbar-width: thin; font-size: 11px; line-height: 1.65; }
.citynet-line { min-height: 1.65em; white-space: pre-wrap; overflow-wrap: anywhere; }
.citynet-line::before { content: "  "; }
.citynet-line[data-tone="system"] { color: #65b3a1; }
.citynet-line[data-tone="system"]::before { content: "> "; color: var(--cyan); }
.citynet-line[data-tone="command"] { color: #e5fff8; }
.citynet-line[data-tone="command"]::before { content: "OPER@NULL-SECTOR:> "; color: #4b8175; }
.citynet-line[data-tone="ok"] { color: var(--green); }
.citynet-line[data-tone="ok"]::before { content: "[OK] "; }
.citynet-line[data-tone="error"] { color: var(--red); }
.citynet-line[data-tone="error"]::before { content: "[ERR] "; }
.citynet-line[data-tone="locked"] { color: var(--amber); }
.citynet-line[data-tone="locked"]::before { content: "[LOCKED] "; }
.citynet-line[data-tone="story"] { color: #b8c7c2; }
.citynet-line[data-tone="signal"] { color: var(--cyan); text-shadow: 0 0 10px rgba(131, 214, 206, .23); }
.citynet-case-file { min-width: 0; overflow: auto; padding: 17px 16px; border-left: 1px solid #245146; background: rgba(4, 14, 12, .94); scrollbar-color: #356a5d #07110e; scrollbar-width: thin; }
.citynet-case-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; padding-bottom: 12px; border-bottom: 1px solid #23483f; }
.citynet-case-header span, .citynet-case-lead h4, .citynet-suspect-file h4 { color: #4f8a7c; font-size: 7px; font-weight: 500; letter-spacing: .16em; }
.citynet-case-header h3 { margin: 5px 0 0; color: #d9f8ef; font-size: 11px; line-height: 1.3; letter-spacing: .04em; }
.citynet-case-header > b { flex: 0 0 auto; padding: 4px 6px; border: 1px solid #876e3e; color: var(--amber); font-size: 7px; font-weight: 500; letter-spacing: .1em; }
.citynet-case-summary { margin: 0; }
.citynet-case-summary div { display: grid; grid-template-columns: 1fr auto; gap: 9px; padding: 9px 0; border-bottom: 1px solid #18342d; font-size: 7px; letter-spacing: .08em; }
.citynet-case-summary dt { color: #496b63; }
.citynet-case-summary dd { margin: 0; color: #abc8bf; text-align: right; }
.citynet-case-summary dd[data-state="closed"] { color: var(--green); text-shadow: 0 0 8px rgba(141, 202, 126, .32); }
.citynet-case-summary dd[data-state="containment"] { color: var(--amber); }
.citynet-case-lead { padding: 13px 0 14px; border-bottom: 1px solid #23483f; }
.citynet-case-lead h4, .citynet-suspect-file h4 { margin: 0 0 8px; }
.citynet-case-lead p { margin: 0; color: #c9ded8; font-size: 9px; line-height: 1.55; }
.citynet-suspect-file { padding-top: 13px; }
.citynet-suspect-file ul { display: grid; gap: 5px; margin: 0; padding: 0; list-style: none; }
.citynet-suspect { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 7px; padding: 7px 8px; border-left: 2px solid #52615d; background: #07110f; font-size: 7px; letter-spacing: .07em; }
.citynet-suspect span { overflow: hidden; color: #b3c5c0; text-overflow: ellipsis; white-space: nowrap; }
.citynet-suspect b { color: #667973; font-weight: 500; }
.citynet-suspect[data-status="cleared"] { border-left-color: var(--green); }
.citynet-suspect[data-status="cleared"] b { color: var(--green); }
.citynet-suspect[data-status="suspect"] { border-left-color: var(--amber); }
.citynet-suspect[data-status="suspect"] b { color: var(--amber); }
.citynet-suspect[data-status="hostile"] { border-left-color: var(--red); }
.citynet-suspect[data-status="hostile"] b { color: var(--red); }
.citynet-actions { display: flex; gap: 6px; overflow-x: auto; padding: 10px 24px; border-top: 1px solid #18372f; background: rgba(3, 11, 9, .94); }
.citynet-actions:empty { display: none; }
.citynet-actions button, .citynet-footer button, .citynet-prompt button {
  min-height: 38px;
  padding: 8px 12px;
  border: 1px solid #315f54;
  background: #07130f;
  color: #8ac7b8;
  font-size: 8px;
  letter-spacing: .1em;
  white-space: nowrap;
  cursor: pointer;
}
.citynet-actions button:hover, .citynet-actions button:focus-visible, .citynet-footer button:hover, .citynet-footer button:focus-visible, .citynet-prompt button:hover, .citynet-prompt button:focus-visible { border-color: var(--cyan); color: #e5fff8; outline: 1px solid var(--cyan); outline-offset: 2px; }
.citynet-form { padding: 12px 24px 14px; border-top: 1px solid #234d43; background: #06100d; }
.citynet-form label { display: block; margin-bottom: 7px; color: #4e7e72; font-size: 8px; letter-spacing: .17em; }
.citynet-prompt { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 10px; }
.citynet-prompt > span { color: var(--cyan); font-size: 9px; white-space: nowrap; }
.citynet-prompt input { min-width: 0; height: 42px; padding: 0 11px; border: 1px solid #315f54; outline: 0; background: #020706; color: #eafff9; caret-color: var(--cyan); font-size: 12px; text-transform: uppercase; box-shadow: inset 0 0 24px rgba(65, 221, 188, .025); }
.citynet-prompt input:focus { border-color: var(--cyan); box-shadow: inset 0 0 24px rgba(65, 221, 188, .055), 0 0 12px rgba(65, 221, 188, .08); }
.citynet-prompt button { height: 42px; border-color: var(--cyan); background: var(--cyan); color: #03110d; font-weight: 700; }
.citynet-footer { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 8px 24px; border-top: 1px solid #18372f; background: #030a08; color: #426a61; font-size: 8px; letter-spacing: .12em; }
.citynet-footer button { min-height: 32px; border-color: transparent; background: transparent; color: #719a90; }

.lift-dialog {
  width: min(620px, calc(100vw - 32px));
  height: min(680px, calc(100dvh - 32px));
  max-width: none;
  max-height: none;
  margin: auto;
  padding: 0;
  overflow: hidden;
  border: 1px solid #46796f;
  background: #050a09;
  color: #cfddd8;
  box-shadow: 0 0 0 1px #0b1512, 0 0 72px rgba(131, 214, 206, .14), 0 34px 90px #000;
}
.lift-dialog::backdrop { background: rgba(2, 5, 4, .88); backdrop-filter: blur(4px); }
.lift-dialog[open] { animation: lift-arrive .16s steps(3, end); }
.lift-dialog:not([open]) { display: none; }
@keyframes lift-arrive {
  0% { opacity: 0; transform: translateY(12px) scaleY(.88); filter: brightness(1.7); }
  55% { opacity: 1; transform: translateY(-2px) scaleY(1.01); }
  100% { transform: translateY(0) scaleY(1); filter: brightness(1); }
}
.lift-shell {
  height: 100%;
  min-height: 0;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  background:
    linear-gradient(rgba(73, 128, 116, .045) 1px, transparent 1px),
    radial-gradient(circle at 82% 14%, rgba(131, 214, 206, .08), transparent 20rem),
    #050a09;
  background-size: 100% 23px, auto, auto;
}
.lift-header { display: flex; align-items: center; justify-content: space-between; gap: 22px; padding: 19px 22px 16px; border-bottom: 1px solid #31574e; background: rgba(7, 16, 13, .95); }
.lift-kicker { color: #5f9589; font-size: 8px; letter-spacing: .18em; }
.lift-header h2 { margin: 5px 0 0; color: #e4fff7; font-size: 18px; font-weight: 600; letter-spacing: .055em; }
.lift-link-state { display: flex; flex: 0 0 auto; align-items: center; gap: 8px; color: var(--green); font-size: 8px; letter-spacing: .13em; }
.lift-link-state i { width: 6px; height: 6px; border-radius: 50%; background: var(--green); box-shadow: 0 0 12px rgba(141, 202, 126, .7); }
.lift-status { display: flex; justify-content: space-between; gap: 20px; padding: 9px 22px; border-bottom: 1px solid #213d36; background: rgba(5, 15, 12, .9); color: #51736b; font-size: 8px; letter-spacing: .12em; }
.lift-status b { color: var(--amber); font-weight: 500; }
.lift-floors {
  min-height: 0;
  display: grid;
  align-content: start;
  gap: 7px;
  margin: 0;
  padding: 16px 22px 24px;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-color: #37665b #08120f;
  scrollbar-width: thin;
  list-style: none;
}
.lift-floor-button {
  width: 100%;
  min-height: 52px;
  display: grid;
  grid-template-columns: 36px 68px minmax(0, 1fr) auto 56px;
  align-items: center;
  gap: 11px;
  padding: 0 13px 0 0;
  border: 1px solid #2f4b45;
  background: rgba(8, 18, 15, .94);
  color: #adc5bd;
  text-align: left;
  cursor: pointer;
}
.lift-floor-button kbd { align-self: stretch; display: grid; place-items: center; border-right: 1px solid #2f4b45; color: var(--cyan); font: inherit; font-size: 9px; }
.lift-floor-label { color: #e0eee9; font-size: 11px; letter-spacing: .08em; }
.lift-floor-use { min-width: 0; overflow: hidden; color: #789088; font-size: 8px; letter-spacing: .11em; text-overflow: ellipsis; white-space: nowrap; }
.lift-floor-altitude { color: #4f6e66; font-size: 8px; letter-spacing: .08em; white-space: nowrap; }
.lift-floor-state { color: var(--green); font-size: 7px; letter-spacing: .13em; text-align: right; }
.lift-floor-button:hover, .lift-floor-button:focus-visible { border-color: var(--cyan); background: #0d211c; color: #eafff8; outline: 1px solid var(--cyan); outline-offset: 2px; }
.lift-floor-button[aria-current="location"] { border-color: #897044; background: #17170f; }
.lift-floor-button[aria-current="location"] .lift-floor-label, .lift-floor-button[aria-current="location"] .lift-floor-altitude { color: var(--amber); }
.lift-footer { min-height: 58px; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 8px 22px; border-top: 1px solid #29473f; background: #060d0b; }
.lift-footer p { margin: 0; color: #5d776f; font-size: 7px; letter-spacing: .1em; }
.lift-footer p kbd { color: #9bb2aa; font: inherit; }
.lift-footer button { min-height: 44px; padding: 9px 12px; border: 1px solid #3d5b54; background: #0b1512; color: #9db5ad; font-size: 8px; letter-spacing: .09em; cursor: pointer; }
.lift-footer button:hover, .lift-footer button:focus-visible { border-color: var(--cyan); color: #e8fff8; outline: 1px solid var(--cyan); outline-offset: 2px; }

.witness-dialog {
  width: min(980px, calc(100vw - 32px));
  height: min(620px, calc(100dvh - 32px));
  max-width: none;
  max-height: none;
  margin: auto;
  padding: 0;
  overflow: hidden;
  border: 1px solid #7e6b43;
  background: #070806;
  color: #d8d6ca;
  box-shadow: 0 0 0 1px #151207, 0 0 82px rgba(224, 170, 85, .13), 0 34px 90px #000;
}
.witness-dialog::backdrop { background: rgba(2, 3, 3, .88); backdrop-filter: blur(4px); }
.witness-dialog[open] { animation: witness-connect .18s steps(3, end); }
.witness-dialog:not([open]) { display: none; }
@keyframes witness-connect {
  0% { opacity: 0; transform: translateY(8px); filter: brightness(1.8); }
  45% { opacity: 1; transform: translateY(0); filter: brightness(1.2); }
  100% { filter: brightness(1); }
}
.witness-shell {
  height: 100%;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  background:
    linear-gradient(rgba(130, 108, 61, .045) 1px, transparent 1px),
    radial-gradient(circle at 18% 20%, rgba(224, 170, 85, .07), transparent 22rem),
    #070806;
  background-size: 100% 24px, auto, auto;
}
.witness-header { display: flex; align-items: center; justify-content: space-between; gap: 24px; padding: 19px 22px 16px; border-bottom: 1px solid #594a2e; background: rgba(13, 13, 9, .94); }
.witness-kicker { color: #927d50; font-size: 8px; letter-spacing: .18em; }
.witness-header h2 { margin: 5px 0 0; color: #fff5d8; font-size: 17px; font-weight: 600; letter-spacing: .055em; }
.witness-link-state { display: flex; flex: 0 0 auto; align-items: center; gap: 8px; color: var(--red); font-size: 8px; letter-spacing: .13em; }
.witness-link-state i { width: 6px; height: 6px; border-radius: 50%; background: var(--red); box-shadow: 0 0 12px rgba(215, 109, 114, .75); }
.witness-layout { min-height: 0; display: grid; grid-template-columns: minmax(220px, .72fr) minmax(0, 1.55fr); }
.witness-dossier { min-width: 0; overflow: auto; padding: 24px 22px; border-right: 1px solid #594a2e; background: rgba(13, 13, 9, .86); scrollbar-color: #6d5a36 #0d0d09; scrollbar-width: thin; }
.witness-portrait { margin: 0 0 22px; padding: 21px 8px; overflow: hidden; border: 1px solid #5a4b30; background: #090a07; color: var(--amber); font-size: clamp(9px, 1.1vw, 12px); line-height: 1.22; text-align: center; text-shadow: 0 0 12px rgba(224, 170, 85, .18); }
.witness-identity > span { color: #716344; font-size: 7px; letter-spacing: .16em; }
.witness-identity h3 { margin: 6px 0 4px; color: #fff1ce; font-size: 16px; line-height: 1.2; letter-spacing: .04em; }
.witness-identity p { margin: 0; color: #927d50; font-size: 8px; letter-spacing: .11em; }
.witness-metadata { margin: 20px 0 0; }
.witness-metadata div { padding: 9px 0; border-top: 1px solid #332d1e; }
.witness-metadata dt { margin-bottom: 5px; color: #6f6348; font-size: 7px; letter-spacing: .15em; }
.witness-metadata dd { margin: 0; overflow-wrap: anywhere; color: #d8c99f; font-size: 9px; line-height: 1.45; }
.witness-conversation { min-width: 0; min-height: 0; display: grid; grid-template-rows: auto minmax(0, 1fr) auto auto; }
.witness-channel-label { display: flex; justify-content: space-between; gap: 16px; padding: 13px 20px; border-bottom: 1px solid #3f3624; color: #766747; background: rgba(9, 10, 7, .88); font-size: 7px; letter-spacing: .14em; }
.witness-channel-label b { color: var(--green); font-weight: 500; }
.witness-dialogue { min-height: 0; margin: 0; overflow: auto; padding: 34px 36px; border: 0; color: #e4e1d5; scrollbar-color: #6d5a36 #0d0d09; scrollbar-width: thin; font-family: Arial, Helvetica, sans-serif; font-size: clamp(18px, 2.25vw, 28px); line-height: 1.45; letter-spacing: -.015em; }
.witness-dialogue::before { content: "“"; margin-left: -.55em; color: var(--amber); }
.witness-dialogue::after { content: "”"; color: var(--amber); }
.witness-dialogue:focus { outline: 0; }
.witness-choice-panel { padding: 0 20px 17px; }
.witness-choices { display: grid; gap: 7px; }
.witness-choice { min-height: 42px; display: grid; grid-template-columns: 31px minmax(0, 1fr); align-items: center; padding: 0 12px 0 0; border: 1px solid #4b412b; background: #0d0e0a; color: #c5b78f; font-size: 9px; letter-spacing: .09em; text-align: left; cursor: pointer; }
.witness-choice[hidden] { display: none; }
.witness-choice kbd { align-self: stretch; display: grid; place-items: center; border-right: 1px solid #4b412b; color: var(--amber); font: inherit; }
.witness-choice span { padding-left: 11px; }
.witness-choice:hover, .witness-choice:focus-visible { border-color: var(--amber); background: #17150d; color: #fff2d2; outline: 1px solid var(--amber); outline-offset: 2px; }
.witness-footer { min-height: 57px; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 8px 20px; border-top: 1px solid #3f3624; background: #0a0a07; }
.witness-footer p { margin: 0; color: #75694e; font-size: 7px; letter-spacing: .09em; }
.witness-footer p kbd { color: #b9aa80; font: inherit; }
.witness-footer > div { display: flex; gap: 7px; }
.witness-footer button { min-height: 38px; padding: 8px 11px; border: 1px solid #55482e; background: #111008; color: #b9aa80; font-size: 8px; letter-spacing: .09em; cursor: pointer; }
.witness-footer button:first-child { border-color: var(--amber); color: #f1d99b; }
.witness-footer button:hover, .witness-footer button:focus-visible { border-color: var(--amber); color: #fff4d8; outline: 1px solid var(--amber); outline-offset: 2px; }
.viewport:has(.witness-dialog[open]) .context-reticle, .viewport:has(.witness-dialog[open]) .field-telemetry, .viewport:has(.witness-dialog[open]) .scanline,
.viewport:has(.lift-dialog[open]) .context-reticle, .viewport:has(.lift-dialog[open]) .field-telemetry, .viewport:has(.lift-dialog[open]) .scanline { opacity: 0; }

.context-reticle { position: absolute; z-index: 4; left: 50%; top: 50%; display: grid; min-width: 190px; justify-items: center; gap: 7px; pointer-events: none; transform: translate(-50%, -50%); color: rgba(223, 239, 232, .9); font-size: 8px; letter-spacing: .12em; text-align: center; text-shadow: 0 0 8px #000, 0 0 8px #000; transition: opacity .18s ease; }
.context-reticle i { width: 13px; height: 13px; border: 1px solid rgba(173, 211, 199, .52); border-radius: 50%; box-shadow: 0 0 10px rgba(131, 214, 206, .18); }
.context-reticle span { padding: 3px 6px; background: rgba(2, 5, 5, .56); }
.context-reticle b { min-height: 10px; color: var(--amber); font-weight: 500; }
.viewport:has(.focus-card:not(.hidden)) .context-reticle { opacity: 0; }
.viewport.citynet-open .context-reticle, .viewport.citynet-open .field-telemetry, .viewport.citynet-open .scanline,
.viewport.lift-open .context-reticle, .viewport.lift-open .field-telemetry, .viewport.lift-open .scanline { opacity: 0; }

.field-telemetry {
  position: absolute;
  z-index: 4;
  top: 44px;
  right: 12px;
  display: grid;
  min-width: 156px;
  gap: 2px;
  pointer-events: none;
  color: #899892;
  font-size: 7px;
  letter-spacing: .11em;
  text-shadow: 0 1px 6px #000;
  transition: opacity .18s ease;
}
.field-telemetry span { display: grid; grid-template-columns: 39px 1fr; gap: 8px; padding: 4px 6px; border-left: 1px solid #35433f; background: rgba(2, 7, 6, .72); }
.field-telemetry b { color: #52635d; font-weight: 500; }
.field-telemetry output { overflow: hidden; color: #afbeb8; text-align: right; text-overflow: ellipsis; white-space: nowrap; }
.field-telemetry span[data-state="ready"] { border-left-color: var(--cyan); }
.field-telemetry span[data-state="ready"] output { color: var(--cyan); }
.field-telemetry span[data-state="active"] { border-left-color: var(--green); }
.field-telemetry span[data-state="active"] output { color: var(--green); text-shadow: 0 0 8px rgba(141, 202, 126, .2); }
.field-telemetry span[data-state="warning"] { border-left-color: var(--amber); }
.field-telemetry span[data-state="warning"] output { color: var(--amber); }
.field-telemetry span[data-state="danger"] { border-left-color: var(--red); }
.field-telemetry span[data-state="danger"] output { color: var(--red); }
.viewport:has(.focus-card:not(.hidden)) .field-telemetry { opacity: 0; }

.story-notice {
  position: absolute;
  z-index: 5;
  left: 50%;
  bottom: 54px;
  width: min(620px, calc(100% - 32px));
  padding: 13px 16px;
  border: 1px solid #4b8b7d;
  pointer-events: none;
  transform: translateX(-50%);
  background: rgba(3, 13, 11, .94);
  color: #bce4d9;
  box-shadow: 0 12px 42px #000, inset 3px 0 0 var(--cyan);
  font-size: 10px;
  line-height: 1.55;
  letter-spacing: .05em;
}
.story-notice[hidden] { display: none; }
.story-notice strong { display: block; margin-bottom: 5px; color: var(--cyan); font-size: 8px; letter-spacing: .16em; }
.story-notice p { margin: 0; }
.story-notice[data-tone="item"] { border-color: #90733e; box-shadow: 0 12px 42px #000, inset 3px 0 0 var(--amber); }
.story-notice[data-tone="item"] strong, .story-notice[data-tone="activity"] strong { color: var(--amber); }
.story-notice[data-tone="locked"] { border-color: #8e5558; box-shadow: 0 12px 42px #000, inset 3px 0 0 var(--red); }
.story-notice[data-tone="locked"] strong { color: var(--red); }
.story-notice[data-tone="objective"] { border-color: #5f8858; box-shadow: 0 12px 42px #000, inset 3px 0 0 var(--green); }
.story-notice[data-tone="objective"] strong { color: var(--green); }

.c-sky { color: #121817; text-shadow: none; }
.c-rain { color: #65847f; }
.c-floor { color: #616b67; text-shadow: none; }
.c-floor-mid { color: #45534e; text-shadow: none; }
.c-cyan { color: var(--cyan); }
.c-violet { color: var(--violet); }
.c-amber { color: var(--amber); }
.c-steel { color: #a5aca9; }
.c-concrete { color: #a9aca8; text-shadow: 0 0 4px rgba(220, 225, 222, .18); }
.c-white { color: #e8f4ef; }
.c-green { color: var(--green); }
.c-red { color: var(--red); }
.c-floor-far { color: #27332f; text-shadow: none; }
.c-cyan-far { color: #347e76; text-shadow: none; }
.c-violet-far { color: #75477e; text-shadow: none; }
.c-steel-far { color: #566762; text-shadow: none; }
.c-concrete-far { color: #626b67; text-shadow: none; }
.c-white-far { color: #71817c; text-shadow: none; }
.c-horizon { color: #3e5b55; text-shadow: none; }
.c-outline { color: #eef2ef; text-shadow: 0 0 5px rgba(238, 242, 239, .25); }
.c-outline-far { color: #77847f; text-shadow: none; }
.c-blue { color: var(--blue); }
.c-blue-far { color: #385578; }
.c-gold { color: var(--gold); }
.c-gold-far { color: #6f5d3c; }
.c-pink { color: var(--pink); }
.c-pink-far { color: #71405a; }
.c-wet-cyan { color: #477c78; }
.c-wet-violet { color: #624d70; }
.c-wet-amber { color: #75613d; }
.c-shadow { color: #1d2523; }

.focus-card {
  position: absolute;
  z-index: 4;
  width: 320px;
  padding: 26px;
  border: 1px solid #40504c;
  background: rgba(5, 9, 9, 0.94);
  box-shadow: 0 20px 70px #000;
  transition: opacity .25s ease, transform .25s ease, visibility .25s;
}
.focus-card.hidden { opacity: 0; visibility: hidden; transform: translateY(8px); }
.focus-index { color: var(--amber); font-size: 9px; letter-spacing: .15em; }
.focus-card h2 { margin: 18px 0 12px; font-family: Arial, Helvetica, sans-serif; font-size: 29px; line-height: .95; letter-spacing: -.04em; }
.focus-card p { margin: 0 0 22px; color: #899590; font-size: 11px; line-height: 1.6; }
.focus-card button, .seed-control button {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--cyan);
  background: var(--cyan);
  color: #04100e;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .08em;
  cursor: pointer;
}
.focus-card button:hover, .seed-control button:hover { background: transparent; color: var(--cyan); }
.scanline { position: absolute; z-index: 3; inset: -10% 0 auto; height: 10%; pointer-events: none; opacity: var(--signal-sweep-opacity); background: linear-gradient(transparent, rgba(104,247,231,.07), transparent); animation: scan 7s linear infinite; }
@keyframes scan { to { transform: translateY(750px); } }

.terminal-footer { display: flex; justify-content: space-between; padding: 10px 2px; color: #4f5c58; font-size: 8px; letter-spacing: .1em; }
.side-panel { display: flex; flex-direction: column; border: 1px solid var(--line); background: rgba(9, 13, 14, .72); }
.panel-block { position: relative; padding: 28px 24px; border-bottom: 1px solid var(--line); }
.panel-number { position: absolute; top: 28px; right: 22px; color: #38433f; font-size: 10px; }
.panel-block h2 { margin: 0 0 18px; font-family: Arial, Helvetica, sans-serif; font-size: 22px; line-height: .95; letter-spacing: -.035em; }
.panel-block h3 { margin: 0 0 12px; font-size: 14px; letter-spacing: -.03em; }
.panel-block > p:not(.panel-kicker) { margin: 0; color: #71807b; font-family: Arial, Helvetica, sans-serif; font-size: 12px; line-height: 1.55; }

.relay-list { margin-top: 24px; }
.relay { display: grid; grid-template-columns: 28px 1fr auto; align-items: center; padding: 9px 0; border-top: 1px solid #202927; color: #65736f; font-size: 9px; }
.relay i { width: 6px; height: 6px; border: 1px solid #687872; transform: rotate(45deg); }
.relay strong { color: #aab8b3; font-weight: 500; }
.relay.online i { border-color: var(--green); background: var(--green); box-shadow: 0 0 9px var(--green); }
.relay.online span { color: var(--green); }
.control-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 8px 0; border-top: 1px solid #202927; font-size: 8px; color: #63706c; }
.control-row kbd { min-width: 84px; padding: 6px; border: 1px solid #3b4643; background: #0e1313; color: #c6d2ce; text-align: center; box-shadow: 0 2px 0 #27302e; }
.renderer-block code { display: block; overflow: hidden; margin: 18px 0 9px; padding: 11px; border: 1px solid #2d3835; background: #050808; color: var(--amber); font-size: 10px; white-space: nowrap; }
.context-stats { margin: 20px 0 0; }
.context-stats div { display: grid; grid-template-columns: 1fr auto; gap: 12px; padding: 8px 0; border-top: 1px solid #202927; font-size: 8px; }
.context-stats dt { color: #52605c; }
.context-stats dd { max-width: 184px; margin: 0; overflow-wrap: anywhere; color: #b2c0bb; text-align: right; }
.context-stats dd[data-state="selected"] { color: var(--amber); }
.context-stats dd[data-state="active"], .context-stats dd[data-state="ready"], .context-stats dd[data-state="stable"] { color: var(--green); text-shadow: 0 0 8px rgba(141, 202, 126, .18); }
.context-stats dd[data-state="warning"] { color: var(--amber); }
.context-stats dd[data-state="danger"] { color: var(--red); }
.context-stats dd[data-state="empty"], .context-stats dd[data-state="idle"] { color: #66736f; }
.copy-button { padding: 0; border: 0; background: none; color: #6f807b; font-size: 8px; letter-spacing: .13em; cursor: pointer; }
.copy-button:hover { color: var(--cyan); }
.seed-block { margin-top: auto; padding: 22px 24px; }
.seed-block label { display: block; margin-bottom: 8px; color: #56635f; font-size: 8px; letter-spacing: .14em; }
.seed-control { display: grid; grid-template-columns: 1fr auto; }
.seed-control input { min-width: 0; padding: 11px; border: 1px solid #33403c; border-right: 0; outline: 0; background: #040707; color: var(--ink); font-size: 10px; text-transform: uppercase; }
.seed-control input:focus { border-color: var(--cyan); }
.seed-control button { width: auto; padding-inline: 10px; font-size: 8px; }
.seed-control button:disabled { border-color: #47514e; background: #111716; color: #7d8985; cursor: wait; }

.mobile-controls {
  display: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
  overscroll-behavior: contain;
}
.mobile-controls button {
  -webkit-appearance: none;
  appearance: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}
.shell > footer { height: 92px; display: flex; justify-content: space-between; align-items: center; border-top: 1px solid var(--line); color: #46524e; font-size: 8px; letter-spacing: .12em; }
.shell > footer b { color: #84928d; font-weight: 400; }

/* Desktop is a single cockpit, with the simulation owning the flexible center
   of the viewport. The two-column instrument rail keeps every directive and
   control in sight without covering the live canvas. */
@media (min-width: 1101px) and (min-height: 680px) {
  html, body { width: 100%; height: 100%; overflow: hidden; }
  body { min-height: 100dvh; }
  .shell {
    width: min(calc(100% - 24px), 1800px);
    height: 100dvh;
    display: grid;
    grid-template-rows: 44px 72px minmax(0, 1fr) 22px;
    margin: 0 auto;
    overflow: hidden;
  }
  .masthead {
    height: auto;
    min-height: 0;
    font-size: 8px;
  }
  .wordmark { gap: 10px; font-size: 11px; }
  .wordmark-mark { width: 30px; height: 30px; }
  .header-meta { font-size: 7px; line-height: 1.45; }
  .hero {
    min-height: 0;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(260px, 28vw);
    align-items: center;
    gap: 24px;
    padding: 4px 0 5px;
    overflow: hidden;
  }
  .hero-copy {
    min-width: 0;
    display: grid;
    grid-template-columns: auto minmax(260px, 1fr);
    align-items: center;
    gap: 0 22px;
  }
  .hero .eyebrow {
    grid-column: 1 / -1;
    margin: 0 0 5px;
    font-size: 7px;
  }
  .hero h1 {
    font-size: clamp(28px, 2.35vw, 38px);
    line-height: .76;
    white-space: nowrap;
  }
  .lede {
    max-width: 700px;
    margin: 0;
    font-size: 10px;
    line-height: 1.42;
  }
  .coordinates {
    width: 100%;
    min-width: 0;
  }
  .coordinates div {
    gap: 16px;
    padding: 5px 0;
    font-size: 8px;
  }
  .game-layout {
    min-height: 0;
    height: 100%;
    grid-template-columns: minmax(0, 1fr) clamp(340px, 27vw, 410px);
    gap: 10px;
  }
  .terminal-column {
    min-height: 0;
    display: grid;
    grid-template-rows: minmax(0, 1fr) 22px;
  }
  .terminal-frame {
    min-height: 0;
    height: 100%;
    display: grid;
    grid-template-rows: 44px minmax(0, 1fr);
  }
  .terminal-frame:fullscreen {
    width: 100vw;
    height: 100dvh;
    grid-template-rows: 44px minmax(0, 1fr);
  }
  .terminal-bar {
    height: 44px;
    gap: 10px;
    padding-inline: 11px;
    font-size: 8px;
  }
  .terminal-bar .audio-toggle {
    min-height: 32px;
    display: inline-grid;
    place-items: center;
    padding: 6px 8px;
  }
  .viewport, #screen {
    min-height: 0;
    height: 100%;
  }
  .terminal-frame:fullscreen .viewport,
  .terminal-frame:fullscreen #screen {
    min-height: 0;
    height: 100%;
  }
  .terminal-footer {
    height: 22px;
    align-items: center;
    padding: 0 2px;
    font-size: 7px;
  }
  .side-panel {
    min-height: 0;
    height: 100%;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-rows: auto minmax(0, 1fr) auto;
    overflow: hidden;
  }
  .panel-block {
    min-width: 0;
    min-height: 0;
    padding: 9px 10px;
    overflow: hidden;
  }
  .panel-number { top: 9px; right: 8px; font-size: 7px; }
  .panel-block .panel-kicker { margin: 0 0 6px; font-size: 7px; }
  .panel-block h2 { margin: 0 0 7px; font-size: 17px; }
  .panel-block h3 { margin: 0 0 6px; font-size: 11px; }
  .panel-block > p:not(.panel-kicker) { font-size: 9px; line-height: 1.35; }
  .mission-block {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: minmax(150px, .9fr) minmax(0, 1.1fr);
    grid-template-rows: auto auto 1fr;
    gap: 0 12px;
  }
  .mission-block .panel-kicker,
  .mission-block h2,
  .mission-block > p:not(.panel-kicker) { grid-column: 1; }
  .mission-block .relay-list {
    grid-column: 2;
    grid-row: 1 / 4;
    align-self: stretch;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-content: start;
    gap: 2px 8px;
    margin: 0;
  }
  .mission-block .relay {
    min-width: 0;
    grid-template-columns: 10px minmax(0, 1fr);
    gap: 2px;
    padding: 3px 0;
    font-size: 6px;
  }
  .mission-block .relay strong,
  .mission-block .relay span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .mission-block .relay span { grid-column: 2; }
  .controls-block { grid-column: 1; border-right: 1px solid var(--line); }
  .controls-block .panel-kicker { margin-bottom: 4px; }
  .context-block { grid-column: 2; }
  .control-row {
    gap: 6px;
    padding: 3px 0;
    font-size: 6px;
  }
  .control-row kbd {
    min-width: 68px;
    padding: 4px 3px;
  }
  .context-stats { margin-top: 8px; }
  .context-stats div {
    gap: 6px;
    padding: 4px 0;
    font-size: 6px;
  }
  .context-stats dd { max-width: 110px; }
  .renderer-block {
    grid-column: 1;
    border-right: 1px solid var(--line);
    border-bottom: 0;
  }
  .renderer-block code {
    margin: 7px 0 0;
    padding: 6px;
    font-size: 7px;
  }
  .seed-block {
    grid-column: 2;
    align-self: stretch;
    margin: 0;
    padding: 9px 10px;
  }
  .seed-block label { margin-bottom: 6px; font-size: 7px; }
  .seed-control input { padding: 8px; font-size: 8px; }
  .seed-control button { min-height: 34px; padding-inline: 8px; font-size: 7px; }
  .shell > footer {
    height: auto;
    min-height: 0;
    font-size: 6px;
  }
}

@media (max-width: 1100px) {
  .shell { width: min(100% - 28px, 900px); }
  .game-layout { grid-template-columns: 1fr; }
  .side-panel { display: grid; grid-template-columns: repeat(2, 1fr); }
  .panel-block { border-right: 1px solid var(--line); }
  .seed-block { margin: 0; }
  .viewport, #screen { min-height: 560px; }
}

@media (max-width: 680px) {
  .shell { width: calc(100% - 20px); }
  .masthead { height: 68px; grid-template-columns: 1fr auto; }
  .network-state { display: none; }
  .header-meta { font-size: 8px; }
  .hero { min-height: 0; display: block; padding: 38px 0 28px; }
  .hero h1 { font-size: clamp(41px, 14vw, 62px); }
  .lede { margin-top: 20px; font-size: 13px; }
  .coordinates { margin-top: 30px; }
  .terminal-bar { position: relative; z-index: 20; height: 52px; grid-template-columns: 1fr auto auto; gap: 6px; padding-inline: 7px; }
  .terminal-bar .audio-toggle { min-width: 64px; min-height: 44px; padding: 8px 7px; }
  .terminal-bar .expand-toggle { min-width: 92px; }
  .terminal-latency { display: none; }
  .terminal-seed { display: none; }
  .viewport, #screen { min-height: 430px; }
  .focus-card { width: min(290px, calc(100% - 30px)); }
  .field-telemetry { top: 34px; right: 7px; min-width: 136px; font-size: 6px; }
  .field-telemetry span { grid-template-columns: 31px 1fr; gap: 5px; padding: 3px 5px; }
  .terminal-footer span:first-child, .terminal-footer span:last-child { display: none; }
  .terminal-footer { justify-content: center; }
  .side-panel { display: block; }
  .mobile-controls {
    min-height: calc(240px + env(safe-area-inset-bottom, 0px));
    display: grid;
    grid-template-rows: auto 48px;
    gap: 8px;
    padding: 8px 6px calc(10px + env(safe-area-inset-bottom, 0px));
    border-top: 1px solid #283532;
    background: linear-gradient(180deg, #07100e, #050908);
  }
  .mobile-control-deck { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .touch-zone { min-width: 0; display: grid; grid-template-rows: 12px auto; gap: 4px; }
  .touch-zone-label { color: #657c75; font-size: 7px; letter-spacing: .18em; text-align: center; }
  .touch-pad {
    width: 100%;
    height: clamp(140px, 38vw, 148px);
    display: grid;
    grid-template-columns: repeat(3, minmax(44px, 1fr));
    grid-template-rows: repeat(3, minmax(44px, 1fr));
    gap: 3px;
  }
  .touch-pad .pad-north { grid-column: 2; grid-row: 1; }
  .touch-pad .pad-west { grid-column: 1; grid-row: 2; }
  .touch-pad .pad-center { grid-column: 2; grid-row: 2; }
  .touch-pad .pad-east { grid-column: 3; grid-row: 2; }
  .touch-pad .pad-south { grid-column: 2; grid-row: 3; }
  .touch-pad-origin { display: grid; place-items: center; color: #32403c; font-size: 16px; }
  .mobile-controls button {
    min-width: 44px;
    min-height: 44px;
    display: grid;
    place-content: center;
    gap: 2px;
    padding: 2px;
    border: 1px solid #3b4d48;
    border-radius: 2px;
    background: linear-gradient(145deg, #111a18, #0a100f);
    color: #c1cfca;
    font-size: 14px;
    line-height: 1;
    box-shadow: inset 0 0 16px rgba(131, 214, 206, .025), 0 2px 0 #030606;
  }
  .mobile-controls button small { display: block; color: #72817c; font-size: 6px; line-height: 1; letter-spacing: .1em; }
  .mobile-controls button:focus-visible { border-color: var(--cyan); outline: 2px solid var(--cyan); outline-offset: 1px; }
  .mobile-controls button:active, .mobile-controls button[data-active="true"] {
    border-color: var(--cyan);
    background: #152522;
    color: #e7fff7;
    box-shadow: inset 0 0 18px rgba(131, 214, 206, .14);
    transform: translateY(1px);
  }
  .mobile-controls button:active small, .mobile-controls button[data-active="true"] small { color: var(--cyan); }
  .move-pad .pad-center { border-color: #6c5a34; color: var(--amber); }
  .touch-actions { display: grid; grid-template-columns: repeat(5, minmax(44px, 1fr)); gap: 4px; }
  .touch-actions button { height: 48px; }
  .touch-actions button[data-action="interact"] { border-color: #507168; color: var(--cyan); }
  .touch-actions button[data-action="cycle-item"], .touch-actions button[data-action="use-item"] { border-color: #675b38; color: var(--amber); }
  .touch-actions button[data-action="audio"][aria-pressed="false"] { border-color: #313b38; color: #66736f; }
  .terminal-frame:fullscreen { overflow: hidden; }
  .terminal-frame:fullscreen .viewport, .terminal-frame:fullscreen #screen { height: calc(100dvh - 292px - env(safe-area-inset-bottom, 0px)); }
  .terminal-frame:fullscreen .mobile-controls {
    padding-right: max(8px, env(safe-area-inset-right, 0px));
    padding-left: max(8px, env(safe-area-inset-left, 0px));
  }
  .citynet-dialog { width: calc(100vw - 12px); height: calc(100dvh - 12px); }
  .citynet-header { padding: 15px 14px 13px; }
  .citynet-header h2 { font-size: 15px; }
  .citynet-link-state { max-width: 42%; }
  .citynet-status { gap: 12px; justify-content: space-between; padding: 7px 14px; }
  .citynet-workspace { grid-template-columns: 1fr; grid-template-rows: minmax(0, 1fr) auto; }
  .citynet-output { padding: 14px; font-size: 10px; }
  .citynet-case-file { max-height: 172px; padding: 10px 14px; border-top: 1px solid #245146; border-left: 0; }
  .citynet-case-header { align-items: center; padding-bottom: 8px; }
  .citynet-case-header h3 { margin-top: 3px; }
  .citynet-case-summary { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 16px; }
  .citynet-case-lead { padding: 9px 0 10px; }
  .citynet-suspect-file { padding-top: 9px; }
  .citynet-suspect-file ul { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .citynet-suspect { grid-template-columns: 1fr; gap: 3px; padding: 6px; }
  .citynet-actions { padding: 8px 14px; }
  .citynet-actions button, .citynet-footer button, .citynet-prompt button { min-height: 44px; }
  .citynet-form { padding: 10px 14px 12px; }
  .citynet-prompt { grid-template-columns: 1fr auto; gap: 6px; }
  .citynet-prompt > span { grid-column: 1 / -1; }
  .citynet-prompt input, .citynet-prompt button { height: 46px; }
  .citynet-footer { padding: 6px 14px; }
  .citynet-footer > span { display: none; }
  .citynet-footer button { width: 100%; }
  .lift-dialog { width: calc(100vw - 12px); height: calc(100dvh - 12px); }
  .lift-header { padding: 14px; }
  .lift-header h2 { font-size: 14px; }
  .lift-link-state { display: none; }
  .lift-status { gap: 10px; padding: 8px 14px; font-size: 7px; }
  .lift-floors { gap: 6px; padding: 12px 14px 18px; }
  .lift-floor-button { min-height: 52px; grid-template-columns: 32px 58px minmax(0, 1fr) auto 48px; gap: 7px; padding-right: 9px; }
  .lift-floor-label { font-size: 10px; }
  .lift-floor-use, .lift-floor-altitude { font-size: 7px; }
  .lift-footer { display: grid; gap: 7px; padding: 7px 14px calc(7px + env(safe-area-inset-bottom, 0px)); }
  .lift-footer p { text-align: center; }
  .lift-footer button { width: 100%; min-height: 44px; }
  .witness-dialog { width: calc(100vw - 12px); height: calc(100dvh - 12px); }
  .witness-header { padding: 14px; }
  .witness-header h2 { font-size: 14px; }
  .witness-link-state { display: none; }
  .witness-layout { grid-template-columns: 1fr; grid-template-rows: auto minmax(0, 1fr); }
  .witness-dossier { max-height: 166px; display: grid; grid-template-columns: 86px minmax(0, 1fr); grid-template-rows: auto auto; gap: 0 13px; padding: 12px 14px; border-right: 0; border-bottom: 1px solid #594a2e; }
  .witness-portrait { grid-row: 1 / 3; margin: 0; padding: 10px 2px; font-size: 7px; }
  .witness-identity { align-self: end; }
  .witness-identity h3 { font-size: 13px; }
  .witness-metadata { align-self: start; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; margin: 8px 0 0; }
  .witness-metadata div { min-width: 0; padding: 7px 0 0; }
  .witness-channel-label { padding: 10px 14px; }
  .witness-dialogue { padding: 20px 22px; font-size: clamp(16px, 5vw, 22px); }
  .witness-choice-panel { padding: 0 14px 12px; }
  .witness-choice, .witness-footer button { min-height: 44px; }
  .witness-footer { display: grid; gap: 7px; padding: 7px 14px calc(7px + env(safe-area-inset-bottom, 0px)); }
  .witness-footer p { text-align: center; }
  .witness-footer > div { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .witness-footer button { width: 100%; }
  .shell > footer { height: 70px; gap: 15px; line-height: 1.5; }
}

/* A coarse-pointer phone is the game surface, not a tall marketing page with
   a game embedded halfway down it. Keeping the document to one visual viewport
   also prevents mobile browser chrome and focus scrolling from moving the
   terminal bar away from the control deck. */
@media (max-width: 680px) and (pointer: coarse) {
  html, body { width: 100%; height: 100%; overflow: hidden; overscroll-behavior: none; }
  body { min-height: 100dvh; }
  .shell { width: 100%; height: 100dvh; margin: 0; }
  .masthead, .hero, .terminal-footer, .side-panel, .shell > footer { display: none; }
  .game-layout, .terminal-column { width: 100%; height: 100%; }
  .game-layout { display: block; }
  .terminal-frame {
    width: 100%;
    height: 100dvh;
    display: grid;
    grid-template-rows: 52px minmax(0, 1fr) auto;
    overflow: hidden;
    border: 0;
  }
  .terminal-frame .viewport, .terminal-frame #screen {
    min-height: 0;
    height: 100%;
  }
  .terminal-frame .mobile-controls {
    padding-right: max(8px, env(safe-area-inset-right, 0px));
    padding-left: max(8px, env(safe-area-inset-left, 0px));
  }
}

@media (pointer: coarse) and (max-height: 520px) and (orientation: landscape) {
  html, body { width: 100%; height: 100%; overflow: hidden; overscroll-behavior: none; }
  body { min-height: 100dvh; }
  .shell { width: 100%; height: 100dvh; margin: 0; }
  .masthead, .hero, .terminal-footer, .side-panel, .shell > footer { display: none; }
  .game-layout, .terminal-column { width: 100%; height: 100%; }
  .game-layout { display: block; }
  .terminal-frame, .terminal-frame:fullscreen {
    position: relative;
    width: 100%;
    height: 100dvh;
    display: grid;
    grid-template-rows: 52px minmax(0, 1fr);
    overflow: hidden;
    border: 0;
  }
  .terminal-frame .terminal-bar, .terminal-frame:fullscreen .terminal-bar {
    position: relative;
    z-index: 20;
    height: 52px;
    gap: 8px;
    padding-inline: max(8px, env(safe-area-inset-left, 0px)) max(8px, env(safe-area-inset-right, 0px));
  }
  .terminal-frame .terminal-bar .audio-toggle {
    min-width: 64px;
    min-height: 44px;
    padding: 8px 7px;
  }
  .terminal-frame .terminal-bar .expand-toggle { min-width: 92px; }
  .terminal-frame .viewport, .terminal-frame #screen,
  .terminal-frame:fullscreen .viewport, .terminal-frame:fullscreen #screen {
    min-height: 0;
    height: 100%;
  }
  .terminal-frame .mobile-controls,
  .terminal-frame:fullscreen .mobile-controls {
    position: absolute;
    z-index: 9;
    inset: auto 0 0;
    min-height: 0;
    height: calc(174px + env(safe-area-inset-bottom, 0px));
    display: block;
    padding: 30px max(8px, env(safe-area-inset-right, 0px)) env(safe-area-inset-bottom, 0px) max(8px, env(safe-area-inset-left, 0px));
    border: 0;
    background: linear-gradient(180deg, transparent, rgba(3, 8, 7, .72) 38%, rgba(3, 8, 7, .9));
    pointer-events: none;
  }
  .terminal-frame .mobile-control-deck { height: 140px; display: flex; align-items: flex-end; justify-content: space-between; }
  .terminal-frame .touch-zone { position: relative; width: min(164px, 30vw); pointer-events: none; }
  .terminal-frame .touch-zone-label { position: absolute; top: -18px; left: 0; width: 100%; color: #9aaca6; font-size: 8px; letter-spacing: .18em; text-align: center; }
  .terminal-frame .touch-pad {
    width: 100%;
    height: 140px;
    display: grid;
    grid-template-columns: repeat(3, minmax(44px, 1fr));
    grid-template-rows: repeat(3, minmax(44px, 1fr));
    gap: 2px;
  }
  .terminal-frame .touch-pad .pad-north { grid-column: 2; grid-row: 1; }
  .terminal-frame .touch-pad .pad-west { grid-column: 1; grid-row: 2; }
  .terminal-frame .touch-pad .pad-center { grid-column: 2; grid-row: 2; }
  .terminal-frame .touch-pad .pad-east { grid-column: 3; grid-row: 2; }
  .terminal-frame .touch-pad .pad-south { grid-column: 2; grid-row: 3; }
  .terminal-frame .touch-pad-origin { display: grid; place-items: center; color: #52635e; font-size: 16px; }
  .terminal-frame .touch-actions {
    position: absolute;
    top: 4px;
    left: 50%;
    width: min(300px, 52vw);
    display: grid;
    grid-template-columns: repeat(5, minmax(44px, 1fr));
    gap: 4px;
    transform: translateX(-50%);
    pointer-events: none;
  }
  .terminal-frame .mobile-controls button {
    min-width: 44px;
    min-height: 44px;
    display: grid;
    place-content: center;
    gap: 2px;
    padding: 2px;
    border: 1px solid #3b4d48;
    border-radius: 2px;
    background: rgba(9, 17, 15, .88);
    color: #c1cfca;
    font-size: 14px;
    line-height: 1;
    pointer-events: auto;
  }
  .terminal-frame .mobile-controls button small { display: block; color: #72817c; font-size: 6px; line-height: 1; letter-spacing: .1em; }
  .terminal-frame .touch-actions button { height: 44px; }
  .witness-choice, .witness-footer button,
  .citynet-actions button, .citynet-footer button, .citynet-prompt button,
  .lift-floor-button, .lift-footer button { min-height: 44px; }
}

@media (prefers-reduced-motion: reduce) {
  .scanline { animation: none; display: none; }
  .focus-card { transition: none; }
  .citynet-dialog[open] { animation: none; }
  .lift-dialog[open] { animation: none; }
  .witness-dialog[open] { animation: none; }
}
