:root {
  color-scheme: dark;
  font-family: Inter, system-ui, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: #0a101e;
  color: #eef8fb;
  --muted: #a0b1c9;
  --outline: #2a3b55;
  --mint: #a5fae7;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100svh;
  display: grid;
  place-items: center;
  background: radial-gradient(ellipse at 50% 30%, #162444, #0a101e 70%);
}

.game {
  width: min(100%, 960px);
  padding: 20px clamp(12px, 3vw, 36px);
  padding-bottom: max(20px, env(safe-area-inset-bottom));
}

.masthead, .brand, .flight-actions, .telemetry, .controls { display: flex; align-items: center; }
.masthead { justify-content: space-between; min-height: 40px; margin-bottom: 12px; }
.brand { gap: 10px; font-size: .9rem; font-weight: 800; letter-spacing: .18em; }
.flight-actions { gap: 10px; }
.shield-status { color: var(--mint); font-size: .85rem; white-space: nowrap; }
.brand-mark {
  display: grid;
  place-items: center;
  width: 33px;
  height: 33px;
  border: 1px solid #477a83;
  border-radius: 10px;
  color: var(--mint);
  background: #152c3b;
  font-size: 1.2rem;
}

.telemetry {
  margin-bottom: 10px;
  background: #0e192b;
  border: 1px solid var(--outline);
  border-radius: 14px;
}
.telemetry > div { flex: 1; padding: 9px clamp(10px, 2.4vw, 21px); }
.telemetry > div + div { border-left: 1px solid var(--outline); }
.telemetry span { display: block; color: var(--muted); font-size: .85rem; }
.telemetry strong {
  display: block;
  margin-top: 2px;
  font: 750 clamp(1.1rem, 4vw, 1.65rem)/1.05 ui-monospace, monospace;
  letter-spacing: .06em;
}
.telemetry div:last-child strong { color: var(--mint); }

.viewport {
  position: relative;
  height: clamp(350px, 61svh, 570px);
  overflow: hidden;
  isolation: isolate;
  border: 1px solid #425471;
  border-radius: 19px;
  background: #10182b;
  box-shadow: 0 18px 60px #03060f80;
  touch-action: pan-y;
}
canvas { display: block; width: 100%; height: 100%; }
.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 16px;
  background: linear-gradient(#11172922, #080f20a3 70%, #080f2048);
}
.panel {
  width: min(100%, 410px);
  padding: 30px 16px 27px;
  text-align: center;
  background: #10182be8;
  border: 1px solid #58738d;
  border-radius: 18px;
  box-shadow: 0 15px 48px #02061190;
}
h1 {
  margin: 0;
  font-size: clamp(2.1rem, 8vw, 3.5rem);
  letter-spacing: .08em;
  line-height: 1.15;
}
.panel p { margin: 12px 0 22px; color: #c4d3e6; line-height: 1.5; }
.panel-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 8px 16px;
}
.mode-choice {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  cursor: pointer;
}
.mode-choice input { width: 18px; height: 18px; margin: 0; accent-color: var(--mint); }
.mode-choice input:focus-visible { outline: 2px solid #fff; outline-offset: 3px; }
button {
  min-height: 44px;
  display: inline-grid;
  place-items: center;
  border: 1px solid #425773;
  border-radius: 11px;
  color: inherit;
  background: #15243a;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  touch-action: manipulation;
}
button:hover { background: #243752; }
button:active { transform: translateY(1px); }
button:focus-visible { outline: 2px solid #fff; outline-offset: 3px; }
.pause, .end-flight { padding-inline: 16px; }
.primary {
  min-height: 48px;
  min-width: 151px;
  padding: 8px 24px;
  border: 0;
  background: var(--mint);
  color: #10211e;
}
.primary:hover { background: #d0fff4; }
.controls { justify-content: space-between; gap: 12px; margin-top: 12px; }
.controls p { margin: 0; color: var(--muted); font-size: .875rem; text-align: center; }
.steer { width: clamp(54px, 16vw, 105px); font-size: 1.4rem; line-height: 1; }

@media (max-height: 640px) {
  .game { padding-block: 8px; }
  .masthead { margin-bottom: 6px; }
  .viewport { height: clamp(220px, calc(100svh - 170px), 420px); }
  .panel { padding-block: 16px; }
  .panel p { margin-block: 8px 12px; }
  .telemetry > div { padding-block: 6px; }
  .controls { margin-top: 8px; }
}
