:root {
  color-scheme: dark;
  --bg: #07101c;
  --panel: #0c1726;
  --panel-2: #111f31;
  --line: #213147;
  --line-soft: #18283b;
  --text: #f4f7fb;
  --muted: #8ea0b7;
  --accent: #4ee1a0;
  --accent-soft: rgba(78, 225, 160, .11);
  --blue: #64a8ff;
  --red: #ff7188;
  --amber: #ffc65b;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-width: 320px; background: radial-gradient(circle at 75% -20%, #173251 0, transparent 34rem), var(--bg); color: var(--text); }
button, input { font: inherit; }
button { cursor: pointer; }

.topbar { height: 52px; padding: 0 max(12px, calc((100vw - 1320px) / 2)); display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); background: rgba(7, 16, 28, .9); backdrop-filter: blur(14px); position: sticky; top: 0; z-index: 10; }
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark { width: 30px; height: 30px; display: grid; place-items: center; border-radius: 8px; color: #07101c; background: var(--accent); font-weight: 900; font-size: 16px; transform: skew(-7deg); }
.brand strong { font-size: 15px; letter-spacing: -.02em; }
.mode { color: #b8c4d2; font-size: 12px; padding: 6px 9px; border: 1px solid var(--line); border-radius: 999px; background: var(--panel); }
.mode-dot, .live-indicator { width: 6px; height: 6px; display: inline-block; border-radius: 50%; }
.mode-dot { background: var(--amber); margin-right: 6px; box-shadow: 0 0 0 3px rgba(255,198,91,.11); }
.mode[data-status="connected"] .mode-dot { background: var(--accent); box-shadow: 0 0 0 3px rgba(78,225,160,.11); }
.mode[data-status="partial"] .mode-dot, .mode[data-status="stale"] .mode-dot { background: var(--amber); }
.mode[data-status="error"] .mode-dot { background: var(--red); box-shadow: 0 0 0 3px rgba(255,113,136,.11); }
.live-indicator { background: var(--accent); box-shadow: 0 0 0 3px rgba(78,225,160,.1); }

main { max-width: 1320px; margin: 0 auto; padding: 10px 12px 24px; }
.control-strip { min-height: 40px; display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 8px; }
.tabs { display: flex; gap: 3px; padding: 3px; background: var(--panel); border: 1px solid var(--line); border-radius: 9px; }
.tab { min-height: 32px; border: 0; color: var(--muted); background: transparent; padding: 5px 12px; border-radius: 6px; font-weight: 750; font-size: 13px; }
.tab span { margin-left: 5px; padding: 1px 6px; border-radius: 999px; background: #1a2a3e; font-size: 11px; }
.tab.active { color: var(--text); background: #1b2a3f; }
.tab.active:first-child { color: var(--accent); }
.live-controls { display: flex; align-items: center; gap: 7px; }
.live-controls > span { color: var(--muted); font-size: 12px; margin-right: 4px; }
.ghost-button, .primary-button { min-height: 32px; border-radius: 7px; padding: 0 11px; border: 1px solid var(--line); font-size: 12px; font-weight: 750; }
.ghost-button { color: #c3cedb; background: var(--panel); }
.primary-button { color: #052216; background: var(--accent); border-color: var(--accent); }
.primary-button:disabled { opacity: .65; cursor: wait; }
.primary-button.loading span { display: inline-block; animation: spin .75s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.workspace { border: 1px solid var(--line); border-radius: 11px; overflow: hidden; background: rgba(12,23,38,.97); box-shadow: 0 18px 55px rgba(0,0,0,.17); }
.workspace-head { min-height: 42px; padding: 5px 11px; display: flex; align-items: center; justify-content: space-between; gap: 12px; border-bottom: 1px solid var(--line); background: #091522; }
.view-label { display: flex; align-items: center; gap: 8px; }
.view-label strong { font-size: 13px; }
.view-label small { color: #74889f; font-size: 11px; padding-left: 8px; border-left: 1px solid var(--line); }
.search { width: 220px; min-height: 30px; display: flex; align-items: center; gap: 7px; padding: 0 10px; border: 1px solid var(--line); border-radius: 7px; background: #07111e; color: var(--muted); }
.search input { width: 100%; border: 0; outline: 0; color: var(--text); background: transparent; font-size: 12px; }
.search input::placeholder { color: #6f8299; }

.match-list { background: var(--line-soft); display: grid; gap: 1px; }
.match-card { min-width: 0; background: var(--panel); }
.match-summary { width: 100%; height: 54px; display: grid; grid-template-rows: 26px 27px; padding: 0 10px; border: 0; color: var(--text); background: transparent; text-align: left; font-variant-numeric: tabular-nums; transition: background .15s ease; }
.match-summary:hover, .match-summary:focus-visible, .match-card.open .match-summary { background: #101e30; outline: 0; }
.match-card.divergence-match .match-summary { background: linear-gradient(90deg, rgba(255,198,91,.13), transparent 27%); box-shadow: inset 3px 0 var(--amber); }
.match-card.divergence-quarter .match-summary { background: linear-gradient(90deg, rgba(100,168,255,.13), transparent 27%); box-shadow: inset 3px 0 var(--blue); }
.match-card.divergence-match .match-summary:hover, .match-card.divergence-match.open .match-summary { background: linear-gradient(90deg, rgba(255,198,91,.18), #101e30 38%); }
.match-card.divergence-quarter .match-summary:hover, .match-card.divergence-quarter.open .match-summary { background: linear-gradient(90deg, rgba(100,168,255,.18), #101e30 38%); }
.primary-line, .market-line { min-width: 0; display: flex; align-items: center; white-space: nowrap; }
.primary-line { gap: 9px; border-bottom: 1px solid rgba(33,49,71,.48); }
.league { flex: 0 0 128px; overflow: hidden; text-overflow: ellipsis; color: var(--blue); font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .02em; }
.teams { min-width: 0; flex: 1 1 auto; overflow: hidden; text-overflow: ellipsis; font-size: 13px; font-weight: 720; }
.score { flex: 0 0 58px; text-align: right; font-size: 15px; font-weight: 850; letter-spacing: .02em; }
.period-scores { min-width: 0; flex: 0 1 230px; display: flex; justify-content: flex-end; gap: 8px; overflow: hidden; color: #aab7c6; font-size: 10px; font-weight: 750; }
.period-scores > span { display: inline-flex; align-items: baseline; gap: 3px; }
.period-scores small { color: #60748c; font-size: 8px; font-weight: 800; }
.period-scores.empty { color: #60748c; }
.game-clock, .start-time { flex: 0 0 76px; color: var(--accent); text-align: right; font-size: 12px; font-weight: 750; }
.start-time { flex-basis: 104px; color: #b9c5d3; }
.chevron { flex: 0 0 18px; color: var(--muted); text-align: center; font-size: 15px; transition: transform .16s ease; }
.match-card.open .chevron { color: var(--text); transform: rotate(180deg); }

.market-line { gap: 10px; padding-left: 137px; font-size: 12px; }
.market-item { display: inline-flex; align-items: baseline; gap: 6px; }
.market-item small { color: #6f8299; font-size: 10px; font-weight: 700; letter-spacing: .025em; }
.market-item strong { font-size: 13px; font-weight: 820; }
.current-market strong { color: #fff; }
.quarter-fact strong { color: var(--accent); }
.divergence-badge { flex: 0 0 auto; margin-left: auto; min-height: 19px; display: inline-flex; align-items: center; padding: 1px 6px; border: 1px solid; border-radius: 999px; font-size: 9px; font-weight: 850; letter-spacing: .02em; }
.divergence-badge.match { color: var(--amber); border-color: rgba(255,198,91,.42); background: rgba(255,198,91,.09); }
.divergence-badge.quarter { color: var(--blue); border-color: rgba(100,168,255,.42); background: rgba(100,168,255,.09); }
.market-divider { width: 1px; height: 12px; background: var(--line); }
.delta { display: inline-flex; align-items: center; justify-content: center; min-width: 42px; min-height: 21px; padding: 2px 6px; border-radius: 5px; font-size: 11px; font-weight: 850; }
.delta.negative { color: var(--red); background: rgba(255,113,136,.1); }
.delta.positive { color: var(--accent); background: var(--accent-soft); }
.delta.neutral { color: #aab7c6; background: rgba(142,160,183,.09); }
.inline-delta { min-width: 0; min-height: 0; padding: 1px 5px; }
.value-empty { color: #60748c; }

.match-detail { background: #08131f; border-top: 1px solid var(--line); }
.detail-panel { padding: 10px 12px 12px; }
.quarter-matrix { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 7px; }
.quarter-block { min-width: 0; border: 1px solid var(--line-soft); border-radius: 8px; overflow: hidden; background: #0c1928; }
.quarter-block.current { border-color: rgba(78,225,160,.48); box-shadow: 0 0 0 1px rgba(78,225,160,.07) inset; }
.quarter-block.quoted { border-color: rgba(255,198,91,.44); }
.quarter-block.complete { border-color: #293b51; }
.quarter-block header { height: 27px; display: flex; align-items: center; justify-content: space-between; padding: 0 9px; border-bottom: 1px solid var(--line-soft); background: #101f31; }
.quarter-block header span { font-size: 12px; font-weight: 850; }
.quarter-block header small { color: var(--muted); font-size: 9px; font-weight: 800; letter-spacing: .035em; }
.quarter-block.current header small { color: var(--accent); }
.quarter-block.quoted header small { color: var(--amber); }
.quarter-values { min-height: 64px; display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); align-items: stretch; }
.quarter-block.complete .quarter-values { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.matrix-metric { min-width: 0; display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 3px; padding: 5px 3px; border-right: 1px solid var(--line-soft); text-align: center; }
.matrix-metric:last-child { border-right: 0; }
.matrix-metric small { color: #71859c; font-size: 9px; font-weight: 750; letter-spacing: .025em; }
.matrix-metric strong { font-size: 13px; font-weight: 820; }
.matrix-metric.current-price strong { color: var(--accent); }
.matrix-metric .delta { min-width: 0; padding: 1px 3px; font-size: 10px; }

.state-message { padding: 36px 16px; color: var(--muted); text-align: center; font-size: 13px; }
.state-message.error { color: var(--red); }

@media (max-width: 1050px) {
  .league { flex-basis: 100px; }
  .period-scores { flex-basis: 175px; gap: 5px; }
  .market-line { padding-left: 109px; gap: 8px; }
  .quarter-values { min-height: 60px; }
}

@media (max-width: 760px) {
  .topbar { padding: 0 9px; }
  .mode { font-size: 0; width: 25px; height: 25px; padding: 8px; }
  .mode-dot { margin: 0; }
  main { padding: 8px 7px 18px; }
  .live-controls > span { display: none; }
  .ghost-button { display: none; }
  .workspace-head { padding: 5px 8px; }
  .view-label small { display: none; }
  .search { width: 160px; }
  .match-summary { height: 58px; grid-template-rows: 29px 28px; padding: 0 7px; }
  .primary-line { gap: 6px; }
  .league { flex-basis: 53px; font-size: 9px; }
  .teams { font-size: 12px; }
  .score { flex-basis: 44px; font-size: 13px; }
  .period-scores { flex-basis: 112px; gap: 4px; font-size: 9px; }
  .period-scores small { display: none; }
  .game-clock { flex-basis: 60px; font-size: 11px; }
  .start-time { flex-basis: 82px; font-size: 10px; }
  .chevron { flex-basis: 13px; }
  .market-line { gap: 6px; padding-left: 59px; }
  .market-item { gap: 4px; }
  .market-item small { font-size: 8px; }
  .market-item strong { font-size: 11px; }
  .market-divider { height: 10px; }
  .delta { min-width: 35px; padding: 1px 4px; font-size: 10px; }
  .divergence-badge { padding-inline: 4px; font-size: 8px; }
  .upcoming-markets .market-item:last-child, .upcoming-markets .market-divider:last-of-type { display: none; }
  .detail-panel { overflow-x: auto; padding: 8px; }
  .quarter-matrix { min-width: 800px; }
}

/* Paper experiments: isolated from the 54px match rows. */
[hidden] { display: none !important; }
.lab-panel { padding: 14px; }
.lab-heading strong { font-size: 16px; }
.lab-heading p, .lab-status, .lab-explanation p { color: var(--muted); font-size: 12px; line-height: 1.55; }
.lab-filters, .journal-heading { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; margin: 16px 0; }
.lab-filters label, .journal-heading label { display: flex; align-items: center; gap: 7px; font-size: 12px; color: var(--muted); }
.lab-panel input[type="date"], .lab-panel select { color-scheme: dark; background: #0c1928; color: var(--text); border: 1px solid var(--line); border-radius: 6px; padding: 7px; font: inherit; }
.lab-note { color: var(--muted); font-size: 11px; }
.table-scroll { overflow-x: auto; }
.lab-table { width: 100%; border-collapse: collapse; font-size: 12px; font-variant-numeric: tabular-nums; }
.lab-table th { color: var(--muted); font-size: 11px; font-weight: 650; white-space: nowrap; }
.lab-table td, .lab-table th { padding: 11px 7px; text-align: right; border-bottom: 1px solid var(--line-soft); }
.lab-table td:first-child, .lab-table th:first-child { text-align: left; width: 40%; min-width: 250px; }
.rule-toggle { display: flex; align-items: center; gap: 9px; cursor: pointer; }
.rule-toggle input { width: 20px; height: 20px; accent-color: var(--accent); flex-shrink: 0; }
.rule-description { color: #9baec3; font-size: 11px; line-height: 1.45; margin: 5px 0 5px 29px; }
.lab-table .positive { color: var(--accent); }
.lab-table .negative, .lab-error { color: var(--red); }
.lab-error { font-size: 12px; padding: 8px 0; }
.lab-explanation { padding: 13px 0; border-bottom: 1px solid var(--line); font-size: 12px; }
.lab-explanation summary { cursor: pointer; color: var(--blue); }
.journal-heading { font-size: 13px; }
#journal-count { color: var(--muted); font-size: 12px; margin-left: auto; }
.journal-entry { border: 1px solid var(--line-soft); border-radius: 7px; margin: 5px 0; background: #0c1928; font-size: 11px; }
.journal-entry summary { cursor: pointer; display: grid; grid-template-columns: 128px minmax(160px,1fr) 152px 155px; gap: 10px; align-items: center; padding: 10px; }
.journal-match small { display: block; color: var(--muted); margin-top: 4px; }
.journal-time { color: var(--muted); }
.journal-entry.win .journal-result { color: var(--accent); }
.journal-entry.loss .journal-result { color: var(--red); }
.journal-entry.pending .journal-result { color: var(--amber); }
.journal-detail { border-top: 1px solid var(--line-soft); padding: 8px 12px; }
.evidence-grid { display: flex; flex-wrap: wrap; gap: 12px; color: var(--muted); }
.evidence-grid b { color: var(--text); }
.journal-pages { display: flex; justify-content: space-between; margin-top: 12px; }
button:disabled { opacity: .45; cursor: default; }
.divergence-badge.conflict { color: var(--muted); border-color: var(--muted); }
@media (max-width: 760px) {
  .tabs { gap: 0; }
  .tab { padding-inline: 8px; font-size: 11px; }
  .lab-panel { padding: 10px; }
  .journal-entry summary { grid-template-columns: 1fr 1fr; }
  .lab-table { min-width: 720px; }
}

.match-card.paper-under .match-summary { box-shadow: inset 3px 0 var(--blue); background: linear-gradient(90deg, rgba(100,168,255,.13), var(--panel) 38%); }
.match-card.paper-over .match-summary { box-shadow: inset 3px 0 var(--amber); background: linear-gradient(90deg, rgba(255,198,91,.13), var(--panel) 38%); }
.match-card.paper-conflict .match-summary { box-shadow: inset 3px 0 var(--muted); background: var(--panel); }

/* League preferences do not change match row height. */
.league-controls { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin: 14px 0; }
.league-controls .search { width: min(100%, 320px); min-height: 36px; }
.league-button { min-height: 32px; padding: 0 11px; border: 1px solid var(--line); border-radius: 7px; background: #16263a; color: var(--text); font-size: 12px; font-weight: 700; }
.league-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; }
.league-option { display: flex; align-items: center; gap: 12px; padding: 11px; border: 1px solid var(--line); border-radius: 7px; background: #0c1928; cursor: pointer; min-width: 0; }
.league-option input { width: 21px; height: 21px; flex-shrink: 0; accent-color: var(--accent); }
.league-option span { min-width: 0; }
.league-option strong { display: block; font-size: 12px; overflow-wrap: anywhere; }
.league-option small { display: block; margin-top: 4px; font-size: 11px; color: var(--muted); }
.league-option.disabled { background: #091420; color: var(--muted); }
.league-list .state-message { grid-column: 1 / -1; }
#lab-league-filter { max-width: 290px; }
@media (max-width: 760px) {
  .control-strip { flex-wrap: wrap; }
  .tabs { max-width: 100%; overflow-x: auto; flex-shrink: 1; }
  .tab { white-space: nowrap; }
  .league-list { grid-template-columns: minmax(0, 1fr); }
}

.matrix-note { margin-top: 6px; color: var(--muted); font-size: 9px; line-height: 1.25; }
