/* Brand tokens (--bg, --tx, --mu, --card, --line, --acc, --acctx, --link, --disp, --body) come from the page. */
:root {
  --back: #a6d8ff; --back2: #cbe8ff; --lay: #fac9d1; --lay2: #fde3e7; --cell-tx: #0b1a2c;
  --ok: #1fa86b; --warn: #d99a1e; --bad: #d64545; --mono: 'JetBrains Mono', ui-monospace, Menlo, monospace;
  --r: 12px;
}
* { box-sizing: border-box; }
code, pre, .rawlist, .ladder, .badge, .tag { font-variant-ligatures: none; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--tx); font: 15px/1.5 var(--body); }
a { color: var(--link); }
code { font-family: var(--mono); font-size: .88em; background: color-mix(in srgb, var(--tx) 8%, transparent); padding: .1em .35em; border-radius: 5px; }
button { font: inherit; cursor: pointer; }
.muted { color: var(--mu); } .small { font-size: 13px; } .pad { padding: 14px; }
.wrap { max-width: 1440px; margin: 0 auto; padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right)); }

.top { position: sticky; top: 0; z-index: 5; background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.top-in { display: flex; align-items: center; gap: 14px; min-height: 58px; flex-wrap: wrap; }
.logo { font: 700 19px var(--disp); color: var(--tx); text-decoration: none; }
.tag { font: 600 11px var(--mono); letter-spacing: .12em; text-transform: uppercase; color: var(--acctx); background: var(--acc); padding: 3px 8px; border-radius: 6px; }
.conn { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; color: var(--mu); }
.conn i { width: 8px; height: 8px; border-radius: 50%; background: var(--warn); }
.conn.on i { background: var(--ok); box-shadow: 0 0 0 4px color-mix(in srgb, var(--ok) 25%, transparent); }
.conn.off i { background: var(--bad); }
.links { margin-left: auto; display: flex; gap: 16px; align-items: center; }
.links a { text-decoration: none; font-weight: 600; font-size: 14px; }
.links .cta { background: var(--acc); color: var(--acctx); padding: 8px 14px; border-radius: 999px; }

.intro { padding: 26px 0 8px; max-width: 78ch; }
.intro h1 { font: 700 clamp(26px, 3.4vw, 38px)/1.15 var(--disp); margin: 0 0 10px; text-wrap: balance; }
.intro p { margin: 0; color: var(--mu); }
.intro b { color: var(--tx); }

.grid { display: grid; grid-template-columns: 300px minmax(0, 1fr) 340px; gap: 16px; padding: 18px 0; align-items: start; }
@media (max-width: 1180px) { .grid { grid-template-columns: 280px minmax(0, 1fr); } .raw { grid-column: 1 / -1; } }
@media (max-width: 760px) { .grid { grid-template-columns: minmax(0, 1fr); } }
.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; min-width: 0; }
.ph { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 10px; }
.ph h2, .ph h3 { margin: 0; font: 700 17px var(--disp); }
.head-btns { display: flex; gap: 8px; flex-shrink: 0; }
.code-btn, .ghost { border: 1px solid var(--line); background: transparent; color: var(--tx); border-radius: 8px; padding: 5px 10px; font-size: 13px; font-weight: 600; }
.code-btn { border-color: color-mix(in srgb, var(--acc) 60%, var(--line)); color: var(--link); }
.code-btn::before { content: "</> "; font-family: var(--mono); font-size: 11px; }
.code-btn:hover, .ghost:hover { background: color-mix(in srgb, var(--tx) 7%, transparent); }

.list { position: sticky; top: 72px; max-height: calc(100vh - 88px); display: flex; flex-direction: column; }
@media (max-width: 760px) { .list { position: static; max-height: 420px; } }
.sports { display: flex; gap: 6px; margin-bottom: 8px; }
.sports button { flex: 1; border: 1px solid var(--line); background: transparent; color: var(--mu); border-radius: 8px; padding: 6px 4px; font-weight: 600; font-size: 13px; }
.sports button[aria-selected="true"] { background: var(--acc); border-color: var(--acc); color: var(--acctx); }
.filters { display: flex; justify-content: space-between; font-size: 13px; color: var(--mu); margin-bottom: 6px; }
.events { list-style: none; margin: 0 -6px; padding: 0; overflow-y: auto; }
.events li button { width: 100%; text-align: left; background: none; border: 0; color: var(--tx); padding: 9px 8px; border-radius: 8px; display: grid; gap: 2px; }
.events li button:hover { background: color-mix(in srgb, var(--tx) 6%, transparent); }
.events li button[aria-current="true"] { background: color-mix(in srgb, var(--acc) 16%, transparent); }
.events .n { font-weight: 600; font-size: 14px; line-height: 1.3; }
.events .s { font-size: 12px; color: var(--mu); display: flex; flex-wrap: wrap; gap: 2px 8px; align-items: center; }
.events .s > span { white-space: nowrap; }
.live { color: var(--ok); font-weight: 700; font-size: 11px; letter-spacing: .06em; }

.empty { padding: 50px 10px; text-align: center; }
.match-head { align-items: flex-start; }
.crumbs { font-size: 12px; color: var(--mu); text-transform: capitalize; }
#title { font: 700 22px/1.25 var(--disp); margin: 2px 0; }
.toolbar { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px; font-size: 13px; color: var(--mu); padding: 8px 0 12px; border-bottom: 1px solid var(--line); margin-bottom: 12px; }

.group-title { font: 700 12px var(--mono); letter-spacing: .1em; text-transform: uppercase; color: var(--mu); margin: 16px 0 8px; }
/* Markets drawn like our player sites: a header bar, one row per runner, odds on the
   right; a halted row gets SUSPENDED / BALL RUNNING written across its odds. */
.market { border: 1px solid var(--line); border-radius: 8px; margin-bottom: 10px; overflow: hidden; background: #fff; color: #1b1b1b; }
.mh { display: flex; align-items: baseline; gap: 8px; padding: 7px 10px; background: #2c3e50; color: #fff; }
.mh b { font-size: 14px; }
.mh .fmt { font: 500 11px var(--mono); opacity: .7; }
.mrow { display: flex; align-items: stretch; border-top: 1px solid #e2e5ea; min-height: 44px; }
.mrow .rn { flex: 1; min-width: 0; padding: 6px 10px; font-size: 14px; font-weight: 600; display: flex; align-items: center; color: #1b1b1b; }
.odds { position: relative; display: flex; gap: 2px; padding: 2px; flex-shrink: 0; }
.mhead { min-height: 0; border-top: 0; background: #f4f5f7; }
.mhead .rn { padding: 0; }
.c { width: 64px; display: flex; flex-direction: column; align-items: center; justify-content: center; border-radius: 3px; line-height: 1.1; }
.c b { font: 700 15px var(--mono); color: #1b1b1b; }
.c small { font: 500 10.5px var(--mono); color: #333; opacity: .8; }
.c.hd { height: auto; padding: 3px 0; background: none !important; font: 700 11px var(--body); color: #444; }
.c.back.l0 { background: #72bbef; } .c.back.l1 { background: #a6d8ff; } .c.back.l2 { background: #c9e7fd; }
.c.lay.l0 { background: #faa9ba; } .c.lay.l1 { background: #fac9d1; } .c.lay.l2 { background: #fde1e6; }
.c.blank b { color: #555; font-weight: 500; }
.c.flash { box-shadow: inset 0 0 0 2px #f5b800; }
.k-line .c, .k-range .c { width: 78px; }
.shut .odds::after {
  content: attr(data-title); position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  background: rgba(55, 54, 54, .84); color: #ff3b3b; font: 700 14px var(--body); letter-spacing: .04em; cursor: not-allowed;
}
@media (max-width: 640px) {
  /* Phones: the best back and lay only, as the player sites do. */
  .k-ladder .c.l1, .k-ladder .c.l2 { display: none; }
  .c { width: 60px; }
}

.settled-wrap { margin-top: 18px; border-top: 1px solid var(--line); padding-top: 12px; }
.settled { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.settled li { display: flex; justify-content: space-between; gap: 10px; align-items: center; padding: 8px 10px; border: 1px dashed var(--line); border-radius: 8px; font-size: 14px; }
.settled .res { font: 700 14px var(--mono); text-align: right; }
.hide-settled .settled-wrap { display: none; }

.raw { position: sticky; top: 72px; max-height: calc(100vh - 88px); display: flex; flex-direction: column; }
@media (max-width: 1180px) { .raw { position: static; max-height: 460px; } }
.rawlist { list-style: none; margin: 0; padding: 0; overflow-y: auto; font: 12px/1.45 var(--mono); display: grid; gap: 6px; }
.rawlist li { border-left: 3px solid var(--line); padding: 4px 8px; background: color-mix(in srgb, var(--tx) 3%, transparent); border-radius: 0 6px 6px 0; word-break: break-all; }
.rawlist .ty { font-weight: 700; color: var(--link); }
.rawlist .tm { color: var(--mu); float: right; }
.rawlist .dt { color: var(--mu); display: block; max-height: 4.4em; overflow: hidden; }
.rawlist li.k-snapshot { border-color: #7c5cff; } .rawlist li.k-market-update { border-color: #3d8bfd; }
.rawlist li.k-market-remove, .rawlist li.k-result { border-color: #f5b800; } .rawlist li.k-ready { border-color: var(--ok); }

.foot { padding: 4px 0 30px; }

dialog { width: min(920px, calc(100vw - 32px)); max-height: calc(100vh - 48px); border: 1px solid var(--line); border-radius: 14px; background: var(--card); color: var(--tx); padding: 18px; }
dialog::backdrop { background: rgba(0, 0, 0, .55); }
.dlg-head { display: flex; justify-content: space-between; align-items: center; }
.dlg-head h2 { margin: 0; font: 700 19px var(--disp); }
.tabs { display: flex; gap: 6px; margin: 10px 0; flex-wrap: wrap; }
.tabs button { border: 1px solid var(--line); background: transparent; color: var(--mu); border-radius: 8px; padding: 5px 12px; font-weight: 600; font-size: 13px; }
.tabs button[aria-selected="true"] { background: var(--acc); color: var(--acctx); border-color: var(--acc); }
.code-box { position: relative; }
.code-box pre { margin: 0; background: #0a0f1d; color: #dbe3ff; border-radius: 10px; padding: 16px; overflow: auto; max-height: 60vh; font: 12.5px/1.55 var(--mono); }
.code-box code { background: none; padding: 0; font-size: inherit; }
.copy { position: absolute; top: 8px; right: 8px; border: 1px solid #33406a; background: #141c33; color: #dbe3ff; border-radius: 7px; padding: 4px 10px; font-size: 12px; }

/* Status labels in the settled list. */
.badge { font: 700 10.5px var(--mono); letter-spacing: .06em; padding: 3px 7px; border-radius: 6px; white-space: nowrap; }
.b-SETTLED, .b-VOIDED, .b-CLOSED { background: color-mix(in srgb, var(--mu) 20%, transparent); color: var(--mu); }

/* Jumping to a match keeps its title clear of the sticky header. */
#match, .detail { scroll-margin-top: 120px; }

/* While the code pop-up is open the page behind it stays still: scrolling
   inside the pop-up never reaches the page. */
html.modal-open, html.modal-open body { overflow: hidden; }
dialog, .code-box pre { overscroll-behavior: contain; }

/* Results are hidden on the demo: a blurred stand-in, never the real value. */
.settled .hidden-res { filter: blur(6px); user-select: none; pointer-events: none; }
