:root {
  --gold: #ebb41d;
  --gold-hot: #ffd24a;
  --gold-dim: #c47820;
  --orange: #fa590e;
  --orange-hot: #f81800;
  --lava: #dc601c;
  --cyan: #3ec8f0;
  --cyan-hot: #7ae4ff;
  --cyan-bar: #2ec4f0;
  --ink: #e3e7ed;
  --muted: #8a9099;
  --panel: rgba(8, 10, 16, 0.82);
  --panel-solid: #0c1018;
  --line: rgba(235, 180, 29, 0.75);
  --cyan-line: rgba(62, 200, 240, 0.7);
  --red: #e03028;
  --red-hot: #ff5a48;
  --shadow: 0 8px 28px rgba(0, 0, 0, 0.55);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  width: 100%; height: 100%; overflow: hidden;
  background: #0d0811;
  color: var(--ink);
  font-family: "Rajdhani", "Exo 2", sans-serif;
  user-select: none;
}
#stage, #c {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  display: block;
}
#c { z-index: 0; }

#fp-arms {
  position: absolute; inset: 0;
  z-index: 1;
  pointer-events: none;
  opacity: 0;
}
#fp-arms.on { opacity: 1; }
#arm-l, #arm-r {
  position: absolute;
  bottom: 9%;
  width: min(30vw, 400px);
  height: auto;
  filter: drop-shadow(0 8px 12px rgba(0,0,0,0.45));
}
#arm-l { left: -2%; transform: rotate(-6deg); transform-origin: 10% 90%; }
#arm-r { right: -2%; transform: rotate(6deg); transform-origin: 90% 90%; }
#fp-arms.boost #arm-l { transform: rotate(-14deg) translateY(10px); }
#fp-arms.boost #arm-r { transform: rotate(14deg) translateY(10px); }

.hidden { display: none !important; }

/* ---------- HUD ---------- */
#hud { position: absolute; inset: 0; z-index: 2; pointer-events: none; }
#hud button, #hud #map-overlay { pointer-events: auto; }

.panel {
  background: var(--panel);
  border: 1px solid rgba(235, 180, 29, 0.38);
  box-shadow: var(--shadow), inset 0 0 0 1px rgba(255, 255, 255, 0.03);
}

/* TOP LEFT */
#hud-tl {
  position: absolute;
  top: 1.6%;
  left: 1.6%;
  width: min(340px, 26vw);
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}
.sector-panel {
  padding: 0.55rem 0.85rem 0.5rem;
  clip-path: polygon(0 0, calc(100% - 18px) 0, 100% 18px, 100% 100%, 14px 100%, 0 calc(100% - 14px));
  border-color: rgba(180, 200, 220, 0.28);
  position: relative;
}
.sector-panel::before, .sector-panel::after {
  content: "";
  position: absolute;
  top: 6px; width: 42px; height: 2px;
  background: linear-gradient(90deg, transparent, #d8e4f0);
  opacity: 0.85;
}
.sector-panel::before { left: -2px; }
.sector-panel::after {
  right: 10px;
  background: linear-gradient(90deg, #d8e4f0, transparent);
}
.sector-title {
  font-family: "Orbitron", "Exo 2", sans-serif;
  font-weight: 800;
  letter-spacing: 0.08em;
  font-size: clamp(11px, 1.15vw, 15px);
  color: #f4f7fb;
}
.threat-row {
  margin-top: 0.15rem;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--gold);
}
.threat-row b { color: var(--gold-hot); font-weight: 800; }
.stars { color: var(--gold); letter-spacing: 0.12em; }

.vitals-panel {
  padding: 0.45rem 0.75rem 0.5rem;
  clip-path: polygon(0 10px, 10px 0, 100% 0, 100% calc(100% - 10px), calc(100% - 10px) 100%, 0 100%);
  border-color: rgba(180, 200, 220, 0.22);
}
.vitals-head {
  font-size: 10px;
  letter-spacing: 0.18em;
  font-weight: 700;
  color: #c9d0d8;
  margin-bottom: 0.25rem;
}
.vital-row {
  display: grid;
  grid-template-columns: 52px 1fr 40px;
  align-items: center;
  gap: 0.4rem;
  margin: 0.18rem 0;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: #d6dbe2;
}
.vital-track {
  height: 9px;
  background: #141820;
  border: 1px solid rgba(80, 100, 120, 0.4);
  overflow: hidden;
}
.vital-track i {
  display: block;
  height: 100%;
  width: 86%;
  background: linear-gradient(90deg, #1aa0d0, var(--cyan-bar) 55%, var(--cyan-hot));
  box-shadow: 0 0 8px rgba(62, 200, 240, 0.55);
}
.vital-pct { text-align: right; font-family: "Share Tech Mono", monospace; font-size: 12px; }
.vitals-meta {
  margin-top: 0.28rem;
  font-size: 10px;
  letter-spacing: 0.06em;
  color: #9aa3ae;
  font-family: "Share Tech Mono", monospace;
}

/* TOP CENTER TITLE */
#hud-tc {
  position: absolute;
  top: 1.15%;
  left: 50%;
  transform: translateX(-50%);
  z-index: 3;
}
.title-bar {
  display: flex;
  align-items: stretch;
  min-width: min(520px, 46vw);
  background: linear-gradient(180deg, #141820ee, #0c1018ee);
  border: 1px solid rgba(235, 180, 29, 0.55);
  clip-path: polygon(0 0, calc(100% - 22px) 0, 100% 50%, calc(100% - 22px) 100%, 0 100%);
  box-shadow: 0 0 22px rgba(235, 180, 29, 0.18), var(--shadow);
}
.title-gold {
  width: 54px;
  background: linear-gradient(180deg, #f0b01c, #c47814);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.title-hex {
  width: 28px; height: 28px;
  object-fit: contain;
  filter: drop-shadow(0 0 4px rgba(0,0,0,0.4));
}
.title-copy { padding: 0.4rem 1.4rem 0.38rem 0.85rem; }
.title-word {
  font-family: "Orbitron", "Exo 2", sans-serif;
  font-weight: 800;
  letter-spacing: 0.16em;
  font-size: clamp(13px, 1.35vw, 18px);
  color: #f6f8fb;
  line-height: 1.05;
}
.title-sub {
  margin-top: 0.08rem;
  font-size: 9px;
  letter-spacing: 0.16em;
  font-weight: 700;
  color: var(--gold);
}

/* TOP RIGHT */
#hud-tr {
  position: absolute;
  top: 1.5%;
  right: 1.6%;
  width: min(320px, 24vw);
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}
.score-panel {
  padding: 0.45rem 0.85rem 0.42rem 0.75rem;
  clip-path: polygon(18px 0, 100% 0, 100% calc(100% - 12px), calc(100% - 12px) 100%, 0 100%, 0 18px);
  background: linear-gradient(90deg, #d89a18 0 10px, rgba(10,12,18,0.88) 10px);
  border-color: rgba(235, 180, 29, 0.55);
}
.score-line {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: #d0d6de;
}
.score-line b {
  font-family: "Orbitron", "Share Tech Mono", monospace;
  font-size: clamp(16px, 1.7vw, 22px);
  color: var(--gold-hot);
  letter-spacing: 0.08em;
  margin-left: 0.25rem;
}
.score-sub {
  display: flex;
  justify-content: space-between;
  gap: 0.6rem;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: #c5ccd4;
  margin-top: 0.1rem;
}
.score-sub .boosted { color: var(--gold-hot); }
.mission-panel {
  padding: 0.55rem 0.8rem 0.6rem;
  clip-path: polygon(0 0, 100% 0, 100% calc(100% - 16px), calc(100% - 16px) 100%, 0 100%);
  border-color: rgba(235, 180, 29, 0.42);
  position: relative;
}
.mission-panel::after {
  content: "";
  position: absolute;
  left: -1px; bottom: -1px;
  width: 28px; height: 3px;
  background: var(--gold);
}
.mission-head {
  font-size: 10px;
  letter-spacing: 0.16em;
  font-weight: 800;
  color: var(--gold);
  margin-bottom: 0.3rem;
}
.mission-list {
  list-style: none;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.45;
  color: #e8edf2;
}
.mission-list .indent { padding-left: 0.7rem; font-size: 11px; }
.mission-list .muted { color: #9aa3ae; }
.mission-list .gold { color: var(--gold-hot); font-weight: 700; }
.mission-list li.done { color: #6ad07a; text-decoration: line-through; }

/* CROSSHAIR + PITCH */
#crosshair {
  position: absolute;
  left: 50%; top: 48%;
  width: 54px; height: 54px;
  transform: translate(-50%, -50%);
  pointer-events: none;
}
#crosshair .ch-h, #crosshair .ch-v {
  position: absolute; background: var(--cyan);
  box-shadow: 0 0 6px var(--cyan);
  opacity: 0.9;
}
#crosshair .ch-h { left: 10px; right: 10px; top: 50%; height: 1px; }
#crosshair .ch-v { top: 10px; bottom: 10px; left: 50%; width: 1px; }
#crosshair .ch-ring {
  position: absolute; inset: 8px;
  border: 1px solid rgba(62, 200, 240, 0.75);
  border-radius: 50%;
  box-shadow: 0 0 10px rgba(62, 200, 240, 0.35);
}
#pitch-ladder {
  position: absolute;
  left: 54.5%;
  top: 32%;
  height: 32%;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  pointer-events: none;
  color: var(--cyan);
  font-family: "Share Tech Mono", monospace;
  font-size: 11px;
  text-shadow: 0 0 6px rgba(62, 200, 240, 0.6);
}
.pl-tick {
  display: flex; align-items: center; gap: 0.35rem;
}
.pl-tick::before {
  content: "";
  width: 18px; height: 1px;
  background: var(--cyan);
  opacity: 0.8;
}

/* World-space tags (targeting boxes) */
#world-tags { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.tag {
  position: absolute;
  transform: translate(-50%, -50%);
  pointer-events: none;
}
.tag-box {
  border: 1px solid rgba(235, 180, 29, 0.9);
  box-shadow: 0 0 12px rgba(235, 180, 29, 0.25);
  position: relative;
}
.tag-box.hostile {
  border-color: #e4453a;
  box-shadow: 0 0 12px rgba(228, 69, 58, 0.35);
}
.tag-label {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  top: -22px;
  background: #1a140c;
  border: 1px solid var(--gold);
  color: var(--gold-hot);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.1em;
  padding: 0.12rem 0.45rem;
  white-space: nowrap;
  font-family: "Orbitron", "Rajdhani", sans-serif;
}
.tag-box.hostile .tag-label {
  background: #2a0c0c;
  border-color: #e4453a;
  color: #ff8a7a;
}
.tag-sub {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  bottom: -22px;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.14em;
  white-space: nowrap;
  color: var(--gold);
}
.tag-box.hostile .tag-sub { color: #e4453a; }
.tag-prompt {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  bottom: -44px;
  background: rgba(8, 28, 40, 0.85);
  border: 1px solid var(--cyan);
  color: var(--cyan-hot);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.12em;
  padding: 0.15rem 0.5rem;
  white-space: nowrap;
}

#toast {
  position: absolute;
  left: 50%; top: 18%;
  transform: translateX(-50%);
  background: rgba(12, 10, 16, 0.82);
  border: 1px solid var(--gold);
  color: var(--gold-hot);
  padding: 0.4rem 0.9rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  font-size: 13px;
}
#hit-flash {
  position: absolute; inset: 0;
  background: radial-gradient(circle at 50% 50%, transparent 40%, rgba(224, 48, 40, 0.45));
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.12s;
}
#hit-flash.on { opacity: 1; }
#heat-vignette {
  position: absolute; inset: 0;
  background: radial-gradient(circle at 50% 70%, transparent 45%, rgba(250, 89, 14, 0.35));
  opacity: 0;
  pointer-events: none;
}

/* RADAR */
#hud-bl {
  position: absolute;
  left: 1.4%;
  bottom: 2.2%;
}
#radar-wrap { position: relative; width: 168px; height: 168px; }
#radar {
  width: 168px; height: 168px;
  display: block;
  filter: drop-shadow(0 0 8px rgba(62, 200, 240, 0.35));
}
.radar-lab {
  position: absolute;
  left: 50%;
  bottom: -2px;
  transform: translateX(-50%);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.16em;
  color: var(--cyan);
  text-shadow: 0 0 8px rgba(62, 200, 240, 0.5);
}

/* BOTTOM CENTER FUEL */
#hud-bc {
  position: absolute;
  left: 50%;
  bottom: 1.4%;
  transform: translateX(-50%);
  width: min(640px, 52vw);
}
.fuel-panel {
  padding: 0.5rem 0.85rem 0.4rem;
  clip-path: polygon(12px 0, calc(100% - 18px) 0, 100% 18px, 100% calc(100% - 10px), calc(100% - 10px) 100%, 10px 100%, 0 calc(100% - 10px), 0 12px);
  border-color: rgba(62, 200, 240, 0.28);
  position: relative;
  background: rgba(8, 10, 16, 0.88);
}
.fuel-panel::before {
  content: "";
  position: absolute;
  right: -1px; top: -1px;
  width: 56px; height: 18px;
  background: var(--gold);
  clip-path: polygon(18px 0, 100% 0, 100% 100%, 0 100%);
}
.fuel-head {
  display: flex;
  align-items: baseline;
  gap: 0.7rem;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.12em;
  color: #e8edf2;
  margin-bottom: 0.28rem;
}
.fuel-cons { color: #9aa3ae; font-weight: 700; letter-spacing: 0.08em; font-size: 10px; }
.fuel-pct-wrap {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
#hud-fuel-pct {
  color: var(--orange);
  font-size: 18px;
  font-family: "Orbitron", monospace;
}
.low-fuel {
  background: #8a1810;
  color: #ffd0c8;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.1em;
  padding: 0.12rem 0.4rem;
  border: 1px solid #e4453a;
}
.low-fuel.off { display: none; }
.fuel-track {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 3px;
  height: 14px;
  margin-bottom: 0.45rem;
}
.fuel-seg {
  background: #1a1e26;
  border: 1px solid rgba(80, 70, 60, 0.4);
}
.fuel-seg.on {
  background: linear-gradient(180deg, #ffb020, #fa590e);
  box-shadow: 0 0 6px rgba(250, 89, 14, 0.45);
}
.fuel-row {
  display: grid;
  grid-template-columns: 1.15fr 1fr;
  gap: 0.55rem;
}
.boost-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  background: linear-gradient(90deg, #c47814, #a05010);
  border: 1px solid #f0b01c;
  padding: 0.35rem 0.5rem 0.35rem 0.55rem;
}
.boost-box.active {
  background: linear-gradient(90deg, #fa590e, #f81800);
  box-shadow: 0 0 16px rgba(250, 89, 14, 0.55);
}
.boost-title {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: #1a1208;
}
.boost-status {
  font-size: 10px;
  font-weight: 700;
  color: #2a1a0a;
  letter-spacing: 0.04em;
}
#btn-engage {
  pointer-events: auto;
  background: #fa590e;
  color: #1a0c06;
  border: 1px solid #ffd24a;
  font-family: "Orbitron", sans-serif;
  font-weight: 800;
  font-size: 10px;
  letter-spacing: 0.12em;
  padding: 0.4rem 0.65rem;
  cursor: pointer;
}
#btn-engage:hover { background: #ffd24a; }
.heat-box { padding: 0.1rem 0.15rem; }
.heat-title {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.1em;
  color: #e8edf2;
}
.heat-meta {
  font-size: 10px;
  color: #9aa3ae;
  font-weight: 700;
  margin: 0.05rem 0 0.15rem;
}
.heat-row { display: flex; align-items: center; gap: 0.4rem; }
.heat-track {
  flex: 1;
  height: 10px;
  background: #1a1416;
  border: 1px solid rgba(120, 40, 30, 0.5);
  overflow: hidden;
}
.heat-track i {
  display: block;
  height: 100%;
  width: 74%;
  background: linear-gradient(90deg, #a01810, #e03028 60%, #ff6a48);
}
#hud-heat-pct {
  font-family: "Share Tech Mono", monospace;
  font-size: 12px;
  color: #e8edf2;
  width: 36px;
  text-align: right;
}
.controls-foot {
  margin-top: 0.4rem;
  text-align: center;
  font-size: 9px;
  letter-spacing: 0.08em;
  font-weight: 700;
  color: #8b929c;
}

/* CARGO */
#hud-br {
  position: absolute;
  right: 1.4%;
  bottom: 1.8%;
  width: min(230px, 20vw);
}
.cargo-panel {
  padding: 0.55rem 0.7rem 0.5rem;
  background: rgba(12, 10, 8, 0.86);
  border: 1.5px solid var(--gold);
  clip-path: polygon(14px 0, 100% 0, 100% calc(100% - 14px), calc(100% - 14px) 100%, 0 100%, 0 14px);
  box-shadow: 0 0 18px rgba(235, 180, 29, 0.2), var(--shadow);
}
.cargo-head {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.12em;
  color: var(--gold-hot);
  text-align: center;
}
.cargo-cap {
  text-align: center;
  font-size: 10px;
  font-weight: 700;
  color: #c5ccd4;
  margin: 0.15rem 0 0.35rem;
}
.hex-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  justify-items: center;
  gap: 0.28rem 0.2rem;
  padding: 0 0.4rem;
}
.hex-grid img, .hex-slot {
  width: 36px; height: 40px;
  object-fit: contain;
}
.hex-slot.empty { opacity: 0.28; filter: grayscale(0.4); }
.hex-plus {
  width: 28px; height: 28px;
  border: 1px solid rgba(235, 180, 29, 0.45);
  clip-path: polygon(50% 0, 100% 25%, 100% 75%, 50% 100%, 0 75%, 0 25%);
  display: flex; align-items: center; justify-content: center;
  color: var(--gold);
  font-size: 16px;
  font-weight: 800;
  margin-top: 4px;
}
.cargo-grade {
  margin-top: 0.4rem;
  text-align: center;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.12em;
  color: var(--gold);
}

/* MAP */
#map-overlay {
  position: absolute; inset: 0;
  background: rgba(4, 4, 8, 0.55);
  display: flex; align-items: center; justify-content: center;
  z-index: 8;
}
.map-card {
  background: rgba(10, 12, 18, 0.94);
  border: 1px solid var(--gold);
  padding: 0.8rem 1rem 0.7rem;
  box-shadow: 0 0 40px rgba(0,0,0,0.6);
}
.map-title {
  font-family: "Orbitron", sans-serif;
  font-size: 12px;
  letter-spacing: 0.14em;
  color: var(--gold-hot);
  margin-bottom: 0.5rem;
}
#map-canvas { display: block; background: #0a0c12; border: 1px solid rgba(62, 200, 240, 0.25); }
.map-legend {
  display: flex; gap: 1rem; margin-top: 0.45rem;
  font-size: 10px; font-weight: 800; letter-spacing: 0.1em;
}
.lg::before {
  content: "";
  display: inline-block;
  width: 8px; height: 8px; margin-right: 0.35rem;
  vertical-align: middle;
}
.lg.you::before { background: var(--cyan); }
.lg.orchid::before { background: var(--gold); }
.lg.hornet::before { background: var(--red); }
.lg.hive::before { background: #7ad07a; }
.lg.lava::before { background: var(--orange); }
.map-hint { margin-top: 0.35rem; font-size: 10px; color: #8a9099; letter-spacing: 0.12em; }

/* MENU / RESULTS */
#menu, #results {
  position: absolute; inset: 0; z-index: 10;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at 50% 60%, rgba(80, 20, 8, 0.55), rgba(6, 4, 10, 0.78));
}
.menu-card {
  width: min(640px, 90vw);
  background: rgba(8, 10, 16, 0.9);
  border: 1px solid rgba(235, 180, 29, 0.5);
  padding: 1.4rem 1.6rem 1.3rem;
  box-shadow: 0 0 48px rgba(250, 89, 14, 0.18), var(--shadow);
  text-align: center;
}
.menu-title { margin: 0 auto 1.1rem; max-width: 520px; transform: none; }
.menu-blurb {
  color: #c5ccd4;
  font-size: 15px;
  line-height: 1.5;
  font-weight: 600;
  margin-bottom: 0.9rem;
}
.menu-blurb b { color: var(--gold-hot); }
.menu-art {
  display: flex; justify-content: center; gap: 1.4rem;
  margin: 0.6rem 0 1.1rem;
}
.menu-art img {
  height: 110px; width: auto; object-fit: contain;
  filter: drop-shadow(0 0 16px rgba(250, 89, 14, 0.45));
}
#btn-play, #btn-again {
  pointer-events: auto;
  background: linear-gradient(180deg, #f0b01c, #c47814);
  color: #1a1208;
  border: 1px solid #ffd24a;
  font-family: "Orbitron", sans-serif;
  font-weight: 800;
  letter-spacing: 0.14em;
  font-size: 13px;
  padding: 0.7rem 1.4rem;
  cursor: pointer;
}
#btn-play:hover, #btn-again:hover { filter: brightness(1.12); }
.menu-controls {
  margin-top: 0.9rem;
  font-size: 12px;
  color: #9aa3ae;
  font-weight: 600;
  line-height: 1.6;
}
kbd {
  display: inline-block;
  border: 1px solid rgba(235, 180, 29, 0.45);
  background: #16141c;
  color: var(--gold-hot);
  padding: 0 0.28rem;
  font-family: "Share Tech Mono", monospace;
  font-size: 11px;
}
.res-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.55rem;
  margin: 1rem 0 1.2rem;
  font-size: 12px;
  letter-spacing: 0.1em;
  font-weight: 700;
  color: #9aa3ae;
}
.res-grid b {
  display: block;
  color: var(--gold-hot);
  font-family: "Orbitron", monospace;
  font-size: 18px;
  margin-top: 0.15rem;
}

@media (max-width: 1100px) {
  #hud-bc { width: min(560px, 62vw); }
  .title-word { letter-spacing: 0.1em; }
}
@media (max-width: 800px) {
  #hud-tr, #hud-tl { width: min(240px, 40vw); }
  .mission-list { font-size: 10px; }
}
