@import url('https://fonts.googleapis.com/css2?family=Rubik:wght@400;500;700&display=swap');

body {
  margin: 0;
  font-family: 'Rubik', sans-serif;
  background: linear-gradient(135deg, #050505 0%, #130821 100%);
  color: white;
  overflow: hidden;
  height: 100vh;
  width: 100vw;
}

/* --- GRID LAYOUT --- */
/* Flexbox statt Grid, weil die Hoehen animiert werden: die Interpolation
   von grid-template-rows koennen erst neuere Chromium-Versionen, und das
   in OBS eingebaute ist je nach Version aelter. Hoehen animiert jeder
   Browser. */
#main-grid {
  display: flex;
  flex-direction: column;
  padding: 2vh 4vh;
  box-sizing: border-box;
  height: 100vh;
  width: 100%;
  gap: 1vh;
}

/* --- MODERATIONSANSICHT ---------------------------------------------
   Host gross, Spieler als schmale Leiste unten, Antwort-Boards und
   Namensschilder weg. Fuer Anmoderation und Abmoderation. */
.host-focus .question-section {
  height: 0;
  opacity: 0;
  overflow: hidden;
}

.host-focus .answer-board {
  max-height: 0;
  opacity: 0;
  border-top-width: 0;
}

.host-focus .player-info {
  max-height: 0;
  min-height: 0;
  padding-top: 0;
  padding-bottom: 0;
  opacity: 0;
  border-top-width: 0;
}

/* Waehrend der Moderation sind Spielstands-Anzeigen fehl am Platz. */
.host-focus .tendency-row,
.host-focus .imposter-frame,
.host-focus #timer-overlay {
  opacity: 0;
}

/* --- REIHE 1: HOST & HEADER --- */
.top-section {
  display: flex;
  justify-content: center;
  position: relative;
  width: 100%;
  height: 25vh;
  flex: 0 0 auto;
  transition: height 0.75s cubic-bezier(0.65, 0, 0.35, 1);
}

/* 74vh Kopfbereich lassen bei 4vh Padding und 2vh Abstaenden genau 20vh
   fuer die Spielerleiste. */
.host-focus .top-section {
  height: 74vh;
}

.logo-area {
  position: absolute;
  top: 0; left: 0;
  height: 100%; 
  max-height: 120px;
  filter: drop-shadow(0 0 10px rgba(138, 43, 226, 0.5));
  z-index: 10;
}
.logo-area img { height: 100%; width: auto; object-fit: contain;}

.socials-area {
  position: absolute;
  top: 0; right: 0;
  display: flex;
  flex-direction: column;
  gap: 5px;
  align-items: flex-end;
  z-index: 10;
}

.social-pill {
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(5px);
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 500;
  border-left: 3px solid #8a2be2;
  color: #eee;
  display: flex;
  align-items: center;
  gap: 8px;
}
.social-pill strong { color: white; }

/* Host Cam */
.host-cam-wrapper {
  height: 100%;
  aspect-ratio: 16/9;
  /* Damit die Kamera in der Moderationsansicht nicht breiter wird als
     der Bildschirm. */
  max-width: 100%;
  border: 3px solid #8a2be2;
  border-radius: 12px;
  overflow: hidden;
  background: black;
  box-shadow: 0 0 30px rgba(0, 0, 0, 0.8);
  z-index: 5;
  position: relative;
  transition: box-shadow 0.75s ease;
}

.host-focus .host-cam-wrapper {
  box-shadow: 0 0 60px rgba(138, 43, 226, 0.45), 0 0 30px rgba(0, 0, 0, 0.8);
}

.host-name-tag {
  position: absolute;
  bottom: -15px; /* Etwas tiefer hängen */
  left: 50%;
  transform: translateX(-50%);
  background: #8a2be2;
  color: white;
  padding: 2px 12px;
  border-radius: 4px;
  font-weight: bold;
  font-size: 0.9rem;
  box-shadow: 0 2px 5px rgba(0,0,0,0.5);
  text-transform: uppercase;
  z-index: 20;
}

/* --- REIHE 2: FRAGE --- */
.question-section {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  height: 15vh;
  flex: 0 0 auto;
  overflow: visible; /* Damit Schatten nicht abgeschnitten werden */
  transition: height 0.75s cubic-bezier(0.65, 0, 0.35, 1), opacity 0.45s ease;
}

.main-question {
  background: rgba(10, 10, 15, 0.95);
  border: 1px solid rgba(138, 43, 226, 0.3);
  padding: 10px 30px;
  font-size: 2.2rem; 
  font-weight: 700;
  text-align: center;
  width: 80%;
  border-radius: 12px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.7);
  opacity: 0;
  transition: opacity 0.5s, transform 0.5s;
  text-transform: uppercase;
  transform: translateY(20px);
  color: #fff;
  text-shadow: 0 2px 4px rgba(0,0,0,0.8);
}

.main-question.visible { opacity: 1; transform: translateY(0); }

.question-stack {
  width: 80%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.question-stack .main-question { width: 100%; }

/* Erscheint, sobald jemand seinen Joker zieht. */
.joker-question {
  background: rgba(255, 215, 0, 0.12);
  border: 1px solid rgba(255, 215, 0, 0.45);
  padding: 8px 22px;
  font-size: 1.5rem;
  font-weight: 700;
  text-align: center;
  border-radius: 10px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.6);
  color: #ffd700;
  text-transform: uppercase;
  text-shadow: 0 2px 4px rgba(0,0,0,0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  opacity: 0;
  transform: translateY(-12px);
  transition: opacity .4s, transform .4s;
  pointer-events: none;
}
.joker-question.visible {
  opacity: 1;
  transform: translateY(0);
  animation: joker-glow 1.4s ease-in-out infinite alternate;
}
.joker-tag {
  background: #ffd700;
  color: #1a1a00;
  font-size: .8rem;
  padding: 3px 10px;
  border-radius: 5px;
  white-space: nowrap;
  flex-shrink: 0;
}
@keyframes joker-glow {
  from { box-shadow: 0 8px 30px rgba(0,0,0,.6), 0 0 12px rgba(255,215,0,.25); }
  to   { box-shadow: 0 8px 30px rgba(0,0,0,.6), 0 0 34px rgba(255,215,0,.6); }
}

/* Zeigt, dass dieser Spieler seinen Joker noch hat. Verschwindet, sobald
   er gezogen wurde. */
.joker-badge {
  display: none;
  font-size: 0.95rem;
  line-height: 1;
  margin-left: 6px;
  flex-shrink: 0;
  filter: drop-shadow(0 0 5px rgba(255, 215, 0, 0.85));
}
.joker-badge.available {
  display: inline-block;
}

/* --- TENDENZEN --- */
/* Profilbilder derjenigen, die gerade auf diesen Spieler tippen.
   Sie liegen am unteren Rand der Kamera statt im Namensschild: dort haben
   sie den Namen bei langen Nicks und mehreren Tippgebern auf null Breite
   gequetscht. */
.tendency-row {
  position: absolute;
  left: 6px;
  bottom: 6px;
  right: 6px;
  display: flex;
  gap: 4px;
  align-items: flex-end;
  flex-wrap: wrap;
  z-index: 6;
  pointer-events: none;
  transition: opacity 0.4s ease;
}
.tendency-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid #ffd700;
  background: #222;
  box-shadow: 0 0 10px rgba(0, 0, 0, .9), 0 0 10px rgba(255, 215, 0, .5);
  animation: tendency-pop .3s ease;
}
@keyframes tendency-pop {
  from { transform: scale(0); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}

/* --- REIHE 3: SPIELER --- */
.players-row {
  display: grid;
  /* Spaltenzahl kommt vom Server (3 bis 6). Die Reihe staucht sich,
     bricht aber nie um. Bei 4 Spielern identisch zu vorher. */
  grid-template-columns: repeat(var(--slot-count, 4), 1fr);
  gap: 15px;
  align-items: stretch;
  /* Nimmt den Rest und folgt damit weich der Hoehenaenderung oben. */
  flex: 1 1 auto;
  min-height: 0;
}

.player-slot {
  display: flex;
  flex-direction: column;
  background: rgba(20, 20, 20, 0.6);
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.05);
  overflow: hidden;
  box-shadow: 0 8px 25px rgba(0,0,0,0.6);
  height: 100%; /* Füllt die Zelle aus */
  max-height: 100%;
  position: relative;
}

/* Die Kamera nimmt den Platz, der nach Antwort-Board und Namensleiste
   uebrig bleibt. Kein festes 16:9 mehr: bei drei breiten Karten lief der
   Inhalt sonst unten heraus und die Namen wurden abgeschnitten, bei fuenf
   oder sechs schmalen blieb oben eine graue Flaeche stehen. */
.cam-area {
  width: 100%;
  background: #000;
  flex: 1 1 auto;
  min-height: 0;
  position: relative;
  overflow: hidden;
}

.cam-wrapper {
  position: absolute;
  inset: 0;
  overflow: hidden;
}

/* Das Video behaelt sein 16:9 und wird so vergroessert, dass es die ganze
   Flaeche ausfuellt - ueberstehende Raender werden beschnitten statt
   schwarze Balken zu zeigen. */
.cam-wrapper iframe {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 100%;
  height: 100%;
  min-width: 100%;
  min-height: 100%;
  aspect-ratio: 16/9;
  border: none;
}

iframe { width: 100%; height: 100%; border: none; }

.answer-board {
  width: 100%;
  aspect-ratio: 16/9;
  /* Deckelt die Hoehe bei breiten Karten, damit Kamera und Namensleiste
     nicht herausgedrueckt werden. */
  max-height: 42%;
  background: white;
  display: flex;
  justify-content: center;
  align-items: center;
  border-top: 3px solid #8a2be2;
  position: relative;
  overflow: hidden;
  flex: 0 1 auto;
  min-height: 0;
  transition: max-height 0.75s cubic-bezier(0.65, 0, 0.35, 1),
              opacity 0.4s ease,
              border-top-width 0.4s ease;
}

.answer-cover {
  position: absolute;
  top: 0; left: 0; width: 100%; height: 100%;
  background: #151515;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 3rem;
  color: #444;
  transition: transform 0.6s cubic-bezier(0.68, -0.55, 0.27, 1.55);
  transform-origin: top;
  z-index: 2;
  background-image: radial-gradient(#333 1px, transparent 1px);
  background-size: 15px 15px;
}
.answer-cover.open { transform: scaleY(0); }
.answer-board img { width: 100%; height: 100%; object-fit: contain; z-index: 1; }

/* Versetzt aufklappen, damit "Alle aufdecken" nacheinander laeuft
   statt alle Boards gleichzeitig umzuschlagen. */
.player-slot:nth-child(1) .answer-cover { transition-delay: 0ms; }
.player-slot:nth-child(2) .answer-cover { transition-delay: 150ms; }
.player-slot:nth-child(3) .answer-cover { transition-delay: 300ms; }
.player-slot:nth-child(4) .answer-cover { transition-delay: 450ms; }
.player-slot:nth-child(5) .answer-cover { transition-delay: 600ms; }
.player-slot:nth-child(6) .answer-cover { transition-delay: 750ms; }

/* ... (Dein bisheriger CSS Code für .player-slot, .cam-wrapper etc. bleibt) ... */

/* UPDATE FÜR DIE INFO-LEISTE */
/* Padding, Abstand, Bildgroesse und Schrift schrumpfen mit steigender
   Spielerzahl - sonst bleibt bei sechs schmalen Karten kaum Platz fuer
   den Namen. */
.player-info {
  background: #0a0a0a;
  padding: 8px calc(15px - (var(--slot-count, 4) - 4) * 3px);
  display: flex;
  align-items: center; /* Vertikal zentrieren */
  gap: calc(12px - (var(--slot-count, 4) - 4) * 2px);
  border-top: 1px solid #333;
  color: white;
  flex-shrink: 0;
  min-height: 50px; /* Etwas höher für das Bild */
  max-height: 90px;
  overflow: hidden;
  z-index: 10;
  transition: max-height 0.75s cubic-bezier(0.65, 0, 0.35, 1),
              min-height 0.75s cubic-bezier(0.65, 0, 0.35, 1),
              padding 0.75s cubic-bezier(0.65, 0, 0.35, 1),
              opacity 0.4s ease,
              border-top-width 0.4s ease;
}

/* DAS NEUE PROFILBILD */
.player-avatar {
  width: calc(38px - (var(--slot-count, 4) - 4) * 4px);
  height: calc(38px - (var(--slot-count, 4) - 4) * 4px);
  border-radius: 50%; /* Macht es rund */
  object-fit: cover;
  border: 2px solid #8a2be2; /* Lila Rand passend zum Design */
  background: #222; /* Fallback Farbe */
  flex-shrink: 0;
}

.player-name {
    font-size: calc(1.2rem - (var(--slot-count, 4) - 4) * 0.1rem);
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}
/* Drückt den Score nach ganz rechts, die Tendenzen bleiben beim Namen */
.player-info .spacer { margin-left: auto; }

.score-badge {
    color: #ffd700;
    font-family: 'VT323', monospace;
    font-size: calc(1.8rem - (var(--slot-count, 4) - 4) * 0.15rem);
    line-height: 1;
    flex-shrink: 0;
}

/* --- TIMER STYLE --- */
#timer-overlay {
    position: absolute;
    top: 12vh; /* Höhe anpassen, damit er zwischen Header und Frage passt */
    left: 4vh; /* Exakt der gleiche Abstand wie das Main-Grid Padding */
    transform: translateY(-50%); /* Nur noch vertikal zentrieren */
    background: rgba(220, 0, 0, 0.9);
    color: white;
    padding: 10px 30px; /* Etwas kompakter */
    font-size: 3rem;    /* Etwas kleiner, damit es links gut aussieht */
    font-family: 'Rubik', sans-serif;
    font-weight: 700;
    border-radius: 12px;
    box-shadow: 0 0 30px rgba(255, 0, 0, 0.5);
    z-index: 100;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.5s ease-in-out;
    border: 2px solid white;
}

#timer-overlay.active {
    opacity: 1;
    animation: pulse 1s infinite alternate;
}

@keyframes pulse {
    from { box-shadow: 0 0 20px rgba(255, 0, 0, 0.4); }
    to { box-shadow: 0 0 60px rgba(255, 0, 0, 0.9); }
}

/* Update für Buttons im Admin Panel damit die neuen Minus-Knöpfe passen */
.btn-dark { padding: 5px 8px; font-size: 0.8rem; }

/* ... (Dein restlicher CSS Code bleibt oben gleich) ... */

/* ... (Dein restlicher CSS Code bleibt) ... */

/* --- IMPOSTER REVEAL (Die "Hammer"-Methode) --- */

/* 2. Der Rahmen selbst */
.imposter-frame {
    position: absolute; /* Legt sich über den Slot */
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 9999; /* Ganz oben */
    pointer-events: none; /* Klicks gehen durch */

    /* Der rote Look */
    border: 8px solid #ff0000;
    border-radius: 12px; /* Muss exakt zum Slot-Radius passen */
    box-sizing: border-box; /* Wichtig, damit der Rand INNEN ist */

    opacity: 0; /* Unsichtbar starten */
    transition: opacity 0.3s ease;
}

/* Wenn der Slot "is-imposter" ist, wird der Rahmen sichtbar und pulsiert */
.player-slot.is-imposter .imposter-frame {
    opacity: 1;
    animation: danger-pulse 1s infinite alternate;
}

/* Roter Hintergrund für den Namen */
.player-slot.is-imposter .player-info {
    background-color: #500000 !important;
    color: #ffcccc !important;
    position: relative;
    z-index: 10000;
}

@keyframes danger-pulse {
    from { box-shadow: inset 0 0 20px rgba(255, 0, 0, 0.3); border-color: #aa0000; }
    to { box-shadow: inset 0 0 60px rgba(255, 0, 0, 0.8); border-color: #ff0000; }
}
