/* Football Prediction Pool — one stylesheet, no external resources. */

:root {
  --bg: #f4f6f3;
  --surface: #ffffff;
  --surface-2: #eef1ec;
  --text: #17201b;
  --muted: #5d6a62;
  --border: #d6ddd7;
  --accent: #0f7a4a;
  --accent-text: #ffffff;
  --exact-bg: #d7f2e1;
  --exact-fg: #0b5e37;
  --outcome-bg: #e6eefc;
  --outcome-fg: #1d4a9a;
  --wrong-bg: #fbe7e5;
  --wrong-fg: #9b2a1f;
  --live-bg: #fff3d1;
  --live-fg: #7a5200;
  --warn-bg: #fff3d1;
  --warn-fg: #6b4800;
  --error: #b42318;
  --focus: #2b6ee8;
  --shadow: 0 1px 2px rgb(0 0 0 / 0.06), 0 2px 8px rgb(0 0 0 / 0.04);
  --radius: 10px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1412;
    --surface: #171e1b;
    --surface-2: #1f2824;
    --text: #e6ece8;
    --muted: #9aa8a0;
    --border: #2d3833;
    --accent: #3ccf8a;
    --accent-text: #06231a;
    --exact-bg: #133b27;
    --exact-fg: #8ff0bb;
    --outcome-bg: #182a4a;
    --outcome-fg: #a9c6ff;
    --wrong-bg: #3f1d1a;
    --wrong-fg: #ffb4aa;
    --live-bg: #3a2e0c;
    --live-fg: #ffd77a;
    --warn-bg: #3a2e0c;
    --warn-fg: #ffd77a;
    --error: #ff8a7a;
    --focus: #7aa8ff;
    --shadow: none;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #0f1412;
  --surface: #171e1b;
  --surface-2: #1f2824;
  --text: #e6ece8;
  --muted: #9aa8a0;
  --border: #2d3833;
  --accent: #3ccf8a;
  --accent-text: #06231a;
  --exact-bg: #133b27;
  --exact-fg: #8ff0bb;
  --outcome-bg: #182a4a;
  --outcome-fg: #a9c6ff;
  --wrong-bg: #3f1d1a;
  --wrong-fg: #ffb4aa;
  --live-bg: #3a2e0c;
  --live-fg: #ffd77a;
  --warn-bg: #3a2e0c;
  --warn-fg: #ffd77a;
  --error: #ff8a7a;
  --focus: #7aa8ff;
  --shadow: none;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 var(--font);
}
a { color: var(--accent); }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, summary:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}
h1, h2, h3 { line-height: 1.2; margin: 0 0 0.5em; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.2rem; margin-top: 1.5em; }
h3 { font-size: 1rem; }
.muted { color: var(--muted); }
.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; }
.small { font-size: 0.85rem; }
.nowrap { white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; text-align: right; }

/* Layout */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}
.brand { font-weight: 700; color: var(--text); text-decoration: none; display: flex; align-items: center; gap: 8px; }
.brand-mark {
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--accent); color: var(--accent-text);
  display: grid; place-items: center; font-size: 14px;
}
.nav { display: flex; gap: 4px; flex-wrap: wrap; margin-left: auto; align-items: center; }
.nav a, .nav button {
  color: var(--text); text-decoration: none; padding: 6px 10px; border-radius: 8px;
  background: none; border: 0; font: inherit; cursor: pointer;
}
.nav a:hover, .nav button:hover { background: var(--surface-2); }
.nav a[aria-current="page"] { background: var(--surface-2); font-weight: 600; }
.admin-bar { background: var(--accent); color: var(--accent-text); }
.admin-bar .nav a, .admin-bar .nav button, .admin-bar .brand { color: var(--accent-text); }
.admin-bar .nav a:hover, .admin-bar .nav button:hover, .admin-bar .nav a[aria-current="page"] {
  background: rgb(255 255 255 / 0.18);
}
.admin-bar .brand-mark { background: var(--accent-text); color: var(--accent); }

main { max-width: 1200px; margin: 0 auto; padding: 20px 16px 48px; }
.footer { max-width: 1200px; margin: 0 auto; padding: 0 16px 32px; color: var(--muted); font-size: 0.85rem; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 12px; }
.stat { background: var(--surface-2); border-radius: 8px; padding: 10px 12px; }
.stat b { display: block; font-size: 1.4rem; font-variant-numeric: tabular-nums; }
.stat span { color: var(--muted); font-size: 0.85rem; }

.page-head { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: baseline; justify-content: space-between; margin-bottom: 12px; }
.page-head h1 { margin: 0; }
.crumbs { font-size: 0.85rem; color: var(--muted); margin-bottom: 6px; }
.crumbs a { color: var(--muted); }

/* Tables */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
table { border-collapse: separate; border-spacing: 0; width: 100%; }
th, td { padding: 8px 10px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }
th { font-size: 0.8rem; font-weight: 600; color: var(--muted); background: var(--surface); }
tr:last-child td { border-bottom: 0; }
.standings td.rank { width: 3em; font-weight: 700; font-variant-numeric: tabular-nums; }
.standings td.total { font-weight: 700; font-size: 1.05rem; }

/* Prediction matrix: frozen header row and first column, horizontal scroll */
.matrix-wrap { max-height: 75vh; overflow: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.matrix { width: max-content; min-width: 100%; }
.matrix th, .matrix td { padding: 6px 8px; white-space: nowrap; }
.matrix thead th { position: sticky; top: 0; z-index: 3; border-bottom: 2px solid var(--border); text-align: center; }
.matrix .match-col { position: sticky; left: 0; z-index: 2; background: var(--surface); min-width: 210px; max-width: 260px; white-space: normal; border-right: 1px solid var(--border); }
.matrix thead .match-col { z-index: 4; text-align: left; }
.matrix .date-row th { position: sticky; top: 34px; z-index: 3; background: var(--surface-2); color: var(--text); text-align: left; font-size: 0.85rem; }
.matrix .date-row th.match-col { left: 0; z-index: 4; background: var(--surface-2); }
.matrix td.res { text-align: center; font-weight: 700; font-variant-numeric: tabular-nums; }
.matrix tfoot td { position: sticky; bottom: 0; background: var(--surface); border-top: 2px solid var(--border); font-weight: 700; text-align: center; }
.matrix tfoot td.match-col { z-index: 3; text-align: left; }
.teams { font-weight: 600; }
.teams .vs { color: var(--muted); font-weight: 400; }
.meta { color: var(--muted); font-size: 0.78rem; }

.cell { text-align: center; font-variant-numeric: tabular-nums; min-width: 64px; }
.cell .sym { display: inline-block; width: 1.1em; font-size: 0.85em; }
.cell .pts { font-size: 0.72rem; opacity: 0.85; margin-left: 2px; }
.k-exact { background: var(--exact-bg); color: var(--exact-fg); font-weight: 700; }
.k-outcome { background: var(--outcome-bg); color: var(--outcome-fg); }
.k-wrong { background: var(--wrong-bg); color: var(--wrong-fg); }
.k-missing { color: var(--muted); }
.k-excluded { color: var(--muted); text-decoration: line-through; }
.provisional { outline: 2px dashed var(--live-fg); outline-offset: -3px; }
tr.excluded td { opacity: 0.6; }

.badge {
  display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 0.75rem; font-weight: 600;
  background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); white-space: nowrap;
}
.badge.live { background: var(--live-bg); color: var(--live-fg); border-color: transparent; }
.badge.live::before { content: "● "; }
.badge.ft { background: var(--exact-bg); color: var(--exact-fg); border-color: transparent; }
.badge.warn { background: var(--warn-bg); color: var(--warn-fg); border-color: transparent; }
.badge.status-draft { border-style: dashed; }

.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 0.82rem; color: var(--muted); margin: 10px 0; padding: 0; list-style: none; }
.legend li { display: flex; align-items: center; gap: 6px; }
.legend .swatch { display: inline-grid; place-items: center; min-width: 26px; height: 20px; border-radius: 4px; font-size: 0.8rem; padding: 0 4px; }

.notice { padding: 10px 14px; border-radius: 8px; background: var(--warn-bg); color: var(--warn-fg); margin: 12px 0; }
.notice.info { background: var(--surface-2); color: var(--text); }
.messages { list-style: none; padding: 0; margin: 0 0 16px; display: grid; gap: 8px; }
.messages li { padding: 10px 14px; border-radius: 8px; background: var(--surface-2); border-left: 4px solid var(--accent); }
.messages li.error { border-left-color: var(--error); }
.messages li.error::before { content: "Error: "; font-weight: 700; color: var(--error); }

/* Cards view of a tour (phones) */
.filters { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 12px; }
.filters a { padding: 6px 12px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); color: var(--text); text-decoration: none; font-size: 0.9rem; }
.filters a[aria-current="page"] { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }
.order-switch { align-items: center; }
.order-switch .order-label { font-size: 0.85rem; color: var(--muted); margin-right: 2px; }
.view-toggle { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.view-toggle button { border: 0; background: var(--surface); color: var(--text); padding: 6px 12px; font: inherit; cursor: pointer; }
.view-toggle button[aria-pressed="true"] { background: var(--accent); color: var(--accent-text); }
.cards { display: grid; gap: 10px; }
.match-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; }
.match-card header { display: flex; justify-content: space-between; gap: 8px; align-items: start; }
.match-card .score { font-size: 1.3rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.picks { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 6px; margin-top: 10px; }
.pick { border-radius: 6px; padding: 4px 6px; background: var(--surface-2); font-size: 0.85rem; display: flex; justify-content: space-between; gap: 4px; }
.pick .who { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.date-heading { margin: 18px 0 8px; font-size: 0.95rem; color: var(--muted); }
[data-view="cards"] .matrix-view { display: none; }
[data-view="matrix"] .cards-view { display: none; }

/* Forms */
form.stack { display: grid; gap: 12px; max-width: 560px; }
label { font-weight: 600; font-size: 0.9rem; }
.field { display: grid; gap: 4px; }
.field .help { font-size: 0.8rem; color: var(--muted); }
.field .errorlist { color: var(--error); margin: 0; padding: 0; list-style: none; font-size: 0.85rem; }
input[type=text], input[type=password], input[type=date], input[type=time], input[type=number], select, textarea {
  font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; padding: 8px 10px; width: 100%;
}
input[type=checkbox] { width: 18px; height: 18px; vertical-align: middle; accent-color: var(--accent); }
.inline { display: flex; gap: 8px; flex-wrap: wrap; align-items: end; }
.inline > * { flex: 1 1 140px; }
.inline > .shrink { flex: 0 0 auto; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: inherit; font-weight: 600; padding: 8px 14px; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--accent); background: var(--accent); color: var(--accent-text); text-decoration: none;
  white-space: nowrap;
}
.btn.secondary { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn.danger { background: var(--surface); color: var(--error); border-color: var(--error); }
.btn.small { padding: 4px 10px; font-size: 0.85rem; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
details > summary { cursor: pointer; }

/* Admin prediction grid */
input.grid-input {
  width: 64px; text-align: center; padding: 5px 4px; font: 600 0.95rem var(--mono);
  border: 1px solid var(--border); border-radius: 6px; background: var(--surface); color: var(--text);
}
input.grid-input.dirty { border-color: var(--focus); background: var(--outcome-bg); }
input.grid-input.invalid { border-color: var(--error); background: var(--wrong-bg); color: var(--wrong-fg); }
.savebar {
  position: sticky; bottom: 0; z-index: 10; margin-top: 12px; padding: 10px 12px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center; box-shadow: var(--shadow);
}
.savebar .status { flex: 1 1 200px; font-size: 0.9rem; }
.savebar .status.error { color: var(--error); font-weight: 600; }
.result-form { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.result-form select { width: auto; }
.result-form input.score { width: 74px; text-align: center; font-family: var(--mono); }
.result-form input.reason { width: 200px; flex: 1 1 160px; }

.theme-toggle { font-size: 1rem; }

@media (max-width: 640px) {
  body { font-size: 14px; }
  h1 { font-size: 1.35rem; }
  main { padding: 14px 16px 40px; }
  .nav { margin-left: 0; width: 100%; }
  .hide-sm { display: none; }
  .matrix .match-col { min-width: 150px; max-width: 170px; }
  .standings th, .standings td { padding: 7px 6px; }
  .stack-sm thead { display: none; }
  .stack-sm tr, .stack-sm td { display: block; }
  .stack-sm td { border-bottom: 0; padding-bottom: 4px; }
  .stack-sm tr { border-bottom: 1px solid var(--border); padding: 6px 0; }
  .result-form input.reason { width: 100%; flex-basis: 100%; }
}

@media print {
  .topbar, .no-print, .view-toggle, .savebar, .footer { display: none !important; }
  body { background: #fff; color: #000; }
  main { max-width: none; padding: 0; }
  .card, .table-wrap, .matrix-wrap { border: 0; box-shadow: none; max-height: none; overflow: visible; }
  .cards-view { display: none !important; }
  .matrix-view { display: block !important; }
}
