/* Basic reset */
body {
  margin: 0;
  padding: 0;
  overflow: hidden;
  background-color: #000;
  color: #fff;
  font-family: "Arial", sans-serif;
}

#canvas-container {
  width: 100vw;
  height: 100vh;
  display: block;
}

/* ===== CROSSHAIR ===== */
#crosshair {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 0;
  height: 0;
  z-index: 10;
  pointer-events: none;
  --gap: 6px;
  display: none;
}

.ch-line {
  position: absolute;
  background-color: rgba(255,255,255,0.9);
  box-shadow: 0 0 3px rgba(0,0,0,0.8);
  transition: transform 0.06s ease, background-color 0.1s;
}

.ch-line.top    { width: 2px; height: 8px; left: -1px; bottom: var(--gap); }
.ch-line.bottom { width: 2px; height: 8px; left: -1px; top: var(--gap); }
.ch-line.left   { width: 8px; height: 2px; top: -1px;  right: var(--gap); }
.ch-line.right  { width: 8px; height: 2px; top: -1px;  left: var(--gap); }

#crosshair.hit .ch-line {
  background-color: #ff3333;
  box-shadow: 0 0 6px #ff3333, 0 0 12px #ff0000;
}

#crosshair.glow .ch-line {
  background-color: #fff;
  box-shadow: 0 0 4px #fff, 0 0 10px #fff, 0 0 18px #a24cff;
}

/* ===== VIGNETTE (always on, subtle) ===== */
#vignette {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 3;
  background: radial-gradient(ellipse at center, transparent 55%, rgba(0,0,0,0.6) 100%);
}

/* ===== DAMAGE FLASH ===== */
#damage-flash {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 4;
  background: radial-gradient(ellipse at center, transparent 35%, rgba(180,0,0,0.55) 100%);
  opacity: 0;
  transition: opacity 0.5s ease-out;
}
#damage-flash.active {
  opacity: 1;
  transition: none;
}

/* ===== TOP HUD: wave / enemy / points pills ===== */
#ui-top {
  position: fixed;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 12px;
  pointer-events: none;
  z-index: 5;
}

.hud-pill {
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 20px;
  padding: 5px 16px;
  font-size: 0.85rem;
  font-weight: bold;
  color: #eee;
  text-shadow: 1px 1px 3px #000;
  white-space: nowrap;
}

/* ===== BOTTOM HUD ===== */
#ui-overlay {
  position: fixed;
  bottom: 90px;
  left: 20px;
  right: 20px;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  pointer-events: none;
  z-index: 5;
}

#ui-left, #ui-right {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

#ui-right { align-items: flex-end; }

.hud-label {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: rgba(255,255,255,0.5);
  text-shadow: 1px 1px 2px #000;
}

/* Health bar */
#health-bar-container {
  width: 180px;
  height: 9px;
  background: rgba(255,255,255,0.08);
  border-radius: 5px;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,0.15);
}
#health-bar-fill {
  height: 100%;
  width: 100%;
  background: #4caf50;
  border-radius: 5px;
  transition: width 0.18s ease, background-color 0.28s ease;
}
#health-bar-fill.low {
  animation: pulse-low 0.7s ease-in-out infinite;
}
@keyframes pulse-low {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.45; }
}
#health-text {
  font-size: 0.75rem;
  color: rgba(255,255,255,0.6);
  text-shadow: 1px 1px 2px #000;
}

/* Ammo pips */
#ammo-pips {
  display: flex;
  gap: 3px;
  flex-wrap: wrap;
  max-width: 200px;
  justify-content: flex-end;
}
.ammo-pip {
  width: 5px;
  height: 12px;
  border-radius: 2px;
  background: rgba(255,210,40,0.9);
  box-shadow: 0 0 5px rgba(255,210,40,0.4);
}
.ammo-pip.empty {
  background: rgba(255,255,255,0.12);
  box-shadow: none;
}
#ammo-count {
  font-size: 1.05rem;
  font-weight: bold;
  color: #ffd700;
  text-shadow: 0 0 10px rgba(255,215,0,0.45), 1px 1px 3px #000;
  text-align: right;
}

/* Reload bar */
#reload-bar-container {
  width: 130px;
  height: 3px;
  background: rgba(255,255,255,0.12);
  border-radius: 2px;
  overflow: hidden;
  display: none;
}
#reload-bar-fill {
  height: 100%;
  width: 0%;
  background: #3a86ff;
  border-radius: 2px;
}

/* ===== WEAPON HOTBAR ===== */
#weapon-hotbar {
  position: fixed;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 8px;
  pointer-events: none;
  z-index: 5;
}
.weapon-slot {
  width: 60px;
  height: 58px;
  border: 2px solid rgba(255,255,255,0.18);
  border-radius: 8px;
  background: rgba(0,0,0,0.45);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  transition: border-color 0.14s, background 0.14s, box-shadow 0.14s;
}
.weapon-slot.active {
  border-color: #a24cff;
  background: rgba(162,76,255,0.18);
  box-shadow: 0 0 14px rgba(162,76,255,0.45);
}
.weapon-slot.empty {
  opacity: 0.3;
}
.weapon-slot-icon { font-size: 1.3rem; line-height: 1; }
.weapon-slot-name { font-size: 0.52rem; text-transform: uppercase; letter-spacing: 0.06em; color: rgba(255,255,255,0.65); }
.weapon-slot-key  { font-size: 0.5rem; color: rgba(255,255,255,0.35); }

/* ===== PAUSE OVERLAY ===== */
#pause-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 20;
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
}
#pause-overlay.active { display: flex; }

#pause-menu {
  background: #13132b;
  border: 1px solid rgba(162,76,255,0.35);
  border-radius: 16px;
  padding: 40px 36px;
  text-align: center;
  box-shadow: 0 0 50px rgba(162,76,255,0.15), 0 20px 60px rgba(0,0,0,0.8);
  min-width: 260px;
}
#pause-menu h2 {
  margin: 0 0 28px;
  font-size: 1.8rem;
  color: #a24cff;
  letter-spacing: 0.15em;
  text-shadow: 0 0 24px rgba(162,76,255,0.5);
}
.pause-btn {
  display: block !important;
  width: 100%;
  margin: 8px 0 !important;
  padding: 13px 20px !important;
  font-size: 1rem !important;
  font-weight: bold;
  color: #fff !important;
  background: rgba(255,255,255,0.07) !important;
  border: 1px solid rgba(255,255,255,0.18) !important;
  border-radius: 8px !important;
  cursor: pointer;
  text-align: center !important;
  transition: background 0.18s, border-color 0.18s, transform 0.12s;
  box-shadow: none !important;
  flex-direction: row !important;
}
.pause-btn:hover {
  background: rgba(162,76,255,0.22) !important;
  border-color: #a24cff !important;
  transform: translateX(4px) !important;
  box-shadow: none !important;
}

/* ===== SETTINGS PANEL ===== */
#settings-panel {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: #0f0f28;
  border: 1px solid rgba(162,76,255,0.38);
  border-radius: 16px;
  padding: 28px 28px 22px;
  z-index: 30;
  display: none;
  min-width: 330px;
  box-shadow: 0 0 60px rgba(0,0,0,0.9), 0 0 30px rgba(162,76,255,0.1);
}
#settings-panel.active { display: block; }
#settings-panel h2 {
  margin: 0 0 18px;
  font-size: 1.3rem;
  color: #a24cff;
}

.settings-section { margin-bottom: 16px; }
.settings-section > label {
  display: block;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: rgba(255,255,255,0.5);
  margin-bottom: 8px;
}

.preset-buttons {
  display: flex;
  gap: 6px;
}
.preset-btn {
  flex: 1;
  padding: 8px 4px !important;
  font-size: 0.78rem !important;
  background: rgba(255,255,255,0.07) !important;
  border: 1px solid rgba(255,255,255,0.18) !important;
  border-radius: 6px !important;
  color: #ccc !important;
  cursor: pointer;
  transition: all 0.14s;
  box-shadow: none !important;
  flex-direction: row !important;
}
.preset-btn:hover { background: rgba(162,76,255,0.2) !important; color: #fff !important; }
.preset-btn.active {
  background: rgba(162,76,255,0.35) !important;
  border-color: #a24cff !important;
  color: #fff !important;
  box-shadow: 0 0 10px rgba(162,76,255,0.3) !important;
}

.settings-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}
.settings-row > label {
  flex: 1;
  font-size: 0.82rem;
  color: #bbb;
  margin: 0;
}
.settings-row input[type="range"] {
  flex: 1;
  accent-color: #a24cff;
  cursor: pointer;
}
.settings-row .val-label {
  font-size: 0.78rem;
  color: #888;
  min-width: 24px;
  text-align: right;
}

.toggle-btn {
  width: 42px;
  height: 22px;
  border-radius: 11px;
  background: #333 !important;
  border: 1px solid #555 !important;
  cursor: pointer;
  position: relative;
  transition: background 0.2s !important;
  flex-shrink: 0;
  padding: 0 !important;
  flex-direction: row !important;
  box-shadow: none !important;
}
.toggle-btn.on { background: #a24cff !important; border-color: #a24cff !important; }
.toggle-btn::after {
  content: '';
  position: absolute;
  top: 2px; left: 2px;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.18s;
}
.toggle-btn.on::after { transform: translateX(20px); }

#settings-close-btn {
  width: 100%;
  margin-top: 8px !important;
  padding: 10px !important;
  background: rgba(162,76,255,0.18) !important;
  border: 1px solid rgba(162,76,255,0.35) !important;
  border-radius: 8px !important;
  color: #ccc !important;
  font-size: 0.88rem !important;
  cursor: pointer;
  flex-direction: row !important;
  box-shadow: none !important;
}
#settings-close-btn:hover { background: rgba(162,76,255,0.35) !important; color: #fff !important; }

/* ===== MODALS ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.88);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 10;
}

.modal-content {
  background: #13132b;
  padding: 28px 28px 22px;
  border-radius: 14px;
  text-align: center;
  border: 1px solid rgba(162,76,255,0.3);
  box-shadow: 0 12px 40px rgba(0,0,0,0.7), 0 0 30px rgba(162,76,255,0.1);
  max-width: 680px;
  width: 90%;
  max-height: 92vh;
  overflow-y: auto;
}

.modal-content h1 {
  margin: 0 0 6px;
  font-size: 1.8rem;
  color: #a24cff;
  text-shadow: 0 0 22px rgba(162,76,255,0.45);
}
.modal-content p {
  font-size: 1rem;
  color: #bbb;
  margin: 0 0 18px;
}

/* Shop categories */
.shop-category { margin-bottom: 16px; }
.shop-category-title {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: rgba(255,255,255,0.38);
  border-bottom: 1px solid rgba(255,255,255,0.08);
  padding-bottom: 5px;
  margin-bottom: 9px;
  text-align: left;
}
.shop-items {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
}
.shop-items.triple { grid-template-columns: 1fr 1fr 1fr; }

/* Base button */
button {
  padding: 10px 14px;
  font-size: 0.88rem;
  font-weight: bold;
  color: #fff;
  background: #3a86ff;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.18s ease;
  box-shadow: 0 4px 14px rgba(58,134,255,0.3);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  text-align: center;
}
button:hover {
  background: #4a91ff;
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(58,134,255,0.4);
}
button:active { transform: translateY(1px); }
button:disabled {
  background: #252535 !important;
  color: #555 !important;
  cursor: not-allowed;
  box-shadow: none !important;
  transform: none !important;
  opacity: 0.6;
}

.btn-weapon    { background: rgba(58,134,255,0.8);  border: 1px solid rgba(58,134,255,0.4);  box-shadow: 0 4px 14px rgba(58,134,255,0.25); }
.btn-weapon:hover { background: rgba(80,148,255,0.9); }

.btn-consumable { background: rgba(56,161,75,0.8);   border: 1px solid rgba(56,161,75,0.4);   box-shadow: 0 4px 14px rgba(56,161,75,0.25); }
.btn-consumable:hover { background: rgba(72,180,92,0.9); }

.btn-upgrade   { background: rgba(220,130,0,0.8);   border: 1px solid rgba(220,130,0,0.4);   box-shadow: 0 4px 14px rgba(220,130,0,0.25); }
.btn-upgrade:hover { background: rgba(240,148,20,0.9); }

.btn-icon  { font-size: 1.3rem; line-height: 1; }
.btn-label { font-size: 0.8rem; font-weight: bold; }
.btn-desc  { font-size: 0.63rem; color: rgba(255,255,255,0.65); font-weight: normal; }
.btn-cost  { font-size: 0.68rem; color: rgba(255,255,255,0.55); font-weight: normal; }
.btn-level { font-size: 0.63rem; color: rgba(255,200,50,0.75); font-weight: normal; }

#start-next-wave-btn {
  width: 100%;
  margin-top: 14px;
  padding: 14px !important;
  font-size: 1rem !important;
  background: #3a9e40 !important;
  border: none !important;
  box-shadow: 0 4px 16px rgba(58,158,64,0.35) !important;
  flex-direction: row !important;
  justify-content: center;
}
#start-next-wave-btn:hover {
  background: #4ab852 !important;
  box-shadow: 0 6px 22px rgba(58,158,64,0.5) !important;
}

#restart-game-btn {
  width: 100%;
  margin-top: 12px;
  padding: 14px !important;
  font-size: 1rem !important;
  background: #c0392b !important;
  border: none !important;
  box-shadow: 0 4px 16px rgba(192,57,43,0.35) !important;
  flex-direction: row !important;
  justify-content: center;
}
#restart-game-btn:hover {
  background: #e04030 !important;
  box-shadow: 0 6px 22px rgba(192,57,43,0.5) !important;
}

/* ===== ENEMY HEALTH BARS ===== */
.enemy-health-bar {
  position: fixed;
  pointer-events: none;
  z-index: 6;
  transform: translateX(-50%);
}
.enemy-hb-bg {
  width: 38px;
  height: 4px;
  background: rgba(0,0,0,0.6);
  border-radius: 2px;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,0.1);
}
.enemy-hb-fill {
  height: 100%;
  background: #e53935;
  border-radius: 2px;
  transition: width 0.08s;
}

/* ===== TOUCH CONTROLS ===== */
#touch-controls {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 260px;
  pointer-events: none;
  z-index: 8;
}
@media (pointer: coarse) {
  #touch-controls { display: block; }
}
#touch-move-zone {
  position: absolute;
  left: 0; bottom: 0;
  width: 50%; height: 100%;
  pointer-events: all;
}
#touch-look-zone {
  position: absolute;
  right: 0; bottom: 0;
  width: 50%; height: 100%;
  pointer-events: all;
}
#touch-joystick-base {
  position: absolute;
  width: 90px; height: 90px;
  border: 2px solid rgba(255,255,255,0.22);
  border-radius: 50%;
  background: rgba(255,255,255,0.05);
  display: none;
  pointer-events: none;
  transform: translate(-50%, -50%);
}
#touch-joystick-stick {
  position: absolute;
  width: 36px; height: 36px;
  border-radius: 50%;
  background: rgba(255,255,255,0.32);
  transform: translate(-50%, -50%);
  top: 50%; left: 50%;
}
#touch-shoot-btn {
  position: fixed;
  bottom: 28px; right: 28px;
  width: 68px; height: 68px;
  border-radius: 50%;
  background: rgba(200,40,40,0.5) !important;
  border: 2px solid rgba(255,100,100,0.55) !important;
  color: #fff !important;
  font-size: 1.5rem !important;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 9;
  pointer-events: all;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  flex-direction: row !important;
  box-shadow: none !important;
}
@media (pointer: coarse) {
  #touch-shoot-btn { display: flex; }
}
