/* style.css (UI-Update für Mobile + Lobby-Layout) */
:root {
  --ui-bg: rgba(0, 0, 0, 0.5);
  --glass-bg: rgba(255, 255, 255, 0.15);
  --glass-border: rgba(255, 255, 255, 0.35);
  --glass-shadow: rgba(0, 0, 0, 0.35);
  --accent: #4caf50;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  width: 100%;
  overflow: hidden;
  font-family: "Press Start 2P", cursive;
  color: #fff;
  background-color: #000;
  touch-action: none;
  overscroll-behavior: none;
}

.video-container {
  position: absolute;
  inset: 0;
  overflow: hidden;
  z-index: 0;
}
.video-container.hidden {
  display: none;
}
#backgroundVideo {
  min-width: 100%;
  min-height: 100%;
  width: auto;
  height: auto;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}
.video-overlay {
  position: absolute;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.5);
  z-index: 1;
}

.lobby {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 10;
  text-align: center;
  transition: opacity 300ms ease-in-out;
  width: min(90vw, 720px);
}
.lobby.fade {
  opacity: 0;
  pointer-events: none;
}
.lobby h1 {
  font-size: 48px;
  text-shadow: 4px 4px 0 #000;
  margin-bottom: 20px;
}

#name {
  padding: 10px 12px;
  font-size: 16px;
  border: 2px solid #fff;
  background-color: rgba(0, 0, 0, 0.5);
  color: #fff;
  font-family: "Press Start 2P", cursive;
  margin-bottom: 15px;
}
#startBtn {
  padding: 12px 22px;
  font-size: 16px;
  cursor: pointer;
  background: linear-gradient(180deg, #55c35a, #419e46);
  color: #fff;
  border: 0;
  border-radius: 10px;
  box-shadow: 0 6px 16px rgba(76, 175, 80, 0.35);
  font-family: "Press Start 2P", cursive;
  transition: transform 0.08s ease, box-shadow 0.2s ease, filter 0.2s ease;
}
#startBtn:hover {
  filter: brightness(1.05);
}
#startBtn:active {
  transform: translateY(1px) scale(0.99);
  box-shadow: 0 4px 12px rgba(76, 175, 80, 0.25);
}

#gameCanvas {
  display: none;
  position: absolute;
  inset: 0;
  z-index: 5;
  width: 100%;
  height: 100%;
  image-rendering: optimizeSpeed;
  image-rendering: -webkit-optimize-contrast;
  image-rendering: pixelated;
}

/* HUD-Boxen */
#leaderboard,
#timer,
#playerList,
#roundResults {
  position: absolute;
  background: var(--ui-bg);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: #fff;
  padding: 12px;
  font-size: 14px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  z-index: 15;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.35);
}
#leaderboard {
  top: 20px;
  left: 20px;
  min-width: 200px;
}
#roundResults {
  top: 20px;
  left: 20px;
  min-width: 200px;
}
.hidden {
  display: none !important;
}

#timer {
  top: 20px;
  right: 20px;
  font-size: 16px;
  padding: 12px 14px;
}
#playerList {
  right: 20px;
  top: 50%;
  transform: translateY(-50%);
  min-width: 180px;
}
.player-item {
  margin: 6px 0;
}

.lobby-timer {
  font-size: 16px;
  margin-top: 22px;
  color: #ffd700;
  text-shadow: 2px 2px 0 #000;
}

/* Mobile Controls */
#mobile-controls {
  display: none; /* Standardmäßig aus, wird via JS-Klasse .game-active aktiviert */
  position: fixed;
  bottom: 20px;
  left: 20px;
  right: 20px;
  z-index: 20;
  justify-content: space-between;
  align-items: flex-end;
  pointer-events: auto;
}
#mobile-left-controls {
  display: flex;
  flex-direction: row;
  gap: 14px;
}
.control-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.22), rgba(255, 255, 255, 0.08));
  color: #fff;
  border: 1px solid var(--glass-border);
  border-radius: 18px;
  font-size: 28px;
  width: 120px;
  height: 72px;
  cursor: pointer;
  opacity: 0.95;
  font-family: "Press Start 2P", cursive;
  -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
  transition: transform 0.08s ease, background 0.2s ease, box-shadow 0.2s ease, filter 0.2s ease;
  box-shadow: 0 10px 24px var(--glass-shadow);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
.control-button:hover {
  filter: brightness(1.05);
}
.control-button:active {
  transform: scale(0.98);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.28), rgba(255, 255, 255, 0.12));
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.4);
}
.jump-button {
  width: 124px;
  height: 72px;
  font-size: 36px;
  border-radius: 18px;
}
.control-button::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: radial-gradient(ellipse at top, rgba(255, 255, 255, 0.25), transparent 60%);
  opacity: 0.35;
  pointer-events: none;
}

.control-button img {
  width: 100%; /* Bild füllt die Breite des Buttons */
  height: 100%; /* Bild füllt die Höhe des Buttons */
  object-fit: contain; /* Stellt sicher, dass das gesamte Bild sichtbar ist, ohne Verzerrung */
  padding: 8px; /* Ein wenig Abstand vom Rand des Buttons */
}

/* Spezifische Anpassung für den Sprung-Button, falls nötig */
.jump-button img {
  padding: 4px; /* Mehr Platz um den Springen-Pfeil */
}

/* --- NEU: Mobile Controls nur im Spiel anzeigen --- */
body.touch.game-active #mobile-controls {
    display: flex;
}

/* --- ÜBERARBEITET: Spezifischere und kompaktere mobile Styles --- */

/* Generelle Touch-Anpassungen */
@media (max-width: 900px) {
  body.touch .lobby #name,
  body.touch .lobby #startBtn {
    display: block;
    width: 80%;
    margin-left: auto;
    margin-right: auto;
    max-width: 300px;
  }
  body.touch .lobby #startBtn {
    margin-top: 10px;
  }

  body.touch #leaderboard,
  body.touch #roundResults {
    font-size: 11px;
    padding: 8px 10px;
    min-width: 140px;
    top: 10px;
    left: 10px;
  }
  
  body.touch #playerList {
    font-size: 11px;
    padding: 8px 10px;
    min-width: auto; /* Wichtig für kompakte Darstellung */
    right: 10px;
  }
  
  body.touch #timer {
    font-size: 16px;
    padding: 8px 12px;
    top: 10px;
    right: 10px;
  }
  
  body.touch .lobby h1 {
    font-size: 32px;
  }
}


/* Kleines Gerät Portrait */
@media (max-width: 480px) and (orientation: portrait) {
  body.touch #leaderboard h3,
  body.touch #roundResults h3,
  body.touch #playerList h4 {
    font-size: 0.9em;
    margin: 0 0 6px;
  }
}