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

:root {
  --bg-color: #0b0914;
  --surface-color: #161324;
  --modal-bg: #1c1830;
  --text-main: #ffffff;
  --text-muted: #8e8aab;
  --border-light: rgba(255, 255, 255, 0.12);
  --cyan-glow: #00f0ff;
  --pink-glow: #ff007f;
  --yellow-glow: #ffe600;
  --brand-coral: #ff6b57;
  --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

body {
  background-color: var(--bg-color);
  color: var(--text-main);
  font-family: var(--font-family);
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

.game-wrapper {
  position: relative;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  max-width: 900px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

canvas#stage {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  z-index: 1;
}

/* Heads Up Display */
.hud {
  position: absolute;
  top: 14px;
  left: 14px;
  right: 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  z-index: 10;
  pointer-events: none;
}

.hud-pill {
  background: rgba(18, 15, 33, 0.82);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--border-light);
  border-radius: 20px;
  padding: 6px 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.hud-label {
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

.hud-val {
  font-size: 1.15rem;
  font-weight: 900;
  color: #fff;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}

.hud-combo-pill {
  background: linear-gradient(135deg, rgba(255, 0, 127, 0.25), rgba(0, 240, 255, 0.25));
  border-color: var(--cyan-glow);
  box-shadow: 0 0 16px rgba(0, 240, 255, 0.35);
  animation: pulseGlow 0.8s infinite alternate ease-in-out;
}

.hud-combo {
  font-size: 1.1rem;
  font-weight: 950;
  color: var(--yellow-glow);
  text-shadow: 0 0 8px rgba(255, 230, 0, 0.6);
}

@keyframes pulseGlow {
  0% { transform: scale(0.96); box-shadow: 0 0 10px rgba(0, 240, 255, 0.25); }
  100% { transform: scale(1.04); box-shadow: 0 0 20px rgba(0, 240, 255, 0.55); }
}

/* Combo Toast */
.combo-toast {
  position: absolute;
  top: 75px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(255, 0, 127, 0.9);
  color: #fff;
  font-weight: 900;
  font-size: 1.1rem;
  padding: 8px 18px;
  border-radius: 30px;
  box-shadow: 0 8px 24px rgba(255, 0, 127, 0.5);
  pointer-events: none;
  z-index: 20;
  letter-spacing: 0.04em;
  animation: popBounce 0.3s cubic-bezier(0.18, 0.89, 0.32, 1.28);
}

@keyframes popBounce {
  0% { transform: translate(-50%, -15px) scale(0.7); opacity: 0; }
  100% { transform: translate(-50%, 0) scale(1); opacity: 1; }
}

/* Overlays & Modals */
.overlay {
  position: absolute;
  inset: 0;
  background: rgba(8, 6, 16, 0.88);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 16px;
  animation: fadeIn 0.22s ease-out;
}

.overlay.hidden {
  display: none !important;
}

@keyframes fadeIn {
  from { opacity: 0; transform: scale(0.98); }
  to { opacity: 1; transform: scale(1); }
}

.modal-card {
  background: var(--modal-bg);
  border: 1px solid var(--border-light);
  border-radius: 20px;
  padding: 30px 24px;
  max-width: 420px;
  width: 100%;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.7), 0 0 30px rgba(0, 240, 255, 0.12);
  display: flex;
  flex-direction: column;
  gap: 16px;
  text-align: center;
  position: relative;
}

.neon-badge {
  display: inline-block;
  align-self: center;
  padding: 4px 12px;
  border-radius: 20px;
  background: rgba(0, 240, 255, 0.15);
  border: 1px solid var(--cyan-glow);
  color: var(--cyan-glow);
  font-size: 0.72rem;
  font-weight: 850;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.game-title {
  font-size: 2.2rem;
  font-weight: 950;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #fff;
  text-shadow: 0 0 20px rgba(0, 240, 255, 0.5), 0 2px 4px rgba(0, 0, 0, 0.6);
  margin-top: -4px;
}

.modal-card h2 {
  font-size: 1.85rem;
  font-weight: 900;
  color: #fff;
  letter-spacing: 0.02em;
}

.subtitle {
  font-size: 0.92rem;
  color: var(--text-muted);
  line-height: 1.45;
}

.guide-box {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-light);
  border-radius: 12px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  text-align: left;
}

.guide-item {
  display: flex;
  align-items: center;
  gap: 12px;
}

.guide-key {
  background: linear-gradient(135deg, var(--cyan-glow), #0099ff);
  color: #0b0914;
  font-size: 0.74rem;
  font-weight: 900;
  padding: 4px 10px;
  border-radius: 6px;
  letter-spacing: 0.06em;
  min-width: 76px;
  text-align: center;
}

.guide-desc {
  font-size: 0.85rem;
  font-weight: 600;
  color: #f1f3f5;
}

/* Stats Grid in Game Over */
.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 4px 0;
}

.stat-box {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-light);
  border-radius: 10px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.stat-box .stat-label {
  font-size: 0.68rem;
  font-weight: 800;
  color: var(--text-muted);
  letter-spacing: 0.06em;
}

.stat-box .stat-val {
  font-size: 1.4rem;
  font-weight: 900;
  color: #fff;
}

.stat-highlight {
  color: var(--cyan-glow) !important;
  text-shadow: 0 0 10px rgba(0, 240, 255, 0.4);
}

/* Buttons */
.btn {
  font-family: inherit;
  font-size: 1.05rem;
  font-weight: 850;
  border: none;
  border-radius: 12px;
  padding: 14px 24px;
  cursor: pointer;
  transition: transform 0.1s, box-shadow 0.15s, filter 0.15s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  letter-spacing: 0.03em;
  -webkit-tap-highlight-color: transparent;
}

.btn-primary {
  background: linear-gradient(135deg, var(--cyan-glow), #0099ff);
  color: #080610;
  box-shadow: 0 4px 0 #0077b6, 0 8px 24px rgba(0, 240, 255, 0.4);
}

.btn-primary:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
}

.btn-primary:active {
  transform: translateY(2.5px);
  box-shadow: 0 1px 0 #0077b6;
}

.controls-hint {
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* Mobile Media Queries */
@media (max-width: 480px) {
  .hud {
    top: 10px;
    left: 10px;
    right: 10px;
  }
  .hud-pill {
    padding: 5px 10px;
  }
  .game-title {
    font-size: 1.85rem;
  }
  .modal-card {
    padding: 24px 18px;
  }
}
