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

body {
  background: #0a0a14;
  color: #e0e0e0;
  font-family: 'Segoe UI', system-ui, sans-serif;
  overflow: hidden;
  width: 100vw;
  height: 100vh;
}

/* ── Screens ───────────────────────────────────────── */
.screen {
  position: fixed; inset: 0;
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 10;
}
.screen.active { display: flex; }

/* ── Main Menu ─────────────────────────────────────── */
.menu-bg {
  position: absolute; inset: 0;
  background: radial-gradient(ellipse at 50% 40%, #1a1a3a 0%, #0a0a14 70%);
}
.menu-content {
  position: relative;
  text-align: center;
  z-index: 2;
}
.game-title {
  font-size: 4.5rem;
  font-weight: 900;
  letter-spacing: 0.15em;
  color: #fff;
  text-shadow: 0 0 40px rgba(0,180,255,0.4), 0 0 80px rgba(0,100,255,0.2);
  line-height: 1.1;
  margin-bottom: 0.5rem;
}
.game-title span {
  font-size: 2.2rem;
  font-weight: 400;
  letter-spacing: 0.35em;
  color: #00b4ff;
}
.tagline {
  color: #888;
  font-size: 1.1rem;
  margin-bottom: 2.5rem;
}
.menu-buttons {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  align-items: center;
}
.menu-btn {
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.12);
  color: #ccc;
  font-size: 1.1rem;
  padding: 0.9rem 2.5rem;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
  min-width: 240px;
  font-weight: 600;
}
.menu-btn:hover {
  background: rgba(255,255,255,0.12);
  color: #fff;
  border-color: rgba(255,255,255,0.25);
  transform: translateY(-1px);
}
.menu-btn.primary {
  background: linear-gradient(135deg, #00b4ff, #0066cc);
  border-color: #00b4ff;
  color: #fff;
}
.menu-btn.primary:hover {
  background: linear-gradient(135deg, #33c4ff, #0077ee);
  box-shadow: 0 0 20px rgba(0,180,255,0.3);
}
.menu-btn.small {
  font-size: 0.9rem;
  padding: 0.5rem 1.5rem;
  min-width: auto;
  margin-top: 1rem;
}
.menu-footer {
  margin-top: 2.5rem;
  color: #555;
  font-size: 0.85rem;
  letter-spacing: 0.1em;
}

/* ── Lobby ─────────────────────────────────────────── */
.lobby-panel {
  background: rgba(15,15,30,0.95);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 16px;
  padding: 2.5rem;
  text-align: center;
  min-width: 380px;
}
.lobby-panel h2 {
  margin-bottom: 1.5rem;
  color: #00b4ff;
}
.lobby-options {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  align-items: center;
}
.divider {
  color: #555;
  font-size: 0.85rem;
  padding: 0.3rem 0;
}
.join-row {
  display: flex;
  gap: 0.5rem;
}
.join-row input {
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.15);
  color: #fff;
  padding: 0.7rem 1rem;
  border-radius: 8px;
  font-size: 1.1rem;
  width: 140px;
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 0.15em;
}
.join-row input::placeholder { color: #555; text-transform: none; letter-spacing: normal; }
.lobby-info { margin-top: 1.5rem; }
.lobby-info p { margin-bottom: 0.5rem; color: #aaa; }
.lobby-info strong { color: #00b4ff; }
.player-list {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  margin: 1rem 0;
  padding: 0.8rem;
  background: rgba(0,0,0,0.3);
  border-radius: 8px;
}
.player-list .player-item {
  color: #ccc;
  font-size: 0.9rem;
  padding: 0.3rem 0.5rem;
}
.hidden { display: none !important; }

/* ── Game HUD ──────────────────────────────────────── */
.hud {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 44px;
  background: rgba(8,8,20,0.92);
  border-bottom: 1px solid rgba(255,255,255,0.08);
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 24px;
  z-index: 20;
  font-size: 0.9rem;
}
.hud-item {
  display: flex;
  align-items: center;
  gap: 6px;
  color: #aaa;
}
.hud-item strong { color: #fff; font-size: 1rem; }
.hud-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px; height: 22px;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 800;
  background: rgba(255,255,255,0.1);
  color: #aaa;
}
.hud-icon.gold { background: rgba(255,200,0,0.2); color: #ffd700; }
.hud-icon.red { background: rgba(255,60,60,0.2); color: #ff4444; }
.hud-icon.blue { background: rgba(60,120,255,0.2); color: #4488ff; }
.hud-right {
  margin-left: auto;
  display: flex;
  gap: 8px;
}
.hud-btn {
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.1);
  color: #aaa;
  padding: 4px 12px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 700;
  transition: all 0.15s;
}
.hud-btn:hover { background: rgba(255,255,255,0.15); color: #fff; }
.hud-btn.active { background: rgba(0,180,255,0.25); border-color: #00b4ff; color: #00b4ff; }

/* ── Ally Info ─────────────────────────────────────── */
.hud-allies {
  display: flex;
  gap: 16px;
}
.hud-allies .ally-item {
  display: flex;
  align-items: center;
  gap: 5px;
  color: #aaa;
  font-size: 0.8rem;
}
.hud-allies .ally-name { color: #00b4ff; font-weight: 600; }
.hud-allies .ally-gold { color: #ffd700; font-weight: 700; }

/* ── Canvas ────────────────────────────────────────── */
#gameCanvas {
  position: fixed;
  top: 44px;
  left: 0;
  width: calc(100vw - 190px);
  height: calc(100vh - 44px);
  background: #111;
}

/* ── Tower Panel ───────────────────────────────────── */
.tower-panel {
  position: fixed;
  top: 44px;
  right: 0;
  width: 190px;
  height: calc(100vh - 44px);
  background: rgba(8,8,20,0.94);
  border-left: 1px solid rgba(255,255,255,0.08);
  padding: 12px 10px;
  overflow-y: auto;
  z-index: 20;
}
.tower-panel h3 {
  font-size: 0.7rem;
  letter-spacing: 0.15em;
  color: #666;
  margin-bottom: 8px;
}
.tower-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.panel-divider {
  height: 1px;
  background: rgba(255,255,255,0.06);
  margin: 12px 0;
}
.tower-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s;
  width: 100%;
  text-align: left;
}
.tower-btn:hover {
  background: rgba(255,255,255,0.1);
  border-color: rgba(255,255,255,0.2);
}
.tower-btn.selected {
  border-color: #00b4ff;
  background: rgba(0,180,255,0.1);
  box-shadow: 0 0 10px rgba(0,180,255,0.15);
}
.tower-btn.disabled {
  opacity: 0.35;
  cursor: not-allowed;
}
.tower-btn .t-icon {
  width: 28px; height: 28px;
  border-radius: 5px;
  flex-shrink: 0;
}
.tower-btn .t-info {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.tower-btn .t-name {
  font-size: 0.75rem;
  font-weight: 700;
  color: #ddd;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tower-btn .t-cost {
  font-size: 0.65rem;
  color: #ffd700;
}
.tower-btn .t-desc {
  font-size: 0.58rem;
  color: #888;
  white-space: normal;
  line-height: 1.3;
  margin-top: 2px;
}
.tower-btn .t-stats {
  font-size: 0.55rem;
  color: #6ab;
  white-space: normal;
  line-height: 1.3;
  margin-top: 1px;
  font-weight: 600;
}
.ascended-list .tower-btn {
  border-color: rgba(255,180,0,0.2);
}
.ascended-list .tower-btn.selected {
  border-color: #ffd700;
  background: rgba(255,200,0,0.1);
  box-shadow: 0 0 10px rgba(255,200,0,0.15);
}
.ascended-list .tower-btn.locked {
  opacity: 0.3;
  cursor: not-allowed;
  position: relative;
}
.ascended-list .tower-btn.locked::after {
  content: 'LIMIT 1';
  position: absolute;
  top: 2px; right: 4px;
  font-size: 0.5rem;
  color: #ff4444;
  font-weight: 800;
}

/* ── Tower Info ────────────────────────────────────── */
.tower-info {
  position: fixed;
  bottom: 0; left: 0;
  right: 190px;
  height: 70px;
  background: rgba(8,8,20,0.94);
  border-top: 1px solid rgba(255,255,255,0.08);
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 24px;
  z-index: 20;
}
.info-header {
  display: flex;
  align-items: center;
  gap: 10px;
}
.info-icon {
  width: 36px; height: 36px;
  border-radius: 6px;
}
.info-header h4 { font-size: 0.95rem; color: #fff; }
.info-level { font-size: 0.7rem; color: #00b4ff; }
.info-stats {
  display: flex;
  gap: 20px;
  color: #999;
  font-size: 0.85rem;
}
.info-stats strong { color: #fff; }
.info-actions {
  margin-left: auto;
  display: flex;
  gap: 8px;
}
.info-btn {
  padding: 6px 16px;
  border-radius: 5px;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.15s;
}
.info-btn.upgrade {
  background: rgba(0,200,100,0.15);
  border-color: rgba(0,200,100,0.3);
  color: #44ff88;
}
.info-btn.upgrade:hover { background: rgba(0,200,100,0.25); }
.info-btn.upgrade:disabled { opacity: 0.3; cursor: not-allowed; }
.info-btn.sell {
  background: rgba(255,60,60,0.12);
  border-color: rgba(255,60,60,0.25);
  color: #ff6666;
}
.info-btn.sell:hover { background: rgba(255,60,60,0.22); }

/* ── Upgrade Preview ──────────────────────────────── */
.upgrade-preview {
  font-size: 0.75rem;
  color: #44ff88;
  font-style: italic;
  max-width: 200px;
  line-height: 1.3;
}
.stat-arrow { color: #888; margin: 0 2px; }
.stat-up { color: #44ff88; font-weight: 700; }

/* ── Wave Banner ───────────────────────────────────── */
.wave-banner {
  position: fixed;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  font-size: 2.5rem;
  font-weight: 900;
  color: #fff;
  text-shadow: 0 0 30px rgba(0,180,255,0.5);
  letter-spacing: 0.1em;
  z-index: 30;
  pointer-events: none;
  animation: bannerPop 0.4s ease-out;
}
@keyframes bannerPop {
  0% { transform: translate(-50%, -50%) scale(0.5); opacity: 0; }
  100% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}

/* ── Next Wave Button ──────────────────────────────── */
.next-wave-btn {
  position: fixed;
  bottom: 90px;
  left: 50%;
  transform: translateX(-50%);
  background: linear-gradient(135deg, #00b4ff, #0066cc);
  border: none;
  color: #fff;
  padding: 10px 28px;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  z-index: 25;
  transition: all 0.2s;
  animation: pulse-glow 2s infinite;
}
.next-wave-btn:hover {
  transform: translateX(-50%) scale(1.05);
  box-shadow: 0 0 25px rgba(0,180,255,0.4);
}
@keyframes pulse-glow {
  0%, 100% { box-shadow: 0 0 10px rgba(0,180,255,0.2); }
  50% { box-shadow: 0 0 20px rgba(0,180,255,0.4); }
}

/* ── Game Over ─────────────────────────────────────── */
.gameover-panel {
  background: rgba(15,15,30,0.96);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 16px;
  padding: 3rem;
  text-align: center;
  min-width: 340px;
}
.gameover-panel h2 {
  font-size: 2.5rem;
  font-weight: 900;
  margin-bottom: 1.5rem;
  color: #ff4444;
}
.gameover-panel h2.victory { color: #ffd700; }
.gameover-stats {
  margin-bottom: 2rem;
  font-size: 1.1rem;
  line-height: 2;
  color: #aaa;
}
.gameover-stats strong { color: #fff; }
