:root {
  color-scheme: dark;
  --ink: #e8e3d5;
  --muted: #a8aa9e;
  --dim: #747b70;
  --night: #090d0b;
  --forest-950: #0c130f;
  --forest-900: #111b15;
  --forest-850: #18231d;
  --forest-800: #1d2c23;
  --forest-700: #2d4335;
  --forest-600: #425a47;
  --amber: #e4aa58;
  --amber-soft: #f1ca83;
  --amber-dark: #8d622c;
  --rust: #a65338;
  --red: #d3604c;
  --green: #8db68e;
  --blue: #7aa5aa;
  --panel: rgba(12, 18, 14, 0.97);
  --line: rgba(232, 227, 213, 0.17);
  --line-strong: rgba(232, 227, 213, 0.32);
  --shadow: 0 24px 90px rgba(0, 0, 0, 0.6);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  /* Runtime measurements use viewport-top coordinates and override these fallbacks. */
  --mobile-hud-bottom: calc(var(--safe-top) + 196px);
  --mobile-controls-top: calc(100dvh - var(--safe-bottom) - 221px);
  font-family: "Arial Narrow", "Roboto Condensed", "Helvetica Neue", Arial, sans-serif;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--night);
  overscroll-behavior: none;
}

body {
  color: var(--ink);
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
}

button,
input,
select {
  font: inherit;
}

button {
  color: inherit;
}

button:not(:disabled) {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 3px solid var(--amber-soft);
  outline-offset: 3px;
}

.hidden {
  display: none !important;
}

.game-shell {
  position: relative;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  min-height: 320px;
  overflow: hidden;
  background: #18251c;
  touch-action: pinch-zoom;
  isolation: isolate;
}

.game-shell.panel-open {
  touch-action: pan-y pinch-zoom;
}

#game-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  background: #243628;
  touch-action: none;
}

.scanlines {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 2;
  opacity: 0.07;
  background: repeating-linear-gradient(to bottom, transparent 0, transparent 3px, rgba(0, 0, 0, 0.35) 4px);
  mix-blend-mode: multiply;
}

.danger-vignette {
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  opacity: 0;
  background: radial-gradient(circle at center, transparent 35%, rgba(129, 25, 19, 0.58) 100%);
  transition: opacity 160ms ease;
}

.danger-vignette.active {
  opacity: 0.9;
}

.hud {
  position: absolute;
  inset: 0;
  z-index: 5;
  pointer-events: none;
  padding: calc(16px + var(--safe-top)) calc(18px + var(--safe-right)) calc(16px + var(--safe-bottom)) calc(18px + var(--safe-left));
}

.hud-objective {
  position: absolute;
  top: calc(18px + var(--safe-top));
  left: calc(20px + var(--safe-left));
  max-width: min(470px, 54vw);
  padding: 12px 15px 12px 18px;
  border-left: 3px solid var(--amber);
  background: linear-gradient(90deg, rgba(8, 13, 10, 0.94), rgba(8, 13, 10, 0.68));
  text-shadow: 0 2px 5px #000;
}

.objective-heading {
  display: flex;
  gap: 14px;
  align-items: center;
  justify-content: space-between;
}

.objective-end-goal {
  color: rgba(232, 227, 213, .68);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .1em;
  white-space: nowrap;
}

.eyebrow {
  color: var(--amber-soft);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.objective-text {
  margin-top: 4px;
  font-size: clamp(15px, 2vw, 20px);
  font-weight: 750;
  letter-spacing: 0.015em;
}

.objective-detail {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.objective-route {
  width: max-content;
  max-width: 100%;
  margin-top: 8px;
  padding: 4px 7px;
  border: 1px solid rgba(228, 170, 88, .34);
  background: rgba(5, 10, 8, .62);
  color: var(--amber-soft);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .08em;
  line-height: 1.35;
  text-transform: uppercase;
}

.time-widget {
  display: flex;
  gap: 7px;
  align-items: center;
  width: max-content;
  margin-top: 9px;
  padding: 5px 8px;
  border: 1px solid rgba(232, 227, 213, .15);
  background: rgba(5, 10, 8, .54);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  text-shadow: none;
}

.time-widget > span {
  color: var(--amber-soft);
  font-size: 15px;
}

.time-widget b {
  min-width: 40px;
  color: var(--ink);
  font-size: 11px;
  letter-spacing: .04em;
}

.time-widget small {
  color: var(--muted);
  font-size: 8px;
  letter-spacing: .1em;
}

.time-widget[data-phase="night"] {
  border-color: rgba(122, 165, 170, .35);
  background: rgba(4, 9, 17, .76);
}

.time-widget[data-phase="night"] > span,
.time-widget[data-phase="night"] small {
  color: #a8c1ca;
}

.hud-vitals {
  position: absolute;
  top: calc(18px + var(--safe-top));
  right: calc(18px + var(--safe-right));
  display: grid;
  grid-template-columns: auto repeat(4, 42px);
  gap: 7px 10px;
  align-items: center;
  padding: 10px;
  background: rgba(8, 13, 10, 0.9);
  border: 1px solid var(--line);
  backdrop-filter: blur(6px);
}

.hud-vitals-drawer {
  display: contents;
}

.mobile-hud-toggle {
  display: none;
}

.vital {
  grid-column: 1;
  display: grid;
  grid-template-columns: 16px 96px 36px;
  gap: 7px;
  align-items: center;
  min-height: 12px;
}

.weapon-vital {
  grid-template-columns: 16px minmax(96px, 1fr);
  min-height: 27px;
  padding-top: 2px;
  border-top: 1px solid var(--line);
}

.weapon-vital > span:last-child {
  display: flex;
  gap: 8px;
  align-items: baseline;
  justify-content: space-between;
  min-width: 0;
}

.weapon-vital b {
  overflow: hidden;
  color: var(--ink);
  font-size: 10px;
  letter-spacing: .08em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.weapon-vital small {
  flex: 0 0 auto;
  color: var(--amber-soft);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 9px;
}

.vital-icon {
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

.meter {
  position: relative;
  display: block;
  width: 96px;
  height: 7px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.09);
}

.meter i {
  position: absolute;
  inset: 0 auto 0 0;
  width: 100%;
  background: var(--ink);
  transition: width 180ms linear, background 180ms ease;
}

.meter.stamina i {
  background: var(--green);
}

.meter.battery i {
  background: var(--amber);
}

.meter.flashlight i {
  background: #d8c98f;
}

.flashlight-vital {
  grid-template-columns: 16px 82px 50px;
}

.flashlight-vital .meter {
  width: 82px;
}

.flashlight-vital .vital-value {
  font-size: 9px;
}

.flashlight-vital[data-condition="worn"] .meter.flashlight i {
  background: var(--amber);
}

.flashlight-vital[data-condition="critical"] .meter.flashlight i {
  background: var(--red);
}

.vital-value {
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11px;
  text-align: right;
}

.icon-button {
  grid-row: 1 / span 2;
  width: 42px;
  height: 42px;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.04);
  pointer-events: auto;
}

.quick-music {
  grid-column: 2;
}

#help-btn {
  grid-column: 3;
}

#settings-btn {
  grid-column: 4;
}

#mute-btn {
  grid-column: 5;
}

.quick-music[aria-pressed="true"] {
  color: #17120b;
  border-color: var(--amber);
  background: var(--amber);
}

.icon-button[aria-pressed="true"] {
  color: var(--red);
  border-color: rgba(211, 96, 76, 0.65);
}

.quick-volume {
  grid-row: 3 / span 2;
  grid-column: 2 / 6;
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) 40px;
  gap: 6px;
  align-items: stretch;
  min-height: 48px;
  padding: 5px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.025);
  pointer-events: auto;
}

.quick-volume:hover,
.quick-volume:focus-within {
  border-color: var(--amber-dark);
  background: rgba(228, 170, 88, 0.055);
}

.quick-volume > button {
  min-width: 0;
  border: 1px solid var(--line-strong);
  background: rgba(255, 255, 255, 0.055);
  color: var(--amber-soft);
  font-size: 21px;
  line-height: 1;
}

.quick-volume > button:hover,
.quick-volume > button:active {
  border-color: var(--amber);
  background: rgba(228, 170, 88, 0.14);
}

.quick-volume-readout {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-rows: auto auto;
  gap: 0 7px;
  align-content: center;
  min-width: 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.quick-volume-readout span {
  align-self: end;
  color: var(--muted);
  font-size: 8px;
  font-weight: 800;
  letter-spacing: .12em;
}

.quick-volume-readout output {
  grid-row: 1 / 3;
  grid-column: 2;
  align-self: center;
  color: var(--ink);
  font-size: 13px;
  font-weight: 800;
}

.quick-volume-readout small {
  align-self: start;
  color: var(--dim);
  font-size: 7px;
  letter-spacing: .1em;
}

.noise-widget {
  position: absolute;
  right: calc(20px + var(--safe-right));
  bottom: calc(122px + var(--safe-bottom));
  display: flex;
  gap: 8px;
  align-items: flex-end;
  color: rgba(232, 227, 213, 0.66);
  font-size: 9px;
  letter-spacing: 0.13em;
  text-shadow: 0 1px 3px #000;
}

.noise-bars {
  display: flex;
  gap: 3px;
  align-items: flex-end;
  height: 16px;
}

.noise-bars i {
  display: block;
  width: 4px;
  height: 5px;
  background: rgba(232, 227, 213, 0.2);
  transition: height 120ms, background 120ms;
}

.noise-bars i:nth-child(2) { height: 8px; }
.noise-bars i:nth-child(3) { height: 12px; }
.noise-bars i:nth-child(4) { height: 16px; }
.noise-bars i.active { background: var(--amber-soft); }

.context-prompt {
  position: absolute;
  left: 50%;
  bottom: calc(92px + var(--safe-bottom));
  transform: translateX(-50%);
  display: flex;
  gap: 9px;
  align-items: center;
  padding: 9px 14px;
  border: 1px solid var(--line-strong);
  background: rgba(8, 13, 10, 0.88);
  box-shadow: 0 5px 20px rgba(0, 0, 0, 0.35);
  font-size: 13px;
  letter-spacing: 0.04em;
}

.keycap,
kbd {
  display: inline-grid;
  min-width: 25px;
  height: 25px;
  place-items: center;
  border: 1px solid var(--line-strong);
  border-bottom-width: 2px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.07);
  color: var(--amber-soft);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
}

.quick-nav {
  position: absolute;
  left: 50%;
  bottom: calc(18px + var(--safe-bottom));
  display: flex;
  gap: 8px;
  transform: translateX(-50%);
  pointer-events: auto;
}

.tool-button {
  min-width: 108px;
  height: 54px;
  display: grid;
  grid-template-columns: 28px auto 22px;
  gap: 6px;
  align-items: center;
  padding: 7px 9px;
  border: 1px solid var(--line);
  background: rgba(8, 13, 10, 0.92);
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(6px);
}

.tool-button:hover,
.tool-button:active {
  border-color: var(--amber-dark);
  background: rgba(28, 39, 31, 0.92);
}

.flashlight-button[aria-pressed="true"] {
  color: #17120b;
  border-color: #e8d99d;
  background: rgba(232, 217, 157, .88);
}

.flashlight-button[aria-pressed="true"] > span,
.flashlight-button[aria-pressed="true"] kbd {
  color: #17120b;
}

.tool-button > span {
  color: var(--amber-soft);
  font-size: 22px;
}

.tool-button b {
  font-size: 11px;
  letter-spacing: 0.12em;
}

.tool-button kbd {
  min-width: 20px;
  height: 20px;
  color: var(--muted);
  font-size: 9px;
}

.mobile-controls {
  position: absolute;
  inset: 0;
  z-index: 7;
  pointer-events: none;
  touch-action: none;
}

.joystick {
  position: absolute;
  left: calc(22px + var(--safe-left));
  bottom: calc(22px + var(--safe-bottom));
  width: 126px;
  height: 126px;
  border-radius: 50%;
  pointer-events: auto;
  touch-action: none;
}

.joystick-ring {
  position: absolute;
  inset: 8px;
  border: 1px solid rgba(232, 227, 213, 0.3);
  border-radius: 50%;
  background: rgba(8, 13, 10, 0.3);
  box-shadow: inset 0 0 0 18px rgba(8, 13, 10, 0.08);
}

.joystick-knob {
  position: absolute;
  left: 38px;
  top: 38px;
  width: 50px;
  height: 50px;
  border: 1px solid rgba(241, 202, 131, 0.65);
  border-radius: 50%;
  background: rgba(228, 170, 88, 0.24);
  box-shadow: 0 5px 16px rgba(0, 0, 0, 0.4);
  transform: translate(0, 0);
}

.mobile-action {
  position: absolute;
  right: calc(24px + var(--safe-right));
  bottom: calc(28px + var(--safe-bottom));
  width: 94px;
  height: 94px;
  border: 2px solid rgba(241, 202, 131, 0.72);
  border-radius: 50%;
  background: rgba(119, 77, 34, 0.7);
  box-shadow: inset 0 0 0 7px rgba(8, 13, 10, 0.23), 0 8px 24px rgba(0, 0, 0, 0.42);
  pointer-events: auto;
  touch-action: none;
}

.mobile-attack {
  position: absolute;
  right: calc(126px + var(--safe-right));
  bottom: calc(35px + var(--safe-bottom));
  width: 76px;
  height: 76px;
  border: 2px solid rgba(211, 96, 76, .78);
  border-radius: 50%;
  background: rgba(111, 41, 31, .76);
  box-shadow: inset 0 0 0 6px rgba(8, 13, 10, .25), 0 8px 24px rgba(0, 0, 0, .42);
  pointer-events: auto;
  touch-action: none;
}

.mobile-attack span {
  font-size: 10px;
  font-weight: 850;
  letter-spacing: .07em;
}

.mobile-attack:active,
.mobile-attack.charging,
.mobile-attack[aria-pressed="true"] {
  transform: scale(.96);
  border-color: #f19b83;
  background: rgba(151, 55, 39, .9);
}

.mobile-action span {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.mobile-action:active {
  transform: scale(0.96);
  background: rgba(159, 103, 43, 0.8);
}

.mobile-tools {
  position: absolute;
  right: calc(24px + var(--safe-right));
  bottom: calc(138px + var(--safe-bottom));
  display: flex;
  gap: 8px;
  pointer-events: auto;
}

.mobile-tools button {
  width: 50px;
  height: 50px;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  background: rgba(8, 13, 10, 0.76);
  color: var(--amber-soft);
  font-size: 20px;
  backdrop-filter: blur(5px);
}

.mobile-tools button:active,
.mobile-tools button[aria-pressed="true"] {
  transform: scale(.94);
  border-color: var(--amber);
  background: rgba(228, 170, 88, .22);
}

#mobile-flashlight[aria-pressed="true"] {
  color: #17120b;
  border-color: #e8d99d;
  background: rgba(232, 217, 157, .9);
}

/*
 * JavaScript and CSS use the same touch-capability decision. This prevents a
 * hybrid touchscreen with a fine primary pointer from showing both toolbars.
 */
.touch-ui .quick-nav,
.touch-ui .noise-widget,
.touch-ui .context-prompt,
.touch-ui .quick-music,
.touch-ui .quick-volume {
  display: none;
}

.mobile-hud-mode .hud-vitals {
  position: relative;
  inset: auto;
  grid-template-columns: auto repeat(3, 44px);
  max-height: 220px;
  overflow: hidden;
  transition:
    max-height 220ms ease,
    padding 220ms ease,
    border-color 160ms ease,
    background-color 160ms ease;
}

.mobile-hud-mode .hud-vitals-drawer {
  position: absolute;
  top: calc(18px + var(--safe-top));
  right: calc(18px + var(--safe-right));
  display: block;
  pointer-events: none;
}

.mobile-hud-mode .hud-vitals > * {
  transition: opacity 140ms ease;
}

.mobile-hud-mode .hud-vitals.is-collapsed {
  max-height: 0;
  padding-top: 0;
  padding-bottom: 0;
  border-color: transparent;
  background: transparent;
  backdrop-filter: none;
}

.mobile-hud-mode .hud-vitals.is-collapsed > * {
  opacity: 0;
  pointer-events: none;
}

.mobile-hud-mode .mobile-hud-toggle {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  display: inline-flex;
  gap: 6px;
  align-items: center;
  justify-content: center;
  min-width: 86px;
  height: 36px;
  padding: 0 11px;
  border: 1px solid var(--line-strong);
  border-radius: 0 0 4px 4px;
  background: rgba(8, 13, 10, .9);
  box-shadow: 0 5px 16px rgba(0, 0, 0, .28);
  color: var(--amber-soft);
  pointer-events: auto;
  touch-action: manipulation;
}

.mobile-hud-mode .mobile-hud-toggle span {
  font-size: 17px;
  line-height: 1;
}

.mobile-hud-mode .mobile-hud-toggle b {
  font-size: 9px;
  letter-spacing: .12em;
}

.mobile-hud-mode .mobile-hud-toggle:active {
  border-color: var(--amber);
  background: rgba(228, 170, 88, .18);
}

.mobile-hud-mode .quick-music,
.mobile-hud-mode .quick-volume {
  display: none;
}

.mobile-hud-mode #help-btn { grid-column: 2; }
.mobile-hud-mode #settings-btn { grid-column: 3; }
.mobile-hud-mode #mute-btn { grid-column: 4; }

.screen,
.panel,
.dialog-panel {
  position: absolute;
  inset: 0;
  z-index: 20;
}

.screen,
.panel,
.dialog-panel {
  padding: calc(20px + var(--safe-top)) calc(20px + var(--safe-right)) calc(20px + var(--safe-bottom)) calc(20px + var(--safe-left));
}

.screen {
  display: grid;
  place-items: center;
  background: rgba(4, 7, 5, 0.94);
}

.start-screen {
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  touch-action: pan-y pinch-zoom;
  -webkit-overflow-scrolling: touch;
  background:
    linear-gradient(90deg, rgba(7, 11, 8, 0.96) 0%, rgba(7, 11, 8, 0.79) 45%, rgba(7, 11, 8, 0.22) 75%),
    radial-gradient(circle at 78% 30%, rgba(227, 162, 80, 0.22), transparent 28%),
    linear-gradient(150deg, #233626 0%, #0d1510 48%, #050806 100%);
}

.start-screen::before,
.start-screen::after {
  content: "";
  position: absolute;
  pointer-events: none;
}

.start-screen::before {
  right: 7vw;
  bottom: -8vh;
  width: min(38vw, 520px);
  height: min(78vh, 700px);
  opacity: 0.43;
  background:
    linear-gradient(90deg, transparent 48%, #bd8848 49%, #bd8848 51%, transparent 52%) center 18% / 100% 62% no-repeat,
    linear-gradient(28deg, transparent 48%, #bd8848 49%, #bd8848 51%, transparent 52%) center 32% / 90% 40% no-repeat,
    linear-gradient(-28deg, transparent 48%, #bd8848 49%, #bd8848 51%, transparent 52%) center 32% / 90% 40% no-repeat,
    linear-gradient(90deg, transparent 35%, rgba(10, 19, 13, 0.9) 36%, rgba(10, 19, 13, 0.9) 64%, transparent 65%) center bottom / 85% 48% no-repeat;
  filter: drop-shadow(0 0 35px rgba(228, 170, 88, 0.18));
}

.start-screen::after {
  inset: 0;
  opacity: 0.1;
  background-image: linear-gradient(113deg, transparent 45%, rgba(255, 255, 255, 0.18) 46%, transparent 47%);
  background-size: 88px 100%;
}

.start-noise {
  position: absolute;
  inset: -40%;
  opacity: 0.045;
  background-image: repeating-radial-gradient(circle, #fff 0, #fff 1px, transparent 1px, transparent 5px);
  background-size: 9px 9px;
  animation: static-shift 550ms steps(2) infinite;
}

@keyframes static-shift {
  to { transform: translate(8px, -7px); }
}

.start-content {
  position: relative;
  z-index: 1;
  width: min(620px, 88vw);
  margin-right: min(36vw, 480px);
}

.start-content h1 {
  margin: 11px 0 0;
  font-size: clamp(58px, 10vw, 132px);
  line-height: 0.75;
  letter-spacing: -0.065em;
  text-transform: uppercase;
  text-shadow: 0 8px 50px #000;
}

.start-content h1 span {
  color: transparent;
  -webkit-text-stroke: 1px rgba(232, 227, 213, 0.65);
}

.chapter {
  margin: 22px 0 18px;
  color: var(--amber-soft);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 14px;
  letter-spacing: 0.5em;
}

.start-copy {
  max-width: 570px;
  color: #c7c6bb;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(15px, 2vw, 19px);
  line-height: 1.55;
}

.start-actions,
.end-actions,
.dialog-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 25px;
}

.primary-button,
.secondary-button {
  min-height: 48px;
  padding: 0 22px;
  border: 1px solid var(--amber);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.12em;
}

.primary-button {
  background: var(--amber);
  color: #15110b;
}

.primary-button:hover,
.primary-button:active {
  background: var(--amber-soft);
}

.secondary-button {
  background: rgba(12, 18, 14, 0.7);
  color: var(--ink);
}

.secondary-button:hover,
.secondary-button:active {
  background: rgba(232, 227, 213, 0.12);
}

.start-note {
  max-width: 520px;
  margin-top: 14px;
  color: var(--dim);
  font-size: 11px;
  line-height: 1.45;
}

.start-footer {
  position: absolute;
  right: calc(22px + var(--safe-right));
  bottom: calc(18px + var(--safe-bottom));
  left: calc(22px + var(--safe-left));
  display: flex;
  justify-content: space-between;
  color: rgba(232, 227, 213, 0.4);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 10px;
  letter-spacing: 0.12em;
}

.trait-screen {
  overflow: hidden;
  background:
    linear-gradient(115deg, rgba(7, 11, 8, .98), rgba(7, 11, 8, .77)),
    repeating-linear-gradient(125deg, transparent 0 86px, rgba(228, 170, 88, .04) 87px 88px),
    #17251b;
}

.trait-screen::before {
  content: "K-12 // PREPARATION";
  position: absolute;
  top: 9vh;
  right: -4vw;
  color: rgba(232, 227, 213, .025);
  font-size: clamp(60px, 12vw, 160px);
  font-weight: 900;
  letter-spacing: -.06em;
  white-space: nowrap;
}

.trait-card {
  position: relative;
  z-index: 1;
  width: min(1020px, 96vw);
  max-height: calc(100dvh - 32px - var(--safe-top) - var(--safe-bottom));
  overflow: auto;
  padding: clamp(24px, 4vw, 48px);
  border: 1px solid var(--line-strong);
  background: rgba(10, 16, 12, .94);
  box-shadow: var(--shadow);
  touch-action: pan-y pinch-zoom;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.trait-card > h2 {
  margin: 7px 0 8px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(30px, 5vw, 52px);
  font-weight: 400;
  line-height: 1.05;
}

.trait-card > p {
  max-width: 620px;
  margin: 0;
  color: var(--muted);
  font-family: Georgia, "Times New Roman", serif;
  line-height: 1.5;
}

.customization-group {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  max-width: 620px;
  margin-top: 20px;
}

.custom-input-label {
  display: grid;
  gap: 7px;
  min-width: 0;
  color: var(--muted);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: .12em;
}

.custom-input-label input,
.custom-input-label select {
  width: 100%;
  min-width: 0;
  min-height: 48px;
  padding: 12px 13px;
  border: 1px solid var(--line-strong);
  border-radius: 0;
  background: rgba(255, 255, 255, .045);
  color: var(--ink);
  font-size: 16px;
}

.custom-input-label select {
  color-scheme: dark;
}

.custom-input-label:focus-within {
  color: var(--amber-soft);
}

.custom-input-label input[aria-invalid="true"] {
  border-color: var(--red);
  box-shadow: 0 0 0 1px rgba(188, 75, 62, .28);
}

.input-error {
  color: #e4a399;
  font-size: 11px;
  font-weight: 650;
  letter-spacing: .015em;
  line-height: 1.35;
}

.protagonist-name {
  text-transform: none;
}

.trait-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: clamp(20px, 4vw, 34px);
}

.trait-grid button {
  position: relative;
  display: flex;
  min-height: 190px;
  flex-direction: column;
  align-items: flex-start;
  justify-content: flex-end;
  padding: 22px 18px;
  overflow: hidden;
  border: 1px solid var(--line);
  background:
    linear-gradient(180deg, transparent, rgba(0, 0, 0, .38)),
    rgba(255, 255, 255, .025);
  text-align: left;
}

.trait-grid button::before {
  content: attr(data-trait);
  position: absolute;
  top: 4px;
  right: 10px;
  color: rgba(228, 170, 88, .09);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 46px;
  font-weight: 900;
  letter-spacing: -.08em;
  text-transform: uppercase;
}

.trait-grid button:hover,
.trait-grid button:active,
.trait-grid button:focus-visible {
  border-color: var(--amber);
  background:
    linear-gradient(180deg, rgba(228, 170, 88, .03), rgba(117, 74, 31, .2)),
    rgba(255, 255, 255, .035);
}

.trait-grid b,
.trait-grid span,
.trait-grid small {
  position: relative;
  z-index: 1;
  display: block;
}

.trait-grid b {
  color: var(--amber-soft);
  font-size: 14px;
  letter-spacing: .1em;
}

.trait-grid span {
  margin-top: 13px;
  color: var(--ink);
  font-size: 13px;
  line-height: 1.4;
}

.trait-grid small {
  margin-top: 7px;
  color: #d4846e;
  font-size: 11px;
  line-height: 1.35;
}

.intro-screen {
  place-items: end start;
  overflow: hidden;
  opacity: 1;
  background:
    radial-gradient(circle at 73% 24%, rgba(244, 187, 104, .28), transparent 19%),
    linear-gradient(180deg, #b06f45 0%, #514d3f 39%, #16231a 40%, #070b08 100%);
  transition: opacity 280ms ease;
}

.intro-screen.is-exiting {
  opacity: 0;
  pointer-events: none;
}

.intro-screen::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background: linear-gradient(90deg, rgba(4, 7, 5, .74), transparent 58%), linear-gradient(0deg, rgba(4, 7, 5, .84), transparent 53%);
}

.cinematic-panorama {
  position: absolute;
  inset: 0;
  overflow: hidden;
  transform: scale(1.08) translate3d(2.5%, 1.5%, 0);
  filter: brightness(.76) saturate(.82);
  transition: transform 620ms cubic-bezier(.22, .61, .36, 1), filter 620ms ease;
}

.cinematic-panorama::before,
.cinematic-panorama::after,
.cinematic-panorama i {
  position: absolute;
  bottom: -4%;
  display: block;
  transform-origin: center bottom;
  clip-path: polygon(0 100%, 18% 67%, 31% 73%, 48% 34%, 59% 55%, 70% 43%, 100% 100%);
}

.cinematic-panorama::before,
.cinematic-panorama::after {
  content: "";
  left: -8%;
  width: 118%;
}

.cinematic-panorama::before {
  height: 62%;
  background: #2d4130;
  opacity: .9;
  animation: cinematic-drift 18s ease-in-out infinite alternate;
}

.cinematic-panorama::after {
  height: 43%;
  background: #101a13;
  clip-path: polygon(0 100%, 11% 56%, 28% 78%, 41% 45%, 61% 84%, 76% 48%, 100% 77%, 100% 100%);
}

.cinematic-panorama i:nth-child(1) {
  right: 14%;
  bottom: 22%;
  z-index: 1;
  width: 3px;
  height: 47%;
  background: #161b15;
  clip-path: none;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, .25);
}

.cinematic-panorama i:nth-child(1)::before,
.cinematic-panorama i:nth-child(1)::after {
  content: "";
  position: absolute;
  left: 50%;
  width: 72px;
  height: 2px;
  background: #161b15;
  transform-origin: left;
}

.cinematic-panorama i:nth-child(1)::before { top: 16%; transform: rotate(21deg); }
.cinematic-panorama i:nth-child(1)::after { top: 16%; transform: rotate(-201deg); }

.cinematic-panorama i:nth-child(2) {
  right: 5%;
  bottom: 0;
  width: 28%;
  height: 54%;
  background: rgba(8, 13, 10, .72);
  clip-path: polygon(7% 100%, 24% 15%, 46% 9%, 60% 24%, 77% 100%);
}

.cinematic-panorama i:nth-child(3),
.cinematic-panorama i:nth-child(4) {
  bottom: -8%;
  width: 7%;
  height: 55%;
  background: #0a100c;
  clip-path: polygon(47% 0, 55% 44%, 100% 100%, 0 100%, 42% 44%);
}

.cinematic-panorama i:nth-child(3) { left: 8%; }
.cinematic-panorama i:nth-child(4) { left: 25%; height: 38%; opacity: .82; }

.cinematic-panorama i,
.cinematic-radio,
.cinematic-solar,
.cinematic-wave,
.cinematic-relay,
.cinematic-signal {
  transition: opacity 620ms ease, transform 620ms cubic-bezier(.22, .61, .36, 1);
}

.cinematic-radio {
  position: absolute;
  right: 17%;
  bottom: 18%;
  z-index: 2;
  width: 92px;
  height: 56px;
  border: 2px solid rgba(220, 202, 152, .55);
  background:
    linear-gradient(90deg, transparent 0 62%, rgba(220, 202, 152, .22) 62% 64%, transparent 64%),
    rgba(7, 12, 9, .82);
  box-shadow: 0 18px 30px rgba(0, 0, 0, .25);
  opacity: .84;
  transform: rotate(-3deg);
}

.cinematic-radio::before {
  content: "";
  position: absolute;
  left: 11px;
  top: 12px;
  width: 38px;
  height: 20px;
  border: 1px solid rgba(141, 182, 142, .5);
  background: repeating-linear-gradient(0deg, rgba(141, 182, 142, .08) 0 1px, transparent 1px 4px);
}

.cinematic-radio::after {
  content: "";
  position: absolute;
  right: 12px;
  top: -46px;
  width: 2px;
  height: 47px;
  background: rgba(220, 202, 152, .48);
  transform: rotate(8deg);
  transform-origin: bottom;
}

.cinematic-radio b {
  position: absolute;
  left: 17px;
  top: 15px;
  color: rgba(190, 219, 185, .82);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 9px;
  letter-spacing: .08em;
}

.cinematic-solar {
  position: absolute;
  right: 25%;
  bottom: 21%;
  z-index: 2;
  width: 148px;
  height: 76px;
  border: 2px solid rgba(235, 216, 166, .78);
  background:
    repeating-linear-gradient(90deg, transparent 0 23px, rgba(235, 216, 166, .52) 23px 24px),
    repeating-linear-gradient(0deg, rgba(75, 112, 82, .5) 0 18px, rgba(235, 216, 166, .48) 18px 19px);
  box-shadow: 0 22px 34px rgba(0, 0, 0, .28);
  filter: drop-shadow(0 0 9px rgba(228, 170, 88, .22));
  mix-blend-mode: screen;
  opacity: .96;
  transform: perspective(240px) rotateX(58deg) rotateZ(-7deg);
  transform-origin: center bottom;
}

.cinematic-solar::before {
  content: "SOLAR // CHARGING";
  position: absolute;
  left: 7px;
  top: -22px;
  color: rgba(245, 224, 174, .94);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 9px;
  letter-spacing: .12em;
  white-space: nowrap;
}

.cinematic-solar::after {
  content: "";
  position: absolute;
  right: -49px;
  top: 38px;
  width: 49px;
  height: 1px;
  background: rgba(220, 202, 152, .4);
  transform: rotate(-12deg);
  transform-origin: left;
}

.cinematic-wave,
.cinematic-relay {
  position: absolute;
  right: 7%;
  top: auto;
  bottom: 37%;
  z-index: 2;
  width: 230px;
  opacity: 0;
  transform: translate3d(16px, 0, 0);
}

.cinematic-wave {
  height: 82px;
  filter: drop-shadow(0 0 9px rgba(228, 170, 88, .3));
  mix-blend-mode: screen;
}

.cinematic-wave::before,
.cinematic-relay::before {
  position: absolute;
  left: 0;
  top: -24px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 10px;
  letter-spacing: .13em;
  white-space: nowrap;
}

.cinematic-wave::before {
  content: "TRACK 01 // PLAYING";
  color: rgba(243, 205, 145, .82);
}

.cinematic-wave::after {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(228, 170, 88, .72);
  clip-path: polygon(0 50%, 5% 43%, 9% 56%, 14% 30%, 19% 69%, 24% 42%, 29% 54%, 35% 17%, 40% 82%, 46% 38%, 51% 60%, 57% 27%, 62% 72%, 68% 45%, 73% 55%, 79% 35%, 84% 65%, 90% 46%, 95% 54%, 100% 50%, 100% 53%, 95% 57%, 90% 49%, 84% 69%, 79% 39%, 73% 59%, 68% 49%, 62% 76%, 57% 31%, 51% 64%, 46% 42%, 40% 86%, 35% 21%, 29% 58%, 24% 46%, 19% 73%, 14% 34%, 9% 60%, 5% 47%, 0 53%);
}

.cinematic-relay {
  height: 94px;
  border-left: 2px solid rgba(198, 218, 194, .76);
  filter: drop-shadow(0 0 8px rgba(164, 184, 160, .2));
  mix-blend-mode: screen;
}

.cinematic-relay::before {
  content: "K-12 // NO CARRIER";
  left: 13px;
  color: rgba(218, 231, 214, .94);
}

.cinematic-relay::after {
  content: "";
  position: absolute;
  left: 13px;
  right: 0;
  top: 45px;
  height: 1px;
  background: rgba(205, 224, 201, .88);
  box-shadow: 0 0 12px rgba(164, 184, 160, .2);
}

.cinematic-signal {
  position: absolute;
  right: 7%;
  top: auto;
  bottom: 37%;
  z-index: 2;
  width: 178px;
  height: 74px;
  border-left: 2px solid rgba(182, 222, 180, .86);
  filter: drop-shadow(0 0 9px rgba(141, 182, 142, .22));
  mix-blend-mode: screen;
  opacity: 0;
  transform: translate3d(16px, 0, 0);
}

.cinematic-signal::before {
  content: "101.7";
  position: absolute;
  left: 13px;
  top: -5px;
  color: rgba(218, 241, 213, .94);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 26px;
  letter-spacing: .08em;
}

.cinematic-signal::after {
  content: "";
  position: absolute;
  left: 13px;
  right: 0;
  bottom: 13px;
  height: 2px;
  background:
    linear-gradient(90deg, transparent, rgba(182, 222, 180, .95) 11%, transparent 14%, rgba(182, 222, 180, .68) 31%, transparent 38%, rgba(182, 222, 180, .92) 63%, transparent 69%);
  box-shadow: 0 0 10px rgba(141, 182, 142, .28);
  animation: intro-signal-breathe 2.4s ease-in-out infinite alternate;
}

.intro-screen[data-scene="music"] .cinematic-panorama {
  transform: scale(1.015) translate3d(-1.5%, 0, 0);
  filter: brightness(1.02) saturate(1.08);
}

.intro-screen[data-scene="music"] .cinematic-radio {
  opacity: .8;
  transform: rotate(-3deg) translate3d(-8px, 2px, 0);
}

.intro-screen[data-scene="music"] .cinematic-solar {
  opacity: .12;
  transform: perspective(240px) rotateX(58deg) rotateZ(-7deg) translate3d(-12px, 7px, 0);
}

.intro-screen[data-scene="music"] .cinematic-wave {
  opacity: .9;
  transform: translate3d(0, 0, 0);
}

.intro-screen[data-scene="silence"] .cinematic-panorama {
  transform: scale(1.045) translate3d(-2.5%, 1%, 0);
  filter: grayscale(.42) brightness(.7) saturate(.72);
}

.intro-screen[data-scene="silence"] .cinematic-radio {
  opacity: .12;
  transform: rotate(-3deg) translate3d(-16px, 5px, 0);
}

.intro-screen[data-scene="silence"] .cinematic-solar,
.intro-screen[data-scene="carrier"] .cinematic-solar {
  opacity: 0;
  transform: perspective(240px) rotateX(58deg) rotateZ(-7deg) translate3d(-18px, 10px, 0);
}

.intro-screen[data-scene="silence"] .cinematic-relay {
  opacity: .96;
  transform: translate3d(0, 0, 0);
}

.intro-screen[data-scene="carrier"] .cinematic-panorama {
  transform: scale(1.09) translate3d(-3.5%, -1%, 0);
  filter: brightness(.68) contrast(1.12) saturate(.7);
}

.intro-screen[data-scene="carrier"] .cinematic-radio {
  opacity: .18;
  transform: rotate(-3deg) translate3d(-20px, 5px, 0);
}

.intro-screen[data-scene="carrier"] .cinematic-signal {
  opacity: 1;
  transform: translate3d(0, 0, 0);
}

@keyframes cinematic-drift {
  to { transform: scale(1.035) translate3d(-1.5%, 0, 0); }
}

@keyframes intro-signal-breathe {
  to { opacity: .46; transform: scaleX(.96); }
}

.cinematic-grain {
  position: absolute;
  inset: -35%;
  z-index: 1;
  opacity: .07;
  background-image: repeating-radial-gradient(circle, #fff 0 1px, transparent 1px 5px);
  background-size: 11px 11px;
  animation: static-shift 620ms steps(2) infinite;
  mix-blend-mode: overlay;
}

.intro-card {
  position: relative;
  z-index: 3;
  width: min(650px, 92vw);
  max-height: calc(100dvh - 32px - var(--safe-top) - var(--safe-bottom));
  overflow: auto;
  padding: clamp(24px, 5vw, 50px);
  border-left: 3px solid var(--amber);
  background: linear-gradient(90deg, rgba(7, 11, 8, .94), rgba(7, 11, 8, .64) 74%, transparent);
  box-shadow: -26px 26px 80px rgba(0, 0, 0, .34);
  touch-action: pan-y pinch-zoom;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.intro-card h2 {
  margin: 9px 0 15px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(29px, 5vw, 50px);
  font-weight: 400;
  line-height: 1.05;
}

.intro-card p {
  max-width: 560px;
  min-height: 3.2em;
  color: #d5d1c2;
  font-family: Georgia, "Times New Roman", serif;
  line-height: 1.6;
}

/*
 * Beat text changes after the short exit completes. Keeping all three text
 * elements on one class prevents the heading and copy from drifting apart.
 */
.intro-card .intro-beat > .eyebrow,
.intro-card .intro-beat > h2,
.intro-card .intro-beat > p {
  opacity: 1;
  transform: translateY(0);
  transition: opacity 320ms ease, transform 320ms ease;
}

.intro-card.is-beat-exiting .intro-beat > .eyebrow,
.intro-card.is-beat-exiting .intro-beat > h2,
.intro-card.is-beat-exiting .intro-beat > p {
  opacity: 0;
  transform: translateY(6px);
}

.intro-card.is-beat-entering .intro-beat > .eyebrow,
.intro-card.is-beat-entering .intro-beat > h2,
.intro-card.is-beat-entering .intro-beat > p {
  animation: intro-beat-in 540ms cubic-bezier(.22, .61, .36, 1) both;
}

@keyframes intro-beat-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
}

.intro-progress {
  margin: 22px 0 18px;
  display: flex;
  align-items: center;
  gap: 13px;
}

.intro-progress > span:first-child {
  flex: 0 0 auto;
  color: var(--amber-soft);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .12em;
}

.intro-progress-track {
  display: grid;
  flex: 1;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
}

.intro-progress-track i {
  display: block;
  height: 3px;
  background: rgba(255, 255, 255, .14);
  transition: background-color 420ms ease, box-shadow 420ms ease;
}

.intro-progress-track i.is-active {
  background: var(--amber);
  box-shadow: 0 0 10px rgba(228, 170, 88, .42);
}

.intro-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.panel,
.dialog-panel {
  display: grid;
  place-items: center;
  background: rgba(4, 7, 5, 0.72);
  backdrop-filter: blur(9px);
}

.panel-frame {
  width: min(690px, 94vw);
  max-height: calc(100dvh - 32px - var(--safe-top) - var(--safe-bottom));
  overflow: auto;
  border: 1px solid var(--line-strong);
  background: var(--panel);
  box-shadow: var(--shadow);
  scrollbar-color: var(--amber-dark) rgba(255,255,255,.04);
  touch-action: pan-y pinch-zoom;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.panel-header {
  position: sticky;
  top: 0;
  z-index: 3;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
  background: rgba(12, 18, 14, 0.97);
}

.panel-header h2 {
  margin: 3px 0 0;
  font-size: 26px;
  letter-spacing: 0.08em;
}

.panel-close {
  width: 46px;
  height: 46px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,.035);
  color: var(--muted);
  font-size: 28px;
  line-height: 1;
}

.radio-frame {
  display: flex;
  flex-direction: column;
  width: min(650px, 94vw);
  overflow: hidden;
  border: 2px solid #4b4c42;
  border-radius: 8px;
  background:
    linear-gradient(100deg, rgba(255,255,255,.025), transparent 18%, rgba(0,0,0,.13) 70%),
    #171c17;
  box-shadow: inset 0 0 0 4px #252a22, var(--shadow);
}

.radio-frame .panel-header {
  position: relative;
  flex: 0 0 auto;
}

.radio-command-bar {
  position: relative;
  z-index: 2;
  flex: 0 0 auto;
  padding: 12px 22px 11px;
  border-bottom: 1px solid var(--line);
  background: rgba(17, 23, 18, .985);
  box-shadow: 0 8px 18px rgba(0, 0, 0, .16);
}

#radio-controls {
  flex: 1 1 auto;
  min-height: 0;
  padding: 19px 22px 24px;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-color: var(--amber-dark) rgba(255,255,255,.04);
  -webkit-overflow-scrolling: touch;
}

.radio-topline {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
}

.radio-topline > .radio-action {
  width: 100%;
  min-width: 0;
  padding-right: 10px;
  padding-left: 10px;
  white-space: nowrap;
}

.radio-device-state {
  display: flex;
  gap: 12px;
  align-items: center;
}

.radio-command-status {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 3px 16px;
  margin-top: 7px;
  color: var(--dim);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 9px;
  letter-spacing: .035em;
}

.radio-command-status #solar-status {
  color: var(--muted);
}

.toggle-button,
.radio-action,
.danger-button {
  min-height: 44px;
  border: 1px solid var(--line-strong);
  background: rgba(255, 255, 255, 0.045);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.1em;
}

.toggle-button {
  padding: 0 14px;
}

.toggle-button i {
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 7px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 8px var(--green);
}

.toggle-button[aria-pressed="false"] i {
  background: #59403b;
  box-shadow: none;
}

.radio-battery-readout {
  color: var(--amber-soft);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 28px;
}

.radio-battery-readout small {
  font-size: 11px;
}

.radio-status {
  display: flex;
  gap: 7px;
  align-items: center;
  color: var(--muted);
  font-size: 10px;
}

.radio-status span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--amber);
  box-shadow: 0 0 8px var(--amber);
}

.frequency-display {
  position: relative;
  display: flex;
  align-items: baseline;
  margin-top: 17px;
  padding: 18px 18px 13px;
  overflow: hidden;
  border: 1px solid #685b42;
  background:
    repeating-linear-gradient(0deg, rgba(63, 49, 28, .13) 0, rgba(63, 49, 28, .13) 1px, transparent 1px, transparent 4px),
    #15130e;
  color: var(--amber-soft);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  text-shadow: 0 0 8px rgba(228, 170, 88, .45);
}

.frequency-display > span {
  font-size: clamp(42px, 9vw, 64px);
  letter-spacing: 0.06em;
}

.frequency-display small {
  margin-left: 8px;
  font-size: 12px;
}

.signal-bars {
  position: absolute;
  right: 15px;
  bottom: 15px;
  display: flex;
  gap: 4px;
  align-items: flex-end;
  height: 24px;
}

.signal-bars i {
  width: 5px;
  height: 6px;
  background: rgba(228, 170, 88, .15);
}

.signal-bars i:nth-child(2) { height: 10px; }
.signal-bars i:nth-child(3) { height: 14px; }
.signal-bars i:nth-child(4) { height: 19px; }
.signal-bars i:nth-child(5) { height: 24px; }
.signal-bars i.active { background: var(--amber); box-shadow: 0 0 5px rgba(228,170,88,.4); }

.tuner-row {
  display: grid;
  grid-template-columns: 48px 1fr 48px;
  gap: 8px;
  align-items: center;
  margin: 10px 0;
}

.tuner-row button {
  height: 46px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,.045);
  font-size: 22px;
}

input[type="range"] {
  accent-color: var(--amber);
}

.tuner-row input,
.wide-slider {
  width: 100%;
  min-height: 42px;
}

.radio-readout {
  min-height: 67px;
  padding: 11px 13px;
  border: 1px solid var(--line);
  background: rgba(0,0,0,.22);
}

.readout-label {
  color: var(--amber-soft);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 9px;
  letter-spacing: 0.13em;
}

.radio-readout p {
  margin: 6px 0 0;
  color: #c2c3b8;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  line-height: 1.45;
}

.radio-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 9px;
}

.radio-action {
  padding: 0 16px;
}

.radio-action:hover:not(:disabled),
.radio-action:active:not(:disabled) {
  border-color: var(--amber-dark);
  background: rgba(228, 170, 88, .1);
}

.radio-action.emphasis {
  border-color: var(--amber);
  background: var(--amber);
  color: #16110b;
}

.radio-action:disabled {
  opacity: .62;
  filter: saturate(.35);
}

.radio-action.emphasis:disabled {
  border-color: var(--line);
  background: rgba(228, 170, 88, .08);
  color: var(--dim);
}

.radio-separator {
  height: 1px;
  margin: 17px 0;
  background: var(--line);
}

.music-control {
  display: flex;
  gap: 15px;
  align-items: center;
}

.music-control > div {
  min-width: 0;
}

.music-control h3 {
  margin: 5px 0 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 19px;
  font-weight: 400;
}

.music-control p {
  margin: 2px 0;
  color: var(--dim);
  font-size: 10px;
}

.play-button {
  flex: 0 0 auto;
  width: 55px;
  height: 55px;
  margin-left: auto;
  border: 1px solid var(--amber-dark);
  border-radius: 50%;
  background: rgba(228, 170, 88, .1);
  color: var(--amber-soft);
}

.play-button[aria-pressed="true"] {
  background: var(--amber);
  color: #17120b;
}

.track-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 7px;
  margin-top: 13px;
}

.tape-recovery-count {
  margin: 10px 0 0;
  color: var(--amber-soft);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: .1em;
}

.track-list button {
  position: relative;
  min-width: 0;
  min-height: 58px;
  padding: 9px 10px 9px 31px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, .025);
  color: var(--muted);
  font-size: 9px;
  line-height: 1.25;
  text-align: left;
  text-overflow: ellipsis;
}

.track-list button::before {
  content: "▶";
  position: absolute;
  top: 50%;
  left: 10px;
  color: var(--amber-soft);
  transform: translateY(-50%);
}

.track-list button:hover:not(:disabled),
.track-list button:active:not(:disabled),
.track-list button.selected,
.track-list button.active,
.track-list button[aria-pressed="true"] {
  border-color: var(--amber-dark);
  background: rgba(228, 170, 88, .1);
  color: var(--ink);
}

.track-list button:disabled,
.track-list button.locked {
  opacity: .42;
  filter: saturate(.4);
}

.track-list button:disabled::before,
.track-list button.locked::before {
  content: "▣";
  color: var(--dim);
}

.track-list button b,
.track-list button span,
.track-list button small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.track-list button b {
  color: inherit;
  font-size: 10px;
  letter-spacing: .04em;
}

.track-list button small {
  margin-top: 3px;
  color: var(--dim);
  font-size: 8px;
}

.slider-label,
.volume-scale {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.slider-label {
  margin-top: 12px;
  color: var(--muted);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: .1em;
}

.volume-scale {
  margin-top: -5px;
  color: var(--dim);
  font-size: 8px;
  letter-spacing: .08em;
}

.danger-button {
  width: 100%;
  margin-top: 0;
  padding: 0 16px;
  border-color: rgba(166, 83, 56, .7);
  color: #e5a58f;
}

.danger-button:hover:not(:disabled),
.danger-button:active:not(:disabled) {
  background: rgba(166, 83, 56, .14);
}

.radio-warning {
  margin: 7px 0 0;
  color: var(--dim);
  font-size: 9px;
  text-align: center;
}

.radio-unavailable,
.map-offline {
  padding: 50px 30px;
  text-align: center;
}

.radio-unavailable {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
}

.lost-signal,
.map-offline b {
  color: var(--red);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: clamp(28px, 7vw, 52px);
  letter-spacing: .14em;
}

.radio-unavailable p,
.map-offline p {
  color: var(--muted);
  line-height: 1.5;
}

.map-frame {
  width: min(860px, 95vw);
  background: #151a14;
}

#map-canvas {
  display: block;
  width: calc(100% - 32px);
  height: auto;
  min-height: 0;
  max-height: 520px;
  aspect-ratio: 16 / 9;
  margin: 16px;
  border: 1px solid rgba(226, 214, 178, .3);
  background: #b8a77d;
  cursor: crosshair;
  touch-action: none;
}

.map-controls {
  display: grid;
  grid-template-columns: 48px minmax(88px, auto) 48px;
  gap: 7px;
  justify-content: center;
  padding: 0 18px 12px;
}

.map-controls button {
  min-height: 44px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, .04);
  color: var(--amber-soft);
  font-size: 18px;
}

.map-controls button:nth-child(2) {
  color: var(--muted);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: .1em;
}

.map-controls button:hover,
.map-controls button:active {
  border-color: var(--amber-dark);
  background: rgba(228, 170, 88, .1);
}

.map-legend {
  display: flex;
  gap: 17px;
  flex-wrap: wrap;
  padding: 0 18px;
  color: var(--muted);
  font-size: 10px;
}

.map-legend span {
  display: inline-flex;
  gap: 6px;
  align-items: center;
}

.map-legend i {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--muted);
}

.map-legend .you { background: #d65b42; }
.map-legend .objective { background: #e4aa58; border-radius: 0; transform: rotate(45deg); }
.map-legend .poi { background: #4a6253; }
.map-legend .fog-known { border: 1px solid #777b76; border-radius: 0; background: #343938; }
.map-legend .fog-unknown { border: 1px solid #343938; border-radius: 0; background: #020403; }

.map-detail {
  min-height: 68px;
  margin: 12px 18px 0;
  padding: 11px 13px;
  border-left: 2px solid #4f6757;
  background: rgba(0, 0, 0, .2);
}

.map-detail b {
  color: var(--amber-soft);
  font-size: 10px;
  letter-spacing: .11em;
}

.map-detail p {
  margin: 5px 0 0;
  color: var(--muted);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 12px;
  line-height: 1.4;
}

.map-caption {
  margin: 12px 18px 18px;
  color: var(--dim);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 10px;
}

.inventory-frame {
  display: flex;
  flex-direction: column;
  width: min(760px, 94vw);
  overflow: hidden;
}

.inventory-frame .panel-header {
  position: relative;
  flex: 0 0 auto;
}

.inventory-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-color: var(--amber-dark) rgba(255,255,255,.04);
  -webkit-overflow-scrolling: touch;
}

.load-summary {
  display: grid;
  grid-template-columns: minmax(115px, 1fr);
  gap: 6px;
  width: min(210px, 32vw);
  margin-left: auto;
  padding: 0 18px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  text-align: right;
}

.load-summary > span:first-child {
  display: flex;
  gap: 10px;
  align-items: baseline;
  justify-content: flex-end;
}

.load-summary b {
  color: var(--ink);
  font-size: 11px;
  letter-spacing: .05em;
  white-space: nowrap;
}

.load-summary small {
  color: var(--muted);
  font-size: 9px;
  white-space: nowrap;
}

.load-meter {
  position: relative;
  display: block;
  width: 100%;
  height: 5px;
  overflow: hidden;
  background: rgba(255,255,255,.09);
}

.load-meter i {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0;
  background: var(--green);
  transition: width 180ms linear, background 180ms ease;
}

.load-summary.heavy .load-meter i {
  background: var(--amber);
}

.load-summary.full .load-meter i {
  background: var(--red);
}

.inventory-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 9px;
  align-content: start;
  padding: 18px;
}

.inventory-slot {
  position: relative;
  min-height: 116px;
  padding: 12px 10px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,.025);
  text-align: left;
}

.inventory-slot:hover,
.inventory-slot.selected {
  border-color: var(--amber-dark);
  background: rgba(228,170,88,.07);
}

.item-icon {
  display: block;
  color: var(--amber-soft);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 29px;
}

.inventory-slot b {
  display: block;
  margin-top: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 11px;
  letter-spacing: .07em;
}

.inventory-slot small {
  position: absolute;
  right: 9px;
  top: 9px;
  color: var(--muted);
  font-size: 10px;
}

.inventory-slot .item-weight {
  position: absolute;
  bottom: 9px;
  left: 10px;
  color: var(--dim);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 9px;
  font-style: normal;
  letter-spacing: .04em;
}

.item-detail {
  display: flex;
  position: relative;
  z-index: 2;
  flex: 0 0 auto;
  gap: 18px;
  align-items: center;
  justify-content: space-between;
  min-height: 102px;
  margin: 0;
  padding: 15px;
  border-top: 1px solid var(--line);
  border-left: 2px solid var(--amber-dark);
  background: rgba(10, 15, 11, .985);
  box-shadow: 0 -10px 22px rgba(0, 0, 0, .2);
}

.item-detail.is-empty {
  min-height: 66px;
}

.item-detail > div:first-child {
  min-width: 0;
}

.item-detail h3 {
  margin: 4px 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 20px;
  font-weight: 400;
}

.item-detail p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.item-actions {
  display: flex;
  flex: 0 0 auto;
  gap: 8px;
  align-items: center;
}

.item-actions .secondary-button,
.item-actions .radio-action {
  width: auto;
  min-width: 94px;
  margin: 0;
  white-space: nowrap;
}

.repair-frame {
  width: min(640px, 94vw);
}

.repair-copy {
  margin: 18px;
  color: #c1c1b6;
  font-family: Georgia, "Times New Roman", serif;
  line-height: 1.55;
}

.repair-action-visual {
  position: relative;
  height: 104px;
  margin: 0 18px 14px;
  overflow: hidden;
  border: 1px solid rgba(228, 170, 88, .2);
  background:
    linear-gradient(90deg, rgba(255,255,255,.025) 1px, transparent 1px) 0 0 / 18px 18px,
    #111610;
}

.repair-board {
  position: absolute;
  inset: 14px auto auto 50%;
  width: 118px;
  height: 62px;
  transform: translateX(-50%);
  border: 2px solid #6e716a;
  background: #282d28;
}

.repair-board::before,
.repair-board::after {
  content: "";
  position: absolute;
  left: 12px;
  right: 12px;
  height: 2px;
  background: #7b6041;
}

.repair-board::before { top: 18px; }
.repair-board::after { top: 42px; }

.repair-fuse-part,
.repair-wire-part,
.repair-status-light {
  position: absolute;
  z-index: 1;
  opacity: .16;
  transition: opacity 180ms ease, box-shadow 180ms ease;
}

.repair-fuse-part {
  top: 12px;
  left: 17px;
  width: 28px;
  height: 11px;
  border: 3px solid #ad8350;
  background: #d7d2b9;
}

.repair-wire-part {
  top: 31px;
  left: 40px;
  width: 46px;
  height: 17px;
  border: 3px solid #aa633c;
  border-top-color: transparent;
  border-radius: 0 0 50% 50%;
}

.repair-status-light {
  top: 11px;
  right: 13px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #8db68e;
}

.repair-action-visual[data-step="1"] .repair-fuse-part,
.repair-action-visual[data-step="2"] .repair-fuse-part,
.repair-action-visual[data-step="3"] .repair-fuse-part,
.repair-action-visual[data-step="2"] .repair-wire-part,
.repair-action-visual[data-step="3"] .repair-wire-part,
.repair-action-visual[data-step="3"] .repair-status-light {
  opacity: 1;
}

.repair-action-visual[data-step="3"] .repair-status-light {
  box-shadow: 0 0 13px #8db68e;
}

.repair-action-item {
  position: absolute;
  top: 38px;
  left: 18px;
  z-index: 3;
  color: var(--amber-soft);
  font: bold 24px ui-monospace, SFMono-Regular, Menlo, monospace;
  opacity: 0;
}

.repair-action-hand {
  position: absolute;
  top: 57px;
  left: -12px;
  z-index: 2;
  width: 76px;
  height: 12px;
  border-radius: 8px;
  background: #9b7c61;
  opacity: 0;
}

.repair-action-visual.animating .repair-action-item,
.repair-action-visual.animating .repair-action-hand {
  animation: repair-reach 820ms ease-in-out;
}

.repair-action-visual.animating .repair-action-hand {
  animation-name: repair-hand-reach;
}

.repair-action-visual > b {
  position: absolute;
  right: 8px;
  bottom: 5px;
  left: 8px;
  color: #aaa99e;
  font: 8px ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: .08em;
  text-align: center;
}

@keyframes repair-reach {
  0%, 100% { transform: translateX(0) rotate(-12deg); opacity: 0; }
  18%, 72% { opacity: 1; }
  58% { transform: translateX(118px) rotate(8deg); opacity: 1; }
}

@keyframes repair-hand-reach {
  0%, 100% { transform: translateX(0); opacity: 0; }
  18%, 72% { opacity: 1; }
  58% { transform: translateX(105px); opacity: 1; }
}

.repair-steps {
  display: grid;
  gap: 8px;
  padding: 0 18px;
}

.repair-steps button {
  display: grid;
  grid-template-columns: 42px 1fr auto;
  gap: 12px;
  align-items: center;
  min-height: 70px;
  padding: 9px 13px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,.035);
  text-align: left;
}

.repair-steps button:not(:disabled):hover {
  border-color: var(--amber-dark);
  background: rgba(228,170,88,.07);
}

.repair-steps button:disabled {
  opacity: .43;
}

.repair-steps button.done {
  border-color: rgba(141,182,142,.45);
}

.repair-steps i {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  color: var(--amber-soft);
  font-style: normal;
}

.repair-steps span b,
.repair-steps span small {
  display: block;
}

.repair-steps span b {
  font-size: 12px;
  letter-spacing: .09em;
}

.repair-steps span small {
  margin-top: 4px;
  color: var(--dim);
  font-size: 10px;
}

.repair-steps em {
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 9px;
  font-style: normal;
}

.repair-terminal {
  margin: 15px 18px 18px;
  min-height: 65px;
  padding: 13px;
  border: 1px solid rgba(228,170,88,.25);
  background: #0e0d0a;
  color: var(--amber);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  line-height: 1.5;
}

.dialog-panel {
  z-index: 30;
}

.dialog-card {
  width: min(590px, 92vw);
  padding: clamp(24px, 5vw, 42px);
  border: 1px solid var(--line-strong);
  background: rgba(10, 15, 11, .98);
  box-shadow: var(--shadow);
  max-height: calc(100dvh - 32px - var(--safe-top) - var(--safe-bottom));
  overflow: auto;
  touch-action: pan-y pinch-zoom;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.dialog-card h2 {
  margin: 8px 0 14px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(26px, 5vw, 42px);
  font-weight: 400;
}

.dialog-card p {
  color: #c7c5b9;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 16px;
  line-height: 1.6;
}

.loot-frame {
  width: min(590px, 94vw);
  background:
    linear-gradient(135deg, rgba(166, 83, 56, .08), transparent 42%),
    var(--panel);
}

.loot-copy,
.settings-copy {
  margin: 17px 18px;
  color: var(--muted);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 14px;
  line-height: 1.5;
}

.loot-list {
  display: grid;
  gap: 7px;
  padding: 0 18px 16px;
}

.loot-list:empty::before {
  content: "Niente di recuperabile.";
  display: block;
  padding: 18px;
  border: 1px dashed var(--line);
  color: var(--dim);
  font-size: 12px;
  text-align: center;
}

.loot-list > * {
  min-height: 58px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, .025);
}

.loot-list .loot-item,
.loot-list .loot-entry,
.loot-list > div,
.loot-list > li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 5px 14px;
  align-items: center;
}

.loot-list .loot-row {
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 10px;
}

.loot-row > span {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border: 1px solid var(--line);
  color: var(--amber-soft);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 16px;
}

.loot-row > div {
  min-width: 0;
}

.loot-row small {
  display: block;
  margin-top: 4px;
}

.loot-row.taken,
.loot-row.ruined-row {
  opacity: .58;
}

.loot-row.ruined-row > span {
  border-color: #874f42;
  color: #d4846e;
}

.loot-list b {
  overflow: hidden;
  font-size: 11px;
  letter-spacing: .07em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.loot-list span,
.loot-list small,
.loot-condition {
  color: var(--muted);
  font-size: 10px;
}

.loot-list em,
.loot-list .ruined,
.loot-list .broken {
  color: #d4846e;
  font-size: 9px;
  font-style: normal;
  letter-spacing: .08em;
}

.loot-list .taken {
  opacity: .38;
  text-decoration: line-through;
}

.loot-frame > .primary-button {
  width: calc(100% - 36px);
  margin: 0 18px 20px;
}

.settings-frame {
  width: min(680px, 94vw);
}

.about-frame {
  width: min(980px, 94vw);
  background:
    linear-gradient(145deg, rgba(228, 170, 88, .045), transparent 34%),
    var(--panel);
}

.about-content {
  padding: 20px;
}

.about-spoiler {
  margin: 0 0 14px;
  padding: 10px 13px;
  border: 1px solid rgba(228, 170, 88, .22);
  background: rgba(228, 170, 88, .045);
  color: var(--muted);
  font-size: 10px;
  line-height: 1.45;
  letter-spacing: .025em;
}

.about-spoiler b {
  margin-right: 7px;
  color: var(--amber-soft);
  letter-spacing: .11em;
}

.about-lede {
  display: grid;
  grid-template-columns: minmax(0, 1.7fr) minmax(220px, .7fr);
  gap: clamp(22px, 4vw, 44px);
  padding: clamp(22px, 4vw, 38px);
  border: 1px solid var(--line);
  border-top: 3px solid var(--amber);
  background:
    radial-gradient(circle at 86% 18%, rgba(228, 170, 88, .13), transparent 31%),
    linear-gradient(120deg, rgba(255, 255, 255, .025), transparent 60%),
    #101812;
}

.about-dateline,
.about-index,
.about-signal span,
.about-signal small {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-weight: 800;
  letter-spacing: .12em;
}

.about-dateline {
  display: block;
  margin-bottom: 10px;
  color: var(--amber-soft);
  font-size: 10px;
}

.about-lede h3,
.about-story h3,
.about-demo-bridge h3 {
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 400;
}

.about-lede h3 {
  max-width: 650px;
  margin: 0 0 16px;
  font-size: clamp(27px, 4.3vw, 45px);
  line-height: 1.08;
}

.about-lede p,
.about-story p,
.about-demo-bridge p {
  color: #c7c5b9;
  font-family: Georgia, "Times New Roman", serif;
  line-height: 1.67;
}

.about-lede p {
  margin: 0 0 12px;
  font-size: 15px;
}

.about-lede p:last-child,
.about-story p:last-child,
.about-demo-bridge p:last-child {
  margin-bottom: 0;
}

.about-signal {
  align-self: center;
  min-width: 0;
  padding: 20px;
  border: 1px solid rgba(141, 182, 142, .25);
  background:
    repeating-linear-gradient(0deg, transparent 0 4px, rgba(141, 182, 142, .025) 5px),
    rgba(5, 12, 8, .82);
  box-shadow: inset 0 0 35px rgba(141, 182, 142, .035);
}

.about-signal span,
.about-signal small {
  display: block;
  color: var(--green);
  font-size: 8px;
}

.about-signal strong {
  display: block;
  margin: 9px 0 2px;
  color: #bfdbb9;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: clamp(38px, 6vw, 58px);
  font-weight: 500;
  letter-spacing: -.055em;
  text-shadow: 0 0 14px rgba(141, 182, 142, .22);
}

.about-signal i {
  display: block;
  height: 2px;
  margin: 15px 0;
  background:
    linear-gradient(90deg, transparent, var(--green) 18%, transparent 21%, var(--green) 31%, var(--green) 57%, transparent 61%, var(--green) 75%, transparent);
  box-shadow: 0 0 8px rgba(141, 182, 142, .3);
}

.about-signal blockquote {
  margin: 0;
  color: #d6d4c7;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 15px;
  font-style: italic;
  line-height: 1.5;
}

.about-story-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1px;
  margin-top: 18px;
  background: var(--line);
  border: 1px solid var(--line);
}

.about-story {
  min-width: 0;
  padding: clamp(20px, 3vw, 30px);
  background: #101712;
}

.about-index {
  display: block;
  color: var(--amber-soft);
  font-size: 9px;
}

.about-story h3,
.about-demo-bridge h3 {
  margin: 8px 0 13px;
  color: var(--ink);
  font-size: clamp(21px, 2.6vw, 29px);
  line-height: 1.18;
}

.about-story p,
.about-demo-bridge p {
  margin: 0 0 11px;
  font-size: 13px;
}

.about-demo-bridge {
  margin-top: 18px;
  padding: clamp(22px, 4vw, 36px);
  border-left: 3px solid var(--rust);
  background:
    linear-gradient(90deg, rgba(166, 83, 56, .09), transparent 48%),
    rgba(255, 255, 255, .025);
}

.about-demo-bridge h3 {
  max-width: 690px;
}

.about-demo-bridge p {
  max-width: 820px;
}

.help-frame {
  width: min(820px, 94vw);
}

.help-content {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  padding: 18px;
}

.help-section {
  min-width: 0;
  padding: 16px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, .025);
}

.help-section-wide {
  grid-column: 1 / -1;
}

.help-section h3 {
  margin: 0 0 12px;
  color: var(--amber-soft);
  font-size: 11px;
  letter-spacing: .13em;
}

.control-list {
  display: grid;
  gap: 1px;
  margin: 0;
  background: var(--line);
}

.control-list > div {
  display: grid;
  grid-template-columns: minmax(126px, .9fr) minmax(0, 1.4fr);
  gap: 12px;
  align-items: center;
  min-height: 50px;
  padding: 8px 10px;
  background: #111914;
}

.control-list dt,
.control-list dd {
  margin: 0;
}

.control-list dt {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  align-items: center;
}

.control-list dt span {
  color: var(--dim);
  font-size: 9px;
}

.control-list dd,
.pointer-help p {
  color: #c5c5bb;
  font-size: 11px;
  line-height: 1.45;
}

.control-list kbd {
  min-width: 29px;
  padding: 0 7px;
  white-space: nowrap;
}

.pointer-help {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.pointer-help p {
  margin: 0;
  padding: 13px;
  border-left: 2px solid var(--amber-dark);
  background: rgba(228, 170, 88, .035);
}

.pointer-help b {
  display: block;
  margin-bottom: 5px;
  color: var(--ink);
  font-size: 9px;
  letter-spacing: .12em;
}

.custom-track-list {
  display: grid;
  gap: 8px;
  padding: 0 18px 16px;
}

.custom-track-list label {
  display: grid;
  grid-template-columns: minmax(110px, .8fr) minmax(130px, 1fr) minmax(180px, 1.25fr);
  gap: 10px;
  align-items: center;
  min-height: 64px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, .025);
}

.custom-track-list label:focus-within {
  border-color: var(--amber);
  background: rgba(228, 170, 88, .07);
}

.custom-track-list b {
  color: var(--amber-soft);
  font-size: 10px;
  letter-spacing: .09em;
}

.custom-track-list span {
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.custom-track-list input[type="file"] {
  min-width: 0;
  max-width: 100%;
  color: var(--dim);
  font-size: 10px;
}

.custom-track-list input[type="file"]::file-selector-button {
  min-height: 42px;
  margin-right: 8px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  background: rgba(228, 170, 88, .09);
  color: var(--ink);
  font: inherit;
  font-weight: 800;
}

.settings-frame > .secondary-button {
  margin: 0 18px 18px;
}

.settings-toggle {
  display: grid;
  grid-template-columns: 24px 1fr;
  gap: 11px;
  align-items: center;
  margin: 0 18px 18px;
  padding: 13px;
  border: 1px solid var(--line);
  background: rgba(141, 182, 142, .045);
  color: #cfcec3;
  font-size: 12px;
  line-height: 1.4;
}

.settings-toggle input {
  width: 22px;
  height: 22px;
  margin: 0;
  accent-color: var(--amber);
}

.music-credit-compact {
  padding: 12px 18px 18px;
  border-top: 1px solid var(--line);
  color: var(--dim);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 9px;
  line-height: 1.5;
}

.death-screen {
  z-index: 55;
  background:
    radial-gradient(circle at 50% 40%, rgba(133, 30, 24, .2), transparent 36%),
    rgba(3, 5, 4, .97);
}

.death-screen::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(0deg, transparent 0 5px, rgba(211, 96, 76, .025) 6px);
}

.death-card {
  position: relative;
  width: min(610px, 94vw);
  max-height: calc(100dvh - 30px - var(--safe-top) - var(--safe-bottom));
  overflow: auto;
  padding: clamp(26px, 6vw, 56px);
  border: 1px solid rgba(211, 96, 76, .33);
  border-top: 3px solid var(--red);
  background: rgba(9, 13, 10, .96);
  box-shadow: 0 30px 100px rgba(0, 0, 0, .7);
  text-align: center;
  touch-action: pan-y pinch-zoom;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.death-card h2 {
  margin: 9px 0 12px;
  color: #e8ddd2;
  font-size: clamp(38px, 8vw, 70px);
  line-height: .92;
  letter-spacing: -.035em;
}

.death-card > p {
  max-width: 480px;
  margin: 0 auto;
  color: var(--muted);
  font-family: Georgia, "Times New Roman", serif;
  line-height: 1.55;
}

.hard-checkpoint-label {
  margin: 23px 0 0;
  padding: 12px 14px;
  border: 1px solid rgba(228, 170, 88, .32);
  background: rgba(228, 170, 88, .07);
  color: var(--amber-soft);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .1em;
}

.death-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-top: 21px;
}

.toast-stack {
  position: absolute;
  z-index: 40;
  top: calc(118px + var(--safe-top));
  left: 50%;
  display: grid;
  gap: 8px;
  width: min(440px, calc(100vw - 34px));
  transform: translateX(-50%);
  pointer-events: none;
}

.game-shell.panel-open .toast-stack {
  top: auto;
  bottom: calc(14px + var(--safe-bottom));
}

.toast {
  padding: 11px 15px;
  border-left: 3px solid var(--amber);
  background: rgba(8, 13, 10, .92);
  box-shadow: 0 7px 24px rgba(0,0,0,.38);
  color: #d5d4c9;
  font-size: 12px;
  animation: toast-in 180ms ease both;
}

.toast.danger { border-left-color: var(--red); }
.toast.success { border-left-color: var(--green); }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(-8px); }
}

.subtitle {
  position: absolute;
  z-index: 35;
  left: 50%;
  bottom: calc(82px + var(--safe-bottom));
  width: min(680px, calc(100vw - 36px));
  padding: 12px 16px;
  transform: translateX(-50%);
  border: 1px solid rgba(232, 227, 213, .15);
  background: rgba(5,8,6,.9);
  color: #f0ecdf;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 15px;
  line-height: 1.45;
  text-align: center;
  box-shadow: 0 6px 30px rgba(0,0,0,.45);
}

.end-screen {
  z-index: 50;
  background:
    radial-gradient(circle at 50% 28%, rgba(228,170,88,.15), transparent 30%),
    rgba(4,7,5,.96);
}

.end-card {
  width: min(670px, 94vw);
  max-height: calc(100dvh - 30px - var(--safe-top) - var(--safe-bottom));
  overflow: auto;
  padding: clamp(25px, 5vw, 52px);
  border: 1px solid var(--line);
  background: rgba(10,15,11,.9);
  box-shadow: var(--shadow);
  text-align: center;
  touch-action: pan-y pinch-zoom;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.waveform {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 5px;
  height: 54px;
  margin: 20px 0 10px;
}

.waveform i {
  width: 4px;
  height: 14px;
  background: var(--amber);
  animation: wave 900ms ease-in-out infinite alternate;
}

.waveform i:nth-child(2) { height: 28px; animation-delay: -200ms; }
.waveform i:nth-child(3) { height: 45px; animation-delay: -500ms; }
.waveform i:nth-child(4) { height: 20px; animation-delay: -100ms; }
.waveform i:nth-child(5) { height: 50px; animation-delay: -700ms; }
.waveform i:nth-child(6) { height: 30px; animation-delay: -400ms; }
.waveform i:nth-child(7) { height: 43px; animation-delay: -650ms; }
.waveform i:nth-child(8) { height: 24px; animation-delay: -150ms; }
.waveform i:nth-child(9) { height: 12px; animation-delay: -550ms; }

@keyframes wave { to { transform: scaleY(.45); opacity: .55; } }

.end-card blockquote {
  margin: 18px auto;
  max-width: 560px;
  color: #e8dfca;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(17px, 3vw, 22px);
  line-height: 1.55;
}

.end-card h2 {
  margin: 26px 0 5px;
  color: var(--amber-soft);
  font-size: clamp(38px, 8vw, 72px);
  letter-spacing: .09em;
}

.end-card > p {
  color: var(--muted);
  line-height: 1.5;
}

.end-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0,1fr));
  gap: 1px;
  margin-top: 24px;
  background: var(--line);
}

.end-stat {
  padding: 13px 8px;
  background: #101712;
}

.end-stat b,
.end-stat span {
  display: block;
}

.end-stat b {
  color: var(--amber-soft);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 19px;
}

.end-stat span {
  margin-top: 4px;
  color: var(--dim);
  font-size: 9px;
  letter-spacing: .08em;
}

.end-actions {
  justify-content: center;
}

noscript {
  position: fixed;
  z-index: 100;
  inset: 20px;
  padding: 20px;
  background: #111;
  color: #fff;
}

@media (pointer: coarse), (max-width: 760px) {
  .hud-objective {
    max-width: calc(100vw - 360px - var(--safe-left) - var(--safe-right));
    padding: 8px 10px 8px 12px;
  }

  .objective-text {
    font-size: 14px;
  }

  .objective-detail {
    display: none;
  }

  .objective-route {
    margin-top: 5px;
    padding: 3px 6px;
    font-size: 9px;
  }

  .objective-end-goal {
    font-size: 9px;
  }

  .time-widget {
    margin-top: 5px;
    padding: 3px 6px;
  }

  .hud-vitals {
    padding: 7px;
    grid-template-columns: auto repeat(4, 44px);
    gap: 5px;
  }

  .vital {
    grid-template-columns: 12px 62px 30px;
    gap: 5px;
  }

  .flashlight-vital {
    grid-template-columns: 12px 52px 40px;
  }

  .flashlight-vital .meter {
    width: 52px;
  }

  .flashlight-vital .vital-value {
    font-size: 8px;
  }

  .weapon-vital {
    grid-template-columns: 12px minmax(80px, 1fr);
  }

  .meter {
    width: 62px;
  }

  .icon-button {
    width: 44px;
    height: 44px;
  }

  .quick-volume {
    grid-template-columns: 42px minmax(0, 1fr) 42px;
    gap: 4px;
    padding: 4px;
  }

  .mobile-action,
  .mobile-attack,
  .mobile-tools button,
  .panel-close,
  .map-controls button {
    -webkit-touch-callout: none;
  }

  .start-content {
    margin-right: 15vw;
  }

  .start-screen::before {
    right: -4vw;
    opacity: .28;
  }

  .panel,
  .dialog-panel,
  .screen {
    padding: calc(8px + var(--safe-top)) calc(8px + var(--safe-right)) calc(8px + var(--safe-bottom)) calc(8px + var(--safe-left));
  }

  .panel-frame {
    width: 100%;
    max-height: calc(100dvh - 16px - var(--safe-top) - var(--safe-bottom));
  }

  .trait-card {
    width: 100%;
    max-height: calc(100dvh - 16px - var(--safe-top) - var(--safe-bottom));
  }

  .trait-grid button {
    min-height: 165px;
  }

  .inventory-grid {
    grid-template-columns: repeat(3, minmax(0,1fr));
  }

  .inventory-slot {
    min-height: 102px;
  }
}

@media (max-width: 560px) {
  .game-shell {
    --mobile-hud-bottom: calc(var(--safe-top) + 214px);
  }

  /*
   * Portrait HUD panels participate in one flow. Text can wrap or grow without
   * relying on a guessed top offset for the vitals panel below it.
   */
  .hud {
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: stretch;
    padding: calc(10px + var(--safe-top)) calc(12px + var(--safe-right)) calc(12px + var(--safe-bottom)) calc(12px + var(--safe-left));
  }

  .hud-objective {
    position: relative;
    inset: auto;
    width: 100%;
    max-width: none;
  }

  .hud-vitals {
    position: relative;
    inset: auto;
    grid-template-columns: minmax(0, 1fr) repeat(4, 44px);
    width: 100%;
  }

  .mobile-hud-mode .hud-vitals-drawer {
    position: relative;
    inset: auto;
    width: 100%;
  }

  /* The full volume strip is duplicated in the radio and cannot fit a narrow HUD. */
  .quick-volume {
    display: none;
  }

  .inventory-panel .panel-header {
    align-items: flex-start;
  }

  .load-summary {
    width: auto;
    min-width: 120px;
    padding: 1px 10px;
  }

  .load-summary > span:first-child {
    display: grid;
    gap: 2px;
  }

  .load-summary small {
    font-size: 8px;
  }

  .mobile-action {
    right: calc(16px + var(--safe-right));
    bottom: calc(22px + var(--safe-bottom));
    width: 84px;
    height: 84px;
  }

  .mobile-attack {
    right: calc(105px + var(--safe-right));
    bottom: calc(29px + var(--safe-bottom));
    width: 72px;
    height: 72px;
  }

  .mobile-tools {
    right: calc(16px + var(--safe-right));
    bottom: calc(122px + var(--safe-bottom));
    display: grid;
    grid-template-columns: repeat(3, 46px);
    gap: 7px;
  }

  .mobile-tools button {
    width: 46px;
    height: 46px;
  }

  /* Right-align the second row so the tray remains adjacent to the action cluster. */
  .mobile-tools button:nth-child(1) { grid-row: 1; grid-column: 1; }
  .mobile-tools button:nth-child(2) { grid-row: 1; grid-column: 2; }
  .mobile-tools button:nth-child(3) { grid-row: 1; grid-column: 3; }
  .mobile-tools button:nth-child(4) { grid-row: 2; grid-column: 2; }
  .mobile-tools button:nth-child(5) { grid-row: 2; grid-column: 3; }

  .toast-stack {
    top: calc(var(--mobile-hud-bottom) + 8px);
  }

  .subtitle {
    bottom: calc(100dvh - var(--mobile-controls-top) + 8px);
  }

  .start-content {
    width: 100%;
    min-width: 0;
    max-width: 100%;
    margin-right: 0;
    align-self: end;
    padding-bottom: 60px;
  }

  .start-content h1 {
    max-width: 100%;
    font-size: clamp(48px, 16vw, 82px);
    letter-spacing: -0.055em;
  }

  .start-actions {
    display: grid;
    grid-template-columns: 1fr;
    width: min(280px, 100%);
    gap: 7px;
  }

  .start-actions .primary-button,
  .start-actions .secondary-button {
    width: 100%;
  }

  .start-copy {
    max-width: 92%;
    font-size: 14px;
    overflow-wrap: anywhere;
  }

  .start-note { overflow-wrap: anywhere; }

  .start-screen::before {
    right: -25vw;
    bottom: 16vh;
    width: 85vw;
    height: 65vh;
  }

  .start-footer {
    font-size: 8px;
  }

  .about-content {
    padding: 10px;
  }

  .about-lede {
    grid-template-columns: 1fr;
    gap: 18px;
    padding: 20px 17px;
  }

  .about-lede p {
    font-size: 14px;
  }

  .about-signal {
    padding: 16px;
  }

  .about-story-grid {
    grid-template-columns: 1fr;
    margin-top: 10px;
  }

  .about-story {
    padding: 20px 17px;
  }

  .about-demo-bridge {
    margin-top: 10px;
    padding: 20px 17px;
  }

  .radio-frame #radio-controls {
    padding: 14px;
  }

  .radio-command-bar {
    padding: 10px 14px 9px;
  }

  .radio-topline {
    gap: 8px;
  }

  .radio-topline > .toggle-button,
  .radio-topline > .radio-action {
    padding-right: 9px;
    padding-left: 9px;
    font-size: 10px;
  }

  .radio-device-state {
    gap: 7px;
  }

  .radio-battery-readout {
    font-size: 24px;
  }

  .radio-command-status {
    gap: 3px 10px;
    font-size: 8px;
  }

  .trait-card {
    padding: 22px 16px;
  }

  .customization-group {
    grid-template-columns: 1fr;
    gap: 10px;
    margin-top: 16px;
  }

  .trait-card > h2 {
    font-size: clamp(27px, 10vw, 38px);
  }

  .trait-grid {
    grid-template-columns: 1fr;
    gap: 8px;
    margin-top: 18px;
  }

  .trait-grid button {
    min-height: 118px;
    padding: 16px;
  }

  .trait-grid button::before {
    font-size: 34px;
  }

  .trait-grid span {
    margin-top: 8px;
  }

  .intro-card {
    width: 100%;
    padding: 22px 18px;
    background: rgba(7, 11, 8, .88);
  }

  .intro-card h2 {
    font-size: clamp(29px, 10vw, 40px);
  }

  .intro-card p {
    min-height: 4.7em;
    font-size: 14px;
    line-height: 1.55;
  }

  .intro-screen[data-scene="power"] .cinematic-radio {
    right: 8%;
    bottom: 55%;
  }

  .intro-screen[data-scene="power"] .cinematic-solar {
    right: 31%;
    bottom: 55%;
  }

  .intro-screen[data-scene="carrier"] .cinematic-signal {
    right: 4%;
    bottom: 47%;
  }

  .frequency-display > span {
    font-size: 42px;
  }

  .signal-bars {
    display: none;
  }

  .music-control h3 {
    max-width: 220px;
  }

  .track-list {
    grid-template-columns: 1fr;
  }

  .track-list button {
    min-height: 48px;
  }

  .map-controls {
    padding-right: 12px;
    padding-left: 12px;
  }

  .map-legend {
    gap: 10px;
    padding: 0 12px;
  }

  .map-detail {
    margin-right: 12px;
    margin-left: 12px;
  }

  .custom-track-list {
    padding-right: 12px;
    padding-left: 12px;
  }

  .custom-track-list label {
    grid-template-columns: 1fr;
    gap: 5px;
  }

  .custom-track-list input[type="file"] {
    width: 100%;
  }

  .settings-frame > .secondary-button {
    width: calc(100% - 24px);
    margin-right: 12px;
    margin-left: 12px;
  }

  .settings-toggle {
    margin-right: 12px;
    margin-left: 12px;
  }

  .help-content {
    grid-template-columns: 1fr;
    gap: 8px;
    padding: 12px;
  }

  .help-section-wide {
    grid-column: auto;
  }

  .pointer-help {
    grid-template-columns: 1fr;
  }

  .death-actions {
    display: grid;
  }

  .death-actions button {
    width: 100%;
  }

  .inventory-grid {
    grid-template-columns: repeat(2, minmax(0,1fr));
  }

  .item-detail {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 9px;
    align-items: stretch;
    min-height: 0;
    padding: 11px 12px 12px;
  }

  .item-detail.is-empty {
    min-height: 60px;
  }

  .item-detail h3 {
    margin: 2px 0;
    font-size: 18px;
  }

  .item-detail p {
    display: -webkit-box;
    overflow: hidden;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    line-clamp: 2;
  }

  .item-actions {
    display: flex;
    gap: 7px;
    width: 100%;
  }

  .item-actions .secondary-button,
  .item-actions .radio-action {
    flex: 1 1 0;
    width: 100%;
    min-width: 0;
  }

  .repair-steps button {
    grid-template-columns: 36px 1fr;
  }

  .repair-steps em {
    display: none;
  }

  .end-stats {
    grid-template-columns: 1fr;
  }
}

@media (pointer: coarse) {
  .quick-nav,
  .noise-widget,
  .context-prompt {
    display: none;
  }

  .context-prompt .keycap {
    display: none;
  }

  /*
   * Music and volume are already in the touch tray/radio. Removing duplicates
   * leaves three full-size utility targets without shrinking their hit areas.
   */
  .hud-vitals {
    grid-template-columns: auto repeat(3, 44px);
  }

  .quick-music,
  .quick-volume {
    display: none;
  }

  #help-btn {
    grid-column: 2;
  }

  #settings-btn {
    grid-column: 3;
  }

  #mute-btn {
    grid-column: 4;
  }

  .toast-stack {
    top: calc(var(--mobile-hud-bottom) + 8px);
  }

  .subtitle {
    bottom: calc(100dvh - var(--mobile-controls-top) + 8px);
  }

  .quick-volume-readout small {
    display: none;
  }
}

/*
 * A narrow fine-pointer window still needs its desktop tool entry points.
 * Compressing the labels is preferable to switching on controls it cannot use.
 */
@media (max-width: 560px) and (pointer: fine) {
  .quick-nav {
    right: calc(8px + var(--safe-right));
    bottom: calc(10px + var(--safe-bottom));
    left: calc(8px + var(--safe-left));
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 5px;
    transform: none;
  }

  .tool-button {
    min-width: 0;
    height: 48px;
    grid-template-columns: 20px minmax(0, 1fr) 18px;
    gap: 3px;
    padding: 5px;
  }

  .tool-button b {
    overflow: hidden;
    font-size: 9px;
    text-overflow: ellipsis;
  }

  .tool-button kbd {
    min-width: 18px;
    width: 18px;
  }
}

@media (max-width: 360px) and (orientation: portrait) {
  .start-content {
    padding-bottom: 48px;
  }

  .start-content h1 {
    font-size: 47px;
  }

  .chapter {
    margin: 10px 0;
  }

  .start-copy {
    margin: 8px 0;
    font-size: 13px;
    line-height: 1.38;
  }

  .start-actions {
    margin-top: 12px;
  }

  .start-actions .primary-button,
  .start-actions .secondary-button {
    min-height: 44px;
  }

  .start-note {
    display: none;
  }

  .hud-vitals {
    grid-template-columns: minmax(0, 1fr) repeat(3, 44px);
  }

  .quick-music {
    display: none;
  }

  #help-btn {
    grid-column: 2;
  }

  #settings-btn {
    grid-column: 3;
  }

  #mute-btn {
    grid-column: 4;
  }

  .joystick {
    left: calc(15px + var(--safe-left));
  }

  .mobile-attack {
    right: calc(101px + var(--safe-right));
  }

  .panel-header {
    padding: 13px 12px;
  }

  .panel-header h2 {
    font-size: 22px;
  }

  .radio-device-state {
    gap: 4px;
  }

  .radio-status b {
    display: none;
  }
}

/*
 * Centering an oversized grid child can place its beginning above the scroll
 * origin. Short screens switch to normal document flow so every start action
 * remains reachable by touch or keyboard.
 */
@media (max-height: 700px) {
  .start-screen {
    display: block;
  }

  .start-content {
    margin-top: 0;
    padding-top: 10px;
    padding-bottom: 72px;
  }
}

@media (pointer: coarse) and (max-height: 640px) {
  .toast-stack .toast:not(:last-child) {
    display: none;
  }
}

@media (max-height: 520px) and (orientation: landscape) {
  .game-shell {
    --mobile-hud-bottom: calc(var(--safe-top) + 116px);
    --mobile-controls-top: calc(100dvh - var(--safe-bottom) - 118px);
  }

  .hud {
    display: block;
  }

  .hud-objective {
    position: absolute;
    top: calc(8px + var(--safe-top));
    right: auto;
    bottom: auto;
    left: calc(10px + var(--safe-left));
  }

  .hud-vitals {
    position: absolute;
    top: calc(8px + var(--safe-top));
    right: calc(10px + var(--safe-right));
    bottom: auto;
    left: auto;
    width: auto;
  }

  .mobile-hud-mode .hud-vitals-drawer {
    position: absolute;
    top: calc(8px + var(--safe-top));
    right: calc(10px + var(--safe-right));
    bottom: auto;
    left: auto;
    width: auto;
  }

  .mobile-hud-mode .hud-vitals {
    width: auto;
  }

  .hud-objective {
    max-width: 42vw;
  }

  .time-widget {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
  }

  .joystick {
    width: 106px;
    height: 106px;
    left: calc(16px + var(--safe-left));
    bottom: calc(12px + var(--safe-bottom));
  }

  .joystick-ring { inset: 7px; }
  .joystick-knob { left: 31px; top: 31px; width: 44px; height: 44px; }

  .mobile-action {
    width: 80px;
    height: 80px;
    right: calc(17px + var(--safe-right));
    bottom: calc(14px + var(--safe-bottom));
  }

  .mobile-attack {
    right: calc(105px + var(--safe-right));
    bottom: calc(19px + var(--safe-bottom));
    width: 70px;
    height: 70px;
  }

  .mobile-tools {
    right: calc(187px + var(--safe-right));
    bottom: calc(28px + var(--safe-bottom));
    display: flex;
    gap: 6px;
  }

  .mobile-tools button {
    width: 44px;
    height: 44px;
  }

  .context-prompt {
    bottom: calc(68px + var(--safe-bottom));
  }

  .start-content {
    width: min(60vw, 620px);
    margin-right: 0;
    justify-self: start;
  }

  .start-content h1 {
    font-size: clamp(48px, 12vh, 76px);
  }

  .start-copy {
    margin: 8px 0;
    font-size: 13px;
    line-height: 1.35;
  }

  .chapter {
    margin: 10px 0;
  }

  .start-note {
    display: none;
  }

  .start-actions {
    margin-top: 10px;
    display: flex;
    width: auto;
  }

  .trait-card {
    padding: 16px 20px;
  }

  .trait-card > h2 {
    margin-bottom: 4px;
    font-size: clamp(25px, 8vh, 38px);
  }

  .trait-card > p {
    font-size: 12px;
  }

  .trait-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    margin-top: 12px;
  }

  .trait-grid button {
    min-height: 120px;
    padding: 12px;
  }

  .trait-grid b { font-size: 11px; }
  .trait-grid span { margin-top: 7px; font-size: 11px; }
  .trait-grid small { margin-top: 4px; font-size: 9px; }

  .intro-card {
    width: min(560px, 72vw);
    padding: 18px 22px;
  }

  .intro-card h2 {
    margin: 5px 0 7px;
    font-size: clamp(27px, 8vh, 38px);
  }

  .intro-card p {
    min-height: 2.8em;
    margin: 6px 0;
    font-size: 13px;
    line-height: 1.4;
  }

  .intro-progress {
    margin: 10px 0;
  }

  .panel-header {
    padding: 10px 14px;
  }

  .panel-header h2 {
    font-size: 20px;
  }

  .panel-close {
    width: 44px;
    height: 44px;
  }

  #radio-controls {
    padding: 10px 14px 14px;
  }

  .radio-command-bar {
    padding: 7px 14px 6px;
  }

  .radio-command-status {
    margin-top: 4px;
  }

  #power-estimate {
    display: none;
  }

  .frequency-display {
    margin-top: 9px;
    padding: 8px 13px;
  }

  .frequency-display > span {
    font-size: 34px;
  }

  .radio-readout {
    min-height: 55px;
  }

  .radio-separator {
    margin: 9px 0;
  }

  .music-control p,
  .radio-warning {
    display: none;
  }

  .play-button {
    width: 46px;
    height: 46px;
  }

  .item-detail {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
    align-items: center;
    min-height: 72px;
    padding: 8px 10px;
  }

  .item-detail.is-empty {
    min-height: 54px;
  }

  .item-detail p {
    display: none;
  }

  .item-actions {
    display: flex;
    width: auto;
  }

  .item-actions .secondary-button,
  .item-actions .radio-action {
    flex: 0 0 auto;
    width: auto;
    min-width: 88px;
  }

  .map-frame {
    display: grid;
    grid-template-columns: minmax(190px, .9fr) minmax(0, 2.2fr);
    grid-template-rows: auto auto auto 1fr auto;
    width: 100%;
    overflow: hidden;
  }

  .map-frame .panel-header {
    grid-row: 1;
    grid-column: 1 / -1;
  }

  #map-canvas {
    grid-row: 2 / 6;
    grid-column: 2;
    width: calc(100% - 20px);
    height: calc(100dvh - 104px - var(--safe-top) - var(--safe-bottom));
    min-height: 210px;
    max-height: none;
    aspect-ratio: auto;
    margin: 10px;
  }

  .map-controls {
    grid-column: 1;
    grid-row: 2;
    grid-template-columns: 44px minmax(72px, 1fr) 44px;
    gap: 5px;
    padding: 10px 10px 5px;
  }

  .map-legend {
    grid-column: 1;
    grid-row: 3;
    align-content: start;
    gap: 8px;
    padding: 6px 12px;
  }

  .map-detail {
    grid-column: 1;
    grid-row: 4;
    min-height: 0;
    margin: 5px 10px;
    padding: 9px 10px;
    overflow: auto;
  }

  .map-detail p {
    font-size: 10px;
  }

  .map-caption {
    grid-column: 1;
    grid-row: 5;
    margin: 5px 10px 10px;
    font-size: 8px;
  }

  .custom-track-list {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
  }

  .custom-track-list label {
    grid-template-columns: 1fr;
    align-content: start;
    min-height: 110px;
    gap: 4px;
  }

  .custom-track-list input[type="file"]::file-selector-button {
    min-height: 34px;
    padding: 0 7px;
  }

  .death-card {
    width: min(720px, 92vw);
    padding: 18px 24px;
  }

  .death-card h2 {
    margin: 4px 0 7px;
    font-size: clamp(34px, 12vh, 50px);
  }

  .hard-checkpoint-label {
    margin-top: 10px;
    padding: 8px;
  }

  .death-actions {
    display: flex;
    margin-top: 10px;
  }
}

/* A 3+2 tray fits between the stick and action cluster at 480px landscape. */
@media (max-width: 600px) and (max-height: 520px) and (orientation: landscape) {
  .touch-ui .mobile-tools {
    bottom: calc(18px + var(--safe-bottom));
    display: grid;
    grid-template-columns: repeat(3, 44px);
    gap: 6px;
  }

  .mobile-tools button:nth-child(1) { grid-row: 1; grid-column: 1; }
  .mobile-tools button:nth-child(2) { grid-row: 1; grid-column: 2; }
  .mobile-tools button:nth-child(3) { grid-row: 1; grid-column: 3; }
  .mobile-tools button:nth-child(4) { grid-row: 2; grid-column: 2; }
  .mobile-tools button:nth-child(5) { grid-row: 2; grid-column: 3; }
}

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