:root {
  --ink: #0a0e17;
  --surface: #121826;
  --surface-2: #0e1320;
  --inset: #0b101b;
  --border: #1e2636;
  --border-soft: #161d2b;
  --text: #e6eaf2;
  --muted: #8190ac;
  --faint: #5b6883;
  --home: #2bd17e;
  --away: #5b9dff;
  --live: #ff4d6d;
  --amber: #f5b544;
  --radius: 12px;
  --radius-sm: 8px;
  --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  --display: 'Space Grotesk', system-ui, sans-serif;
  --body: 'Inter', system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--ink);
  color: var(--text);
  font-family: var(--body);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--away); }
button { font-family: inherit; }

/* ---------- Top bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 14px 22px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(var(--surface-2), var(--ink));
  position: sticky;
  top: 0;
  z-index: 10;
}
.brand { display: flex; align-items: center; gap: 11px; }
.brand .mark {
  width: 30px; height: 30px; border-radius: 8px;
  background: var(--home);
  display: grid; place-items: center;
  color: var(--ink); font-family: var(--display); font-weight: 700; font-size: 14px;
  box-shadow: inset 0 0 0 2px rgba(255,255,255,.08);
}
.brand .title { font-family: var(--display); font-weight: 600; letter-spacing: .2px; }
.brand .sub { color: var(--faint); font-size: 12px; letter-spacing: .12em; text-transform: uppercase; }

.tabs { display: flex; gap: 2px; margin-left: 8px; }
.tab {
  background: none; border: 0; color: var(--muted);
  padding: 8px 14px; border-radius: 999px; cursor: pointer;
  font-size: 14px; font-weight: 500; letter-spacing: .01em;
}
.tab:hover { color: var(--text); background: var(--surface); }
.tab.active { color: var(--ink); background: var(--text); }

.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 16px; }
.feed-pill {
  display: flex; align-items: center; gap: 8px;
  font-size: 12px; color: var(--muted);
  border: 1px solid var(--border); border-radius: 999px; padding: 5px 12px;
}
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); }
.dot.ok { background: var(--home); }
.dot.err { background: var(--live); }
.dot.live {
  background: var(--live);
  box-shadow: 0 0 0 0 rgba(255,77,109,.6);
  animation: pulse 1.6s infinite;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(255,77,109,.5); }
  70% { box-shadow: 0 0 0 7px rgba(255,77,109,0); }
  100% { box-shadow: 0 0 0 0 rgba(255,77,109,0); }
}
.user { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 10px; }

/* ---------- Buttons ---------- */
.btn {
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 9px 15px; cursor: pointer; font-size: 14px; font-weight: 500;
}
.btn:hover { border-color: #2c3852; background: #161d2b; }
.btn.primary { background: var(--home); color: var(--ink); border-color: var(--home); }
.btn.primary:hover { background: #36e08a; }
.btn.ghost { background: none; }
.btn:disabled { opacity: .5; cursor: default; }

/* ---------- Layout ---------- */
main { max-width: 1080px; margin: 0 auto; padding: 26px 22px 80px; }
.view { display: none; }
.view.active { display: block; }
.section-head {
  display: flex; align-items: baseline; gap: 12px; margin: 4px 0 18px;
}
.section-head h2 { font-family: var(--display); font-weight: 600; font-size: 20px; margin: 0; }
.section-head .count { color: var(--faint); font-family: var(--mono); font-size: 13px; }

/* ---------- Match cards ---------- */
.match-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(310px, 1fr)); gap: 14px; }
.match-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 18px; cursor: pointer; transition: border-color .15s, transform .1s;
}
.match-card:hover { border-color: #2c3852; transform: translateY(-1px); }
.match-card .meta {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--faint);
  margin-bottom: 12px;
}
.status-tag { display: inline-flex; align-items: center; gap: 6px; }
.status-tag.live { color: var(--live); }
.status-tag.finished { color: var(--muted); }
.match-card .row {
  display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 8px; padding: 3px 0;
}
.match-card .team { display: flex; align-items: center; gap: 9px; font-weight: 500; }
.match-card .team .code {
  font-family: var(--mono); font-size: 11px; color: var(--faint);
  border: 1px solid var(--border); border-radius: 5px; padding: 1px 5px;
}
.match-card .score { font-family: var(--mono); font-size: 20px; font-weight: 700; }
.match-card .score.win { color: var(--home); }

/* ---------- Comparison bars (signature) ---------- */
.detail { display: grid; gap: 4px; }
.detail-head {
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  gap: 16px; padding: 8px 4px 18px;
}
.detail-team { display: flex; align-items: center; gap: 10px; font-family: var(--display); font-weight: 600; font-size: 17px; }
.detail-team.away { justify-content: flex-end; }
.detail-team .swatch { width: 10px; height: 10px; border-radius: 3px; }
.detail-score { font-family: var(--mono); font-size: 30px; font-weight: 700; letter-spacing: .04em; }
.cmp-row { padding: 9px 0; border-bottom: 1px solid var(--border-soft); }
.cmp-row:last-child { border-bottom: 0; }
.cmp-vals {
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  font-family: var(--mono); font-size: 14px; margin-bottom: 6px;
}
.cmp-vals .label { text-align: center; color: var(--muted); font-family: var(--body); font-size: 12px; letter-spacing: .04em; }
.cmp-vals .v-home { text-align: left; color: var(--home); font-weight: 700; }
.cmp-vals .v-away { text-align: right; color: var(--away); font-weight: 700; }
.cmp-bar { display: grid; grid-template-columns: 1fr 1fr; gap: 2px; height: 7px; }
.cmp-bar .side { background: var(--inset); border-radius: 4px; overflow: hidden; position: relative; }
.cmp-bar .fill-home { background: var(--home); height: 100%; float: right; border-radius: 4px; }
.cmp-bar .fill-away { background: var(--away); height: 100%; border-radius: 4px; }

/* ---------- Tournament table ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); }
table.stats { width: 100%; border-collapse: collapse; font-size: 14px; }
table.stats th, table.stats td { padding: 11px 13px; text-align: right; white-space: nowrap; }
table.stats th:first-child, table.stats td:first-child { text-align: left; position: sticky; left: 0; background: var(--surface); }
table.stats thead th {
  background: var(--surface-2); color: var(--muted); font-weight: 500; font-size: 12px;
  letter-spacing: .03em; cursor: pointer; user-select: none; border-bottom: 1px solid var(--border);
}
table.stats thead th:hover { color: var(--text); }
table.stats thead th.sorted { color: var(--amber); }
table.stats tbody tr { border-bottom: 1px solid var(--border-soft); }
table.stats tbody tr:hover { background: var(--surface); }
table.stats td { font-family: var(--mono); color: var(--text); }
table.stats td:first-child { font-family: var(--body); font-weight: 500; }

/* ---------- Ask (AI) ---------- */
.ask-box { display: flex; gap: 10px; margin-bottom: 16px; }
.ask-box input {
  flex: 1; background: var(--surface); border: 1px solid var(--border); color: var(--text);
  border-radius: var(--radius-sm); padding: 12px 15px; font-size: 15px; font-family: inherit;
}
.ask-box input:focus { outline: none; border-color: var(--home); }
.suggestions { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 22px; }
.chip {
  background: var(--surface); border: 1px solid var(--border); color: var(--muted);
  border-radius: 999px; padding: 7px 13px; font-size: 13px; cursor: pointer;
}
.chip:hover { color: var(--text); border-color: #2c3852; }
.answer {
  background: var(--surface); border: 1px solid var(--border); border-left: 3px solid var(--home);
  border-radius: var(--radius); padding: 18px 20px; white-space: pre-wrap; line-height: 1.65;
  min-height: 30px;
}
.answer.empty { color: var(--faint); border-left-color: var(--border); }

/* ---------- Auth ---------- */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth-card {
  width: 100%; max-width: 380px; background: var(--surface);
  border: 1px solid var(--border); border-radius: 16px; padding: 30px 28px;
}
.auth-card .mark { width: 38px; height: 38px; border-radius: 10px; background: var(--home);
  display: grid; place-items: center; color: var(--ink); font-family: var(--display); font-weight: 700; }
.auth-card h1 { font-family: var(--display); font-size: 22px; margin: 16px 0 4px; }
.auth-card p.lede { color: var(--muted); margin: 0 0 22px; font-size: 14px; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 6px; letter-spacing: .04em; }
.field input {
  width: 100%; background: var(--inset); border: 1px solid var(--border); color: var(--text);
  border-radius: var(--radius-sm); padding: 11px 13px; font-size: 15px; font-family: inherit;
}
.field input:focus { outline: none; border-color: var(--home); }
.auth-card .btn { width: 100%; margin-top: 6px; }
.switch { text-align: center; margin-top: 18px; font-size: 14px; color: var(--muted); }
.switch a { cursor: pointer; }
.error {
  background: rgba(255,77,109,.1); border: 1px solid rgba(255,77,109,.3); color: #ff8aa0;
  border-radius: var(--radius-sm); padding: 10px 13px; font-size: 13px; margin-bottom: 14px;
}
.empty-state { color: var(--faint); text-align: center; padding: 60px 20px; }

.hidden { display: none !important; }
.spin { display: inline-block; width: 14px; height: 14px; border: 2px solid var(--border);
  border-top-color: var(--home); border-radius: 50%; animation: rot .7s linear infinite; vertical-align: -2px; }
@keyframes rot { to { transform: rotate(360deg); } }

@media (max-width: 560px) {
  .topbar { flex-wrap: wrap; gap: 12px; }
  .tabs { order: 3; width: 100%; }
  .brand .sub { display: none; }
}

/* ============ v2: enriched match detail, standings, ingest ============ */

.logo { width: 22px; height: 22px; border-radius: 4px; object-fit: contain; background: var(--inset); }
.logo-lg { width: 40px; height: 40px; }

/* Scoreboard */
.scoreboard {
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 18px;
  background: linear-gradient(var(--surface), var(--surface-2));
  border: 1px solid var(--border); border-radius: 16px; padding: 22px 24px; margin-bottom: 6px;
}
.sb-team { display: flex; align-items: center; gap: 13px; font-family: var(--display); font-weight: 600; font-size: 19px; }
.sb-team.away { flex-direction: row-reverse; text-align: right; }
.sb-mid { text-align: center; }
.sb-score { font-family: var(--mono); font-size: 34px; font-weight: 700; letter-spacing: .04em; }
.sb-clock { font-size: 12px; color: var(--muted); margin-top: 4px; letter-spacing: .12em; text-transform: uppercase; }
.sb-clock.live { color: var(--live); }
.sb-venue { text-align: center; color: var(--faint); font-size: 12px; margin: 2px 0 18px; }

/* Sub-section heading inside detail */
.sub-h { font-family: var(--display); font-weight: 600; font-size: 14px; letter-spacing: .04em;
  color: var(--muted); text-transform: uppercase; margin: 26px 0 12px; }

/* Events timeline */
.timeline { position: relative; margin: 4px 0; }
.timeline::before { content: ""; position: absolute; left: 50%; top: 0; bottom: 0; width: 1px; background: var(--border); transform: translateX(-.5px); }
.tl-row { display: grid; grid-template-columns: 1fr 56px 1fr; align-items: center; gap: 0; padding: 5px 0; }
.tl-min { text-align: center; font-family: var(--mono); font-size: 12px; color: var(--faint); }
.tl-card { display: flex; align-items: center; gap: 9px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; padding: 7px 12px; max-width: max-content; }
.tl-row.home .tl-card { justify-self: end; }
.tl-row.away .tl-card { justify-self: start; flex-direction: row-reverse; text-align: right; }
.tl-card .who { font-weight: 500; font-size: 14px; }
.tl-card .what { color: var(--faint); font-size: 12px; }
.ev-ic { width: 16px; height: 16px; border-radius: 50%; flex: none; display: grid; place-items: center; }
.ev-goal { background: var(--home); }
.ev-pen { background: var(--home); box-shadow: 0 0 0 2px var(--inset), 0 0 0 3px var(--home); }
.ev-yellow { background: var(--amber); border-radius: 2px; width: 11px; height: 15px; }
.ev-red { background: var(--live); border-radius: 2px; width: 11px; height: 15px; }
.ev-sub { background: var(--away); }
.ev-var { background: var(--faint); }

/* Lineups — formation pitch */
.pitch-wrap { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.pitch { background: linear-gradient(160deg, #0c2a1a, #0a1f15); border: 1px solid var(--border);
  border-radius: 12px; padding: 14px 10px; position: relative; min-height: 220px;
  background-image: repeating-linear-gradient(0deg, transparent, transparent 38px, rgba(255,255,255,.03) 38px, rgba(255,255,255,.03) 39px); }
.pitch .formation-tag { position: absolute; top: 10px; right: 12px; font-family: var(--mono); font-size: 11px; color: var(--home); }
.pitch .coach-tag { position: absolute; bottom: 8px; left: 12px; font-size: 11px; color: var(--faint); }
.pitch-row { display: flex; justify-content: space-around; align-items: center; margin: 8px 0; }
.player-dot { display: flex; flex-direction: column; align-items: center; gap: 3px; width: 56px; }
.player-dot .num { width: 26px; height: 26px; border-radius: 50%; background: var(--home); color: var(--ink);
  display: grid; place-items: center; font-family: var(--mono); font-weight: 700; font-size: 12px; }
.player-dot.away .num { background: var(--away); }
.player-dot .nm { font-size: 10px; color: var(--text); text-align: center; line-height: 1.15; max-width: 60px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lineup-list { font-size: 13px; color: var(--muted); }
.lineup-list .ln { padding: 2px 0; }

/* Key players */
.kp-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 10px; }
.kp { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 11px 13px;
  display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.kp .nm { font-weight: 500; font-size: 14px; } .kp .tm { color: var(--faint); font-size: 12px; }
.kp .rt { font-family: var(--mono); font-weight: 700; font-size: 16px; color: var(--amber); }

/* Standings */
.group-block { margin-bottom: 22px; }
.group-block h3 { font-family: var(--display); font-weight: 600; font-size: 15px; margin: 0 0 10px; color: var(--text); }
table.standings { width: 100%; border-collapse: collapse; font-size: 14px; }
table.standings th { background: var(--surface-2); color: var(--muted); font-weight: 500; font-size: 12px;
  text-align: right; padding: 9px 11px; border-bottom: 1px solid var(--border); }
table.standings th:nth-child(-n+2) { text-align: left; }
table.standings td { padding: 10px 11px; text-align: right; font-family: var(--mono); border-bottom: 1px solid var(--border-soft); }
table.standings td:nth-child(2) { text-align: left; font-family: var(--body); font-weight: 500; display: flex; align-items: center; gap: 9px; }
table.standings td.rank { color: var(--faint); }
table.standings tr.qualify td.rank { color: var(--home); font-weight: 700; }
table.standings td.pts { color: var(--text); font-weight: 700; }
.form-pills { display: inline-flex; gap: 3px; justify-content: flex-end; }
.fp { width: 16px; height: 16px; border-radius: 4px; font-size: 10px; font-weight: 700; display: grid; place-items: center; font-family: var(--body); }
.fp.W { background: rgba(43,209,126,.18); color: var(--home); }
.fp.D { background: rgba(129,144,172,.18); color: var(--muted); }
.fp.L { background: rgba(255,77,109,.16); color: #ff8aa0; }

/* Ingest / admin */
.sync-menu { position: relative; }
.sync-pop { position: absolute; right: 0; top: 38px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; padding: 6px; min-width: 200px; z-index: 20; box-shadow: 0 8px 28px rgba(0,0,0,.4); }
.sync-pop button { display: block; width: 100%; text-align: left; background: none; border: 0; color: var(--text);
  padding: 9px 11px; border-radius: 7px; cursor: pointer; font-size: 13px; }
.sync-pop button:hover { background: var(--inset); }
.sync-pop .lbl { color: var(--faint); font-size: 11px; padding: 6px 11px 3px; letter-spacing: .06em; text-transform: uppercase; }

/* ============ Prediction panel ============ */
.pred {
  background: var(--inset); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 11px 13px; margin-top: 10px;
}
.pred-head {
  font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--faint);
  margin-bottom: 9px; display: flex; align-items: center; gap: 7px;
}
.pred-head .tag {
  background: rgba(245,181,68,.12); color: var(--amber);
  border-radius: 4px; padding: 2px 7px; font-size: 10px; font-weight: 600; letter-spacing: .06em;
}
.pred-bars { display: flex; gap: 6px; margin-bottom: 9px; }
.pred-bar-wrap { flex: 1; }
.pred-bar-lbl { font-size: 11px; color: var(--muted); text-align: center; margin-bottom: 4px; }
.pred-bar-track { height: 6px; background: var(--border); border-radius: 3px; overflow: hidden; }
.pred-bar-fill { height: 100%; border-radius: 3px; }
.pred-bar-fill.hw { background: var(--home); }
.pred-bar-fill.dr { background: var(--muted); }
.pred-bar-fill.aw { background: var(--away); }
.pred-bar-pct { font-family: var(--mono); font-size: 12px; font-weight: 700; text-align: center; margin-top: 3px; }
.pred-bar-pct.hw { color: var(--home); }
.pred-bar-pct.dr { color: var(--muted); }
.pred-bar-pct.aw { color: var(--away); }
.pred-scores { display: flex; gap: 5px; flex-wrap: wrap; }
.pred-score {
  font-family: var(--mono); font-size: 12px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 6px; padding: 3px 8px; color: var(--muted);
}
.pred-score.top { border-color: var(--amber); color: var(--amber); font-weight: 700; }
.pred-adv { font-size: 11px; color: var(--amber); margin-top: 6px; }

/* Detail prediction block */
.pred-detail {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px 20px; margin-bottom: 6px;
}
.pred-detail .pred-bars { gap: 12px; }
.pred-detail .pred-bar-fill { height: 8px; }
.pred-detail .pred-bar-pct { font-size: 14px; }
.pred-detail .pred-bar-lbl { font-size: 12px; }
