:root {
    --ink: #17211b;
    --muted: #5d675f;
    --line: #e3ddd2;
    --paper: #f4f1ea;
    --card: #fffcf7;
    --pine: #14211b;
    --pine-2: #1d2c26;
    --brass: #a68456;
    --danger: #8d2f2f;
    --ok: #1d6b3a;
    --shadow: 0 16px 40px rgba(20, 32, 24, 0.06);
    --sans: "Outfit", "Avenir Next", "Segoe UI", sans-serif;
    --serif: "Fraunces", "Iowan Old Style", Georgia, serif;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
    min-height: 100vh;
    color: var(--ink);
    background:
        radial-gradient(1200px 420px at 10% -10%, rgba(166, 132, 86, 0.16), transparent 55%),
        var(--paper);
    font-family: var(--sans);
    font-size: 16px;
    line-height: 1.45;
}

.nav {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 16px;
    background: rgba(20, 33, 27, 0.94);
    color: #f7f3ea;
    backdrop-filter: blur(16px);
    border-bottom: 1px solid rgba(166, 132, 86, 0.35);
}

.brand {
    color: inherit;
    text-decoration: none;
    font-family: var(--serif);
    font-weight: 560;
    font-size: 1.05rem;
    letter-spacing: -0.03em;
}

.nav-links {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 12px;
    justify-content: flex-end;
}

.nav-links a {
    color: #efe8da;
    text-decoration: none;
    font-size: 0.84rem;
    font-weight: 560;
}

.nav-links a:hover { color: #fff; }

.container {
    width: min(880px, calc(100% - 24px));
    margin: 0 auto;
    padding: 16px 0 48px;
}

.container.narrow { width: min(640px, calc(100% - 32px)); }

.header { margin-bottom: 14px; }

.header h1,
.card h2,
.card h3,
.section-title {
    font-family: var(--serif);
    font-weight: 560;
    letter-spacing: -0.03em;
    color: var(--ink);
}

.header h1 {
    margin: 0 0 4px;
    font-size: 1.55rem;
    line-height: 1.15;
}
.card h2,
.card h3 {
    margin: 0 0 10px;
    font-size: 1.25rem;
}

.header p,
.welcome-section p,
.help-text,
.course-info,
.match-info,
.match-details {
    color: var(--muted);
}

.kicker {
    margin: 0 0 8px;
    color: var(--muted);
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.16em;
    text-transform: uppercase;
}

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

.welcome-section h2 { margin: 0 0 8px; font-size: 1.35rem; }
.card form > .btn:only-of-type { width: 100%; }

.actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 18px;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: auto;
    margin: 0;
    min-height: 48px;
    padding: 12px 16px;
    border-radius: 12px;
    border: 1px solid var(--pine);
    background: var(--pine);
    color: #f7f3ea;
    font: inherit;
    font-weight: 640;
    text-decoration: none;
    cursor: pointer;
}

.btn:hover { background: var(--pine-2); }

.btn-secondary,
.btn.btn-secondary {
    background: transparent;
    color: var(--pine);
}

.btn-secondary:hover { background: rgba(20, 33, 27, 0.06); }

.btn-block { width: 100%; }

.name-grid { display: grid; gap: 16px; margin-bottom: 16px; }
.password-requirements { margin-top: 6px; color: var(--muted); font-size: 0.82rem; }
@media (min-width: 560px) {
    .name-grid { grid-template-columns: 1fr 1fr; }
}
.name-grid .form-group { margin-bottom: 0; }

.form-group { margin-bottom: 16px; }

.form-group label,
.section-title {
    display: block;
    margin-bottom: 8px;
    font-family: var(--sans);
    font-size: 0.92rem;
    font-weight: 680;
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    min-height: 48px;
    padding: 12px 13px;
    border: 1px solid #d9d2c6;
    border-radius: 12px;
    background: #fff;
    color: var(--ink);
    font: inherit;
    font-size: 16px;
}

.form-group textarea { min-height: 96px; resize: vertical; }

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: 2px solid rgba(20, 33, 27, 0.18);
    border-color: var(--pine);
}

.scoring-options,
.choice-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.scoring-option {
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: #fff;
    cursor: pointer;
}

.scoring-option h3 {
    margin: 0 0 4px;
    font-family: var(--sans);
    font-size: 1rem;
}

.scoring-option p { margin: 0; color: var(--muted); font-size: 0.88rem; }

.scoring-option.selected,
.scoring-option:has(input:checked) {
    border-color: var(--pine);
    background: #f3f7f4;
}

.scoring-option input { display: none; }

.match-card,
.course-item,
.player-item,
.match-result {
    padding: 14px 0;
    border-top: 1px solid var(--line);
}

.match-card:first-child,
.course-item:first-child { border-top: 0; padding-top: 0; }

.match-title,
.course-name,
.player-name {
    font-weight: 680;
    color: var(--ink);
}

a.match-link {
    display: block;
    text-decoration: none;
    color: inherit;
}

a.match-link:hover .match-title { color: var(--pine-2); }

.scoring-type,
.stat {
    display: inline-flex;
    align-items: center;
    margin: 8px 8px 0 0;
    padding: 4px 9px;
    border-radius: 999px;
    background: #efeae1;
    color: var(--ink);
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.scoring-type.match-play,
.scoring-type.match_play { background: #e7eef8; color: #1d3f6e; }
.scoring-type.skins { background: #f8efe2; color: #7a4e12; }
.scoring-type.stroke { background: #e8f3ec; color: #1d5a38; }
.stat.status.completed { background: #e8f3ec; color: var(--ok); }

.match-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }

.error,
.success {
    padding: 12px 14px;
    border-radius: 12px;
    margin-bottom: 14px;
}

.error { background: #fdecec; color: var(--danger); }
.success { background: #e8f6ec; color: var(--ok); }

.no-matches { color: var(--muted); padding: 8px 0 4px; }

.back-link { margin-top: 8px; }
.back-link a,
.links a { color: var(--pine); font-weight: 680; text-decoration: none; }
.back-link a:hover,
.links a:hover { text-decoration: underline; }
.links { margin-top: 16px; color: var(--muted); }

.user-selection {
    max-height: 220px;
    overflow: auto;
    padding: 8px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #fff;
}

.user-option {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px;
}

.holes-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: 10px;
}

.hole-input {
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #fff;
}

.hole-input h4 { margin: 0 0 8px; text-align: center; color: var(--ink); font-size: 1rem; }
.mini-header,
.hole-fields { display: flex; gap: 8px; }
.mini-header span,
.hole-fields input { flex: 1; text-align: center; }
.hole-fields input {
    min-height: 44px;
    padding: 8px;
    border: 1px solid #d9d2c6;
    border-radius: 12px;
    background: #fff;
    color: var(--ink);
    font: inherit;
    font-size: 16px;
}
.mini-header { margin-bottom: 6px; color: var(--muted); font-size: 0.75rem; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; }

.finder { display: grid; gap: 10px; }
.finder-row { display: grid; gap: 10px; }
.finder-row input[type="search"] {
    width: 100%;
    min-height: 48px;
    padding: 12px 14px;
    border: 1px solid #d9d2c6;
    border-radius: 12px;
    background: #fff;
    color: var(--ink);
    font: inherit;
    font-size: 16px;
}
.finder-row input[type="search"]:focus {
    outline: 2px solid rgba(20, 33, 27, 0.18);
    border-color: var(--pine);
}
.finder-row .btn {
    width: 100%;
    min-height: 48px;
    border-radius: 12px;
    background: #fff;
}
.course-results {
    display: grid;
    gap: 8px;
    max-height: 280px;
    overflow: auto;
}
.course-result {
    display: block;
    width: 100%;
    min-height: 48px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #fff;
    color: inherit;
    font: inherit;
    text-align: left;
    cursor: pointer;
}
.course-result:hover,
.course-result:focus-visible {
    border-color: var(--pine);
    background: #f3f7f4;
    outline: none;
}
.course-result strong { display: block; font-weight: 680; color: var(--ink); }
.course-result span { display: block; margin-top: 2px; color: var(--muted); font-size: 0.86rem; line-height: 1.35; }
.finder-note,
.attribution { margin: 0; color: var(--muted); font-size: 0.82rem; line-height: 1.4; }
.selected-course {
    padding: 14px;
    border-radius: 12px;
    background: #f3f7f4;
    border: 1px solid var(--pine);
    color: var(--ink);
    font-weight: 680;
}
.selected-course[hidden] { display: none; }
.or-line {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 4px 0;
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}
.or-line::before,
.or-line::after {
    content: "";
    height: 1px;
    flex: 1;
    background: var(--line);
}

body.setup { padding-bottom: calc(92px + env(safe-area-inset-bottom)); }
body.setup .card-title {
    margin: 0 0 6px;
    font-family: var(--serif);
    font-size: 1.45rem;
    font-weight: 560;
    letter-spacing: -0.03em;
}
body.setup .card > .help-text { margin: 0 0 16px; }
body.setup .form-group input,
body.setup .form-group select {
    min-height: 48px;
    font-size: 16px;
}
body.setup .choice-grid { display: grid; gap: 8px; }
body.setup .choice {
    display: block;
    min-height: 48px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #fff;
    cursor: pointer;
}
body.setup .choice input { position: absolute; opacity: 0; pointer-events: none; }
body.setup .choice.selected,
body.setup .choice:has(input:checked) {
    border-color: var(--pine);
    background: #f3f7f4;
}
body.setup .choice strong { display: block; color: var(--pine); font-weight: 680; }
body.setup .choice span { display: block; margin-top: 2px; color: var(--muted); font-size: 0.82rem; line-height: 1.35; }
body.setup .field-note {
    margin: 8px 0 0;
    padding: 12px 14px;
    border-radius: 12px;
    border: 1px solid #c9ddd1;
    background: #f3f7f4;
    color: var(--pine);
    font-size: 0.82rem;
    line-height: 1.4;
}
body.setup .toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    min-height: 48px;
}
body.setup .toggle-row strong { display: block; font-weight: 680; }
body.setup .toggle-row span { display: block; margin-top: 2px; color: var(--muted); font-size: 0.82rem; }
body.setup .switch { position: relative; width: 52px; height: 32px; flex-shrink: 0; }
body.setup .switch input { opacity: 0; width: 0; height: 0; }
body.setup .switch .slider {
    position: absolute;
    inset: 0;
    background: #d7d1c6;
    border-radius: 999px;
    cursor: pointer;
}
body.setup .switch .slider::before {
    content: "";
    position: absolute;
    width: 26px;
    height: 26px;
    left: 3px;
    top: 3px;
    background: #fff;
    border-radius: 50%;
    box-shadow: 0 1px 2px rgba(23, 33, 27, 0.18);
    transition: transform 0.2s;
}
body.setup .switch input:checked + .slider { background: var(--pine); }
body.setup .switch input:checked + .slider::before { transform: translateX(20px); }
body.setup .player-row,
body.setup .guest-row {
    display: grid;
    grid-template-columns: 1fr 88px;
    gap: 8px;
    align-items: end;
    padding: 12px 0;
    border-top: 1px solid var(--line);
}
body.setup .guest-row { grid-template-columns: 1fr 88px 48px; }
body.setup:not(.hcp-on) .player-row,
body.setup:not(.hcp-on) .guest-row { grid-template-columns: 1fr auto; }
body.setup:not(.hcp-on) .hcp-field { display: none; }
body.setup .player-row .meta,
body.setup .hcp-field label {
    display: block;
    margin-bottom: 4px;
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}
body.setup .player-row input,
body.setup .guest-row input {
    width: 100%;
    min-height: 48px;
    padding: 12px 14px;
    border: 1px solid #d9d2c6;
    border-radius: 12px;
    background: #fff;
    color: var(--ink);
    font: inherit;
    font-size: 16px;
}
body.setup .player-row input:focus,
body.setup .guest-row input:focus {
    outline: 2px solid rgba(20, 33, 27, 0.18);
    border-color: var(--pine);
}
body.setup .hcp-field input { text-align: center; font-weight: 680; padding-left: 8px; padding-right: 8px; }
body.setup .user-pick {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 48px;
    padding: 8px 0;
    border-top: 1px solid var(--line);
    cursor: pointer;
}
body.setup .user-pick input { width: 20px; height: 20px; accent-color: var(--pine); }
body.setup .user-pick .name { font-weight: 680; }
body.setup .roster-block[data-empty="1"] { display: none; }
body.setup .btn-icon,
body.setup .btn-add {
    min-height: 48px;
    border-radius: 12px;
    font: inherit;
    font-weight: 680;
    cursor: pointer;
}
body.setup .btn-icon {
    width: 48px;
    border: 1px solid var(--line);
    background: #fff;
    color: var(--danger);
}
body.setup .btn-add {
    width: 100%;
    margin-top: 8px;
    border: 1px dashed #c9bfae;
    background: transparent;
    color: var(--pine);
}
body.setup .setup-bar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 30;
    padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
    background: rgba(244, 241, 234, 0.96);
    border-top: 1px solid var(--line);
}
body.setup .setup-bar-inner {
    width: min(640px, 100%);
    margin: 0 auto;
    display: grid;
    grid-template-columns: 1fr 1.7fr;
    gap: 10px;
}
body.setup .setup-bar .btn { width: 100%; min-height: 48px; border-radius: 12px; }
@media (min-width: 720px) {
    body.setup .choice-grid.three { grid-template-columns: repeat(3, 1fr); }
}

.players-list { margin: 8px 0 16px; }
.player-badge {
    display: inline-block;
    margin-left: 6px;
    font-size: 0.75rem;
    color: var(--muted);
}

details.manual { margin-top: 8px; }
details.manual summary { cursor: pointer; font-weight: 680; color: var(--pine); }

@media (max-width: 700px) {
    .scoring-options,
    .choice-row { grid-template-columns: 1fr; }
}

body.gate { background: var(--paper); }
.gate-hero {
    position: relative;
    display: grid;
    align-items: end;
    min-height: min(82vh, 760px);
    color: #f7f3ea;
    overflow: hidden;
}
.gate-hero img,
.gate-band img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.gate-hero::after {
    content: "";
    position: absolute;
    inset: 0;
    background:
        linear-gradient(180deg, rgba(20, 33, 27, 0.08) 0%, rgba(20, 33, 27, 0.18) 42%, rgba(20, 33, 27, 0.88) 100%);
}
.gate-hero-copy {
    position: relative;
    z-index: 1;
    width: min(760px, calc(100% - 32px));
    margin: 0 auto;
    padding: 72px 0 40px;
}
.gate-hero .kicker { color: rgba(247, 243, 234, 0.72); }
.gate-hero h1 {
    margin: 0 0 12px;
    max-width: 14ch;
    color: #f7f3ea;
    font-family: var(--serif);
    font-size: clamp(2.3rem, 7vw, 4rem);
    font-weight: 560;
    line-height: 1.02;
    letter-spacing: -0.035em;
}
.gate-hero p {
    max-width: 38rem;
    margin: 0;
    color: rgba(247, 243, 234, 0.86);
    font-size: 1.05rem;
}
.gate-hero .actions { margin-top: 20px; }
.gate-hero .actions .btn:not(.btn-secondary),
.gate-band .btn {
    background: #f4f1ea;
    border-color: #f4f1ea;
    color: var(--pine);
}
.gate-hero .actions .btn:not(.btn-secondary):hover,
.gate-band .btn:hover { background: #fff; }
.gate-hero .btn-secondary {
    border-color: rgba(247, 243, 234, 0.55);
    color: #f7f3ea;
    background: transparent;
}
.gate-hero .btn-secondary:hover { background: rgba(247, 243, 234, 0.12); }
.gate-story {
    width: min(980px, calc(100% - 24px));
    margin: 28px auto;
    display: grid;
    gap: 22px;
}
.gate-photo {
    min-height: 280px;
    border-radius: 18px;
    overflow: hidden;
}
.gate-photo img {
    width: 100%;
    height: 100%;
    min-height: 280px;
    object-fit: cover;
    display: block;
}
.gate-story h2,
.gate-band h2 {
    margin: 0 0 8px;
    font-family: var(--serif);
    font-size: clamp(1.7rem, 3vw, 2.3rem);
    font-weight: 560;
    letter-spacing: -0.03em;
    line-height: 1.1;
}
.gate-points {
    list-style: none;
    margin: 18px 0 0;
    padding: 0;
    display: grid;
    gap: 16px;
}
.gate-points li {
    padding-top: 14px;
    border-top: 1px solid var(--line);
}
.gate-points strong { display: block; margin-bottom: 4px; }
.gate-points li { color: var(--muted); }
.gate-points strong { color: var(--ink); }
.gate-band {
    position: relative;
    display: grid;
    align-items: end;
    width: min(980px, calc(100% - 24px));
    min-height: 360px;
    margin: 8px auto 28px;
    border-radius: 18px;
    overflow: hidden;
    color: #f7f3ea;
}
.gate-band-copy {
    position: relative;
    z-index: 1;
    padding: 28px;
    background: linear-gradient(180deg, rgba(20, 33, 27, 0) 0%, rgba(20, 33, 27, 0.82) 58%);
}
.gate-band p { max-width: 36rem; margin: 0 0 16px; color: rgba(247, 243, 234, 0.86); }
.gate-band h2 { color: #f7f3ea; }
@media (min-width: 860px) {
    .gate-story {
        grid-template-columns: 1.05fr 0.95fr;
        align-items: center;
        gap: 40px;
        margin-top: 48px;
        margin-bottom: 48px;
    }
    .gate-photo,
    .gate-photo img { min-height: 460px; }
}
