/* ── Reset & Variables ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --bg:        #0d1117;
    --surface:   #161b22;
    --surface2:  #21262d;
    --border:    #30363d;
    --text:      #e6edf3;
    --text2:     #8b949e;
    --gold:      #B98E3E;
    --gold-dk:   #96722f;
    --gold-lt:   #d4a84a;
    --green:     #3fb950;
    --red:       #f85149;
    --radius:    8px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    min-height: 100vh;
}

/* ── Navbar ───────────────────────────────────────────────────── */
.navbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.25rem;
    height: 56px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-brand {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--gold);
    white-space: nowrap;
}

.nav-links { display: flex; gap: 0.25rem; }

.nav-link {
    color: var(--text2);
    text-decoration: none;
    padding: 0.4rem 0.75rem;
    border-radius: var(--radius);
    font-size: 0.875rem;
    transition: background 0.15s, color 0.15s;
}
.nav-link:hover { background: var(--surface2); color: var(--text); }
.nav-link.active { color: var(--gold); background: rgba(185,142,62,0.12); }

/* ── Layout ───────────────────────────────────────────────────── */
.container {
    max-width: 800px;
    margin: 0 auto;
    padding: 1.5rem 1rem 3rem;
}

.view { display: none; }
.view.active { display: block; }

h1 { font-size: 1.5rem; margin-bottom: 1rem; color: var(--gold); }
h2 { font-size: 1.15rem; margin-bottom: 0.75rem; color: var(--text); }

/* ── Cards ────────────────────────────────────────────────────── */
.card, fieldset {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    margin-bottom: 1rem;
}

fieldset { padding-top: 0.75rem; }

legend {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--gold);
    padding: 0 0.35rem;
}

/* ── Form Fields ──────────────────────────────────────────────── */
.field { margin-bottom: 0.75rem; }
.field label {
    display: block;
    font-size: 0.85rem;
    color: var(--text2);
    margin-bottom: 0.25rem;
}

input[type="text"],
input[type="email"],
input[type="tel"],
input[type="number"],
input[type="password"],
select,
textarea {
    width: 100%;
    padding: 0.6rem 0.75rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 0.95rem;
    font-family: inherit;
    transition: border-color 0.15s;
    resize: vertical;
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--gold);
}

.input-sm { width: 80px; display: inline-block; }

/* ── Radio Cards (golfer picks & payment) ─────────────────────── */
.radio-group {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.radio-card {
    flex: 1 1 auto;
    min-width: 0;
    cursor: pointer;
}
.radio-card input { position: absolute; opacity: 0; pointer-events: none; }
.radio-card span {
    display: block;
    text-align: center;
    padding: 0.55rem 0.5rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.85rem;
    transition: border-color 0.15s, background 0.15s;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.radio-card:hover span { border-color: var(--gold-dk); }
.radio-card input:checked + span {
    border-color: var(--gold);
    background: rgba(185,142,62,0.15);
    color: var(--gold-lt);
    font-weight: 600;
}

/* ── Buttons ──────────────────────────────────────────────────── */
.btn {
    display: inline-block;
    padding: 0.65rem 1.5rem;
    border: none;
    border-radius: var(--radius);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, opacity 0.15s;
    text-decoration: none;
    text-align: center;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-sm { padding: 0.4rem 0.9rem; font-size: 0.85rem; }

.btn-gold {
    background: var(--gold);
    color: #111;
}
.btn-gold:hover:not(:disabled) { background: var(--gold-lt); }

.btn-outline {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text);
}
.btn-outline:hover { border-color: var(--gold); color: var(--gold); }

/* ── Status & Errors ──────────────────────────────────────────── */
.status-msg {
    text-align: center;
    padding: 2rem 1rem;
    color: var(--text2);
}
.status-msg h2 { color: var(--green); margin-bottom: 0.5rem; }

.error-box {
    background: rgba(248,81,73,0.1);
    border: 1px solid var(--red);
    color: var(--red);
    border-radius: var(--radius);
    padding: 0.75rem 1rem;
    margin-bottom: 1rem;
    font-size: 0.875rem;
}

.hint { color: var(--text2); font-size: 0.8rem; margin-bottom: 0.5rem; }

.info-line {
    color: var(--text2);
    font-size: 0.875rem;
    margin-bottom: 0.75rem;
}

/* ── Admin ────────────────────────────────────────────────────── */
.admin-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-bottom: 0.75rem;
}
.admin-row label { font-size: 0.875rem; color: var(--text2); }

#upload-status {
    font-size: 0.85rem;
    margin-top: 0.5rem;
}

/* ── Wizard ──────────────────────────────────────────────────── */
.step-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    margin-bottom: 1.5rem;
    padding: 0 1rem;
}

.step-dot {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.2rem;
    min-width: 48px;
}
.step-dot span {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.85rem;
    background: var(--surface2);
    color: var(--text2);
    border: 2px solid var(--border);
    transition: all 0.2s;
}
.step-dot small {
    font-size: 0.65rem;
    color: var(--text2);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.step-dot.active span {
    background: var(--gold);
    color: #111;
    border-color: var(--gold);
}
.step-dot.completed span {
    background: var(--green);
    color: #111;
    border-color: var(--green);
}
.step-dot.active small,
.step-dot.completed small { color: var(--text); }

.step-line {
    flex: 1;
    height: 2px;
    background: var(--border);
    margin: 0 0.25rem;
    margin-bottom: 1rem;
    transition: background 0.2s;
}
.step-line.completed { background: var(--green); }

.wizard-panel { display: none; }
.wizard-panel.active { display: block; }

.wizard-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 1rem;
    gap: 0.5rem;
}

.confirm-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
    margin-bottom: 0.75rem;
}
.confirm-table th, .confirm-table td {
    padding: 0.5rem 0.5rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}
.confirm-table th {
    color: var(--gold);
    font-size: 0.75rem;
    text-transform: uppercase;
}

.confirm-text-box {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
    font-size: 0.8rem;
    color: var(--text);
    white-space: pre-wrap;
    word-wrap: break-word;
    max-height: 300px;
    overflow-y: auto;
    font-family: inherit;
}

/* ── Leaderboard Header ──────────────────────────────────────── */
#lb-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}
#lb-header h1 { margin-bottom: 0; }

/* ── Tabs ────────────────────────────────────────────────────── */
.tabs {
    display: flex;
    gap: 0.25rem;
    border-bottom: 2px solid var(--border);
    margin-bottom: 1rem;
}

.tab {
    background: none;
    border: none;
    color: var(--text2);
    font-size: 0.875rem;
    font-weight: 600;
    padding: 0.6rem 1rem;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: color 0.15s, border-color 0.15s;
}
.tab:hover { color: var(--text); }
.tab.active {
    color: var(--gold);
    border-bottom-color: var(--gold);
}

.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── Leaderboard Table (shared) ──────────────────────────────── */
.lb-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

.lb-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}
.lb-table th, .lb-table td {
    padding: 0.6rem 0.5rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
.lb-table th {
    color: var(--gold);
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    position: sticky;
    top: 0;
    background: var(--surface);
}
.lb-table tr:hover { background: var(--surface2); }
.lb-table td.num { text-align: center; }
.lb-table th.num { text-align: center; }

/* ── Pool Standings ──────────────────────────────────────────── */
.rank-medal { font-size: 1rem; margin-right: 0.2rem; }
.rank-num { font-weight: 700; color: var(--text); }
.rank-1 .rank-num { color: var(--gold-lt); }
.rank-2 .rank-num { color: #c0c0c0; }
.rank-3 .rank-num { color: #cd7f32; }

.pick-cell {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}
.pick-name {
    font-size: 0.8rem;
    color: var(--text);
    line-height: 1.2;
}

/* ── Position Badges ─────────────────────────────────────────── */
.pos-badge {
    display: inline-block;
    padding: 0.1rem 0.4rem;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 700;
    line-height: 1.3;
    min-width: 28px;
    text-align: center;
}
.pos-top10 {
    background: rgba(63,185,80,0.18);
    color: #3fb950;
}
.pos-mid {
    background: rgba(185,142,62,0.18);
    color: var(--gold-lt);
}
.pos-bottom {
    background: rgba(139,148,158,0.15);
    color: var(--text2);
}
.pos-cut {
    background: rgba(248,81,73,0.15);
    color: var(--red);
}

.avg-pos {
    font-weight: 700;
    font-size: 0.9rem;
}
.avg-good { color: var(--green); }
.avg-mid { color: var(--gold-lt); }
.avg-bad { color: var(--text2); }

/* ── Tournament (ESPN) Table ─────────────────────────────────── */
.espn-table .status-cut td { opacity: 0.45; }
.espn-table .status-wd td { opacity: 0.35; }
.espn-table .picked-player { background: rgba(185,142,62,0.08); }
.espn-score {
    font-weight: 700;
    font-size: 0.9rem;
}
.score-under { color: var(--green); }
.score-even { color: var(--text); }
.score-over { color: var(--red); }

/* ── Stats ───────────────────────────────────────────────────── */
.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
}
.stat-card h3 {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--gold);
    margin-bottom: 0.5rem;
}
.stat-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.35rem 0;
    border-bottom: 1px solid var(--border);
    font-size: 0.85rem;
}
.stat-row:last-child { border-bottom: none; }
.stat-label { color: var(--text2); font-size: 0.75rem; }
.stat-value { font-weight: 600; }
.stat-pct { color: var(--text2); font-size: 0.75rem; margin-left: 0.35rem; }
.stat-highlight {
    text-align: center;
    padding: 1.5rem 1rem;
}
.stat-big {
    font-size: 2rem;
    font-weight: 800;
    color: var(--gold);
    line-height: 1;
}
.stat-sub {
    font-size: 0.8rem;
    color: var(--text2);
    margin-top: 0.25rem;
}

/* ── Entries Table (Admin) ────────────────────────────────────── */
.entries-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

.entries-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8rem;
}
.entries-table th, .entries-table td {
    padding: 0.5rem 0.4rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
.entries-table th {
    color: var(--gold);
    font-size: 0.75rem;
    text-transform: uppercase;
}

.badge {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
}
.badge-paid { background: rgba(63,185,80,0.15); color: var(--green); }
.badge-unpaid { background: rgba(248,81,73,0.1); color: var(--red); }

/* ── Group Fieldsets ──────────────────────────────────────────── */
.group-fieldset { margin-bottom: 1rem; }
.group-fieldset legend {
    font-size: 0.9rem;
}
.group-fieldset .radio-group {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.4rem;
}

/* ── Responsive ───────────────────────────────────────────────── */
@media (max-width: 600px) {
    .navbar { padding: 0 0.75rem; }
    .nav-link { padding: 0.35rem 0.5rem; font-size: 0.8rem; }
    .container { padding: 1rem 0.75rem 2rem; }
    h1 { font-size: 1.25rem; }
    .group-fieldset .radio-group { grid-template-columns: 1fr; }
    .lb-table, .entries-table { font-size: 0.75rem; }
    .lb-table th, .lb-table td,
    .entries-table th, .entries-table td { padding: 0.45rem 0.3rem; }
    .tab { padding: 0.5rem 0.6rem; font-size: 0.8rem; }
    .stats-grid { grid-template-columns: 1fr; }
    .pick-name { font-size: 0.7rem; }
    .pos-badge { font-size: 0.65rem; min-width: 24px; }
    .step-dot span { width: 28px; height: 28px; font-size: 0.75rem; }
    .step-dot small { font-size: 0.6rem; }
    .step-dot { min-width: 40px; }
}

@media (min-width: 801px) {
    .container { max-width: 1100px; }
}
