:root {
  --bg: #f6f5f2;
  --panel: #ffffff;
  --ink: #1b1d21;
  --muted: #6b6f76;
  --line: #e4e2dd;
  --soft: #f0eee9;
  --accent: #d9480f;
  --pos: #1b7f45;
  --neg: #b42318;
  --warn: #b45309;
  --live: #e03131;
  --top-h: 44px;
  font: 14px/1.4 "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--bg);
}
* { box-sizing: border-box; }
body { margin: 0; }
button { font: inherit; color: inherit; cursor: pointer; }
input { font: inherit; }

.app { min-height: 100vh; display: flex; flex-direction: column; }

/* header */
.top {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 6px 14px; background: var(--ink); color: #fff; min-height: var(--top-h);
}
.menu { border: 0; background: none; color: #fff; font-size: 18px; line-height: 1; padding: 4px 6px; border-radius: 6px; }
.menu:hover { background: #2a2d33; }
.brand { font-weight: 700; letter-spacing: .01em; font-size: 15px; margin-right: auto; }
.brand small { font-weight: 400; color: #aab0b8; font-size: 12px; margin-left: 8px; }
@media (max-width: 1100px) { .brand small { display: none; } }
.controls { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.controls button, .controls input {
  border: 1px solid #3a3e45; background: #2a2d33; color: #fff; border-radius: 6px; padding: 5px 10px;
}
.controls input[type=date] { color-scheme: dark; }
.seg { display: flex; }
.seg button { border-radius: 0; }
.seg button:first-child { border-radius: 6px 0 0 6px; }
.seg button:last-child { border-radius: 0 6px 6px 0; border-left: 0; }
.seg button.on { background: #fff; color: var(--ink); border-color: #fff; }
.date, .byid { display: flex; gap: 4px; }
.byid input { width: 130px; }

/* layout */
.layout { flex: 1; display: grid; grid-template-columns: 260px minmax(0, 1fr) 320px; gap: 0; }
.layout.no-picker { grid-template-columns: minmax(0, 1fr) 320px; }
.picker { border-right: 1px solid var(--line); background: var(--panel); overflow-y: auto; max-height: calc(100vh - var(--top-h)); position: sticky; top: 0; }
main { padding: 10px 14px; min-width: 0; }
.side { border-left: 1px solid var(--line); background: var(--panel); display: flex; flex-direction: column; max-height: calc(100vh - var(--top-h)); position: sticky; top: 0; }
@media (max-width: 1200px) {
  .layout { grid-template-columns: 240px minmax(0, 1fr); }
  .layout.no-picker { grid-template-columns: minmax(0, 1fr); }
  .side { grid-column: 1 / -1; max-height: none; position: static; border-left: 0; border-top: 1px solid var(--line); }
}
@media (max-width: 760px) {
  .layout, .layout.no-picker { grid-template-columns: 1fr; }
  .picker { max-height: 240px; position: static; border-right: 0; border-bottom: 1px solid var(--line); }
}

/* game list */
.games { display: flex; flex-direction: column; }
.games p { padding: 12px; margin: 0; }
.game {
  text-align: left; border: 0; border-bottom: 1px solid var(--line); background: none; padding: 8px 12px;
  display: flex; flex-direction: column; gap: 3px;
}
.game:hover { background: var(--soft); }
.game.sel { background: #fff4ec; box-shadow: inset 3px 0 0 var(--accent); }
.game .teams { display: flex; flex-direction: column; gap: 2px; }
.game .st { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.game.in .st { color: var(--live); font-weight: 600; }
.tl { display: flex; align-items: center; gap: 6px; }
.tl img { object-fit: contain; }
.tl .rank { font-size: 11px; color: var(--muted); }
.tl .abbr { font-weight: 600; }
.tl .sc { margin-left: auto; font-variant-numeric: tabular-nums; font-weight: 600; }

.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--live); display: inline-block; animation: pulse 1.6s infinite; }
@keyframes pulse { 50% { opacity: .35; } }

/* scorebug */
.bug { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 8px 14px; display: flex; flex-direction: column; gap: 4px; }
.matchup { display: flex; align-items: center; gap: 12px; font-size: 17px; flex-wrap: wrap; }
.matchup .tl img { width: 24px; height: 24px; }
.matchup .tl .sc { margin-left: 6px; font-size: 21px; }
.matchup .at { color: var(--muted); font-size: 15px; }
.status { margin-left: auto; font-size: 14px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.status.in { color: var(--live); font-weight: 600; }
.meta { display: flex; align-items: center; gap: 16px; color: var(--muted); font-size: 12.5px; flex-wrap: nowrap; font-variant-numeric: tabular-nums; }
.meta .info { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; white-space: nowrap; overflow: hidden; }
.meta .info > * { flex: none; }
.meta .info .fd { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.meta .ctrls { flex: none; display: flex; align-items: center; gap: 14px; white-space: nowrap; }
.upd { display: inline-flex; align-items: center; gap: 6px; min-width: 18ch; }
.upd .pulse { width: 6px; height: 6px; border-radius: 50%; background: #c9c6bf; flex: none; transition: background .2s; }
.upd.busy .pulse { background: var(--accent); animation: pulse 0.9s infinite; }
.upd.err { color: var(--neg); }
.upd.err .pulse { background: var(--neg); }
.fd-mark { display: inline-block; width: 6px; height: 6px; margin-left: 6px; border-radius: 50%; vertical-align: middle; }
.fd-mark.busy { background: var(--accent); animation: pulse 0.9s infinite; }
.fd-mark.err { background: var(--neg); }
.fd-mark.none { background: #c9c6bf; }
@media (max-width: 760px) {
  /* narrow: controls always get their own line, so the height is still fixed */
  .meta { flex-wrap: wrap; row-gap: 6px; }
  .meta .ctrls { flex-basis: 100%; }
}
.meta .sep { color: var(--line); }
.cmp { display: flex; align-items: center; gap: 6px; color: var(--ink); cursor: pointer; }
.cmp.disabled { opacity: .45; }
.link { border: 0; background: none; color: var(--accent); padding: 0; text-decoration: underline; text-underline-offset: 2px; }
.badge { display: inline-block; min-width: 18px; padding: 0 5px; border-radius: 9px; background: var(--soft); color: var(--ink); font-size: 11px; text-align: center; margin-left: 4px; font-weight: 600; }
.badge.warn { background: #fdecd8; color: var(--warn); }
.badge.ok { background: #e3f4e8; color: var(--pos); }

.replay { display: flex; align-items: center; gap: 12px; margin: 4px 2px; font-size: 12px; color: var(--muted); }
.replay input[type=range] { flex: 1; accent-color: var(--accent); }
.replay .at { font-variant-numeric: tabular-nums; min-width: 230px; }

/* box tables */
.boxes { display: flex; flex-direction: column; gap: 8px; }
.team { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; border-top: 3px solid var(--team); }
.team .th { display: flex; align-items: center; gap: 10px; padding: 3px 10px; font-size: 13.5px; font-weight: 600; white-space: nowrap; }
.team .th .tl img { width: 18px; height: 18px; }
.team .th .full-name { color: var(--muted); font-weight: 400; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.team .th .shoot { margin-left: auto; color: var(--muted); font-weight: 400; font-size: 11.5px; font-variant-numeric: tabular-nums; }
.team .th .roster { font-weight: 400; font-size: 11.5px; }
.team .th .big { font-size: 18px; font-variant-numeric: tabular-nums; min-width: 2.2em; text-align: right; }
.scroll { overflow-x: auto; container-type: inline-size; }
table.box { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.box { font-size: 12.5px; line-height: 1.3; }
.box th, .box td { padding: 2px 5px; text-align: right; white-space: nowrap; border-top: 1px solid var(--soft); }
.box thead th { font-size: 10.5px; color: var(--muted); font-weight: 600; letter-spacing: .03em; background: #fbfaf8; padding-top: 3px; padding-bottom: 3px; }
.box tr.bench-start td { border-top: 2px solid var(--line); }
.box .name { text-align: left; width: 100%; }
.box td.num { color: var(--muted); font-size: 11px; }
.box td.name .full { font-weight: 500; }
.box td.name .short { display: none; }
.box td.name .pos { color: var(--muted); font-size: 11px; margin-left: 6px; }
/* short names when the table itself is narrow (sidebars open on a laptop) */
@container (max-width: 820px) { .box td.name .full { display: none; } .box td.name .short { display: inline; } .box td.name .pos { display: none; } }
.box td.pts { font-weight: 700; }
.box td.pm.pos { color: var(--pos); font-weight: 600; }
.box td.pm.neg { color: var(--neg); font-weight: 600; }
.box tr.dnp td { color: #a9acb2; }
.box tr.on { background: #fffaf3; }
.box td.oc { width: 10px; padding-right: 0; }
.box td.oc span { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }
.box td.diff { background: #fdecd8; color: var(--warn); font-weight: 700; cursor: help; text-decoration: underline dotted; }
.box tfoot td { border-top: 2px solid var(--line); font-weight: 700; }

/* side panel */
.tabs { display: flex; border-bottom: 1px solid var(--line); }
.tabs button { flex: 1; border: 0; background: none; padding: 10px 6px; border-bottom: 2px solid transparent; color: var(--muted); font-weight: 600; font-size: 13px; }
.tabs button.on { color: var(--ink); border-bottom-color: var(--accent); }
.tab-body { overflow-y: auto; flex: 1; }
.tab-body > p { padding: 14px; margin: 0; }
.feed { list-style: none; margin: 0; padding: 0; }
.feed li { display: grid; grid-template-columns: 62px 1fr auto; gap: 8px; padding: 6px 12px; border-bottom: 1px solid var(--soft); font-size: 12.5px; align-items: baseline; }
.feed .t { color: var(--muted); font-variant-numeric: tabular-nums; font-size: 11.5px; }
.feed .s { font-variant-numeric: tabular-nums; color: var(--muted); }
.feed li.score .x, .feed li.score .s { font-weight: 700; color: var(--ink); }
.feed li.sub-in .x, .feed li.sub-out .x { color: var(--muted); font-style: italic; }
.feed li.corr, .feed li.note { grid-template-columns: 62px 1fr; }
.feed li.note em { display: block; color: var(--muted); font-style: normal; font-size: 11.5px; margin-top: 2px; }

.empty { max-width: 520px; margin: 60px auto; text-align: center; color: var(--muted); }
.empty h1 { color: var(--ink); font-size: 22px; }
.muted { color: var(--muted); }
.err { color: var(--neg); }

/* sidebar tabs */
.stabs { display: flex; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--panel); z-index: 1; }
.stabs button { flex: 1; border: 0; background: none; padding: 9px 6px; border-bottom: 2px solid transparent; color: var(--muted); font-weight: 600; font-size: 13px; }
.stabs button.on { color: var(--ink); border-bottom-color: var(--accent); }

.game.fav .teams { font-weight: 600; }
.game .star, .result .star { color: #e8a317; }
.game .st .star { margin-left: auto; }

/* team search */
.myteams { padding: 10px; display: flex; flex-direction: column; gap: 10px; }
.search input { width: 100%; padding: 7px 10px; border: 1px solid var(--line); border-radius: 6px; background: #fff; }
.search input:focus { outline: 2px solid #ffd8bf; border-color: var(--accent); }
.search p { margin: 8px 2px 0; font-size: 12.5px; }
.results { list-style: none; margin: 6px 0 0; padding: 0; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.results li + li { border-top: 1px solid var(--soft); }
.result { width: 100%; display: flex; align-items: center; gap: 8px; padding: 6px 8px; border: 0; background: #fff; text-align: left; }
.result:hover { background: var(--soft); }
.result img { object-fit: contain; flex: none; }
.result .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.result .mascot { color: var(--muted); }
.result .star { font-size: 16px; color: #c9c6bf; }
.result.on .star { color: #e8a317; }

/* followed team cards */
.hint { font-size: 12.5px; margin: 2px; }
.cards { display: flex; flex-direction: column; gap: 10px; }
.card { border: 1px solid var(--line); border-left: 4px solid var(--team); border-radius: 8px; background: #fff; overflow: hidden; transition: box-shadow .12s, opacity .12s; }
.card.dragging { opacity: .45; }
.card.droppable:hover { box-shadow: 0 -3px 0 var(--accent); }
.ch { width: 100%; display: flex; align-items: center; gap: 8px; padding: 7px 8px; border: 0; background: none; text-align: left; cursor: pointer; }
.ch:hover { background: var(--soft); }
.ch img { object-fit: contain; flex: none; }
.grip { color: #c3c0b9; cursor: grab; font-size: 14px; line-height: 1; flex: none; }
.cn { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.cn small { color: var(--muted); font-size: 11.5px; }
.chev { color: var(--muted); flex: none; font-size: 12px; }
.hl { font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-variant-numeric: tabular-nums; }
.hl.in { color: var(--live); font-weight: 600; }
.hl b.w { color: var(--pos); } .hl b.l { color: var(--neg); }
.hl .rank { font-size: 10.5px; }
.card.open .ch { border-bottom: 1px solid var(--soft); }
.tools { display: flex; gap: 4px; padding: 6px 8px; border-top: 1px solid var(--soft); background: #fbfaf8; }
.tools button { border: 1px solid var(--line); background: #fff; border-radius: 5px; padding: 2px 7px; font-size: 11.5px; white-space: nowrap; }
.tools button:disabled { opacity: .4; cursor: default; }
.tools .unf { margin-left: auto; color: var(--neg); border-color: #f1d0cc; }
.sgs { display: flex; flex-direction: column; }
.card p { margin: 0; padding: 4px 10px 8px; font-size: 12px; }
.sg { display: grid; grid-template-columns: 76px 1fr auto; gap: 6px; align-items: center; border: 0; border-top: 1px solid var(--soft); background: none; padding: 5px 10px; font-size: 12.5px; text-align: left; font-variant-numeric: tabular-nums; }
.sg:hover { background: var(--soft); }
.sg.sel { background: #fff4ec; }
.sg .d { color: var(--muted); font-size: 11.5px; white-space: nowrap; }
.sg .rank { color: var(--muted); font-size: 11px; }
.sg .r { text-align: right; white-space: nowrap; }
.sg.pre .r { color: var(--muted); }
.sg.in { background: #fff5f5; }
.sg.in .r { color: var(--live); font-weight: 700; display: flex; align-items: center; gap: 4px; }
.sg b.w { color: var(--pos); }
.sg b.l { color: var(--neg); }
.result .conf { color: var(--muted); font-size: 11px; flex: none; }


.credits { margin: 10px 2px 0; font-size: 11px; color: #a9acb2; }
.credits a { color: inherit; }

/* foul trouble */
.box td.pf.trouble { color: var(--neg); font-weight: 700; cursor: help; }
.box td.pf.out { background: var(--neg); color: #fff; font-weight: 700; cursor: help; }
