:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #040716;
  color: #eef6ff;
}

* { box-sizing: border-box; }

body {
  min-height: 100vh;
  margin: 0;
  display: grid;
  place-items: center;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 12% 15%, rgba(58, 77, 180, .25), transparent 25rem),
    radial-gradient(circle at 90% 85%, rgba(179, 53, 143, .18), transparent 30rem),
    #040716;
}

.game-shell {
  width: min(1040px, 100%);
  padding: 22px 24px;
}

header, footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

header { margin-bottom: 14px; }

.eyebrow {
  margin: 0 0 3px;
  color: #75e7ff;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .28em;
}

h1 {
  margin: 0;
  text-transform: uppercase;
  font-size: clamp(23px, 4vw, 38px);
  line-height: 1;
  letter-spacing: -.04em;
}

h1 span { color: #ff4fc3; }

.sound-button, .primary-button {
  border: 0;
  color: #fff;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

.sound-button {
  padding: 9px 13px;
  border: 1px solid rgba(117, 231, 255, .45);
  border-radius: 10px;
  background: rgba(17, 30, 66, .85);
  font-size: 12px;
}

.screen-wrap {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  border: 1px solid rgba(117, 231, 255, .35);
  border-radius: 16px;
  background: #020514;
  box-shadow: 0 0 0 4px rgba(26, 37, 83, .45), 0 25px 80px rgba(0, 0, 0, .5);
}

.runtime-status {
  position: absolute;
  right: 10px;
  bottom: 10px;
  z-index: 20;
  padding: 5px 8px;
  border: 1px solid rgba(117, 231, 255, .35);
  border-radius: 6px;
  color: #70edff;
  background: rgba(2, 5, 20, .9);
  font-size: 9px;
  font-weight: 900;
  letter-spacing: .08em;
  pointer-events: none;
}

.runtime-status.error { max-width: 70%; color: #ff8bbb; border-color: #ff4fc3; }

.quick-start-button {
  position: absolute;
  top: 14px;
  left: 50%;
  z-index: 30;
  transform: translateX(-50%);
  padding: 11px 18px;
  border: 1px solid #70edff;
  border-radius: 9px;
  color: #fff;
  background: linear-gradient(90deg, #276fff, #d934ad);
  box-shadow: 0 0 20px rgba(39, 111, 255, .5);
  font: inherit;
  font-size: 11px;
  font-weight: 900;
  cursor: pointer;
}

.quick-start-button.hidden { display: none; }

canvas {
  position: relative;
  z-index: 0;
  width: 100%;
  height: auto;
  display: block;
  aspect-ratio: 8 / 5;
  touch-action: none;
}

.overlay {
  position: absolute;
  z-index: 10;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 22px;
  background: rgba(2, 5, 20, .64);
  backdrop-filter: blur(5px);
}

.overlay.hidden { display: none; }

.base-overlay {
  display: block;
  align-items: center;
  overflow-y: auto;
  background: rgba(2, 5, 20, .5);
}

.panel {
  width: min(530px, 100%);
  padding: clamp(22px, 5vw, 40px);
  border: 1px solid rgba(117, 231, 255, .45);
  border-radius: 18px;
  text-align: center;
  background: linear-gradient(145deg, rgba(17, 30, 66, .96), rgba(31, 13, 64, .96));
  box-shadow: 0 18px 50px rgba(0, 0, 0, .45);
}

.base-panel {
  width: min(820px, 100%);
  margin: 0 auto;
  padding: clamp(18px, 3.5vw, 34px);
  text-align: left;
}

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

.coin-bank {
  flex: 0 0 auto;
  padding: 10px 14px;
  border: 1px solid rgba(255, 228, 94, .4);
  border-radius: 12px;
  color: #ffe45e;
  background: rgba(45, 36, 5, .55);
}

.coin-icon { text-shadow: 0 0 10px #ffe45e; }
.base-panel > p { max-width: none !important; margin: 8px 0 17px !important; }

.fleet-section { margin-bottom: 13px; }
.section-heading { display: flex; align-items: end; justify-content: space-between; gap: 14px; margin-bottom: 9px; }
.section-heading h3 { margin: 1px 0 0; font-size: 17px; }
.section-heading > span { color: #70edff; font-size: 11px; font-weight: 800; }
.section-kicker { margin: 0; color: #7786a9; font-size: 9px; font-weight: 900; letter-spacing: .18em; }

.ship-grid {
  display: flex;
  gap: 9px;
  padding-bottom: 7px;
  overflow-x: auto;
  scrollbar-color: #3560a6 #0a1027;
}

.ship-card {
  position: relative;
  flex: 0 0 165px;
  min-height: 126px;
  padding: 11px;
  overflow: hidden;
  border: 1px solid rgba(117, 231, 255, .18);
  border-radius: 12px;
  background: rgba(2, 5, 20, .58);
}

.ship-card.selected { border-color: #70edff; box-shadow: inset 0 0 18px rgba(39, 111, 255, .2); }
.ship-card.locked { opacity: .72; }
.ship-swatch { width: 37px; height: 22px; margin-bottom: 7px; clip-path: polygon(50% 0, 100% 100%, 50% 76%, 0 100%); background: var(--ship-color); filter: drop-shadow(0 0 7px var(--ship-color)); }
.ship-card h4 { margin: 0 0 3px; font-size: 13px; }
.ship-card p { margin: 0 0 7px; color: #7e8ca9; font-size: 9px; line-height: 1.35; }
.ship-card small { color: #bdc9df; font-size: 9px; }
.ship-select { position: absolute; right: 8px; bottom: 8px; padding: 6px 8px; border: 0; border-radius: 7px; color: #fff; background: #21428a; font: inherit; font-size: 9px; font-weight: 900; cursor: pointer; }
.ship-select:disabled { cursor: default; background: #283047; color: #77819a; }

.pilot-section { margin-bottom: 13px; }
.pilot-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 9px; }
.pilot-card { display: flex; align-items: center; gap: 9px; padding: 9px; border: 1px solid rgba(117, 231, 255, .18); border-radius: 11px; color: #fff; background: rgba(2, 5, 20, .58); text-align: left; cursor: pointer; }
.pilot-card:hover, .pilot-card.selected { border-color: var(--pilot-color); box-shadow: inset 0 0 15px color-mix(in srgb, var(--pilot-color) 18%, transparent); }
.pilot-avatar { display: grid; flex: 0 0 35px; width: 35px; height: 35px; place-items: center; border: 2px solid var(--pilot-color); border-radius: 50%; color: var(--pilot-color); background: #111831; font-size: 17px; font-weight: 1000; box-shadow: 0 0 10px color-mix(in srgb, var(--pilot-color) 45%, transparent); }
.pilot-card strong, .pilot-card small { display: block; }
.pilot-card strong { font-size: 12px; }
.pilot-card small { margin-top: 2px; color: #7e8ca9; font-size: 9px; }

.ability-dock { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 9px; padding: 10px 12px; border: 1px solid rgba(255, 228, 94, .3); border-radius: 11px; background: rgba(45, 36, 5, .3); }
.ability-dock > div:first-child { display: grid; grid-template-columns: 34px auto; align-items: center; column-gap: 8px; }
.ability-icon { grid-row: 1 / 3; color: #ffe45e; font-size: 25px; text-align: center; text-shadow: 0 0 12px #ffe45e; }
.ability-dock strong { font-size: 12px; }
.ability-dock small { color: #a49b79; font-size: 9px; }
.ability-purchase { display: flex; align-items: center; gap: 8px; }
.ability-purchase > span { white-space: nowrap; color: #ffe45e; font-size: 10px; font-weight: 800; }
.ability-purchase .shop-button { width: auto; white-space: nowrap; }

.shop-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.shop-card {
  padding: 16px;
  border: 1px solid rgba(117, 231, 255, .22);
  border-radius: 14px;
  background: rgba(2, 5, 20, .55);
}

.shop-icon { color: #70edff; font-size: 25px; text-shadow: 0 0 14px #276fff; }
.shop-card h3 { margin: 7px 0 5px; font-size: 16px; }
.shop-card p { min-height: 34px; margin: 0 0 10px; color: #8e9bb8; font-size: 12px; line-height: 1.4; }
.shop-card small { display: block; margin-bottom: 10px; color: #bfcae4; }

.shop-button, .secondary-button {
  border: 1px solid rgba(117, 231, 255, .4);
  border-radius: 9px;
  color: #fff;
  background: #152453;
  font: inherit;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}

.shop-button { width: 100%; padding: 9px; }
.shop-button:hover:not(:disabled) { background: #204184; }
.shop-button:disabled { cursor: not-allowed; opacity: .45; }
.shop-message { min-height: 18px; color: #ffe45e !important; font-size: 12px; }
.boss-warning { color: #ff7bd5 !important; font-weight: 800; text-shadow: 0 0 12px rgba(255, 79, 195, .65); }
.report-actions { display: flex; justify-content: center; gap: 10px; }
.secondary-button { padding: 13px 19px; }

.mission-tag {
  margin: 0 0 8px;
  color: #70edff;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .25em;
}

.panel h2 {
  margin: 0 0 12px;
  font-size: clamp(25px, 4vw, 38px);
  letter-spacing: -.04em;
}

.panel > p:not(.mission-tag) {
  max-width: 440px;
  margin: 0 auto 22px;
  color: #bfcae4;
  line-height: 1.55;
}

.controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 0 0 24px;
}

.controls div {
  padding: 12px;
  border-radius: 10px;
  background: rgba(2, 5, 20, .55);
}

kbd { display: block; color: #fff; font-weight: 900; }
.controls span { color: #8e9bb8; font-size: 11px; }

.primary-button {
  padding: 13px 24px;
  border-radius: 11px;
  background: linear-gradient(90deg, #276fff, #d934ad);
  box-shadow: 0 8px 25px rgba(83, 59, 224, .42);
  transition: transform .15s ease, filter .15s ease;
}

.primary-button:hover { transform: translateY(-2px); filter: brightness(1.13); }

footer {
  justify-content: center;
  margin-top: 14px;
  color: #67728d;
  font-size: 10px;
  letter-spacing: .12em;
}

footer b { color: #b8c8e8; margin-left: 4px; }

@media (max-width: 620px) {
  .game-shell { padding: 13px; }
  .controls { grid-template-columns: 1fr; }
  .shop-grid { grid-template-columns: 1fr; }
  .pilot-grid { grid-template-columns: 1fr; }
  .ability-dock { align-items: stretch; flex-direction: column; }
  .shop-card p { min-height: 0; }
  .base-heading { align-items: flex-start; }
  .base-overlay { align-items: start; }
  footer { flex-wrap: wrap; }
}
