/* === Globales Layout & Grunddesign === */
html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  width: 100%;
  background: #111;
  font-family: "Segoe UI", sans-serif;
  color: #eee;
  display: flex;
  justify-content: center;
  align-items: start;
  overflow: hidden; /* wird in .scene für Scrollbarkeit überschrieben */
  touch-action: none;
  overscroll-behavior: none;
  background-image: url("../img/background.png");
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  background-attachment: fixed;
}

/* === Szenenstruktur === */
.scene {
  display: none;
  background: #1a1a1a80;
  border-radius: 12px;
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
  padding: 30px 20px;
  width: 90%;
  max-width: 500px;
  overflow-y: auto;
  overscroll-behavior: contain;
  animation: fadeIn 0.3s ease;
  text-align: center;
  height: 300px;
  border: 2px solid lightblue;
}

.scene h2,
.scene h3 {
  color: #00afcc;
  box-shadow: 5px 5px 5px rgba(0, 0, 0, 0.8);
}

/* === Eingabeelemente === */
input[type="text"],
input[type="color"] {
  padding: 8px;
  border-radius: 6px;
  border: none;
  margin: 8px 0;
  width: 100%;
  box-sizing: border-box;
}

/* === Buttons === */
button,
.touch-btn {
  background: #00afcc;
  color: #fff;
  padding: 10px 16px;
  margin: 10px 5px 0;
  border: none;
  border-radius: 10px;
  font-weight: bold;
  font-size: 16px;
  cursor: pointer;
  transition: background 0.2s ease;
}

button:hover {
  background: #00aa77;
}

.touch-btn {
  background: #333;
  font-size: 22px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
  padding: 12px 0;
}

.touch-btn:active {
  background: #555;
}

/* === Mobile-Steuerung === */
.mobile-row {
  display: flex;
  justify-content: space-evenly;
  gap: 10px;
  width: 100%;
  margin-bottom: 8px;
}

#mobileControls {
  position: absolute;
  bottom: 5px;
  right: 20px;
  z-index: 1000;
  display: flex;
  gap: 12px;
}

#controls {
  display: none;
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  flex-direction: column;
  align-items: center;
  gap: 10px;
  z-index: 200;
}

#controls .row {
  display: flex;
  gap: 15px;
  justify-content: center;
}

.control-btn {
  width: 40px;
  height: 40px;
  font-size: 15px;
  background: #444;
  color: #fff;
  border: none;
  border-radius: 12px;
  box-shadow: 0 0 5px rgba(0, 0, 0, 0.5);
}

/* === Spielbereich === */
#gameWrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  padding-bottom: 120px;
}

#gameCanvas {
  display: none;
  max-width: 100%;
  height: 80vh;
  margin: 0 auto;
  border: 1px solid #ccc;
  background: #000;
  pointer-events: none !important;
  margin-top: 50px;
}

.fullscreen-canvas {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 999;
  width: 100vw;
  height: 100vh;
  transform-origin: top left;
}

canvas.fullscreen-canvas {
  top: 50%;
  left: 50%;
  transform-origin: center center;
}

/* === UI & Panels === */
#statusPanel {
  position: absolute;
  top: 70px;
  left: 10px;
  z-index: 2000;
  font-size: 14px;
}

#statusPanel ul {
  list-style: none;
  padding-left: 0;
  margin: 4px 0 12px 0;
}

#nachrichten {
  position: absolute;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.8);
  color: white;
  font-size: 20px;
  border-radius: 10px;
  padding: 12px 20px;
  z-index: 10;
  pointer-events: none;
  display: none;
}

#headline {
  position: absolute;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 32px;
  color: #fff;
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
  z-index: 100;
  margin: 0;
}

#playernameLabel {
  position: absolute;
  bottom: 10px;
  left: 20px;
  color: white;
  font-size: 16px;
  z-index: 10;
}

#countdownBox {
  position: absolute;
  top: 80px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 32px;
  color: yellow;
  display: none;
  z-index: 10;
}

#scoreBoard {
  position: fixed;
  top: 10px;
  right: 20px;
  font-size: 24px;
  font-weight: bold;
  color: #00ff00;
  z-index: 9999;
  text-align: right;
  width: 100px; /* Feste Breite verhindert Zucken */
}

.scoreNumber {
  display: block;
  width: 100%;
}

#scoreContainer {
  text-align: center;
  margin-top: 10px;
}

#fullscreenToggle {
  margin-top: 8px;
  padding: 6px 12px;
  font-size: 1rem;
  cursor: pointer;
  background-color: #222;
  color: white;
  border: 1px solid #666;
  border-radius: 4px;
  position: absolute;
  left: 0;
}

/* === Highscore === */
.hiscore-overlay {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: white;
  border: 2px solid #ccc;
  padding: 20px;
  z-index: 10000;
  max-width: 90vw;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  width: 90%;
  color: black;
  font-family: sans-serif;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease;
}

.hiscore-overlay.visible {
  opacity: 1;
  pointer-events: auto;
}

.hiscore-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

/* === Effekte === */
#explosion {
  transition: transform 0.5s ease-out, opacity 0.5s ease-out;
  opacity: 0;
}

#lobbyContainer #scene1 button,
#lobbyContainer #scene2 button {
  width: 100%;
  margin: 0;
}

#lobbyContainer #scene3 button {
  width: 80%;
}
.scene div div {
  text-align: left;
}

.hiscore-entry {
  display: flex;
  justify-content: space-between;
  padding: 4px 8px;
  border-bottom: 1px solid #ddd;
  font-family: sans-serif;
}

.rank-and-name {
  flex: 1;
  text-align: left;
}

.points {
  width: 100px;
  text-align: right;
}

/* === Animation === */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* === Medienanpassung === */
@media screen and (orientation: portrait) {
  #orientationOverlay {
    display: flex !important;
  }
  #mainGameUI,
  #gameCanvas,
  #mobileControls {
    display: none !important;
  }
}
@media screen and (orientation: landscape) {
  #orientationOverlay {
    display: none !important;
  }
  #mainGameUI,
  #gameCanvas,
  #mobileControls {
    display: block !important;
  }
}
