:root {
  --bg: #080c16;
  --panel: rgba(8, 14, 28, 0.78);
  --panel-solid: #0c1422;
  --cyan: #3ee8f7;
  --cyan-2: #5cf0ff;
  --cyan-dim: #1aa8c0;
  --gold: #ffd24a;
  --gold-text: #ffe082;
  --mag: #ff4ec8;
  --mag-deep: #c2186a;
  --green: #3dff9a;
  --green-dim: #1eaa6a;
  --orange: #ffaf2b;
  --blue-btn: #3a8dff;
  --purple-btn: #7b3cff;
  --pink-bar: #ff3a8a;
  --text: #e8f4ff;
  --muted: #7a8aa0;
  --stroke: rgba(62, 232, 247, 0.55);
  --gold-stroke: rgba(255, 210, 74, 0.7);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { width: 100%; height: 100%; overflow: hidden; background: var(--bg); }
body {
  font-family: "Rajdhani", "Exo 2", sans-serif;
  color: var(--text);
  user-select: none;
}
button { font-family: inherit; cursor: pointer; }
kbd {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 4px;
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.18);
  font-family: "Orbitron", sans-serif;
  font-size: 11px;
  letter-spacing: 0.06em;
}

#stage { position: relative; width: 100%; height: 100%; }
#c { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }

#runes {
  position: absolute; left: 18px; top: 38%;
  width: 70px; height: 180px;
  opacity: 0.18; pointer-events: none;
  background-image:
    linear-gradient(90deg, transparent 40%, #8aa 40%, #8aa 42%, transparent 42%),
    linear-gradient(#8aa, #8aa);
  background-size: 100% 14px, 18px 3px;
  background-repeat: repeat-y, no-repeat;
  filter: blur(0.2px);
}

.hidden { display: none !important; }

/* ========== HUD ========== */
#hud { position: absolute; inset: 0; pointer-events: none; }
#hud button, #hud .build-card, #hud .stat-chip { pointer-events: auto; }

#hud-tl {
  position: absolute; top: 16px; left: 18px;
  display: flex; align-items: center; gap: 10px;
  background: linear-gradient(90deg, rgba(18,16,12,0.92), rgba(12,14,22,0.82));
  border: 1.5px solid rgba(255, 175, 43, 0.35);
  border-radius: 14px;
  padding: 8px 18px 8px 8px;
  box-shadow: 0 0 18px rgba(255, 160, 30, 0.12), inset 0 0 20px rgba(255, 180, 40, 0.05);
}
.title-pick {
  width: 52px; height: 52px; border-radius: 12px;
  object-fit: cover; flex: none;
  box-shadow: 0 0 12px rgba(255, 160, 30, 0.45);
}
.title-pick.lg { width: 64px; height: 64px; }
.title-copy h1, .menu-card h1, .menu-title-row h1 {
  font-family: "Orbitron", sans-serif;
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: var(--gold-text);
  text-shadow: 0 0 12px rgba(255, 210, 74, 0.35);
}
.title-sub {
  font-size: 11px;
  letter-spacing: 0.12em;
  color: #c9a24a;
  margin-top: 2px;
  font-weight: 600;
}

#hud-tc {
  position: absolute; top: 12px; left: 50%;
  transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  min-width: 540px;
}
.wave-row { display: flex; align-items: center; gap: 10px; }
.wave-pill {
  display: flex; align-items: baseline; gap: 8px;
  background: rgba(8, 18, 32, 0.88);
  border: 1.5px solid var(--cyan);
  border-radius: 22px;
  padding: 6px 22px;
  box-shadow: 0 0 16px rgba(62, 232, 247, 0.25);
  font-family: "Orbitron", sans-serif;
}
.wave-lab { color: var(--cyan); font-size: 12px; letter-spacing: 0.18em; font-weight: 700; }
.wave-num { color: var(--cyan-2); font-size: 22px; font-weight: 800; }
.wave-sep, .wave-max { color: var(--cyan-dim); font-size: 16px; font-weight: 700; }
.swarm-pill {
  background: linear-gradient(90deg, #7a1848, #c2186a);
  border: 1px solid #ff5a9a;
  color: #ffe0ee;
  border-radius: 16px;
  padding: 6px 14px;
  font-family: "Orbitron", sans-serif;
  font-size: 11px;
  letter-spacing: 0.1em;
  font-weight: 700;
  box-shadow: 0 0 14px rgba(255, 60, 140, 0.35);
}
.swarm-pill.off { opacity: 0.25; filter: grayscale(0.8); }
.swarm-ico { color: #ffd24a; margin-right: 4px; }

.boss-plate {
  width: 620px;
  background: rgba(12, 8, 18, 0.82);
  border: 1.5px solid #ff4a9a;
  border-radius: 16px;
  padding: 6px 14px 8px;
  box-shadow: 0 0 16px rgba(255, 50, 140, 0.2);
}
.boss-row {
  display: flex; justify-content: space-between; align-items: baseline;
  font-family: "Orbitron", sans-serif;
  font-size: 11px; letter-spacing: 0.06em;
  margin-bottom: 5px;
}
.boss-name { color: #ffd0e4; font-weight: 700; }
.boss-hp { color: #ff8ab8; }
.boss-track {
  height: 8px; border-radius: 6px;
  background: #141018;
  overflow: hidden;
  box-shadow: inset 0 0 6px #000;
}
.boss-track i {
  display: block; height: 100%; width: 64.5%;
  background: linear-gradient(90deg, #2ad4e8 0%, #3ee8f7 45%, #ff4ec8 78%, #ff3a8a 100%);
  box-shadow: 0 0 8px #3ee8f7;
}

#hud-tr {
  position: absolute; top: 14px; right: 16px;
  display: flex; gap: 8px;
}
.stat-chip {
  display: flex; align-items: center; gap: 8px;
  background: rgba(8, 14, 24, 0.88);
  border-radius: 14px;
  padding: 6px 12px 6px 8px;
  min-width: 118px;
  border: 1.5px solid rgba(80, 100, 130, 0.4);
}
.stat-chip img { width: 28px; height: 28px; object-fit: contain; }
.chip-num {
  font-family: "Orbitron", sans-serif;
  font-size: 13px; font-weight: 800;
}
.chip-lab {
  font-size: 9px; letter-spacing: 0.1em;
  color: var(--muted); font-weight: 700;
}
.stat-chip.teal { border-color: #2ee6a0; }
.stat-chip.teal .chip-num { color: #7dffc4; }
.stat-chip.gold { border-color: #e0b020; }
.stat-chip.gold .chip-num { color: var(--gold); }
.stat-chip.cyan { border-color: #2ad0e8; }
.stat-chip.cyan .chip-num { color: var(--cyan); }
.stat-chip.mag { border-color: #e040a0; }
.stat-chip.mag .chip-num { color: #ff8ad0; }

#radar-panel {
  position: absolute; top: 78px; right: 18px;
  width: 188px;
  background: rgba(6, 18, 28, 0.82);
  border: 1.5px solid var(--cyan-dim);
  border-radius: 12px;
  padding: 8px 8px 10px;
  box-shadow: 0 0 16px rgba(40, 180, 200, 0.15);
}
.radar-head {
  display: flex; justify-content: space-between;
  font-family: "Orbitron", sans-serif;
  font-size: 9px; letter-spacing: 0.14em;
  color: var(--cyan); margin-bottom: 4px; font-weight: 700;
}
.radar-head .live { color: var(--cyan-2); }
#radar { width: 100%; height: 150px; display: block; image-rendering: pixelated; }

/* Linked avatars */
#hud-bl {
  position: absolute; left: 16px; bottom: 16px;
  width: 520px;
  background: rgba(8, 14, 28, 0.86);
  border: 1.5px solid rgba(62, 232, 247, 0.45);
  border-radius: 16px;
  padding: 10px 12px 12px;
  box-shadow: 0 0 22px rgba(40, 180, 220, 0.12);
}
.linked-head {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 8px;
}
.linked-title {
  font-family: "Orbitron", sans-serif;
  font-size: 12px; letter-spacing: 0.18em;
  color: var(--cyan); font-weight: 800;
}
.tether-sync {
  font-family: "Orbitron", sans-serif;
  font-size: 10px; letter-spacing: 0.08em;
  color: var(--green);
  background: rgba(20, 80, 50, 0.5);
  border: 1px solid var(--green-dim);
  border-radius: 10px;
  padding: 3px 8px;
  font-weight: 700;
}
.avatar-row { display: flex; gap: 10px; }
.avatar-card {
  flex: 1;
  display: flex; gap: 8px; align-items: center;
  background: rgba(10, 18, 32, 0.7);
  border: 1px solid rgba(80, 100, 130, 0.35);
  border-radius: 12px;
  padding: 8px;
}
.avatar-card.active {
  border-color: var(--cyan);
  box-shadow: 0 0 12px rgba(62, 232, 247, 0.2);
  background: linear-gradient(90deg, rgba(18, 70, 90, 0.55), rgba(10, 18, 32, 0.7));
}
.av-port {
  width: 56px; height: 56px; border-radius: 12px;
  object-fit: cover; background: #0a1220;
  border: 1px solid rgba(255,255,255,0.08);
  flex: none;
}
.av-name {
  font-family: "Orbitron", sans-serif;
  font-size: 12px; font-weight: 800; letter-spacing: 0.06em;
}
.av-name-row { display: flex; align-items: center; gap: 8px; }
.tag {
  font-size: 9px; font-weight: 800; letter-spacing: 0.1em;
  border-radius: 8px; padding: 2px 6px;
  font-family: "Orbitron", sans-serif;
}
.active-tag { background: #1a8a5a; color: #d8ffe8; }
.sentry-tag { background: #3a4558; color: #c8d0dc; }
.av-ability {
  display: flex; justify-content: space-between;
  font-size: 10px; color: var(--muted); margin-top: 4px;
  letter-spacing: 0.04em; font-weight: 600;
}
.ready { color: var(--green); font-weight: 800; }
.av-bar {
  margin-top: 4px; height: 4px; border-radius: 3px;
  background: #1a2430; overflow: hidden;
}
.av-bar i { display: block; height: 100%; width: 100%; background: var(--green); }

#btn-swap {
  margin-top: 10px; width: 100%;
  border: 0; border-radius: 10px;
  padding: 9px 12px;
  background: linear-gradient(90deg, #ff3ec8, #c040ff);
  color: #fff;
  font-family: "Orbitron", sans-serif;
  font-size: 12px; font-weight: 800; letter-spacing: 0.1em;
  box-shadow: 0 0 18px rgba(255, 60, 200, 0.35);
}
#btn-swap kbd { background: rgba(0,0,0,0.25); margin-right: 6px; }
.swap-plus { opacity: 0.8; }

/* Build bar */
#hud-bc {
  position: absolute; left: 50%; bottom: 16px;
  transform: translateX(-50%);
}
.build-wrap {
  display: flex; gap: 8px;
  background: rgba(8, 12, 22, 0.86);
  border: 1.5px solid rgba(255, 210, 74, 0.35);
  border-radius: 16px;
  padding: 10px 12px;
}
.build-card {
  width: 108px;
  background: #10182a;
  border: 1px solid rgba(80, 100, 140, 0.35);
  border-radius: 12px;
  color: var(--text);
  padding: 10px 6px 8px;
  position: relative;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
}
.build-card img { width: 42px; height: 42px; object-fit: contain; }
.build-card .slot-num {
  position: absolute; top: 6px; left: 8px;
  width: 18px; height: 18px; border-radius: 50%;
  background: #2a3348; color: #c8d0dc;
  font-size: 10px; font-family: "Orbitron", sans-serif; font-weight: 800;
  display: grid; place-items: center;
}
.build-card .b-name {
  font-family: "Orbitron", sans-serif;
  font-size: 9px; letter-spacing: 0.06em; font-weight: 700;
  margin-top: 2px;
}
.build-card .b-cost {
  display: flex; align-items: center; gap: 4px;
  color: var(--gold); font-family: "Orbitron", sans-serif;
  font-size: 12px; font-weight: 800;
}
.build-card .b-cost img { width: 14px; height: 14px; }
.build-card.selected {
  background: linear-gradient(180deg, #2a2410, #16120a);
  border: 1.5px solid var(--gold);
  box-shadow: 0 0 16px rgba(255, 210, 74, 0.35);
}
.build-card:hover { border-color: var(--gold-text); }
.build-card.disabled { opacity: 0.4; }

/* Action panel */
#hud-br {
  position: absolute; right: 16px; bottom: 16px;
  width: 280px;
  background: rgba(8, 12, 22, 0.86);
  border: 1.5px solid rgba(80, 120, 180, 0.35);
  border-radius: 16px;
  padding: 12px;
  display: flex; flex-direction: column; gap: 8px;
}
.act-blue, .act-purple {
  display: flex; align-items: center; gap: 8px;
  border: 0; border-radius: 10px;
  padding: 10px 12px;
  color: #fff;
  font-family: "Orbitron", sans-serif;
  font-size: 12px; font-weight: 800; letter-spacing: 0.08em;
}
.act-blue { background: linear-gradient(90deg, #2a7dff, #4aa8ff); }
.act-purple { background: linear-gradient(90deg, #6a2adf, #9a4aff); }
.act-blue img { width: 18px; height: 18px; object-fit: contain; filter: brightness(2); }
.act-blue kbd, .act-purple kbd {
  margin-left: auto; background: rgba(0,0,0,0.25);
}
.spark { color: #ffe080; }
.speed-row { display: flex; gap: 6px; }
.spd {
  flex: 1;
  background: #1a2230;
  border: 1px solid #2a3448;
  color: #c8d0dc;
  border-radius: 8px;
  padding: 8px 4px;
  font-family: "Orbitron", sans-serif;
  font-size: 10px; font-weight: 700;
  display: flex; align-items: center; justify-content: center; gap: 4px;
}
.spd img { width: 14px; height: 14px; object-fit: contain; filter: invert(1); }
.spd.on { background: #243044; border-color: #4a90c0; color: #fff; }
.spd.cyan-spd { border-color: var(--cyan-dim); color: var(--cyan); }
.spd.ico-only { flex: 0 0 40px; font-size: 16px; }

/* World labels */
#world-labels {
  position: absolute; inset: 0; pointer-events: none;
  overflow: hidden;
}
.wlab {
  position: absolute;
  transform: translate(-50%, -100%);
  font-family: "Orbitron", sans-serif;
  font-size: 11px; font-weight: 700; letter-spacing: 0.06em;
  padding: 4px 8px; border-radius: 6px;
  white-space: nowrap;
  pointer-events: none;
}
.wlab.cyan { background: #0a3048; color: #9ef0ff; border: 1px solid #2ad4e8; }
.wlab.mag { background: #2a1040; color: #f0c0ff; border: 1px solid #c070e0; }
.wlab.green {
  background: #083828; color: #b8ffd0; border: 1px solid #2ee6a0;
  text-align: center; white-space: normal; max-width: 220px;
  font-size: 10px; line-height: 1.35;
}
.wlab.gold {
  background: #3a2808; color: var(--gold); border: 1px solid #e0a020;
  font-size: 14px; font-weight: 800;
}
.wlab.dmg {
  background: transparent; border: 0; color: #ffd24a;
  font-size: 16px; text-shadow: 0 0 8px #000;
}

/* Menu / results */
#menu, #results, #settings {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  background: rgba(4, 8, 16, 0.55);
  z-index: 5;
}
.menu-card {
  width: min(640px, 92vw);
  background: linear-gradient(180deg, rgba(12, 18, 32, 0.96), rgba(8, 12, 22, 0.96));
  border: 1.5px solid rgba(62, 232, 247, 0.45);
  border-radius: 18px;
  padding: 28px 32px;
  box-shadow: 0 0 40px rgba(40, 180, 220, 0.18);
}
.menu-card.slim { width: min(380px, 90vw); }
.menu-title-row { display: flex; gap: 14px; align-items: center; margin-bottom: 16px; }
.menu-blurb { color: #c8d4e4; line-height: 1.5; margin-bottom: 16px; font-size: 16px; }
.menu-controls { color: var(--muted); font-size: 14px; line-height: 1.7; margin-bottom: 20px; }
#btn-play, #btn-again, #btn-close-set {
  width: 100%;
  background: linear-gradient(90deg, #2a7dff, #3ee8f7);
  border: 0; border-radius: 10px;
  padding: 12px;
  font-family: "Orbitron", sans-serif;
  font-size: 14px; font-weight: 800; letter-spacing: 0.12em;
  color: #081018;
}
#btn-new.ghost, .ghost {
  width: 100%; margin-top: 8px;
  background: transparent;
  border: 1px solid var(--cyan-dim);
  color: var(--cyan);
  border-radius: 10px; padding: 10px;
  font-family: "Orbitron", sans-serif;
  font-size: 12px; letter-spacing: 0.1em; font-weight: 700;
}
.res-grid {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 10px; margin: 18px 0;
  font-family: "Orbitron", sans-serif; font-size: 12px; color: var(--muted);
}
.res-grid b { display: block; color: var(--gold); font-size: 18px; margin-top: 4px; }
.set-row { display: flex; gap: 10px; align-items: center; margin: 16px 0; font-family: "Orbitron", sans-serif; }

#pause {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  background: rgba(4, 8, 16, 0.45);
  font-family: "Orbitron", sans-serif;
  font-size: 42px; letter-spacing: 0.2em;
  color: var(--cyan);
  z-index: 4;
  pointer-events: none;
}
#toast {
  position: absolute; top: 22%; left: 50%;
  transform: translateX(-50%);
  background: rgba(8, 16, 28, 0.9);
  border: 1px solid var(--gold);
  color: var(--gold-text);
  font-family: "Orbitron", sans-serif;
  font-size: 14px; letter-spacing: 0.1em;
  padding: 8px 16px; border-radius: 8px;
  z-index: 6; pointer-events: none;
}

@media (max-width: 1280px) {
  #hud-tl h1 { font-size: 12px; }
  .build-card { width: 88px; }
  #hud-bl { width: 440px; }
  .boss-plate { width: 480px; }
}
