:root {
    color-scheme: light;
    --bg: #f6f7f2;
    --surface: #ffffff;
    --surface-soft: #eef3ea;
    --text: #18211c;
    --muted: #667168;
    --line: #d9dfd7;
    --green: #1f7a4d;
    --green-dark: #135d39;
    --blue: #235a8d;
    --amber: #c78118;
    --red: #b64236;
    --shadow: 0 18px 45px rgba(20, 34, 28, 0.12);
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
    background: var(--bg);
}

body {
    min-height: 100%;
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 16px;
    line-height: 1.45;
}

a {
    color: inherit;
    text-decoration: none;
}

button,
input,
select {
    font: inherit;
}

button {
    cursor: pointer;
}

button:disabled {
    cursor: not-allowed;
    opacity: 0.45;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 18px;
    align-items: center;
    min-height: 68px;
    padding: 12px clamp(16px, 4vw, 40px);
    background: rgba(246, 247, 242, 0.94);
    border-bottom: 1px solid var(--line);
    backdrop-filter: blur(16px);
}

.brand {
    font-weight: 800;
}

.topbar nav {
    display: flex;
    gap: 6px;
}

.topbar nav a {
    min-height: 40px;
    padding: 9px 12px;
    border-radius: 8px;
    color: var(--muted);
    font-weight: 700;
}

.topbar nav a.active,
.topbar nav a:hover {
    background: var(--surface-soft);
    color: var(--green-dark);
}

.topbar form {
    display: flex;
    gap: 10px;
    align-items: center;
    color: var(--muted);
}

.page {
    width: min(1180px, 100%);
    margin: 0 auto;
    padding: 22px clamp(14px, 4vw, 34px) 70px;
}

.login-page {
    display: grid;
    place-items: center;
    min-height: 100vh;
    padding: 22px;
    background:
        linear-gradient(140deg, rgba(31, 122, 77, 0.12), transparent 42%),
        linear-gradient(35deg, rgba(35, 90, 141, 0.12), transparent 48%),
        var(--bg);
}

.login-shell {
    width: min(420px, 100%);
}

.login-panel,
.panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.login-panel {
    padding: clamp(24px, 7vw, 38px);
}

.hero-band,
.hero-band.compact,
.match-hero,
.page-band {
    margin-bottom: 18px;
    padding: clamp(20px, 5vw, 36px);
    border-radius: 8px;
    background:
        linear-gradient(135deg, rgba(31, 122, 77, 0.16), transparent 46%),
        linear-gradient(25deg, rgba(199, 129, 24, 0.13), transparent 56%),
        #fbfcf7;
    border: 1px solid var(--line);
}

.hero-band h1,
.match-hero h1,
.page-band h1,
.login-panel h1 {
    margin: 0;
    font-size: clamp(30px, 8vw, 54px);
    line-height: 1;
}

.hero-band.compact h1 {
    font-size: clamp(28px, 6vw, 44px);
}

.eyebrow {
    margin: 0 0 8px;
    color: var(--green-dark);
    font-size: 0.78rem;
    font-weight: 800;
    letter-spacing: 0;
    text-transform: uppercase;
}

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

.admin-grid,
.player-grid {
    display: grid;
    grid-template-columns: minmax(280px, 360px) 1fr;
    gap: 18px;
    align-items: start;
    margin-bottom: 18px;
}

.panel {
    padding: clamp(16px, 4vw, 24px);
}

.panel h2 {
    margin: 0 0 16px;
    font-size: 1.2rem;
}

.full-width {
    width: 100%;
}

.stacked-form {
    display: grid;
    gap: 14px;
}

label {
    display: grid;
    gap: 7px;
    color: var(--muted);
    font-size: 0.9rem;
    font-weight: 700;
}

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

input:focus,
select:focus {
    border-color: var(--green);
    box-shadow: 0 0 0 3px rgba(31, 122, 77, 0.15);
}

.primary-button,
.ghost-button,
.small-button,
.step-button {
    border: 0;
    border-radius: 8px;
    font-weight: 800;
}

.primary-button {
    min-height: 48px;
    padding: 12px 18px;
    color: #ffffff;
    background: var(--green);
}

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

.ghost-button,
.small-button {
    min-height: 38px;
    padding: 9px 12px;
    color: var(--green-dark);
    background: var(--surface-soft);
}

.ghost-button:hover,
.small-button:hover {
    background: #dfead9;
}

.wide {
    width: 100%;
}

.section-title {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: center;
    margin-bottom: 12px;
}

.section-title h2 {
    margin: 0;
}

.section-title span {
    min-width: 34px;
    padding: 5px 8px;
    border-radius: 8px;
    text-align: center;
    font-weight: 800;
    background: var(--surface-soft);
}

.notice {
    margin: 0 0 18px;
    padding: 12px 14px;
    border-radius: 8px;
    font-weight: 700;
}

.notice.success {
    color: var(--green-dark);
    background: #e5f3e8;
    border: 1px solid #b9dfc2;
}

.notice.error {
    color: #7a1f18;
    background: #fde8e4;
    border: 1px solid #f0b7ad;
}

.user-list,
.match-list {
    display: grid;
    gap: 10px;
}

.user-row,
.match-item {
    display: grid;
    gap: 14px;
    align-items: center;
    min-height: 74px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #ffffff;
}

.user-row {
    grid-template-columns: minmax(180px, 1fr) auto;
}

.user-row strong,
.match-item strong {
    display: block;
    margin-bottom: 4px;
}

.user-row span,
.match-item span {
    display: block;
    color: var(--muted);
    font-size: 0.92rem;
}

.user-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: flex-end;
    align-items: center;
}

.inline-form {
    display: flex;
    gap: 8px;
}

.inline-form input {
    width: 150px;
    min-height: 38px;
}

.match-item {
    grid-template-columns: 1fr auto;
}

.match-item:hover {
    border-color: rgba(31, 122, 77, 0.55);
    box-shadow: 0 10px 26px rgba(20, 34, 28, 0.08);
}

.match-score {
    display: grid;
    grid-template-columns: auto auto;
    gap: 4px 9px;
    align-items: center;
    text-align: right;
}

.match-score b {
    font-size: 1.35rem;
}

.match-score em {
    grid-column: 1 / -1;
    justify-self: end;
    padding: 3px 8px;
    border-radius: 8px;
    font-size: 0.78rem;
    font-style: normal;
    font-weight: 800;
}

.status-pill,
.match-score em {
    color: var(--green-dark);
    background: #e5f3e8;
}

.status-pill.finished,
.match-score em.finished {
    color: #5f4a10;
    background: #f8e7bd;
}

.muted-pill {
    color: var(--muted);
    background: #edf0ec;
}

.status-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 30px;
    padding: 5px 9px;
    border-radius: 8px;
    font-size: 0.82rem;
    font-weight: 800;
}

.empty-state {
    margin: 0;
    color: var(--muted);
}

.match-hero {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 18px;
    align-items: end;
    position: relative;
}

.back-link {
    grid-column: 1 / -1;
    width: fit-content;
    color: var(--green-dark);
    font-weight: 800;
}

.totals {
    display: grid;
    grid-template-columns: repeat(3, minmax(84px, 1fr));
    gap: 10px;
}

.totals div {
    min-height: 78px;
    padding: 12px;
    border: 1px solid rgba(31, 122, 77, 0.22);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.72);
}

.totals span {
    display: block;
    color: var(--muted);
    font-size: 0.82rem;
    font-weight: 700;
}

.totals strong {
    display: block;
    margin-top: 5px;
    font-size: 1.8rem;
    line-height: 1;
}

.score-form {
    margin-bottom: 14px;
}

.scorecard {
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #ffffff;
    box-shadow: var(--shadow);
}

.score-head,
.score-row {
    display: grid;
    grid-template-columns: minmax(72px, 1fr) minmax(72px, 0.8fr) minmax(178px, 1.5fr);
    gap: 10px;
    align-items: center;
    min-height: 66px;
    padding: 10px 12px;
}

.score-head {
    min-height: 44px;
    color: var(--muted);
    background: var(--surface-soft);
    font-size: 0.8rem;
    font-weight: 800;
    text-transform: uppercase;
}

.score-row {
    border-top: 1px solid var(--line);
}

.score-row.score-birdie {
    background: #eff8ef;
}

.score-row.score-eagle {
    background: #e9f3fb;
}

.score-row.score-bogey {
    background: #fff8e8;
}

.score-row.score-double {
    background: #fdecea;
}

.hole-number {
    font-size: 1.1rem;
    font-weight: 900;
}

.score-input {
    min-height: 44px;
    text-align: center;
    font-weight: 900;
}

.stroke-control {
    display: grid;
    grid-template-columns: 46px minmax(68px, 1fr) 46px;
    gap: 8px;
    align-items: center;
}

.step-button {
    width: 46px;
    height: 44px;
    color: var(--green-dark);
    background: var(--surface-soft);
    font-size: 1.4rem;
    line-height: 1;
}

.step-button:active {
    transform: translateY(1px);
}

.sticky-actions {
    position: sticky;
    bottom: 0;
    z-index: 10;
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 10px;
    align-items: center;
    margin-top: 12px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.94);
    box-shadow: 0 -12px 32px rgba(20, 34, 28, 0.1);
    backdrop-filter: blur(14px);
}

.save-status {
    color: var(--muted);
    font-size: 0.9rem;
    font-weight: 700;
}

.finish-form {
    margin-top: 12px;
}

@media (max-width: 820px) {
    .topbar {
        grid-template-columns: 1fr auto;
        gap: 10px;
    }

    .topbar nav {
        grid-column: 1 / -1;
        order: 3;
    }

    .topbar form span {
        display: none;
    }

    .admin-grid,
    .player-grid,
    .match-hero {
        grid-template-columns: 1fr;
    }

    .user-row,
    .match-item {
        grid-template-columns: 1fr;
    }

    .user-actions {
        justify-content: flex-start;
    }

    .inline-form {
        width: 100%;
    }

    .inline-form input {
        width: 100%;
    }

    .match-score {
        grid-template-columns: auto auto auto;
        justify-content: start;
        text-align: left;
    }

    .match-score em {
        grid-column: auto;
    }

    .totals {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 560px) {
    .page {
        padding-inline: 10px;
    }

    .hero-band,
    .hero-band.compact,
    .match-hero,
    .page-band,
    .panel {
        padding: 16px;
    }

    .totals {
        gap: 6px;
    }

    .totals div {
        min-height: 66px;
        padding: 9px;
    }

    .totals strong {
        font-size: 1.35rem;
    }

    .score-head,
    .score-row {
        grid-template-columns: 58px 62px minmax(156px, 1fr);
        gap: 6px;
        padding-inline: 8px;
    }

    .stroke-control {
        grid-template-columns: 40px minmax(58px, 1fr) 40px;
        gap: 6px;
    }

    .step-button {
        width: 40px;
    }

    .sticky-actions {
        grid-template-columns: 1fr auto;
    }

    .save-status {
        order: 3;
        grid-column: 1 / -1;
    }
}
