* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { width: 100%; height: 100%; overflow: hidden; font-family: Inter, Segoe UI, system-ui, sans-serif; color: #e8f3ff; }
body {
  background: radial-gradient(circle at 20% 20%, #1d1147, #070b1d 45%, #03040a);
}
#bg-orb {
  position: fixed; inset: -20%; z-index: -1;
  background: conic-gradient(from 0deg, #1f9fff44, #ff2ea644, #00f7ff33, #1f9fff44);
  filter: blur(80px);
  animation: spin 18s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

#layout { display: flex; width: 100vw; height: 100vh; padding-top: 70px; }
#board-wrap { flex: 1; padding: 10px; }
#phaser-game {
  width: 100%; height: calc(100vh - 90px); border: 1px solid #2f4e88;
  border-radius: 14px; overflow: hidden;
  box-shadow: 0 0 30px #00c2ff2f, inset 0 0 30px #8927ff24;
  background: #020617;
}

#hud {
  position: fixed; top: 0; left: 0; right: 0; height: 70px; z-index: 20;
  display: flex; align-items: center; gap: 10px; padding: 10px;
  border-bottom: 1px solid #345694;
  background: linear-gradient(180deg, #080f2bea, #040915cc);
  backdrop-filter: blur(8px);
}
.badge {
  padding: 8px 12px; border: 1px solid #2b4f8d; border-radius: 12px;
  background: #091228d6; box-shadow: 0 0 14px #1846a136;
  display: flex; align-items: center; gap: 8px; min-height: 44px;
}
.badge.combo { border-color: #ff8f2f; box-shadow: 0 0 14px #ff8f2f33; }
.badge b { font-size: 16px; }
#hud-controls { margin-left: auto; display: flex; gap: 8px; }
#hud-controls button {
  border: 1px solid #3f65ad; background: #0e1a36; color: #b9dbff;
  padding: 8px 10px; border-radius: 10px; font-weight: 700; cursor: pointer;
}
#hud-controls button.active { border-color: #29ffe1; color: #29ffe1; box-shadow: 0 0 10px #29ffe166; }

#side-panel {
  width: 360px; height: calc(100vh - 70px); overflow-y: auto;
  border-left: 1px solid #29497f; padding: 10px; display: flex; flex-direction: column; gap: 10px;
  background: linear-gradient(180deg, #060b1de8, #040915ee);
}
.panel {
  border: 1px solid #294b82; border-radius: 12px; padding: 10px;
  background: #08132ac7; box-shadow: inset 0 0 15px #2264c01f;
}
.panel h3 { color: #7ce8ff; margin-bottom: 8px; font-size: 14px; letter-spacing: .4px; }

#shop-list, #event-log { max-height: 220px; overflow-y: auto; }
#hardware-list, #power-list { display: grid; gap: 8px; }

.tower-card, .buy-item {
  border: 1px solid #335e9f; border-radius: 10px; padding: 8px; margin-bottom: 8px;
  background: #0a1633; cursor: pointer; transition: .15s;
}
.tower-card:hover, .buy-item:hover { transform: translateY(-1px); border-color: #5ac6ff; }
.tower-card.selected { border-color: #00ffd0; box-shadow: 0 0 14px #00ffd044; }
.tower-card.too-expensive { opacity: .45; }
.tc-head { display: flex; justify-content: space-between; gap: 4px; }
.tc-name { font-weight: 700; font-size: 13px; }
.tc-cost { color: #61ffad; font-weight: 700; }
.badges { margin-top: 4px; display: flex; flex-wrap: wrap; gap: 4px; }
.pill { padding: 1px 6px; border-radius: 999px; font-size: 10px; border: 1px solid #355a92; color: #b9d9ff; }

.weather-box {
  border: 1px solid #3a62a2; padding: 8px; border-radius: 10px; margin-bottom: 8px;
  color: #d9f1ff; background: #0b1d39;
}
#start-wave-btn {
  width: 100%; border: none; cursor: pointer; padding: 11px; border-radius: 10px; font-weight: 800;
  background: linear-gradient(135deg, #00ffc6, #35b5ff); color: #00111f;
}
#start-wave-btn:disabled { background: #253244; color: #6f8aa8; cursor: not-allowed; }

#event-log { display: flex; flex-direction: column; gap: 6px; }
.event-line {
  font-size: 12px; border-left: 3px solid #375d9d; background: #091a35; padding: 6px; border-radius: 6px;
}
.event-line.bad { border-left-color: #ff5787; }
.event-line.good { border-left-color: #38ffb3; }
.event-line.warn { border-left-color: #ffc44d; }

#tower-info {
  display: none; position: absolute; z-index: 40; width: 250px; padding: 10px;
  border-radius: 10px; border: 1px solid #43deff; background: #08142cd9;
  box-shadow: 0 8px 25px #0008;
}
#tower-info.visible { display: block; }
#tower-info button { border: none; border-radius: 8px; padding: 6px; margin-top: 6px; cursor: pointer; width: 100%; }

.overlay {
  position: fixed; inset: 0; z-index: 100; background: #01040ddd;
  display: flex; align-items: center; justify-content: center;
}
.overlay-card {
  max-width: 520px; border: 1px solid #3c67a9; border-radius: 14px; padding: 20px;
  background: #07142fe8; box-shadow: 0 0 40px #2f6ddd40;
}
.overlay-card h1, .overlay-card h2 { margin-bottom: 10px; }
.overlay-card ul { margin-left: 18px; line-height: 1.7; }
.overlay-card button {
  margin-top: 12px; border: none; border-radius: 10px; padding: 10px 14px; cursor: pointer;
  background: linear-gradient(135deg, #00ffd0, #4ea6ff); font-weight: 800;
}
.hidden { display: none !important; }

.loading-spinner {
  width: 44px; height: 44px; border-radius: 50%; border: 3px solid #385893; border-top-color: #00ffd0;
  animation: spin .8s linear infinite; margin-bottom: 12px;
}

@media (max-width: 920px) {
  #layout { flex-direction: column; }
  #side-panel { width: 100%; height: 52vh; border-left: none; border-top: 1px solid #29497f; }
  #board-wrap { padding: 8px; }
  #phaser-game { height: calc(48vh - 70px); }
  #hud { overflow-x: auto; }
}