        :root {
            --w-min: 140px;
            --h-player: 1.3em;
            --gap-x: 3vw;
            --translate-semis: 25px;
            --color-header: #e0e0e0;
            --bs-body-line-height: 1.2;

/*
            --bracket-crunch-provisional: -50px;
            --bracket-crunch: calc(var(--gap-x) * -1.5);
*/
        }

        body { 
          overflow-x: auto; 
          min-width: fit-content;
        }
        
        h1 {
          color: var(--color-header);
        }
        
        #match-container {
            display: contents;
        }

        .bracket-container {
            display: grid;
            grid-template-columns: repeat(5, minmax(var(--w-min), 1fr));
            /*grid-template-rows: repeat(5, auto) clamp(2rem, 1.8rem + 3vw, 5rem) repeat(4, auto);*/
            grid-template-rows: repeat(5, auto) 5rem repeat(5, auto);
            gap: 15px var(--gap-x);
            align-items: center;
            width: 100%;
            max-width: 1800px;
            margin: 0 auto;
            padding-bottom: 1rem;
        }
        
        #last-updated-label {
            grid-column: 1;
            grid-row: 11;
            margin-top: 0;
            margin-left: 0.8em;
        }

        /* Header Styling */
        .round-header {
            font-size: clamp(0.7rem, 0.65rem + 0.8vw, 1.4rem);
            font-weight: bold;
            color: var(--color-header);
            text-align: center;
            padding-bottom: 10px;
            grid-row: 1; /* Alle Header fix in Zeile 1 */
        }

        /* Positionen der Header */
        .rh1 { grid-column: 1; }
        .rh2 { grid-column: 2; }
        .rh3 { grid-column: 3; }
        .rh4 { grid-column: 4; }
        .rh5 { grid-column: 5; }

        .match {
            background: #c8eaff;
            border: 1px solid #ccc;
            border-radius: 4px;
            padding: 8px;
            font-size: 0.8rem;
            box-shadow: 2px 2px 4px rgba(0,0,0,0.5);
            position: relative;
        }

        .team {
          font-family: Arial, sans-serif;
          color: black;
          background: ivory;
          padding: 3px;
          margin-bottom: 6px;
          border: 1px solid #bbb;
          border-radius: 4px;
          position: relative;
          display: flex;
          flex-direction: column;
          gap: 2px;
          
          /* für Rechner
          cursor: pointer;
          transition: all 0.2s ease;
          */
        }

        .team:last-child { margin-bottom: 0; }
        
        .seed {
          position: absolute;
          top: 0;
          right: 0;
          font-size: 0.9rem;
          background: #eee;
          /*color: #666;*/
          border-left: 1px solid #bbb;
          border-bottom: 1px solid #bbb;
          border-radius: 0 4px 0 4px;
          padding: 0 3px;
          line-height: 1.2;
          font-weight: normal;
        }
        
        .team.tbd .seed {
          display: none;
        }
        
        .player { 
          display: block; 
          height: var(--h-player); 
          width: 90%;
          overflow: hidden; 
          text-overflow: ellipsis; 
        }
        .winner { 
          color: #000; 
          background: #ffb300; 
          border-radius: 4px; 
        }
        .label { 
          font-size: clamp(0.6rem, 0.5rem + 0.3vw, 0.8rem);
          color: #666; 
          margin-bottom: 4px; 
          display: block; 
          border-bottom: 1px solid #eee; 
        }
        
        @media (min-width: 1000px) {
          :root {
            /*--bracket-crunch: -1.5rem;*/
            /*--bracket-crunch: calc(var(--gap-x) * -0.3);*/
          }
          .match {
            font-size: 0.7rem;
            font-size: clamp(0.7rem, 0.27rem + 0.7vw, 1rem);
          }
          .team {
              flex-direction: row;
              flex-wrap: no-wrap;
              align-items: center;
              justify-content: flex-start;
              overflow: hidden;
          }
          .player {
              display: inline;
              
          }
          .player:nth-of-type(2)::before {
              content: "/";
              margin: 0 3px;
              color: #000;
              font-weight: normal;
          }
          .team-text-wrapper {
            display: block;
            width: 95%;
            
            overflow: hidden;
            text-overflow: ellipsis; /* Pünktchen am Ende des gesamten Duos */
            text-wrap: nowrap;
          }
          .seed {
            font-size: 0.7rem;
            font-size: clamp(0.7rem, 0.56rem + 0.23vw, 0.8rem);
          }
        }
        

        /* --- POSITIONIERUNG WINNER BRACKET --- */

        /* R1: Die 4 Start-Matches */
        .m1 { grid-column: 1; grid-row: 2 / 4; }
        .m2 { grid-column: 1; grid-row: 4 / 6; }
        .m3 { grid-column: 1; grid-row: 7 / 9; }
        .m4 { grid-column: 1; grid-row: 9 / 11; }

        /* R2: Viertelfinals (Zentriert zu R1) */
        .m7 { grid-column: 2; grid-row: 3 / 5; } /* Mitte aus M1 & M2 */
        .m8 { grid-column: 2; grid-row: 8 / 10; } /* Mitte aus M3 & M4 */

        /* R3: Halbfinals (HF) */
        .m11 { grid-column: 3; grid-row: 3 / 5; }
        .m12 { grid-column: 3; grid-row: 8 / 10; }

        /* DAS ZENTRALE FINALE */
        .m13 { 
            grid-column: 3; 
            grid-row: 6; /* Exakt in der Mitte zwischen den HF-Blöcken */
            /*border: 1px solid #ffd700;*/
            /*background: #fffdf0;*/
        }
        .m13 .label:after {
            content: " - FINALE";
        }

        /* Loser-Runden / Platzierungsspiele */
        .m9 { grid-column: 4; grid-row: 3 / 5; }
        .m10 { grid-column: 4; grid-row: 8 / 10; }
        .m5 { grid-column: 5; grid-row: 3 / 5; }
        .m6 { grid-column: 5; grid-row: 8 / 10; }
        
        /* Translate */
        .m3, .m4, .m8, .m6, .m10, .m12 {
          transform: translateY(var(--bracket-crunch));
        }
        .m13 {
          transform: translateY(calc(var(--bracket-crunch) * 0.5));
        }
        
        /* Provisional Bracket */
        .provisional .seed { display: none; }
        .provisional .player:nth-child(3) {display: none; }
        .provisional .m3, .provisional .m4, .provisional .m8, .provisional .m6, .provisional .m10, .provisional .m12 {
          transform: translateY(var(--bracket-crunch-provisional));
        }
        .provisional .m13 {
          transform: translateY(calc(var(--bracket-crunch-provisional) * 0.5));
        }


/* connections */
.match {
    position: relative;
}

.match::before, .match::after {
    content: "";
    position: absolute;
    border-color: #bbb; /* Farbe der Linien */
    border-style: solid;
    border-width: 0;
    pointer-events: none;
}

/* --- HORIZONTALE ABGÄNGE (nach rechts) --- */
.m11:before, .m12:before {
    content: "";
    position: absolute;
    left: calc(var(--gap-x) * -1.2);
    top: 48%;
    width: var(--gap-x);
    height: 22px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' preserveAspectRatio='none' fill='white' class='bi bi-arrow-right' viewBox='0 0 16 16'%3E%3Cpath fill-rule='evenodd' d='M1 8a.5.5 0 0 1 .5-.5h11.793l-3.147-3.146a.5.5 0 0 1 .708-.708l4 4a.5.5 0 0 1 0 .708l-4 4a.5.5 0 0 1-.708-.708L13.293 8.5H1.5A.5.5 0 0 1 1 8'/%3E%3C/svg%3E");
/*    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16'  fill='white' class='bi bi-caret-right' viewBox='0 0 16 16'%3E%3Cpath d='M6 12.796V3.204L11.481 8zm.659.753 5.48-4.796a1 1 0 0 0 0-1.506L6.66 2.451C6.011 1.885 5 2.345 5 3.204v9.592a1 1 0 0 0 1.659.753'/%3E%3C/svg%3E");*/
    background-repeat: no-repeat;
    background-position: center right;
    background-size: calc(var(--gap-x) * 0.6);
}

/* --- HORIZONTALE ABGÄNGE (nach links) --- */
.m5:before, .m6:before, .m9:before, .m10:before {
    content: "";
    position: absolute;
    left: calc(var(--gap-x) * -1.2);
    top: 48%;
    width: var(--gap-x);
    height: 22px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' preserveAspectRatio='none' fill='white' viewBox='0 0 16 16'%3E%3Cpath fill-rule='evenodd' d='M15 8a.5.5 0 0 0-.5-.5H2.707l3.147-3.146a.5.5 0 1 0-.708-.708l-4 4a.5.5 0 0 0 0 .708l4 4a.5.5 0 0 0 .708-.708L2.707 8.5H14.5A.5.5 0 0 0 15 8'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: center right;
    background-size: calc(var(--gap-x) * 0.6);
}

/* --- KLAMMER (nach rechts) --- */
.m7::before, .m8::before {
    left: calc(var(--gap-x) * -1);
    width: calc(var(--gap-x) * 0.2);
    top: -15%; /* Startet oberhalb des Matches bei M1/M3 */
    height: 130%; /* Reicht bis runter zu M2/M4 */
    border-right-width: 2px;
    border-top-width: 2px;
    border-bottom-width: 2px;
    border-radius: 0 4px 4px 0;
}
.m7:after, .m8:after {
    content: "";
    position: absolute;
    left: calc(var(--gap-x) * -1.2);
    top: 48%;
    width: var(--gap-x);
    height: 22px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' preserveAspectRatio='none' fill='white' class='bi bi-arrow-right' viewBox='0 0 16 16'%3E%3Cpath fill-rule='evenodd' d='M1 8a.5.5 0 0 1 .5-.5h11.793l-3.147-3.146a.5.5 0 0 1 .708-.708l4 4a.5.5 0 0 1 0 .708l-4 4a.5.5 0 0 1-.708-.708L13.293 8.5H1.5A.5.5 0 0 1 1 8'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: center right;
    background-size: calc(var(--gap-x) * 0.6);
}


/* HF zu F */

.m11:after {
    content: "";
    position: absolute;
    top: clamp(102%, 102% + 1vw, 105%);
    top: 105%;
    left: 45%;
    width: 22px;
    /*height: calc(var(--bracket-crunch) * -0.45);*/
    height: var(--gap-x);
    /*height: 64px;*/
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' preserveAspectRatio='none' fill='white' viewBox='0 0 16 16'%3E%3Cpath fill-rule='evenodd' d='M8 1a.5.5 0 0 1 .5.5v11.793l3.146-3.147a.5.5 0 0 1 .708.708l-4 4a.5.5 0 0 1-.708 0l-4-4a.5.5 0 0 1 .708-.708L7.5 13.293V1.5A.5.5 0 0 1 8 1'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: center;
    background-size: calc(var(--gap-x) * 0.6);
}

.m13:after {
    content: "";
    position: absolute;
    top: 105%;
    left: 45%;
    width: 22px;
    height: calc(var(--bracket-crunch) * -0.45);
    height: var(--gap-x);
    /*height: 64px;*/
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' preserveAspectRatio='none' fill='white' viewBox='0 0 16 16'%3E%3Cpath fill-rule='evenodd' d='M8 15a.5.5 0 0 0 .5-.5V2.707l3.146 3.147a.5.5 0 0 0 .708-.708l-4-4a.5.5 0 0 0-.708 0l-4 4a.5.5 0 1 0 .708.708L7.5 2.707V14.5a.5.5 0 0 0 .5.5'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: center;
    background-size: calc(var(--gap-x) * 0.6);
}

.m13:before {
    content: "";
    position: absolute;
    top: 38%;
    left: -3rem;
    width: 2rem;
    height: 2rem;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='gold' class='bi bi-trophy' viewBox='0 0 16 16'%3E%3Cpath d='M2.5.5A.5.5 0 0 1 3 0h10a.5.5 0 0 1 .5.5q0 .807-.034 1.536a3 3 0 1 1-1.133 5.89c-.79 1.865-1.878 2.777-2.833 3.011v2.173l1.425.356c.194.048.377.135.537.255L13.3 15.1a.5.5 0 0 1-.3.9H3a.5.5 0 0 1-.3-.9l1.838-1.379c.16-.12.343-.207.537-.255L6.5 13.11v-2.173c-.955-.234-2.043-1.146-2.833-3.012a3 3 0 1 1-1.132-5.89A33 33 0 0 1 2.5.5m.099 2.54a2 2 0 0 0 .72 3.935c-.333-1.05-.588-2.346-.72-3.935m10.083 3.935a2 2 0 0 0 .72-3.935c-.133 1.59-.388 2.885-.72 3.935M3.504 1q.01.775.056 1.469c.13 2.028.457 3.546.87 4.667C5.294 9.48 6.484 10 7 10a.5.5 0 0 1 .5.5v2.61a1 1 0 0 1-.757.97l-1.426.356a.5.5 0 0 0-.179.085L4.5 15h7l-.638-.479a.5.5 0 0 0-.18-.085l-1.425-.356a1 1 0 0 1-.757-.97V10.5A.5.5 0 0 1 9 10c.516 0 1.706-.52 2.57-2.864.413-1.12.74-2.64.87-4.667q.045-.694.056-1.469z'/%3E%3C/svg%3E");
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='gold' class='bi bi-trophy-fill' viewBox='0 0 16 16'%3E%3Cpath d='M2.5.5A.5.5 0 0 1 3 0h10a.5.5 0 0 1 .5.5q0 .807-.034 1.536a3 3 0 1 1-1.133 5.89c-.79 1.865-1.878 2.777-2.833 3.011v2.173l1.425.356c.194.048.377.135.537.255L13.3 15.1a.5.5 0 0 1-.3.9H3a.5.5 0 0 1-.3-.9l1.838-1.379c.16-.12.343-.207.537-.255L6.5 13.11v-2.173c-.955-.234-2.043-1.146-2.833-3.012a3 3 0 1 1-1.132-5.89A33 33 0 0 1 2.5.5m.099 2.54a2 2 0 0 0 .72 3.935c-.333-1.05-.588-2.346-.72-3.935m10.083 3.935a2 2 0 0 0 .72-3.935c-.133 1.59-.388 2.885-.72 3.935'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: center;
    background-size: calc(var(--gap-x) * 0.6);
    background-size: 2rem;
}

@media (max-width: 999px) {
    .team {
        min-height: 3.2em;
    }
    .m13::after,
    .m11::after {
        top: 144px;
    }
}

/* TBD-Feld */
.tbd {
    color: #666;
}

.mode-simulator .tbd {
    cursor: not-allowed;
}

/* klickbares Feld */
.clickable {
    cursor: pointer;
}

/* Optional: Hover-Effekt für klickbare Teams */
.clickable .team:hover {
    /*background-color: #e0e0e0;*/
}


/* Warning bei provisional or exmpty bracket */
#warning {
    width: 450px;
    margin: 20px auto;
    font-size: 1.2rem;
    text-align: center;
    box-shadow: 2px 2px 4px rgba(0,0,0,0.5);
}

/* Reset */
.reset-buttons {
    width: 100%;
    max-width: 1800px;
    text-align: left;
    margin: 10px auto;
}

button.reset {
    margin-right: 10px;
    box-shadow: 2px 2px 4px rgba(0,0,0,0.5);
}


/* Share-Link */
#share-container {
    text-align: center;
    padding: 1rem 0 2rem 0;
}

#share-link {
    width: auto;
    min-width: 500px;
    border: 1px solid #ddd;
    background-color: #f8f9fa;
    padding: 8px 12px;
    border-radius: 4px;
    text-align: center;
    color: #555;
    font-family: monospace;
    cursor: default;
    margin-bottom: 10px;
}

#share-link:focus {
    outline: none;
    border-color: #0d6efd;
}

#bracket-incomplete-info {
    display: inline-block;
    width: auto;
    margin: 0 auto;
    box-shadow: 2px 2px 4px rgba(0,0,0,0.5);
    background: #c8eaff;
}

button.share {
    box-shadow: 2px 2px 4px rgba(0,0,0,0.5);
}

#share-success {
    margin-top: 10px;
    font-weight: 600;
}

/* Grundzustand: unsichtbar */
.fade-element {
    opacity: 0;
    transition: opacity 0.3s ease-in-out;
}

/* Zustand: sichtbar */
.fade-element.show {
    opacity: 1;
}