:root {
  color-scheme: dark;
  --black: #080a0c;
  --black-soft: #11161a;
  --panel: rgba(8, 10, 12, 0.96);
  --ink: #fff8dc;
  --muted: #b9c1bc;
  --red: #ff3b35;
  --cyan: #55e6ec;
  --yellow: #ffd85a;
  --green: #70ec8c;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Courier New", monospace;
  font-synthesis: none;
}

* { box-sizing: border-box; }
[hidden], .is-hidden { display: none !important; }

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  background: #080a0c;
  color: var(--ink);
}

.rotate-notice { display: none; }
.compact-tutorial-step, .compact-chat-toggle { display: none; }

button, input { font: inherit; letter-spacing: 0; }

button, button * {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

button {
  min-height: 44px;
  border: 3px solid var(--ink);
  border-radius: 0;
  background: #080a0c;
  color: var(--ink);
  padding: 8px 12px;
  font-weight: 900;
  cursor: pointer;
  touch-action: manipulation;
}

button:hover, button:focus-visible { border-color: var(--yellow); color: var(--yellow); outline: 0; }
button:disabled { border-color: #4e5857; color: #697372; cursor: not-allowed; }
button.primary { border-color: var(--red); background: var(--red); color: #080a0c; }
button.primary:hover, button.primary:focus-visible { border-color: var(--ink); background: var(--ink); color: #080a0c; }

input {
  width: 100%;
  min-height: 46px;
  border: 2px solid #596362;
  border-radius: 0;
  background: #050607;
  color: var(--ink);
  padding: 10px 12px;
  font-size: 15px;
  text-transform: uppercase;
}

input:focus { border-color: var(--cyan); outline: 0; }
input:disabled { border-color: #3c4445; color: #697372; }

.boot-screen {
  position: relative;
  min-height: 100vh;
  display: grid;
  align-items: end;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior-y: contain;
  touch-action: pan-y;
  background: #080a0c url("./assets/reactor-title.png") center / cover no-repeat;
  image-rendering: pixelated;
}

.boot-shade { position: absolute; inset: 0; background: rgba(5, 7, 8, 0.48); }
.boot-content { position: relative; width: min(560px, calc(100% - 40px)); margin: 0 0 6vh 6vw; text-shadow: 3px 3px 0 #050607; }
.eyebrow { margin: 0; color: var(--cyan); font-size: 14px; font-weight: 900; }
.boot-content h1 { margin: 14px 0 18px; font-size: 126px; line-height: 0.72; letter-spacing: 0; }
.boot-content h1 span { color: var(--red); }
.boot-copy { margin: 0 0 24px; font-size: 19px; line-height: 1.5; }

.join-box {
  width: min(460px, 100%);
  border: 4px solid var(--ink);
  background: rgba(8, 10, 12, 0.96);
  padding: 18px;
  text-shadow: none;
}

.join-box label { display: grid; gap: 7px; margin-bottom: 13px; color: var(--muted); font-size: 12px; font-weight: 900; }
.menu-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.tutorial-gate { min-height: 18px; margin: 10px 0 0; color: var(--yellow); font-size: 9px; font-weight: 900; line-height: 1.4; }
.tutorial-gate.is-complete { color: var(--green); }
.stats-menu-button { width: 100%; margin-top: 9px; }
.connection-status {
  min-height: 18px;
  margin: 12px 0 0;
  color: var(--red);
  font-size: 12px;
  font-weight: 900;
  line-height: 1.4;
}

.tutorial-intro {
  position: fixed;
  z-index: 50;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 18px;
}
.tutorial-intro[hidden] { display: none; }
.tutorial-intro-backdrop { position: absolute; inset: 0; background: rgba(3, 5, 6, 0.94); }
.tutorial-intro-content {
  position: relative;
  width: min(860px, calc(100vw - 32px));
  border: 4px solid var(--ink);
  background: #080a0c;
  box-shadow: 12px 12px 0 #232a2d;
  padding: 26px;
}
.tutorial-intro-content > span { color: var(--cyan); font-size: 11px; font-weight: 900; }
.tutorial-intro-content h2 { margin: 10px 0 12px; color: var(--ink); font-size: 34px; line-height: 1.12; }
.tutorial-intro-content > p { max-width: 690px; margin: 0; color: var(--muted); font-size: 14px; line-height: 1.5; }
.tutorial-flow { display: grid; grid-template-columns: 1fr auto 1fr auto 1fr; align-items: stretch; gap: 9px; margin: 22px 0; }
.tutorial-flow > div { display: grid; grid-template-columns: 34px 1fr; align-content: center; gap: 5px 9px; border: 2px solid #596362; padding: 11px; }
.tutorial-flow b { grid-row: 1 / 3; display: grid; place-items: center; border: 2px solid currentColor; color: var(--yellow); font-size: 16px; }
.tutorial-flow strong { color: var(--ink); font-size: 12px; }
.tutorial-flow small { color: var(--muted); font-size: 9px; }
.tutorial-flow > i { align-self: center; color: var(--yellow); font-size: 21px; font-style: normal; }
.tutorial-intro-note { color: var(--yellow) !important; font-size: 11px !important; }
.tutorial-intro-actions { display: grid; grid-template-columns: 150px 1fr; gap: 9px; margin-top: 20px; }

.game-shell {
  width: min(1280px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: 12px;
}

.game-bar {
  min-height: 58px;
  display: grid;
  grid-template-columns: minmax(120px, 1fr) auto minmax(120px, auto) auto auto auto auto 42px 42px 42px;
  align-items: center;
  gap: 18px;
  border: 3px solid var(--ink);
  border-bottom: 0;
  background: var(--black);
  padding: 7px 12px;
}

.game-brand { font-size: 18px; font-weight: 900; }
.game-brand span { color: var(--red); }
.status-role { color: var(--cyan); font-size: 13px; font-weight: 900; }
.status-scenario { color: var(--yellow); font-size: 11px; font-weight: 900; text-align: center; }
.status-room, .status-strikes { color: var(--muted); font-size: 12px; }
.status-room strong, .status-strikes strong { color: var(--ink); }
.status-time { min-width: 72px; color: var(--yellow); font-size: 22px; font-weight: 900; text-align: center; }
.module-dots { display: flex; gap: 7px; }
.module-dot { width: 14px; height: 14px; border: 2px solid #73807d; background: #080a0c; }
.module-dot.done { border-color: var(--green); background: var(--green); }
.module-dot.active:not(.done) { border-color: var(--yellow); animation: module-pulse 700ms steps(2, end) infinite; }
.icon-button { position: relative; width: 42px; min-height: 38px; padding: 0; font-size: 26px; line-height: 1; }
.icon-button.is-muted::after {
  content: "";
  position: absolute;
  width: 30px;
  height: 3px;
  left: 5px;
  top: 18px;
  background: var(--red);
  transform: rotate(-45deg);
}

.tutorial-role-bar {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 14px;
  border: 3px solid var(--ink);
  border-bottom: 0;
  background: #080a0c;
  padding: 8px 10px;
}
.tutorial-role-bar > strong { color: var(--yellow); font-size: 11px; }
.tutorial-steps { display: grid; grid-template-columns: 1fr auto 1fr auto 1fr; align-items: center; gap: 6px; }
.tutorial-steps > span { min-height: 34px; display: flex; align-items: center; justify-content: center; gap: 7px; border: 2px solid #4e5857; padding: 4px 7px; color: #697372; font-size: 10px; font-weight: 900; }
.tutorial-steps > span b { color: inherit; }
.tutorial-steps > i { color: #697372; font-size: 14px; font-style: normal; }
.tutorial-steps > span.is-complete { border-color: var(--green); color: var(--green); }
.tutorial-steps > span.is-current { border-color: var(--cyan); background: var(--cyan); color: #080a0c; }
.tutorial-steps > span.is-complete + i, .tutorial-steps > span.is-current + i { color: var(--green); }
.tutorial-role-bar > button { min-height: 38px; padding: 5px 10px; font-size: 10px; }

.arena-frame { border: 3px solid var(--ink); background: var(--black); box-shadow: 9px 9px 0 #232a2d; }
.canvas-stage { position: relative; overflow: hidden; aspect-ratio: 16 / 9; background: #171b1d var(--scenario-bg, url("./assets/reactor-room-v2.png")) center / 100% 100% no-repeat; image-rendering: pixelated; }
.canvas-stage[data-scenario="cryo"] { box-shadow: inset 0 0 0 3px rgba(140, 236, 255, 0.48); }
.canvas-stage[data-scenario="signal"] { box-shadow: inset 0 0 0 3px rgba(112, 236, 140, 0.48); }
.canvas-stage::after { content: ""; position: absolute; z-index: 7; inset: 0; pointer-events: none; opacity: 0; }
.canvas-stage.outcome-lost { animation: reactor-shake 80ms steps(2, end) 16; }
.canvas-stage.outcome-lost::after { background: rgba(255, 35, 28, 0.38); animation: alarm-flash 260ms steps(2, end) 5; }
.canvas-stage.outcome-won::after { border: 8px solid rgba(112, 236, 140, 0.72); animation: stable-frame 900ms steps(4, end) 2; }

#game {
  position: absolute;
  inset: 0;
  z-index: 2;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

#game:focus { outline: 0; }

.station-label {
  position: absolute;
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 8px;
  border: 2px solid var(--ink);
  background: rgba(8, 10, 12, 0.9);
  padding: 6px 9px;
  font-size: 13px;
  font-weight: 900;
  pointer-events: none;
}

.station-label i { width: 10px; height: 10px; background: currentColor; }
.station-wires { left: 7%; top: 17%; color: var(--red); }
.station-glyphs { right: 6%; top: 17%; color: var(--cyan); }
.station-coolant { left: 50%; bottom: 7%; color: var(--yellow); transform: translateX(-50%); }
.station-label.is-done { color: var(--green); }
.station-label.is-active { border-color: var(--yellow); background: var(--yellow); color: #080a0c; animation: module-pulse 700ms steps(2, end) infinite; }
.canvas-stage.is-blind .station-label { opacity: 0; }

.objective-card {
  position: absolute;
  z-index: 4;
  left: 18px;
  bottom: 18px;
  width: min(470px, calc(100% - 36px));
  border: 3px solid var(--ink);
  border-left: 8px solid var(--yellow);
  background: var(--panel);
  padding: 13px 15px;
}

.objective-card strong { display: block; margin-bottom: 7px; color: var(--yellow); font-size: 13px; }
.objective-card p { margin: 0; color: var(--ink); font-size: 16px; line-height: 1.45; }
.game-shell.is-tutorial .objective-card { top: 18px; bottom: auto; }
.game-shell.is-tutorial .proximity-hint { display: none; }

.module-console {
  position: absolute;
  z-index: 6;
  top: 18px;
  right: 18px;
  width: min(390px, calc(100% - 36px));
  max-height: calc(100% - 80px);
  overflow: auto;
  border: 4px solid var(--ink);
  background: var(--panel);
  box-shadow: 8px 8px 0 rgba(0, 0, 0, 0.7);
}

.module-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; border-bottom: 3px solid var(--ink); padding: 11px 13px; }
.module-head span { color: var(--muted); font-size: 11px; font-weight: 900; }
.module-head h2 { margin: 3px 0 0; font-size: 23px; }
.key-help { color: var(--yellow) !important; }
.intel-content { padding: 13px; }
.intel-content p { margin: 0; color: var(--ink); font-size: 15px; line-height: 1.45; }
.intel-content strong { color: var(--cyan); }
.big-readout { min-height: 116px; display: grid; place-items: center; align-content: center; gap: 7px; border: 3px solid var(--cyan); padding: 12px; text-align: center; }
.big-readout > span { color: var(--muted); font-size: 10px; font-weight: 900; }
.big-readout > strong { color: var(--ink); font-size: 27px; line-height: 1; }
.big-readout > small { color: var(--cyan); font-size: 11px; line-height: 1.35; }
.big-readout.symbol-readout { border-color: var(--yellow); }
.big-readout.symbol-readout > strong { color: var(--yellow); font-size: 56px; }
.big-readout.waiting { border-color: #4e5857; }
.big-readout.waiting > strong { color: #697372; }
.data-list { display: grid; border-top: 2px solid #56605e; }
.data-row { min-height: 42px; display: grid; grid-template-columns: 1fr minmax(90px, auto); align-items: center; gap: 12px; border-bottom: 2px solid #394240; font-size: 14px; }
.data-row strong { color: var(--cyan); text-align: right; overflow-wrap: anywhere; }
.manual-page { border: 3px solid var(--yellow); background: var(--ink); color: #080a0c; }
.manual-page header { display: flex; align-items: center; justify-content: space-between; gap: 10px; border-bottom: 3px solid #080a0c; padding: 9px 11px; }
.manual-page header span { font-size: 9px; font-weight: 900; }
.manual-page header strong { color: #080a0c; font-size: 12px; }
.manual-page .manual-rule { min-height: 74px; display: grid; place-items: center; margin: 0; padding: 14px; color: #080a0c; font-size: 18px; font-weight: 900; line-height: 1.45; text-align: center; }
.manual-page footer { border-top: 3px solid #080a0c; padding: 8px 10px; background: var(--yellow); color: #080a0c; font-size: 9px; font-weight: 900; text-align: center; }
.action-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; padding: 0 13px 13px; }
.action-grid p { grid-column: 1 / -1; margin: 0; color: var(--green); font-size: 15px; }
.action-grid p.locked-action { color: var(--red); }
.action-grid button { min-height: 50px; text-align: left; font-size: 14px; }
.action-grid kbd { display: inline-grid; place-items: center; width: 25px; height: 25px; margin-right: 6px; border: 2px solid currentColor; font: inherit; }
.action-grid .wide-action { grid-column: 1 / -1; min-height: 66px; display: flex; align-items: center; justify-content: center; gap: 12px; text-align: center; }
.wide-action b { font-size: 28px; }
.symbol-choice { position: relative; min-width: 0; display: grid; place-items: center; gap: 5px; padding: 9px 5px !important; text-align: center !important; }
.symbol-choice kbd { position: absolute; top: 4px; left: 4px; width: 19px !important; height: 19px !important; margin: 0 !important; font-size: 9px !important; }
.symbol-choice b { color: var(--yellow); font-size: 31px; line-height: 1; }
.symbol-choice span { max-width: 100%; overflow-wrap: anywhere; font-size: 9px; }
.route-controls { border-top: 3px solid #56605e; padding: 11px 13px 13px; }
.route-label { display: block; margin-bottom: 8px; color: var(--yellow); font-size: 11px; font-weight: 900; }
.route-pad { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 7px; }
.route-pad button { min-height: 46px; padding: 0; color: var(--cyan); font-size: 24px; }
.route-pad button:hover, .route-pad button:focus-visible { background: var(--cyan); color: #080a0c; }

.proximity-hint {
  position: absolute;
  z-index: 5;
  left: 50%;
  top: 18px;
  transform: translateX(-50%);
  border: 2px solid var(--ink);
  background: rgba(8, 10, 12, 0.9);
  padding: 8px 12px;
  color: var(--ink);
  font-size: 12px;
  font-weight: 900;
  pointer-events: none;
}

.story-line {
  min-height: 88px;
  display: grid;
  grid-template-columns: 130px 1fr;
  align-items: center;
  gap: 16px;
  border-top: 4px solid var(--ink);
  background: var(--black);
  padding: 14px 18px;
}

.story-line strong { color: var(--red); font-size: 14px; }
.story-line span { color: var(--ink); font-size: 17px; line-height: 1.45; }
.game-shell.is-tutorial .story-line,
.game-shell.is-tutorial .relay { display: none !important; }

.end-overlay {
  position: absolute;
  z-index: 8;
  inset: 50% auto auto 50%;
  width: min(520px, calc(100% - 32px));
  transform: translate(-50%, -50%);
  border: 5px solid var(--ink);
  background: #080a0c;
  padding: 24px;
  text-align: center;
}

.end-overlay span { color: var(--muted); font-size: 13px; }
.end-overlay h2 { margin: 10px 0 12px; color: var(--green); font-size: 30px; }
.end-overlay p { margin: 0 auto 14px; max-width: 420px; color: var(--ink); font-size: 15px; line-height: 1.45; }
.end-overlay.is-lost { border-color: var(--red); animation: end-reveal 360ms 1100ms steps(4, end) both; }
.end-overlay.is-lost h2 { color: var(--red); }
.end-overlay.is-won { border-color: var(--green); animation: end-reveal 360ms 700ms steps(4, end) both; }
.end-overlay.is-won h2 { color: var(--green); }
.end-stats { margin-bottom: 18px; border-top: 2px solid #4e5857; border-bottom: 2px solid #4e5857; padding: 10px; color: var(--yellow); font-size: 13px; font-weight: 900; }
.end-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

.lobby {
  position: fixed;
  z-index: 20;
  inset: 50% auto auto 50%;
  width: min(720px, calc(100% - 32px));
  transform: translate(-50%, -50%);
  border: 5px solid var(--ink);
  background: #080a0c;
  box-shadow: 12px 12px 0 rgba(0, 0, 0, 0.65);
  padding: 20px;
}

.lobby header { display: flex; align-items: end; justify-content: space-between; gap: 20px; margin-bottom: 16px; }
#inviteButton { min-width: 44px; margin-left: 8px; font-size: 22px; }
.lobby header span { color: var(--cyan); font-size: 12px; }
.lobby h2 { margin: 5px 0 0; font-size: 28px; }
.lobby header p { max-width: 340px; margin: 0; color: var(--muted); font-size: 14px; }
.players { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 12px; }
.player { min-width: 0; display: grid; grid-template-columns: 40px 1fr; align-items: center; gap: 10px; border: 2px solid #5a6462; padding: 8px; font-size: 14px; }
.player-copy { min-width: 0; display: grid; gap: 5px; }
.player-copy strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.player-copy em { color: var(--yellow); font-size: 9px; font-style: normal; font-weight: 900; }
.player small { color: var(--cyan); }
.role-avatar { position: relative; width: 40px; height: 60px; overflow: hidden; image-rendering: pixelated; }
.role-avatar img { position: absolute; top: 0; width: 120px; height: 60px; max-width: none; image-rendering: pixelated; }
.role-avatar.role-operator img { left: 0; }
.role-avatar.role-lookout img, .role-avatar.role-observer img { left: -40px; }
.role-avatar.role-scribe img { left: -80px; }
.role-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 10px; }
.role-row button { min-height: 70px; display: grid; align-content: center; gap: 6px; text-align: left; }
.role-row button strong { font-size: 14px; }
.role-row button small { color: var(--muted); font-size: 10px; line-height: 1.35; }
.role-row button:hover small, .role-row button:focus-visible small { color: currentColor; }
.lobby > .primary { width: 100%; }

.relay { display: grid; grid-template-columns: auto minmax(240px, 1fr) minmax(300px, 0.7fr); align-items: center; gap: 10px; margin-top: 8px; border: 3px solid var(--ink); background: var(--black); padding: 8px 10px; }
.relay-head { display: grid; gap: 4px; color: var(--muted); font-size: 10px; }
.relay-head strong { color: var(--cyan); }
.log { min-height: 42px; max-height: 48px; overflow: auto; display: grid; align-content: end; gap: 3px; font-size: 11px; }
.log-line { color: var(--muted); line-height: 1.35; }
.log-line.success { color: var(--green); }
.log-line.danger { color: var(--red); }
.log-line.chat { color: var(--ink); }
.log-line.ping { color: var(--yellow); }
.chat-form { display: grid; grid-template-columns: 1fr 48px; gap: 6px; }
.quick-pings { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; grid-column: 3; }
.quick-pings button { min-height: 34px; padding: 4px; font-size: 10px; }
.symbol-relay { grid-column: 2; display: grid; grid-template-columns: 1fr auto; gap: 6px; }
.symbol-draft {
  min-height: 46px;
  display: flex;
  align-items: center;
  border: 2px solid #596362;
  background: #050607;
  padding: 7px 10px;
  color: var(--yellow);
  font-size: 21px;
  overflow: hidden;
}
.symbol-palette { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(9, minmax(32px, 1fr)); gap: 4px; }
.symbol-palette button { min-height: 34px; padding: 2px; font-size: 17px; }
.symbol-actions { display: grid; grid-template-columns: 42px 42px; gap: 5px; }
.symbol-actions button { min-height: 46px; padding: 0; font-size: 20px; }
.log-line.symbol { color: var(--yellow); font-size: 18px; }

.stats-panel {
  position: fixed;
  z-index: 40;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 16px;
}
.stats-panel[hidden] { display: none; }
.stats-backdrop { position: absolute; inset: 0; background: rgba(3, 5, 6, 0.88); }
.stats-dialog {
  position: relative;
  width: min(760px, calc(100vw - 24px));
  max-height: calc(100vh - 24px);
  overflow: auto;
  border: 4px solid var(--ink);
  background: #080a0c;
  box-shadow: 12px 12px 0 #232a2d;
  padding: 18px;
}
.stats-header, .stats-footer, .stats-row, .stats-history-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}
.stats-header span { color: var(--cyan); font-size: 11px; font-weight: 900; }
.stats-header h2 { margin: 5px 0 0; font-size: 26px; }
.stats-summary { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); margin-top: 18px; border-block: 3px solid #4e5857; }
.stats-cell { min-width: 0; padding: 14px 10px; border-right: 2px solid #4e5857; }
.stats-cell:last-child { border-right: 0; }
.stats-cell span, .stats-row span, .stats-history-row span { display: block; color: var(--muted); font-size: 10px; font-weight: 900; }
.stats-cell strong { display: block; margin-top: 6px; color: var(--cyan); font-size: 24px; overflow-wrap: anywhere; }
.stats-details { margin-top: 12px; }
.stats-row, .stats-history-row { min-height: 38px; border-bottom: 1px solid #3d4646; padding: 7px 2px; }
.stats-row strong, .stats-history-row strong { max-width: 68%; color: var(--ink); font-size: 12px; text-align: right; }
.stats-breakdown { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-top: 18px; }
.stats-breakdown h3, .stats-history h3 { margin: 0; color: var(--yellow); font-size: 12px; }
.stats-history { margin-top: 18px; }
.stats-history-row.is-win strong { color: var(--green); }
.stats-history-row.is-loss strong { color: var(--red); }
.stats-empty { color: var(--muted); font-size: 12px; padding: 14px 0; }
.stats-footer { margin-top: 18px; }
.stats-footer p { max-width: 460px; margin: 0; color: var(--muted); font-size: 11px; line-height: 1.4; }

.touch {
  display: none;
  grid-template-columns: repeat(3, 58px);
  grid-template-areas: ". up ." "left down right";
  justify-content: center;
  gap: 7px;
  margin-top: 14px;
}

.touch [data-move="up"] { grid-area: up; }
.touch [data-move="left"] { grid-area: left; }
.touch [data-move="down"] { grid-area: down; }
.touch [data-move="right"] { grid-area: right; }
.touch [data-move] { touch-action: none; }

@keyframes module-pulse {
  0%, 100% { background: #080a0c; }
  50% { background: var(--yellow); }
}

@keyframes reactor-shake {
  0% { transform: translate(0, 0); }
  25% { transform: translate(-4px, 3px); }
  50% { transform: translate(4px, -2px); }
  75% { transform: translate(-2px, -3px); }
  100% { transform: translate(0, 0); }
}

@keyframes alarm-flash {
  0%, 100% { opacity: 0; }
  50% { opacity: 1; }
}

@keyframes stable-frame {
  0%, 100% { opacity: 0; }
  50% { opacity: 1; }
}

@keyframes end-reveal {
  from { opacity: 0; transform: translate(-50%, -46%) scale(0.96); }
  to { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

@media (max-width: 820px) {
  .game-bar { grid-template-columns: 1fr auto auto auto 42px 42px 42px; gap: 9px; }
  .status-scenario, .status-room, .status-strikes { display: none; }
  .station-label { font-size: 10px; padding: 4px 6px; }
  .station-label i { width: 7px; height: 7px; }
  .objective-card { left: 10px; bottom: 10px; width: min(400px, calc(100% - 20px)); padding: 9px 11px; }
  .objective-card p { font-size: 13px; }
  .module-console { top: 10px; right: 10px; max-height: calc(100% - 20px); }
  .proximity-hint { top: 10px; font-size: 10px; }
  .touch { display: grid; }
  .relay { grid-template-columns: 1fr; }
  .quick-pings { grid-column: auto; }
  .symbol-relay { grid-column: auto; }
}

@media (max-width: 560px) {
  .boot-content { width: calc(100% - 24px); margin: 0 12px 18px; }
  .boot-content h1 { font-size: 62px; }
  .boot-copy { font-size: 15px; }
  .menu-actions { grid-template-columns: 1fr; }
  .game-shell { padding: 6px; }
  .game-brand { display: none; }
  .game-bar { min-height: 50px; grid-template-columns: 1fr auto auto 38px 38px 38px; }
  .status-time { font-size: 18px; }
  .station-label span { display: none; }
  .station-label { border: 0; background: transparent; }
  .station-label i { width: 13px; height: 13px; border: 2px solid var(--ink); }
  .objective-card { left: 0; bottom: -94px; width: 100%; border-width: 0; border-top: 3px solid var(--ink); border-left: 7px solid var(--yellow); }
  .canvas-stage { overflow: visible; margin-bottom: 94px; }
  .module-console { position: fixed; inset: auto 6px 6px; width: auto; max-height: 72vh; }
  .proximity-hint { top: auto; bottom: 8px; white-space: nowrap; }
  .story-line { grid-template-columns: 82px 1fr; min-height: 80px; padding: 10px 12px; }
  .story-line strong { font-size: 11px; }
  .story-line span { font-size: 13px; }
  .lobby header { display: grid; }
  .players, .role-row { grid-template-columns: 1fr; }
  .relay { margin-top: 8px; }
  .tutorial-role-bar { grid-template-columns: 1fr auto; }
  .tutorial-role-bar > strong { display: none; }
  .tutorial-steps > span { font-size: 8px; }
  .tutorial-role-bar > button { font-size: 8px; }
  .symbol-palette { grid-template-columns: repeat(6, minmax(32px, 1fr)); }
  .stats-dialog { padding: 14px; }
  .stats-header h2 { font-size: 20px; }
  .stats-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stats-cell:nth-child(2) { border-right: 0; }
  .stats-cell:nth-child(-n + 2) { border-bottom: 2px solid #4e5857; }
  .stats-breakdown { grid-template-columns: 1fr; gap: 16px; }
  .stats-footer { align-items: stretch; flex-direction: column; }
}

@media (max-height: 600px) and (orientation: landscape) {
  body { min-height: 100dvh; overflow: hidden; }

  .boot-screen { min-height: 100dvh; }
  .boot-content { width: min(470px, 58vw); margin: 6px 0 6px 4vw; }
  .eyebrow { font-size: 9px; }
  .boot-content h1 { margin: 5px 0 7px; font-size: 58px; line-height: 0.72; }
  .boot-copy { margin-bottom: 8px; font-size: 11px; line-height: 1.25; }
  .join-box { width: min(430px, 100%); border-width: 2px; padding: 8px; }
  .join-box label { gap: 3px; margin-bottom: 5px; font-size: 8px; }
  .join-box input { min-height: 32px; padding: 5px 8px; font-size: 10px; }
  .join-box button { min-height: 32px; padding: 4px 7px; font-size: 9px; }
  .stats-menu-button { margin-top: 5px; }
  .connection-status { min-height: 11px; margin-top: 4px; font-size: 8px; }
  .tutorial-gate { min-height: 10px; margin-top: 4px; font-size: 7px; }

  .tutorial-intro { padding: 8px; }
  .tutorial-intro-content { width: min(760px, calc(100vw - 16px)); max-height: calc(100dvh - 16px); overflow: auto; border-width: 2px; box-shadow: 5px 5px 0 #232a2d; padding: 10px 12px; }
  .tutorial-intro-content > span { font-size: 7px; }
  .tutorial-intro-content h2 { margin: 4px 0 5px; font-size: 19px; line-height: 1.05; }
  .tutorial-intro-content > p { font-size: 8px; line-height: 1.3; }
  .tutorial-flow { gap: 4px; margin: 8px 0; }
  .tutorial-flow > div { grid-template-columns: 22px 1fr; gap: 2px 4px; border-width: 1px; padding: 5px; }
  .tutorial-flow b { border-width: 1px; font-size: 10px; }
  .tutorial-flow strong { font-size: 8px; }
  .tutorial-flow small { font-size: 6px; }
  .tutorial-flow > i { font-size: 12px; }
  .tutorial-intro-note { font-size: 7px !important; }
  .tutorial-intro-actions { grid-template-columns: 100px 1fr; gap: 5px; margin-top: 8px; }
  .tutorial-intro-actions button { min-height: 30px; border-width: 2px; padding: 3px 6px; font-size: 8px; }

  .game-shell { width: 100vw; height: 100dvh; min-height: 0; margin: 0; padding: 0; overflow: hidden; }
  .game-bar {
    position: fixed;
    z-index: 18;
    inset: 5px 6px auto;
    min-height: 38px;
    grid-template-columns: minmax(120px, 1fr) auto auto auto 34px 34px;
    gap: 8px;
    border: 2px solid var(--ink);
    padding: 3px 6px;
    background: rgba(8, 10, 12, 0.94);
  }
  .game-brand, .status-scenario, .status-room, #statsOpenGame { display: none; }
  .status-role { overflow: hidden; font-size: 9px; text-overflow: ellipsis; white-space: nowrap; }
  .status-time { min-width: 48px; font-size: 17px; }
  .status-strikes { font-size: 8px; white-space: nowrap; }
  .module-dots { gap: 4px; }
  .module-dot { width: 9px; height: 9px; border-width: 1px; }
  .icon-button { width: 34px; min-height: 30px; border-width: 2px; font-size: 19px; }
  .icon-button.is-muted::after { width: 24px; height: 2px; left: 3px; top: 14px; }

  .tutorial-role-bar {
    position: fixed;
    z-index: 17;
    top: 47px;
    left: 50%;
    width: calc(100vw - 16px);
    transform: translateX(-50%);
    grid-template-columns: 1fr;
    gap: 4px;
    border: 2px solid var(--ink);
    padding: 3px;
    background: rgba(8, 10, 12, 0.94);
  }
  .tutorial-role-bar > strong { display: none; }
  .tutorial-steps { gap: 3px; }
  .tutorial-steps > span { min-height: 27px; gap: 3px; border-width: 1px; padding: 2px 4px; font-size: 7px; }
  .tutorial-steps > i { font-size: 8px; }
  .tutorial-role-bar > button { min-height: 27px; border-width: 1px; padding: 2px 5px; font-size: 7px; }

  .arena-frame { position: fixed; inset: 0; border: 0; box-shadow: none; }
  .canvas-stage { width: 100vw; height: 100dvh; aspect-ratio: auto; }
  .story-line { display: none; }
  .station-label { gap: 4px; border-width: 1px; padding: 3px 5px; font-size: 8px; }
  .station-label i { width: 6px; height: 6px; }

  .objective-card {
    left: 8px;
    bottom: 8px;
    width: min(42vw, 340px);
    max-height: 88px;
    overflow: hidden;
    border-width: 2px;
    border-left-width: 5px;
    padding: 6px 8px;
  }
  .game-shell.is-tutorial .objective-card { top: auto; bottom: 8px; }
  .objective-card strong { margin-bottom: 3px; font-size: 8px; }
  .objective-card p { font-size: 9px; line-height: 1.3; }

  .module-console {
    position: fixed;
    z-index: 15;
    inset: 49px 8px auto auto;
    width: min(34vw, 300px);
    max-height: calc(100dvh - 106px);
    border-width: 2px;
    box-shadow: 4px 4px 0 rgba(0, 0, 0, 0.7);
  }
  .game-shell.is-tutorial .module-console { top: 82px; }
  .module-head { gap: 6px; border-bottom-width: 2px; padding: 5px 7px; }
  .module-head span { font-size: 7px; }
  .module-head h2 { margin-top: 1px; font-size: 14px; }
  .intel-content { padding: 6px 7px; }
  .intel-content p { font-size: 9px; line-height: 1.25; }
  .big-readout { min-height: 70px; gap: 3px; border-width: 2px; padding: 5px; }
  .big-readout > span { font-size: 6px; }
  .big-readout > strong { font-size: 15px; }
  .big-readout > small { font-size: 7px; }
  .big-readout.symbol-readout > strong { font-size: 29px; }
  .data-list { border-top-width: 1px; }
  .data-row { min-height: 25px; gap: 6px; border-bottom-width: 1px; font-size: 8px; }
  .manual-page { border-width: 2px; }
  .manual-page header { gap: 4px; border-bottom-width: 2px; padding: 4px 5px; }
  .manual-page header span { font-size: 6px; }
  .manual-page header strong { font-size: 8px; }
  .manual-page .manual-rule { min-height: 38px; padding: 6px; font-size: 10px; line-height: 1.25; }
  .manual-page footer { border-top-width: 2px; padding: 4px 5px; font-size: 6px; }
  .action-grid { gap: 4px; padding: 0 7px 7px; }
  .action-grid p { font-size: 9px; }
  .action-grid button { min-height: 33px; border-width: 2px; padding: 3px 5px; font-size: 9px; }
  .action-grid kbd { width: 18px; height: 18px; margin-right: 3px; border-width: 1px; }
  .action-grid .wide-action { min-height: 38px; gap: 6px; }
  .wide-action b { font-size: 17px; }
  .symbol-choice { gap: 2px; padding: 4px 2px !important; }
  .symbol-choice b { font-size: 18px; }
  .symbol-choice span { font-size: 6px; }
  .symbol-choice kbd { top: 2px; left: 2px; width: 13px !important; height: 13px !important; font-size: 6px !important; }
  .route-controls { border-top-width: 2px; padding: 6px 7px 7px; }
  .route-label { margin-bottom: 4px; font-size: 7px; }
  .route-pad { gap: 4px; }
  .route-pad button { min-height: 32px; border-width: 2px; font-size: 17px; }
  .proximity-hint { display: none; }

  .relay {
    position: fixed;
    z-index: 16;
    right: 8px;
    bottom: 8px;
    width: min(39vw, 360px);
    height: 42px;
    grid-template-columns: minmax(0, 1fr) minmax(150px, 1.25fr);
    gap: 4px;
    margin: 0;
    border-width: 2px;
    padding: 4px;
    background: rgba(8, 10, 12, 0.94);
  }
  .relay-head { display: none; }
  .log { min-height: 30px; max-height: 30px; gap: 0; overflow: hidden; align-content: center; font-size: 8px; }
  .log-line { display: none; line-height: 1.2; }
  .log-line:last-child { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .chat-form { grid-template-columns: minmax(0, 1fr) 32px; gap: 3px; }
  .chat-form input { min-height: 30px; padding: 3px 5px; font-size: 8px; }
  .chat-form button { min-height: 30px; border-width: 2px; padding: 0; font-size: 14px; }
  .quick-pings { display: none !important; }

  .touch {
    position: fixed;
    z-index: 16;
    left: max(10px, env(safe-area-inset-left));
    top: 50%;
    display: grid;
    grid-template-columns: repeat(3, 38px);
    justify-content: start;
    gap: 3px;
    margin: 0;
    transform: translateY(-50%);
  }
  .touch button { min-height: 36px; border-width: 2px; padding: 0; background: rgba(8, 10, 12, 0.84); font-size: 11px; }

  .game-shell[data-role="scribe"] .module-console { width: min(31vw, 270px); max-height: calc(100dvh - 150px); }
  .game-shell[data-role="scribe"] .objective-card { width: min(29vw, 250px); max-height: 94px; }
  .game-shell[data-role="scribe"] .relay { width: min(39vw, 360px); height: 42px; grid-template-columns: 1fr; }
  .game-shell[data-role="scribe"] .log { min-height: 30px; max-height: 30px; white-space: normal; }
  .symbol-relay { grid-column: auto; grid-template-columns: minmax(70px, 1fr) auto; gap: 3px; }
  .symbol-draft { min-height: 27px; border-width: 1px; padding: 3px 5px; font-size: 13px; }
  .symbol-palette { grid-template-columns: repeat(13, minmax(22px, 1fr)); gap: 2px; }
  .symbol-palette button { min-height: 25px; border-width: 1px; padding: 0; font-size: 11px; }
  .symbol-actions { grid-template-columns: 29px 29px; gap: 3px; }
  .symbol-actions button { min-height: 27px; border-width: 2px; font-size: 14px; }

  .lobby { width: min(760px, calc(100vw - 24px)); padding: 10px; border-width: 3px; }
  .lobby header { margin-bottom: 7px; }
  .lobby h2 { font-size: 19px; }
  .lobby header p { font-size: 9px; }
  .players { gap: 5px; margin-bottom: 6px; }
  .player { grid-template-columns: 30px 1fr; gap: 5px; padding: 4px; font-size: 9px; }
  .role-avatar { width: 30px; height: 45px; }
  .role-avatar img { width: 90px; height: 45px; }
  .role-avatar.role-lookout img, .role-avatar.role-observer img { left: -30px; }
  .role-avatar.role-scribe img { left: -60px; }
  .role-row { gap: 5px; margin-bottom: 6px; }
  .role-row button { min-height: 48px; gap: 2px; padding: 4px 6px; }
  .role-row button strong { font-size: 9px; }
  .role-row button small { font-size: 7px; }
  .lobby > .primary { min-height: 34px; font-size: 9px; }

  .end-overlay { width: min(470px, calc(100% - 24px)); border-width: 3px; padding: 12px; }
  .end-overlay h2 { margin: 5px 0 6px; font-size: 20px; }
  .end-overlay p { margin-bottom: 7px; font-size: 10px; }
  .end-stats { margin-bottom: 8px; padding: 5px; font-size: 9px; }
  .end-actions button { min-height: 34px; font-size: 9px; }
}

@media (max-width: 900px) and (orientation: portrait) and (hover: none) and (pointer: coarse) {
  body.is-game { height: 100dvh; overflow: hidden; }
  body.is-game .rotate-notice {
    position: fixed;
    z-index: 100;
    inset: 0;
    display: grid;
    place-content: center;
    justify-items: center;
    gap: 13px;
    padding: 28px;
    background: #080a0c;
    text-align: center;
  }
  .rotate-notice strong { color: var(--yellow); font-size: 19px; }
  .rotate-notice p { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.4; }
  .rotate-icon { position: relative; width: 112px; height: 78px; }
  .rotate-icon span {
    position: absolute;
    left: 7px;
    bottom: 4px;
    width: 70px;
    height: 42px;
    border: 4px solid var(--cyan);
    box-shadow: 5px 5px 0 #263235;
  }
  .rotate-icon span::after { content: ""; position: absolute; right: 4px; top: 15px; width: 4px; height: 4px; background: var(--cyan); }
  .rotate-icon b { position: absolute; right: 0; top: 0; color: var(--yellow); font-size: 44px; line-height: 1; }
}

@media (max-width: 760px) and (pointer: fine) {
  .game-shell {
    width: 100%;
    height: 100dvh;
    min-height: 0;
    padding: 4px;
    overflow: hidden;
  }

  .game-bar {
    min-height: 46px;
    grid-template-columns: minmax(0, 1fr) auto auto auto 38px 38px;
    gap: 7px;
    border-width: 2px;
    padding: 4px 7px;
  }
  .game-brand,
  .status-scenario,
  .status-room,
  #statsOpenGame { display: none; }
  .status-role { min-width: 0; overflow: hidden; font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
  .status-time { min-width: 42px; font-size: 17px; }
  .status-strikes { font-size: 8px; white-space: nowrap; }
  .module-dots { gap: 3px; }
  .module-dot { width: 9px; height: 9px; border-width: 1px; }
  .icon-button { width: 38px; min-height: 34px; border-width: 2px; font-size: 20px; }

  .tutorial-role-bar {
    min-height: 42px;
    grid-template-columns: 1fr;
    gap: 0;
    border-width: 2px;
    padding: 4px;
  }
  .tutorial-role-bar > strong { display: none; }
  .tutorial-steps { gap: 4px; }
  .tutorial-steps > span { min-height: 30px; gap: 4px; border-width: 1px; padding: 3px 5px; font-size: 8px; }
  .tutorial-steps > i { font-size: 9px; }

  .arena-frame {
    position: relative;
    height: calc(100dvh - 54px);
    border-width: 2px;
    box-shadow: none;
  }
  .game-shell.is-tutorial .arena-frame { height: calc(100dvh - 96px); }
  .canvas-stage { width: 100%; height: 100%; aspect-ratio: auto; background-size: cover; }
  .story-line,
  .relay,
  .proximity-hint { display: none !important; }

  .station-label { gap: 4px; border-width: 1px; padding: 3px 5px; font-size: 8px; }
  .station-label i { width: 6px; height: 6px; }

  .objective-card,
  .game-shell.is-tutorial .objective-card {
    inset: 8px 8px auto;
    width: auto;
    max-height: 76px;
    overflow: hidden;
    border-width: 2px;
    border-left-width: 5px;
    padding: 7px 9px;
  }
  .objective-card strong { margin-bottom: 3px; font-size: 9px; }
  .objective-card p { font-size: 11px; line-height: 1.3; }

  .module-console,
  .game-shell.is-tutorial .module-console {
    position: absolute;
    inset: auto 8px 8px;
    width: auto;
    max-height: 44%;
    border-width: 2px;
    box-shadow: none;
  }
  .module-head { gap: 6px; border-bottom-width: 2px; padding: 5px 7px; }
  .module-head span { font-size: 7px; }
  .module-head h2 { margin-top: 1px; font-size: 15px; }
  .intel-content { padding: 6px 7px; }
  .big-readout { min-height: 58px; gap: 2px; border-width: 2px; padding: 5px; }
  .big-readout > span { font-size: 6px; }
  .big-readout > strong { font-size: 16px; }
  .big-readout > small { font-size: 7px; }
  .big-readout.symbol-readout > strong { font-size: 30px; }
  .action-grid { gap: 5px; padding: 0 7px 7px; }
  .action-grid p { font-size: 9px; }
  .action-grid button { min-height: 40px; border-width: 2px; padding: 4px; font-size: 9px; }
  .action-grid .wide-action { min-height: 44px; gap: 7px; }
  .wide-action b { font-size: 18px; }
  .symbol-choice { gap: 2px; padding: 5px 2px !important; }
  .symbol-choice b { font-size: 20px; }
  .symbol-choice span { font-size: 7px; }
  .symbol-choice kbd { top: 2px; left: 2px; width: 14px !important; height: 14px !important; font-size: 6px !important; }
  .route-controls { border-top-width: 2px; padding: 5px 7px 7px; }
  .route-label { margin-bottom: 4px; font-size: 7px; }
  .route-pad { gap: 4px; }
  .route-pad button { min-height: 34px; border-width: 2px; font-size: 17px; }
}

@media (max-height: 600px) and (orientation: landscape) {
  .boot-screen { height: 100dvh; min-height: 0; align-items: center; overflow-y: auto; padding: 14px max(16px, env(safe-area-inset-right)) 14px max(16px, env(safe-area-inset-left)); }
  .boot-content { width: min(880px, 100%); margin: auto; display: grid; grid-template-columns: minmax(0, 1fr) minmax(280px, 1fr); gap: 8px 24px; align-items: start; }
  .boot-content .eyebrow { grid-column: 1; font-size: 10px; line-height: 1.4; }
  .boot-content h1 { grid-column: 1; margin: 8px 0; font-size: 58px; line-height: 0.85; }
  .boot-copy { grid-column: 1; margin: 0; font-size: 12px; line-height: 1.4; }
  .join-box { grid-column: 2; grid-row: 1 / 4; width: 100%; padding: 10px; }
  .join-box label { font-size: 10px; gap: 4px; margin-bottom: 7px; }
  .join-box input { min-height: 36px; font-size: 12px; padding: 6px 8px; }
  .join-box button { min-height: 38px; font-size: 10px; padding: 5px 7px; }
  .tutorial-gate { font-size: 9px; line-height: 1.35; }
  .connection-status:empty { display: none; }
}

@media (max-height: 600px) and (max-width: 600px) and (orientation: landscape) {
  .boot-content { grid-template-columns: minmax(0, 0.65fr) minmax(240px, 1fr); gap: 6px 12px; }
  .boot-content h1 { font-size: 40px; }
  .boot-copy { font-size: 10px; }
  .eyebrow { display: none; }
  .join-box { grid-row: 1 / 4; }
}

body.is-menu { height: auto; min-height: 0; overflow-y: auto; }
.boot-screen { height: var(--visible-height, 100dvh); min-height: 0; overflow-y: auto; align-items: safe end; }
.cinematic { position: fixed; z-index: 110; inset: 0; background: #000; }
.cinematic video { display: block; width: 100%; height: 100%; object-fit: contain; }
.cinematic-controls { position: absolute; right: max(12px, env(safe-area-inset-right)); bottom: max(12px, env(safe-area-inset-bottom)); display: flex; gap: 8px; }
.cinematic-controls button { min-height: 44px; background: rgba(0, 0, 0, 0.8); font-size: 12px; }
#introSound, #introRestart { width: 44px; font-size: 23px; }
#introSound.is-muted { color: var(--muted); }
.keyboard-done { position: fixed; z-index: 120; right: max(8px, env(safe-area-inset-right)); bottom: calc(var(--keyboard-inset, 0px) + 8px); min-height: 44px; background: var(--cyan); border-color: var(--cyan); color: #080a0c; font-size: 11px; }

@media (pointer: coarse) {
  input, .join-box input, .chat-form input { font-size: 16px; }
  .boot-screen { align-items: start; }
  .boot-content { margin-top: 16px; margin-bottom: 16px; }
  .join-box button { min-height: 44px; }
  .boot-content h1 { line-height: 0.9; }
}

/* Fit the embedded game window, not the phone's physical screen. */
.game-shell.is-compact {
  --compact-side-width: min(260px, max(220px, 29vw));
  --compact-hint-height: 70px;
  --console-width: 0px;
  position: fixed;
  inset: 0;
  width: 100%;
  height: var(--visible-height, 100dvh);
  min-height: 0;
  margin: 0;
  padding: 0;
  overflow: hidden;
  background: #080a0c;
}
.game-shell.is-compact[data-console-open="true"] { --console-width: var(--compact-side-width); }
.is-compact .game-bar {
  position: absolute;
  inset: 0 var(--console-width) auto 0;
  height: 44px;
  min-height: 44px;
  grid-template-columns: minmax(0, 1fr) auto auto auto 36px 36px 36px;
  gap: 4px;
  border: 0;
  border-bottom: 1px solid #4e5857;
  padding: 2px 6px;
  background: #080a0c;
}
.is-compact .game-brand, .is-compact .status-scenario, .is-compact .status-room,
.is-compact #statsOpenGame, .is-compact .module-dots { display: none; }
.is-compact .status-role { min-width: 0; font-size: 10px; white-space: nowrap; }
.is-compact .status-time { min-width: 34px; font-size: 16px; }
.is-compact .status-strikes { font-size: 9px; }
.is-compact .icon-button { width: 36px; min-height: 40px; height: 40px; border: 0; font-size: 23px; }
.is-compact .compact-chat-toggle { display: block; }
.is-compact:not([data-phase="playing"]) .compact-chat-toggle { visibility: hidden; pointer-events: none; }
.is-compact .compact-tutorial-step { display: block; color: var(--yellow); font-size: 11px; }
.is-compact[data-phase="lobby"] .compact-tutorial-step { display: none; }
.is-compact .icon-button.is-muted::after { width: 25px; top: 19px; }
.is-compact.is-tutorial .status-strikes, .is-compact.is-tutorial .status-time { display: none; }
.is-compact.is-tutorial .game-bar { grid-template-columns: minmax(0, 1fr) auto 36px 36px 36px; }
.is-compact.is-tutorial .compact-tutorial-step { display: block; color: var(--yellow); font-size: 11px; }
.is-compact .tutorial-role-bar { display: none; }
.game-shell.is-compact .arena-frame {
  position: absolute;
  inset: 44px var(--console-width) 0 0;
  width: auto;
  height: auto;
  display: grid;
  place-items: center;
  border: 0;
  box-shadow: none;
}
.is-compact .canvas-stage {
  width: min(100%, calc((var(--visible-height, 100dvh) - 44px) * 16 / 9));
  height: auto;
  max-height: 100%;
  aspect-ratio: 16 / 9;
  margin: 0;
  overflow: visible;
  background-size: 100% 100%;
}
.is-compact .station-label { border-width: 1px; padding: 2px 4px; font-size: 9px; }
.is-compact .station-label i { width: 5px; height: 5px; }
.is-compact .module-console, .is-compact.is-tutorial .module-console,
.is-compact[data-role="scribe"] .module-console {
  position: fixed;
  inset: 0 0 var(--compact-hint-height) auto;
  width: var(--compact-side-width);
  max-height: none;
  border: 0;
  border-left: 1px solid #4e5857;
  box-shadow: none;
  overflow: auto;
  overscroll-behavior: contain;
  background: #080a0c;
}
.is-compact .module-head { min-height: 32px; padding: 6px 8px; border-bottom-width: 1px; }
.is-compact .module-head h2 { margin: 0; font-size: 13px; line-height: 1.3; }
.is-compact .module-head span { display: none; }
.is-compact .intel-content { padding: 6px 8px; }
.is-compact .big-readout { min-height: 64px; border-width: 1px; padding: 6px; gap: 4px; }
.is-compact .big-readout > span { font-size: 9px; }
.is-compact .big-readout > strong { font-size: 19px; }
.is-compact .big-readout > small { font-size: 10px; line-height: 1.3; }
.is-compact .big-readout.symbol-readout > strong { font-size: 30px; }
.is-compact .action-grid { gap: 5px; padding: 0 8px 6px; }
.is-compact .action-grid button, .is-compact .action-grid .wide-action { min-height: 44px; padding: 5px; border-width: 1px; font-size: 10px; }
.is-compact .action-grid .wide-action { gap: 6px; }
.is-compact .action-grid p { font-size: 10px; line-height: 1.4; }
.is-compact .action-grid kbd { display: none; }
.is-compact .symbol-choice b { font-size: 24px; }
.is-compact .symbol-choice { padding: 4px 2px !important; }
.is-compact .symbol-choice span { font-size: 9px; }
.is-compact .route-controls { padding: 6px 8px; border-top-width: 1px; }
.is-compact .route-label { font-size: 9px; margin-bottom: 5px; }
.is-compact .route-pad { gap: 4px; }
.is-compact .route-pad button { min-height: 44px; border-width: 1px; font-size: 22px; }
.is-compact .objective-card, .is-compact.is-tutorial .objective-card,
.is-compact[data-role="scribe"] .objective-card {
  position: fixed;
  inset: auto auto 6px 6px;
  width: min(340px, calc(100% - 12px));
  max-height: none;
  border-width: 1px;
  border-left-width: 3px;
  padding: 7px 8px;
  overflow: visible;
}
.is-compact[data-console-open="true"] .objective-card {
  inset: auto 0 0 auto;
  width: var(--compact-side-width);
  border: 0;
  border-left: 1px solid #4e5857;
  border-top: 1px solid #4e5857;
}
.is-compact .objective-card strong { display: none; }
.is-compact .objective-card p { font-size: 11px; line-height: 1.4; }
.is-compact .story-line, .is-compact .proximity-hint { display: none; }
.is-compact .relay { display: none !important; }
.is-compact.is-chat-open .relay:not([hidden]) {
  position: fixed;
  display: grid !important;
  inset: auto 6px 6px auto;
  width: min(360px, calc(100% - 12px));
  height: auto;
  max-height: calc(var(--visible-height, 100dvh) - 50px);
  overflow: auto;
  grid-template-columns: 1fr;
  border-width: 1px;
  padding: 8px;
  gap: 8px;
}
.is-compact.is-chat-open .relay-head { display: flex; font-size: 10px; }
.is-compact.is-chat-open .log { min-height: 36px; max-height: 70px; overflow: auto; font-size: 11px; }
.is-compact.is-chat-open .log-line { display: block; white-space: normal; }
.is-compact.is-chat-open .chat-form { grid-template-columns: 1fr 44px; }
.is-compact.is-chat-open .chat-form input { min-height: 44px; font-size: 16px; }
.is-compact.is-chat-open .chat-form button { min-height: 44px; }
.is-compact .touch { top: auto; bottom: 8px; left: 8px; transform: none; grid-template-columns: repeat(3, 44px); gap: 3px; }
.is-compact .touch button { min-height: 44px; border-width: 1px; font-size: 15px; }
.is-compact[data-console-open="false"] .objective-card { left: 156px; width: min(340px, calc(100% - 168px)); }
.is-compact .end-overlay { position: fixed; z-index: 30; width: min(430px, calc(100vw - 24px)); max-height: calc(var(--visible-height, 100dvh) - 16px); overflow: auto; }
.is-compact .lobby { max-height: calc(var(--visible-height, 100dvh) - 16px); overflow: auto; }

.diagnostic-normal { color: var(--cyan); font-size: 13px; font-weight: 900; }
.diagnostic-node { min-width: 0; display: grid; align-content: center; gap: 5px; text-align: center !important; }
.diagnostic-node strong { color: var(--ink); font-size: 24px; }
.diagnostic-node span { overflow-wrap: anywhere; font-size: 10px; }
.diagnostic-pattern { display: grid; gap: 5px; text-align: center; }
.diagnostic-pattern span { color: var(--muted); font-size: 10px; }
.diagnostic-pattern strong { color: var(--cyan); font-size: 28px; }
.diagnostic-legend { display: flex; justify-content: space-around; gap: 5px; margin-top: 8px; font-size: 13px; }
.received-clues { display: flex; justify-content: space-between; gap: 5px; margin-bottom: 8px; color: var(--cyan); font-size: 12px; }
.received-clues b { color: var(--yellow); }
.repair-rules { width: 100%; border-collapse: collapse; table-layout: fixed; text-align: center; }
.repair-rules th, .repair-rules td { height: 31px; border: 1px solid #4e5857; padding: 3px; font-size: 19px; }
.repair-rules thead th { height: 23px; color: var(--muted); font-size: 12px; }
.repair-rules tbody th { color: var(--cyan); }
.terminal-modes { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 5px; }
.mode-choice { display: grid; place-items: center; gap: 3px; text-align: center !important; }
.mode-choice b { color: var(--cyan); font-size: 24px; }
.mode-choice span { font-size: 9px; }
.pressure-readout { display: grid; justify-items: center; gap: 8px; }
.pressure-readout > span, .pressure-readout small { font-size: 10px; color: var(--muted); text-align: center; }
.pressure-readout strong { font-size: 24px; color: var(--cyan); }
.pressure-track { position: relative; width: 100%; height: 22px; border: 1px solid #697372; background: #201416; }
.pressure-safe { position: absolute; inset: 0 25%; background: #215d39; }
.pressure-track i { position: absolute; top: -3px; width: 3px; height: 26px; transform: translateX(-50%); background: var(--ink); }
.big-readout.sync-live { border-color: var(--green); }
.big-readout.sync-live > strong { color: var(--green); }
.is-compact .diagnostic-node strong { font-size: 19px; }
.is-compact .diagnostic-node span { font-size: 9px; }
.is-compact .diagnostic-node { padding: 4px 2px; }
.is-compact .received-clues { font-size: 10px; margin-bottom: 5px; }
.is-compact .repair-rules th, .is-compact .repair-rules td { height: 21px; padding: 1px; font-size: 16px; line-height: 1; }
.is-compact .repair-rules thead th { height: 18px; font-size: 10px; }
.is-compact[data-role="scribe"] .intel-content { padding: 4px 8px; }
.is-compact[data-role="scribe"] .action-grid { padding-bottom: 2px; }
.route-target { color: var(--cyan) !important; font-size: 13px !important; font-weight: 900; }
.is-compact .diagnostic-legend { font-size: 12px; }
.is-compact .pressure-readout { gap: 5px; }
