/* BDPSL — single stylesheet for public site and admin portal. No build step. */
:root {
  --baize: #0b5d3b;
  --baize-dark: #083f29;
  --baize-tint: #e7f2ec;
  --gold: #c9a227;
  --red: #b3261e;
  --ink: #17201b;
  --muted: #5b6760;
  --line: #d9e0dc;
  --bg: #f6f8f7;
  --card: #ffffff;
  --focus: #1a73e8;
  --warn-bg: #fff6db;
  --warn-line: #e8c65a;
  --err-bg: #fdecea;
  --ok-bg: #e6f4ea;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(0,0,0,.06), 0 1px 6px rgba(0,0,0,.04);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --ink: #e6ece8; --muted: #a3b0a8; --line: #2c3a33; --bg: #0f1613; --card: #16201b;
    --baize-tint: #173628; --warn-bg: #3a3215; --warn-line: #7a6620; --err-bg: #3d1d1b; --ok-bg: #173628;
    color-scheme: dark;
  }
}
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
a { color: var(--baize); }
@media (prefers-color-scheme: dark) { a { color: #6fd3a3; } }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
img { max-width: 100%; height: auto; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .6em; }
h1 { font-size: clamp(1.5rem, 1.2rem + 1.4vw, 2.1rem); }
h2 { font-size: 1.3rem; }
h3 { font-size: 1.1rem; }
p { margin: 0 0 1em; }
.skip { position: absolute; left: -999px; top: 0; background: #fff; padding: .5rem 1rem; z-index: 100; }
.skip:focus { left: 1rem; }
.wrap { max-width: 1180px; margin: 0 auto; padding: 0 16px; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.center { text-align: center; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- header / nav */
.site-header { background: var(--baize-dark); color: #fff; border-bottom: 4px solid var(--gold); }
.site-header .wrap { display: flex; align-items: center; gap: 1rem; min-height: 64px; flex-wrap: wrap; }
.brand { color: #fff; text-decoration: none; font-weight: 700; display: flex; align-items: center; gap: .6rem; font-size: 1.05rem; line-height: 1.2; }
.brand .ball { width: 26px; height: 26px; border-radius: 50%; background: radial-gradient(circle at 35% 35%, #ff6b5e, var(--red) 60%, #6d140f); flex: none; }
.brand small { display: block; font-weight: 400; opacity: .8; font-size: .78rem; }
.nav-toggle { margin-left: auto; background: transparent; color: #fff; border: 1px solid rgba(255,255,255,.4); border-radius: 8px; padding: .4rem .7rem; font: inherit; cursor: pointer; }
.main-nav { width: 100%; display: none; padding-bottom: .75rem; }
.main-nav.open { display: block; }
.main-nav ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .15rem; }
.main-nav a { color: #fff; text-decoration: none; display: block; padding: .55rem .7rem; border-radius: 8px; }
.main-nav a:hover, .main-nav a[aria-current="page"] { background: rgba(255,255,255,.12); }
@media (min-width: 900px) {
  .nav-toggle { display: none; }
  .main-nav { display: block; width: auto; margin-left: auto; padding: 0; }
  .main-nav ul { flex-direction: row; flex-wrap: wrap; }
  .main-nav a { padding: .45rem .65rem; font-size: .95rem; }
}

main { padding: 1.5rem 0 3rem; }
.site-footer { border-top: 1px solid var(--line); padding: 1.5rem 0; color: var(--muted); font-size: .9rem; }
.site-footer .wrap { display: flex; flex-wrap: wrap; gap: .5rem 1.5rem; justify-content: space-between; }

/* ---------- layout helpers */
.grid { display: grid; gap: 1.25rem; }
@media (min-width: 760px) { .grid-2 { grid-template-columns: 1fr 1fr; } .grid-3 { grid-template-columns: repeat(3, 1fr); } .grid-main { grid-template-columns: 2fr 1fr; } }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.1rem 1.2rem; }
.card > h2:first-child, .card > h3:first-child { margin-top: 0; }
.card + .card { margin-top: 1.25rem; }
.grid > .card + .card { margin-top: 0; }
.stack > * + * { margin-top: 1.25rem; }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: .75rem 1rem; margin-bottom: 1.25rem; }
.page-head h1 { margin: 0; }
.crumbs { font-size: .9rem; color: var(--muted); margin-bottom: .35rem; }
.crumbs a { color: inherit; }
.hero { background: linear-gradient(135deg, var(--baize), var(--baize-dark)); color: #fff; border-radius: var(--radius); padding: 1.4rem 1.4rem; margin-bottom: 1.5rem; }
.hero h1 { margin-bottom: .3rem; }
.hero p { margin: 0; opacity: .9; }
.pill-links { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: 1rem; }
.pill-links a { background: rgba(255,255,255,.14); color: #fff; padding: .4rem .8rem; border-radius: 999px; text-decoration: none; font-size: .92rem; }
.pill-links a:hover { background: rgba(255,255,255,.25); }

/* ---------- tables */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); }
table { border-collapse: collapse; width: 100%; font-size: .95rem; }
th, td { padding: .55rem .65rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
thead th { background: var(--baize-tint); font-size: .82rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: color-mix(in srgb, var(--baize-tint) 45%, transparent); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.standings td:first-child { width: 2.5rem; color: var(--muted); }
.standings .pts { font-weight: 700; }
.standings tr.promo td:first-child { box-shadow: inset 4px 0 0 var(--baize); }
.standings tr.releg td:first-child { box-shadow: inset 4px 0 0 var(--red); }
.standings tr.qual td:first-child { box-shadow: inset 4px 0 0 var(--gold); }
.standings tr.withdrawn td { color: var(--muted); text-decoration: line-through; }
@media (max-width: 560px) { .hide-sm { display: none; } th, td { padding: .5rem .45rem; } }
.form { display: inline-flex; gap: 2px; }
.form span { width: 1.3rem; height: 1.3rem; border-radius: 4px; color: #fff; font-size: .72rem; font-weight: 700; display: inline-grid; place-items: center; }
.form .W { background: var(--baize); } .form .D { background: #8a8f8c; } .form .L { background: var(--red); }

/* ---------- fixtures list */
.fixtures { list-style: none; margin: 0; padding: 0; }
.fixtures li { display: grid; grid-template-columns: 1fr auto 1fr; gap: .5rem; align-items: center; padding: .6rem 0; border-bottom: 1px solid var(--line); }
.fixtures li:last-child { border-bottom: 0; }
.fixtures .home { text-align: right; }
.fixtures .score { min-width: 4.2rem; text-align: center; font-weight: 700; font-variant-numeric: tabular-nums; background: var(--baize-tint); border-radius: 6px; padding: .2rem .4rem; text-decoration: none; color: var(--ink); }
.fixtures .meta { grid-column: 1 / -1; font-size: .8rem; color: var(--muted); text-align: center; margin-top: -.2rem; }
.fixtures .win { font-weight: 700; }
.date-head { margin: 1.1rem 0 .2rem; font-size: .9rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }

/* ---------- bracket */
.bracket { display: flex; gap: 1rem; overflow-x: auto; padding-bottom: .5rem; }
.bracket .round { min-width: 220px; flex: 1; }
.bracket .round h3 { font-size: .9rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.tie { border: 1px solid var(--line); border-radius: 8px; background: var(--card); margin-bottom: .75rem; overflow: hidden; }
.tie div { display: flex; justify-content: space-between; gap: .5rem; padding: .4rem .6rem; }
.tie div + div { border-top: 1px solid var(--line); }
.tie .win { font-weight: 700; background: var(--baize-tint); }
.tie a { color: inherit; text-decoration: none; }

/* ---------- badges, alerts */
.badge { display: inline-block; font-size: .72rem; font-weight: 600; padding: .12rem .5rem; border-radius: 999px; border: 1px solid var(--line); background: var(--card); color: var(--muted); vertical-align: middle; white-space: nowrap; }
.badge.verified { border-color: #9fd1b5; color: var(--baize); }
.badge.imported_unverified, .badge.inferred { border-color: var(--warn-line); background: var(--warn-bg); color: #6b5410; }
.badge.missing { border-color: #f0b4ae; background: var(--err-bg); color: var(--red); }
.badge.fictional_dev { border-color: #b8a2e8; background: #f1ebff; color: #4b2c99; }
@media (prefers-color-scheme: dark) { .badge.imported_unverified, .badge.inferred { color: #f4d77a; } .badge.fictional_dev { background: #2a2140; color: #cdb8ff; } }
.alert { border-radius: var(--radius); padding: .8rem 1rem; margin-bottom: 1rem; border: 1px solid var(--line); background: var(--card); }
.alert.ok { background: var(--ok-bg); border-color: #9fd1b5; }
.alert.error { background: var(--err-bg); border-color: #f0b4ae; }
.alert.warn { background: var(--warn-bg); border-color: var(--warn-line); }
.alert ul { margin: .3rem 0 0; padding-left: 1.2rem; }
.dev-banner { background: #4b2c99; color: #fff; text-align: center; font-size: .9rem; padding: .45rem 1rem; }

/* ---------- buttons & forms */
.btn { display: inline-flex; align-items: center; gap: .35rem; font: inherit; font-weight: 600; font-size: .95rem; padding: .55rem 1rem; border-radius: 8px; border: 1px solid var(--baize); background: var(--baize); color: #fff; text-decoration: none; cursor: pointer; line-height: 1.2; min-height: 44px; }
.btn:hover { background: var(--baize-dark); color: #fff; }
.btn.secondary { background: var(--card); color: var(--baize); }
.btn.secondary:hover { background: var(--baize-tint); }
.btn.danger { background: var(--red); border-color: var(--red); }
.btn.small { padding: .3rem .65rem; font-size: .85rem; min-height: 34px; }
.btn.link { background: none; border: 0; color: var(--baize); padding: 0; min-height: 0; text-decoration: underline; font-weight: 500; }
.actions { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
label { font-weight: 600; display: block; margin-bottom: .25rem; }
.field { margin-bottom: 1rem; }
.field .help { font-size: .85rem; color: var(--muted); margin-top: .25rem; }
.field .error { font-size: .88rem; color: var(--red); margin-top: .25rem; font-weight: 600; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=datetime-local], input[type=time], input[type=url], input[type=search], input[type=file], select, textarea {
  width: 100%; font: inherit; color: var(--ink); background: var(--card); border: 1px solid #b9c4be; border-radius: 8px; padding: .55rem .65rem; min-height: 44px;
}
textarea { min-height: 8rem; resize: vertical; }
textarea.markdown { min-height: 16rem; font-family: ui-monospace, Consolas, monospace; font-size: .92rem; }
input[aria-invalid=true], select[aria-invalid=true], textarea[aria-invalid=true] { border-color: var(--red); }
.check { display: flex; gap: .55rem; align-items: flex-start; font-weight: 600; }
.check input { width: 1.2rem; height: 1.2rem; margin-top: .15rem; flex: none; }
.inline-form { display: flex; flex-wrap: wrap; gap: .5rem; align-items: flex-end; }
.inline-form .field { margin: 0; flex: 1 1 160px; }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: .8rem 1rem; margin: 0 0 1rem; }
legend { font-weight: 700; padding: 0 .3rem; }
.filters { display: flex; flex-wrap: wrap; gap: .5rem; align-items: flex-end; margin-bottom: 1rem; }
.filters > * { flex: 1 1 140px; }
.filters .btn { flex: 0 0 auto; }
.pagination { display: flex; flex-wrap: wrap; gap: .3rem; list-style: none; padding: 0; margin: 1rem 0; }
.pagination a, .pagination span { display: inline-block; padding: .35rem .7rem; border: 1px solid var(--line); border-radius: 6px; text-decoration: none; background: var(--card); }
.pagination [aria-current] span { background: var(--baize); color: #fff; border-color: var(--baize); }

/* ---------- prose */
.prose { max-width: 75ch; }
.prose h2 { margin-top: 1.5em; }
.prose table { margin: 1rem 0; }
.prose blockquote { border-left: 4px solid var(--gold); margin: 1rem 0; padding: .3rem 1rem; color: var(--muted); }

/* ---------- stat tiles */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: .75rem; }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: .8rem 1rem; }
.tile b { display: block; font-size: 1.6rem; font-variant-numeric: tabular-nums; }
.tile span { color: var(--muted); font-size: .85rem; }

/* ---------- admin */
.admin-shell { display: grid; min-height: 100vh; grid-template-columns: 1fr; }
.admin-side { background: var(--baize-dark); color: #fff; padding: 1rem; }
.admin-side .brand { margin-bottom: 1rem; }
.admin-side nav { display: none; }
.admin-side nav.open { display: block; }
.admin-side h4 { font-size: .75rem; text-transform: uppercase; letter-spacing: .08em; opacity: .65; margin: 1.1rem 0 .3rem; }
.admin-side ul { list-style: none; margin: 0; padding: 0; }
.admin-side a { color: #fff; text-decoration: none; display: block; padding: .45rem .6rem; border-radius: 6px; font-size: .95rem; }
.admin-side a:hover, .admin-side a[aria-current="page"] { background: rgba(255,255,255,.14); }
.admin-side .side-top { display: flex; align-items: center; justify-content: space-between; }
.admin-main { padding: 1.25rem 16px 3rem; min-width: 0; }
.admin-top { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: .75rem; align-items: center; font-size: .9rem; margin-bottom: 1rem; color: var(--muted); }
@media (min-width: 980px) {
  .admin-shell { grid-template-columns: 250px 1fr; }
  .admin-side { position: sticky; top: 0; height: 100vh; overflow-y: auto; }
  .admin-side nav { display: block; }
  .admin-side .nav-toggle { display: none; }
  .admin-main { padding: 1.5rem 2rem 3rem; }
}
.row-links { display: flex; flex-wrap: wrap; gap: .25rem .7rem; font-size: .88rem; }
.frames-table input, .frames-table select { min-height: 38px; padding: .35rem .4rem; }
.frames-table td { padding: .35rem .3rem; }
.frames-table .winner label { display: inline-flex; gap: .25rem; font-weight: 500; margin-right: .5rem; }
.frames-table td.nowrap input[type=number] { width: 4.5rem; display: inline-block; }
.frames-table .frame-no { font-weight: 600; white-space: nowrap; }
.frames-table tbody.pairing { border-top: 2px solid var(--line); }
.frames-table tbody.pairing:nth-of-type(even) { background: color-mix(in srgb, var(--baize-tint) 35%, transparent); }
/* Phones: each frame becomes a stacked card so nothing scrolls sideways. */
@media (max-width: 700px) {
  .frames-table thead { display: none; }
  .frames-table, .frames-table tbody, .frames-table tr, .frames-table td { display: block; width: 100%; }
  .frames-table tr { padding: .6rem .5rem; border-bottom: 2px solid var(--line); }
  .frames-table td { border: 0; padding: .25rem 0; }
  .frames-table td[data-label]::before { content: attr(data-label); display: block; font-size: .8rem; color: var(--muted); font-weight: 600; }
  .frames-table .winner label { font-size: 1.05rem; margin-right: 1.25rem; }
  .frames-table .winner input { width: 1.3rem; height: 1.3rem; }
}
.tally { font-size: 1.3rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.score-inputs { display: flex; align-items: center; gap: .5rem; }
.score-inputs input { width: 5.5rem; text-align: center; font-size: 1.2rem; }
.check-list { columns: 2 220px; list-style: none; padding: 0; margin: 0 0 1rem; }
.check-list li { break-inside: avoid; margin-bottom: .2rem; }
.check-list label { font-weight: 500; display: flex; gap: .4rem; align-items: center; }
.severity-error { border-left: 5px solid var(--red); }
.severity-warning { border-left: 5px solid var(--gold); }
.severity-info { border-left: 5px solid #7d8c84; }
pre.json { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: .8rem; overflow-x: auto; font-size: .82rem; }
.login-box { max-width: 420px; margin: 8vh auto; }
.tb-row { display: flex; gap: .5rem; align-items: center; margin-bottom: .4rem; }
.tb-row span { width: 1.5rem; color: var(--muted); }

@media print {
  .site-header, .site-footer, .main-nav, .admin-side, .btn, .filters { display: none !important; }
  body { background: #fff; }
  .card, .table-wrap { box-shadow: none; border-color: #999; }
}
