:root {
  --pd-bg: #04030b;
  --pd-glass: rgba(14, 18, 38, 0.72);
  --pd-glass-border: rgba(124, 249, 255, 0.22);
  --pd-accent: #7cf9ff;
  --pd-gold: #ffd36b;
  --pd-good: #5dff9d;
  --pd-bad: #ff4d6a;
  --pd-text: #e8f1ff;
  --pd-muted: #93a3c4;
}

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--pd-bg);
  color: var(--pd-text);
  font-family: 'Rajdhani', system-ui, sans-serif;
  user-select: none;
}

#scene {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  display: block;
}

body.in-game #scene { cursor: none; }

.hidden { display: none !important; }

.glass {
  background: var(--pd-glass);
  border: 1px solid var(--pd-glass-border);
  border-radius: 18px;
  backdrop-filter: blur(10px);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.btn { font-family: 'Rajdhani', sans-serif; font-weight: 700; letter-spacing: 0.02em; }

/* ---------- HUD ---------- */

#hud {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 10;
}

.hud-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
}

.hud-panel {
  background: var(--pd-glass);
  border: 1px solid var(--pd-glass-border);
  border-radius: 14px;
  padding: 8px 14px;
  backdrop-filter: blur(8px);
}

.hud-left { min-width: 170px; }
.hud-label { font-size: 0.8rem; color: var(--pd-muted); letter-spacing: 0.12em; }
.hud-wave { font-family: 'Orbitron', sans-serif; font-weight: 800; font-size: 1.35rem; color: var(--pd-accent); }
.hud-sub { font-size: 0.9rem; color: var(--pd-muted); }

.hud-center { width: min(380px, 40vw); }

.bar-row { display: flex; align-items: center; gap: 8px; margin-bottom: 5px; }
.bar-icon { width: 1.4em; text-align: center; }
.bar {
  position: relative;
  flex: 1;
  height: 18px;
  background: rgba(0, 0, 0, 0.5);
  border-radius: 9px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.1);
}
.bar-fill { height: 100%; transition: width 0.2s; border-radius: 9px; }
.bar-fill.hp { background: linear-gradient(90deg, #ff4d6a, #ffb347 45%, #5dff9d); background-size: 380px 100%; }
.bar-fill.shield { background: linear-gradient(90deg, #2f8cff, #7cf9ff); box-shadow: 0 0 12px rgba(124, 249, 255, 0.7); }
.bar-text {
  position: absolute;
  inset: 0;
  text-align: center;
  font-size: 0.8rem;
  font-weight: 700;
  line-height: 18px;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 1px 2px #000;
}
.eco-row { font-size: 0.85rem; color: var(--pd-muted); text-align: center; }
.eco-row span { color: var(--pd-good); font-weight: 700; font-variant-numeric: tabular-nums; }

.hud-right { display: flex; gap: 8px; align-items: center; pointer-events: auto; }
.coin-box {
  font-family: 'Orbitron', sans-serif;
  font-weight: 800;
  font-size: 1.3rem;
  color: var(--pd-gold);
  font-variant-numeric: tabular-nums;
  min-width: 120px;
  text-align: right;
}
.coin-box.bump { animation: bump 0.25s ease-out; }
.coin-box.deny { animation: deny 0.35s ease-out; color: var(--pd-bad); }
.hud-btn { width: 44px; height: 44px; border-radius: 12px; padding: 0; font-size: 1.1rem; }

@keyframes bump { 50% { transform: scale(1.12); } }
@keyframes deny {
  20% { transform: translateX(-6px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}

#boss-bar {
  position: absolute;
  top: 110px;
  left: 50%;
  transform: translateX(-50%);
  width: min(560px, 70vw);
  text-align: center;
}
.boss-name {
  font-family: 'Orbitron', sans-serif;
  font-weight: 800;
  color: #ff5fb8;
  letter-spacing: 0.2em;
  text-shadow: 0 0 12px #ff2fa0;
  font-size: 0.9rem;
}
.boss-track {
  height: 14px;
  background: rgba(0, 0, 0, 0.6);
  border: 1px solid #ff2fa0;
  border-radius: 7px;
  overflow: hidden;
  box-shadow: 0 0 18px rgba(255, 47, 160, 0.5);
}
#boss-fill { height: 100%; background: linear-gradient(90deg, #ff2fa0, #ff8ad1); transition: width 0.15s; }

#combo {
  position: absolute;
  right: 28px;
  top: 42%;
  font-family: 'Orbitron', sans-serif;
  font-weight: 800;
  font-size: 1.1rem;
  color: var(--pd-gold);
  text-shadow: 0 0 14px rgba(255, 211, 107, 0.8);
  opacity: 0;
  transition: opacity 0.3s;
}
#combo.show { opacity: 1; }
#combo.pop { animation: pop 0.2s ease-out; }
.combo-x { font-size: 2.2rem; display: block; text-align: right; }
@keyframes pop { 50% { transform: scale(1.25) rotate(-3deg); } }

.hud-bottom {
  position: absolute;
  bottom: 14px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: flex-end;
  gap: 16px;
  pointer-events: auto;
}
.ability-group { display: flex; gap: 10px; }

.ability {
  --cd: 0;
  position: relative;
  width: 104px;
  height: 92px;
  border-radius: 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: var(--pd-glass);
  backdrop-filter: blur(8px);
  border-width: 2px;
  line-height: 1.1;
}
.ability::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: calc(var(--cd) * 100%);
  background: rgba(0, 0, 0, 0.6);
  pointer-events: none;
}
.ability.ready { box-shadow: 0 0 18px currentColor; }
.ability.active { animation: pulse 0.6s infinite alternate; }
.ab-icon { font-size: 1.6rem; }
.ab-name { font-size: 0.95rem; }
.ab-state { font-size: 0.75rem; opacity: 0.85; font-variant-numeric: tabular-nums; }
.ab-key {
  position: absolute;
  top: 5px;
  left: 8px;
  font-size: 0.7rem;
  opacity: 0.7;
  border: 1px solid currentColor;
  border-radius: 4px;
  padding: 0 4px;
}
@keyframes pulse { to { box-shadow: 0 0 28px currentColor; transform: scale(1.04); } }

/* ---------- build bar & pad labels ---------- */

#build-bar { padding: 6px 10px 10px; }
#build-bar.nudge { animation: nudge 1.2s ease-in-out infinite; }
@keyframes nudge {
  0%, 100% { box-shadow: 0 0 0 rgba(93, 255, 157, 0); }
  50% { box-shadow: 0 0 26px rgba(93, 255, 157, 0.75); border-color: var(--pd-good); }
}
.build-bar-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 5px; }
.build-bar-title {
  font-family: 'Orbitron', sans-serif;
  font-weight: 800;
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  color: var(--pd-good);
}
#build-cards { display: flex; gap: 6px; }
.build-card {
  --turret: #7cf9ff;
  width: 84px;
  height: 66px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  padding: 4px;
  border-radius: 12px;
  border-color: rgba(255, 255, 255, 0.18);
  border-bottom: 4px solid var(--turret);
  line-height: 1.05;
}
.build-card:hover:not(:disabled) { border-color: var(--turret); box-shadow: 0 0 14px var(--turret); background: rgba(255, 255, 255, 0.06); color: #fff; }
.build-card.selected {
  border-color: var(--turret);
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  box-shadow: 0 0 20px var(--turret), inset 0 0 12px var(--turret);
  animation: pulse 0.6s infinite alternate;
}
.build-card:disabled { opacity: 0.45; }
.build-card:disabled .bc-cost { color: var(--pd-bad); }
.bc-icon { font-size: 1.25rem; }
.bc-text { display: flex; flex-direction: column; align-items: center; }
.bc-name { font-size: 0.8rem; white-space: nowrap; }
.bc-cost { font-size: 0.78rem; color: var(--pd-gold); font-variant-numeric: tabular-nums; }
.build-bar-hint { font-size: 0.75rem; color: var(--pd-muted); white-space: nowrap; }

#pad-labels { position: fixed; inset: 0; pointer-events: none; z-index: 9; }
.pad-label {
  position: absolute;
  left: 0;
  top: 0;
  pointer-events: auto;
  border: 1px solid var(--pd-good);
  background: rgba(10, 40, 24, 0.8);
  color: var(--pd-good);
  font-family: 'Rajdhani', sans-serif;
  font-weight: 700;
  font-size: 0.8rem;
  letter-spacing: 0.05em;
  padding: 2px 8px;
  border-radius: 999px;
  white-space: nowrap;
  cursor: pointer;
}
.pad-label.poor { opacity: 0.45; }
.pad-label.place {
  font-size: 0.95rem;
  padding: 4px 12px;
  background: rgba(10, 40, 24, 0.92);
  box-shadow: 0 0 16px var(--pd-good);
  animation: padBounce 0.6s ease-in-out infinite alternate;
}
.pad-label.upgrade {
  border-color: var(--pd-gold);
  color: var(--pd-gold);
  background: rgba(50, 36, 6, 0.85);
  font-size: 0.72rem;
  padding: 1px 7px;
  font-variant-numeric: tabular-nums;
  animation: upgradeGlow 1.1s ease-in-out infinite alternate;
}
.pad-label.upgrade:hover { background: rgba(90, 64, 10, 0.95); color: #fff; }
@keyframes upgradeGlow {
  from { box-shadow: 0 0 0 rgba(255, 211, 107, 0); }
  to { box-shadow: 0 0 12px rgba(255, 211, 107, 0.8); }
}
.pad-label.repair { border-color: var(--pd-bad); color: #ffb3c0; background: rgba(60, 10, 20, 0.85); }
@keyframes padBounce { to { margin-top: -6px; } }
body.placing #scene { cursor: copy; }

/* ---------- crosshair, vignette, floaters ---------- */

#crosshair {
  position: fixed;
  left: 0;
  top: 0;
  pointer-events: none;
  z-index: 30;
  display: none;
}
#crosshair span {
  position: absolute;
  width: 28px;
  height: 28px;
  left: -14px;
  top: -14px;
  border: 2px solid var(--pd-accent);
  border-radius: 50%;
  box-shadow: 0 0 10px var(--pd-accent);
  transition: transform 0.08s;
}
#crosshair span::before,
#crosshair span::after {
  content: '';
  position: absolute;
  background: var(--pd-accent);
}
#crosshair span::before { left: 11px; top: -8px; width: 2px; height: 40px; }
#crosshair span::after { top: 11px; left: -8px; height: 2px; width: 40px; }
#crosshair.firing span { transform: scale(0.75) rotate(45deg); }

#vignette {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 5;
  box-shadow: inset 0 0 160px rgba(255, 30, 40, 0.9);
  opacity: 0;
}
#vignette.hit { animation: vignette 0.5s ease-out; }
@keyframes vignette { 0% { opacity: 1; } 100% { opacity: 0; } }

#fx-layer { position: fixed; inset: 0; pointer-events: none; z-index: 8; overflow: hidden; }
.floater {
  position: absolute;
  transform: translate(-50%, -50%);
  font-family: 'Orbitron', sans-serif;
  font-weight: 800;
  font-size: 0.85rem;
  color: #fff;
  text-shadow: 0 0 6px rgba(0, 0, 0, 0.9);
  animation: floatUp 0.95s ease-out forwards;
  white-space: nowrap;
}
.floater.coin { color: var(--pd-gold); font-size: 1rem; }
.floater.crit { color: #ffe14d; font-size: 1.3rem; text-shadow: 0 0 10px #ff8a00; }
.floater.dmg { color: #d8e6ff; opacity: 0.9; }
@keyframes floatUp {
  0% { transform: translate(-50%, -50%) scale(0.6); opacity: 0; }
  15% { transform: translate(-50%, -80%) scale(1.15); opacity: 1; }
  100% { transform: translate(-50%, -260%) scale(1); opacity: 0; }
}

/* ---------- banner & toast ---------- */

.banner {
  position: fixed;
  top: 30%;
  left: 0;
  right: 0;
  text-align: center;
  pointer-events: none;
  z-index: 20;
  opacity: 0;
}
.banner.show { animation: banner 2.8s ease-out forwards; }
#banner-title {
  font-family: 'Orbitron', sans-serif;
  font-weight: 800;
  font-size: clamp(2.2rem, 6vw, 4.5rem);
  color: #fff;
  letter-spacing: 0.08em;
  text-shadow: 0 0 24px var(--pd-accent), 0 0 4px #000;
}
#banner-sub { font-size: 1.3rem; color: var(--pd-accent); font-weight: 600; text-shadow: 0 0 6px #000; }
.banner.boss #banner-title { text-shadow: 0 0 30px #ff2fa0, 0 0 4px #000; }
.banner.boss #banner-sub { color: #ff6fc0; }
.banner.good #banner-title { text-shadow: 0 0 24px var(--pd-good), 0 0 4px #000; }
.banner.good #banner-sub { color: var(--pd-good); }
@keyframes banner {
  0% { opacity: 0; transform: scale(1.6); }
  12% { opacity: 1; transform: scale(1); }
  80% { opacity: 1; transform: scale(1); }
  100% { opacity: 0; transform: scale(0.95) translateY(-20px); }
}

#toast {
  position: fixed;
  bottom: 150px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(120, 20, 30, 0.85);
  border: 1px solid var(--pd-bad);
  border-radius: 12px;
  padding: 8px 18px;
  font-weight: 700;
  z-index: 20;
  pointer-events: none;
  opacity: 0;
}
#toast.show { animation: toast 3s ease-out forwards; }
@keyframes toast { 0%, 85% { opacity: 1; } 100% { opacity: 0; } }

/* ---------- slot popup ---------- */

#slot-popup {
  position: fixed;
  z-index: 25;
  width: 330px;
  padding: 14px;
}
.popup-close { position: absolute; top: 12px; right: 12px; }
.popup-title { font-family: 'Orbitron', sans-serif; font-weight: 800; font-size: 1rem; margin-bottom: 10px; padding-right: 28px; }
.popup-note { color: var(--pd-muted); font-size: 0.95rem; }
.build-grid { display: grid; gap: 8px; }
.build-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: left;
  padding: 8px 10px;
  border-radius: 12px;
  border-color: rgba(255, 255, 255, 0.2);
}
.build-icon { font-size: 1.6rem; }
.build-text { flex: 1; display: flex; flex-direction: column; line-height: 1.15; }
.build-name { font-size: 1rem; }
.build-desc { font-size: 0.78rem; font-weight: 500; opacity: 0.7; }
.build-cost { color: var(--pd-gold); white-space: nowrap; font-variant-numeric: tabular-nums; }
.build-btn:disabled .build-cost { color: var(--pd-bad); }
.cost { font-variant-numeric: tabular-nums; margin-left: 4px; }

.turret-hp { height: 6px; background: rgba(0, 0, 0, 0.5); border-radius: 3px; overflow: hidden; margin-bottom: 8px; }
.turret-hp div { height: 100%; background: var(--pd-good); transition: width 0.2s; }

.stats-table { --bs-table-bg: transparent; font-size: 0.95rem; }
.stats-table td { padding: 3px 0; }
.stats-table td:first-child { padding-left: 1rem; text-align: left; color: var(--pd-muted); }
.stats-table td:last-child { padding-right: 1rem; }
.stats-table .num { text-align: right; padding-right: 0.75rem; font-variant-numeric: tabular-nums; font-weight: 700; }
.stats-table .num.next { color: var(--pd-good); }

/* ---------- shop ---------- */

#shop {
  position: fixed;
  top: 120px;
  right: 16px;
  bottom: 128px;
  width: 360px;
  z-index: 15;
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow: hidden;
}
.shop-head { padding: 14px 16px 6px; }
.shop-kicker { font-size: 0.75rem; letter-spacing: 0.2em; color: var(--pd-accent); text-transform: uppercase; }
.shop-head h2 { font-family: 'Orbitron', sans-serif; font-weight: 800; font-size: 1.15rem; margin: 2px 0 4px; }
.shop-tip { font-size: 0.9rem; color: var(--pd-muted); margin: 0; }
#shop-body { flex: 1; overflow-y: auto; padding: 4px 16px; }
.shop-group { margin-bottom: 10px; }
.shop-group-title {
  font-size: 0.75rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--pd-muted);
  margin: 6px 0 4px;
}
.upgrade-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  margin-bottom: 6px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.07);
}
.up-icon { font-size: 1.5rem; width: 1.8em; text-align: center; }
.up-info { flex: 1; min-width: 0; }
.up-name { font-weight: 700; line-height: 1.1; }
.up-desc { font-size: 0.8rem; color: var(--pd-muted); line-height: 1.15; }
.up-pips { display: flex; gap: 3px; margin-top: 4px; }
.up-pips i { width: 10px; height: 4px; border-radius: 2px; background: rgba(255, 255, 255, 0.15); }
.up-pips i.on { background: var(--pd-gold); box-shadow: 0 0 6px var(--pd-gold); }
.up-buy { min-width: 84px; font-variant-numeric: tabular-nums; }
.shop-foot { padding: 12px 16px 16px; border-top: 1px solid rgba(255, 255, 255, 0.08); }
.launch { font-family: 'Orbitron', sans-serif; font-weight: 800; animation: launchGlow 1.4s infinite alternate; }
.launch small { font-family: 'Rajdhani', sans-serif; font-size: 0.75rem; opacity: 0.8; }
@keyframes launchGlow { to { box-shadow: 0 0 24px rgba(93, 255, 157, 0.7); } }

/* ---------- screens ---------- */

.screen {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: radial-gradient(ellipse at center, rgba(4, 3, 11, 0.2), rgba(4, 3, 11, 0.75));
}
.screen-card { width: min(460px, 100%); padding: 28px 26px; }
.title-kicker { font-size: 0.85rem; letter-spacing: 0.25em; text-transform: uppercase; color: var(--pd-accent); }
.game-title {
  font-family: 'Orbitron', sans-serif;
  font-weight: 800;
  font-size: clamp(2.4rem, 8vw, 3.6rem);
  line-height: 1;
  margin: 10px 0 18px;
  background: linear-gradient(180deg, #ffffff, #7cf9ff 60%, #3a8bff);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 0 18px rgba(124, 249, 255, 0.45));
}
.screen-title { font-family: 'Orbitron', sans-serif; font-weight: 800; margin: 6px 0 14px; }
.how-to { list-style: none; padding: 0; margin: 0 0 22px; text-align: left; color: var(--pd-muted); }
.how-to li { padding: 4px 0 4px 22px; position: relative; }
.how-to li::before { content: '▸'; position: absolute; left: 4px; color: var(--pd-accent); }
.how-to b { color: var(--pd-text); }
.play-btn { font-family: 'Orbitron', sans-serif; font-weight: 800; border-radius: 14px; }
.menu-best { margin-top: 14px; color: var(--pd-gold); font-size: 0.95rem; }
.stars { font-size: 2.6rem; margin-bottom: 10px; }
.star { color: rgba(255, 255, 255, 0.15); margin: 0 4px; }
.star.on { color: var(--pd-gold); text-shadow: 0 0 16px var(--pd-gold); }

.glass-modal { background: rgba(14, 18, 38, 0.95); border: 1px solid var(--pd-glass-border); border-radius: 16px; }

@media (max-width: 900px) {
  .hud-top { flex-wrap: wrap; }
  .hud-center { order: 3; width: 100%; }
  #shop { top: auto; height: 45vh; left: 16px; right: 16px; width: auto; }
  .build-card { width: 64px; }
  .bc-name, .build-bar-hint { display: none; }
  .ability { width: 86px; height: 80px; }
}
