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

body {
  background: #08080f;
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100vh;
  font-family: 'Courier New', monospace;
  overflow: hidden;
}

#app {
  position: relative;
  width: 100%;
  height: 100vh;
}

.hidden { display: none !important; }

/* ── Shared buttons ── */
.btn {
  display: block;
  width: 220px;
  padding: 12px 0;
  margin: 8px auto;
  background: transparent;
  border: 2px solid #6d28d9;
  border-radius: 8px;
  color: #c4b5fd;
  font-family: 'Courier New', monospace;
  font-size: 1rem;
  letter-spacing: 2px;
  cursor: pointer;
  transition: all 0.2s;
}
.btn:hover { background: #6d28d9; color: #fff; box-shadow: 0 0 14px #7c3aed; }
.btn-primary { border-color: #8b5cf6; color: #e9d5ff; }
.btn-primary:hover { background: #8b5cf6; }

/* ── Menu ── */
#screen-menu {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: linear-gradient(160deg, #08080f 0%, #1a0a2e 100%);
  z-index: 50;
}
.game-title {
  font-size: clamp(2rem, 7vw, 3.5rem);
  color: #a78bfa;
  letter-spacing: 8px;
  text-align: center;
  text-shadow: 0 0 20px #7c3aed, 0 0 40px #4c1d95;
  margin-bottom: 10px;
  line-height: 1.1;
  animation: glow 2s ease-in-out infinite;
}
@keyframes glow {
  0%,100% { text-shadow: 0 0 20px #7c3aed, 0 0 40px #4c1d95; }
  50%     { text-shadow: 0 0 40px #a78bfa, 0 0 80px #7c3aed; }
}
.coin-badge { color: #fbbf24; font-size: 1.1rem; margin: 2px 0 12px; }
.hint { color: #4b5563; font-size: 0.75rem; letter-spacing: 1px; margin-top: 6px; text-align: center; }

/* Difficulty selector */
.section-label {
  color: #6d28d9;
  font-size: 0.7rem;
  letter-spacing: 3px;
  margin-top: 4px;
}
.diff-row { display: flex; gap: 6px; }
.diff-btn {
  background: transparent;
  border: 2px solid #4c1d95;
  border-radius: 6px;
  color: #7c3aed;
  font-family: 'Courier New', monospace;
  font-size: 0.82rem;
  padding: 7px 18px;
  cursor: pointer;
  transition: all 0.18s;
  letter-spacing: 2px;
}
.diff-btn:hover { background: rgba(124,58,237,0.2); color: #c4b5fd; }
.diff-btn.diff-active { background: #4c1d95; color: #e9d5ff; border-color: #7c3aed; box-shadow: 0 0 10px rgba(124,58,237,0.5); }
.diff-btn[data-diff="medium"].diff-active { background: #92400e; border-color: #f59e0b; color: #fde68a; box-shadow: 0 0 10px rgba(245,158,11,0.5); }
.diff-btn[data-diff="hard"].diff-active   { background: #7f1d1d; border-color: #ef4444; color: #fca5a5; box-shadow: 0 0 10px rgba(239,68,68,0.5); }
.diff-hint {
  color: #6b7280;
  font-size: 0.7rem;
  letter-spacing: 1px;
  margin: 3px 0 6px;
  min-height: 14px;
  text-align: center;
}

/* ── Shop ── */
#screen-shop {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  background: linear-gradient(160deg, #08080f 0%, #1a0a2e 100%);
  z-index: 50;
  overflow-y: auto;
  padding: 20px 8px 16px;
}
.screen-title { color: #a78bfa; font-size: 1.5rem; letter-spacing: 4px; }

/* Shop tabs */
.tab-bar { display: flex; gap: 6px; }
.tab-btn {
  background: transparent;
  border: 1px solid #4c1d95;
  border-radius: 6px;
  color: #7c3aed;
  font-family: 'Courier New', monospace;
  font-size: 0.78rem;
  padding: 6px 12px;
  cursor: pointer;
  transition: all 0.18s;
  letter-spacing: 1px;
}
.tab-btn:hover { background: rgba(124,58,237,0.2); }
.tab-btn.tab-active { background: #4c1d95; color: #e9d5ff; border-color: #7c3aed; }

/* Shop grid */
#shop-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  max-width: 500px;
  padding: 4px 4px 8px;
}
.skin-card {
  width: 90px;
  border: 2px solid #3b1f6a;
  border-radius: 10px;
  padding: 10px 6px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  transition: all 0.18s;
  background: rgba(76,29,149,0.15);
  color: #c4b5fd;
  font-size: 0.72rem;
  text-align: center;
}
.skin-card:hover { border-color: #7c3aed; background: rgba(124,58,237,0.2); }
.skin-card.selected { border-color: #fbbf24; }
.skin-preview { display: block; border-radius: 5px; }
.skin-status { color: #fbbf24; font-size: 0.64rem; }
.skin-price  { color: #9ca3af; }

/* ── Game screen ── */
#screen-game {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  background: #08080f;
}

/* HUD */
#hud {
  width: 100%;
  max-width: 490px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 5px 10px;
  background: rgba(0,0,0,0.65);
  color: #fff;
  font-size: 11px;
  flex-shrink: 0;
  gap: 4px;
  flex-wrap: wrap;
  pointer-events: none;
}
#hud-lives  { color: #f87171; letter-spacing: 2px; }
#hud-diff   { font-size: 0.65rem; letter-spacing: 1px; padding: 1px 5px; border-radius: 4px; }
#hud-diff.easy   { background: rgba(34,197,94,0.2);  color: #4ade80; }
#hud-diff.medium { background: rgba(245,158,11,0.2); color: #fbbf24; }
#hud-diff.hard   { background: rgba(239,68,68,0.2);  color: #f87171; }
#hud-wave   { color: #a78bfa; }
#hud-timer  { color: #94a3b8; }
#hud-powerup { color: #fbbf24; font-size: 0.65rem; min-width: 55px; }
#btn-pause {
  pointer-events: auto;
  background: transparent;
  border: 1px solid rgba(139,92,246,0.5);
  border-radius: 5px;
  color: #a78bfa;
  font-size: 0.85rem;
  width: 26px; height: 22px;
  cursor: pointer;
  padding: 0;
  font-family: 'Courier New', monospace;
  transition: all 0.15s;
}
#btn-pause:hover { background: rgba(139,92,246,0.3); }

/* Canvas */
#gameCanvas {
  display: block;
  border: 2px solid #4c1d95;
  border-radius: 6px;
  box-shadow: 0 0 28px rgba(109,40,217,0.35);
  flex-shrink: 0;
  touch-action: none;
  cursor: none;
}

/* ── Overlays ── */
.overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.82);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 60;
}
.overlay-box {
  background: rgba(8,8,15,0.97);
  border: 2px solid #6d28d9;
  border-radius: 14px;
  padding: 30px 44px;
  text-align: center;
  min-width: 270px;
  max-width: 360px;
  box-shadow: 0 0 40px rgba(109,40,217,0.45);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  color: #fff;
  animation: popIn 0.2s ease-out;
}
@keyframes popIn {
  from { opacity:0; transform: scale(0.85); }
  to   { opacity:1; transform: scale(1); }
}
.overlay-box h2 { font-size: 1.7rem; margin-bottom: 4px; }
.col-red  { color: #f87171; }
.col-gold { color: #fbbf24; }
.stat-line { color: #c4b5fd; font-size: 0.95rem; }

/* ── Fullscreen ── */
:fullscreen        #app { width: 100vw; height: 100vh; }
:-webkit-full-screen #app { width: 100vw; height: 100vh; }
