:root {
    --bg: #f4f7f4;
    --surface: #ffffff;
    --text: #18221b;
    --muted: #66736a;
    --line: #dce4de;
    --green: #17643a;
    --green-dark: #104b2c;
    --green-soft: #e7f2eb;
    --danger: #a63737;
    --radius: 18px;
    --shadow:
        0 8px 28px rgba(20, 40, 28, 0.07);
}

* {
    box-sizing: border-box;
}

html {
    background: var(--bg);
}

body {
    margin: 0;
    color: var(--text);
    background: var(--bg);
    font-family:
        Inter,
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        sans-serif;
}

button,
input,
select {
    font: inherit;
}

.shell {
    width: min(
        1180px,
        calc(100% - 32px)
    );
    margin-inline: auto;
}

.topbar {
    background: var(--surface);
    border-bottom: 1px solid var(--line);
}

.topbar-inner {
    height: 68px;
    display: flex;
    align-items: center;
}

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

.brand-mark {
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    border-radius: 12px;
    background: var(--green-soft);
}

.main {
    padding-block: 32px 56px;
}

.page-heading {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 24px;
}

.page-heading h1 {
    margin: 5px 0 7px;
    font-size: clamp(
        30px,
        5vw,
        44px
    );
    line-height: 1.05;
}

.page-heading p {
    max-width: 680px;
    margin: 0;
    color: var(--muted);
    font-size: 16px;
}

.eyebrow {
    color: var(--green);
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.card {
    margin-bottom: 20px;
    padding: 24px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.section-title {
    font-size: 18px;
    font-weight: 800;
}

.section-help {
    margin-top: 4px;
    color: var(--muted);
    font-size: 13px;
}

.section-heading-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 20px;
}

.form-grid {
    display: grid;
    grid-template-columns:
        minmax(220px, 2fr)
        minmax(160px, 1fr)
        minmax(180px, 1fr);
    gap: 16px;
    margin-top: 20px;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 7px;
}

.field > span {
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}

input,
select {
    width: 100%;
    min-height: 46px;
    padding: 10px 12px;
    color: var(--text);
    background: #fff;
    border: 1px solid #ccd7cf;
    border-radius: 11px;
    outline: none;
}

input:focus,
select:focus {
    border-color: var(--green);
    box-shadow:
        0 0 0 3px
        rgba(23, 100, 58, 0.11);
}

.players {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.player-row {
    display: grid;
    grid-template-columns:
        38px
        minmax(150px, 1.4fr)
        120px
        minmax(200px, 1fr)
        42px;
    align-items: end;
    gap: 12px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: #fbfcfb;
}

.player-number {
    align-self: center;
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    color: var(--green);
    background: var(--green-soft);
    border-radius: 50%;
    font-weight: 800;
}

.remove-player {
    width: 42px;
    height: 46px;
    padding: 0;
    color: var(--danger);
    background: transparent;
    border: 0;
    border-radius: 10px;
    cursor: pointer;
    font-size: 25px;
}

.remove-player:hover {
    background: #faeeee;
}

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    padding: 9px 16px;
    border: 0;
    border-radius: 11px;
    cursor: pointer;
    font-weight: 800;
    text-decoration: none;
}

.button-primary {
    color: #fff;
    background: var(--green);
}

.button-primary:hover {
    background: var(--green-dark);
}

.button-secondary {
    color: var(--green);
    background: var(--green-soft);
}

.button-large {
    min-width: 180px;
    min-height: 50px;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
}

.message {
    margin-bottom: 18px;
    padding: 14px 16px;
    border-radius: 12px;
}

.message-error {
    color: #762929;
    background: #fceaea;
    border: 1px solid #f2c7c7;
}

.participant-grid {
    display: grid;
    grid-template-columns:
        repeat(
            auto-fit,
            minmax(180px, 1fr)
        );
    gap: 12px;
    margin-top: 18px;
}

.participant-card {
    display: flex;
    flex-direction: column;
    gap: 5px;
    padding: 16px;
    background: #f7faf8;
    border: 1px solid var(--line);
    border-radius: 13px;
}

.participant-card span {
    color: var(--muted);
    font-size: 13px;
}

.table-wrap {
    overflow-x: auto;
    margin-top: 18px;
}

.scorecard {
    width: 100%;
    min-width: 620px;
    border-collapse: collapse;
}

.scorecard th,
.scorecard td {
    padding: 11px 12px;
    text-align: center;
    border-bottom: 1px solid var(--line);
}

.scorecard th {
    color: var(--muted);
    background: #f7faf8;
    font-size: 12px;
    font-weight: 800;
}

.hole-number {
    color: var(--green);
    font-weight: 800;
}

.score-empty {
    color: #a7afa9;
}

@media (
    max-width: 780px
) {
    .shell {
        width: min(
            100% - 20px,
            1180px
        );
    }

    .main {
        padding-top: 22px;
    }

    .page-heading,
    .round-heading {
        align-items: flex-start;
        flex-direction: column;
    }

    .card {
        padding: 18px;
        border-radius: 15px;
    }

    .form-grid {
        grid-template-columns: 1fr;
    }

    .player-row {
        grid-template-columns:
            36px
            1fr
            42px;
    }

    .player-row .field {
        grid-column:
            2 / 3;
    }

    .player-row .remove-player {
        grid-column: 3;
        grid-row: 1;
    }

    .player-number {
        grid-column: 1;
        grid-row: 1;
    }

    .handicap-field,
    .tee-field {
        grid-column:
            1 / -1 !important;
    }

    .form-actions {
        position: sticky;
        bottom: 12px;
    }

    .form-actions .button {
        width: 100%;
        box-shadow:
            0 8px 22px
            rgba(20, 40, 28, 0.18);
    }
}

.csrf-form {
    display: none;
}

.save-state {
    min-width: 110px;
    padding: 7px 11px;
    color: var(--muted);
    background: #f3f6f4;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 800;
    text-align: center;
}

.save-state-saving {
    color: #725b18;
    background: #fff5cf;
}

.save-state-ok {
    color: var(--green);
    background: var(--green-soft);
}

.save-state-error {
    color: #8d2d2d;
    background: #fae7e7;
}

.score-player-name {
    display: block;
    min-width: 82px;
}

.score-cell {
    padding: 5px !important;
}

.score-input {
    width: 66px;
    min-height: 42px;
    padding: 6px;
    margin-inline: auto;
    text-align: center;
    font-size: 17px;
    font-weight: 800;
    border-radius: 9px;
}

.score-input::-webkit-inner-spin-button,
.score-input::-webkit-outer-spin-button {
    margin: 0;
    appearance: none;
}

.score-input-saved {
    border-color: var(--green);
    background: var(--green-soft);
}

.score-input-error {
    border-color: var(--danger);
    background: #fff0f0;
}

.subtotal-row th,
.subtotal-row td {
    color: var(--text);
    background: #f1f5f2;
    font-weight: 800;
}

.grand-total-row th,
.grand-total-row td {
    color: #fff;
    background: var(--green);
    border-bottom: 0;
    font-size: 15px;
    font-weight: 900;
}

@media (max-width: 780px) {
    .scorecard-card {
        padding-inline: 10px;
    }

    .scorecard th,
    .scorecard td {
        padding-inline: 8px;
    }

    .score-input {
        width: 58px;
    }
}

.scorecard-live th small {
    display: block;
    margin-top: 3px;
    font-weight: 600;
}

.hole-meta {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 4px 8px;
    margin-bottom: 6px;
    color: var(--muted);
    font-size: 10px;
    white-space: nowrap;
}

.stroke-badge {
    width: fit-content;
    margin: 0 auto 5px;
    padding: 2px 6px;
    color: var(--green-dark);
    background: var(--green-soft);
    border-radius: 999px;
    font-size: 10px;
    font-weight: 900;
}

.net-score {
    margin-top: 5px;
    color: var(--muted);
    font-size: 10px;
}

.net-score strong {
    color: var(--green);
    font-size: 13px;
}

.total-pair {
    display: flex;
    justify-content: center;
    gap: 12px;
    white-space: nowrap;
    font-size: 11px;
}

.total-pair span {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.total-pair strong {
    font-size: 16px;
}

.sticky-hole {
    position: sticky;
    left: 0;
    z-index: 2;
    background: inherit;
}

thead .sticky-hole {
    z-index: 4;
}

@media (max-width: 780px) {
    .scorecard-live {
        min-width: max-content;
    }

    .scorecard-live .score-cell {
        min-width: 118px;
    }

    .hole-meta {
        white-space: normal;
    }
}

.betting-player-grid {
    display: grid;
    grid-template-columns:
        repeat(
            auto-fit,
            minmax(170px, 1fr)
        );
    gap: 10px;
    margin-top: 18px;
}

.betting-player-option {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 13px;
    border: 1px solid var(--line);
    border-radius: 12px;
    cursor: pointer;
}

.betting-player-option input {
    width: 20px;
    min-height: 20px;
}

.betting-player-option span {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.betting-player-option small {
    color: var(--muted);
}

.betting-actions {
    margin-top: 18px;
}

.circle-table {
    border-collapse: collapse;
    min-width: 1050px;
    width: 100%;
}

.circle-table th,
.circle-table td {
    min-width: 46px;
    padding: 7px;
    text-align: center;
    border-bottom: 1px solid var(--line);
}

.circle-table th {
    background: #f7faf8;
    font-size: 11px;
}

.circle-table tbody th {
    min-width: 130px;
    text-align: left;
}

.circle-table tbody th small {
    display: block;
    margin-top: 3px;
    color: var(--muted);
    font-weight: 600;
}

.circle-toggle {
    display: grid;
    place-items: center;
    cursor: pointer;
}

.circle-toggle input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.circle-toggle span {
    display: grid;
    place-items: center;
    width: 29px;
    height: 29px;
    color: #b7c1ba;
    border: 1px solid var(--line);
    border-radius: 50%;
}

.circle-toggle input:checked + span {
    color: #fff;
    background: var(--green);
    border-color: var(--green);
}

.betting-save-sticky {
    position: sticky;
    bottom: 12px;
    z-index: 5;
}

@media (max-width: 780px) {
    .betting-save-sticky .button {
        width: 100%;
    }
}

.round-heading-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.betting-live-table {
    width: 100%;
    min-width: 1180px;
    border-collapse: collapse;
}

.betting-live-table th,
.betting-live-table td {
    min-width: 45px;
    padding: 9px 7px;
    text-align: center;
    border-bottom: 1px solid var(--line);
    font-weight: 800;
}

.betting-live-table thead th {
    color: var(--muted);
    background: #f7faf8;
    font-size: 11px;
}

.betting-live-table tbody th {
    min-width: 170px;
    text-align: left;
    background: #fff;
}

.betting-live-table tbody th strong,
.betting-live-table tbody th small {
    display: block;
}

.betting-live-table tbody th small {
    margin-top: 3px;
    color: var(--muted);
    font-weight: 600;
}

.betting-total-col {
    border-left: 2px solid var(--line);
    border-right: 2px solid var(--line);
    background: #f3f6f4;
    font-weight: 900 !important;
}

.betting-value-positive {
    color: var(--green);
}

.betting-value-negative {
    color: #a83232;
}

.betting-value-zero {
    color: var(--text);
}

.betting-value-pending {
    color: #aeb7b1;
}

@media (max-width: 780px) {
    .betting-live-card {
        padding-inline: 10px;
    }
}
