:root {
  color-scheme: dark;
  --bg: #040806;
  --surface: rgba(8, 17, 12, 0.92);
  --surface-soft: rgba(10, 21, 15, 0.8);
  --surface-strong: rgba(3, 10, 6, 0.97);
  --text: #f2f7f1;
  --muted: #a6b4ac;
  --faint: #7e8d85;
  --line: rgba(210, 255, 226, 0.18);
  --line-strong: rgba(210, 255, 226, 0.32);
  --accent: #a8ff7c;
  --accent-ink: #0b160b;
  --cyan: #49dceb;
  --yellow: #ffd55f;
  --blue: #6e9dff;
  --danger: #ff756b;
  --shadow: 0 30px 90px rgba(0, 7, 3, 0.58);
  --screen-shadow: 0 38px 110px rgba(0, 7, 3, 0.68);
  --display: "Arial Narrow", "Avenir Next Condensed", "Helvetica Neue", sans-serif;
  --body: "Avenir Next", "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-family: var(--body);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
  scroll-behavior: smooth;
}

body {
  min-height: 100dvh;
  margin: 0;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 78% 2%, rgba(121, 216, 119, 0.16), transparent 30rem),
    radial-gradient(circle at 8% 86%, rgba(51, 133, 96, 0.11), transparent 36rem),
    linear-gradient(145deg, #09110c 0%, var(--bg) 46%, #020503 100%);
  color: var(--text);
}

body::before {
  position: fixed;
  inset: 0;
  z-index: 20;
  pointer-events: none;
  content: "";
  opacity: 0.12;
  background-image:
    repeating-linear-gradient(0deg, transparent 0 3px, rgba(255, 255, 255, 0.018) 3px 4px),
    radial-gradient(circle at 20% 30%, rgba(255, 255, 255, 0.06) 0 0.5px, transparent 0.8px);
  background-size: auto, 5px 5px;
  mix-blend-mode: soft-light;
}

a {
  color: inherit;
}

button {
  border: 0;
  color: inherit;
  font: inherit;
}

h1,
h2,
p,
dl,
dd,
ol {
  margin: 0;
}

.skip-link {
  position: fixed;
  top: 10px;
  left: 10px;
  z-index: 50;
  padding: 10px 14px;
  border-radius: 6px;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 800;
  transform: translateY(-160%);
  transition: transform 160ms ease;
}

.skip-link:focus {
  transform: translateY(0);
}

.app {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: clamp(8px, 1.6vw, 22px);
}

.shell {
  position: relative;
  isolation: isolate;
  width: min(1480px, 100%);
  display: grid;
  grid-template-rows: auto minmax(340px, 1fr) auto auto;
  gap: 8px;
}

.topbar,
.lower {
  border: 1px solid var(--line);
  background:
    radial-gradient(circle at 8% 0%, rgba(168, 255, 124, 0.055), transparent 22rem),
    linear-gradient(150deg, rgba(11, 22, 16, 0.96), rgba(4, 11, 7, 0.84));
  box-shadow: var(--shadow), inset 0 1px rgba(255, 255, 255, 0.035);
  backdrop-filter: blur(20px);
}

.topbar {
  position: relative;
  overflow: hidden;
  min-height: 88px;
  display: grid;
  grid-template-columns: minmax(420px, 1fr) minmax(610px, 0.96fr);
  gap: clamp(16px, 3vw, 42px);
  align-items: center;
  padding: 14px clamp(16px, 2vw, 28px);
  border-radius: 16px 16px 5px 5px;
}

.topbar::before {
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  content: "";
  background: var(--accent);
  box-shadow: 0 0 24px rgba(168, 255, 124, 0.62);
}

.title-block {
  min-width: 0;
}

.eyebrow,
.overlay-kicker,
.mission-label {
  color: var(--accent);
  font-family: var(--mono);
  font-size: 0.7rem;
  font-weight: 750;
  letter-spacing: 0.1em;
  line-height: 1;
  text-transform: uppercase;
}

.eyebrow {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 7px;
}

.eyebrow span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 14px rgba(167, 255, 131, 0.72);
}

.title-row {
  display: flex;
  align-items: baseline;
  gap: 14px;
}

h1,
h2 {
  font-family: var(--display);
  font-weight: 900;
  letter-spacing: -0.045em;
  text-wrap: balance;
}

h1 {
  font-size: clamp(2rem, 3.4vw, 3.55rem);
  line-height: 0.88;
  text-shadow: 0 8px 32px rgba(0, 0, 0, 0.38);
}

.best-chip {
  flex: none;
  padding: 5px 7px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.66rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.best-chip strong {
  margin-left: 4px;
  color: var(--text);
  font-size: 0.82rem;
  font-variant-numeric: tabular-nums;
}

.tagline {
  max-width: 58ch;
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.35;
  text-wrap: pretty;
}

.status {
  min-width: 0;
  display: grid;
  grid-template-columns: repeat(4, minmax(76px, 0.82fr)) minmax(120px, 1.25fr);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(0, 6, 3, 0.5);
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.025), 0 12px 36px rgba(0, 0, 0, 0.2);
  font-variant-numeric: tabular-nums;
}

.stat,
.heat {
  min-height: 62px;
  display: grid;
  align-content: center;
  gap: 5px;
  padding: 9px 11px;
  border-left: 1px solid var(--line);
}

.status > :first-child {
  border-left: 0;
}

.stat dt,
.heat dt {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.62rem;
  font-weight: 750;
  letter-spacing: 0.08em;
  line-height: 1;
  text-transform: uppercase;
}

.stat dd {
  font-family: var(--mono);
  font-size: clamp(1rem, 1.7vw, 1.28rem);
  font-weight: 800;
  line-height: 1;
}

.stat-time {
  background: rgba(168, 255, 124, 0.055);
}

.stat-time dd {
  color: var(--accent);
  text-shadow: 0 0 18px rgba(168, 255, 124, 0.18);
}

.stat-score dd {
  color: #fff;
}

#combo {
  color: var(--yellow);
}

.heat dd {
  min-width: 0;
}

.heat-track {
  width: 100%;
  height: 9px;
  display: block;
  overflow: hidden;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.08);
  box-shadow: inset 0 1px 6px rgba(0, 0, 0, 0.5);
}

.heat b {
  width: 0%;
  height: 100%;
  display: block;
  background: linear-gradient(90deg, var(--accent), var(--yellow) 62%, var(--danger));
  transition: width 120ms ease;
}

.heat.is-hot {
  background: rgba(94, 22, 19, 0.22);
}

.heat.is-hot b {
  box-shadow: 0 0 14px rgba(255, 117, 107, 0.68);
}

.stage-wrap {
  position: relative;
  min-height: 400px;
  height: min(56dvh, 660px);
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: #020503;
  box-shadow:
    var(--screen-shadow),
    inset 0 0 0 1px rgba(168, 255, 124, 0.06),
    inset 0 2px 26px rgba(0, 0, 0, 0.48);
}

.stage-wrap::before,
.stage-wrap::after {
  position: absolute;
  inset: 0;
  pointer-events: none;
  content: "";
}

.stage-wrap::before {
  z-index: 1;
  background:
    linear-gradient(112deg, rgba(255, 255, 255, 0.035), transparent 21%, transparent 76%, rgba(168, 255, 124, 0.025)),
    radial-gradient(circle at 50% 50%, transparent 58%, rgba(0, 4, 2, 0.28) 100%);
  mix-blend-mode: screen;
}

.stage-wrap::after {
  z-index: 3;
  inset: 9px;
  background:
    linear-gradient(var(--accent), var(--accent)) top left / 42px 1px no-repeat,
    linear-gradient(var(--accent), var(--accent)) top left / 1px 42px no-repeat,
    linear-gradient(var(--accent), var(--accent)) top right / 42px 1px no-repeat,
    linear-gradient(var(--accent), var(--accent)) top right / 1px 42px no-repeat,
    linear-gradient(var(--accent), var(--accent)) bottom left / 42px 1px no-repeat,
    linear-gradient(var(--accent), var(--accent)) bottom left / 1px 42px no-repeat,
    linear-gradient(var(--accent), var(--accent)) bottom right / 42px 1px no-repeat,
    linear-gradient(var(--accent), var(--accent)) bottom right / 1px 42px no-repeat;
  opacity: 0.28;
}

canvas {
  position: relative;
  z-index: 0;
  width: 100%;
  height: 100%;
  display: block;
  background: #020503;
  outline: none;
  touch-action: none;
}

canvas:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: -4px;
}

.stage-hud {
  position: absolute;
  top: 12px;
  right: 14px;
  left: 14px;
  z-index: 4;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  pointer-events: none;
}

.stage-hud span {
  padding: 8px 10px;
  border: 1px solid rgba(210, 255, 226, 0.23);
  border-radius: 4px;
  background: rgba(2, 8, 5, 0.85);
  color: var(--text);
  font-family: var(--mono);
  font-size: 0.66rem;
  font-weight: 750;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.28), inset 0 1px rgba(255, 255, 255, 0.035);
  backdrop-filter: blur(10px);
}

.stage-hud strong {
  color: var(--accent);
}

.overlay {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: grid;
  place-items: center start;
  padding: clamp(8px, 1.2vw, 16px) clamp(18px, 4vw, 58px);
  background:
    linear-gradient(90deg, rgba(1, 6, 3, 0.94) 0%, rgba(1, 6, 3, 0.68) 46%, rgba(1, 5, 3, 0.08) 79%),
    radial-gradient(circle at 25% 47%, rgba(63, 143, 83, 0.2), transparent 44%);
  transition: opacity 180ms ease, visibility 180ms ease;
  overflow-y: auto;
}

.overlay.is-hidden {
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
}

.overlay-panel {
  position: relative;
  width: min(560px, 94%);
  max-height: 100%;
  padding: clamp(19px, 2vw, 24px);
  overflow-y: auto;
  border: 1px solid rgba(168, 255, 124, 0.46);
  border-radius: 14px;
  background: linear-gradient(150deg, rgba(8, 17, 11, 0.97), rgba(3, 8, 5, 0.95));
  box-shadow:
    0 32px 100px rgba(0, 0, 0, 0.72),
    0 0 64px rgba(77, 160, 96, 0.065),
    inset 0 1px rgba(255, 255, 255, 0.05),
    inset 0 0 60px rgba(77, 160, 96, 0.045);
}

.overlay-panel::before {
  position: absolute;
  top: -1px;
  left: 24px;
  width: 88px;
  height: 2px;
  content: "";
  background: var(--accent);
  box-shadow: 0 0 18px rgba(168, 255, 124, 0.48);
}

.overlay.has-results .overlay-panel {
  padding: 16px 20px;
}

.overlay.has-results .overlay-panel h2 {
  margin-top: 5px;
  font-size: clamp(2rem, 3.8vw, 2.8rem);
}

.overlay.has-results #overlay-copy {
  margin-top: 6px;
  font-size: 0.84rem;
  line-height: 1.35;
}

.overlay-panel h2 {
  max-width: none;
  margin-top: 8px;
  font-size: clamp(2.1rem, 4.4vw, 3.35rem);
  line-height: 0.92;
  text-shadow: 0 10px 38px rgba(0, 0, 0, 0.48);
}

#overlay-copy {
  max-width: 50ch;
  margin-top: 10px;
  color: var(--muted);
  font-size: 0.96rem;
  line-height: 1.5;
  text-wrap: pretty;
}

.briefing-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px;
  margin-top: 14px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--line);
  font-variant-numeric: tabular-nums;
}

.briefing-stats div {
  display: grid;
  gap: 3px;
  padding: 9px 11px;
  background: rgba(2, 9, 5, 0.94);
}

.briefing-stats dt {
  color: var(--faint);
  font-family: var(--mono);
  font-size: 0.58rem;
  font-weight: 760;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.briefing-stats dd {
  color: var(--text);
  font-size: 0.78rem;
  font-weight: 760;
}

.control-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-top: 15px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: rgba(1, 7, 4, 0.42);
  overflow: hidden;
}

.control-grid div {
  min-height: 48px;
  display: grid;
  align-items: center;
  justify-items: center;
  gap: 2px;
  padding: 6px;
  border-left: 1px solid rgba(210, 255, 226, 0.09);
}

.control-grid div:first-child {
  border-left: 0;
}

kbd {
  min-width: 28px;
  padding: 3px 5px;
  border: 1px solid var(--line-strong);
  border-bottom-color: rgba(210, 255, 226, 0.48);
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.045);
  color: var(--text);
  font-family: var(--mono);
  font-size: 0.73rem;
  font-weight: 800;
}

.control-grid span {
  color: var(--faint);
  font-size: 0.76rem;
  font-weight: 650;
}

.how-to {
  max-width: 60ch;
  margin-top: 10px;
  color: rgba(242, 247, 241, 0.76);
  font-size: 0.77rem;
  line-height: 1.45;
}

.results {
  margin-top: 22px;
}

.overlay.has-results .results {
  margin-top: 10px;
}

.result-hero {
  display: grid;
  grid-template-columns: 0.7fr 1.3fr;
  gap: 1px;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--line);
}

.result-hero > div {
  display: grid;
  gap: 4px;
  padding: 14px 16px;
  background: rgba(3, 9, 5, 0.92);
}

.overlay.has-results .result-hero > div {
  padding: 9px 12px;
}

.result-hero span,
.result-breakdown dt {
  color: var(--faint);
  font-family: var(--mono);
  font-size: 0.62rem;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.result-hero strong {
  color: var(--accent);
  font-family: var(--mono);
  font-size: clamp(1.55rem, 4vw, 2.35rem);
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.overlay.has-results .result-hero strong {
  font-size: clamp(1.35rem, 3vw, 1.85rem);
}

.result-breakdown {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  margin-top: 8px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.result-breakdown div {
  display: grid;
  gap: 4px;
  padding: 10px 4px;
  border-left: 1px solid var(--line);
}

.overlay.has-results .result-breakdown div {
  padding-block: 6px;
}

.result-breakdown div:first-child {
  border-left: 0;
}

.result-breakdown dd {
  font-family: var(--mono);
  font-size: 0.83rem;
  font-weight: 800;
}

#result-note {
  margin-top: 10px;
  color: var(--muted);
  font-size: 0.78rem;
}

.overlay.has-results #result-note {
  margin-top: 6px;
  font-size: 0.7rem;
}

.overlay.has-results .overlay-actions {
  margin-top: 9px;
}

.overlay-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  margin-top: 14px;
}

.action-hint {
  align-self: center;
  color: var(--faint);
  font-family: var(--mono);
  font-size: 0.62rem;
  letter-spacing: 0.03em;
}

.overlay.has-results .action-hint {
  display: none;
}

.overlay.has-results .briefing-stats {
  display: none;
}

.overlay-actions button,
.controls button {
  min-height: 44px;
  cursor: pointer;
  border: 1px solid rgba(167, 255, 131, 0.46);
  border-radius: 7px;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 0.85rem;
  font-weight: 820;
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease, box-shadow 160ms ease;
}

.overlay-actions button {
  min-width: 150px;
  padding: 0 18px;
}

#start-button {
  min-height: 52px;
  min-width: 184px;
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 28px;
  padding-inline: 20px 15px;
  box-shadow: 0 14px 34px rgba(91, 193, 84, 0.2), inset 0 1px rgba(255, 255, 255, 0.38);
}

#start-button::after {
  font-family: var(--mono);
  font-size: 1rem;
  content: "→";
}

.overlay-actions .secondary-action,
.controls button {
  border-color: var(--line-strong);
  background: rgba(10, 22, 15, 0.88);
  color: var(--text);
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.035);
}

.is-hidden {
  display: none !important;
}

button:disabled {
  cursor: default;
  opacity: 0.46;
}

button:focus-visible,
a:focus-visible {
  outline: 3px solid #fff;
  outline-offset: 3px;
}

@media (hover: hover) {
  .overlay-actions button:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 12px 30px rgba(87, 184, 84, 0.24);
  }

  .overlay-actions .secondary-action:hover:not(:disabled),
  .controls button:hover:not(:disabled) {
    border-color: rgba(167, 255, 131, 0.48);
    background: rgba(19, 40, 27, 0.94);
    box-shadow: inset 0 1px rgba(255, 255, 255, 0.05), 0 8px 24px rgba(0, 0, 0, 0.28);
  }

  .built a:hover {
    color: var(--text);
  }
}

button:active:not(:disabled) {
  transform: translateY(1px) scale(0.985);
}

.lower {
  min-height: 78px;
  display: grid;
  grid-template-columns: minmax(250px, 0.82fr) minmax(480px, 1.45fr) auto;
  gap: 18px;
  align-items: center;
  padding: 11px 14px;
  border-radius: 5px 5px 16px 16px;
  box-shadow: 0 24px 70px rgba(0, 7, 3, 0.48), inset 0 1px rgba(255, 255, 255, 0.03);
}

.mission {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.mission strong {
  overflow: hidden;
  font-size: 0.98rem;
  line-height: 1.15;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mission > span:last-child {
  overflow: hidden;
  color: var(--muted);
  font-size: 0.76rem;
  line-height: 1.3;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.checklist {
  min-width: 0;
  display: grid;
  grid-template-columns: repeat(5, minmax(82px, 1fr));
  gap: 3px;
  list-style: none;
}

.checklist li {
  position: relative;
  min-width: 0;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 2px 8px;
  align-items: center;
  padding: 4px 10px;
  border: 1px solid transparent;
  border-radius: 5px;
  color: var(--faint);
  transition: background 180ms ease, border-color 180ms ease, color 180ms ease;
}

.checklist li:first-child {
  border-left: 0;
}

.checklist .step {
  grid-row: 1 / 3;
  color: rgba(242, 247, 241, 0.32);
  font-family: var(--mono);
  font-size: 0.65rem;
}

.checklist li > span:nth-child(2) {
  overflow: hidden;
  font-size: 0.75rem;
  font-weight: 760;
  line-height: 1.1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.checklist em {
  color: var(--faint);
  font-family: var(--mono);
  font-size: 0.55rem;
  font-style: normal;
  letter-spacing: 0.05em;
  line-height: 1;
  text-transform: uppercase;
}

.checklist li.is-current {
  border-color: rgba(73, 220, 235, 0.25);
  background: rgba(73, 220, 235, 0.065);
  color: var(--text);
}

.checklist li.is-current .step,
.checklist li.is-current em {
  color: var(--cyan);
}

.checklist li.is-done {
  background: rgba(168, 255, 124, 0.045);
  color: var(--text);
}

.checklist li.is-done .step,
.checklist li.is-done em {
  color: var(--accent);
}

.controls {
  display: flex;
  gap: 7px;
}

.controls button {
  min-width: 78px;
  padding: 0 11px;
  font-size: 0.76rem;
}

#dash {
  border-color: rgba(255, 213, 95, 0.38);
  color: #fff6d2;
}

#dash.is-ready {
  background: rgba(75, 58, 15, 0.84);
  box-shadow: 0 0 22px rgba(255, 213, 95, 0.16), inset 0 1px rgba(255, 255, 255, 0.05);
}

#dash.is-shielded {
  border-color: rgba(255, 213, 95, 0.72);
}

#dash.is-cooling {
  box-shadow: none;
}

.built {
  min-height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 0 4px;
  color: var(--faint);
  font-size: 0.7rem;
  line-height: 1.3;
  text-align: center;
}

.built a {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.65rem;
  font-weight: 750;
  letter-spacing: 0.04em;
  text-decoration: none;
  text-transform: uppercase;
  transition: color 160ms ease;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 1120px) {
  .topbar {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .status {
    width: 100%;
  }

  .lower {
    grid-template-columns: 1fr auto;
  }

  .mission {
    grid-column: 1 / -1;
  }
}

@media (max-width: 760px) {
  body {
    padding-bottom: 76px;
  }

  .app {
    min-height: auto;
    place-items: start center;
    padding: 6px;
  }

  .shell {
    grid-template-rows: auto minmax(300px, 1fr) auto auto;
    gap: 6px;
  }

  .topbar {
    gap: 10px;
    padding: 11px;
    border-radius: 11px 11px 4px 4px;
  }

  .eyebrow {
    margin-bottom: 6px;
    font-size: 0.61rem;
  }

  .title-row {
    align-items: center;
    justify-content: space-between;
    gap: 8px;
  }

  h1 {
    font-size: clamp(1.8rem, 10vw, 2.65rem);
  }

  .best-chip {
    display: grid;
    text-align: right;
  }

  .tagline {
    margin-top: 6px;
    font-size: 0.78rem;
  }

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

  .stat,
  .heat {
    min-height: 48px;
    padding: 7px 8px;
  }

  .status > :nth-child(4) {
    border-top: 1px solid var(--line);
    border-left: 0;
  }

  .heat {
    grid-column: span 2;
    border-top: 1px solid var(--line);
  }

  .stage-wrap {
    min-height: 350px;
    height: min(62dvh, 540px);
  }

  .stage-wrap::after {
    inset: 6px;
    opacity: 0.22;
  }

  .stage-hud {
    top: 8px;
    right: 8px;
    left: 8px;
  }

  .stage-hud span {
    padding: 6px;
    font-size: 0.57rem;
  }

  .overlay {
    place-items: center;
    padding: 10px;
    background: rgba(1, 5, 3, 0.76);
    overflow-y: auto;
  }

  .overlay-panel {
    width: min(100%, 520px);
    max-height: 100%;
    padding: 18px;
    overflow-y: auto;
  }

  .briefing-stats div {
    padding: 8px;
  }

  .overlay-panel h2 {
    font-size: clamp(2rem, 11vw, 3.15rem);
  }

  #overlay-copy {
    font-size: 0.85rem;
  }

  .control-grid {
    margin-top: 15px;
  }

  .control-grid div {
    min-height: 42px;
  }

  .how-to {
    font-size: 0.7rem;
  }

  .overlay-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .action-hint {
    grid-column: 1 / -1;
    text-align: center;
  }

  .overlay-actions button {
    min-width: 0;
    width: 100%;
  }

  #start-button {
    grid-column: 1 / -1;
  }

  .lower {
    min-height: 0;
    grid-template-columns: 1fr;
    gap: 8px;
    padding: 10px;
    border-radius: 4px 4px 11px 11px;
    backdrop-filter: none;
  }

  .mission {
    grid-column: auto;
  }

  .checklist {
    grid-template-columns: repeat(5, minmax(102px, 1fr));
    overflow-x: auto;
    scrollbar-width: thin;
  }

  .checklist li {
    min-height: 42px;
    padding: 4px 8px;
  }

  .controls {
    position: fixed;
    right: 8px;
    bottom: max(8px, env(safe-area-inset-bottom));
    left: 8px;
    z-index: 15;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 5px;
    padding: 6px;
    border: 1px solid var(--line-strong);
    border-radius: 10px;
    background: rgba(4, 10, 6, 0.92);
    box-shadow: 0 18px 48px rgba(0, 0, 0, 0.58);
    backdrop-filter: blur(18px);
  }

  .controls button {
    min-width: 0;
    min-height: 48px;
    padding: 0 6px;
    font-size: 0.69rem;
  }

  .built {
    min-height: 38px;
    flex-wrap: wrap;
    gap: 4px 12px;
    font-size: 0.62rem;
  }
}

@media (max-width: 380px) {
  .tagline {
    display: none;
  }

  .overlay-panel {
    padding: 15px;
  }

  .briefing-stats {
    margin-top: 9px;
  }

  .briefing-stats div {
    padding: 6px 5px;
    text-align: center;
  }

  .briefing-stats dt {
    display: none;
  }

  .briefing-stats dd {
    font-size: 0.66rem;
  }

  .control-grid {
    margin-top: 9px;
  }

  .control-grid span {
    display: none;
  }

  .result-breakdown dd {
    font-size: 0.72rem;
  }
}

@media (max-width: 380px) and (max-height: 640px) {
  .overlay-panel {
    display: flex;
    flex-direction: column;
  }

  .overlay-actions {
    order: 1;
    flex: 0 0 auto;
    margin-top: 10px;
  }

  .control-grid,
  .how-to {
    order: 2;
    flex: 0 0 auto;
  }
}

@media (max-width: 760px) and (max-height: 480px) and (orientation: landscape) {
  .topbar {
    grid-template-columns: minmax(210px, 0.8fr) minmax(350px, 1.2fr);
    gap: 10px;
    padding: 8px 10px;
  }

  .eyebrow {
    margin-bottom: 4px;
  }

  h1 {
    font-size: clamp(1.7rem, 5vw, 2.2rem);
  }

  .best-chip,
  .tagline {
    display: none;
  }

  .status {
    grid-template-columns: repeat(4, minmax(54px, 0.8fr)) minmax(92px, 1.25fr);
  }

  .stat,
  .heat {
    min-height: 44px;
    padding: 6px 7px;
    border-top: 0 !important;
  }

  .heat {
    grid-column: auto;
  }

  .stage-wrap {
    min-height: 260px;
    height: calc(100dvh - 106px);
  }

  .overlay {
    place-items: center start;
    padding: 7px 46px 7px 10px;
  }

  .overlay-panel {
    width: min(500px, 88%);
    padding: 14px 17px;
  }

  .overlay-panel h2 {
    margin-top: 4px;
    font-size: 2rem;
  }

  #overlay-copy {
    margin-top: 6px;
    font-size: 0.76rem;
    line-height: 1.35;
  }

  .control-grid {
    display: none;
  }

  .briefing-stats {
    display: none;
  }

  .how-to {
    margin-top: 7px;
    font-size: 0.65rem;
  }

  .overlay-actions {
    margin-top: 8px;
  }

  .overlay-actions button {
    min-height: 40px;
  }

  .built {
    display: none;
  }
}

@media (max-height: 700px) and (min-width: 761px) {
  .app {
    padding-block: 7px;
  }

  .topbar {
    min-height: 78px;
    padding-block: 10px;
  }

  .tagline {
    margin-top: 5px;
  }

  .stage-wrap {
    min-height: 350px;
    height: 53dvh;
  }

  .lower {
    min-height: 70px;
  }
}

@media (prefers-contrast: more) {
  :root {
    --muted: #d0d8d3;
    --faint: #b1bdb6;
    --line: rgba(255, 255, 255, 0.34);
    --line-strong: rgba(255, 255, 255, 0.56);
  }
}

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