:root {
  --bg: #f4f2ec;
  --surface: #ffffff;
  --surface-2: #f8f7f3;
  --text: #1d2420;
  --muted: #6b736e;
  --line: #e3e0d7;
  --accent: #0f6b45;
  --accent-ink: #ffffff;
  --accent-soft: #e3f1e9;
  --gold: #b8862b;
  --gold-soft: #fbf3e2;
  --danger: #b3261e;
  --danger-soft: #fbe9e7;
  --warn: #8a5a00;
  --warn-soft: #fff4d6;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(20, 30, 25, .06), 0 4px 16px rgba(20, 30, 25, .05);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111513;
    --surface: #1a201d;
    --surface-2: #151a17;
    --text: #e8ece9;
    --muted: #97a29c;
    --line: #2b3430;
    --accent: #3fbf84;
    --accent-ink: #0b130f;
    --accent-soft: #19352a;
    --gold: #e0b45a;
    --gold-soft: #2e2716;
    --danger: #ff8a80;
    --danger-soft: #3a1d1b;
    --warn: #f0c060;
    --warn-soft: #33290f;
    --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.5 system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, sans-serif;
  font-variant-numeric: tabular-nums;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .6em; letter-spacing: -.01em; }
h1 { font-size: 1.8rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; margin-top: 1.4em; }
p { margin: 0 0 .8em; }

.wrap { max-width: 1100px; margin: 0 auto; padding: 0 16px; }
main.wrap { padding-top: 24px; padding-bottom: 32px; }

.topbar { background: var(--surface); border-bottom: 1px solid var(--line); }
.topbar-in { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 56px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; color: var(--text); font-size: 1.05rem; }
.brand:hover { text-decoration: none; }
.logo { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 8px; background: var(--accent); color: var(--accent-ink); font-weight: 800; }
.topbar nav { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.foot { color: var(--muted); font-size: .8rem; padding-bottom: 24px; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; margin-bottom: 18px; box-shadow: var(--shadow); min-width: 0; }
.card.narrow { max-width: 420px; margin: 40px auto; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: start; }
.grid2 > .card { margin-bottom: 0; }
.grid2 + * { margin-top: 18px; }
@media (max-width: 820px) { .grid2 { grid-template-columns: 1fr; } }

.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.page-head h1 { margin-bottom: .2em; }
.eyebrow { text-transform: uppercase; letter-spacing: .08em; font-size: .72rem; font-weight: 600; color: var(--muted); margin: 0 0 4px; }
.crumbs { margin-bottom: 8px; font-size: .9rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.nowrap { white-space: nowrap; }

.hero { text-align: center; padding: 64px 0 48px; max-width: 620px; margin: 0 auto; }
.hero h1 { font-size: 2.6rem; }
.hero p { font-size: 1.1rem; }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 18px; }
@media (max-width: 640px) { .stats { grid-template-columns: repeat(2, 1fr); } }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; display: flex; flex-direction: column; box-shadow: var(--shadow); }
.stat .v { font-size: 1.45rem; font-weight: 700; }
.stat .l { color: var(--muted); font-size: .82rem; }

/* tables */
.table-scroll { overflow-x: auto; margin: 0 -20px; padding: 0 20px; }
table { border-collapse: collapse; width: 100%; }
th, td { padding: 8px 10px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
thead th { font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; border-bottom-width: 2px; }
tfoot th { border-bottom: 0; }
.num { text-align: right; }
table.list tbody tr:hover { background: var(--surface-2); }

.standings { min-width: 100%; }
.standings td, .standings th { padding: 7px 8px; }
.standings .rank { color: var(--muted); width: 2.5em; }
.standings .sticky { position: sticky; left: 0; background: var(--surface); z-index: 1; white-space: nowrap; max-width: 12em; overflow: hidden; text-overflow: ellipsis; }
.standings td.total { font-weight: 700; font-size: 1.05rem; }
.standings th.ev a { color: var(--muted); }
.standings .cell { color: var(--text); min-width: 2.2em; }
.standings .cell.win { color: var(--gold); font-weight: 700; }
.standings .cell.absent { color: var(--line); }
.standings tr.in .rank { color: var(--accent); font-weight: 700; }
.standings tr.cut td { border-bottom: 2px dashed var(--accent); }
.dropped, .dropped-sample { text-decoration: line-through; color: var(--muted) !important; opacity: .7; }
.legend { margin-top: 10px; }

table.kv th { font-weight: 500; color: var(--muted); }
table.kv td { text-align: right; }
table.kv tr.sum th, table.kv tr.sum td { font-weight: 700; color: var(--text); border-top: 2px solid var(--line); }
.win-row td { background: var(--gold-soft); }
.final-row td { background: var(--accent-soft); }
.dropped-row td { color: var(--muted); }
tr.inactive input[name=name] { color: var(--muted); }

.final { border-color: var(--gold); background: linear-gradient(135deg, var(--gold-soft), var(--surface) 60%); }
.final-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; }
.pot { text-align: right; display: flex; flex-direction: column; }
.pot-label { font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.pot-value { font-size: 2rem; font-weight: 800; color: var(--gold); }
.podium { list-style: none; padding: 0; display: flex; gap: 18px; flex-wrap: wrap; font-weight: 600; }
.medal { margin-right: 6px; }

.chip { display: inline-block; padding: 3px 10px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); margin: 0 6px 6px 0; font-size: .85rem; }
.tag { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: .72rem; font-weight: 600; background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); vertical-align: middle; }
.tag.ok { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.tag.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.notes { white-space: pre-wrap; background: var(--surface-2); padding: 10px 12px; border-radius: 10px; margin-top: 12px; }

.flash { padding: 10px 14px; border-radius: 10px; margin-bottom: 14px; font-weight: 500; }
.flash.ok { background: var(--accent-soft); color: var(--accent); }
.flash.err { background: var(--danger-soft); color: var(--danger); }
.flash.warn { background: var(--warn-soft); color: var(--warn); }

/* forms */
label { display: flex; flex-direction: column; gap: 4px; font-size: .85rem; font-weight: 500; color: var(--muted); }
input, select, textarea {
  font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--line); border-radius: 9px;
  padding: 9px 11px; width: 100%; min-width: 0;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
label.check { flex-direction: row; align-items: center; gap: 8px; color: var(--text); }
label.check input { width: auto; }
.stack { display: flex; flex-direction: column; gap: 12px; margin-bottom: 12px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 10px 0; }
.row input:not([type=checkbox]) { flex: 1 1 180px; width: auto; }
.row.tight { margin: 0; flex-wrap: nowrap; }
.row.tight input[name=name] { flex: 1 1 auto; }
.grid-form { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; align-items: end; margin-bottom: 14px; }
.grid-form .wide { grid-column: 1 / -1; }
form.inline { display: inline; }
details { margin-top: 12px; }
summary { cursor: pointer; color: var(--accent); font-weight: 600; margin-bottom: 10px; }

table.entry input.pos { width: 4.5em; text-align: right; padding: 6px 8px; }
table.entry input.pos.bad { border-color: var(--danger); background: var(--danger-soft); }
table.entry td { padding: 5px 8px; }
table.entry .pts { color: var(--muted); width: 4em; }
table.players td { padding: 6px 4px; }

.btn {
  font: inherit; font-weight: 600; cursor: pointer; border-radius: 9px; padding: 9px 16px; border: 1px solid var(--line);
  background: var(--surface); color: var(--text); display: inline-block; white-space: nowrap;
}
.btn:hover { text-decoration: none; border-color: var(--muted); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--danger); border-color: var(--danger-soft); background: var(--danger-soft); }
.btn.small { padding: 5px 11px; font-size: .85rem; }
.linklike { background: none; border: 0; padding: 0; font: inherit; color: var(--accent); cursor: pointer; }
.copy code { display: block; word-break: break-all; background: var(--surface-2); padding: 10px; border-radius: 8px; user-select: all; }

@media (max-width: 640px) {
  h1 { font-size: 1.5rem; }
  .card { padding: 16px; }
  .table-scroll { margin: 0 -16px; padding: 0 16px; }
  .pot-value { font-size: 1.6rem; }
}
