/* Farben nach Rolle; hell und dunkel je eigene Stufen */
:root {
    color-scheme: light;
    --page: #f9f9f7;
    --surface: #fcfcfb;
    --text: #0b0b0b;
    --text-2: #52514e;
    --muted: #898781;
    --grid: #e1e0d9;
    --axis: #c3c2b7;
    --border: rgba(11, 11, 11, 0.10);
    --accent: #2a78d6;
    --dot: #86b6ef;
    --link: #1c5cab;
    --wash: rgba(42, 120, 214, 0.08);
    --critical: #d03b3b;
    --shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
    /* Ergebnis je Bahn, divergierend um Par: Blau darunter, Grau für Par, Rot darüber – je weiter weg, desto kräftiger.
       Mit dem Palette-Validator geprüft (je Arm gleichmäßig in der Helligkeit, Blau gegen Rot auch bei Farbschwäche).
       Birdie und Bogey liegen hell unter 3:1 – deshalb gibt es die Verteilung auch als Zahlen. -ink ist die Schrift darauf. */
    --s-eagle: #1c5cab;
    --s-eagle-ink: #ffffff;
    --s-birdie: #6da7ec;
    --s-birdie-ink: #0b0b0b;
    --s-par: #c3c2b7;
    --s-par-ink: #0b0b0b;
    --s-bogey: #f37b6f;
    --s-bogey-ink: #0b0b0b;
    --s-double: #a52a26;
    --s-double-ink: #ffffff;
}

@media (prefers-color-scheme: dark) {
    :root {
        color-scheme: dark;
        --page: #0d0d0d;
        --surface: #1a1a19;
        --text: #f0efec;
        --text-2: #c3c2b7;
        --grid: #2c2c2a;
        --axis: #383835;
        --border: rgba(255, 255, 255, 0.10);
        --accent: #3987e5;
        --dot: #256abf;
        --link: #86b6ef;
        --wash: rgba(57, 135, 229, 0.14);
        --critical: #e66767;
        --shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
        /* Dunkel eigene Stufen: Die kräftigste Stufe ist hier die hellste, weil sie sich am stärksten vom Grund abhebt */
        --s-eagle: #86b6ef;
        --s-eagle-ink: #0b0b0b;
        --s-birdie: #256abf;
        --s-birdie-ink: #ffffff;
        --s-par: #383835;
        --s-par-ink: #f0efec;
        --s-bogey: #b53a34;
        --s-bogey-ink: #ffffff;
        --s-double: #fa9085;
        --s-double-ink: #0b0b0b;
    }
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--page);
    color: var(--text);
    font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
    line-height: 1.45;
}

h1, h2 {
    line-height: 1.2;
}

h1:focus {
    outline: none;
}

a {
    color: var(--link);
}

.top {
    max-width: 1100px;
    margin: 0 auto;
    padding: 14px 16px 0;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--text);
    font-weight: 600;
    text-decoration: none;
}

main {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 16px 24px;
}

.bottom {
    max-width: 1100px;
    margin: 0 auto;
    padding: 8px 16px 24px;
    color: var(--text-2);
    font-size: 0.8rem;
    text-align: center;
}

.muted {
    color: var(--text-2);
}

.small {
    font-size: 0.8rem;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
}

.error {
    color: var(--critical);
}

    .error::before {
        content: "⚠ ";
    }

/* Startseite: Datei auswählen */
.intro {
    max-width: 640px;
    margin: 8vh auto 0;
}

    .intro h1 {
        font-size: 1.8rem;
        margin: 0 0 12px;
    }

    .intro p, .intro ul {
        color: var(--text-2);
    }

    .intro h2 {
        margin: 40px 0 8px;
        font-size: 1.1rem;
    }

    .intro ul {
        padding-left: 20px;
    }

    .intro li + li {
        margin-top: 8px;
    }

.drop {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    margin-top: 24px;
    padding: 40px 16px;
    border: 2px dashed var(--axis);
    border-radius: 12px;
    background: var(--surface);
    color: var(--text-2);
    text-align: center;
    cursor: pointer;
}

    .drop strong {
        color: var(--link);
        font-size: 1.1rem;
    }

    .drop:hover, .drop.dragging {
        border-color: var(--accent);
        background: var(--wash);
    }

    .drop:focus-within, .button:focus-within, .button:focus-visible {
        outline: 2px solid var(--accent);
        outline-offset: 2px;
    }

    /* Das echte Dateifeld liegt unsichtbar über der Fläche: Klicken und Hineinziehen gehen beide */
    .drop input[type=file], .button input[type=file], .file-link input[type=file] {
        position: absolute;
        inset: 0;
        width: 100%;
        opacity: 0;
        cursor: pointer;
    }

/* Kopf: Spieler und Zeitraum nebeneinander, darunter die Datei */
.toolbar {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px 12px;
    margin-top: 16px;
}

@media (min-width: 760px) {
    .toolbar {
        grid-template-columns: repeat(2, minmax(0, 280px));
    }
}

    .toolbar select {
        width: 100%;
    }

.file-line {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 4px 16px;
    margin-top: 8px;
    color: var(--text-2);
    font-size: 0.8rem;
}

.file-actions {
    display: flex;
    gap: 16px;
}

.file-link {
    position: relative;
    overflow: hidden;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 2px;
    max-width: 100%;
    color: var(--text-2);
    font-size: 0.85rem;
}

select {
    max-width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--axis);
    border-radius: 8px;
    background: var(--surface);
    color: var(--text);
    font: inherit;
    font-size: 1rem;
}

.button {
    position: relative;
    overflow: hidden;
    display: inline-flex;
    padding: 8px 14px;
    border: 1px solid var(--axis);
    border-radius: 8px;
    background: var(--surface);
    color: var(--text);
    font: inherit;
    cursor: pointer;
}

    .button:hover {
        background: var(--wash);
    }

.link {
    padding: 0;
    border: 0;
    background: none;
    color: var(--link);
    font: inherit;
    text-align: left;
    cursor: pointer;
}

    .link:hover {
        text-decoration: underline;
    }

/* Reiter: bleiben beim Scrollen oben stehen, auf dem Handy vier gleich breite */
.tabs {
    position: sticky;
    top: 0;
    z-index: 5;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    margin: 12px -16px 0;
    padding: 0 8px;
    border-bottom: 1px solid var(--grid);
    background: var(--page);
}

@media (min-width: 760px) {
    .tabs {
        grid-template-columns: repeat(4, 150px);
    }
}

    .tabs button {
        margin-bottom: -1px;
        padding: 12px 4px 10px;
        border: 0;
        border-bottom: 2px solid transparent;
        background: none;
        color: var(--text-2);
        font: inherit;
        font-size: 0.9rem;
        white-space: nowrap;
        cursor: pointer;
    }

        .tabs button:hover {
            color: var(--text);
        }

        .tabs button:focus-visible {
            outline: 2px solid var(--accent);
            outline-offset: -2px;
        }

        .tabs button[aria-current] {
            border-bottom-color: var(--accent);
            color: var(--text);
            font-weight: 600;
        }

/* Kopf einer Ansicht: zurück, Titel, worum es geht */
.view-head {
    margin-top: 16px;
}

    .view-head h2 {
        margin: 2px 0;
        font-size: 1.4rem;
        line-height: 1.2;
    }

    .view-head p {
        margin: 0;
        color: var(--text-2);
        font-size: 0.85rem;
    }

.up {
    padding: 4px 0;
    border: 0;
    background: none;
    color: var(--link);
    font: inherit;
    font-size: 0.9rem;
    cursor: pointer;
}

    .up:hover {
        text-decoration: underline;
    }

.view-title {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.person {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 4px;
}

.search {
    width: 100%;
    margin-top: 16px;
    padding: 10px 12px;
    border: 1px solid var(--axis);
    border-radius: 10px;
    background: var(--surface);
    color: var(--text);
    font: inherit;
}

/* Listen: eine Zeile je Eintrag, Titel und Zusatz links, Zahlen rechts; antippbare Zeilen sind Knöpfe */
.list {
    margin: 0;
    padding: 0;
    list-style: none;
}

    .list > li + li {
        border-top: 1px solid var(--grid);
    }

.item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    min-height: 56px;
    padding: 8px 6px;
    border: 0;
    border-radius: 8px;
    background: none;
    color: inherit;
    font: inherit;
    text-align: left;
}

button.item {
    cursor: pointer;
}

    button.item:hover {
        background: var(--wash);
    }

    button.item:focus-visible {
        outline: 2px solid var(--accent);
        outline-offset: -2px;
    }

.item-main {
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: 1px;
    min-width: 0;
}

.item-title {
    font-weight: 600;
    overflow-wrap: anywhere;
}

.item-meta {
    color: var(--text-2);
    font-size: 0.8rem;
}

.figure {
    display: flex;
    flex: none;
    flex-direction: column;
    align-items: flex-end;
    min-width: 40px;
}

    .figure strong {
        font-size: 0.95rem;
        font-variant-numeric: tabular-nums;
        white-space: nowrap;
    }

    .figure small {
        color: var(--text-2);
        font-size: 0.7rem;
        white-space: nowrap;
    }

.chevron {
    flex: none;
    color: var(--muted);
    font-size: 1.4rem;
    line-height: 1;
}

.avatar {
    display: grid;
    flex: none;
    place-items: center;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--wash);
    color: var(--link);
    font-size: 0.85rem;
    font-weight: 600;
}

    .avatar.large {
        width: 52px;
        height: 52px;
        font-size: 1.15rem;
    }

.list-card {
    padding: 12px 12px 6px;
}

.list-head {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    gap: 4px 12px;
    margin-bottom: 4px;
    padding: 0 6px;
}

    .list-head h2 {
        margin: 0;
    }

.list-card .sub, .list-card .legend {
    padding: 0 6px;
}

/* Ranglisten: Platz im Kreis, die ersten drei hervorgehoben, der gewählte Spieler unterlegt */
.rank {
    display: grid;
    flex: none;
    place-items: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    color: var(--text-2);
    font-size: 0.85rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

    .rank.podium {
        background: var(--wash);
        box-shadow: inset 0 0 0 1px var(--accent);
        color: var(--link);
    }

.ranking li.me .item {
    background: var(--wash);
}

.ranking li.gap {
    padding: 2px 0 2px 16px;
    color: var(--muted);
}

.tiles {
    display: grid;
    margin-top: 16px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

@media (min-width: 760px) {
    .tiles {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

.tile, .card {
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface);
}

.tile {
    padding: 12px 16px;
}

.tile-label {
    color: var(--text-2);
    font-size: 0.85rem;
}

.tile-value {
    font-size: 2rem;
    font-weight: 600;
    line-height: 1.2;
}

.tile-sub {
    color: var(--text-2);
    font-size: 0.8rem;
}

.card {
    margin-top: 16px;
    padding: 16px;
}

    .card h2 {
        margin: 0 0 4px;
        font-size: 1.1rem;
    }

    .card .sub {
        margin: 0 0 12px;
        color: var(--text-2);
        font-size: 0.85rem;
    }

.card-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 4px;
}

    .card-head h2 {
        margin: 0;
    }

/* Bahnen eines Layouts: Vergleich wählen, je Bahn eine Zeile – Nummer, Par, Verteilung, zu Par, Vergleich */
.field.compare {
    margin-bottom: 12px;
}

.hole-row {
    display: grid;
    grid-template-columns: 30px 40px minmax(56px, 1fr) 48px 64px 10px;
    align-items: center;
    gap: 8px;
}

.hole-list.solo .hole-row {
    grid-template-columns: 30px 40px minmax(56px, 1fr) 48px 10px;
}

.hole-list .item.hole-row {
    min-height: 44px;
}

.hole-head {
    padding: 0 6px 4px;
    color: var(--text-2);
    font-size: 0.75rem;
}

.hole-row .num {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.hole-no {
    display: grid;
    place-items: center;
    width: 28px;
    height: 28px;
    border: 1px solid var(--axis);
    border-radius: 50%;
    font-size: 0.85rem;
    font-weight: 600;
}

.hole-par {
    color: var(--text-2);
    font-size: 0.8rem;
    white-space: nowrap;
}

.hole-spread .segments {
    max-width: none;
    height: 8px;
    margin-top: 0;
    border-radius: 4px;
}

.stepper {
    display: flex;
    align-items: center;
    gap: 6px;
}

    .stepper .button {
        padding: 6px 12px;
    }

        .stepper .button:disabled {
            opacity: 0.4;
            cursor: default;
        }

.empty {
    padding: 24px 0;
    color: var(--text-2);
    text-align: center;
}

.facts {
    margin: 0 0 12px;
    padding-left: 20px;
    color: var(--text-2);
    font-size: 0.85rem;
}

    .facts strong {
        color: var(--text);
    }

/* Kennzahlen in einer Karte, z. B. bei der letzten Runde */
.stats {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px 16px;
    margin: 12px 0 16px;
}

@media (min-width: 760px) {
    .stats {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 600;
    line-height: 1.2;
}

/* Ergebnis je Bahn: Farben siehe :root */
.s-eagle {
    background: var(--s-eagle);
    color: var(--s-eagle-ink);
}

.s-birdie {
    background: var(--s-birdie);
    color: var(--s-birdie-ink);
}

.s-par {
    background: var(--s-par);
    color: var(--s-par-ink);
}

.s-bogey {
    background: var(--s-bogey);
    color: var(--s-bogey-ink);
}

.s-double {
    background: var(--s-double);
    color: var(--s-double-ink);
}

.key-box {
    width: 10px;
    height: 10px;
    border-radius: 2px;
}

/* Bilanz gegen Mitspieler: dieselben Farben – Blau besser, Grau gleich, Rot schlechter */
.w-win {
    background: var(--s-birdie);
    color: var(--s-birdie-ink);
}

.w-tie {
    background: var(--s-par);
    color: var(--s-par-ink);
}

.w-loss {
    background: var(--s-bogey);
    color: var(--s-bogey-ink);
}

/* Ein Ganzes in Teilen (SegmentBar): dünn mit runden Enden, die Teile durch 2px Grund getrennt */
.segments {
    display: flex;
    gap: 2px;
    max-width: 200px;
    height: 6px;
    margin-top: 6px;
    border-radius: 3px;
    overflow: hidden;
}

    .segments > span {
        flex-basis: 0;
        min-width: 2px;
    }

    /* Hoch: jeder Teil ein eigener Block, sein Anteil darin, wenn er hineinpasst */
    .segments.tall {
        max-width: none;
        height: 28px;
        margin: 8px 0 12px;
        border-radius: 0;
        overflow: visible;
    }

        .segments.tall > span {
            display: flex;
            align-items: center;
            border-radius: 4px;
            font-size: 0.75rem;
            font-weight: 600;
            white-space: nowrap;
        }

            .segments.tall > span.labeled {
                padding: 0 6px;
            }

/* Scorecard der letzten Runde, in Neunerblöcken, damit sie aufs Handy passt */
.scorecards {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 24px;
    margin: 8px 0 12px;
    overflow-x: auto;
}

table.scorecard {
    border-collapse: separate;
    border-spacing: 2px;
    font-size: 0.85rem;
    font-variant-numeric: tabular-nums;
}

    table.scorecard th {
        padding: 0 6px 0 0;
        color: var(--text-2);
        font-size: 0.8rem;
        font-weight: 400;
        text-align: left;
        white-space: nowrap;
    }

    table.scorecard td {
        width: 28px;
        min-width: 28px;
        padding: 0;
        text-align: center;
    }

    table.scorecard tr.hole td, table.scorecard tr.par td {
        color: var(--text-2);
        font-size: 0.8rem;
    }

    table.scorecard tr.versus td {
        color: var(--text-2);
        font-size: 0.7rem;
        white-space: nowrap;
    }

.cell {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 4px;
    font-weight: 600;
}

    .cell.missing {
        color: var(--muted);
        font-weight: 400;
    }

/* Diagramm */
.legend {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 16px;
    margin-bottom: 4px;
    color: var(--text-2);
    font-size: 0.8rem;
}

    .legend span {
        white-space: nowrap;
    }

.key {
    display: inline-block;
    margin-right: 6px;
    vertical-align: middle;
}

.key-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--dot);
}

.key-line {
    width: 14px;
    height: 2px;
    border-radius: 1px;
    background: var(--accent);
}

.chart {
    position: relative;
    height: 260px;
    overflow: hidden;
    user-select: none;
}

    .chart svg {
        display: block;
    }

    .chart .grid {
        stroke: var(--grid);
        stroke-width: 1;
    }

    .chart .axis {
        stroke: var(--axis);
        stroke-width: 1;
    }

    .chart .reference {
        stroke: var(--muted);
        stroke-width: 1;
    }

    .chart .tick {
        fill: var(--muted);
        font-size: 11px;
        font-variant-numeric: tabular-nums;
    }

    .chart .dot {
        fill: var(--dot);
    }

    .chart .avg {
        fill: none;
        stroke: var(--accent);
        stroke-width: 2;
        stroke-linejoin: round;
        stroke-linecap: round;
    }

    .chart .avg-end, .chart .dot-active {
        fill: var(--accent);
        stroke: var(--surface);
        stroke-width: 2;
    }

    .chart .avg-active {
        fill: var(--surface);
        stroke: var(--accent);
        stroke-width: 2;
    }

    .chart .end-label {
        fill: var(--text-2);
        font-size: 12px;
        font-weight: 600;
    }

    .chart .crosshair {
        stroke: var(--text-2);
        stroke-width: 1;
        opacity: 0.5;
    }

.chart-hit {
    position: absolute;
    border-radius: 4px;
    cursor: crosshair;
    touch-action: pan-y;
    outline: none;
}

    .chart-hit:focus-visible {
        outline: 2px solid var(--accent);
        outline-offset: 2px;
    }

.tooltip {
    position: absolute;
    z-index: 2;
    min-width: 140px;
    max-width: 240px;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    box-shadow: var(--shadow);
    font-size: 0.8rem;
    pointer-events: none;
}

.tooltip-title, .tooltip-detail {
    color: var(--text-2);
}

.tooltip-title {
    margin-bottom: 4px;
}

.tooltip-detail {
    margin-top: 4px;
}

.tooltip-row strong {
    font-size: 0.95rem;
    font-variant-numeric: tabular-nums;
}

.table-toggle {
    margin-top: 8px;
    font-size: 0.85rem;
}

/* Tabellen */
.table-scroll {
    overflow-x: auto;
}

    .table-scroll.limited {
        max-height: 420px;
        margin-top: 8px;
        overflow-y: auto;
    }

table.data {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

    table.data th, table.data td {
        padding: 6px 8px;
        border-bottom: 1px solid var(--grid);
        text-align: left;
        vertical-align: top;
    }

    table.data thead th {
        position: sticky;
        top: 0;
        background: var(--surface);
        color: var(--text-2);
        font-size: 0.85rem;
        font-weight: 600;
    }

    table.data .num {
        text-align: right;
        white-space: nowrap;
        font-variant-numeric: tabular-nums;
    }

    table.data tr.course th {
        padding-top: 16px;
        border-bottom-color: var(--axis);
        font-weight: 600;
    }

    table.data tr.selected td {
        background: var(--wash);
    }

/* Auf dem Handy enger, damit Tabellen ohne Seitwärtsscrollen passen */
@media (max-width: 480px) {
    table.data th, table.data td {
        padding: 6px 4px;
    }
}

/* Ladeanzeige und Fehlerleiste von Blazor */
#blazor-error-ui {
    color-scheme: light only;
    background: lightyellow;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    box-sizing: border-box;
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

    #blazor-error-ui .dismiss {
        cursor: pointer;
        position: absolute;
        right: 0.75rem;
        top: 0.5rem;
    }

.loading-progress {
    position: absolute;
    display: block;
    width: 8rem;
    height: 8rem;
    inset: 20vh 0 auto 0;
    margin: 0 auto 0 auto;
}

    .loading-progress circle {
        fill: none;
        stroke: var(--grid);
        stroke-width: 0.6rem;
        transform-origin: 50% 50%;
        transform: rotate(-90deg);
    }

        .loading-progress circle:last-child {
            stroke: var(--accent);
            stroke-dasharray: calc(3.141 * var(--blazor-load-percentage, 0%) * 0.8), 500%;
            transition: stroke-dasharray 0.05s ease-in-out;
        }

.loading-progress-text {
    position: absolute;
    text-align: center;
    font-weight: bold;
    inset: calc(20vh + 3.25rem) 0 auto 0.2rem;
}

    .loading-progress-text:after {
        content: var(--blazor-load-percentage-text, "Lädt");
    }
