/* ---------- Base ---------- */
html {
    font-size: 16px;
    scroll-behavior: smooth;
}

@media (min-width: 768px) {
    html { font-size: 17px; }
}

body {
    margin: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background-color: #2f2f2f;
    color: #f5f5f5;
    background-image: linear-gradient(rgba(47,47,47,.72), rgba(47,47,47,.72)), url('/static/logo_small.png');
    background-repeat: no-repeat;
    background-position: center;
    background-attachment: fixed;
    background-size: cover, 400px;
}

main { flex: 1; }

/* ---------- Header ---------- */
.site-header {
    position: sticky;
    top: 0;
    z-index: 1000;
}

.site-navbar {
    background: rgba(18, 18, 18, 0.92);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(255,255,255,0.08);
    box-shadow: 0 4px 20px rgba(0,0,0,0.25);
}

.navbar-brand { letter-spacing: 0.3px; }

.nav-link {
    color: rgba(255,255,255,0.78) !important;
    border-radius: 999px;
    padding: 0.45rem 0.85rem !important;
    transition: all 0.2s ease;
}

.nav-link:hover,
.nav-link.active {
    color: #fff !important;
    background: rgba(255,255,255,0.1);
}

/* ---------- Page shell ---------- */
.page-shell {
    width: min(1120px, calc(100% - 2rem));
    margin: 2rem auto;
    padding: 1.5rem;
    flex: 1;
    background: rgba(20, 20, 20, 0.84);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 18px;
    box-shadow: 0 12px 40px rgba(0,0,0,0.35);
    backdrop-filter: blur(10px);
}

.page-heading {
    max-width: 720px;
    margin: 0 auto 1.75rem;
    text-align: center;
}

.page-heading-left {
    max-width: none;
    margin-left: 0;
    text-align: left;
}

.page-heading h1,
.status-card h1 {
    margin: 0 0 .65rem;
    font-weight: 650;
    letter-spacing: -.025em;
}

.page-heading p { color: rgba(255,255,255,.68); }

.eyebrow {
    margin-bottom: .35rem !important;
    color: #6cb6ff !important;
    font-size: .76rem;
    font-weight: 700;
    letter-spacing: .12em;
    text-transform: uppercase;
}

/* ---------- Forms ---------- */
.form-page {
    width: 100%;
    max-width: 680px;
    margin: 0 auto;
}

.form-card,
.result-card,
.status-card {
    background: rgba(31,31,31,.94);
    border: 1px solid rgba(255,255,255,.09);
    border-radius: 14px;
    box-shadow: 0 10px 26px rgba(0,0,0,.25);
}

.form-card { padding: 1.4rem; }

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
}

.form-label {
    color: #f5f5f5;
    font-weight: 500;
}

.form-control {
    min-height: 48px;
    border-radius: 8px;
    background-color: #1f1f1f;
    color: #fff;
    border: 1px solid #444;
}

.form-control::placeholder { color: #888; }
.form-control:focus {
    background-color: #1f1f1f;
    color: #fff;
    border-color: #258cfb;
}

select.form-control { appearance: auto; }

.form-text { color: rgba(255,255,255,.55); }

.option-row {
    padding: .9rem 1rem .9rem 2.6rem;
    background: rgba(255,255,255,.035);
    border: 1px solid rgba(255,255,255,.07);
    border-radius: 10px;
}

.form-check-input {
    background-color: #1f1f1f;
    border-color: #666;
}

.form-check-input:checked {
    background-color: #258cfb;
    border-color: #258cfb;
}

.option-label,
.option-help { display: block; }
.option-label { font-weight: 500; }
.option-help {
    margin-top: .1rem;
    color: rgba(255,255,255,.55);
    font-size: .88rem;
}

/* ---------- Buttons ---------- */
.btn {
    border-radius: 8px;
    padding: 0.6rem 1.2rem;
    font-weight: 500;
    transition: all 0.2s ease;
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.btn-primary {
    background-color: #258cfb;
    border-color: #258cfb;
}

.btn-primary:hover {
    background-color: #1478df;
    border-color: #1478df;
}

.btn:focus,
.form-control:focus,
.form-check-input:focus {
    outline: none;
    box-shadow: 0 0 0 0.2rem rgba(37, 140, 251, 0.5);
}

/* ---------- Results ---------- */
.results-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(310px, 1fr));
    gap: 1rem;
}

.result-card { overflow: hidden; }
.result-card-header {
    padding: 1rem 1.1rem;
    background: rgba(255,255,255,.04);
    border-bottom: 1px solid rgba(255,255,255,.08);
}
.result-card-header h2 {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 600;
}

.result-table {
    width: 100%;
    margin: 0;
    border-collapse: collapse;
}
.result-table th,
.result-table td {
    padding: .72rem .85rem;
    text-align: left;
    border-bottom: 1px solid rgba(255,255,255,.07);
}
.result-table th {
    background: #171717;
    color: rgba(255,255,255,.7);
    font-size: .78rem;
    letter-spacing: .05em;
    text-transform: uppercase;
}
.result-table tbody tr:nth-child(even) { background: rgba(255,255,255,.025); }
.result-table tbody tr:hover { background: rgba(255,255,255,.07); }
.result-table tbody tr:last-child td { border-bottom: 0; }
.result-summary { margin-bottom: 0; }

/* ---------- Status ---------- */
.status-page {
    min-height: 55vh;
    display: grid;
    place-items: center;
}
.status-card {
    width: min(560px, 100%);
    padding: 2rem;
    text-align: center;
}
.status-icon {
    width: 64px;
    height: 64px;
    display: inline-grid;
    place-items: center;
    margin-bottom: 1rem;
    border-radius: 50%;
    background: rgba(25,135,84,.18);
    color: #70d39a;
    font-size: 2rem;
    font-weight: 700;
}
.status-actions {
    display: flex;
    justify-content: center;
    gap: .75rem;
    margin-top: 1.5rem;
    flex-wrap: wrap;
}

/* ---------- Alerts/footer ---------- */
.alert { border-radius: 10px; }
.site-footer {
    margin-top: auto;
    padding: 1.25rem;
    text-align: center;
    color: rgba(255,255,255,0.65);
    background: rgba(10,10,10,0.65);
    border-top: 1px solid rgba(255,255,255,0.08);
}

@media (max-width: 767.98px) {
    .page-shell {
        width: min(100% - 1rem, 1120px);
        margin: .75rem auto;
        padding: 1rem;
        border-radius: 14px;
    }
    .page-heading { text-align: left; }
    .form-grid { grid-template-columns: 1fr; gap: 0; }
    .results-grid { grid-template-columns: 1fr; }
    body { background-size: cover, 260px; }
}

@media screen {
    .print-only { display: none !important; }
}

@media print {
    .no-print,
    .site-header,
    .site-footer,
    .navbar,
    .screen-only { display: none !important; }
    .print-only { display: block !important; }
    body {
        color: #000;
        background: #fff !important;
    }
    .page-shell {
        width: 100%;
        margin: 0;
        padding: 0;
        background: #fff;
        border: 0;
        box-shadow: none;
    }
    .page-heading h1,
    .page-heading p,
    .result-card,
    .result-table { color: #000 !important; }
    .results-grid { display: block; }
    .result-card {
        margin-bottom: 12px;
        break-inside: avoid;
        border: 1px solid #999;
        box-shadow: none;
        background: #fff;
    }
    .result-card-header,
    .result-table th { background: #eee !important; color: #000 !important; }
    .result-table td,
    .result-table th { border-color: #bbb; }
}

.average-score-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1.25rem;
}

.average-score-table {
    width: 100%;
}

@media (max-width: 700px) {
    .average-score-grid {
        grid-template-columns: 1fr;
    }
}

/* ---------- Result enhancements ---------- */
.result-count {
    display: inline-flex;
    align-items: center;
    padding: .28rem .65rem;
    border: 1px solid rgba(255,255,255,.1);
    border-radius: 999px;
    background: rgba(255,255,255,.05);
    color: rgba(255,255,255,.72);
    font-size: .78rem;
    white-space: nowrap;
}

.result-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 34px;
    min-height: 30px;
    padding: .2rem .55rem;
    border-radius: 8px;
    font-weight: 700;
}

.place-badge {
    background: rgba(255,255,255,.1);
    color: #fff;
}

.place-1 {
    background: #b8860b;
}

.place-2 {
    background: #6b7280;
}

.place-3 {
    background: #9a4f22;
}

.hole-badge {
    background: rgba(37,140,251,.16);
    color: #82c2ff;
}

.score-badge {
    background: rgba(25,135,84,.18);
    color: #70d39a;
}

.average-score-card {
    box-shadow: none;
}

.table-responsive {
    overflow-x: auto;
}

.text-end {
    text-align: right !important;
}

@media print {
    .result-badge {
        min-width: auto;
        min-height: auto;
        padding: 0;
        background: transparent !important;
        color: #000 !important;
    }

    .result-count {
        border: 0;
        background: transparent;
        color: #000;
    }
}
