:root {
  --bg: #05060f;
  --accent: #7de2ff;
  --gold: #ffd166;
  --green: #3df07a;
  --purple: #b16bff;
  --text: #e8ecff;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: #02030a;
  color: var(--text);
  font-family: "Courier New", monospace;
  overflow: hidden;
}

#stage {
  position: relative;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  touch-action: none;
}

#game {
  display: block;
  width: 100%;
  height: 100%;
  background: var(--bg);
}

/* HUD ----------------------------------------------------------------------*/
#hud {
  position: absolute;
  top: 0; left: 0; right: 0;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 14px 22px;
  pointer-events: none;
  text-shadow: 0 0 8px rgba(125, 226, 255, 0.5);
  font-size: 20px;
  letter-spacing: 1px;
}

#hud .hud-center { text-align: center; }
#hud .hud-right { text-align: right; }

.hud-label {
  display: block;
  font-size: 11px;
  letter-spacing: 3px;
  color: var(--accent);
  opacity: 0.7;
  margin-bottom: 2px;
}

#hud-lives { color: #ff5f7e; text-shadow: 0 0 8px rgba(255,95,126,0.6); }
#hud-score { color: var(--gold); }
#hud-credits { color: var(--gold); }

.hud-credits-line {
  display: block;
  font-size: 14px;
  margin-top: 4px;
  opacity: 0.9;
}
.hud-credits-line .hud-label { display: inline; margin: 0; }

.shield-row {
  display: block;
  font-size: 14px;
  margin-top: 4px;
  min-height: 16px;
  color: var(--green);
}

.weapon-row {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 3px;
  margin-top: 6px;
  font-size: 12px;
  letter-spacing: 1px;
}
.weapon-row .wrow {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  opacity: 0.5;            /* inactive weapons are dimmed */
  transition: opacity 0.1s ease;
}
.weapon-row .wrow.active { opacity: 1; }
.weapon-row .wrow.empty .ammo-num { color: var(--danger); }
.weapon-row .wkey {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border: 1px solid rgba(255, 255, 255, 0.4);
  border-radius: 3px;
  font-size: 10px;
}
.weapon-row .wrow.active .wkey { border-color: var(--gold); color: var(--gold); }
.weapon-row .wname { min-width: 64px; text-align: right; }
.weapon-row .ammo-bar {
  display: inline-block;
  width: 50px;
  height: 7px;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 4px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.08);
}
.weapon-row .ammo-fill { display: block; height: 100%; }
.weapon-row .ammo-num { opacity: 0.85; min-width: 28px; text-align: right; }

.combo {
  display: block;
  font-size: 13px;
  color: var(--green);
  margin-top: 4px;
  min-height: 16px;
}

.missiles {
  display: block;
  font-size: 13px;
  margin-top: 4px;
  min-height: 16px;
  color: #ff8aa8;
  opacity: 0.6;
}
.missiles.ready {
  color: #ff5c8a;
  opacity: 1;
  text-shadow: 0 0 10px rgba(255, 92, 138, 0.7);
}

/* Stage progress: full at the start of a wave, draining to empty when cleared. */
.stage-bar {
  display: block;
  width: 140px;
  height: 6px;
  margin: 5px auto 0;
  border: 1px solid rgba(125, 226, 255, 0.5);
  border-radius: 3px;
  overflow: hidden;
  background: rgba(125, 226, 255, 0.12);
}
.stage-fill {
  display: block;
  height: 100%;
  width: 100%;
  background: var(--accent);
  box-shadow: 0 0 8px rgba(125, 226, 255, 0.7);
  transition: width 0.2s ease-out;
}

.reload-bar {
  display: inline-block;
  vertical-align: middle;
  width: 72px;
  height: 8px;
  margin-left: 6px;
  border: 1px solid rgba(255, 138, 168, 0.5);
  border-radius: 4px;
  overflow: hidden;
  background: rgba(255, 138, 168, 0.12);
}
.reload-fill {
  display: block;
  height: 100%;
  background: #ff8aa8;
  box-shadow: 0 0 8px rgba(255, 138, 168, 0.7);
}

/* Level banner -------------------------------------------------------------*/
#level-banner {
  position: absolute;
  top: 34%; left: 0; right: 0;
  text-align: center;
  font-size: 52px;
  font-weight: bold;
  letter-spacing: 8px;
  color: var(--gold);
  text-shadow: 0 0 24px rgba(255, 209, 102, 0.7);
  pointer-events: none;
}
#level-banner .mod {
  display: block;
  font-size: 20px;
  letter-spacing: 5px;
  color: var(--accent);
  margin-top: 8px;
}
#level-banner .boss {
  color: var(--purple);
  text-shadow: 0 0 28px rgba(177, 107, 255, 0.8);
}
#level-banner.flash { animation: pop 0.4s ease-out; }
@keyframes pop {
  0% { transform: scale(0.6); opacity: 0; }
  40% { transform: scale(1.1); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}

/* Overlays -----------------------------------------------------------------*/
.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  background: radial-gradient(ellipse at center, rgba(5,6,15,0.78), rgba(2,3,10,0.95));
  padding: 24px;
  gap: 18px;
  overflow-y: auto;
}
.overlay.hidden, .hidden { display: none; }

h1 {
  font-size: 64px;
  letter-spacing: 6px;
  color: var(--accent);
  text-shadow: 0 0 30px rgba(125, 226, 255, 0.6);
}
h1 span { color: var(--gold); display: block; font-size: 40px; letter-spacing: 14px; }

h2 {
  font-size: 44px;
  letter-spacing: 6px;
  color: var(--gold);
  text-shadow: 0 0 24px rgba(255, 209, 102, 0.6);
}

.tagline { max-width: 600px; line-height: 1.5; opacity: 0.85; }
.tagline b { color: var(--gold); }
.tagline.reward { font-size: 24px; color: var(--gold); opacity: 1; }

.stat-line {
  display: flex;
  gap: 40px;
  font-size: 18px;
}
.stat-line b { color: var(--gold); font-size: 22px; }

.btn {
  margin-top: 6px;
  background: transparent;
  border: 2px solid var(--accent);
  color: var(--accent);
  font-family: inherit;
  font-size: 18px;
  letter-spacing: 3px;
  padding: 12px 26px;
  cursor: pointer;
  border-radius: 6px;
  transition: all 0.15s ease;
  text-shadow: 0 0 8px rgba(125, 226, 255, 0.5);
  animation: pulse 1.6s ease-in-out infinite;
}
.btn:hover { background: var(--accent); color: #02030a; }

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 rgba(125, 226, 255, 0); }
  50% { box-shadow: 0 0 18px rgba(125, 226, 255, 0.45); }
}

.btn-secondary {
  background: transparent;
  border: 1px solid rgba(125, 226, 255, 0.4);
  color: var(--accent);
  font-family: inherit;
  font-size: 14px;
  letter-spacing: 2px;
  padding: 10px 18px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
}
.btn-secondary:hover { border-color: var(--accent); background: rgba(125,226,255,0.08); }

.row-buttons {
  display: flex;
  gap: 16px;
  align-items: stretch;   /* all buttons in the row share the tallest height */
  flex-wrap: wrap;
  justify-content: center;
}
/* Keep labels centered and drop per-button top margins so heights line up. */
.row-buttons button {
  margin-top: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.mute-corner { position: absolute; top: 18px; right: 18px; font-size: 12px; }

.hints {
  list-style: none;
  margin-top: 10px;
  max-width: 620px;
  font-size: 13px;
  line-height: 1.9;
  opacity: 0.7;
}
.hints b { color: var(--gold); }

/* Hangar — sidebar tabs (headers on the left, content on the right) ----------*/
.shop-body {
  display: flex;
  flex-direction: row;
  align-items: stretch;
  gap: 16px;
  width: 100%;
  max-width: 800px;
}

.shop-tabs {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex-shrink: 0;
  border-right: 1px solid rgba(125, 226, 255, 0.25);
  padding-right: 14px;
}
.shop-tab {
  background: transparent;
  border: 1px solid rgba(125, 226, 255, 0.25);
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  letter-spacing: 3px;
  text-align: left;
  padding: 12px 22px;
  border-radius: 8px;
  cursor: pointer;
  opacity: 0.55;
  transition: all 0.15s ease;
  white-space: nowrap;
}
.shop-tab:hover { opacity: 0.85; }
.shop-tab.active {
  opacity: 1;
  color: var(--accent);
  border-color: var(--accent);
  background: rgba(125, 226, 255, 0.1);
  box-shadow: 0 0 14px rgba(125, 226, 255, 0.2);
}

/* Content area to the right of the tabs. */
.shop-content {
  flex: 1;
  min-width: 0;
}

/* Both tab panels share one fixed-size container so switching never reflows. */
.shop-panel {
  width: 100%;
  height: 46vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}
.shop-panel.hidden { display: none; }

/* Hangar — ship roster ------------------------------------------------------*/
.shop-sub {
  font-size: 18px;
  letter-spacing: 4px;
  color: var(--accent);
  opacity: 0.85;
  margin-top: 4px;
}

.ship-roster {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;          /* multiple rows of ship tiles */
  align-items: stretch;     /* tiles in a row match the tallest tile's height */
  justify-content: center;
  gap: 12px;
  width: 100%;
}

.ship-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 8px;
  width: 176px;
  flex-shrink: 0;
  padding: 14px 12px;
  border: 1px solid rgba(125, 226, 255, 0.22);
  border-radius: 12px;
  background: rgba(8, 10, 22, 0.6);
  transition: all 0.15s ease;
}
.ship-card.selected {
  border-color: var(--gold);
  box-shadow: 0 0 18px rgba(255, 209, 102, 0.25);
  background: rgba(255, 209, 102, 0.06);
}
.ship-card:not(.owned) { opacity: 0.92; }

.ship-svg {
  width: 52px;
  height: 52px;
  flex-shrink: 0;
  filter: drop-shadow(0 0 6px rgba(255,255,255,0.25));
}

.ship-info {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  width: 100%;
}

.ship-name { font-size: 17px; letter-spacing: 2px; }

.ship-stats {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 4px 10px;
  font-size: 11px;
  letter-spacing: 1px;
  opacity: 0.8;
}

.ship-blurb {
  font-size: 11px;
  line-height: 1.4;
  opacity: 0.6;
  min-height: 46px;
}

.ship-btn {
  width: 100%;
  margin-top: auto;   /* pin to the bottom so buttons align across cards */
  background: transparent;
  border: 2px solid var(--accent);
  color: var(--accent);
  font-family: inherit;
  font-size: 14px;
  letter-spacing: 2px;
  padding: 9px 0;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
}
.ship-btn:hover:not(:disabled) { background: var(--accent); color: #02030a; }
.ship-btn.active {
  border-color: var(--gold);
  color: var(--gold);
  opacity: 1;
  cursor: default;
}
.ship-btn:disabled:not(.active) { opacity: 0.4; cursor: not-allowed; }

/* Hangar — weapons loadout --------------------------------------------------*/
.loadout-row {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: 100%;
  max-width: 460px;
}
.slot-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}
.slot {
  min-width: 96px;
  padding: 10px 14px;
  background: rgba(8, 10, 22, 0.6);
  border: 1px dashed rgba(125, 226, 255, 0.4);
  border-radius: 8px;
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  letter-spacing: 1px;
  cursor: pointer;
  opacity: 0.7;
  transition: all 0.15s ease;
}
.slot.filled { border-style: solid; opacity: 1; }
.slot:hover { opacity: 1; }

.weapon-stats {
  font-size: 11px;
  letter-spacing: 1px;
  opacity: 0.8;
}
.weapon-blurb {
  font-size: 11px;
  line-height: 1.4;
  opacity: 0.55;
}

/* Per-ship upgrades --------------------------------------------------------*/
.shop-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  max-width: 460px;
  margin: 6px 0;
}

.shop-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 16px;
  border: 1px solid rgba(125, 226, 255, 0.22);
  border-radius: 10px;
  background: rgba(8, 10, 22, 0.6);
}

.shop-info { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.shop-name { font-size: 16px; letter-spacing: 2px; }

.shop-pips { display: flex; gap: 5px; }
.shop-pips i {
  width: 14px; height: 10px;
  border-radius: 2px;
  background: rgba(125, 226, 255, 0.15);
  border: 1px solid rgba(125, 226, 255, 0.3);
  display: inline-block;
}
.shop-pips i.on {
  background: var(--gold);
  border-color: var(--gold);
  box-shadow: 0 0 8px rgba(255, 209, 102, 0.6);
}

.shop-buy {
  min-width: 100px;
  background: transparent;
  border: 2px solid var(--gold);
  color: var(--gold);
  font-family: inherit;
  font-size: 15px;
  letter-spacing: 1px;
  padding: 9px 14px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
}
.shop-buy:hover:not(:disabled) { background: var(--gold); color: #02030a; }
.shop-buy:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  border-color: rgba(138, 147, 181, 0.5);
  color: #8a93b5;
}
