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

/* ── Dark theme (default) ── */
:root {
  --background: #1a1a2e;
  --foreground: #eaeaea;
  --card: #252540;
  --card-foreground: #eaeaea;
  --primary: #4ade80;
  --primary-foreground: #1a1a2e;
  --secondary: #f97316;
  --secondary-foreground: #eaeaea;
  --accent: #facc15;
  --accent-foreground: #1a1a2e;
  --destructive: #ef4444;
  --muted: #3a3a5a;
  --muted-foreground: #a0a0b0;
  --border: #4a4a6a;
  --radius: 0.5rem;
}

/* ── Light theme (explicit via data-theme="light") ── */
html[data-theme="light"] {
  --background: #f0f4f8;
  --foreground: #1a1a2e;
  --card: #ffffff;
  --card-foreground: #1a1a2e;
  --primary: #16a34a;
  --primary-foreground: #ffffff;
  --secondary: #ea6c00;
  --secondary-foreground: #ffffff;
  --accent: #ca8a04;
  --accent-foreground: #ffffff;
  --destructive: #dc2626;
  --muted: #e2e8f0;
  --muted-foreground: #64748b;
  --border: #cbd5e1;
}

/* ── Light theme (auto via browser preference, unless dark is forced) ── */
@media (prefers-color-scheme: light) {
  html:not([data-theme="dark"]) {
    --background: #f0f4f8;
    --foreground: #1a1a2e;
    --card: #ffffff;
    --card-foreground: #1a1a2e;
    --primary: #16a34a;
    --primary-foreground: #ffffff;
    --secondary: #ea6c00;
    --secondary-foreground: #ffffff;
    --accent: #ca8a04;
    --accent-foreground: #ffffff;
    --destructive: #dc2626;
    --muted: #e2e8f0;
    --muted-foreground: #64748b;
    --border: #cbd5e1;
  }
}

/* ── General ── */
.hidden {
  display: none !important;
}

body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background-color: var(--background);
  color: var(--foreground);
  min-height: 100vh;
  overflow: hidden;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  transition: background-color 0.25s, color 0.25s;
}

/* ── Settings bar (top-right) ── */
.settings-bar {
  position: fixed;
  top: 0.625rem;
  right: 0.625rem;
  display: flex;
  gap: 0.375rem;
  z-index: 200;
}

.settings-btn {
  background: var(--card);
  color: var(--foreground);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.3rem 0.6rem;
  font-size: 0.8rem;
  font-weight: 600;
  line-height: 1.4;
  cursor: pointer;
  transition: background-color 0.2s, border-color 0.2s, color 0.2s;
}

.settings-btn:hover {
  background: var(--muted);
}

/* ── Confetti canvas ── */
#confetti-canvas {
  display: none;
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 50;
  pointer-events: none;
}

/* ── Pause FAB ── */
.pause-fab {
  display: none;
  position: fixed;
  bottom: 1rem;
  right: 1rem;
  width: 2.75rem;
  height: 2.75rem;
  background: var(--card);
  color: var(--foreground);
  border: 1px solid var(--border);
  border-radius: 50%;
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  z-index: 30;
  align-items: center;
  justify-content: center;
  transition: background-color 0.2s, border-color 0.2s;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.pause-fab:hover {
  background: var(--muted);
}

body.game-active .pause-fab {
  display: flex;
}

/* ── Game container ── */
.game-container {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  position: relative;
}

.background-pattern {
  position: absolute;
  inset: 0;
  background-image: radial-gradient(circle at center, var(--primary) 1px, transparent 1px);
  background-size: 32px 32px;
  opacity: 0.05;
  pointer-events: none;
}

/* ── HUD ── */
.hud {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  background: var(--card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  margin-bottom: 1rem;
  z-index: 10;
  transition: background-color 0.25s, border-color 0.25s;
}

@media (min-width: 640px) {
  .hud {
    gap: 1.5rem;
    padding: 1rem 1.5rem;
  }
}

.hud-item {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

@media (min-width: 640px) {
  .hud-item {
    gap: 0.5rem;
  }
}

.hud-label {
  font-size: 0.75rem;
  color: var(--muted-foreground);
}

.hud-label-short {
  display: inline;
  font-size: 0.75rem;
  color: var(--accent);
}

.hud-label-full {
  display: none;
  font-size: 0.75rem;
  color: var(--muted-foreground);
}

@media (min-width: 640px) {
  .hud-label-short {
    display: none;
  }
  .hud-label-full {
    display: inline;
  }
}

.hud-value {
  font-weight: bold;
  color: var(--primary);
}

.stat-bars {
  display: flex;
  gap: 2px;
}

.stat-bar {
  width: 8px;
  height: 12px;
  border-radius: 2px;
  background: var(--muted);
}

.stat-bar.active {
  background: var(--accent);
}

@media (min-width: 640px) {
  .stat-bar {
    height: 16px;
  }
}

/* ── Game Board ── */
.game-wrapper {
  position: relative;
  z-index: 10;
}

#game-canvas {
  display: block;
  border-radius: var(--radius);
  border: 2px solid var(--border);
  background: var(--card);
  transition: border-color 0.25s;
}

.touch-hint {
  display: block;
  text-align: center;
  font-size: 0.75rem;
  color: var(--muted-foreground);
  margin-top: 0.5rem;
}

@media (min-width: 768px) {
  .touch-hint {
    display: none;
  }
}

/* ── Enemies Indicator ── */
.enemies-indicator {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 1rem;
  z-index: 10;
}

.enemies-label {
  font-size: 0.875rem;
  color: var(--muted-foreground);
}

.enemies-dots {
  display: flex;
  gap: 4px;
}

.enemy-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--destructive);
}

.enemy-dot.dead {
  background: var(--muted);
}

/* ── Overlays ── */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 1rem;
}

.menu-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  text-align: center;
  max-width: 320px;
  width: 100%;
  transition: background-color 0.25s, border-color 0.25s;
}

@media (min-width: 640px) {
  .menu-card {
    padding: 2rem;
  }
}

.menu-title {
  font-size: 1.5rem;
  font-weight: bold;
  margin-bottom: 0.5rem;
  color: var(--foreground);
}

@media (min-width: 640px) {
  .menu-title {
    font-size: 2rem;
  }
}

.menu-title-danger {
  color: var(--destructive);
}

.menu-title-success {
  color: var(--primary);
}

.menu-subtitle {
  color: var(--muted-foreground);
  margin-bottom: 1.5rem;
}

/* ── High score in start menu ── */
.menu-highscore {
  font-size: 0.875rem;
  color: var(--muted-foreground);
  margin-bottom: 1rem;
}

.menu-highscore span:last-child {
  color: var(--accent);
  font-weight: bold;
}

/* ── New high score message ── */
.new-highscore-msg {
  color: var(--accent);
  font-weight: bold;
  font-size: 1rem;
  margin-bottom: 0.75rem;
}

/* ── Start buttons container ── */
.start-buttons {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

/* ── Controls info ── */
.controls-info {
  font-size: 0.875rem;
  color: var(--muted-foreground);
  margin-bottom: 1.5rem;
  text-align: left;
}

.controls-info p {
  margin-bottom: 0.25rem;
}

.controls-info strong {
  color: var(--foreground);
}

#mobile-controls {
  display: block;
  text-align: center;
}

#desktop-controls {
  display: none;
}

@media (min-width: 768px) {
  #mobile-controls {
    display: none;
  }
  #desktop-controls {
    display: block;
  }
}

/* ── Buttons ── */
.btn {
  display: inline-block;
  padding: 0.75rem 2rem;
  font-size: 1rem;
  font-weight: 600;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: opacity 0.2s, transform 0.1s;
}

.btn:hover {
  opacity: 0.9;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: var(--primary);
  color: var(--primary-foreground);
}

/* ── Impressum ── */
.impressum-link {
  display: block;
  font-size: 0.75rem;
  color: var(--muted-foreground);
  text-decoration: none;
  margin-top: 1rem;
  transition: color 0.2s;
  text-align: center;
}

.impressum-link:hover {
  color: var(--foreground);
}
