:root {
  --bg: #f5f6f8;
  --card: #ffffff;
  --text: #1b1d22;
  --muted: #6b7180;
  --border: #e3e5ea;
  --accent: #f26b1d;
  --win: #1f9d55;
  --loss: #d64545;
  --head: #14161b;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121418;
    --card: #1b1e24;
    --text: #e8eaee;
    --muted: #9aa1ad;
    --border: #2a2e36;
    --head: #0b0c0f;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
}

a { color: inherit; }

.wrap { max-width: 1100px; margin: 0 auto; padding: 0 16px; }

/* ---------- Header ---------- */
header { background: var(--head); color: #fff; position: sticky; top: 0; z-index: 10; }
.header-inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; padding-top: 12px; padding-bottom: 12px; }
.logo { font-weight: 800; font-size: 1.15rem; text-decoration: none; }
nav { display: flex; gap: 4px; flex-wrap: wrap; }
nav a { text-decoration: none; padding: 6px 10px; border-radius: 6px; font-size: .95rem; color: #c9ccd3; }
nav a:hover { color: #fff; background: rgba(255,255,255,.08); }
nav a.active { color: #fff; background: var(--accent); }

main { padding-top: 24px; padding-bottom: 24px; }
footer { color: var(--muted); font-size: .85rem; padding-bottom: 32px; }

h1 { font-size: 1.6rem; margin: 0 0 16px; }
h2 { font-size: 1.15rem; margin: 0 0 12px; }

/* ---------- Cards & grids ---------- */
.card { background: var(--card); border: 1px solid var(--border); border-radius: 10px; padding: 16px; margin-bottom: 20px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-teams { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
@media (max-width: 760px) { .grid-2 { grid-template-columns: 1fr; } }

.team-card { display: flex; align-items: center; gap: 12px; text-decoration: none; background: var(--card); border: 1px solid var(--border); border-radius: 10px; padding: 12px; }
.team-card:hover { border-color: var(--accent); }
.team-card small { color: var(--muted); display: block; }

.crest, .badge { width: 36px; height: 36px; flex-shrink: 0; }
.crest { object-fit: contain; }
.badge { display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; background: var(--muted); color: #fff; font-size: .65rem; font-weight: 800; }
.crest.sm, .badge.sm { width: 24px; height: 24px; font-size: .5rem; }
.crest.lg { width: 48px; height: 48px; }
.crest.xl { width: 72px; height: 72px; margin-bottom: 6px; }
.team-title { display: flex; align-items: center; gap: 12px; }
.leader { display: flex; justify-content: space-between; gap: 8px; padding: 2px 0; }
.center { text-align: center; }
tr.dnp td { color: var(--muted); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { padding: 8px 10px; text-align: right; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { color: var(--muted); font-weight: 600; font-size: .8rem; text-transform: uppercase; }
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover, th.sorted { color: var(--accent); }
th:first-child, td:first-child, .left { text-align: left; }
tr:last-child td { border-bottom: none; }
.team-cell { display: flex; align-items: center; gap: 8px; text-decoration: none; }
.team-cell:hover { text-decoration: underline; }
.playoff td:first-child { box-shadow: inset 3px 0 0 var(--win); }
.playin td:first-child { box-shadow: inset 3px 0 0 var(--accent); }
.pos { color: var(--muted); }
.plus { color: var(--win); }
.minus { color: var(--loss); }
.legend { font-size: .8rem; color: var(--muted); margin-top: 10px; display: flex; gap: 16px; }
.legend span::before { content: ""; display: inline-block; width: 10px; height: 10px; margin-right: 6px; border-radius: 2px; vertical-align: -1px; }
.legend .l-po::before { background: var(--win); }
.legend .l-pi::before { background: var(--accent); }

.form { display: inline-flex; gap: 3px; }
.form b { width: 18px; height: 18px; border-radius: 4px; font-size: .65rem; display: inline-flex; align-items: center; justify-content: center; color: #fff; }
.form .W { background: var(--win); }
.form .L { background: var(--loss); }

/* ---------- Games ---------- */
.game { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--border); text-decoration: none; }
.game:last-child { border-bottom: none; }
.game:hover .score { color: var(--accent); }
.game .side { display: flex; align-items: center; gap: 8px; }
.game .side.away { justify-content: flex-end; text-align: right; }
.game .score { font-weight: 700; font-variant-numeric: tabular-nums; text-align: center; min-width: 90px; }
.game .score small { display: block; font-weight: 400; color: var(--muted); font-size: .75rem; }
.winner { font-weight: 700; }
.loser { color: var(--muted); }

.round-title { font-size: .85rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin: 4px 0; }

/* ---------- Controls ---------- */
td.fc { position: relative; min-width: 96px; }
.fc-bar { position: absolute; left: 0; top: 6px; bottom: 6px; border-radius: 3px; opacity: .28; }
.fc-bar.po { background: var(--win); }
.fc-bar.pi { background: var(--accent); }
.fc-num { position: relative; }
a.plain { text-decoration: none; }
a.plain:hover { text-decoration: underline; }
.team-cell.inline { display: inline-flex; vertical-align: middle; }
tr.total td { border-top: 2px solid var(--border); font-weight: 600; }
.tabs { display: flex; gap: 6px; margin-bottom: 16px; }
.tabs a { text-decoration: none; padding: 6px 14px; border-radius: 6px; border: 1px solid var(--border); background: var(--card); }
.tabs a.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.stat-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 10px; }
.stat-tile { border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; display: flex; flex-direction: column; }
.stat-tile small { color: var(--muted); font-size: .72rem; text-transform: uppercase; }
.stat-tile b { font-size: 1.25rem; font-variant-numeric: tabular-nums; }
.stat-tile span { font-size: .78rem; }
.controls { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
select, button { font: inherit; padding: 7px 10px; border-radius: 6px; border: 1px solid var(--border); background: var(--card); color: var(--text); }
button { cursor: pointer; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button:disabled { opacity: .4; cursor: default; }

/* ---------- Game page / predictions ---------- */
.scoreboard { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; text-align: center; gap: 12px; }
.scoreboard .big { font-size: 2.4rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }

.prob-bar { display: flex; height: 26px; border-radius: 6px; overflow: hidden; font-size: .78rem; font-weight: 700; color: #fff; margin: 8px 0; }
.prob-bar div { display: flex; align-items: center; padding: 0 8px; min-width: 64px; white-space: nowrap; }
.prob-bar .ph { background: var(--accent); }
.prob-bar .pa { background: #3d4a66; justify-content: flex-end; }

@media (max-width: 560px) {
  .game .tname { font-size: .85rem; }
  .game .score { min-width: 70px; }
}

.pick { font-size: .8rem; padding: 2px 8px; border-radius: 99px; background: var(--accent); color: #fff; }
.note { font-size: .85rem; color: var(--muted); }

/* ---------- Betting ---------- */
input[type=number] { font: inherit; width: 84px; padding: 6px 8px; border-radius: 6px; border: 1px solid var(--border); background: var(--card); color: var(--text); }
.settings label { display: flex; align-items: center; gap: 6px; font-size: .9rem; }
.settings input[type=number] { width: 72px; }
.model-line { margin: 4px 0 10px; font-size: .92rem; }
.odds-grid { display: grid; grid-template-columns: 80px repeat(3, minmax(0, 1fr)); gap: 8px 12px; align-items: center; margin: 10px 0; font-size: .85rem; }
.odds-grid label { display: flex; align-items: center; gap: 6px; color: var(--muted); }
.odds-grid input[type=number] { width: 100%; min-width: 0; }
.odds-grid .lbl { font-weight: 600; }
details.lines { margin-bottom: 8px; font-size: .88rem; }
details.lines summary { cursor: pointer; color: var(--muted); }
details.lines table { margin-top: 8px; }
tr.value td { background: rgba(31, 157, 85, .12); font-weight: 600; }
button.link { border: none; background: none; padding: 0; color: var(--accent); font-size: .85rem; }
@media (max-width: 560px) {
  .odds-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .odds-grid .lbl { grid-column: 1 / -1; margin-top: 4px; }
  .odds-grid > span:empty { display: none; }
}
label.lineup { display: flex; align-items: baseline; gap: 6px; padding: 2px 0; font-size: .88rem; }
label.lineup small { color: var(--muted); margin-left: auto; }
.out-line { margin: -4px 0 8px; }
label.lineup.key span { font-weight: 600; }
label.button-like { font: inherit; padding: 7px 10px; border-radius: 6px; border: 1px solid var(--border); background: var(--card); cursor: pointer; }
input[type=number]:disabled { opacity: .6; }
textarea { width: 100%; font: .85rem/1.4 ui-monospace, Consolas, monospace; padding: 8px; border-radius: 6px; border: 1px solid var(--border); background: var(--bg); color: var(--text); resize: vertical; }
.leg { border-top: 1px solid var(--border); padding: 10px 0; }
.leg:first-of-type { border-top: none; }
.leg-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.leg p { margin: 6px 0; }
ul.why { margin: 4px 0 0; padding-left: 20px; font-size: .88rem; }
ul.why li { margin: 2px 0; }
a.tab { text-decoration: none; padding: 6px 12px; border-radius: 6px; border: 1px solid var(--border); background: var(--card); }
a.tab.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.lang { display: flex; gap: 2px; order: 3; }
.lang button { padding: 3px 8px; font-size: .8rem; font-weight: 700; background: transparent; color: #c9ccd3; border-color: rgba(255,255,255,.2); }
.lang button.active { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ---------- Wide tables and small screens ---------- */
/* Keep the team / player name in view while a wide table is scrolled sideways. */
.table-wrap :is(td, th):nth-child(1 of .left) { position: sticky; left: 0; z-index: 1; background: var(--card); }
.game .score small { white-space: nowrap; }

@media (max-width: 760px) {
  /* the menu wraps to several rows on a phone: let it scroll away instead of covering the page */
  header { position: static; }
  .header-inner { gap: 8px; padding-top: 8px; padding-bottom: 8px; }
  nav a { padding: 5px 8px; font-size: .9rem; }
  .card { padding: 12px; }
  th, td { padding: 7px 8px; }
  .table-wrap :is(td, th):nth-child(1 of .left) { max-width: 150px; white-space: normal; box-shadow: 1px 0 0 var(--border); }
}

/* ---------- Staking plan chart ---------- */
.plan-chart { --s1: #2a78d6; --s2: #eb6834; position: relative; overflow-x: auto; }
@media (prefers-color-scheme: dark) { .plan-chart { --s1: #3987e5; --s2: #d95926; } }
.plan-chart svg { width: 100%; min-width: 560px; height: auto; display: block; font-size: 12px; }
.plan-chart .s1 { fill: var(--s1); background: var(--s1); }
.plan-chart .s2 { fill: var(--s2); background: var(--s2); }
.plan-chart .dot { fill: var(--text); stroke: var(--card); stroke-width: 2; }
.plan-chart .hit { fill: transparent; }
.plan-chart .grid { stroke: var(--border); stroke-width: 1; }
.plan-chart .start { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 4 3; }
.plan-chart .sep { stroke: var(--border); stroke-width: 1; }
.plan-chart text { fill: var(--muted); }
.plan-chart text.name { fill: var(--text); font-size: 13px; font-weight: 600; }
.plan-chart text.val { fill: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }
.plan-chart .bar:hover rect:not(.hit) { opacity: .8; }
.chart-legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: .85rem; color: var(--muted); margin-bottom: 6px; }
.chart-legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.chart-legend i.dot-key { width: 10px; height: 10px; border-radius: 50%; background: var(--text); }
.chart-tip { position: absolute; max-width: 280px; padding: 6px 9px; border-radius: 6px; background: var(--head); color: #fff; font-size: .8rem; pointer-events: none; z-index: 5; }
button.style-btn.primary { font-weight: 600; }

/* ---------- Bookmakers ---------- */
.book { display: inline-flex; align-items: center; gap: 4px; }
.book.active > button:first-child { background: var(--accent); border-color: var(--accent); color: #fff; }
input[type=text] { font: inherit; padding: 7px 10px; border-radius: 6px; border: 1px solid var(--border); background: var(--card); color: var(--text); width: 170px; }
.at { font-size: .75rem; padding: 1px 6px; border-radius: 99px; border: 1px solid var(--border); color: var(--muted); font-weight: 400; }
.compare-table { margin: 4px 0 10px; font-size: .88rem; }
.compare-table td.best { font-weight: 700; color: var(--win); }
