:root {
    --bg: #f4f1ea;
    --panel: #ffffff;
    --ink: #171717;
    --muted: #6c6a65;
    --line: #ded9cf;
    --red: #b8242f;
    --red-dark: #7f111a;
    --green: #1b7652;
    --gold: #d7a72c;
    --black: #151515;
    --shadow: 0 18px 45px rgba(23, 23, 23, .09);
    --radius: 18px;
    --radius-small: 11px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
    margin: 0;
    min-width: 320px;
    background: var(--bg);
    color: var(--ink);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    line-height: 1.5;
}

button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
a { color: inherit; }
.shell { width: min(1180px, calc(100% - 32px)); margin: 0 auto; }

.site-header {
    position: sticky;
    top: 0;
    z-index: 40;
    background: rgba(21, 21, 21, .96);
    color: white;
    backdrop-filter: blur(14px);
    border-bottom: 1px solid rgba(255,255,255,.08);
}
.header-inner {
    min-height: 76px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
}
.brand {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    color: inherit;
    text-decoration: none;
}
.brand strong, .brand small { display: block; }
.brand strong { font-size: 1rem; letter-spacing: .01em; }
.brand small { color: #bdbdbd; font-size: .75rem; }
.brand-mark {
    width: 46px;
    height: 46px;
    display: grid;
    place-items: center;
    border: 3px solid white;
    border-radius: 50%;
    font-weight: 900;
    font-size: .72rem;
    background:
        radial-gradient(circle, var(--red) 0 12%, white 13% 18%, var(--green) 19% 29%, var(--black) 30% 48%, var(--red) 49% 57%, var(--black) 58%);
    text-shadow: 0 1px 2px black;
}
.top-nav { display: flex; align-items: center; gap: 22px; }
.top-nav > a:not(.button) { color: #dedede; text-decoration: none; font-size: .92rem; }
.top-nav > a:hover { color: white; }

.button {
    border: 0;
    border-radius: 999px;
    padding: 11px 20px;
    background: var(--red);
    color: white;
    font-weight: 800;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    box-shadow: none;
}
.button:hover { background: var(--red-dark); }
.button-small { padding: 8px 14px; font-size: .86rem; }
.button-secondary { background: var(--black); }
.button-secondary:hover { background: #333; }
.button-ghost { background: transparent; border: 1px solid rgba(255,255,255,.35); }
.button-ghost:hover { background: rgba(255,255,255,.1); }
.admin-section .button-ghost { color: var(--ink); border-color: var(--line); }
.button-danger { background: #8c1c24; }

.hero {
    min-height: 390px;
    display: flex;
    align-items: center;
    overflow: hidden;
    color: white;
    background:
        linear-gradient(110deg, rgba(12,12,12,.98), rgba(22,22,22,.84)),
        repeating-linear-gradient(45deg, transparent 0 16px, rgba(255,255,255,.025) 17px 18px);
}
.hero-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 360px;
    align-items: center;
    gap: 60px;
    padding: 60px 0;
}
.hero h1 {
    max-width: 760px;
    margin: 10px 0 16px;
    font-size: clamp(2.45rem, 6vw, 5rem);
    line-height: .95;
    letter-spacing: -.055em;
}
.hero p { max-width: 680px; margin: 0; color: #c8c8c8; font-size: 1.05rem; }
.eyebrow {
    color: var(--gold);
    font-size: .76rem;
    font-weight: 900;
    letter-spacing: .16em;
    text-transform: uppercase;
}
.dartboard-art {
    width: 320px;
    aspect-ratio: 1;
    position: relative;
    border-radius: 50%;
    justify-self: end;
    box-shadow: 0 25px 80px rgba(0,0,0,.5), inset 0 0 0 12px #292929;
    background:
        radial-gradient(circle, #b8242f 0 4%, #1b7652 4.2% 8%, #e7ded0 8.2% 10%, #171717 10.2% 44%, #d7a72c 44.2% 47%, #171717 47.2% 70%, #b8242f 70.2% 74%, #171717 74.2%);
}
.dartboard-art::before,
.dartboard-art::after {
    content: "";
    position: absolute;
    inset: 14%;
    border-radius: 50%;
    background: repeating-conic-gradient(from -9deg, rgba(255,255,255,.75) 0deg 1deg, transparent 1deg 18deg);
    opacity: .35;
}
.dartboard-art::after { inset: 3%; opacity: .2; }
.dartboard-centre {
    position: absolute;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #d7a72c;
    inset: 50% auto auto 50%;
    transform: translate(-50%,-50%);
    box-shadow: 0 0 0 9px #b8242f;
}

.page-content { padding: 44px 0 80px; }
.stats-grid {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 14px;
    margin-top: -82px;
    position: relative;
    z-index: 2;
}
.stat-card {
    min-height: 132px;
    padding: 20px;
    border-radius: var(--radius);
    background: var(--panel);
    box-shadow: var(--shadow);
    border: 1px solid rgba(0,0,0,.04);
}
.stat-card small {
    display: block;
    color: var(--muted);
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .08em;
    font-size: .68rem;
}
.stat-card strong {
    display: block;
    margin-top: 8px;
    font-size: 2rem;
    line-height: 1;
}
.stat-card span { color: var(--muted); font-size: .8rem; }

.content-section { padding-top: 72px; }
.section-heading {
    display: flex;
    justify-content: space-between;
    align-items: end;
    gap: 24px;
    margin-bottom: 24px;
}
.section-heading.compact { align-items: center; }
.section-heading h2, .admin-toolbar h1 { margin: 5px 0 0; font-size: clamp(1.7rem, 4vw, 2.45rem); letter-spacing: -.04em; }
.section-heading p { margin: 4px 0 0; color: var(--muted); }
.segmented {
    display: inline-flex;
    padding: 4px;
    border-radius: 999px;
    background: #e6e1d8;
}
.segmented button {
    border: 0;
    background: transparent;
    color: var(--muted);
    border-radius: 999px;
    padding: 8px 14px;
    font-weight: 800;
    font-size: .82rem;
}
.segmented button.active { background: white; color: var(--ink); box-shadow: 0 3px 12px rgba(0,0,0,.08); }

.fixture-list { display: grid; gap: 14px; }
.fixture-card {
    display: grid;
    grid-template-columns: 165px minmax(0, 1fr) 150px 44px;
    align-items: center;
    gap: 20px;
    padding: 18px 20px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    transition: transform .2s ease, box-shadow .2s ease;
}
.fixture-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.fixture-date strong, .fixture-date span { display: block; }
.fixture-date strong { font-size: 1rem; }
.fixture-date span { color: var(--muted); font-size: .82rem; }
.fixture-title { min-width: 0; }
.fixture-title strong { display: block; font-size: 1.08rem; }
.fixture-title span { color: var(--muted); font-size: .86rem; }
.fixture-result { text-align: right; }
.fixture-result strong { display: block; font-size: 1.8rem; line-height: 1; }
.fixture-result span { font-size: .72rem; font-weight: 900; text-transform: uppercase; letter-spacing: .1em; }
.result-win { color: var(--green); }
.result-loss { color: var(--red); }
.result-draw { color: #76610d; }
.fixture-open {
    width: 38px;
    height: 38px;
    border: 1px solid var(--line);
    border-radius: 50%;
    background: white;
    font-size: 1.2rem;
}
.empty-state {
    padding: 42px;
    text-align: center;
    color: var(--muted);
    border: 1px dashed #c9c2b5;
    border-radius: var(--radius);
    background: rgba(255,255,255,.4);
}

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: white; }
.data-table { width: 100%; border-collapse: collapse; min-width: 920px; }
.data-table th, .data-table td { padding: 14px 15px; text-align: left; border-bottom: 1px solid #ece8df; white-space: nowrap; }
.data-table th { color: var(--muted); font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; background: #faf9f6; }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table tbody tr:hover { background: #fcfbf8; }
.player-name-cell strong { display: block; }
.player-name-cell small { color: var(--muted); }
.search-field input { min-width: 240px; }

.player-card-grid { display: none; gap: 12px; }
.player-card {
    background: white;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 18px;
}
.player-card h3 { margin: 0 0 12px; }
.player-card-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.player-card-stats div { background: #f7f4ee; padding: 10px; border-radius: 10px; }
.player-card-stats small, .player-card-stats strong { display: block; }
.player-card-stats small { color: var(--muted); font-size: .65rem; text-transform: uppercase; }
.player-card-stats strong { font-size: 1.15rem; margin-top: 2px; }

.fixture-dialog {
    width: min(960px, calc(100% - 24px));
    max-height: calc(100vh - 36px);
    border: 0;
    border-radius: 22px;
    padding: 0;
    box-shadow: 0 30px 90px rgba(0,0,0,.35);
}
.fixture-dialog::backdrop { background: rgba(0,0,0,.65); backdrop-filter: blur(3px); }
.dialog-close {
    position: sticky;
    float: right;
    top: 12px;
    margin: 12px 12px -48px 0;
    z-index: 2;
    width: 38px;
    height: 38px;
    border: 0;
    border-radius: 50%;
    background: var(--black);
    color: white;
    font-size: 1.4rem;
}
.dialog-content-header { background: var(--black); color: white; padding: 30px 34px; }
.dialog-content-header h2 { margin: 4px 0; font-size: 2rem; }
.dialog-content-header p { margin: 0; color: #bebebe; }
.dialog-body { padding: 26px 34px 34px; }
.game-group + .game-group { margin-top: 28px; }
.game-group h3 { margin: 0 0 10px; }
.game-result-row {
    display: grid;
    grid-template-columns: 130px minmax(0,1fr) 100px minmax(0,1fr);
    gap: 12px;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid var(--line);
}
.game-result-row:last-child { border-bottom: 0; }
.game-result-row small { display: block; color: var(--muted); }
.game-score { font-size: 1.1rem; font-weight: 900; text-align: center; }
.performance-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.tag { padding: 3px 7px; border-radius: 999px; background: #f0ece4; font-size: .7rem; font-weight: 800; }
.tag.checkout { background: #e1f2e9; color: var(--green); }

.site-footer { background: var(--black); color: #bfbfbf; padding: 28px 0; }
.footer-inner { display: flex; justify-content: space-between; gap: 20px; font-size: .82rem; }

/* Forms and admin */
input, select, textarea {
    width: 100%;
    border: 1px solid #cfc9be;
    border-radius: var(--radius-small);
    padding: 10px 12px;
    background: white;
    color: var(--ink);
}
input:focus, select:focus, textarea:focus { outline: 3px solid rgba(184,36,47,.12); border-color: var(--red); }
label { display: grid; gap: 6px; font-size: .78rem; font-weight: 800; color: #4d4b47; }
input[type="checkbox"] { width: 18px; height: 18px; }
.alert { padding: 13px 16px; border-radius: 12px; margin-bottom: 18px; background: #e8f5ed; color: #155f42; border: 1px solid #b9ddc9; }
.alert-error { background: #fae8e9; color: #861b24; border-color: #e9bcc0; }
.alert-warning { background: #fff5d6; color: #765b00; border-color: #ead58a; }
.login-page { min-height: 100vh; display: grid; place-items: center; background: var(--black); padding: 24px; }
.login-panel { width: min(430px, 100%); background: white; padding: 34px; border-radius: 22px; box-shadow: 0 30px 90px rgba(0,0,0,.35); }
.brand-centred { color: var(--ink); }
.brand-centred small { color: var(--muted); }
.login-panel h1 { margin: 30px 0 4px; }
.login-panel p { margin-top: 0; color: var(--muted); }
.stack-form { display: grid; gap: 16px; margin: 24px 0; }
.text-link { color: var(--red); font-weight: 800; text-decoration: none; font-size: .86rem; }

.admin-content { padding-top: 38px; }
.admin-toolbar { display: flex; justify-content: space-between; align-items: end; gap: 20px; margin-bottom: 26px; }
.toolbar-actions { display: flex; align-items: center; gap: 15px; }
.save-status { color: var(--muted); font-size: .82rem; }
.save-status.dirty { color: #805f00; font-weight: 800; }
.admin-section {
    background: white;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 20px;
}
.form-grid { display: grid; gap: 16px; }
.form-grid.two { grid-template-columns: repeat(2, minmax(0,1fr)); }
.admin-table { min-width: 650px; }
.admin-table input[type="text"] { min-width: 240px; }
.icon-button {
    border: 1px solid var(--line);
    background: white;
    border-radius: 10px;
    padding: 7px 10px;
    font-weight: 800;
}
.icon-button.danger { color: var(--red); }
.admin-fixture-list { display: grid; gap: 10px; }
.admin-fixture-row {
    display: grid;
    grid-template-columns: 130px minmax(0,1fr) 130px auto;
    gap: 14px;
    align-items: center;
    padding: 14px;
    border-radius: 13px;
    background: #f7f5f0;
}
.admin-fixture-row strong, .admin-fixture-row span { display: block; }
.admin-fixture-row span { color: var(--muted); font-size: .8rem; }
.row-actions { display: flex; gap: 8px; }
.fixture-form { display: grid; gap: 24px; }
.fixture-games { display: grid; gap: 18px; }
.fixture-type-group {
    border: 1px solid var(--line);
    border-radius: 16px;
    overflow: hidden;
}
.fixture-type-header {
    padding: 13px 16px;
    background: var(--black);
    color: white;
    display: flex;
    justify-content: space-between;
    gap: 14px;
}
.fixture-type-header h3 { margin: 0; }
.fixture-type-header span { color: #c6c6c6; font-size: .8rem; }
.game-editor {
    padding: 16px;
    border-bottom: 1px solid var(--line);
}
.game-editor:last-child { border-bottom: 0; }
.game-editor-top {
    display: grid;
    grid-template-columns: 150px minmax(0,1fr) 110px 110px;
    gap: 12px;
    align-items: end;
}
.game-editor-title strong, .game-editor-title small { display: block; }
.game-editor-title small { color: var(--muted); }
.player-select-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0,1fr));
    gap: 10px;
}
.performance-editor {
    display: grid;
    gap: 10px;
    margin-top: 14px;
    padding: 13px;
    border-radius: 12px;
    background: #f7f5f0;
}
.performance-row {
    display: grid;
    grid-template-columns: 160px minmax(0,1fr) minmax(0,1fr);
    gap: 12px;
    align-items: end;
}
.performance-row strong { padding-bottom: 10px; }
.help-text { color: var(--muted); font-size: .75rem; margin: 0; }

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0,0,0,0);
    white-space: nowrap;
    border: 0;
}

@media (max-width: 1000px) {
    .stats-grid { grid-template-columns: repeat(3, 1fr); margin-top: -64px; }
    .hero-grid { grid-template-columns: 1fr 260px; }
    .dartboard-art { width: 250px; }
}
@media (max-width: 760px) {
    .shell { width: min(100% - 22px, 1180px); }
    .top-nav > a:not(.button) { display: none; }
    .hero { min-height: 430px; }
    .hero-grid { grid-template-columns: 1fr; padding: 46px 0 84px; }
    .dartboard-art { display: none; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); margin-top: -62px; }
    .stat-card { min-height: 112px; }
    .section-heading, .admin-toolbar { align-items: stretch; flex-direction: column; }
    .fixture-card { grid-template-columns: 110px minmax(0,1fr) 42px; gap: 12px; }
    .fixture-result { grid-column: 2; text-align: left; }
    .fixture-open { grid-column: 3; grid-row: 1 / span 2; }
    .data-table { display: none; }
    .player-card-grid { display: grid; }
    .form-grid.two { grid-template-columns: 1fr; }
    .admin-fixture-row { grid-template-columns: 1fr auto; }
    .admin-fixture-row > :nth-child(3) { display: none; }
    .game-editor-top { grid-template-columns: 1fr 1fr; }
    .player-select-grid { grid-template-columns: 1fr; }
    .performance-row { grid-template-columns: 1fr; }
    .performance-row strong { padding: 0; }
    .toolbar-actions { align-items: stretch; flex-direction: column; }
    .footer-inner { flex-direction: column; }
    .game-result-row { grid-template-columns: 1fr 70px; }
    .game-result-row > :nth-child(4) { grid-column: 1; }
}

/* Season controls */
.season-picker {
    width: fit-content;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 7px 8px 7px 13px;
    border: 1px solid rgba(255,255,255,.2);
    border-radius: 999px;
    background: rgba(255,255,255,.08);
    color: white;
}
.season-picker span {
    color: var(--gold);
    font-size: .7rem;
    font-weight: 900;
    letter-spacing: .13em;
    text-transform: uppercase;
}
.season-picker select {
    width: auto;
    min-width: 145px;
    padding: 7px 34px 7px 12px;
    border: 0;
    border-radius: 999px;
    background: white;
    color: var(--ink);
    font-weight: 900;
}
.season-table { min-width: 620px; }
.season-table input[type="text"] { min-width: 260px; }
.season-table input[type="radio"] { width: 19px; height: 19px; }
.icon-button:disabled {
    cursor: not-allowed;
    opacity: .42;
}

@media (max-width: 760px) {
    .season-picker { width: 100%; justify-content: space-between; }
    .season-picker select { flex: 1; }
}
