/* Grundlegendes Reset und dunkles Farbschema */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background-color: #0d0d1a;
  color: #e8e8f0;
  font-family: system-ui, sans-serif;
  min-height: 100dvh;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 1rem;
}

/* Spielcontainer: relativ positioniert, damit .overlay absolut darüber liegen kann */
main.spiel {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  max-width: 480px;
}

/* HUD: Flex-Zeile mit Punktestand, Leben und Neustart-Button */
.hud {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 0.4rem 0.6rem;
  background-color: #1a1a2e;
  border: 1px solid #2e2e50;
  border-radius: 6px;
  font-size: 1rem;
  gap: 0.75rem;
}

.hud span {
  flex: 1;
}

/* Spielfeld: responsiv, kein Standard-Touch-Verhalten, Mauszeiger versteckt */
canvas#spielfeld {
  display: block;
  max-width: 100%;
  height: auto;
  touch-action: none;
  cursor: none;
  border: 2px solid #2e2e50;
  border-radius: 4px;
  background-color: #050510;
}

/* Gemeinsame Button-Stile */
#restart,
#gameover-restart {
  background-color: #3a3aff;
  color: #ffffff;
  border: none;
  border-radius: 6px;
  padding: 0.5rem 1.1rem;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 0.15s ease;
}

#restart:hover,
#gameover-restart:hover {
  background-color: #5555ff;
}

#restart:active,
#gameover-restart:active {
  background-color: #2222cc;
}

/* Sichtbarer Fokus-Ring für Tastaturnavigation (ausreichender Kontrast) */
#restart:focus-visible,
#gameover-restart:focus-visible {
  outline: 3px solid #ffdd57;
  outline-offset: 3px;
}

/* Game-Over-Overlay: absolut über dem Canvas, halbtransparent, zentriert */
.overlay {
  position: absolute;
  /* Abstand von oben: HUD-Höhe (~2.8rem) + gap (0.5rem) */
  top: calc(2.8rem + 0.5rem);
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  background-color: rgba(5, 5, 16, 0.82);
  border-radius: 4px;
  padding: 2rem;
  text-align: center;
}

.overlay h2 {
  font-size: 2rem;
  color: #ffdd57;
}

.overlay p {
  font-size: 1.1rem;
}

.overlay strong {
  color: #ffdd57;
}

/* Versteckt Elemente mit dem hidden-Attribut */
[hidden] {
  display: none !important;
}

/* Steuerungshinweis unterhalb des Spielfelds */
.steuerung {
  font-size: 0.8rem;
  color: #6666aa;
  text-align: center;
}
