/* ========================================
   TOURNAMENT BRACKET V3 - FIXED SPACING
   Match-Höhe: 78px (inkl. margin)
   ======================================== */

/* Container */
.bracket-wrapper {
    background: var(--farbe-panel);
    border-radius: var(--radius);
    overflow: hidden;
    border: 1px solid var(--farbe-border);
}

/* Sticky Header */
.bracket-header-row {
    display: flex;
    background: var(--farbe-akzent);
    border-bottom: 2px solid var(--farbe-haupt);
    position: sticky;
    top: 0;
    z-index: 100;
}

.bracket-header-cell {
    width: 200px;
    flex-shrink: 0;
    padding: 12px 8px;
    text-align: center;
    font-weight: 700;
    font-size: 0.9em;
    color: var(--farbe-text);
    border-right: 1px solid var(--farbe-border);
}

.bracket-header-cell:last-child {
    border-right: none;
}

.bracket-header-cell small {
    display: block;
    font-size: 0.75em;
    color: var(--farbe-text-muted);
    font-weight: 400;
    margin-top: 2px;
}

/* Scroll Container */
.bracket-scroll {
    overflow-x: auto;
    padding: 15px;
    background: var(--farbe-hintergrund);
}

/* Main Bracket */
.bracket {
    display: flex;
    gap: 20px;
    overflow: visible;
}

/* Round Column */
.bracket-round {
    width: 180px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    overflow: visible;
    padding-right: 30px;
}

/* ===== MATCH BOX - 70px height + 8px margin = 78px total ===== */
.bracket-match {
    background: var(--farbe-panel);
    border: 2px solid var(--farbe-border);
    border-radius: 8px;
    overflow: visible;
    position: relative;
    height: 70px;
    margin: 4px 0;
}

.bracket-match.match-clickable {
    cursor: pointer;
    transition: all 0.15s ease;
}

.bracket-match.match-clickable:hover {
    border-color: var(--farbe-haupt);
    transform: scale(1.02);
    box-shadow: 0 4px 16px rgba(0,0,0,0.4);
    z-index: 10;
}

.bracket-match.completed { border-color: var(--farbe-success); }
.bracket-match.pending { opacity: 0.5; border-style: dashed; }
.bracket-match.ready { border-color: var(--farbe-warning); }

/* Match Header */
.match-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 2px 6px;
    background: var(--farbe-akzent);
    font-size: 0.65em;
    color: var(--farbe-text-muted);
}

.match-bo {
    background: var(--farbe-haupt);
    color: #fff;
    padding: 1px 5px;
    border-radius: 3px;
    font-weight: 600;
}

/* Players */
.match-player {
    display: flex;
    align-items: center;
    padding: 4px 6px;
    gap: 5px;
    border-bottom: 1px solid var(--farbe-border);
    height: 24px;
}

.match-player:last-child { border-bottom: none; }
.match-player.winner { background: rgba(25, 195, 125, 0.2); }
.match-player.winner .player-name { font-weight: 700; color: var(--farbe-success); }
.match-player.tbd { opacity: 0.4; }

.player-seed {
    background: var(--farbe-akzent);
    color: var(--farbe-text-muted);
    padding: 1px 4px;
    border-radius: 3px;
    font-size: 0.65em;
    min-width: 18px;
    text-align: center;
    font-weight: 600;
}

.player-name {
    flex: 1;
    font-size: 0.8em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.player-score {
    font-weight: 700;
    font-size: 1em;
    min-width: 16px;
    text-align: center;
}

/* ===== ROUND SPACING =====
   Runde 1: 16 Matches, kein Abstand oben
   Runde 2: 8 Matches, jedes Match zwischen 2 aus R1 -> margin-top: 39px, dann gap: 78px
   Runde 3: 4 Matches, margin-top: 117px, gap: 234px
   Runde 4: 2 Matches, margin-top: 273px, gap: 546px
   Runde 5: 1 Match, margin-top: 585px
*/

.bracket-round[data-round="1"] .bracket-match {
    margin-bottom: 16px !important;
}

.bracket-round[data-round="2"] .bracket-match:first-child {
    margin-top: 47px;
}
.bracket-round[data-round="2"] .bracket-match {
    margin-bottom: 90px;
}

.bracket-round[data-round="3"] .bracket-match:first-child {
    margin-top: 141px;
}
.bracket-round[data-round="3"] .bracket-match {
    margin-bottom: 278px;
}

.bracket-round[data-round="4"] .bracket-match:first-child {
    margin-top: 329px;
}
.bracket-round[data-round="4"] .bracket-match {
    margin-bottom: 654px;
}

.bracket-round[data-round="5"] .bracket-match:first-child {
    margin-top: 705px;
}

/* ===== CONNECTOR LINES (dezent) ===== */

/* Horizontale Linie von jedem Match (außer Finale) */
.bracket-round:not([data-round="5"]) .bracket-match::after {
    content: '';
    position: absolute;
    right: -20px;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 1px;
    background: rgba(255,255,255,0.2);
}

/* Vertikale Linien - ungerade Matches nach unten, gerade nach oben */
.bracket-round[data-round="1"] .bracket-match:nth-child(odd)::before {
    content: '';
    position: absolute;
    right: -20px;
    top: 50%;
    width: 1px;
    height: 47px;
    background: rgba(255,255,255,0.2);
}

.bracket-round[data-round="1"] .bracket-match:nth-child(even)::before {
    content: '';
    position: absolute;
    right: -20px;
    bottom: 50%;
    width: 1px;
    height: 47px;
    background: rgba(255,255,255,0.2);
}

.bracket-round[data-round="2"] .bracket-match:nth-child(odd)::before {
    content: '';
    position: absolute;
    right: -20px;
    top: 50%;
    width: 1px;
    height: 92px;
    background: rgba(255,255,255,0.2);
}

.bracket-round[data-round="2"] .bracket-match:nth-child(even)::before {
    content: '';
    position: absolute;
    right: -20px;
    bottom: 50%;
    width: 1px;
    height: 92px;
    background: rgba(255,255,255,0.2);
}

.bracket-round[data-round="3"] .bracket-match:nth-child(odd)::before {
    content: '';
    position: absolute;
    right: -20px;
    top: 50%;
    width: 1px;
    height: 186px;
    background: rgba(255,255,255,0.2);
}

.bracket-round[data-round="3"] .bracket-match:nth-child(even)::before {
    content: '';
    position: absolute;
    right: -20px;
    bottom: 50%;
    width: 1px;
    height: 186px;
    background: rgba(255,255,255,0.2);
}

.bracket-round[data-round="4"] .bracket-match:nth-child(odd)::before {
    content: '';
    position: absolute;
    right: -20px;
    top: 50%;
    width: 1px;
    height: 374px;
    background: rgba(255,255,255,0.2);
}

.bracket-round[data-round="4"] .bracket-match:nth-child(even)::before {
    content: '';
    position: absolute;
    right: -20px;
    bottom: 50%;
    width: 1px;
    height: 374px;
    background: rgba(255,255,255,0.2);
}

/* ===== THIRD PLACE ===== */
.bracket-third-place {
    margin-top: 30px;
    padding: 20px;
    background: var(--farbe-panel);
    border-top: 2px solid var(--farbe-haupt);
}

.bracket-third-place .section-title {
    font-weight: 700;
    font-size: 1em;
    margin-bottom: 12px;
    color: var(--farbe-text);
}

.bracket-third-place .section-title::before {
    content: '🥉 ';
}

.bracket-third-place .bracket-match {
    max-width: 180px;
    height: 70px;
}
