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

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

#gameCanvas {
  display: block;
  border: 2px solid #7c3aed;
  box-shadow: 0 0 30px rgba(124,58,237,0.4);
}

.hidden { display: none !important; }

/* ── Shared button styles ── */
.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; }
.btn-muted { border-color: #374151; color: #6b7280; }
.btn-muted:hover { background: rgba(255,255,255,0.05); color: #9ca3af; }

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

/* ── Level select ── */
#screen-level-select {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  background: linear-gradient(160deg, #0a0a1a 0%, #1e1b4b 100%);
  z-index: 50;
}
.screen-title {
  color: #a78bfa;
  font-size: 1.6rem;
  letter-spacing: 4px;
  margin-bottom: 4px;
}
#level-grid {
  display: grid;
  grid-template-columns: repeat(3, 140px);
  gap: 12px;
}
.level-card {
  width: 140px;
  height: 100px;
  border: 2px solid #4c1d95;
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  cursor: pointer;
  transition: all 0.2s;
  background: rgba(76,29,149,0.15);
  color: #c4b5fd;
}
.level-card:hover:not(.locked) { border-color: #8b5cf6; background: rgba(139,92,246,0.2); box-shadow: 0 0 16px rgba(139,92,246,0.3); }
.level-card.locked { opacity: 0.4; cursor: not-allowed; filter: grayscale(0.6); }
.level-card .lc-num  { font-size: 1.5rem; font-weight: bold; color: #fff; }
.level-card .lc-name { font-size: 0.7rem; letter-spacing: 1px; }
.level-card .lc-stars { font-size: 0.85rem; }
.level-card .lc-lock  { font-size: 1.4rem; }
.level-card .lc-best  { font-size: 0.65rem; color: #fbbf24; }

/* ── Shop ── */
#screen-shop {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: linear-gradient(160deg, #0a0a1a 0%, #1e1b4b 100%);
  z-index: 50;
}
#shop-grid {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  justify-content: center;
  max-width: 500px;
}
.skin-card {
  width: 110px;
  border: 2px solid #4c1d95;
  border-radius: 10px;
  padding: 14px 8px 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  transition: all 0.2s;
  background: rgba(76,29,149,0.15);
  color: #c4b5fd;
  font-size: 0.78rem;
  text-align: center;
}
.skin-card:hover { border-color: #8b5cf6; background: rgba(139,92,246,0.2); }
.skin-card.active { border-color: #fbbf24; }
.skin-preview {
  width: 40px; height: 40px;
  border-radius: 4px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.3rem;
}
.skin-status { color: #fbbf24; font-size: 0.7rem; }
.skin-price  { color: #9ca3af; }

/* ── HUD ── */
#hud {
  position: absolute;
  top: 0; left: 50%;
  transform: translateX(-50%);
  width: 800px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 14px;
  background: rgba(0,0,0,0.55);
  color: #fff;
  font-size: 14px;
  z-index: 10;
  pointer-events: none;
  text-shadow: 0 1px 3px #000;
}
#hud-left  { display: flex; gap: 18px; }
#hud-center { color: #a78bfa; font-weight: bold; }
#hud-right  { color: #fbbf24; }
#btn-pause {
  background: transparent;
  border: 1px solid rgba(124,58,237,0.5);
  border-radius: 6px;
  color: #a78bfa;
  font-size: 0.9rem;
  width: 30px; height: 26px;
  cursor: pointer;
  pointer-events: auto;
  padding: 0;
  font-family: 'Courier New', monospace;
  transition: all 0.15s;
}
#btn-pause:hover { background: rgba(124,58,237,0.35); color: #fff; }

/* ── Overlays ── */
.overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 40;
}
.overlay-box {
  background: rgba(10,10,26,0.97);
  border: 2px solid #7c3aed;
  border-radius: 14px;
  padding: 36px 40px;
  text-align: center;
  min-width: 280px;
  box-shadow: 0 0 40px rgba(124,58,237,0.4);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  color: #fff;
  animation: popIn 0.25s ease-out;
}
@keyframes popIn {
  from { opacity:0; transform: scale(0.85); }
  to   { opacity:1; transform: scale(1); }
}
.overlay-box h2 { font-size: 1.8rem; margin-bottom: 4px; }
.stat-line { color: #c4b5fd; font-size: 1rem; }
.revive-title { font-size: 1.6rem; font-weight: bold; color: #ef4444; }

/* Revive ring */
.ring-wrap {
  position: relative;
  width: 80px; height: 80px;
  display: flex; align-items: center; justify-content: center;
  margin: 4px auto;
}
.ring-svg { width: 80px; height: 80px; transform: rotate(-90deg); }
.ring-bg   { fill:none; stroke:#1f2937; stroke-width:5; }
.ring-fill {
  fill:none; stroke:#8b5cf6; stroke-width:5;
  stroke-dasharray: 163.36;
  stroke-dashoffset: 0;
  transition: stroke-dashoffset 0.95s linear;
}
.ring-num {
  position:absolute;
  font-size: 1.6rem;
  font-weight: bold;
  color: #a78bfa;
}
