/* === RESET & BASE === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --cyan: #00f5ff;
  --cyan-dim: #00a8b0;
  --orange: #ff6b00;
  --red: #ff2244;
  --gold: #ffd700;
  --purple: #9933ff;
  --green: #00ff88;
  --white: #ffffff;
  --dark: #050a14;
  --panel-bg: rgba(0, 15, 30, 0.85);
  --border: rgba(0, 245, 255, 0.3);
  --font: 'Courier New', monospace;
  --font-title: 'Arial Black', 'Arial Bold', sans-serif;
}

html, body {
  width: 100%; height: 100%;
  overflow: hidden;
  background: #000;
  font-family: var(--font);
  color: var(--white);
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

#game-container {
  position: relative;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

#gameCanvas {
  display: block;
  image-rendering: pixelated;
  touch-action: none;
}

/* === HUD === */
#hud {
  position: absolute;
  top: 0; left: 0; right: 0;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 8px 12px;
  pointer-events: none;
  z-index: 10;
}

#hud-top-left, #hud-top-center, #hud-top-right {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 120px;
}
#hud-top-left { align-items: flex-start; }
#hud-top-right { align-items: flex-end; }

#score-label, #hiscore-label, #wave-label {
  font-size: 9px;
  letter-spacing: 2px;
  color: var(--cyan-dim);
  text-transform: uppercase;
}

#score-display {
  font-size: 22px;
  font-weight: bold;
  color: var(--gold);
  text-shadow: 0 0 8px var(--gold);
  letter-spacing: 2px;
  line-height: 1.1;
}

#hiscore-display {
  font-size: 13px;
  color: var(--cyan);
  text-shadow: 0 0 4px var(--cyan);
  letter-spacing: 1px;
}

#wave-display {
  font-size: 28px;
  font-weight: bold;
  color: var(--cyan);
  text-shadow: 0 0 10px var(--cyan);
  letter-spacing: 3px;
}

/* Boss HP bar */
#boss-bar-wrap {
  width: 220px;
  margin-top: 4px;
}
#boss-bar-label {
  font-size: 9px;
  letter-spacing: 2px;
  color: var(--red);
  text-align: center;
  text-shadow: 0 0 4px var(--red);
}
#boss-bar-track {
  width: 100%;
  height: 10px;
  background: rgba(255,0,0,0.15);
  border: 1px solid var(--red);
  border-radius: 5px;
  overflow: hidden;
  box-shadow: 0 0 6px rgba(255,34,68,0.5);
}
#boss-bar-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #ff2244, #ff6b00, #ffd700);
  border-radius: 5px;
  transition: width 0.2s ease;
  box-shadow: 0 0 8px #ff2244;
}

/* Combo */
#combo-display {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  pointer-events: none;
}
#combo-value {
  font-size: 26px;
  font-weight: bold;
  color: var(--orange);
  text-shadow: 0 0 12px var(--orange), 0 0 20px var(--orange);
  letter-spacing: 2px;
  animation: comboPulse 0.5s ease infinite alternate;
}
#combo-label {
  font-size: 9px;
  letter-spacing: 2px;
  color: var(--orange);
  opacity: 0.7;
}
@keyframes comboPulse {
  from { transform: scale(1); }
  to { transform: scale(1.08); }
}

#sound-toggle {
  font-size: 20px;
  cursor: pointer;
  pointer-events: all;
  margin-top: 4px;
  opacity: 0.7;
  transition: opacity 0.2s;
}
#sound-toggle:hover { opacity: 1; }

/* === BOTTOM HUD === */
#hud-bottom {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 14px;
  background: linear-gradient(to top, rgba(0,0,0,0.7) 0%, transparent 100%);
  pointer-events: none;
  z-index: 10;
}

#lives-display {
  display: flex;
  gap: 6px;
  align-items: center;
}

/* weapon display */
#weapon-display {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}
#weapon-label {
  font-size: 8px;
  letter-spacing: 2px;
  color: var(--cyan-dim);
}
#weapon-level-bar {
  display: flex;
  gap: 4px;
}
.wlvl-pip {
  width: 16px;
  height: 8px;
  border-radius: 2px;
  background: rgba(0,245,255,0.1);
  border: 1px solid rgba(0,245,255,0.3);
  transition: background 0.3s, box-shadow 0.3s;
}
.wlvl-pip.active {
  background: var(--cyan);
  box-shadow: 0 0 6px var(--cyan);
}
.wlvl-pip.active.lv4 { background: #aa44ff; box-shadow: 0 0 6px #aa44ff; }
.wlvl-pip.active.lv5 { background: #ff8800; box-shadow: 0 0 6px #ff8800; }
.wlvl-pip.active.lv6 { background: #ffd700; box-shadow: 0 0 8px var(--gold), 0 0 16px var(--gold); }

#crystal-bar {
  width: 96px;
  height: 4px;
  background: rgba(0,255,136,0.15);
  border: 1px solid rgba(0,255,136,0.4);
  border-radius: 2px;
  overflow: hidden;
}
#crystal-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--green), #00ffff);
  transition: width 0.3s ease;
  border-radius: 2px;
  box-shadow: 0 0 4px var(--green);
}

#bombs-display {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}
#bombs-label {
  font-size: 8px;
  letter-spacing: 2px;
  color: var(--cyan-dim);
}
#bombs-count {
  font-size: 20px;
  font-weight: bold;
  color: var(--orange);
  text-shadow: 0 0 8px var(--orange);
}

/* === SCREENS === */
.screen {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 20;
  background: transparent;
}
.screen.active { display: flex; }

.screen-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  padding: 40px;
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 0 60px rgba(0,245,255,0.15), inset 0 0 40px rgba(0,0,0,0.5);
  backdrop-filter: blur(10px);
  max-width: 600px;
  width: 90%;
  text-align: center;
}

.title-glow {
  font-family: var(--font-title);
  font-size: clamp(28px, 6vw, 52px);
  font-weight: 900;
  letter-spacing: 4px;
  background: linear-gradient(135deg, #00f5ff, #9933ff, #ffd700);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  filter: drop-shadow(0 0 20px rgba(0,245,255,0.8));
  animation: titlePulse 3s ease-in-out infinite alternate;
  text-transform: uppercase;
  line-height: 1.1;
}
@keyframes titlePulse {
  from { filter: drop-shadow(0 0 15px rgba(0,245,255,0.6)); }
  to { filter: drop-shadow(0 0 30px rgba(153,51,255,0.9)) drop-shadow(0 0 50px rgba(0,245,255,0.4)); }
}

.subtitle {
  font-size: 14px;
  letter-spacing: 6px;
  color: var(--cyan-dim);
  text-transform: uppercase;
  margin-top: -10px;
}

.menu-options { display: flex; flex-direction: column; gap: 12px; width: 100%; }

.menu-btn {
  padding: 14px 32px;
  background: linear-gradient(135deg, rgba(0,245,255,0.15), rgba(153,51,255,0.1));
  border: 1px solid var(--cyan);
  border-radius: 6px;
  font-family: var(--font);
  font-size: 13px;
  letter-spacing: 3px;
  color: var(--cyan);
  cursor: pointer;
  text-transform: uppercase;
  transition: all 0.2s ease;
  text-shadow: 0 0 8px var(--cyan);
  box-shadow: 0 0 12px rgba(0,245,255,0.1), inset 0 0 12px rgba(0,245,255,0.05);
  pointer-events: all;
}
.menu-btn:hover, .menu-btn:focus {
  background: linear-gradient(135deg, rgba(0,245,255,0.3), rgba(153,51,255,0.2));
  box-shadow: 0 0 20px rgba(0,245,255,0.4), inset 0 0 20px rgba(0,245,255,0.1);
  transform: scale(1.02);
  outline: none;
}
.menu-btn.secondary {
  border-color: rgba(0,245,255,0.4);
  color: rgba(0,245,255,0.6);
  font-size: 11px;
  padding: 10px 24px;
  text-shadow: none;
}
.menu-btn.secondary:hover {
  border-color: var(--cyan);
  color: var(--cyan);
  text-shadow: 0 0 6px var(--cyan);
}

.credits {
  font-size: 10px;
  color: rgba(0,245,255,0.4);
  letter-spacing: 1px;
  line-height: 1.8;
}

/* Howto screen */
.howto { max-width: 700px; }
.howto h2 {
  font-family: var(--font-title);
  font-size: 24px;
  letter-spacing: 4px;
  color: var(--cyan);
  text-shadow: 0 0 12px var(--cyan);
}
.howto-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  width: 100%;
  text-align: left;
}
.howto-section h3 {
  font-size: 10px;
  letter-spacing: 3px;
  color: var(--orange);
  border-bottom: 1px solid rgba(255,107,0,0.3);
  padding-bottom: 4px;
  margin-bottom: 8px;
}
.howto-item {
  font-size: 11px;
  color: rgba(255,255,255,0.7);
  margin-bottom: 4px;
  line-height: 1.5;
}
.key {
  display: inline-block;
  padding: 1px 5px;
  background: rgba(0,245,255,0.15);
  border: 1px solid rgba(0,245,255,0.4);
  border-radius: 3px;
  font-size: 10px;
  color: var(--cyan);
  margin-right: 4px;
}

/* Pause */
.pause-title {
  font-family: var(--font-title);
  font-size: 40px;
  letter-spacing: 6px;
  color: var(--cyan);
  text-shadow: 0 0 20px var(--cyan);
}

/* Game Over */
.gameover-title {
  font-family: var(--font-title);
  font-size: clamp(30px, 5vw, 46px);
  letter-spacing: 4px;
  color: var(--red);
  text-shadow: 0 0 20px var(--red), 0 0 40px rgba(255,34,68,0.5);
  animation: goFlicker 2s ease-in-out infinite alternate;
}
@keyframes goFlicker {
  0% { opacity: 1; text-shadow: 0 0 20px var(--red); }
  90% { opacity: 1; }
  95% { opacity: 0.7; }
  100% { opacity: 1; text-shadow: 0 0 30px var(--red), 0 0 60px rgba(255,34,68,0.6); }
}
#go-score-wrap, #v-score-wrap {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.go-stat {
  display: flex;
  justify-content: space-between;
  padding: 8px 16px;
  background: rgba(0,245,255,0.05);
  border: 1px solid rgba(0,245,255,0.15);
  border-radius: 4px;
  font-size: 13px;
}
.go-stat span:first-child {
  color: var(--cyan-dim);
  letter-spacing: 2px;
  font-size: 10px;
}
.go-stat span:last-child {
  color: var(--gold);
  font-weight: bold;
  font-size: 16px;
}

/* Victory */
.victory-title {
  font-family: var(--font-title);
  font-size: clamp(36px, 6vw, 56px);
  letter-spacing: 6px;
  background: linear-gradient(135deg, #ffd700, #00ff88, #00f5ff);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  filter: drop-shadow(0 0 20px rgba(255,215,0,0.8));
  animation: victoryGlow 1.5s ease-in-out infinite alternate;
}
@keyframes victoryGlow {
  from { filter: drop-shadow(0 0 15px rgba(255,215,0,0.6)); }
  to { filter: drop-shadow(0 0 30px rgba(0,245,255,0.9)) drop-shadow(0 0 60px rgba(255,215,0,0.5)); }
}
.victory-sub {
  font-size: 12px;
  letter-spacing: 6px;
  color: var(--gold);
  opacity: 0.8;
  margin-top: -12px;
}

/* Boss Warning */
#boss-warning {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 15;
  pointer-events: none;
  background: radial-gradient(ellipse at center, rgba(255,34,68,0.3) 0%, transparent 70%);
  animation: warningFade 3s ease forwards;
}
#boss-warning.hidden { display: none; }
#boss-warning-text {
  font-family: var(--font-title);
  font-size: clamp(24px, 5vw, 42px);
  letter-spacing: 4px;
  color: var(--red);
  text-align: center;
  text-shadow: 0 0 20px var(--red), 0 0 40px rgba(255,34,68,0.6);
  animation: warningPulse 0.5s ease infinite alternate;
  line-height: 1.4;
}
@keyframes warningFade {
  0% { opacity: 0; } 10% { opacity: 1; } 70% { opacity: 1; } 100% { opacity: 0; }
}
@keyframes warningPulse {
  from { transform: scale(1); letter-spacing: 4px; }
  to { transform: scale(1.05); letter-spacing: 5px; }
}

/* Mobile Controls */
#mobile-controls {
  position: absolute;
  bottom: 60px;
  right: 16px;
  display: none;
  z-index: 15;
}
.mobile-btn {
  width: 60px;
  height: 60px;
  background: rgba(255,107,0,0.3);
  border: 2px solid var(--orange);
  border-radius: 50%;
  color: var(--orange);
  font-size: 18px;
  font-family: var(--font);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0;
  line-height: 1;
  text-shadow: 0 0 6px var(--orange);
  box-shadow: 0 0 12px rgba(255,107,0,0.3);
  transition: all 0.1s;
  touch-action: manipulation;
}
.mobile-btn:active {
  background: rgba(255,107,0,0.6);
  transform: scale(0.95);
}
.mobile-btn small { font-size: 8px; letter-spacing: 1px; }

/* Utility */
.hidden { display: none !important; }

/* Scrollbar hide */
::-webkit-scrollbar { display: none; }

/* Responsive touch */
@media (hover: none) and (pointer: coarse) {
  #mobile-controls { display: flex; }
}
