/* =========================================================
   GRUNDLAYOUT
   ========================================================= */

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 16px;

    background: #f3f4f6;
    color: #1f2937;

    font-family: Arial, Helvetica, sans-serif;
}

.container {
    max-width: 1100px;
    margin: 0 auto;
}


/* =========================================================
   SEITENKOPF
   ========================================================= */

.page-header {
    display: grid;

    grid-template-columns:
        minmax(0, 1fr)
        minmax(0, 2fr);

    align-items: center;
    gap: 30px;

    margin-bottom: 14px;
}

.page-title h1 {
    margin: 0;

    font-size: 28px;
    line-height: 1.15;
}

.tournament-info {
    color: #6b7280;

    font-size: 14px;
    line-height: 1.4;
}

.tournament-info strong {
    color: #374151;

    font-size: 15px;
}


/* =========================================================
   HAUPTLAYOUT
   ========================================================= */

.main-layout {
    display: grid;

    grid-template-columns:
        190px
        minmax(0, 1fr);

    gap: 16px;

    align-items: start;
}


/* =========================================================
   SPIELERBEREICH
   ========================================================= */

.player-panel {
    overflow: hidden;

    background: #ffffff;

    border-radius: 8px;

    box-shadow:
        0 1px 3px rgba(0, 0, 0, 0.08);
}

.player-selection {
    padding: 10px;
}


/* =========================================================
   SPIELER-KOPF
   ========================================================= */

.panel-header {
    display: flex;

    align-items: center;
    justify-content: space-between;

    gap: 6px;

    margin-bottom: 8px;
}

.panel-header h2 {
    margin: 0;

    font-size: 16px;
    line-height: 1.2;
}


/* =========================================================
   ALLE / KEINE BUTTONS
   ========================================================= */

.player-buttons {
    display: flex;

    gap: 4px;
}

.player-buttons button {
    padding: 3px 6px;

    border: 1px solid #d1d5db;
    border-radius: 4px;

    background: #f9fafb;
    color: #374151;

    font-size: 11px;

    cursor: pointer;
}

.player-buttons button:hover {
    background: #e5e7eb;
}


/* =========================================================
   SPIELERLISTE
   ========================================================= */

.player-list {
    display: flex;
    flex-direction: column;

    gap: 1px;
}

.player-list label {
    display: flex;

    align-items: center;

    gap: 5px;

    padding: 2px 1px;

    color: #374151;

    font-size: 12px;
    line-height: 1.25;

    cursor: pointer;
}

.player-list label:hover {
    background: #f3f4f6;
}


.player-list input[type="checkbox"] {
    flex: 0 0 auto;

    width: 14px;
    height: 14px;

    margin: 0;

    appearance: none;
    -webkit-appearance: none;

    border: 1px solid #b8bcc2;
    border-radius: 3px;

    background: #e5e7eb;

    cursor: pointer;

    position: relative;
}


/* Ausgewählt */

.player-list input[type="checkbox"]:checked {
    background: #9ca3af;
    border-color: #6b7280;
}


/* Häkchen */

.player-list input[type="checkbox"]:checked::after {
    content: '';

    position: absolute;

    left: 3px;
    top: 0px;

    width: 5px;
    height: 9px;

    border: solid #ffffff;
    border-width: 0 2px 2px 0;

    transform: rotate(45deg);
}


/* Tastaturfokus */

.player-list input[type="checkbox"]:focus-visible {
    outline: 2px solid #9ca3af;
    outline-offset: 1px;
}



/* =========================================================
   MOBILER EINKLAPP-BUTTON
   ========================================================= */

.player-panel-toggle {
    display: none;

    width: 100%;

    align-items: center;
    justify-content: space-between;

    padding: 8px 10px;

    border: 0;

    background: #111827;
    color: #ffffff;

    font-size: 14px;
    font-weight: bold;

    text-align: left;

    cursor: pointer;
}

.player-toggle-arrow {
    font-size: 17px;
    line-height: 1;

    transition: transform 0.15s ease;
}

.player-panel.collapsed .player-toggle-arrow {
    transform: rotate(-90deg);
}

.player-panel.collapsed .player-selection {
    display: none;
}


/* =========================================================
   RECHTE SPALTE
   ========================================================= */

.results-panel {
    min-width: 0;
}


/* =========================================================
   TAG-AUSWAHL
   ========================================================= */

.day-selection {
    display: flex;

    align-items: center;

    gap: 8px;

    margin-bottom: 10px;
}

.day-selection label {
    font-size: 13px;
    font-weight: bold;

    white-space: nowrap;
}

.day-selection select {
    max-width: 100%;

    padding: 6px 8px;

    border: 1px solid #d1d5db;
    border-radius: 5px;

    background: #ffffff;
    color: #1f2937;

    font-size: 13px;

    cursor: pointer;
}


/* =========================================================
   STATUS
   ========================================================= */

#status {
    margin-bottom: 8px;

    color: #6b7280;

    font-size: 12px;
    line-height: 1.3;
}


/* =========================================================
   LADEANZEIGE
   ========================================================= */

.status-loading {
    display: flex;

    align-items: center;

    gap: 10px;

    padding: 14px 16px;
    margin-bottom: 16px;

    border: 1px solid #c9dcf7;
    border-radius: 8px;

    background: #eef5ff;
    color: #245a8d;

    font-size: 1rem;
}

.loading-spinner {
    flex: 0 0 18px;

    width: 18px;
    height: 18px;

    border: 3px solid #c9dcf7;
    border-top-color: #2878bd;
    border-radius: 50%;

    animation: loading-spin 0.9s linear infinite;
}

.loading-text {
    font-weight: 600;
}

.loading-hint {
    color: #64809a;

    font-size: 0.9rem;
}

@keyframes loading-spin {
    to {
        transform: rotate(360deg);
    }
}


/* =========================================================
   ZEITBLÖCKE
   ========================================================= */

.match-group {
    margin-bottom: 10px;

    overflow: hidden;

    background: #ffffff;

    border-radius: 7px;

    box-shadow:
        0 1px 3px rgba(0, 0, 0, 0.07);
}

.match-group h2 {
    margin: 0;

    padding: 5px 10px;

    background: #111827;
    color: #ffffff;

    font-size: 17px;
    line-height: 1.15;
}


/* =========================================================
   EINZELNES MATCH
   ========================================================= */

.match {
    padding: 6px 10px;

    border-bottom: 1px solid #e5e7eb;
}

.match:last-child {
    border-bottom: 0;
}


/* =========================================================
   SPIELER IM MATCH
   ========================================================= */

.match-players {
    display: grid;

    grid-template-columns:
        minmax(0, 1fr)
        20px
        minmax(0, 1fr);

    align-items: center;

    gap: 5px;

    font-size: 14px;
    line-height: 1.2;
}

.match-players strong {
    font-weight: 600;
}

.match-players strong.opponent {
    color: #707070;
    font-weight: 400;
}

.match-players strong:first-child {
    text-align: right;
}

.match-players strong:last-child {
    text-align: left;
}

.versus {
    color: #9ca3af;

    font-weight: normal;

    text-align: center;
}


/* =========================================================
   SPIELER-DARSTELLUNG
   ========================================================= */

.selected-winner,
.selected-loser {
    color: #1f2937;

    font-weight: 700;
}


/* =========================================================
   PERFORMANCE-SYMBOLE
   ========================================================= */

/*
   Jedes Symbol besteht aus:

       farbiges Quadrat
       + weißes Dreieck

   Die Symbole werden direkt hintereinander dargestellt.

   WICHTIG:
   Keine feste Breite von 18px und kein großer margin-right.
   Dadurch bleibt die Darstellung auch bei vielen Spielen kompakt.
*/

.performance-symbol {
    display: inline-flex;

    width: 9px;
    height: 9px;

    margin-right: 0px;

    align-items: center;
    justify-content: center;

    vertical-align: middle;

    border-radius: 0px;
}


/* ---------------------------------------------------------
   Hintergrundfarben
   --------------------------------------------------------- */

.performance-win {
    background-color: #198754;
}

.performance-lost {
    background-color: #dc3545;
}

.performance-bye {
    background-color: #999999;
}


/* ---------------------------------------------------------
   Pfeile
   --------------------------------------------------------- */

.performance-arrow {
    display: block;

    width: 0;
    height: 0;

    background: transparent;
}


/* Pfeil nach oben – Sieg */

.performance-arrow-up {
    border-right: 3px solid transparent;
    border-bottom: 5px solid #ffffff;
    border-left: 3px solid transparent;
}


/* Pfeil nach unten – Niederlage */

.performance-arrow-down {
    border-top: 5px solid #ffffff;
    border-right: 3px solid transparent;
    border-left: 3px solid transparent;
}


/* Pfeil nach rechts – Bye / Walkover gewonnen */

.performance-arrow-right {
    border-top: 3px solid transparent;
    border-bottom: 3px solid transparent;
    border-left: 5px solid #ffffff;
}


/* Pfeil nach links – Walkover verloren */

.performance-arrow-left {
    border-top: 3px solid transparent;
    border-right: 5px solid #ffffff;
    border-bottom: 3px solid transparent;
}


/* =========================================================
   GESAMTERGEBNIS
   ========================================================= */

.match-result {
    display: inline-block;

    padding: 1px 4px;

    border-radius: 3px;

    font-weight: 700;
}

.match-result.result-won {
    background: #dcfce7;
    color: #166534;
}

.match-result.result-lost {
    background: #fee2e2;
    color: #991b1b;
}


/* =========================================================
   SATZERGEBNISSE
   ========================================================= */

.match-score {
    margin-left: 3px;

    color: #9ca3af;

    font-size: 9px;
    font-weight: normal;
}


/* =========================================================
   ZUSATZINFORMATIONEN
   ========================================================= */

.match-info {
    display: flex;

    justify-content: center;

    gap: 8px;

    margin-top: 2px;

    color: #6b7280;

    font-size: 10px;
    line-height: 1.2;
}

.match-info span:first-child {
    color: #9ca3af;
}

.match-info span:last-child {
    color: #4b5563;

    font-weight: 600;
}


/* =========================================================
   LIVE-COURT PUNKTE
   ========================================================= */

.live-dot {
    display: inline-block;

    width: 9px;
    height: 9px;

    margin-left: 7px;
    margin-right: 7px;

    background-color: #ffb300;

    border-radius: 50%;

    vertical-align: middle;

    animation: liveDotPulse 1.6s ease-in-out infinite;

    box-shadow:
        0 0 4px rgba(255, 179, 0, 0.75),
        0 0 9px rgba(255, 179, 0, 0.45);
}

.live-dot-after {
    animation-delay: 0.8s;
}


@keyframes liveDotPulse {

    0%,
    100% {
        opacity: 0.45;
        transform: scale(0.85);

        box-shadow:
            0 0 3px rgba(255, 179, 0, 0.45),
            0 0 6px rgba(255, 179, 0, 0.25);
    }

    50% {
        opacity: 1;
        transform: scale(1.25);

        box-shadow:
            0 0 6px rgba(255, 179, 0, 0.95),
            0 0 14px rgba(255, 179, 0, 0.70);
    }
}



/* =========================================================
   MOBILE
   ========================================================= */

@media (max-width: 700px) {

    body {
        padding: 8px;
    }

    .container {
        width: 100%;
    }


    /* -----------------------------------------------------
       Kopf
       ----------------------------------------------------- */

    .page-header {
        display: block;

        margin-bottom: 10px;
    }

    .page-title h1 {
        font-size: 23px;
    }

    .tournament-info {
        margin-top: 3px;

        font-size: 12px;
    }

    .tournament-info strong {
        font-size: 13px;
    }


    /* -----------------------------------------------------
       Hauptbereich
       ----------------------------------------------------- */

    .main-layout {
        display: flex;
        flex-direction: column;

        gap: 8px;
    }


    /* -----------------------------------------------------
       Spieler
       ----------------------------------------------------- */

    .player-panel {
        width: 100%;

        border-radius: 6px;
    }

    .player-panel-toggle {
        display: flex;
    }

    .player-selection {
        padding: 8px;
    }

    .panel-header {
        margin-bottom: 6px;
    }

    .panel-header h2 {
        font-size: 14px;
    }

    .player-list {
        gap: 0;
    }

    .player-list label {
        padding: 3px 1px;

        font-size: 12px;
    }


    /* -----------------------------------------------------
       Tag-Auswahl
       ----------------------------------------------------- */

    .day-selection {
        gap: 6px;

        margin-bottom: 7px;
    }

    .day-selection label {
        font-size: 12px;
    }

    .day-selection select {
        flex: 1;

        min-width: 0;

        padding: 5px 6px;

        font-size: 12px;
    }


    /* -----------------------------------------------------
       Status
       ----------------------------------------------------- */

    #status {
        margin-bottom: 6px;

        font-size: 11px;
    }


    /* -----------------------------------------------------
       Zeitblöcke
       ----------------------------------------------------- */

    .match-group {
        margin-bottom: 7px;

        border-radius: 5px;
    }

    .match-group h2 {
        padding: 4px 8px;

        font-size: 16px;
    }


    /* -----------------------------------------------------
       Matches
       ----------------------------------------------------- */

    .match {
        padding: 5px 7px;
    }

    .match-players {
        grid-template-columns:
            minmax(0, 1fr)
            18px
            minmax(0, 1fr);

        gap: 4px;

        font-size: 13px;
        line-height: 1.15;
    }

    .match-info {
        flex-direction: column;

        align-items: center;

        gap: 0;

        margin-top: 2px;

        font-size: 9px;
        line-height: 1.15;
    }

    .match-score {
        font-size: 9px;
    }
}


/* =========================================================
   SEHR KLEINE HANDYS
   ========================================================= */

@media (max-width: 400px) {

    body {
        padding: 6px;
    }

    .page-title h1 {
        font-size: 21px;
    }

    .tournament-info {
        font-size: 11px;
    }

    .tournament-info strong {
        font-size: 12px;
    }

    .match-players {
        grid-template-columns:
            minmax(0, 1fr)
            16px
            minmax(0, 1fr);

        font-size: 12px;
    }

    .match-group h2 {
        font-size: 15px;
    }
}


/* =========================================================
   AUSGESCHIEDENE SPIELER IM FILTER
   ========================================================= */

.eliminated-indicator {
    display: inline-block;

    margin-right: 5px;

    color: #dc3545;

    font-size: 10px;
    font-weight: 700;

    vertical-align: middle;
}


/* =========================================================
   ON-TRACK-BALKEN IM SPIELERFILTER
   ========================================================= */

/*
   Der Balken sitzt links neben dem Spielernamen.

   Höhe:
       0 %   = leer
       25 %  = Viertel der verfügbaren Höhe
       50 %  = halbe Höhe
       75 %  = Dreiviertel
       100 % = volle Höhe

   Der Balken wächst optisch von UNTEN nach OBEN.
*/

.player-track-indicator {
    position: relative;

    flex: 0 0 6px;

    width: 6px;
    height: 16px;

    overflow: hidden;

    background: #e5e7eb;

    border-radius: 2px;
}


/*
 * Der eigentliche grüne Füllbalken.
 */

.player-track-indicator-fill {
    position: absolute;

    left: 0;
    bottom: 0;

    width: 100%;

    background: #198754;

    border-radius: 2px 2px 0 0;

    transition: height 0.25s ease;
}


/*
 * Ausgeschiedene Spieler:
 *
 * Der Balken wird bewusst neutral/leer dargestellt.
 * Das eigentliche "Ausgeschieden"-Kennzeichen bleibt
 * separat möglich.
 */

.player-track-indicator.eliminated {
    background: #f1f1f1;
}

.player-track-indicator.eliminated
.player-track-indicator-fill {
    background: #bdbdbd;
}


/* ---------------------------------------------------------
   MOBILE
   --------------------------------------------------------- */

@media (max-width: 700px) {

    .player-track-indicator {
        flex-basis: 6px;

        width: 6px;
        height: 16px;
    }

}


/* =========================================================
   ON-TRACK-BALKEN IM SPIELERFILTER
   ========================================================= */

.player-progress {
    position: relative;

    flex: 0 0 8px;

    width: 8px;
    height: 18px;

    overflow: hidden;

    background: #e5e7eb;

    border-radius: 2px;

    vertical-align: middle;
}


/*
 * Der eigentliche Balken.
 *
 * bottom: 0 sorgt dafür, dass der Balken
 * immer von unten nach oben wächst.
 */

.player-progress-bar {
    position: absolute;

    left: 0;
    bottom: 0;

    width: 100%;
    height: 0%;

    background: #198754;

    border-radius: 2px;

    transition:
        height 0.25s ease,
        background-color 0.2s ease;
}


/*
 * Ausgeschiedene Spieler:
 *
 * bewusst ein dezentes Rot.
 * Der Balken steht immer auf 100 %.
 */

.player-progress.eliminated .player-progress-bar {
    background: #e5a3a3;
}


/*
 * Spielername
 */

.player-name {
    min-width: 0;

    color: #374151;

    white-space: nowrap;
}


/* ---------------------------------------------------------
   MOBILE
   --------------------------------------------------------- */

@media (max-width: 700px) {

    .player-progress {
        flex-basis: 7px;

        width: 7px;
        height: 18px;
    }

}
