/* ===========================================================
   💎 Diamonds Scoreboard Display (v5)
   - Fix: Score immer zentriert (CSS Grid)
   - Lange Teamnamen mit Ellipsis
   - iPad / Tablet / Mobile optimiert
   =========================================================== */

body {
  margin: 0;
  padding: 0;
  font-family: 'Arial', sans-serif;
  background-color: #111;
  color: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  height: calc(var(--vh, 1vh) * 100);
  overflow: hidden;
}

/* === HEADER === */
#scoreboard-header {
  display: grid;
  grid-template-columns: 1fr auto 1fr; /* Links – Mitte – Rechts */
  align-items: center;
  background-color: #111;
  border-bottom: 3px solid #eb73af;
  color: white;
  padding: 10px 20px;
  width: 100%;
  box-sizing: border-box;
  top: 0;
  z-index: 10;
}

/* Seitencontainer (Teams) */
#scoreboard-header .team-side {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0; /* verhindert Flex-Überlauf */
}
#scoreboard-header .home-side { justify-content: flex-start; }
#scoreboard-header .guest-side { justify-content: flex-end; text-align: right; }

/* Logos */
#scoreboard-header .team-logo {
  width: clamp(50px, 7vw, 70px);
  height: clamp(50px, 7vw, 70px);
  border-radius: 50%;
  background-size: cover;
  background-position: center;
  background-color: #333;
}

/* Teamnamen */
#scoreboard-header .team-name {
  font-size: clamp(1.2rem, 1.5vw + 0.5vh, 2.2rem);
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 35vw; /* zu lange Namen werden abgekürzt */
}

/* Score immer exakt zentriert */
#scoreboard-header .score-center {
  justify-self: center;  /* echte Zentrierung im Grid */
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 15px;
  font-size: clamp(2rem, 3vw + 1vh, 4.5rem);
  font-weight: 700;
  color: #eb73af;
}

/* === TEAMS-CONTAINER === */
.teams-container {
  display: flex;
  justify-content: space-between;
  align-items: stretch;
  width: 95%;
  flex: 1;
  gap: 20px;
  margin-top: 10px;
  overflow: hidden;
  max-height: calc(var(--vh, 1vh) * 100 - 135px);
  padding-bottom: 6px;
  box-sizing: border-box;
}

/* === TEAM === */
.team {
  flex: 1 1 0;
  display: flex;
  flex-direction: column;
  background-color: #222;
  border-radius: 20px;
  padding: 15px;
  min-height: 0;
  overflow: hidden;
}

/* === SPIELERLISTE === */
.players {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 3px;
  scrollbar-width: thin;
  scrollbar-color: #666 #222;
  padding-bottom: 6px;
}
.players::-webkit-scrollbar { width: 8px; }
.players::-webkit-scrollbar-thumb {
  background-color: #666;
  border-radius: 4px;
}

/* Kopfzeile */
.player-header {
  display: grid;
  grid-template-columns: 0.6fr 2fr 0.7fr 0.7fr;
  font-weight: bold;
  font-size: clamp(0.9rem, 0.8vw + 0.5vh, 1.4rem);
  background-color: #444;
  color: #eb73af;
  border-radius: 10px;
  padding: 6px 8px;
  text-align: center;
  position: sticky;
  top: 0;
  z-index: 5;
}

/* Spielerzeilen */
.player {
  display: grid;
  grid-template-columns: 0.6fr 2fr 0.7fr 0.7fr;
  align-items: center;
  background-color: #333;
  border-radius: 10px;
  padding: 2px 6px;
  font-size: clamp(0.85rem, 0.75vw + 0.5vh, 1.5rem);
  min-height: 2.6rem;
}
.player span:nth-child(2),
.player-header span:nth-child(2) {
  text-align: left;
  padding-left: 8px;
}
.player span { text-align: center; }

/* Reserve-Raum für letzte Zeile */
.players::after {
  content: "";
  flex-grow: 0.02;
}

/* === FOULFARBEN === */
.fouls {
  text-align: center;
  padding: 4px 1px;
  border-radius: 5px;
  display: inline-block;
  width: 100%;
}
.fouls.foul-3 { background: yellow; font-weight: bold; color: black; }
.fouls.foul-4 { background: orange; font-weight: bold; color: white; }
.fouls.foul-5 { background: red; font-weight: bold; color: white; }

/* === RESPONSIVE === */

/* Tablet / iPad */
@media (max-width: 1024px) {
  .teams-container {
    width: 100%;
    gap: 10px;
    max-height: calc(100dvh - 120px);
  }
  .player {
    font-size: 0.9rem;
    min-height: 2.4rem;
  }
}

/* Smartphone */
@media (max-width: 700px) {
  body { overflow: auto; height: auto; }

  #scoreboard-header {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 10px;
  }

  #scoreboard-header .score-center {
    justify-self: unset;
    position: static;
    transform: none;
    order: -1;
    font-size: 2.2rem;
  }

  #scoreboard-header .team-logo {
    width: 50px;
    height: 50px;
  }
  #scoreboard-header .team-name {
    font-size: 1.2rem;
    max-width: 80vw;
  }

  .teams-container {
    flex-direction: column;
    width: 95%;
    max-height: none;
    overflow: visible;
    margin-top: 15px;
  }

  .team {
    height: auto;
    min-height: 340px;
    overflow: visible;
  }

  .players {
    max-height: 45vh;
    overflow-y: auto;
  }
}
