:root {
  color-scheme: light;
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --raised: #ffffff;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #898781;
  --line: #e1e0d9;
  --line-strong: #c3c2b7;
  --wash: rgba(11, 11, 11, 0.04);
  --accent: #2a78d6;
  --accent-ink: #184f95;
  --mine: #eef4fd;
  --good: #0ca30c;
  --good-ink: #006300;
  --warning: #fab219;
  --warning-ink: #8a5a00;
  --warning-wash: #fff4dc;
  --serious: #ec835a;
  --serious-ink: #b04a1f;
  --critical: #d03b3b;
  --critical-wash: #fdeceb;
  --shadow: 0 10px 32px rgba(11, 11, 11, 0.16);
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --page: #0d0d0d;
    --surface: #161615;
    --raised: #1f1f1e;
    --ink: #ffffff;
    --ink-2: #c3c2b7;
    --muted: #8f8d86;
    --line: #2c2c2a;
    --line-strong: #3c3c39;
    --wash: rgba(255, 255, 255, 0.05);
    --accent: #3987e5;
    --accent-ink: #9ec5f4;
    --mine: #14253d;
    --good-ink: #3fcb3f;
    --warning-ink: #f7c55c;
    --serious-ink: #f29a76;
    --warning-wash: #2e2410;
    --critical-wash: #331717;
    --shadow: 0 10px 32px rgba(0, 0, 0, 0.6);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif;
  font-variant-numeric: tabular-nums;
}
button, input { font: inherit; color: inherit; }
button {
  background: var(--raised);
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 6px 12px;
  cursor: pointer;
}
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
a { color: var(--accent-ink); }
[hidden] { display: none !important; }

/* ---------- header and tabs ---------- */
.bar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px;
  padding-top: max(10px, env(safe-area-inset-top));
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.bar-main { min-width: 0; flex: 1; display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.title { font-weight: 700; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fresh { color: var(--muted); font-size: 12px; }
.fresh.stale { color: var(--warning-ink); font-weight: 600; }
.icon-btn { padding: 6px; display: grid; place-items: center; border-radius: 50%; }
.icon-btn.spin svg { animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.tabs { display: flex; gap: 2px; }
.tabs button {
  border: 0; background: none; border-radius: 8px; padding: 6px 12px;
  color: var(--ink-2); font-weight: 500;
}
.tabs button.on { background: var(--wash); color: var(--ink); font-weight: 650; }
.tabs .dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--critical); margin-left: 5px; vertical-align: 2px; }

@media (max-width: 759px) {
  .tabs {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
    justify-content: space-around;
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
    background: var(--surface); border-top: 1px solid var(--line);
  }
  .tabs button { flex: 1; padding: 8px 1px; font-size: 12px; min-width: 0; }
  #main { padding-bottom: 76px; }
}

/* ---------- page ---------- */
#view { max-width: 980px; margin: 0 auto; padding: 14px 16px 32px; }
h2 { font-size: 15px; margin: 22px 0 8px; display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
h2 .sub { font-weight: 400; color: var(--muted); font-size: 13px; }
p.lead { color: var(--ink-2); margin: 4px 0 10px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.card {
  background: var(--raised); border: 1px solid var(--line); border-radius: 12px;
  padding: 12px 14px; margin: 8px 0;
}
.banner { border-radius: 12px; padding: 10px 14px; margin: 8px 0; background: var(--mine); }
.banner.warn { background: var(--warning-wash); }
.banner.bad { background: var(--critical-wash); }

/* action cards: the border and chip say how urgent */
.act { border-left: 4px solid var(--line-strong); }
.act.now { border-left-color: var(--critical); background: var(--critical-wash); }
.act.soon { border-left-color: var(--warning); }
.act.optional { border-left-color: var(--accent); }
.act .t { font-weight: 650; }
.act .d { color: var(--ink-2); margin-top: 3px; }
.act .steps { margin: 8px 0 0; padding-left: 20px; }
.act .steps li { margin: 3px 0; }
.act .why { color: var(--ink-2); font-size: 12.5px; margin-top: 8px; }
.urg {
  display: inline-block; font-size: 10.5px; font-weight: 700; letter-spacing: 0.03em; text-transform: uppercase;
  border-radius: 5px; padding: 1px 6px; margin-right: 8px; vertical-align: 1px; white-space: nowrap;
}
.urg.now { background: var(--critical); color: #fff; }
.urg.soon { background: var(--warning); color: #241800; }
.urg.optional { border: 1px solid var(--accent); color: var(--accent-ink); }
.urg.fyi { background: var(--wash); color: var(--muted); }
.act .who { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--line-strong); border-radius: 999px; padding: 3px 10px;
  background: var(--raised); font-size: 13px; cursor: pointer;
}
.pill .lbl { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.03em; }

/* chips */
.chip {
  display: inline-block; font-size: 10.5px; font-weight: 700; letter-spacing: 0.02em;
  border-radius: 5px; padding: 1px 5px; vertical-align: 1px; white-space: nowrap;
  background: var(--wash); color: var(--ink-2);
}
.chip.out { background: var(--critical); color: #fff; }
.chip.dtd { background: var(--warning); color: #241800; }
.chip.wv { background: var(--mine); color: var(--accent-ink); }
.chip.slot { background: none; border: 1px solid var(--line-strong); color: var(--ink-2); min-width: 28px; text-align: center; }
.chip.ir { border-color: var(--critical); color: var(--critical); }
.chip.new { background: var(--accent); color: #fff; }

/* player rows */
.rows { background: var(--raised); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; margin: 8px 0; }
.row {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; align-items: center;
  padding: 9px 12px; border-top: 1px solid var(--line); cursor: pointer;
}
.row:first-child { border-top: 0; }
.row:hover { background: var(--wash); }
.row.mine { background: var(--mine); }
.row.benched { background: var(--wash); }
.row .who { min-width: 0; }
.row .nm { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .meta { color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row.wrap .meta { white-space: normal; }
.row .nums { display: flex; gap: 14px; justify-content: flex-end; text-align: right; }
.row .num { min-width: 44px; }
.row .num b { display: block; font-weight: 650; }
.row .num span { display: block; color: var(--muted); font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.03em; }
.row .note { grid-column: 1 / -1; color: var(--ink-2); font-size: 12.5px; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.row .slotcol { display: flex; gap: 10px; align-items: center; min-width: 0; }
.pos { color: var(--good-ink); }
.neg { color: var(--muted); }
.down { color: var(--serious-ink); }
.chip.up { background: none; border: 1px solid currentColor; color: var(--good-ink); }
.chip.down { background: none; border: 1px solid currentColor; color: var(--serious-ink); }

/* team report tiles */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; margin: 8px 0; }
.tile { background: var(--raised); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.tile b { display: block; font-size: 22px; font-weight: 700; line-height: 1.2; }
.tile span { color: var(--muted); font-size: 12px; }
@media (max-width: 520px) {
  .row .num.opt { display: none; }
  .row .nums { gap: 10px; }
  .row .num { min-width: 38px; }
}

/* segmented controls and filters */
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin: 10px 0 4px; }
.seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: 9px; overflow: hidden; background: var(--raised); }
.seg button { border: 0; border-radius: 0; padding: 6px 11px; background: none; color: var(--ink-2); }
.seg button + button { border-left: 1px solid var(--line); }
.seg button.on { background: var(--accent); color: #fff; font-weight: 600; }
.toolbar input[type=search] {
  flex: 1; min-width: 140px; padding: 7px 10px; border-radius: 9px;
  border: 1px solid var(--line-strong); background: var(--raised);
}
.check { display: inline-flex; gap: 6px; align-items: center; color: var(--ink-2); font-size: 13px; white-space: nowrap; }
.scroll-x { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* matchup */
.vs { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 10px; text-align: center; }
.vs .side .tm { font-weight: 650; }
.vs .side .sc { font-size: 26px; font-weight: 700; line-height: 1.1; }
.vs .side .pj { color: var(--muted); font-size: 12.5px; }
.vs .mid { color: var(--muted); font-size: 12px; }
.bar-split { display: flex; height: 6px; border-radius: 3px; overflow: hidden; margin: 10px 0 4px; background: var(--line); }
.bar-split i { display: block; height: 100%; }
.bar-split i.a { background: var(--accent); }
.bar-split i.b { background: var(--line-strong); }

/* tables */
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th { text-align: left; font-weight: 600; color: var(--muted); font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.03em; padding: 6px 8px; border-bottom: 1px solid var(--line); }
.tbl td { padding: 7px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl td.r, .tbl th.r { text-align: right; white-space: nowrap; }
.tbl tr.mine td { background: var(--mine); }

/* drawer */
.scrim { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.35); z-index: 30; }
.drawer {
  position: fixed; z-index: 31; background: var(--surface); box-shadow: var(--shadow);
  overflow-y: auto; -webkit-overflow-scrolling: touch;
  top: 0; right: 0; bottom: 0; width: min(460px, 100vw); padding: 16px 18px 40px;
}
@media (max-width: 759px) {
  .drawer { top: auto; left: 0; width: 100vw; max-height: 88vh; border-radius: 16px 16px 0 0; padding-bottom: calc(40px + env(safe-area-inset-bottom)); }
}
.drawer h3 { margin: 0; font-size: 18px; padding-right: 36px; }
.drawer .close { position: absolute; top: 12px; right: 12px; border: 0; background: var(--wash); border-radius: 50%; width: 32px; height: 32px; padding: 0; font-size: 18px; line-height: 32px; }
.drawer .sec { margin-top: 16px; }
.drawer .sec > .h { font-weight: 650; font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); margin-bottom: 6px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 3px 14px; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.news { border-top: 1px solid var(--line); padding: 8px 0; }
.news:first-child { border-top: 0; padding-top: 0; }
.news .when { color: var(--muted); font-size: 12px; }
.news .hl { font-weight: 600; }
.news .st { color: var(--ink-2); font-size: 13px; margin-top: 2px; }
.news[data-pid] { cursor: pointer; }

/* lock screen */
.lock { display: grid; place-items: center; min-height: 70vh; padding: 16px; }
.lock form { width: min(360px, 100%); display: grid; gap: 12px; }
.lock h1 { margin: 0; font-size: 22px; }
.lock p { margin: 0; color: var(--ink-2); }
.lock input[type=password] { padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line-strong); background: var(--raised); font-size: 16px; }
.lock .error { color: var(--critical); }
.empty { color: var(--muted); padding: 14px 12px; }
