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

:root {
  --neon-cyan: #00f5ff;
  --neon-pink: #ff2d95;
  --neon-yellow: #ffe61a;
  --neon-green: #39ff14;
  --neon-orange: #ff6b1a;
  --neon-purple: #9d4edd;
  --bg-dark: #0a0a1a;
  --bg-panel: rgba(10, 10, 40, 0.88);
  --text-primary: #e0e8ff;
  --font-retro: 'Press Start 2P', monospace;
  --font-hud: 'Orbitron', sans-serif;
}

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg-dark);
  font-family: var(--font-hud);
  color: var(--text-primary);
}

#game-container {
  position: relative;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  background: radial-gradient(ellipse at 50% 0%, #1a1a3e 0%, #0a0a1a 70%);
}

canvas#gameCanvas {
  display: block;
  width: 100%;
  height: 100%;
}

.crt-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(0deg, rgba(0, 0, 0, 0.06) 0px, rgba(0, 0, 0, 0.06) 1px, transparent 1px, transparent 3px);
  z-index: 100;
}

.vignette-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(ellipse at center, transparent 55%, rgba(0, 0, 0, 0.5) 100%);
  z-index: 101;
}

/* Screens */
.screen {
  position: absolute;
  inset: 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(5, 5, 20, 0.92);
  backdrop-filter: blur(8px);
  transition: opacity .5s;
}

.screen.hidden {
  display: none;
  opacity: 0;
}

/* Title */
.title-wrapper {
  text-align: center;
  margin-bottom: 36px;
  animation: titleFloat 3s ease-in-out infinite;
}

@keyframes titleFloat {

  0%,
  100% {
    transform: translateY(0)
  }

  50% {
    transform: translateY(-10px)
  }
}

.game-title {
  font-family: var(--font-retro);
  font-size: 3rem;
  line-height: 1.4;
  color: var(--neon-cyan);
  text-shadow: 0 0 10px var(--neon-cyan), 0 0 30px var(--neon-cyan), 0 0 60px rgba(0, 245, 255, 0.4);
  letter-spacing: 6px;
}

.title-accent {
  color: var(--neon-pink);
  text-shadow: 0 0 10px var(--neon-pink), 0 0 30px var(--neon-pink), 0 0 60px rgba(255, 45, 149, 0.4);
  font-size: 3.8rem;
}

.subtitle {
  font-size: 1rem;
  color: var(--neon-yellow);
  margin-top: 14px;
  letter-spacing: 4px;
  text-shadow: 0 0 8px rgba(255, 230, 26, 0.5);
}

/* Controls */
.controls-info {
  display: flex;
  gap: 24px;
  margin-bottom: 36px;
  flex-wrap: wrap;
  justify-content: center;
}

.control-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  color: rgba(224, 232, 255, 0.7);
}

kbd {
  display: inline-block;
  padding: 3px 8px;
  font-family: var(--font-retro);
  font-size: 0.6rem;
  color: var(--neon-cyan);
  background: rgba(0, 245, 255, 0.08);
  border: 1px solid rgba(0, 245, 255, 0.3);
  border-radius: 4px;
}

.credit-text {
  font-family: var(--font-hud);
  font-size: 0.55rem;
  color: rgba(255,255,255,0.25);
  letter-spacing: 3px;
  text-transform: uppercase;
  margin-top: 8px;
}

/* Buttons */
.neon-btn {
  position: relative;
  padding: 14px 44px;
  font-family: var(--font-retro);
  font-size: 0.85rem;
  color: var(--neon-green);
  background: transparent;
  border: 2px solid var(--neon-green);
  border-radius: 8px;
  cursor: pointer;
  transition: all .3s;
  text-transform: uppercase;
  letter-spacing: 2px;
}

.neon-btn:hover {
  color: #000;
  background: var(--neon-green);
  box-shadow: 0 0 20px var(--neon-green), 0 0 40px rgba(57, 255, 20, 0.3);
  transform: scale(1.05);
}

.neon-btn:active {
  transform: scale(0.97);
}

.neon-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
  transform: none;
}

.hint-text {
  margin-top: 18px;
  font-size: 0.65rem;
  color: rgba(224, 232, 255, 0.3);
  animation: blink 1.5s step-end infinite;
}

@keyframes blink {

  0%,
  100% {
    opacity: 1
  }

  50% {
    opacity: 0
  }
}

/* Game Over */
.gameover-title {
  font-family: var(--font-retro);
  font-size: 2.8rem;
  color: var(--neon-pink);
  text-shadow: 0 0 10px var(--neon-pink), 0 0 40px var(--neon-pink);
  margin-bottom: 28px;
  animation: glitch 3s infinite;
}

@keyframes glitch {

  0%,
  90%,
  100% {
    transform: translate(0)
  }

  92% {
    transform: translate(-3px, 2px)
  }

  94% {
    transform: translate(3px, -2px)
  }

  96% {
    transform: translate(-2px, -1px)
  }
}

.final-score-wrapper {
  text-align: center;
  margin-bottom: 20px;
}

.final-score-label {
  font-size: 0.8rem;
  color: rgba(224, 232, 255, 0.5);
  margin-bottom: 6px;
  letter-spacing: 3px;
}

.final-score {
  font-family: var(--font-retro);
  font-size: 2.6rem;
  color: var(--neon-yellow);
  text-shadow: 0 0 10px var(--neon-yellow);
}

.final-stats {
  display: flex;
  gap: 36px;
  margin-bottom: 32px;
  flex-wrap: wrap;
  justify-content: center;
}

.stat-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.stat-label {
  font-size: 0.6rem;
  color: rgba(224, 232, 255, 0.4);
  letter-spacing: 2px;
}

.stat-value {
  font-family: var(--font-retro);
  font-size: 1.3rem;
  color: var(--neon-cyan);
  text-shadow: 0 0 8px rgba(0, 245, 255, 0.5);
}

/* Stage Clear */
.stageclear-title {
  font-family: var(--font-retro);
  font-size: 2.4rem;
  color: var(--neon-green);
  text-shadow: 0 0 15px var(--neon-green), 0 0 40px rgba(57, 255, 20, 0.4);
  margin-bottom: 16px;
  animation: stagePulse 1s ease-in-out infinite alternate;
}

@keyframes stagePulse {
  from {
    transform: scale(1)
  }

  to {
    transform: scale(1.05)
  }
}

.stageclear-stage {
  font-family: var(--font-retro);
  font-size: 1.4rem;
  color: var(--neon-cyan);
  margin-bottom: 20px;
}

.clear-rewards {
  font-size: 1.1rem;
  color: var(--neon-yellow);
  text-shadow: 0 0 8px rgba(255, 230, 26, 0.5);
}

/* Shop */
.shop-title {
  font-family: var(--font-retro);
  font-size: 1.8rem;
  color: var(--neon-yellow);
  text-shadow: 0 0 10px var(--neon-yellow);
  margin-bottom: 16px;
}

.shop-info-bar {
  display: flex;
  gap: 30px;
  margin-bottom: 8px;
  font-size: 0.9rem;
}

.shop-coins {
  color: var(--neon-yellow);
}

.shop-stage {
  color: var(--neon-cyan);
}

.player-stats-bar {
  display: flex;
  gap: 20px;
  font-size: 0.75rem;
  color: rgba(224, 232, 255, 0.6);
  margin-bottom: 20px;
}

.shop-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
  max-width: 740px;
  width: 90%;
  margin-bottom: 24px;
  max-height: 50vh;
  overflow-y: auto;
  padding: 8px;
}

.shop-grid::-webkit-scrollbar {
  width: 4px;
}

.shop-grid::-webkit-scrollbar-thumb {
  background: var(--neon-cyan);
  border-radius: 4px;
}

.shop-item {
  background: rgba(10, 20, 50, 0.8);
  border: 1px solid rgba(0, 245, 255, 0.15);
  border-radius: 10px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: all .3s;
}

.shop-item:hover {
  border-color: var(--neon-cyan);
  box-shadow: 0 0 12px rgba(0, 245, 255, 0.15);
}

.shop-item.maxed {
  border-color: rgba(57, 255, 20, 0.3);
  opacity: 0.6;
}

.shop-item-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.shop-item-name {
  font-family: var(--font-retro);
  font-size: 0.65rem;
  color: var(--neon-cyan);
}

.shop-item-level {
  font-size: 0.6rem;
  color: var(--neon-green);
}

.shop-item-desc {
  font-size: 0.65rem;
  color: rgba(224, 232, 255, 0.5);
  line-height: 1.4;
}

.shop-item-bar {
  height: 4px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 2px;
  overflow: hidden;
}

.shop-item-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--neon-cyan), var(--neon-green));
  border-radius: 2px;
  transition: width .3s;
}

.shop-buy-btn {
  padding: 6px 12px;
  font-family: var(--font-retro);
  font-size: 0.55rem;
  color: var(--neon-yellow);
  background: rgba(255, 230, 26, 0.08);
  border: 1px solid rgba(255, 230, 26, 0.3);
  border-radius: 6px;
  cursor: pointer;
  transition: all .2s;
  align-self: flex-end;
}

.shop-buy-btn:hover:not(:disabled) {
  background: var(--neon-yellow);
  color: #000;
  box-shadow: 0 0 10px rgba(255, 230, 26, 0.3);
}

.shop-buy-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.neon-btn-go {
  margin-top: 8px;
  border-color: var(--neon-cyan);
  color: var(--neon-cyan);
}

.neon-btn-go:hover {
  background: var(--neon-cyan);
  color: #000;
  box-shadow: 0 0 20px var(--neon-cyan);
}

/* HUD */
#hud {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 30;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 6px 10px 0;
  pointer-events: none;
}

#hud.hidden { display: none; }

#hud-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 16px;
  background: rgba(5, 5, 25, 0.65);
  border-radius: 0 0 12px 12px;
  border: 1px solid rgba(255,255,255,0.06);
  border-top: none;
  backdrop-filter: blur(6px);
  font-family: var(--font-retro);
  font-size: 0.65rem;
  white-space: nowrap;
}

.hud-divider {
  color: rgba(255,255,255,0.12);
  font-size: 0.7rem;
}

.hud-item {
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

.hud-lbl {
  color: rgba(224, 232, 255, 0.35);
  font-size: 0.5rem;
  letter-spacing: 1px;
}

#score-value {
  color: var(--neon-yellow);
  text-shadow: 0 0 6px rgba(255, 230, 26, 0.4);
}

#stage-value, #wave-value {
  color: var(--neon-cyan);
}

#lv-value {
  color: var(--neon-green);
}

#coin-value {
  color: var(--neon-yellow);
}

#lives-value, #bombs-value {
  font-size: 0.75rem;
  font-family: sans-serif;
}

/* Boss HP */
#boss-hp-bar {
  width: 300px;
  text-align: center;
}

#boss-hp-bar.hidden {
  display: none;
}

.boss-name {
  font-family: var(--font-retro);
  font-size: 0.6rem;
  color: var(--neon-pink);
  display: block;
  margin-bottom: 4px;
}

.boss-bar-bg {
  width: 100%;
  height: 8px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
  overflow: hidden;
  border: 1px solid rgba(255, 45, 149, 0.3);
}

.boss-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--neon-pink), var(--neon-orange));
  border-radius: 4px;
  transition: width .2s;
}

/* Language Toggle */
#lang-toggle {
  position: absolute;
  top: 16px;
  left: 20px;
  z-index: 110;
  padding: 6px 14px;
  font-family: var(--font-hud);
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--neon-cyan);
  background: rgba(0, 245, 255, 0.08);
  border: 1px solid rgba(0, 245, 255, 0.3);
  border-radius: 20px;
  cursor: pointer;
  transition: all 0.3s;
  backdrop-filter: blur(4px);
}
#lang-toggle:hover {
  background: rgba(0, 245, 255, 0.15);
  box-shadow: 0 0 12px rgba(0, 245, 255, 0.2);
  transform: scale(1.05);
}

/* Settings Gear Button */
#settings-btn {
  position: absolute;
  bottom: 20px;
  right: 20px;
  z-index: 110;
  width: 42px;
  height: 42px;
  font-size: 1.3rem;
  background: rgba(10, 10, 40, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 50%;
  cursor: pointer;
  transition: all 0.3s;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
}
#settings-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  transform: rotate(90deg) scale(1.1);
  box-shadow: 0 0 14px rgba(255, 255, 255, 0.15);
}
#settings-btn.hidden { display: none; }

/* Settings Modal */
.settings-panel {
  background: rgba(10, 12, 35, 0.95);
  border: 1px solid rgba(0, 245, 255, 0.2);
  border-radius: 16px;
  padding: 36px 48px;
  text-align: center;
  box-shadow: 0 0 40px rgba(0, 245, 255, 0.08), inset 0 0 30px rgba(0, 245, 255, 0.03);
  min-width: 320px;
  animation: modalIn 0.3s ease-out;
}
@keyframes modalIn {
  from { transform: scale(0.85); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}
.settings-title {
  font-family: var(--font-retro);
  font-size: 1.3rem;
  color: var(--neon-cyan);
  text-shadow: 0 0 10px rgba(0, 245, 255, 0.5);
  margin-bottom: 28px;
}
.settings-buttons {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.settings-opt {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 28px;
  font-family: var(--font-hud);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.25s;
  letter-spacing: 1px;
}
.settings-opt:hover {
  background: rgba(0, 245, 255, 0.1);
  border-color: var(--neon-cyan);
  transform: translateX(4px);
  box-shadow: 0 0 12px rgba(0, 245, 255, 0.1);
}
.settings-opt .opt-icon { font-size: 1.2rem; }
.settings-opt-danger:hover {
  background: rgba(255, 45, 149, 0.1);
  border-color: var(--neon-pink);
  box-shadow: 0 0 12px rgba(255, 45, 149, 0.1);
}

/* Wave announce */
#wave-announce {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 40;
  text-align: center;
  pointer-events: none;
}

#wave-announce.hidden {
  display: none;
}

.wave-text {
  font-family: var(--font-retro);
  font-size: 2.2rem;
  color: var(--neon-cyan);
  text-shadow: 0 0 10px var(--neon-cyan), 0 0 40px rgba(0, 245, 255, 0.5);
  animation: waveZoom 1.8s ease-out forwards;
}

@keyframes waveZoom {
  0% {
    transform: scale(0.5);
    opacity: 0
  }

  25% {
    transform: scale(1.2);
    opacity: 1
  }

  65% {
    transform: scale(1);
    opacity: 1
  }

  100% {
    transform: scale(1.5);
    opacity: 0
  }
}

/* EXP bar */
#exp-bar-wrap {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: rgba(255, 255, 255, 0.05);
  z-index: 30;
}

#exp-bar-wrap.hidden {
  display: none;
}

#exp-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--neon-green), var(--neon-cyan));
  width: 0%;
  transition: width .3s;
}

/* Responsive */
/* Mobile Controls */
#mobile-controls {
  position: absolute;
  bottom: 20px;
  left: 0;
  right: 0;
  z-index: 35;
  display: flex;
  justify-content: space-between;
  padding: 0 24px;
  pointer-events: none;
}
#mobile-controls.hidden { display: none; }
.mob-btn {
  pointer-events: auto;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.2);
  background: rgba(10,10,40,0.6);
  backdrop-filter: blur(4px);
  font-size: 1.6rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.mob-btn:active {
  transform: scale(0.9);
  background: rgba(255,255,255,0.15);
}
.mob-bomb {
  border-color: rgba(255,230,26,0.4);
  box-shadow: 0 0 12px rgba(255,230,26,0.15);
}
.mob-bomb:active {
  box-shadow: 0 0 20px rgba(255,230,26,0.4);
  border-color: var(--neon-yellow);
}
.mob-settings {
  border-color: rgba(0,245,255,0.3);
  box-shadow: 0 0 12px rgba(0,245,255,0.1);
}

/* Responsive */
@media(max-width:600px) {
  .game-title { font-size: 1.8rem }
  .title-accent { font-size: 2.2rem }
  .controls-info { flex-direction: column; gap: 10px; align-items: center }
  .neon-btn { padding: 10px 28px; font-size: 0.7rem }
  .gameover-title { font-size: 1.8rem }
  .final-score { font-size: 1.8rem }
  .shop-grid { grid-template-columns: 1fr }
  #hud { padding: 6px 10px }
  #score-value, #stage-value, #wave-value { font-size: 0.7rem }
  .shop-title { font-size: 1.2rem }
  .subtitle { font-size: 0.75rem; letter-spacing: 2px }
  .settings-panel { padding: 24px 28px; min-width: 280px }
}

/* Show mobile controls on touch devices */
@media (pointer: coarse) {
  #mobile-controls { pointer-events: none; }
  .mob-btn { pointer-events: auto; }
  #settings-btn { display: none !important; }
}
@media (pointer: fine) {
  #mobile-controls { display: none !important; }
}