:root {
  color-scheme: light;
  --bg: #f3f4f6; --card: #ffffff; --ink: #111827; --ink2: #4b5563; --muted: #6b7280; --line: #e5e7eb;
  --navy: #0f1b2d; --gold: #f2b632; --gold-ink: #1a1300;
  --good: #0a7d32; --bad: #c62828; --warnbg: #fff7e0; --warnline: #f2d27a;
  --pos: #2a78d6; --neg: #e34948; --zero: #9ca3af; --grid: #eceef1;
  --lock: #1b6b3a; --lockbg: #e3f4e8; --outbg: #fdecec;
  --r: 12px;
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #0b0f16; --card: #151b24; --ink: #eef0f3; --ink2: #c3c8d0; --muted: #98a0ab; --line: #263040;
    --good: #4cc77a; --bad: #ff7b7b; --warnbg: #2b2410; --warnline: #6b5520;
    --pos: #3987e5; --neg: #e66767; --zero: #6b7280; --grid: #1f2732;
    --lock: #6ad69a; --lockbg: #13301f; --outbg: #3a1717;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--ink); }
a { color: var(--pos); }
h1, h2, h3 { margin: 0 0 8px; line-height: 1.2; }
h2 { font-size: 18px; } h3 { font-size: 15px; margin-top: 18px; }
.muted { color: var(--muted); } .small { font-size: 13px; } .pad { padding: 16px; }
.pos { color: var(--good); } .neg { color: var(--bad); }

/* header */
.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 16px; padding: 10px 16px; padding-top: max(10px, env(safe-area-inset-top));
  background: var(--navy); color: #fff; }
.brand { display: flex; align-items: center; gap: 8px; color: #fff; text-decoration: none; font-size: 20px; letter-spacing: .2px; }
.brand b, .login h1 b { color: var(--gold); }
.tabs { display: flex; gap: 4px; flex: 1; }
.tabs a { color: #cbd5e1; text-decoration: none; padding: 7px 12px; border-radius: 8px; font-weight: 600; font-size: 14px; }
.tabs a.on { background: rgba(255,255,255,.12); color: #fff; }
.top .link { color: #cbd5e1; }
main { max-width: 980px; margin: 0 auto; padding: 16px 12px 96px; }

/* cards */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; margin-bottom: 14px; }
.cardhead { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.cardhead h2 { margin: 0; }
.notice { background: var(--warnbg); border: 1px solid var(--warnline); border-radius: 10px; padding: 10px 12px; margin-top: 12px; }
.notice.bad { color: var(--bad); }

/* buttons + forms */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 42px; padding: 8px 16px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--card); color: var(--ink); font: inherit; font-weight: 600; text-decoration: none; cursor: pointer; }
.btn.go { background: var(--gold); border-color: var(--gold); color: var(--gold-ink); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.wide { width: 100%; } .btn.big { min-height: 50px; font-size: 17px; margin-top: 14px; }
.link { background: none; border: 0; padding: 0; color: var(--pos); font: inherit; font-size: 14px; cursor: pointer; text-decoration: none; }
.filebtn { cursor: pointer; }
.field { display: block; margin: 10px 0; }
.field > span { display: block; font-size: 13px; font-weight: 600; color: var(--ink2); margin-bottom: 4px; }
.field em { font-style: normal; color: var(--muted); }
.field small { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }
input[type=text], input[type=password], input[type=number], input[type=search], select {
  width: 100%; min-height: 44px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); color: var(--ink); font: inherit; font-size: 16px; }
input[type=range] { width: 100%; accent-color: var(--gold); }
.check { display: flex; gap: 10px; align-items: center; margin: 10px 0; min-height: 32px; }
.check input { width: 20px; height: 20px; accent-color: var(--gold); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.adv { margin-top: 6px; border-top: 1px solid var(--line); padding-top: 10px; }
.adv summary { cursor: pointer; font-weight: 600; color: var(--ink2); padding: 4px 0; }
.err { color: var(--bad); min-height: 1.2em; }
.login { max-width: 380px; margin: 40px auto; }

/* segmented contest-type picker */
.seg { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.seg label { position: relative; }
.seg input { position: absolute; opacity: 0; }
.seg span { display: flex; align-items: center; justify-content: center; text-align: center; min-height: 52px; padding: 6px; border: 1px solid var(--line); border-radius: 10px; font-weight: 600; font-size: 14px; cursor: pointer; }
.seg input:checked + span { background: var(--navy); color: #fff; border-color: var(--navy); }
.seg input:focus-visible + span { outline: 2px solid var(--gold); }

/* files */
.files { list-style: none; margin: 0; padding: 0; }
.files li { padding: 10px 0 10px 30px; border-top: 1px solid var(--line); position: relative; }
.files li:first-child { border-top: 0; }
.files li::before { position: absolute; left: 2px; top: 10px; width: 20px; height: 20px; border-radius: 50%; text-align: center; font-size: 13px; line-height: 20px; font-weight: 700; }
.files li.ok::before { content: "✓"; background: var(--good); color: #fff; }
.files li.todo::before { content: "·"; background: var(--line); color: var(--muted); }
.files li.warn::before { content: "!"; background: var(--gold); color: var(--gold-ink); }
.files b { display: inline; } .files em { color: var(--muted); font-style: normal; font-size: 13px; }
.files span { display: block; color: var(--ink2); font-size: 14px; }
.files span.warn { color: var(--bad); }
.files details { font-size: 13px; margin-top: 4px; }

/* players */
.filters { display: flex; flex-direction: column; gap: 8px; margin-bottom: 8px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chips button { min-height: 36px; padding: 4px 12px; border-radius: 18px; border: 1px solid var(--line); background: var(--card); color: var(--ink); font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; }
.chips button.on { background: var(--navy); color: #fff; border-color: var(--navy); }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); font-weight: 600; padding: 6px; border-bottom: 1px solid var(--line); }
td { padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.n { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.sub { font-size: 12px; color: var(--muted); }
.ptable tr.locked { background: var(--lockbg); }
.ptable tr.out td:not(.acts) { opacity: .45; }
.ptable tr.out { background: var(--outbg); }
.acts { white-space: nowrap; text-align: right; }
.pill { min-height: 34px; min-width: 50px; padding: 4px 10px; margin-left: 4px; border-radius: 17px; border: 1px solid var(--line); background: var(--card); color: var(--ink2); font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; }
.pill.on.lock { background: var(--lock); border-color: var(--lock); color: #fff; }
.pill.on.out { background: var(--bad); border-color: var(--bad); color: #fff; }
.proj { min-height: 32px; padding: 2px 8px; border: 1px dashed var(--line); border-radius: 8px; background: none; color: var(--ink); font: inherit; font-variant-numeric: tabular-nums; cursor: pointer; }
.proj.edited { border-style: solid; border-color: var(--gold); font-weight: 700; }
.tag { display: inline-block; padding: 0 5px; border-radius: 4px; font-size: 11px; font-weight: 700; vertical-align: 1px; }
.tag.inj { background: var(--bad); color: #fff; }

/* lineups */
.dl { display: flex; gap: 8px; flex-wrap: wrap; }
.lineups { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 0 14px; }
.lhead { display: flex; gap: 12px; align-items: baseline; flex-wrap: wrap; margin-bottom: 6px; font-variant-numeric: tabular-nums; }
.lhead b { font-size: 18px; }
.ltable td { padding: 6px 4px; }
.slot { width: 44px; font-size: 11px; font-weight: 800; color: var(--muted); }
.plain { margin: 0; padding-left: 18px; } .plain li { margin: 4px 0; }

/* history */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 10px; }
.tile { border: 1px solid var(--line); border-radius: 10px; padding: 12px; }
.tile .k { font-size: 13px; color: var(--muted); font-weight: 600; }
.tile .v { font-size: 28px; font-weight: 700; font-variant-numeric: tabular-nums; }
.tile .s { font-size: 13px; color: var(--ink2); }
.tile .v.pos, .tile .v.neg { color: var(--ink); }
.data td.pos, .data td.neg { color: var(--ink); }

.chart { position: relative; margin: 6px 0 4px; }
.chart svg { width: 100%; height: auto; display: block; overflow: visible; }
.chart .grid { stroke: var(--grid); stroke-width: 1; }
.chart .zero { stroke: var(--zero); stroke-width: 1; }
.chart .yl { fill: var(--muted); font-size: 11px; text-anchor: end; font-variant-numeric: tabular-nums; }
.chart .xl { fill: var(--muted); font-size: 11px; text-anchor: middle; }
.chart .dl { fill: var(--ink2); font-size: 11px; font-weight: 600; text-anchor: middle; font-variant-numeric: tabular-nums; }
.chart path.pos { fill: var(--pos); } .chart path.neg { fill: var(--neg); }
.chart .hit { fill: transparent; cursor: pointer; }
.chart .bar { outline: none; }
.chart .bar.dim path { opacity: .35; }
.chart .bar:focus-visible .hit { stroke: var(--gold); stroke-width: 2; }
.tip { position: absolute; background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font-size: 13px;
  box-shadow: 0 4px 14px rgba(0,0,0,.15); pointer-events: none; max-width: 260px; color: var(--ink2); }
.tip b { color: var(--ink); } .tip .tv { font-size: 18px; font-weight: 700; color: var(--ink); font-variant-numeric: tabular-nums; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 13px; color: var(--ink2); margin-bottom: 10px; align-items: center; }
.sw { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.sw.pos { background: var(--pos); } .sw.neg { background: var(--neg); }

#toast { position: fixed; left: 50%; bottom: max(20px, env(safe-area-inset-bottom)); transform: translate(-50%, 140%); background: var(--navy); color: #fff;
  padding: 12px 16px; border-radius: 12px; max-width: min(92vw, 520px); transition: transform .2s, visibility .2s; z-index: 20; box-shadow: 0 6px 20px rgba(0,0,0,.25); visibility: hidden; }
#toast.show { transform: translate(-50%, 0); visibility: visible; }
#toast.good { border-left: 5px solid var(--gold); } #toast.bad { border-left: 5px solid var(--neg); }

/* phones: tabs move to a bottom bar */
@media (max-width: 700px) {
  .top { gap: 10px; }
  .tabs { position: fixed; left: 0; right: 0; bottom: 0; background: var(--navy); justify-content: space-around; padding: 6px 4px max(6px, env(safe-area-inset-bottom)); gap: 0; border-top: 1px solid rgba(255,255,255,.1); }
  .tabs a { flex: 1; text-align: center; padding: 10px 2px; font-size: 13px; }
  .top .link { margin-left: auto; }
  .hide-sm { display: none; }
  #toast { bottom: calc(72px + env(safe-area-inset-bottom)); }
  .card { padding: 14px 12px; }
  .seg span { font-size: 13px; }
  .pill { min-width: 44px; padding: 4px 8px; }
  .ptable td { padding: 8px 3px; }
}
[hidden] { display: none !important; }
