:root {
  --bg: #04060f;
  --panel: rgba(12, 17, 38, 0.86);
  --card: #121a36;
  --card-owned: #17224a;
  --line: rgba(140, 160, 220, 0.18);
  --text: #e8ecf5;
  --muted: #8b95b5;
  --accent: #7df9ff;
  --gold: #ffd166;
  --danger: #ff6b6b;
  --good: #7dff9f;
  --font: "Segoe UI", system-ui, -apple-system, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", Menlo, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  overflow: hidden;
}

body {
  display: grid;
  place-items: center;
}

#wrap {
  position: relative;
  width: min(100vw, calc(100vh * 1.5));
  aspect-ratio: 3 / 2;
  font-size: clamp(11px, 1.7vmin, 17px);
  box-shadow: 0 0 80px rgba(60, 90, 200, 0.18);
}

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

.overlay {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.1em;
  padding: 2em;
  text-align: center;
  background: var(--panel);
  backdrop-filter: blur(3px);
}
.overlay.show { display: flex; }
.overlay.scroll {
  justify-content: flex-start;
  overflow-y: auto;
  text-align: left;
  padding: 1.6em 2em 2em;
}

h1, h2, h3, h4 { margin: 0; letter-spacing: 0.04em; }
h2 { font-size: 2em; text-transform: uppercase; }
p { margin: 0; }

.logo {
  font-size: 4.4em;
  font-weight: 800;
  letter-spacing: 0.18em;
  line-height: 1;
  text-shadow: 0 0 30px rgba(125, 249, 255, 0.35);
}
.logo span { color: var(--accent); }
.tag { color: var(--muted); max-width: 34em; font-size: 1.05em; }
.muted { color: var(--muted); font-size: 0.85em; }

.controls {
  list-style: none;
  padding: 0;
  margin: 0;
  color: var(--muted);
  display: grid;
  gap: 0.35em;
  font-size: 0.95em;
}
kbd {
  font-family: var(--mono);
  font-size: 0.85em;
  padding: 0.1em 0.45em;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 0.3em;
  background: #0d1330;
  color: var(--text);
}

.btn {
  font: inherit;
  font-weight: 600;
  color: var(--text);
  background: #1c2650;
  border: 1px solid var(--line);
  border-radius: 0.5em;
  padding: 0.6em 1.3em;
  cursor: pointer;
  transition: transform 0.08s ease, background 0.12s ease, box-shadow 0.12s ease;
}
.btn:hover:not(:disabled) { transform: translateY(-1px); background: #243069; }
.btn:active:not(:disabled) { transform: translateY(0); }
.btn:disabled { opacity: 0.45; cursor: default; }
.btn.primary {
  background: linear-gradient(180deg, #2ee6f0, #16a9c4);
  color: #041018;
  border-color: transparent;
  box-shadow: 0 0 18px rgba(125, 249, 255, 0.35);
}
.btn.primary:hover:not(:disabled) { background: linear-gradient(180deg, #5cf0f8, #1bbcd9); }
.btn.big { font-size: 1.15em; padding: 0.75em 2em; letter-spacing: 0.04em; }
.btn.small { font-size: 0.85em; padding: 0.45em 0.9em; }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--danger); }

.row { display: flex; gap: 0.8em; flex-wrap: wrap; justify-content: center; }

.corner {
  position: absolute;
  top: 0.7em;
  right: 12em;
  display: none;
  font: inherit;
  font-size: 0.85em;
  color: var(--muted);
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--line);
  border-radius: 0.4em;
  padding: 0.25em 0.6em;
  cursor: pointer;
}
.corner.show { display: block; }

/* Hangar */
.hangar-head {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 1em;
}
.credits {
  font-family: var(--mono);
  font-size: 2em;
  font-weight: 700;
  color: var(--gold);
}
.launch-row {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1em;
  flex-wrap: wrap;
  padding: 0.9em 1.1em;
  border: 1px solid var(--line);
  border-radius: 0.8em;
  background: rgba(0, 0, 0, 0.25);
}
.sector-pick { display: flex; align-items: center; gap: 0.8em; }
.sector-text { display: flex; flex-direction: column; min-width: 14em; }
.sector-text strong { font-size: 1.15em; }

.stats {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(7em, 1fr));
  gap: 0.6em;
}
.stat {
  display: flex;
  flex-direction: column;
  padding: 0.55em 0.8em;
  border-radius: 0.5em;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--line);
}
.stat-label { color: var(--muted); font-size: 0.75em; text-transform: uppercase; letter-spacing: 0.08em; }
.stat-value { font-family: var(--mono); font-size: 1.15em; font-weight: 700; }
#result .stats { max-width: 36em; }

.shop {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1em;
}
.shop-col { display: flex; flex-direction: column; gap: 0.7em; }
.shop-col h3 {
  font-size: 0.85em;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--accent);
  padding-bottom: 0.3em;
  border-bottom: 1px solid var(--line);
}
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 0.7em;
  padding: 0.8em 0.9em;
  display: flex;
  flex-direction: column;
  gap: 0.45em;
}
.card.owned { background: var(--card-owned); border-color: rgba(125, 249, 255, 0.28); }
.card header { display: flex; justify-content: space-between; align-items: baseline; gap: 0.5em; }
.card h4 { font-size: 1em; }
.card .mk { font-family: var(--mono); font-size: 0.75em; color: var(--muted); white-space: nowrap; }
.card p { color: var(--muted); font-size: 0.85em; line-height: 1.35; flex: 1; }
.card footer { display: flex; justify-content: flex-end; align-items: center; gap: 0.5em; flex-wrap: wrap; }
.pips { display: flex; gap: 0.3em; }
.pips i {
  width: 1.4em;
  height: 0.4em;
  border-radius: 0.2em;
  background: rgba(255, 255, 255, 0.1);
}
.pips i.on { background: var(--accent); box-shadow: 0 0 6px rgba(125, 249, 255, 0.6); }
.card .badge {
  font-size: 0.75em;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--good);
  padding: 0.3em 0.6em;
  border: 1px solid rgba(125, 255, 159, 0.35);
  border-radius: 0.4em;
}
.hangar-foot { width: 100%; display: flex; justify-content: flex-end; }

#result-title.won { color: var(--good); }
#result-title.lost { color: var(--danger); }

@media (max-width: 720px) {
  .shop { grid-template-columns: 1fr; }
  .logo { font-size: 3em; }
  .overlay { padding: 1.2em; }
  .overlay.scroll { padding: 1.2em; }
}
