:root {
  color-scheme: dark;
  --cyan: #7be7ff;
  --cyan-soft: rgba(123, 231, 255, .28);
  --amber: #ffb14a;
  --red: #ff4d4d;
  --ink: #050a10;
  --panel: rgba(5, 12, 20, .86);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

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

body {
  min-height: 100dvh;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

button { font: inherit; }

.game-shell {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 320px;
  isolation: isolate;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 35%, rgba(34, 91, 116, .26), transparent 50%),
    #050a10;
  touch-action: pan-y;
}

.game-shell::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 5;
  pointer-events: none;
  opacity: .18;
  background: repeating-linear-gradient(
    to bottom,
    rgba(255,255,255,.06) 0,
    rgba(255,255,255,.06) 1px,
    transparent 1px,
    transparent 4px
  );
  mix-blend-mode: overlay;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  outline: 0;
  cursor: crosshair;
  touch-action: none;
}

.top-controls {
  position: absolute;
  z-index: 20;
  top: max(12px, env(safe-area-inset-top));
  right: max(12px, env(safe-area-inset-right));
  display: flex;
  gap: 8px;
}

.icon-button {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 1px solid rgba(123, 231, 255, .34);
  border-radius: 12px;
  color: #dff8ff;
  background: rgba(3, 9, 15, .72);
  box-shadow: inset 0 0 16px rgba(123, 231, 255, .05);
  cursor: pointer;
  backdrop-filter: blur(8px);
}

.icon-button:hover,
.icon-button:focus-visible,
.action-button:focus-visible,
.start-button:focus-visible {
  border-color: var(--cyan);
  outline: 2px solid rgba(123, 231, 255, .32);
  outline-offset: 2px;
}

.start-screen,
.message-screen {
  position: absolute;
  inset: 0;
  z-index: 25;
  display: grid;
  place-items: center;
  padding: 20px;
  background:
    linear-gradient(180deg, rgba(2, 8, 14, .38), rgba(2, 6, 11, .84)),
    repeating-linear-gradient(90deg, transparent 0 79px, rgba(123, 231, 255, .04) 80px);
  backdrop-filter: blur(3px);
  touch-action: pan-y;
}

.start-screen[hidden],
.message-screen[hidden] { display: none; }

.start-card,
.message-card {
  width: min(760px, 96vw);
  max-height: calc(100dvh - 24px);
  overflow-y: auto;
  overscroll-behavior: contain;
  touch-action: pan-y;
  -webkit-overflow-scrolling: touch;
  padding: clamp(18px, 3vw, 30px);
  border: 1px solid rgba(123, 231, 255, .34);
  border-radius: 20px;
  color: #e8f8ff;
  background: linear-gradient(155deg, rgba(10, 25, 37, .94), rgba(3, 10, 17, .96));
  box-shadow:
    0 24px 80px rgba(0, 0, 0, .6),
    inset 0 0 0 1px rgba(255, 177, 74, .08),
    inset 0 0 50px rgba(123, 231, 255, .04);
  text-align: center;
}

.message-card { width: min(420px, 92vw); }

.eyebrow {
  margin: 0 0 8px;
  color: var(--amber);
  font: 700 12px/1.4 ui-monospace, SFMono-Regular, Consolas, monospace;
  letter-spacing: .18em;
}

h1,
h2 {
  margin: 0;
  font-weight: 900;
  line-height: .95;
  letter-spacing: .12em;
  text-shadow: 0 0 24px rgba(123, 231, 255, .25);
}

h1 { font-size: clamp(38px, 8vw, 68px); }
h2 { font-size: clamp(26px, 7vw, 42px); }

.briefing,
.message-card p:not(.eyebrow) {
  max-width: 44ch;
  margin: 16px auto 0;
  color: #adc6d2;
  font-size: clamp(14px, 2.8vw, 17px);
  line-height: 1.55;
}

.launch-config {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 18px;
  text-align: left;
}

.selection-group {
  min-width: 0;
  padding: 12px;
  border: 1px solid rgba(123, 231, 255, .16);
  border-radius: 12px;
  background: rgba(0, 0, 0, .18);
}

.selection-group h2 {
  margin: 0 0 9px;
  color: var(--cyan);
  font: 700 11px/1.2 ui-monospace, SFMono-Regular, Consolas, monospace;
  letter-spacing: .16em;
}

.selection-options { display: grid; gap: 6px; }

.selection-card {
  display: grid;
  gap: 2px;
  width: 100%;
  padding: 8px 10px;
  border: 1px solid rgba(123, 231, 255, .15);
  border-radius: 9px;
  color: #b5ced8;
  background: rgba(3, 10, 17, .66);
  text-align: left;
  cursor: pointer;
}

.selection-card strong {
  color: #dff8ff;
  font: 800 11px/1.25 ui-monospace, SFMono-Regular, Consolas, monospace;
  letter-spacing: .08em;
}

.selection-card span { font-size: 11px; }

.selection-card:hover,
.selection-card:focus-visible {
  border-color: rgba(123, 231, 255, .58);
  outline: none;
}

.selection-card[aria-pressed="true"] {
  border-color: var(--amber);
  background: linear-gradient(90deg, rgba(255, 177, 74, .16), rgba(123, 231, 255, .08));
  box-shadow: inset 3px 0 0 var(--amber);
}

.selection-card:disabled { opacity: .5; cursor: not-allowed; }

.pilot-record {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 7px 16px;
  margin-top: 12px;
  color: #88a8b5;
  font: 700 10px/1.4 ui-monospace, SFMono-Regular, Consolas, monospace;
  letter-spacing: .1em;
}

.pilot-record strong { color: var(--amber); }

.embedded .start-card { padding: 14px; }
.embedded .control-grid,
.embedded .pilot-record,
.embedded .briefing { display: none; }
.embedded h1 { font-size: clamp(36px, 7vw, 52px); }
.embedded .launch-config { margin-top: 10px; }
.embedded .selection-group { padding: 10px; }
.embedded .start-button { margin-top: 8px; }

.control-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 16px 0;
  text-align: left;
}

.control-set {
  display: grid;
  gap: 5px;
  min-height: 122px;
  padding: 14px;
  border: 1px solid rgba(123, 231, 255, .16);
  border-radius: 12px;
  color: #a8c0cb;
  background: rgba(0, 0, 0, .18);
  font-size: 13px;
}

.control-set strong {
  margin-bottom: 4px;
  color: var(--cyan);
  font: 700 12px ui-monospace, SFMono-Regular, Consolas, monospace;
  letter-spacing: .14em;
}

kbd {
  padding: 1px 5px;
  border: 1px solid rgba(255,255,255,.22);
  border-radius: 4px;
  color: #e8f8ff;
  background: rgba(255,255,255,.06);
  box-shadow: 0 1px 0 rgba(255,255,255,.1);
  font: inherit;
}

.start-button {
  min-width: min(100%, 260px);
  min-height: 48px;
  padding: 12px 20px;
  border: 1px solid rgba(123, 231, 255, .7);
  border-radius: 12px;
  color: #031016;
  background: linear-gradient(180deg, #a4f0ff, #5dccdf);
  box-shadow: 0 0 24px rgba(123, 231, 255, .2);
  font-weight: 900;
  letter-spacing: .08em;
  cursor: pointer;
}

.start-button:active { transform: translateY(1px); }

.touch-actions {
  position: absolute;
  z-index: 12;
  left: 50%;
  bottom: max(15px, env(safe-area-inset-bottom));
  display: none;
  gap: 10px;
  transform: translateX(-50%);
  pointer-events: none;
}

.action-button {
  display: grid;
  min-width: 88px;
  min-height: 52px;
  align-content: center;
  padding: 7px 12px;
  border: 1px solid rgba(123, 231, 255, .42);
  border-radius: 14px;
  color: #e8f8ff;
  background: rgba(3, 10, 17, .78);
  box-shadow: inset 0 0 20px rgba(123, 231, 255, .06);
  pointer-events: auto;
  backdrop-filter: blur(8px);
}

.action-button--missile { border-color: rgba(255, 177, 74, .55); }
.action-button span { font-size: 12px; font-weight: 900; letter-spacing: .08em; }
.action-button small { margin-top: 2px; color: var(--cyan); font-size: 10px; }
.action-button--missile small { color: var(--amber); }
.action-button:disabled { opacity: .45; }

.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 (pointer: coarse) {
  canvas { cursor: default; }
  .touch-actions { display: flex; }
  .desktop-set { display: none; }
  .control-grid { grid-template-columns: 1fr; }
  .control-set { min-height: 0; }
  .start-card { padding: 22px; }
  .top-controls { top: max(8px, env(safe-area-inset-top)); right: max(8px, env(safe-area-inset-right)); }
  .icon-button { width: 40px; height: 40px; }
}

@media (max-width: 620px) {
  .launch-config { grid-template-columns: 1fr; }
  .start-screen { place-items: start center; padding: 8px; }
  .start-card { width: 100%; max-height: calc(100dvh - 16px); padding: 18px 14px; }
  .briefing { margin-top: 10px; }
  .control-grid { margin: 12px 0; }
}

@media (pointer: fine) {
  .touch-set { display: none; }
  .control-grid { grid-template-columns: 1fr; }
}

@media (max-height: 480px) and (orientation: landscape) {
  .start-screen { padding: 10px; }
  .start-card { width: min(720px, 95vw); padding: 16px 22px; }
  .eyebrow { margin-bottom: 3px; }
  h1 { font-size: 40px; }
  .briefing { margin-top: 8px; font-size: 13px; }
  .launch-config { grid-template-columns: 1fr 1fr; margin-top: 10px; }
  .selection-group { padding: 8px; }
  .selection-card { padding: 5px 8px; }
  .pilot-record { margin-top: 8px; }
  .control-grid { margin: 12px 0; }
  .control-set { min-height: 0; padding: 9px 12px; }
  .start-button { min-height: 42px; }
}

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