:root {
  color-scheme: dark;
  --ink: #080907;
  --ink-soft: rgba(8, 9, 7, 0.74);
  --panel: rgba(12, 14, 12, 0.68);
  --line: rgba(220, 229, 218, 0.16);
  --line-bright: rgba(220, 229, 218, 0.34);
  --paper: #e7eadf;
  --muted: #8f968c;
  --ember: #ff5a20;
  --ember-soft: #c63b18;
  --cyan: #8ce5df;
  --cyan-soft: rgba(140, 229, 223, 0.18);
  --danger: #ff3f31;
  --display: "Bahnschrift Condensed", "DIN Condensed", "Arial Narrow", sans-serif;
  --body: "Bahnschrift", "Aptos", "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--ink);
  color: var(--paper);
  font-family: var(--body);
  font-size: 16px;
}

button,
kbd,
output {
  font: inherit;
}

button {
  color: inherit;
}

button:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 4px;
}

#game-shell {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 420px;
  isolation: isolate;
  background:
    radial-gradient(circle at 30% 8%, rgba(255, 90, 32, 0.11), transparent 30%),
    #050605;
}

#game {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.atmosphere,
.scanlines {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 2;
}

.atmosphere {
  background:
    radial-gradient(ellipse at center, transparent 42%, rgba(2, 3, 2, 0.52) 100%),
    linear-gradient(180deg, rgba(0, 0, 0, 0.13), transparent 42%, rgba(255, 72, 22, 0.04));
  box-shadow: inset 0 0 120px rgba(0, 0, 0, 0.8);
}

.scanlines {
  opacity: 0.1;
  background: repeating-linear-gradient(
    to bottom,
    transparent 0,
    transparent 3px,
    rgba(255, 255, 255, 0.05) 4px
  );
  mix-blend-mode: soft-light;
}

.hud-panel {
  position: absolute;
  z-index: 5;
  pointer-events: none;
  transition: opacity 400ms ease, transform 500ms cubic-bezier(.2, .8, .2, 1);
}

body:not(.flight-active) .hud-panel,
body:not(.flight-active) .target-copy {
  opacity: 0.28;
}

.topbar {
  top: max(20px, env(safe-area-inset-top));
  left: max(24px, env(safe-area-inset-left));
  right: max(24px, env(safe-area-inset-right));
  height: 66px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: start;
  border-top: 1px solid var(--line-bright);
  padding-top: 10px;
}

.topbar::before,
.topbar::after {
  content: "";
  position: absolute;
  top: -2px;
  width: 42px;
  height: 3px;
  background: var(--ember);
  box-shadow: 0 0 14px rgba(255, 90, 32, 0.52);
}

.topbar::after {
  right: 0;
  background: var(--cyan);
  box-shadow: 0 0 14px rgba(140, 229, 223, 0.42);
}

.brand-lockup {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.brand-lockup .brand-kicker,
.panel-label,
.metric > span,
.system-row span,
.score-block > span,
.score-block small,
.mission-copy span,
.target-copy,
.result-kicker,
.hero-eyebrow,
.control-hint span {
  font-family: var(--display);
  font-size: 0.72rem;
  line-height: 1;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
}

.brand-lockup strong {
  font-family: var(--display);
  font-size: 1.28rem;
  line-height: 1;
  letter-spacing: 0.08em;
  font-weight: 650;
}

.mission-copy {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  min-width: 280px;
}

.mission-copy b {
  font-family: var(--display);
  font-size: 0.84rem;
  letter-spacing: 0.11em;
  font-weight: 500;
}

.status-chip {
  justify-self: end;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-width: 132px;
  padding: 8px 11px;
  border: 1px solid var(--line);
  background: rgba(5, 7, 6, 0.46);
  font-family: var(--display);
  font-size: 0.7rem;
  letter-spacing: 0.15em;
}

.status-chip i {
  width: 6px;
  height: 6px;
  background: var(--muted);
  border-radius: 50%;
}

.status-chip[data-state="live"] i,
.status-chip[data-state="safe"] i {
  background: var(--cyan);
  box-shadow: 0 0 10px var(--cyan);
}

.status-chip[data-state="danger"] i {
  background: var(--danger);
  box-shadow: 0 0 10px var(--danger);
  animation: status-pulse 800ms steps(2, jump-none) infinite;
}

.telemetry,
.systems {
  top: 50%;
  width: clamp(190px, 17vw, 260px);
  transform: translateY(-50%);
  padding: 16px;
  border-block: 1px solid var(--line);
  background: linear-gradient(90deg, rgba(8, 10, 8, 0.68), rgba(8, 10, 8, 0.08));
}

.telemetry {
  left: max(24px, env(safe-area-inset-left));
  border-left: 2px solid rgba(255, 90, 32, 0.66);
}

.systems {
  right: max(24px, env(safe-area-inset-right));
  border-right: 2px solid rgba(140, 229, 223, 0.56);
  background: linear-gradient(270deg, rgba(8, 10, 8, 0.68), rgba(8, 10, 8, 0.08));
}

.panel-label {
  margin: 0 0 18px;
  color: var(--paper);
}

.metric {
  min-width: 0;
}

.metric > span,
.system-row span,
.score-block > span {
  display: block;
  margin-bottom: 5px;
  font-size: 0.62rem;
}

.metric strong {
  display: flex;
  align-items: baseline;
  gap: 4px;
  font-family: var(--display);
  font-weight: 350;
  font-size: 1.22rem;
  letter-spacing: 0.04em;
  font-variant-numeric: tabular-nums;
}

.metric strong small {
  font-size: 0.56rem;
  color: var(--muted);
  letter-spacing: 0.08em;
}

.metric-hero strong {
  font-size: clamp(2.8rem, 4.2vw, 4.4rem);
  line-height: 0.88;
  letter-spacing: -0.04em;
}

.metric-hero strong small {
  font-size: 0.7rem;
  letter-spacing: 0.12em;
}

.micro-rule,
.bar {
  height: 3px;
  margin-top: 10px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.11);
}

.micro-rule i,
.bar i {
  display: block;
  height: 100%;
  width: 100%;
  background: var(--ember);
  box-shadow: 0 0 9px currentColor;
  transform-origin: left center;
  transition: transform 120ms linear, background-color 200ms ease;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px 14px;
  padding-top: 22px;
}

.safety-readout {
  margin-top: 22px;
  padding: 10px 11px;
  border: 1px solid var(--cyan-soft);
  background: rgba(140, 229, 223, 0.06);
}

.safety-readout span {
  display: block;
  color: var(--muted);
  font-family: var(--display);
  font-size: 0.56rem;
  letter-spacing: 0.14em;
}

.safety-readout b {
  display: block;
  margin-top: 3px;
  color: var(--cyan);
  font-family: var(--display);
  font-size: 0.86rem;
  font-weight: 500;
  letter-spacing: 0.11em;
}

.safety-readout[data-safety="danger"] {
  border-color: rgba(255, 63, 49, 0.36);
  background: rgba(255, 63, 49, 0.08);
}

.safety-readout[data-safety="danger"] b {
  color: var(--danger);
}

.system-row {
  margin-bottom: 18px;
}

.system-row > div:first-child {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.system-row b {
  font-family: var(--display);
  font-size: 1rem;
  font-weight: 400;
  letter-spacing: 0.05em;
}

.system-row .bar i {
  background: var(--cyan);
}

.score-block {
  margin-top: 30px;
  padding-top: 15px;
  border-top: 1px solid var(--line);
}

.score-block strong {
  display: block;
  font-family: var(--display);
  font-size: clamp(2.1rem, 3.2vw, 3.6rem);
  line-height: 0.95;
  font-weight: 300;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}

.score-block small {
  display: block;
  margin-top: 7px;
  font-size: 0.58rem;
}

.mission-dots {
  display: flex;
  gap: 7px;
  margin-top: 20px;
}

.mission-dots i {
  width: 26px;
  height: 3px;
  background: rgba(255, 255, 255, 0.12);
}

.mission-dots i.complete {
  background: var(--ember);
  box-shadow: 0 0 7px rgba(255, 90, 32, 0.5);
}

.mission-dots i.current {
  background: var(--cyan);
  box-shadow: 0 0 7px rgba(140, 229, 223, 0.5);
}

.target-copy {
  position: absolute;
  z-index: 4;
  left: 50%;
  top: 50%;
  width: min(42vw, 540px);
  display: flex;
  align-items: center;
  gap: 13px;
  transform: translate(-50%, 155px);
  pointer-events: none;
  font-size: 0.53rem;
  opacity: 0.7;
}

.target-copy i {
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--line-bright), transparent);
}

.control-deck {
  left: max(24px, env(safe-area-inset-left));
  right: max(24px, env(safe-area-inset-right));
  bottom: max(18px, env(safe-area-inset-bottom));
  display: flex;
  align-items: center;
  gap: 26px;
  min-height: 48px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
  pointer-events: auto;
}

.control-hint {
  display: flex;
  align-items: center;
  gap: 5px;
}

.control-hint span {
  margin-left: 5px;
  font-size: 0.56rem;
}

kbd {
  display: inline-grid;
  place-items: center;
  width: 25px;
  height: 24px;
  border: 1px solid var(--line-bright);
  border-bottom-color: rgba(255, 255, 255, 0.48);
  background: rgba(0, 0, 0, 0.28);
  font-family: var(--display);
  font-size: 0.63rem;
}

.deck-actions {
  display: flex;
  gap: 8px;
  margin-left: auto;
}

.icon-button,
.secondary-button,
.text-button {
  border: 0;
  background: none;
  cursor: pointer;
  font-family: var(--display);
  font-size: 0.62rem;
  letter-spacing: 0.13em;
}

.icon-button {
  padding: 8px 10px;
  border: 1px solid var(--line);
  color: var(--muted);
}

.icon-button:hover {
  border-color: var(--line-bright);
  color: var(--paper);
}

.overlay {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: max(22px, env(safe-area-inset-top)) max(22px, env(safe-area-inset-right)) max(22px, env(safe-area-inset-bottom)) max(22px, env(safe-area-inset-left));
  overflow: auto;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  background: rgba(4, 5, 4, 0.46);
  backdrop-filter: blur(3px);
  transition: opacity 340ms ease, visibility 340ms;
}

.overlay.overlay-visible {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.overlay-card {
  position: relative;
  width: min(94vw, 820px);
  padding: clamp(28px, 5vw, 64px);
  border: 1px solid var(--line-bright);
  background:
    linear-gradient(135deg, rgba(255, 90, 32, 0.07), transparent 35%),
    rgba(7, 9, 7, 0.88);
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.52);
  transform: translateY(18px) scale(0.99);
  transition: transform 500ms cubic-bezier(.2, .8, .2, 1);
}

.overlay-visible .overlay-card {
  transform: translateY(0) scale(1);
}

.overlay-card::before,
.overlay-card::after {
  content: "";
  position: absolute;
  width: 54px;
  height: 2px;
  background: var(--ember);
  box-shadow: 0 0 18px rgba(255, 90, 32, 0.6);
}

.overlay-card::before {
  top: -1px;
  left: 32px;
}

.overlay-card::after {
  right: 32px;
  bottom: -1px;
  background: var(--cyan);
  box-shadow: 0 0 18px rgba(140, 229, 223, 0.55);
}

.hero-eyebrow {
  display: flex;
  justify-content: space-between;
  padding-bottom: 17px;
  border-bottom: 1px solid var(--line);
  font-size: 0.62rem;
}

.hero-eyebrow b {
  color: var(--cyan);
  font-weight: 500;
}

h1 {
  margin: clamp(30px, 5vh, 58px) 0 0;
  font-family: var(--display);
  font-size: clamp(4.2rem, 10vw, 8.8rem);
  line-height: 0.72;
  letter-spacing: -0.045em;
  font-weight: 620;
  text-transform: uppercase;
  color: var(--paper);
  text-shadow: 0 0 42px rgba(255, 90, 32, 0.1);
}

h1 span {
  display: block;
  margin-left: 0.07em;
  color: var(--ember);
  font-size: 0.265em;
  line-height: 1.3;
  letter-spacing: 0.31em;
}

.hero-copy {
  max-width: 590px;
  margin: 32px 0;
  font-size: clamp(1rem, 1.45vw, 1.18rem);
  line-height: 1.62;
  color: #b8beb5;
}

.briefing-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  margin: 0 0 34px;
  background: var(--line);
  border: 1px solid var(--line);
}

.briefing-grid div {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 11px;
  min-height: 76px;
  padding: 14px;
  background: rgba(8, 9, 7, 0.96);
}

.briefing-grid b {
  color: var(--ember);
  font-family: var(--display);
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.12em;
}

.briefing-grid span {
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 1.45;
}

.hero-actions {
  display: flex;
  align-items: stretch;
  gap: 12px;
}

.primary-button {
  position: relative;
  min-width: 260px;
  min-height: 64px;
  padding: 13px 54px 13px 18px;
  overflow: hidden;
  border: 1px solid var(--ember);
  background: var(--ember);
  color: #110b07;
  text-align: left;
  cursor: pointer;
  transition: transform 180ms ease, background-color 180ms ease, box-shadow 180ms ease;
}

.primary-button::after {
  content: "";
  position: absolute;
  top: 50%;
  right: 20px;
  width: 17px;
  height: 17px;
  border-top: 1px solid currentColor;
  border-right: 1px solid currentColor;
  transform: translateY(-50%) rotate(45deg);
}

.primary-button:hover {
  background: #ff7442;
  box-shadow: 0 10px 34px rgba(255, 90, 32, 0.24);
  transform: translateY(-2px);
}

.primary-button span,
.primary-button small {
  display: block;
  font-family: var(--display);
  letter-spacing: 0.13em;
}

.primary-button span {
  font-size: 0.84rem;
  font-weight: 650;
}

.primary-button small {
  margin-top: 4px;
  font-size: 0.56rem;
  opacity: 0.65;
}

.secondary-button {
  min-width: 180px;
  padding: 14px 18px;
  border: 1px solid var(--line-bright);
  color: var(--paper);
  transition: border-color 180ms ease, background-color 180ms ease;
}

.secondary-button:hover {
  border-color: var(--cyan);
  background: var(--cyan-soft);
}

.orientation-note {
  display: none;
  margin: 18px 0 0;
  color: var(--muted);
  font-size: 0.72rem;
}

.result-card,
.pause-card {
  width: min(92vw, 570px);
  text-align: center;
}

.result-kicker {
  margin: 0 0 12px;
  color: var(--cyan);
}

.result-kicker.danger {
  color: var(--danger);
}

.result-card h2,
.pause-card h2 {
  margin: 0;
  font-family: var(--display);
  font-size: clamp(3rem, 7vw, 5.8rem);
  line-height: 0.92;
  font-weight: 550;
  letter-spacing: -0.035em;
}

.result-card > p:not(.result-kicker),
.pause-card > p:not(.result-kicker) {
  margin: 19px auto 28px;
  max-width: 430px;
  color: var(--muted);
  line-height: 1.55;
}

.result-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  margin: 0 0 28px;
  border-block: 1px solid var(--line);
}

.result-stats div {
  padding: 15px 8px;
  border-right: 1px solid var(--line);
}

.result-stats div:last-child {
  border-right: 0;
}

.result-stats span,
.result-stats b {
  display: block;
  font-family: var(--display);
}

.result-stats span {
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 0.57rem;
  letter-spacing: 0.12em;
}

.result-stats b {
  font-size: 1.45rem;
  font-weight: 400;
  font-variant-numeric: tabular-nums;
}

.result-card .primary-button,
.pause-card .primary-button {
  width: 100%;
  text-align: left;
}

.text-button {
  margin-top: 20px;
  padding: 8px;
  color: var(--muted);
}

.text-button:hover {
  color: var(--paper);
}

.touch-controls {
  position: absolute;
  z-index: 12;
  left: max(14px, env(safe-area-inset-left));
  right: max(14px, env(safe-area-inset-right));
  bottom: max(12px, env(safe-area-inset-bottom));
  display: none;
  align-items: end;
  justify-content: center;
  gap: 16px;
  pointer-events: none;
}

.touch-controls button {
  width: 76px;
  height: 68px;
  border: 1px solid var(--line-bright);
  background: rgba(7, 9, 7, 0.72);
  backdrop-filter: blur(8px);
  color: var(--paper);
  pointer-events: auto;
  touch-action: none;
  user-select: none;
}

.touch-controls button:active,
.touch-controls button.active {
  border-color: var(--cyan);
  background: var(--cyan-soft);
}

.touch-controls span,
.touch-controls small {
  display: block;
  font-family: var(--display);
}

.touch-controls span {
  font-size: 1.45rem;
}

.touch-controls small {
  margin-top: 4px;
  font-size: 0.5rem;
  letter-spacing: 0.1em;
}

.touch-controls .touch-thrust {
  width: 90px;
  height: 86px;
  border-color: var(--ember);
  background: rgba(255, 90, 32, 0.14);
}

.toast {
  position: absolute;
  z-index: 15;
  left: 50%;
  top: 18%;
  max-width: min(84vw, 520px);
  padding: 9px 14px;
  border: 1px solid var(--line-bright);
  background: rgba(6, 8, 6, 0.86);
  color: var(--paper);
  font-family: var(--display);
  font-size: 0.68rem;
  letter-spacing: 0.13em;
  text-align: center;
  opacity: 0;
  transform: translate(-50%, -10px);
  pointer-events: none;
  transition: opacity 220ms ease, transform 220ms ease;
}

.toast.visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

@keyframes status-pulse {
  50% { opacity: 0.35; }
}

@media (pointer: coarse) {
  body.flight-active .touch-controls {
    display: flex;
  }

  body.flight-active .control-deck {
    display: none;
  }
}

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

  .mission-copy {
    display: none;
  }

  .telemetry,
  .systems {
    top: 95px;
    width: 170px;
    transform: none;
    padding: 10px;
    background: rgba(7, 9, 7, 0.54);
  }

  .panel-label,
  .safety-readout,
  .score-block > span,
  .score-block small,
  .mission-dots {
    display: none;
  }

  .metric-grid {
    gap: 8px;
    padding-top: 11px;
  }

  .metric-hero strong {
    font-size: 2.3rem;
  }

  .metric strong {
    font-size: 0.92rem;
  }

  .system-row {
    margin-bottom: 10px;
  }

  .score-block {
    margin-top: 10px;
    padding-top: 8px;
  }

  .score-block strong {
    font-size: 1.8rem;
  }

  .target-copy {
    display: none;
  }
}

@media (max-width: 720px) {
  .topbar {
    top: max(10px, env(safe-area-inset-top));
    left: max(12px, env(safe-area-inset-left));
    right: max(12px, env(safe-area-inset-right));
  }

  .brand-lockup .brand-kicker {
    font-size: 0.52rem;
  }

  .brand-lockup strong {
    font-size: 1rem;
  }

  .status-chip {
    min-width: 108px;
    font-size: 0.56rem;
  }

  .telemetry,
  .systems {
    top: 75px;
    width: 137px;
  }

  .telemetry {
    left: max(12px, env(safe-area-inset-left));
  }

  .systems {
    right: max(12px, env(safe-area-inset-right));
  }

  .metric-grid {
    grid-template-columns: 1fr 1fr;
  }

  .metric > span,
  .system-row span {
    font-size: 0.48rem;
  }

  .briefing-grid {
    display: none;
  }

  .hero-copy {
    margin: 22px 0;
    font-size: 0.88rem;
  }

  .hero-actions {
    flex-direction: column;
  }

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

  .orientation-note {
    display: block;
  }

  .control-hint:nth-child(3) {
    display: none;
  }
}

@media (max-height: 680px) {
  .overlay-card {
    padding: 24px 30px;
  }

  h1 {
    margin-top: 24px;
    font-size: clamp(3.5rem, 14vh, 6rem);
  }

  .hero-copy {
    margin: 18px 0;
    font-size: 0.85rem;
  }

  .briefing-grid {
    margin-bottom: 18px;
  }

  .briefing-grid div {
    min-height: 54px;
    padding: 9px;
  }
}

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

  .scanlines {
    display: none;
  }
}
