html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg, #0d0d1a);
  color: var(--text-color, #e0e0e0);
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  display: flex;
  flex-direction: column;
}

/* ── HUD ─────────────────────────────────────────────────────────────── */
#hud {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 14px;
  background: rgba(0,0,0,0.35);
  border-bottom: 1px solid rgba(255,255,255,0.06);
  flex-shrink: 0;
  min-height: 44px;
  gap: 8px;
  flex-wrap: wrap;
}

.hud-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 60px;
}

.hud-label {
  font-size: 0.6em;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #888;
}

.hud-value {
  font-size: 1.05em;
  font-weight: bold;
  color: var(--text-color, #e0e0e0);
  line-height: 1.2;
}

#comboDisplay {
  display: none;
  color: #fbbf24;
  text-shadow: 0 0 8px rgba(251,191,36,0.5);
}

#effectsDisplay {
  display: none;
  font-size: 1.1em;
  gap: 4px;
  align-items: center;
}

.hud-buttons {
  display: flex;
  gap: 8px;
  margin-left: auto;
}

/* ── Canvas area ─────────────────────────────────────────────────────── */
#canvasWrap {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
}

#gameCanvas {
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  display: block;
  border: 2px solid rgba(255,255,255,0.1);
  border-radius: 6px;
  background: #0a0a1a;
}

/* ── Game buttons (home / leaderboard) ──────────────────────────────── */
.game-button {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--card-bg, rgba(255,255,255,0.06));
  border: 1px solid rgba(255,255,255,0.15);
  color: var(--text-color, #e0e0e0);
  cursor: pointer;
  display: flex;
  justify-content: center;
  align-items: center;
  transition: opacity 0.2s, transform 0.15s;
  padding: 0;
}

.game-button:hover {
  opacity: 0.8;
  transform: scale(1.1);
}

.game-button svg {
  stroke: var(--text-color, #e0e0e0);
}

/* ── D-Pad (touch only) ─────────────────────────────────────────────── */
#dpad {
  position: fixed;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  z-index: 500;
  user-select: none;
  -webkit-user-select: none;
}

@media (pointer: coarse) {
  #dpad {
    display: flex;
  }
  #canvasWrap {
    padding-bottom: 120px;
  }
}

.dpad-row {
  display: flex;
  gap: 4px;
}

.dpad-btn {
  width: 52px;
  height: 52px;
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 10px;
  color: white;
  font-size: 1.3em;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.1s;
  user-select: none;
  -webkit-user-select: none;
}

.dpad-btn:active {
  background: rgba(162,76,255,0.4);
}

.dpad-spacer {
  width: 52px;
  height: 52px;
}

/* ── Modals ─────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.75);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 2000;
  backdrop-filter: blur(5px);
}

.modal-content {
  background: var(--card-bg, #1a1a2e);
  backdrop-filter: blur(15px);
  -webkit-backdrop-filter: blur(15px);
  padding: 28px 32px;
  border-radius: 20px;
  border: 1px solid rgba(255,255,255,0.1);
  box-shadow: 0 10px 40px rgba(0,0,0,0.5);
  animation: fadeInScale 0.25s ease-out;
  width: 95%;
  max-width: 420px;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-content h2 {
  margin: 0 0 20px;
  font-size: 1.8em;
  color: var(--primary, #a24cff);
  font-weight: bold;
  text-align: center;
}

@keyframes fadeInScale {
  from { opacity: 0; transform: scale(0.9); }
  to   { opacity: 1; transform: scale(1); }
}

/* Mode select */
.mode-select-options {
  display: flex;
  gap: 14px;
}

.mode-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 20px 12px;
  background: rgba(255,255,255,0.05);
  border: 2px solid rgba(255,255,255,0.1);
  border-radius: 16px;
  color: var(--text-color, #e0e0e0);
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s, transform 0.15s;
  font-family: inherit;
}

.mode-btn:hover {
  border-color: var(--primary, #a24cff);
  background: rgba(162,76,255,0.1);
  transform: translateY(-3px);
}

.mode-btn-icon { font-size: 2.2em; }
.mode-btn-name { font-size: 1.05em; font-weight: bold; }
.mode-btn-desc { font-size: 0.78em; color: #aaa; text-align: center; line-height: 1.3; }
.mode-btn-hs   { font-size: 0.82em; color: var(--primary, #a24cff); font-weight: bold; margin-top: 4px; }

/* Game over / pause overlays */
.score-stats {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-bottom: 20px;
}

.score-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: rgba(255,255,255,0.05);
  border-radius: 12px;
  padding: 14px 20px;
  flex: 1;
}

.score-stat-label {
  font-size: 0.72em;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #aaa;
  margin-bottom: 6px;
}

.score-stat-value {
  font-size: 1.8em;
  font-weight: bold;
}

.new-highscore-badge {
  background: var(--primary, #a24cff);
  color: white;
  text-align: center;
  border-radius: 20px;
  padding: 4px 14px;
  font-size: 0.8em;
  font-weight: bold;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 16px;
  animation: fadeInScale 0.4s ease;
}

.btn-primary {
  background-color: var(--primary, #a24cff) !important;
  border: none !important;
  font-weight: bold !important;
  padding: 12px !important;
  border-radius: 8px !important;
  transition: filter 0.2s, transform 0.15s !important;
  cursor: pointer;
  color: white;
  font-size: 1em;
  font-family: inherit;
  width: 100%;
}

.btn-primary:hover {
  filter: brightness(1.2) !important;
  transform: translateY(-2px) !important;
}

.btn-secondary {
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.15);
  color: var(--text-color, #e0e0e0);
  font-weight: bold;
  padding: 10px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.95em;
  font-family: inherit;
  width: 100%;
  transition: background 0.2s;
}

.btn-secondary:hover {
  background: rgba(255,255,255,0.14);
}

/* Leaderboard modal */
.sl-close-btn {
  background: none;
  border: none;
  color: var(--text-color, #e0e0e0);
  font-size: 1.2em;
  cursor: pointer;
  opacity: 0.6;
  padding: 4px 8px;
  border-radius: 6px;
  line-height: 1;
  transition: opacity 0.2s;
}

.sl-close-btn:hover { opacity: 1; }

.sl-lb-tab {
  background: rgba(255,255,255,0.07);
  border: 2px solid transparent;
  border-radius: 20px;
  color: var(--text-color, #e0e0e0);
  padding: 6px 18px;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.88em;
  transition: border-color 0.2s, background 0.2s;
}

.sl-lb-tab.active {
  border-color: var(--primary, #a24cff);
  background: rgba(162,76,255,0.12);
}

/* BD-lb item classes (shared pattern) */
.bd-lb-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 6px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}

.bd-lb-item:last-child { border-bottom: none; }

.bd-lb-item.bd-lb-me {
  background: rgba(162,76,255,0.08);
  border-radius: 8px;
}

.bd-lb-rank  { width: 28px; text-align: right; font-size: 0.85em; color: #888; flex-shrink: 0; }
.bd-lb-name  { flex: 1; font-weight: bold; font-size: 0.95em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bd-lb-stats { display: flex; flex-direction: column; align-items: flex-end; flex-shrink: 0; }
.bd-lb-score { font-weight: bold; font-size: 1em; color: var(--primary, #a24cff); }

/* Settings modal */
.settings-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid rgba(255,255,255,0.07);
}

.settings-row:last-child { border-bottom: none; }

.sl-switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  width: 46px;
  height: 22px;
}

.sl-switch input { opacity: 0; width: 0; height: 0; }

.sl-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: #444;
  border-radius: 22px;
  transition: 0.3s;
}

.sl-slider:before {
  content: '';
  position: absolute;
  height: 16px;
  width: 16px;
  left: 3px;
  bottom: 3px;
  background: white;
  border-radius: 50%;
  transition: 0.3s;
}

input:checked + .sl-slider { background: var(--primary, #a24cff); }
input:checked + .sl-slider:before { transform: translateX(24px); }

/* Floating score text */
.float-text {
  position: fixed;
  font-weight: bold;
  font-size: 1.3em;
  pointer-events: none;
  transform: translate(-50%, 0);
  z-index: 1500;
  text-shadow: 0 0 6px rgba(0,0,0,0.8);
  transition: opacity 0.8s ease-out, transform 0.8s ease-out;
}

/* Prevent snow/shine from shared CSS on buttons */
.no-snow .snow-cap, .no-snow .snow-drip { display: none !important; }

html[data-theme] .game-button::after,
html[data-theme] .btn-primary::after,
html[data-theme] .btn-secondary::after { content: none !important; display: none !important; }
