/* Hexa Defense: Cyber Neon Matrix HUD & Glassmorphism UI */
:root {
  --bg-dark: #060814;
  --cyan-neon: #00f5ff;
  --cyan-glow: rgba(0, 245, 255, 0.45);
  --magenta-neon: #ff007f;
  --magenta-glow: rgba(255, 0, 127, 0.45);
  --gold-neon: #ffd166;
  --gold-glow: rgba(255, 209, 102, 0.45);
  --green-neon: #06d6a0;
  --purple-neon: #9d4edd;
  --hud-bg: rgba(9, 14, 30, 0.85);
  --card-bg: rgba(14, 20, 44, 0.92);
  --font-cyber: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'SF Mono', Consolas, Monaco, monospace;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--bg-dark);
  color: #e0f2fe;
  font-family: var(--font-cyber);
  touch-action: none;
  overscroll-behavior: none;
}

#game-container {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: radial-gradient(circle at center, #0e1633 0%, #060814 85%);
}

canvas#game-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: block;
}

/* TOP STATUS HUD */
#top-hud {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  padding: 12px 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
  z-index: 10;
}

.core-bar-container {
  width: 100%;
  max-width: 580px;
  margin: 0 auto;
  background: rgba(0, 0, 0, 0.65);
  border-radius: 8px;
  padding: 7px 12px;
  border: 1px solid rgba(0, 245, 255, 0.3);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.core-info-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 5px;
  font-family: var(--font-mono);
}

.core-name {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: var(--cyan-neon);
  display: flex;
  align-items: center;
  gap: 6px;
}

.core-hp-val {
  font-size: 12px;
  color: #fff;
}

.hp-track {
  width: 100%;
  height: 8px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 4px;
  overflow: hidden;
  position: relative;
}

.hp-fill {
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, #00f5ff, #06d6a0);
  box-shadow: 0 0 10px var(--cyan-glow);
  transition: width 0.2s cubic-bezier(0.1, 0.9, 0.2, 1);
}

.hud-chips-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  max-width: 580px;
  margin: 0 auto;
  font-family: var(--font-mono);
}

.hud-chip {
  background: var(--hud-bg);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  padding: 5px 12px;
  border-radius: 16px;
  border: 1px solid rgba(0, 245, 255, 0.25);
  font-size: 13px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
}

.hud-chip.energy {
  color: var(--gold-neon);
  border-color: var(--gold-glow);
}

.hud-chip.wave {
  color: var(--magenta-neon);
  border-color: var(--magenta-glow);
}

.btn-next-wave {
  pointer-events: auto;
  background: linear-gradient(135deg, #ff007f, #9d4edd);
  border: 1px solid #fff;
  border-radius: 16px;
  color: #fff;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  padding: 6px 14px;
  cursor: pointer;
  box-shadow: 0 0 12px var(--magenta-glow);
  transition: transform 0.1s, box-shadow 0.1s;
}

.btn-next-wave:active {
  transform: scale(0.94);
}

.btn-next-wave.disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

/* TOP RIGHT QUICK BUTTONS */
.hud-btn-group {
  position: absolute;
  top: 12px;
  right: 18px;
  display: flex;
  gap: 8px;
  z-index: 12;
  pointer-events: auto;
}

.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--hud-bg);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #94a3b8;
  font-size: 15px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(6px);
  transition: all 0.2s;
}

.icon-btn:hover, .icon-btn:active {
  color: var(--cyan-neon);
  border-color: var(--cyan-neon);
  box-shadow: 0 0 12px var(--cyan-glow);
}

/* BOTTOM HUD & EMP BUTTON */
#bottom-hud {
  position: absolute;
  bottom: 20px;
  right: 20px;
  z-index: 15;
}

.emp-btn {
  width: 68px;
  height: 68px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, rgba(0, 245, 255, 0.35), rgba(10, 20, 50, 0.95));
  border: 2px solid var(--cyan-neon);
  color: #fff;
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 1px;
  box-shadow: 0 0 16px var(--cyan-glow);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  transition: transform 0.1s, box-shadow 0.1s;
  pointer-events: auto;
}

.emp-btn:active {
  transform: scale(0.92);
  box-shadow: 0 0 25px var(--cyan-neon);
}

.emp-btn.cooldown {
  opacity: 0.45;
  border-color: #64748b;
  box-shadow: none;
  cursor: not-allowed;
}

.emp-subtext {
  font-size: 9px;
  color: var(--cyan-neon);
  opacity: 0.8;
}

/* CONTEXTUAL BUILD / UPGRADE POPUP */
#context-popup {
  position: absolute;
  z-index: 25;
  background: var(--card-bg);
  border: 1.5px solid rgba(0, 245, 255, 0.4);
  border-radius: 14px;
  padding: 10px;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.8), 0 0 20px var(--cyan-glow);
  display: none;
  transform: translate(-50%, -100%);
  margin-top: -14px;
  pointer-events: auto;
  min-width: 220px;
}

.popup-title {
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  margin-bottom: 8px;
  text-align: center;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  padding-bottom: 4px;
}

.popup-options {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.popup-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(0, 245, 255, 0.25);
  border-radius: 8px;
  padding: 8px 10px;
  color: #fff;
  font-family: var(--font-mono);
  font-size: 11px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: all 0.15s;
}

.popup-btn:hover, .popup-btn:active {
  background: rgba(0, 245, 255, 0.18);
  border-color: var(--cyan-neon);
  transform: translateY(-1px);
}

.popup-btn.disabled {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
  border-color: rgba(255, 255, 255, 0.1);
}

.popup-cost {
  color: var(--gold-neon);
  font-weight: 700;
}

/* MODAL OVERLAYS */
.modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(4, 7, 18, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 50;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease-out;
  padding: 16px;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-content {
  background: var(--card-bg);
  border: 1.5px solid rgba(0, 245, 255, 0.35);
  border-radius: 22px;
  padding: 30px 24px;
  max-width: 480px;
  width: 100%;
  text-align: center;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.7), 0 0 30px rgba(0, 245, 255, 0.15);
  animation: modalScale 0.3s cubic-bezier(0.18, 0.89, 0.32, 1.2);
}

@keyframes modalScale {
  0% { transform: scale(0.9) translateY(20px); opacity: 0; }
  100% { transform: scale(1) translateY(0); opacity: 1; }
}

.modal-title {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: 1px;
  margin-bottom: 8px;
  background: linear-gradient(120deg, #fff, var(--cyan-neon), var(--magenta-neon));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.modal-subtitle {
  font-size: 13px;
  color: #94a3b8;
  margin-bottom: 22px;
  line-height: 1.5;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin: 18px 0;
  font-family: var(--font-mono);
}

.stat-box {
  background: rgba(255, 255, 255, 0.04);
  padding: 10px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.stat-label {
  font-size: 11px;
  color: #64748b;
  margin-bottom: 4px;
}

.stat-val {
  font-size: 15px;
  font-weight: 700;
  color: var(--cyan-neon);
}

.btn-primary {
  width: 100%;
  padding: 14px;
  background: linear-gradient(135deg, #00f5ff, #0077ff);
  border: none;
  border-radius: 12px;
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 1px;
  cursor: pointer;
  box-shadow: 0 4px 18px rgba(0, 245, 255, 0.4);
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn-primary:hover, .btn-primary:active {
  transform: translateY(-2px);
  box-shadow: 0 6px 24px rgba(0, 245, 255, 0.6);
}

.controls-hint {
  font-size: 11px;
  color: #64748b;
  margin-top: 14px;
  line-height: 1.6;
}

@media (max-width: 600px) {
  .modal-content {
    padding: 24px 18px;
  }
  .modal-title {
    font-size: 24px;
  }
}
