:root {
    --bg: #F7F7F4;
    --text: #121614;
    --muted: #5E6661;
    --accent: #1F5130;
    --on-accent: #FFFFFF;
    --accent-soft: #E6EEE8;
    --surface: #FFFFFF;
    /* Feste Fläche hinter Schaltern, Linien zwischen Bereichen und innerhalb einer Karte */
    --fill: #ECECE7;
    --line: #E3E3DD;
    --line-soft: #EEEEE9;
    --danger: #A3271F;
    --danger-soft: #FBEDEB;
    --chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%235E6661' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    /* Lochansicht: Rough als Grund, darauf Abschlag, Grün, Bunker, Wasser, Spiellinie und Fahne */
    --map-rough: #E4ECDF;
    --map-tee: #8DB97E;
    --map-green: #5E9F57;
    --map-bunker: #EFE3BD;
    --map-water: #9CCBEA;
    --map-penalty: #E9A79D;
    --map-line: #FFFFFF;
    --map-pin: #A3271F;
    color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0F1311;
        --text: #EDF0EE;
        --muted: #9AA59D;
        --accent: #7FC395;
        --on-accent: #0D2216;
        --accent-soft: #1C3124;
        --surface: #181D1A;
        --fill: #222925;
        --line: #2C3530;
        --line-soft: #232A26;
        --danger: #F08A80;
        --danger-soft: #3A1F1C;
        --chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%239AA59D' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
        --map-rough: #1C2A20;
        --map-tee: #3F6E3A;
        --map-green: #4C8C47;
        --map-bunker: #8C7F57;
        --map-water: #2F5F80;
        --map-penalty: #8A4A42;
        --map-line: #E8ECE8;
        --map-pin: #F08A80;
    }
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 17px/1.45 Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
    font-variant-numeric: tabular-nums;
    -webkit-font-smoothing: antialiased;
}

main {
    max-width: 40rem;
    margin: 0 auto;
    padding: max(1.25rem, env(safe-area-inset-top)) 1.25rem 2rem;
}

h1 {
    font-size: 2.125rem;
    line-height: 1.1;
    font-weight: 700;
    letter-spacing: -0.025em;
    margin: 0.5rem 0 1.25rem;
}

/* Bahn und Länge unter „Loch 4“: eigene Zeile, leiser */
h1 small {
    display: block;
    margin-top: 0.375rem;
    color: var(--muted);
    font-size: 0.95rem;
    font-weight: 500;
    letter-spacing: 0;
}

h2 {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.015em;
    margin: 2rem 0 0.5rem;
}

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

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

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

/* Große Tipp-Flächen für eine Hand auf dem Platz */
button {
    min-height: 3.25rem;
    padding: 0 1rem;
    border: 1px solid var(--line);
    border-radius: 0.875rem;
    background: var(--surface);
    color: var(--text);
    font: inherit;
    font-weight: 600;
    touch-action: manipulation;
    cursor: pointer;
    transition: background-color 120ms, border-color 120ms, transform 80ms;
}

button:active {
    transform: scale(0.98);
}

button:disabled,
button[aria-disabled="true"] {
    opacity: 0.4;
}

button.big {
    border-color: var(--accent);
    border-radius: 1rem;
    background: var(--accent);
    color: var(--on-accent);
}

button.danger {
    border-color: transparent;
    background: transparent;
    color: var(--danger);
}

/* Aufklappliste mit eigenem Pfeil; background-color in den einzelnen Regeln, damit der Pfeil bleibt */
select {
    appearance: none;
    -webkit-appearance: none;
    padding-right: 2.75rem;
    background-image: var(--chevron);
    background-repeat: no-repeat;
    background-position: right 0.875rem center;
}

/* Karten ohne Rahmen: die Fläche hebt sich vom Grund ab */
.card {
    background: var(--surface);
    border-radius: 1.25rem;
    padding: 0.25rem 1rem 1rem;
    margin-bottom: 1.25rem;
}

.card h2 {
    margin-top: 1rem;
}

.choice {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
}

/* Weiter zum nächsten Loch: der dunkle Knopf (nicht die großen 9/18-Löcher-Knöpfe der Freien Runde) */
.choice button:last-child:not(.big) {
    border-color: var(--text);
    background: var(--text);
    color: var(--bg);
}

.choice button:first-child:not(.big) {
    background: transparent;
}

.top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    min-height: 2.75rem;
    font-size: 0.85rem;
}

.top a {
    display: inline-flex;
    align-items: center;
    min-height: 2.75rem;
    color: var(--text);
    font-size: 1rem;
    font-weight: 600;
    text-decoration: none;
}

/* Zähler: Bezeichnung, Minus, Wert, Plus; runde Knöpfe, Plus in der Akzentfarbe */
.stepper {
    display: grid;
    grid-template-columns: 1fr 4rem 3rem 4rem;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 0;
    border-bottom: 1px solid var(--line-soft);
}

.stepper .label {
    font-weight: 600;
}

.stepper .label small {
    display: block;
    color: var(--muted);
    font-size: 0.75rem;
    font-weight: 400;
    line-height: 1.25;
}

.stepper button {
    min-height: 4rem;
    border-radius: 50%;
    font-size: 1.625rem;
    font-weight: 500;
    padding: 0;
}

.stepper button:last-child {
    border-color: transparent;
    background: var(--accent-soft);
    color: var(--accent);
}

.stepper output {
    text-align: center;
    font-size: 1.875rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

/* Kennzahlen in einer Reihe: Bezeichnung über der Zahl, dazwischen feine Linien */
.sum {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: minmax(0, 1fr);
    margin: 0.75rem 0 0;
    padding-top: 0.75rem;
    border-top: 1px solid var(--line-soft);
}

.sum span {
    display: flex;
    flex-direction: column;
    /* Bricht eine Bezeichnung um, stehen die Zahlen trotzdem auf einer Linie */
    justify-content: space-between;
    gap: 0.125rem;
    padding-left: 0.875rem;
    border-left: 1px solid var(--line);
    color: var(--muted);
    font-size: 0.8rem;
    line-height: 1.3;
    hyphens: auto;
}

.sum span:first-child {
    padding-left: 0;
    border-left: 0;
}

.sum strong {
    color: var(--text);
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1.15;
    letter-spacing: -0.02em;
}

/* Loch-HCP als Auswahl, Spielvorgabe als Eingabefeld zwischen Minus und Plus */
.stepper.choose {
    grid-template-columns: 1fr 11rem;
}

.stepper select,
.stepper input {
    min-height: 3.25rem;
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 0.875rem;
    background-color: var(--surface);
    color: var(--text);
    font: inherit;
    font-weight: 700;
}

.stepper select {
    padding-left: 0.875rem;
}

.stepper input {
    padding: 0;
    text-align: center;
    font-size: 1.5rem;
}

/* Loch aufgeben: ein leiser Schalter, gedrückt rot */
button.toggle {
    width: 100%;
    margin-top: 0.75rem;
    border-radius: 999px;
    background: transparent;
    color: var(--muted);
}

button.toggle[aria-pressed="true"] {
    border: 1.5px solid var(--danger);
    background: var(--danger-soft);
    color: var(--danger);
}

.choice + .card {
    margin-top: 1.25rem;
}

.hint {
    margin: 0.5rem 0 0;
    color: var(--danger);
    font-size: 0.875rem;
}

/* Übersicht der Löcher: Nummer und Gesamtschläge, Tipp springt zum Loch */
.holes {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(3.25rem, 1fr));
    gap: 0.375rem;
    list-style: none;
    padding: 0;
    margin: 1.25rem 0;
}

.holes button {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 0.25rem 0;
    border-color: var(--line-soft);
    border-radius: 0.75rem;
    font-size: 1.05rem;
    font-weight: 700;
    line-height: 1.15;
}

.holes small {
    color: var(--muted);
    font-size: 0.7rem;
    font-weight: 500;
}

.holes .note {
    min-height: 1.2em;
}

.holes button[aria-current] {
    border: 2px solid var(--accent);
}

/* Zeichen um die Gesamtschläge nach dem Lochergebnis (Spec scorekarte-und-statistik): Doppelkreis, Kreis, keins,
   Quadrat, Doppelquadrat. Nur Form, keine Farbe; der zweite Ring ist ein Umriss in Textfarbe, hell wie dunkel. */
.mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.6em;
    height: 1.6em;
    margin: 0.2rem 0;
    border: 1.5px solid transparent;
    font-variant-numeric: tabular-nums;
}

.mark.circle,
.mark.doubleCircle {
    border-color: currentColor;
    border-radius: 50%;
}

.mark.square,
.mark.doubleSquare {
    border-color: currentColor;
    border-radius: 0.15em;
}

.mark.doubleCircle,
.mark.doubleSquare {
    outline: 1.5px solid currentColor;
    outline-offset: 1.5px;
}

/* Umschalter Netto · Brutto über der Übersicht der Löcher */
.outcome-choice {
    display: inline-grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.25rem;
    margin: 1.25rem 0 0;
    padding: 0.25rem;
    border-radius: 0.875rem;
    background: var(--fill);
}

.outcome-choice button {
    min-height: 2.5rem;
    border-color: transparent;
    border-radius: 0.625rem;
    background: transparent;
    font-size: 0.9rem;
}

.outcome-choice button[aria-pressed="true"] {
    border-color: var(--line);
    background: var(--surface);
}

.outcome-choice + .holes {
    margin-top: 0.75rem;
}

/* Rundenabschluss oben auf der Seite einer beendeten Runde: bestes und schwächstes Loch, darunter der Vergleichssatz */
.closing {
    margin: 0 0 1.25rem;
}

.closing-holes {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}

.closing-hole {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.875rem 0.75rem;
    border-radius: 1rem;
    background: var(--surface);
}

.closing-hole > span:first-child {
    display: grid;
    gap: 0.125rem;
    min-width: 0;
}

.closing-hole small {
    color: var(--muted);
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.closing-hole strong {
    font-size: 1.25rem;
    font-weight: 500;
}

.closing-hole .muted {
    font-size: 0.85rem;
}

.closing-hole .mark {
    flex: none;
    font-size: 1.05rem;
}

/* Vergleichssatz (Rundenabschluss und Statistik): grün, wenn es besser ist, sonst Textfarbe (ruhig bleiben) */
.sentence {
    margin: 0.75rem 0 0;
    font-weight: 500;
}

.sentence.better {
    color: var(--accent);
}

.actions {
    display: grid;
    gap: 0.5rem;
    margin: 1.5rem 0;
}

/* Frühere Runden */
.rounds {
    list-style: none;
    padding: 0;
    margin: 0;
}

.rounds a {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    min-height: 4rem;
    padding: 0.625rem 0;
    border-bottom: 1px solid var(--line);
    color: var(--text);
    text-decoration: none;
}

.rounds strong,
.rounds small {
    display: block;
}

.rounds strong {
    font-weight: 600;
}

.rounds small {
    color: var(--muted);
    font-size: 0.8rem;
}

.rounds a > span:first-child {
    flex: 1;
    min-width: 0;
}

/* Punkte groß, darunter „Punkte“ (ohne Spielvorgabe „Punkte brutto“) und die Gesamtschläge */
.rounds .score {
    flex: 0 0 auto;
    text-align: right;
}

.rounds .score strong {
    color: var(--accent);
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    font-variant-numeric: tabular-nums;
    line-height: 1.1;
}

/* Streifen unter Ort und Lochanzahl: je Loch ein Balken nach den Punkten, 9 und 18 Löcher gleich breit; Höhe 0 ein
   flacher Strich, Lücke unsichtbar */
.rounds .strip {
    display: flex;
    align-items: flex-end;
    gap: 2px;
    width: 4.5rem;
    height: 1.5rem;
    margin-top: 0.375rem;
}

.rounds .strip > span {
    flex: 1;
    height: max(2px, calc(var(--share) * 100%));
    border-radius: 1px;
    background: var(--accent);
}

.rounds .strip > .gap {
    visibility: hidden;
}

/* Nur für Screenreader: sagt nach jedem Tipp den neuen Stand an */
.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
}

.status {
    color: var(--muted);
    font-size: 0.85rem;
}

/* Login, Einladung und Einladen (Knöpfe wie in der App: button.big, .actions) */
.auth label {
    display: block;
    margin: 1.25rem 0 0.375rem;
    color: var(--muted);
    font-size: 0.85rem;
    font-weight: 500;
}

.auth input,
.auth select {
    width: 100%;
    min-height: 3.25rem;
    padding-left: 0.875rem;
    border: 1px solid var(--line);
    border-radius: 0.875rem;
    background-color: var(--surface);
    color: var(--text);
    font: inherit;
}

.auth input {
    padding-right: 0.875rem;
}

.auth h2 {
    margin-top: 2.5rem;
}

.auth button.big {
    width: 100%;
    margin-top: 1.25rem;
}

/* Einstieg in den Platzmodus: sieht aus wie ein Knopf */
.platz-link {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 3.25rem;
    margin-bottom: 1.25rem;
    border-radius: 1rem;
    background: var(--accent);
    color: var(--on-accent);
    font-weight: 600;
    text-decoration: none;
}

/*
 * Platzmodus: das Loch füllt den Bildschirm, alle Knöpfe mindestens 64 px (4rem) für eine Hand und Handschuh. Die
 * Zahl steht groß über Minus und Plus (die Reihenfolge im Markup bleibt Minus, Zahl, Plus).
 */
.platz {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    min-height: calc(100dvh - 3.25rem);
    padding-bottom: env(safe-area-inset-bottom);
}

.platz h1 {
    margin: 0;
    font-size: 1.75rem;
}

.platz button {
    min-height: 4rem;
    border-radius: 1.25rem;
}

.platz-count {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.6fr);
    grid-template-rows: minmax(9rem, 1fr) 8.5rem;
    grid-template-areas: "value value" "down up";
    gap: 0.625rem;
    flex: 1;
}

.platz-count button {
    font-size: 3.25rem;
    font-weight: 400;
    padding: 0;
    border-radius: 1.75rem;
}

.platz-count button:first-child {
    grid-area: down;
}

.platz-count button:last-child {
    grid-area: up;
    background: var(--accent);
    border-color: var(--accent);
    color: var(--on-accent);
}

.platz-value {
    grid-area: value;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.platz-value output {
    font-size: clamp(6rem, 38vw, 10.5rem);
    font-weight: 800;
    line-height: 0.9;
    letter-spacing: -0.06em;
}

.platz-value span {
    color: var(--muted);
    font-size: 1rem;
}

/* Auf dem Grün: Schalter mit Knopf rechts, an in der Akzentfarbe */
.platz-green {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0 1.125rem;
    text-align: left;
}

.platz-green::after {
    content: "";
    flex: none;
    width: 2.75rem;
    height: 1.625rem;
    border-radius: 999px;
    background: radial-gradient(circle at 0.8125rem 50%, #FFFFFF 0.625rem, transparent 0.66rem), var(--line);
}

.platz-green[aria-pressed="true"] {
    border: 1.5px solid var(--accent);
    background: var(--accent-soft);
    color: var(--accent);
}

.platz-green[aria-pressed="true"]::after {
    background: radial-gradient(circle at calc(100% - 0.8125rem) 50%, var(--on-accent) 0.625rem, transparent 0.66rem),
        var(--accent);
}

/* Vier Werte in zwei Reihen, Bezeichnung links und Zahl rechts: in vier Spalten bräche „Gesamtschläge“ um */
.platz-sum {
    grid-auto-flow: row;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    row-gap: 0.375rem;
    margin: 0;
}

.platz-sum span {
    flex-direction: row;
    align-items: baseline;
    padding-right: 0.875rem;
    font-size: 0.85rem;
}

.platz-sum span:nth-child(odd) {
    padding-left: 0;
    border-left: 0;
}

.platz-sum strong {
    font-size: 1.125rem;
}

.platz-penalty {
    display: grid;
    grid-template-columns: 4rem 1fr;
    gap: 0.625rem;
}

.platz-penalty button {
    background: transparent;
    color: var(--danger);
}

.platz-nav {
    margin-top: auto;
}

/* Fairwaytreffer: Zeile „links · Fairway · rechts“ unter den Zählern, gewählter Wert gefüllt */
.fairway-row {
    margin-top: 0.75rem;
}

.fairway-choice {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
}

.fairway-choice button {
    min-height: 2.75rem;
    border-radius: 999px;
    background: transparent;
}

.fairway-choice button[aria-pressed="true"] {
    border-color: var(--accent);
    background: var(--accent);
    color: var(--surface);
}

.fairway-share {
    margin: 0.5rem 0 0;
    font-weight: 600;
}
