/* =======================================================================================
    CSS-STILE & LAYOUT (Basics)
    ======================================================================================= */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Arial', sans-serif;
    background: #2c3e50;
    min-height: 100vh;
}

#main-wrapper {
    background: white;
    min-height: 100vh;
    /* NEU: WICHTIG! Fügt Platz am unteren Ende hinzu, um das STICKY-FOOTER-Panel aufzunehmen. */
    /* Muss manuell angepasst werden, basierend auf der Höhe des #selection-panel in seinem kleinsten Zustand. */
    /* Geschätzte Höhe des Buttons + 2x py-3 + margin-bottom: ca. 80px */
    padding-bottom: 80px;
}

/* --- Live-Ticker Sektion (Dynamisches Grid) --- */

#live-ticker-container {
    background: #ecf0f1;
    padding: 15px;
}

.live-event-title {
    background: #3498db;
    color: white;
    padding: 8px 15px;
    margin: 10px 0 10px 0;
    font-size: 1em;
    font-weight: bold;
    text-align: left;
}

.live-matches-grid {
    display: grid;
    /* Mindestbreite 350px */
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 15px;
}

/* --- Match-Panel-Stile --- */

.match-card {
    background: white;
    border: 1px solid #bdc3c7;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    /* Basisschriftgröße für relative Em-Werte */
    font-size: 1.5em;
    display: flex;
    flex-direction: column;
    height: 100%;
    transition: border-top 0.3s ease;
}

/* Status-Markierung */
.match-card.active {
    border-top: 5px solid #2ecc71;
}

.match-card.finished {
    border-top: 5px solid #e74c3c;
    opacity: 0.95;
}

.match-card.coming-soon {
    border-top: 5px solid #f39c12;
    opacity: 1;
}


/* Panel Header */
.match-panel-header {
    background: #34495e;
    color: white;
    padding: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
    min-height: 48px;
    /* Header Schrift leicht skalierend */
    font-size: clamp(0.7em, 0.6em + 0.5vw, 1em);
}

.match-panel-header .board-info {
    font-weight: bold;
    position: absolute;
    left: 10px;
}

.match-panel-header .group-info {
    flex-grow: 1;
    text-align: center;
    padding: 0 50px;
}

.match-panel-header .group-name {
    font-size: 1em;
    font-weight: bold;
}

.match-panel-header .match-mode {
    font-size: 0.8em;
    color: #bdc3c7;
}

.match-panel-header .status-info {
    position: absolute;
    right: 10px;
    font-size: 1em;
    font-weight: bold;
}


/* Panel Content: Scores */
.match-panel-content {
    padding: 15px 0 5px 0;
}

.player-score-layout {
    width: 100%;
    table-layout: fixed;
    border-collapse: collapse;
}

.player-score-layout td {
    padding: 0;
    text-align: center;
}

.player-score-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    padding: 5px;
}

/* Flex-Container für Hauptpunkte und Letzter Wurf */
.score-display-row {
    display: flex;
    align-items: baseline;
    justify-content: center;
    gap: 10px;
    padding: 5px 0;
    /* Stellt sicher, dass die Zeile mindestens die Höhe des Sieger-Textes hat */
    min-height: 2.5rem;
}

/* Fluid Font: Player Name */
.match-player-name {
    font-size: clamp(0.9em, 0.7em + 0.5vw, 1.3em);
    padding: 5px 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
    color: #2c3e50;
    min-height: 25px;
}

/* Anpassung des letzten Wurfs (Rechts vom Score) */
.match-points-last {
    font-size: 1.5em;
    color: #7f8c8d;
    height: auto;
    align-self: flex-end;
    line-height: 1;
    white-space: nowrap;
}

/* Anpassung des Hauptscores (Links des letzten Wurfs) */
.match-points {
    font-size: clamp(2.8rem, 2rem + 2.5vw, 4.5rem);
    color: #130c0bff;
    line-height: 1;
    font-weight: bold;
}

/* Stil für den Winner-Text */
.match-winner-status {
    /* Fluid Typography mit Clamp zur Skalierungsbegrenzung */
    font-size: clamp(1.8rem, 1.5rem + 1vw, 2.5rem);
    color: #2ecc71;
    /* Grün */
    line-height: 1;
    font-weight: bold;
    padding: 10px 0;
}

/* Stil für den Loser-Text (Rot zur Unterscheidung) */
.match-loser-status {
    font-size: clamp(1.8rem, 1.5rem + 1vw, 2.5rem);
    color: #e74c3c;
    /* Rot */
    line-height: 1;
    font-weight: bold;
    padding: 10px 0;
}

/* Aktiver Spieler mit Grüner Umrandung */
.active-player-score {
    background-color: #ecf0f1;
    border: 3px solid #2c3e50;
    border-radius: 4px;
}

.active-player-score .match-player-name {
    color: #3498db;
}

/* --- Match Footer: Stats --- */
.match-footer-stats {
    padding: 5px 10px 10px 10px;
    border-top: 1px solid #bdc3c7;
    margin-top: auto;
    font-size: clamp(0.75em, 0.7em + 0.2vw, 0.9em);
}

.stats-layout {
    width: 100%;
    table-layout: fixed;
    text-align: center;
    border-collapse: collapse;
}

.stats-layout td {
    padding: 0 5px;
    width: 50%;
}

.player-stats-table {
    width: 100%;
    border-collapse: collapse;
    color: #34495e;
}

.player-stats-table thead td {
    font-weight: bold;
    padding: 5px 0 2px 0;
    border-bottom: 1px solid #bdc3c7;
}

.player-stats-table .tableStatsValues td {
    padding: 2px 0;
    font-weight: bold;
}

.player-stats-table.right thead td {
    direction: rtl;
}

/* --- Selection Panel (Sticky Footer) --- */

#selection-panel {
    /* NEU: Fixiert das Panel unten */
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    /* Hebt es über andere Inhalte */
    z-index: 1000;
    /* Stellt sicher, dass das Panel die volle Breite hat */
    width: 100%;
    /* Animation der Höhe (für #selection-content) ist wichtig, um den Übergang zu glätten */
    transition: height 0.4s ease-out;
    /* Der Hintergrund wird hier definiert */
    background-color: #f8f9fa;
    border-top: 1px solid #dee2e6;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
}

#selection-panel .container-xl {
    /* Begrenzt die Breite auf das Haupt-Layout */
    max-width: 1200px;
    margin: 0 auto;
}

#selection-panel .list-group-item:hover {
    cursor: pointer;
    background-color: #f8f9fa;
}

/* NEUE CSS FÜR DEN POP-UP EFFEKT (Übergang) */
#selection-content {
    /* Startzustand: Höhe Null, Padding Null, Inhalt versteckt */
    max-height: 0;
    overflow-y: auto;
    /* Scrollbar, wenn geöffneter Inhalt zu lang ist */
    padding-top: 0 !important;
    padding-bottom: 0 !important;
    /* Fügt eine 0.4 Sekunden lange Animation für die Höhe und das Padding hinzu */
    transition: max-height 0.4s ease-out, padding 0.4s ease-out;
}

#selection-content.open {
    /* Endzustand: Große Höhe, um den Inhalt anzuzeigen, gewünschtes Padding */
    max-height: 50vh;
    /* Begrenzt die Höhe des Panels, wenn es geöffnet ist, auf max 50% der Viewporthöhe */
    padding-top: 5px !important;
    padding-bottom: 5px !important;
}

.stats-section .btn-outline-secondary {
    border-color: #bdc3c7;
    color: #7f8c8d;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background: #f8f9fa;
}

.stats-section .btn-outline-secondary:hover {
    background: #ecf0f1;
    color: #2c3e50;
}

.stats-section .table {
    margin-bottom: 0;
    border-radius: 4px;
    overflow: hidden;
    font-size: 0.9rem;
}

.stats-section .table thead th {
    font-weight: 600;
    padding: 8px;
    background: #34495e;
}

.stats-section .table td {
    padding: 6px 8px;
    vertical-align: middle;
}

.btn-stats-toggle {
    background-color: #34495e;
    color: #3498db;
    border: 1px solid #3498db;
    width: 100%;
    margin-top: 5px;
    padding: 8px;
    font-weight: bold;
    text-transform: uppercase;
    font-size: 0.75rem;
}

.stats-table-container {
    background: white;
    border: 1px solid #dee2e6;
    margin-bottom: 15px;
}

.stats-table-container th {
    background-color: #2c3e50 !important;
    color: white !important;
}
#live-ticker-container.container-fluid {
    padding: 0 !important;
}