:root {
  --cyan: #3ec8f0;
  --cyan-hot: #7af4ff;
  --cyan-dim: #1488b0;
  --cyan-line: #00c8e8;
  --gold: #f5b420;
  --gold-hot: #ffd24a;
  --orange: #ffbf24;
  --kw: #f0b428;
  --magenta: #d060ff;
  --purple: #b44cff;
  --green: #2ee8a0;
  --red: #ff4a6a;
  --ink: #e8f6ff;
  --muted: #6a90a8;
  --navy: #020814;
  --panel: rgba(4, 12, 24, 0.88);
  --panel-2: rgba(6, 16, 32, 0.92);
  --border: rgba(0, 200, 232, 0.55);
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #020814;
  color: var(--ink);
  font-family: "Rajdhani", "Exo 2", "Segoe UI", sans-serif;
  user-select: none;
}

#stage {
  position: fixed;
  inset: 0;
  background: #020814;
}

#c {
  display: block;
  width: 100%;
  height: 100%;
}

.hidden { display: none !important; }

button { font-family: inherit; cursor: pointer; }

#float-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 6;
  overflow: hidden;
}

.floater {
  position: absolute;
  transform: translate(-50%, -100%);
  white-space: nowrap;
  pointer-events: none;
  font-family: "Orbitron", "Share Tech Mono", sans-serif;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-shadow: 0 0 10px currentColor;
}
.floater.dmg { color: #7af6ff; font-size: 14px; }
.floater.crit { color: #ffe14a; font-size: 18px; }
.floater.kw { color: #ffd24a; font-size: 13px; }
.floater.heal { color: #40f0a8; font-size: 13px; }
.floater.tag {
  font-size: 10px;
  letter-spacing: 0.16em;
  padding: 1px 7px;
  border: 1px solid currentColor;
  background: rgba(4, 10, 22, 0.82);
  text-shadow: none;
}
.floater.tag.armored { color: #7af0c8; }
.floater.tag.shocked { color: #7af4ff; }
.floater.tag.stunned { color: #c8e8ff; }
.floater.name {
  font-size: 10px;
  color: #ffd24a;
  letter-spacing: 0.14em;
  text-shadow: 0 0 8px #f5b420;
}
.floater.hpwrap {
  transform: translate(-50%, -130%);
  text-shadow: none;
}
.floater .hpbar {
  width: 36px;
  height: 4px;
  background: #1a2430;
  border: 1px solid #2ee8a0;
  display: block;
  position: relative;
}
.floater .hpbar i {
  display: block;
  height: 100%;
  background: #2ee8a0;
  width: 70%;
}

/* ========== HUD ========== */
#hud {
  position: absolute;
  inset: 0;
  z-index: 5;
  pointer-events: none;
}
#hud button { pointer-events: auto; }

.frame-tick {
  position: absolute;
  width: 46px;
  height: 28px;
  border: 2px solid rgba(0, 200, 232, 0.55);
  pointer-events: none;
  z-index: 8;
}
.frame-tick.tl { top: 78px; left: 14px; border-right: none; border-bottom: none; }
.frame-tick.tr { top: 78px; right: 14px; border-left: none; border-bottom: none; }
.frame-tick.bl { bottom: 14px; left: 14px; border-right: none; border-top: none; }
.frame-tick.br { bottom: 14px; right: 14px; border-left: none; border-top: none; }

#topbar {
  position: absolute;
  top: 10px;
  left: 12px;
  right: 12px;
  height: 64px;
  display: grid;
  grid-template-columns: 1.45fr 1.15fr 1.7fr 1.05fr 0.95fr;
  gap: 8px;
  align-items: center;
  padding: 6px 12px 6px 8px;
  background: linear-gradient(180deg, rgba(4, 16, 32, 0.94), rgba(2, 10, 22, 0.9));
  border: 1.5px solid rgba(0, 196, 228, 0.7);
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.55),
    0 0 22px rgba(0, 196, 228, 0.16),
    inset 0 0 28px rgba(0, 40, 70, 0.28);
  clip-path: polygon(
    14px 0%, calc(100% - 14px) 0%, 100% 12px,
    100% calc(100% - 8px), calc(100% - 8px) 100%,
    8px 100%, 0% calc(100% - 8px), 0% 12px
  );
  pointer-events: none;
}

#topbar::before {
  content: "";
  position: absolute;
  left: 18px;
  right: 18px;
  top: -2px;
  height: 2px;
  background: linear-gradient(90deg, transparent, #00f0ff 12%, #00f0ff 88%, transparent);
}

.tb-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.brand-ico {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: linear-gradient(180deg, #1ad0f0, #0688b8);
  display: grid;
  place-items: center;
  box-shadow: 0 0 16px rgba(0, 210, 255, 0.55);
  flex-shrink: 0;
}
.brand-ico img { width: 22px; height: 22px; object-fit: contain; filter: drop-shadow(0 0 4px #fff); }
.wordmark {
  font-family: "Audiowide", "Orbitron", sans-serif;
  font-size: 20px;
  letter-spacing: 0.08em;
  color: #e8fbff;
  text-shadow: 0 0 12px rgba(80, 220, 255, 0.55);
  white-space: nowrap;
}
.sector {
  font-size: 11px;
  letter-spacing: 0.12em;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}
.sector .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #2ee8a0;
  box-shadow: 0 0 8px #2ee8a0;
  display: inline-block;
}
.sector .night { color: #7ad8f0; }

.tb-wave { min-width: 0; padding-left: 8px; }
.wave-line {
  display: flex;
  align-items: baseline;
  gap: 6px;
  font-family: "Orbitron", sans-serif;
}
.wave-line .lab {
  font-size: 11px;
  letter-spacing: 0.18em;
  color: #8eb0c4;
}
.wave-line b {
  font-size: 22px;
  color: #e8fbff;
}
.wave-line .dim { color: #6a90a8; font-size: 16px; }
.surge-lab {
  font-size: 10px;
  letter-spacing: 0.1em;
  color: #7a9cb0;
  margin-top: -2px;
}
.surge-lab b { color: #9ad8f0; }
.surge-track {
  height: 5px;
  background: #0a2030;
  border-radius: 3px;
  overflow: hidden;
  margin-top: 3px;
  box-shadow: inset 0 0 0 1px #123848;
}
.surge-track i {
  display: block;
  height: 100%;
  width: 78%;
  background: linear-gradient(90deg, #1488c8, #3ec8f0);
  box-shadow: 0 0 8px #3ec8f0;
}

.tb-core { min-width: 0; }
.core-lab {
  font-size: 11px;
  letter-spacing: 0.1em;
  color: #8eb0c4;
  white-space: nowrap;
}
.core-lab b { color: #e8fbff; font-family: "Orbitron", sans-serif; font-size: 13px; }
.core-lab .pct { color: #7ad8f0; margin-left: 4px; }
.core-track {
  display: flex;
  gap: 3px;
  margin-top: 6px;
  height: 10px;
}
.core-track span {
  flex: 1;
  background: #0a2438;
  border-radius: 1px;
  box-shadow: inset 0 0 0 1px #123848;
}
.core-track span.on {
  background: linear-gradient(180deg, #5ad8ff, #1aa0d0);
  box-shadow: 0 0 6px rgba(90, 216, 255, 0.55);
}

.tb-kw { display: flex; justify-content: flex-end; }
.kw-box {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 14px 4px 10px;
  border: 1.5px solid #f5b420;
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(40, 28, 4, 0.7), rgba(16, 12, 2, 0.7));
  box-shadow: 0 0 16px rgba(245, 180, 32, 0.22), inset 0 0 12px rgba(245, 180, 32, 0.08);
}
.kw-bolt { width: 18px; height: 18px; object-fit: contain; filter: drop-shadow(0 0 6px #f5b420); }
.kw-num {
  font-family: "Orbitron", sans-serif;
  font-size: 20px;
  color: #ffd24a;
  letter-spacing: 0.04em;
  text-shadow: 0 0 10px #f5b420;
  line-height: 1.05;
}
.kw-num b { font-weight: 800; }
.kw-unit { font-size: 12px; color: #f5b420; }
.kw-rate {
  font-size: 10px;
  letter-spacing: 0.08em;
  color: #2ee8a0;
  margin-top: -1px;
}

.tb-score { text-align: right; padding-right: 6px; }
.tb-score .lab {
  font-size: 10px;
  letter-spacing: 0.16em;
  color: #8eb0c4;
}
.tb-score .score {
  font-family: "Orbitron", sans-serif;
  font-size: 22px;
  color: #e8fbff;
  letter-spacing: 0.06em;
  line-height: 1.05;
  min-height: 1.05em;
}
.tb-score .combo {
  font-size: 10px;
  letter-spacing: 0.1em;
  color: var(--cyan);
}
.tb-score .combo b { color: var(--cyan-hot); }

/* Right overdrive */
#overdrive {
  position: absolute;
  top: 88px;
  right: 16px;
  width: 248px;
  padding: 12px 12px 10px;
  background: linear-gradient(180deg, rgba(4, 14, 28, 0.9), rgba(3, 10, 22, 0.88));
  border: 1.5px solid rgba(0, 196, 228, 0.55);
  border-radius: 10px;
  box-shadow: 0 0 18px rgba(0, 196, 228, 0.12), inset 0 0 20px rgba(0, 40, 70, 0.25);
  pointer-events: auto;
}
.od-head, .radar-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 11px;
  letter-spacing: 0.16em;
  color: var(--cyan);
  margin-bottom: 8px;
  font-weight: 700;
}
.od-head b, .radar-head b {
  color: var(--green);
  font-size: 10px;
  letter-spacing: 0.14em;
}
.od-card {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 8px;
  margin-bottom: 7px;
  background: rgba(6, 16, 32, 0.85);
  border: 1px solid rgba(0, 180, 210, 0.35);
  border-radius: 7px;
  color: inherit;
  text-align: left;
}
.od-card img { width: 22px; height: 22px; object-fit: contain; flex-shrink: 0; }
.od-name {
  font-size: 11px;
  letter-spacing: 0.1em;
  font-weight: 800;
  color: #d8f0ff;
  display: flex;
  justify-content: space-between;
  gap: 6px;
}
.od-name .key { color: #8eb0c4; font-weight: 600; font-size: 10px; }
.od-sub { font-size: 10px; letter-spacing: 0.08em; color: #6a90a8; }
.od-card.gold { border-color: #f5b420; box-shadow: 0 0 10px rgba(245, 180, 32, 0.18); }
.od-card.gold .od-name { color: #ffd24a; }
.od-card.gold .od-sub { color: #f5b420; }
.od-card.cyan { border-color: #3ec8f0; }
.od-card.cyan .od-sub { color: #3ec8f0; }
.od-card.muted { opacity: 0.78; }
.od-card:hover { filter: brightness(1.12); }

#radar {
  width: 100%;
  height: 118px;
  display: block;
  background: #041018;
  border: 1px solid rgba(0, 180, 210, 0.35);
  border-radius: 8px;
  margin-bottom: 8px;
}

.speed-row {
  display: flex;
  gap: 6px;
}
.spd {
  flex: 1;
  height: 26px;
  background: rgba(6, 16, 32, 0.9);
  border: 1px solid rgba(0, 180, 210, 0.4);
  color: #9ad0e8;
  font-size: 10px;
  letter-spacing: 0.1em;
  font-weight: 700;
  border-radius: 4px;
}
.spd.on {
  border-color: #3ec8f0;
  color: #e8fbff;
  box-shadow: 0 0 8px rgba(62, 200, 240, 0.3);
}

/* Telemetry */
#telemetry {
  position: absolute;
  left: 16px;
  bottom: 16px;
  width: 280px;
  padding: 12px 14px 10px;
  background: linear-gradient(180deg, rgba(4, 14, 28, 0.9), rgba(3, 10, 22, 0.88));
  border: 1.5px solid rgba(0, 196, 228, 0.5);
  border-radius: 10px;
  pointer-events: none;
}
.tel-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 8px;
  font-size: 12px;
  letter-spacing: 0.16em;
  color: var(--cyan);
  font-weight: 800;
  line-height: 1.15;
}
.synced {
  color: var(--green);
  font-size: 11px;
  letter-spacing: 0.14em;
  display: flex;
  align-items: center;
  gap: 6px;
}
.synced .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 8px var(--green);
}
.tel-row {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  letter-spacing: 0.08em;
  color: #7a9cb0;
  margin: 3px 0;
}
.tel-row b { color: #e8fbff; font-weight: 700; }
.tel-row b.surge { color: #ff4a6a; }

/* Arsenal */
#arsenal {
  position: absolute;
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%);
  display: flex;
  gap: 8px;
  padding: 10px 12px 8px;
  background: linear-gradient(180deg, rgba(4, 14, 28, 0.9), rgba(3, 10, 22, 0.9));
  border: 1.5px solid rgba(0, 196, 228, 0.5);
  border-radius: 12px;
  pointer-events: auto;
  box-shadow: 0 0 20px rgba(0, 196, 228, 0.12);
}
.tower-card {
  width: 118px;
  height: 118px;
  position: relative;
  background: rgba(6, 14, 28, 0.92);
  border: 1.5px solid rgba(0, 160, 196, 0.4);
  border-radius: 8px;
  color: inherit;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding-top: 8px;
}
.tower-card img { width: 36px; height: 36px; object-fit: contain; }
.tower-card .tc-key {
  position: absolute;
  top: 5px;
  left: 7px;
  font-size: 10px;
  color: #6a90a8;
  letter-spacing: 0.08em;
}
.tower-card .tc-name {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: #d0e8f8;
  text-align: center;
  line-height: 1.1;
}
.tower-card .tc-cost {
  font-family: "Orbitron", sans-serif;
  font-size: 12px;
  color: #f5b420;
  letter-spacing: 0.04em;
}
.tower-card .tc-cost.mag { color: #e060ff; }
.tower-card.selected {
  border-color: #3ec8f0;
  box-shadow: 0 0 0 1px #3ec8f0, 0 0 16px rgba(62, 200, 240, 0.35);
}
.tower-card.selected .tc-name { color: #7af4ff; }
.sel-tag {
  position: absolute;
  top: -10px;
  left: 50%;
  transform: translateX(-50%);
  background: #0a2030;
  border: 1px solid #3ec8f0;
  color: #7af4ff;
  font-size: 8px;
  letter-spacing: 0.16em;
  padding: 1px 8px;
  border-radius: 3px;
  font-weight: 800;
}
.tower-card:hover { filter: brightness(1.1); }
.tower-card.disabled { opacity: 0.45; filter: grayscale(0.3); }

#autoharvest {
  position: absolute;
  right: 16px;
  bottom: 16px;
  padding: 10px 16px 8px;
  background: linear-gradient(180deg, rgba(4, 14, 28, 0.9), rgba(3, 10, 22, 0.88));
  border: 1.5px solid rgba(0, 196, 228, 0.5);
  border-radius: 10px;
  min-width: 200px;
  text-align: left;
  pointer-events: none;
}
.ah-lab {
  font-size: 10px;
  letter-spacing: 0.16em;
  color: #8eb0c4;
  font-weight: 700;
}
.ah-val {
  font-size: 13px;
  letter-spacing: 0.1em;
  color: var(--green);
  font-weight: 800;
  margin-top: 2px;
}

#tooltip {
  position: absolute;
  width: 268px;
  padding: 10px 12px 10px;
  background: linear-gradient(180deg, rgba(6, 16, 32, 0.94), rgba(4, 12, 24, 0.94));
  border: 1.5px solid rgba(0, 196, 228, 0.65);
  border-radius: 8px;
  pointer-events: auto;
  z-index: 9;
  box-shadow: 0 0 18px rgba(0, 196, 228, 0.18);
}
.tt-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-family: "Orbitron", sans-serif;
  font-size: 12px;
  letter-spacing: 0.08em;
  color: var(--cyan-hot);
  margin-bottom: 6px;
}
.tt-head b { color: #8eb0c4; font-size: 11px; }
#tt-stats {
  list-style: none;
  font-size: 11px;
  color: #b8d4e4;
  letter-spacing: 0.02em;
  line-height: 1.45;
}
#tt-stats li::before { content: "• "; color: #3ec8f0; }
.overload {
  margin-top: 8px;
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 8px;
  background: rgba(8, 18, 32, 0.9);
  border: 1px solid #f5b420;
  color: #ffd24a;
  border-radius: 4px;
  font-size: 11px;
  letter-spacing: 0.08em;
  font-weight: 800;
}
.overload b {
  border: 1px solid #f5b420;
  padding: 2px 6px;
  font-size: 10px;
}

/* Menu / results */
#menu, #results, #pause {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  background: radial-gradient(ellipse at 50% 40%, rgba(4, 24, 48, 0.55), rgba(2, 6, 16, 0.82));
  pointer-events: auto;
}
.menu-card {
  width: min(640px, 92vw);
  padding: 28px 32px 24px;
  background: linear-gradient(180deg, rgba(6, 18, 36, 0.94), rgba(3, 10, 22, 0.94));
  border: 1.5px solid rgba(0, 196, 228, 0.65);
  border-radius: 14px;
  box-shadow: 0 0 40px rgba(0, 196, 228, 0.16);
}
.menu-card.slim { width: min(520px, 92vw); text-align: center; }
.menu-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 16px;
}
.menu-brand img {
  width: 52px;
  height: 52px;
  object-fit: contain;
  filter: drop-shadow(0 0 10px #3ec8f0);
}
.menu-brand .wordmark { font-size: 26px; }
.menu-blurb {
  color: #b8d4e4;
  font-size: 15px;
  line-height: 1.45;
  margin-bottom: 18px;
}
.menu-blurb b { color: #ffd24a; }
#btn-play, #btn-again, #btn-resume {
  width: 100%;
  height: 48px;
  background: linear-gradient(180deg, #1ad0f0, #0688b8);
  border: none;
  color: #041018;
  font-family: "Orbitron", sans-serif;
  font-size: 14px;
  letter-spacing: 0.14em;
  font-weight: 800;
  border-radius: 8px;
  box-shadow: 0 0 18px rgba(26, 208, 240, 0.45);
}
#btn-play:hover, #btn-again:hover, #btn-resume:hover { filter: brightness(1.08); }
.menu-controls {
  margin-top: 14px;
  font-size: 12px;
  color: #7a9cb0;
  letter-spacing: 0.06em;
  line-height: 1.55;
}
kbd {
  display: inline-block;
  padding: 0 5px;
  border: 1px solid #3ec8f0;
  border-radius: 3px;
  color: #7af4ff;
  font-family: "Share Tech Mono", monospace;
  font-size: 11px;
}
.res-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 18px;
  margin: 16px 0 18px;
  font-size: 13px;
  letter-spacing: 0.1em;
  color: #8eb0c4;
}
.res-grid b {
  display: block;
  color: #e8fbff;
  font-family: "Orbitron", sans-serif;
  font-size: 16px;
  margin-top: 2px;
}

@media (max-width: 1280px) {
  .wordmark { font-size: 16px; }
  #overdrive { width: 210px; }
  .tower-card { width: 96px; height: 108px; }
  #telemetry { width: 240px; }
}
