:root {
  --bg: #17241e;            /* dark court-green page in both themes, so the cards stand out */
  --bg-glow: #2a4a3a;
  --surface: #ffffff;
  --surface-2: #f1f4ef;
  --surface-3: #e8ede6;
  --ink: #142019;
  --ink-2: #47534b;
  --muted: #7b867f;
  --line: #e1e6df;
  --accent: #17603f;        /* court green */
  --accent-ink: #ffffff;
  --ball: #d8e83a;          /* tennis-ball yellow */
  --ball-ink: #1b2410;
  --pa: #2563c9;            /* player A identity (also the win-probability line) */
  --pb: #e0761d;            /* player B identity */
  --eq: #17603f;            /* bankroll curve */
  --good: #1b8a47;
  --bad: #d23f3f;
  --warn: #b26a00;
  --price: #edf2fb;
  --price-ink: #15366b;
  --price-hot: #15366b;
  --price-hot-ink: #ffffff;
  --head-1: #0c1f17;
  --head-2: #15392a;
  --radius: 12px;
  --edge: rgba(255, 255, 255, 0);
  --shadow: 0 1px 2px rgba(0, 0, 0, .25), 0 14px 32px -16px rgba(0, 0, 0, .6);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #060908; --bg-glow: #12241b; --surface: #151d19; --surface-2: #1d2722; --surface-3: #26322c; --ink: #e8eee9;
    --ink-2: #b6c2ba; --muted: #8a978f; --line: #2a3530; --accent: #3fae78; --accent-ink: #07130c; --pa: #6e9ff5;
    --pb: #f29a4a; --eq: #4cc28a; --good: #55c987; --bad: #f07a7a; --warn: #e3b14d; --price: #1c2a3e; --price-ink: #c4d8fb;
    --price-hot: #c4d8fb; --price-hot-ink: #0d1a2e; --edge: rgba(255, 255, 255, .07);
    --shadow: 0 1px 0 rgba(255, 255, 255, .04) inset, 0 16px 34px -16px rgba(0, 0, 0, .9);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #060908; --bg-glow: #12241b; --surface: #151d19; --surface-2: #1d2722; --surface-3: #26322c; --ink: #e8eee9;
  --ink-2: #b6c2ba; --muted: #8a978f; --line: #2a3530; --accent: #3fae78; --accent-ink: #07130c; --pa: #6e9ff5;
  --pb: #f29a4a; --eq: #4cc28a; --good: #55c987; --bad: #f07a7a; --warn: #e3b14d; --price: #1c2a3e; --price-ink: #c4d8fb;
  --price-hot: #c4d8fb; --price-hot-ink: #0d1a2e; --edge: rgba(255, 255, 255, .07);
  --shadow: 0 1px 0 rgba(255, 255, 255, .04) inset, 0 16px 34px -16px rgba(0, 0, 0, .9);
  color-scheme: dark;
}

* { box-sizing: border-box; }
body { margin: 0; color: var(--ink); font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: radial-gradient(1200px 500px at 30% -10%, var(--bg-glow), transparent 70%), var(--bg); background-attachment: fixed; min-height: 100vh; }
button, input, select { font: inherit; color: inherit; }
h3 { margin: 0; font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-2); font-weight: 800; display: flex; align-items: center; gap: 8px; }
h3::before { content: ""; width: 3px; height: 12px; border-radius: 2px; background: var(--accent); }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.num { font-variant-numeric: tabular-nums; }
.pos { color: var(--good); } .neg { color: var(--bad); }

/* header */
.top { display: flex; flex-wrap: wrap; gap: 10px 28px; align-items: center; padding: 10px 24px; position: sticky; top: env(safe-area-inset-top, 0px); z-index: 5;
  background: linear-gradient(90deg, var(--head-1), var(--head-2)); color: #eef5ef; box-shadow: 0 2px 12px rgba(0, 0, 0, .18); border-bottom: 1px solid rgba(255, 255, 255, .08); }
.brand { font-weight: 800; letter-spacing: .02em; font-size: 16px; display: flex; align-items: center; }
.brand::before { content: ""; width: 14px; height: 14px; border-radius: 50%; margin-right: 10px;
  background: radial-gradient(circle at 35% 30%, #f2fa8c, var(--ball) 55%, #a9b81f); box-shadow: 0 0 12px rgba(216, 232, 58, .45); }
.bank { display: flex; align-items: baseline; gap: 10px; background: rgba(255, 255, 255, .08); border: 1px solid rgba(255, 255, 255, .12);
  padding: 4px 14px; border-radius: 999px; }
.bank .lbl { color: rgba(238, 245, 239, .65); font-size: 12px; text-transform: uppercase; letter-spacing: .08em; }
.bank strong { font-size: 19px; }
.top .pnl { font-weight: 700; font-size: 13px; }
.top .pnl.pos { color: #7fe0a6; } .top .pnl.neg { color: #ff9b9b; } .top .pnl.muted { color: rgba(238, 245, 239, .6); }
.top-actions { margin-left: auto; display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.toggle { display: flex; gap: 6px; align-items: center; cursor: pointer; color: rgba(238, 245, 239, .85); }
.toggle input { accent-color: var(--ball); }
.top select { background: rgba(255, 255, 255, .1); border: 1px solid rgba(255, 255, 255, .2); color: #eef5ef; border-radius: 8px; padding: 5px 8px; }
.top select option { color: #142019; }

/* layout */
.layout { display: grid; grid-template-columns: minmax(0, 1fr) 370px; gap: 18px; padding: 18px 24px 36px; max-width: 1380px; margin: 0 auto; align-items: start; }
.main-col, .side-col, .stack { display: flex; flex-direction: column; gap: 18px; min-width: 0; }
.two { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 18px; align-items: start; }
@media (max-width: 1180px) { .two { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 900px) {
  .layout { grid-template-columns: minmax(0, 1fr); padding: 12px 16px 24px; gap: 14px; }
  .main-col, .side-col, .stack { gap: 14px; }
  .top { padding: 10px 16px; }
}
.card { background: var(--surface); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); border: 1px solid var(--edge); }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 12px; }
.card > h3 { margin-bottom: 12px; }

/* ---- match card: broadcast scoreboard, coloured by surface ---- */
.match { --hero-1: #1d4e89; --hero-2: #10325f; position: relative; overflow: hidden; color: #fff; border: 0;
  background: linear-gradient(135deg, var(--hero-1), var(--hero-2)); padding: 18px 22px; }
.match[data-surface="clay"] { --hero-1: #b9562b; --hero-2: #81361a; }
.match[data-surface="grass"] { --hero-1: #2f7136; --hero-2: #1a4720; }
.match[data-surface="indoor"] { --hero-1: #3a3f6c; --hero-2: #22254a; }
.match::before { content: ""; position: absolute; pointer-events: none; }
.match::before { inset: 12px; border: 2px solid rgba(255, 255, 255, .07); border-radius: 4px; }          /* court outline */
.match > * { position: relative; z-index: 1; }
.match { --pa: #8db7ff; --pb: #ffb36b; }
.info { display: flex; flex-wrap: wrap; gap: 4px 8px; color: rgba(255, 255, 255, .72); font-size: 13px; margin-bottom: 12px; }
.info span:not(:last-child)::after { content: "·"; margin-left: 8px; opacity: .6; }
.info b { color: #fff; }
.score { width: 100%; border-collapse: separate; border-spacing: 0; font-variant-numeric: tabular-nums;
  background: rgba(0, 0, 0, .22); border-radius: 10px; overflow: hidden; }
.score td { padding: 10px 6px; text-align: center; width: 46px; font-size: 20px; }
.score tr + tr td { border-top: 1px solid rgba(255, 255, 255, .1); }
.score td.name { text-align: left; width: auto; font-weight: 700; font-size: 18px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 0; padding-left: 0; }
.score td.name .rank { font-weight: 400; color: rgba(255, 255, 255, .6); margin-left: 8px; font-size: 13px; }
.score .pbar { display: inline-block; width: 4px; height: 26px; vertical-align: middle; margin-right: 12px; border-radius: 0 3px 3px 0; }
.pbar.a, .pdot.a { background: var(--pa); } .pbar.b, .pdot.b { background: var(--pb); }
.score td.set { color: rgba(255, 255, 255, .55); }
.score td.set.won { color: #fff; font-weight: 800; }
.score td.set sup { font-size: 10px; color: rgba(255, 255, 255, .6); font-weight: 400; }
.score td.cur { font-weight: 800; color: #fff; background: rgba(255, 255, 255, .08); }
.score td.pts { font-weight: 900; color: var(--ball-ink); background: var(--ball); width: 58px; }
.score td.prob { width: 72px; color: rgba(255, 255, 255, .8); font-size: 13px; text-align: right; padding-right: 14px; }
.score .srv { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 10px; visibility: hidden; vertical-align: middle;
  background: var(--ball); box-shadow: 0 0 8px rgba(216, 232, 58, .8); }
.score .srv.on { visibility: visible; }
.score tr.winner td.name::after { content: "✓"; color: var(--ball); margin-left: 8px; }
.status { margin: 10px 0 0; color: rgba(255, 255, 255, .8); font-size: 13px; }
.status .tag { display: inline-block; padding: 2px 10px; border-radius: 999px; background: rgba(255, 255, 255, .12); margin-right: 6px; font-weight: 700; font-size: 12px; }
.status .tag.hot { background: var(--ball); color: var(--ball-ink); animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 4px rgba(216, 232, 58, .25); } }
.controls { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 14px; padding-top: 14px; border-top: 1px solid rgba(255, 255, 255, .14); }

button { background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; padding: 6px 12px; cursor: pointer; transition: background .12s, border-color .12s, transform .08s; }
button:hover:not(:disabled) { border-color: var(--muted); }
button:active:not(:disabled) { transform: translateY(1px); }
button:disabled { opacity: .45; cursor: default; }
button.link { background: none; border: 0; padding: 0; color: var(--muted); text-decoration: underline; font-size: 12px; }
.match button { background: rgba(255, 255, 255, .1); border-color: rgba(255, 255, 255, .18); color: #fff; }
.match button:hover:not(:disabled) { background: rgba(255, 255, 255, .18); border-color: rgba(255, 255, 255, .35); }
.match button.primary { background: var(--ball); color: var(--ball-ink); border-color: var(--ball); font-weight: 800; padding: 7px 16px; }
.match button.primary:hover { background: #e6f35a; }
.seg { display: inline-flex; }
.seg button { border-radius: 0; margin-left: -1px; }
.seg button:first-child { border-radius: 8px 0 0 8px; margin-left: 0; }
.seg button:last-child { border-radius: 0 8px 8px 0; }
.match .seg button.on { background: #fff; color: #142019; border-color: #fff; font-weight: 700; }

/* charts */
.chart { position: relative; height: 170px; }
.chart svg, .equity svg { width: 100%; height: 100%; display: block; overflow: visible; }
.equity { position: relative; margin-bottom: 12px; }
.equity svg { height: 90px; margin-bottom: 4px; }
.grid { stroke: var(--line); stroke-width: 1; }
.mid { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 3 3; }
.setline { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 1 3; }
.axis { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.line { fill: none; stroke: var(--pa); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.line.eq { stroke: var(--eq); }
.area { fill: var(--pa); opacity: .09; }
.dot { fill: var(--pa); stroke: var(--surface); stroke-width: 2; }
.dot.eq { fill: var(--eq); }
.cross { stroke: var(--ink-2); stroke-width: 1; }
.tip { position: absolute; pointer-events: none; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 6px 9px;
  font-size: 12px; box-shadow: 0 6px 18px rgba(0, 0, 0, .16); white-space: nowrap; color: var(--ink); z-index: 2; }
.empty { color: var(--muted); font-size: 13px; }

/* player comparison */
.tape { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; font-size: 13px; }
.tape th { font-size: 13px; color: var(--ink); font-weight: 800; padding: 0 0 8px; }
.tape th.l { text-align: left; } .tape th.r { text-align: right; }
.pdot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin: 0 8px; vertical-align: 1px; }
.tape th.l .pdot { margin-left: 0; } .tape th.r .pdot { margin-right: 0; }
.tape td { padding: 6px 0; border-top: 1px solid var(--line); }
.tape td.l { text-align: left; width: 28%; }
.tape td.r { text-align: right; width: 28%; }
.tape td.k { text-align: center; color: var(--muted); font-size: 12px; }
.tape td.best { font-weight: 800; color: var(--ink); }
.tape td:not(.k):not(.best) { color: var(--ink-2); }
.cmp { display: flex; gap: 2px; height: 3px; max-width: 140px; margin: 4px auto 0; border-radius: 2px; overflow: hidden; }
.cmp .a { background: var(--pa); } .cmp .b { background: var(--pb); }
.form { display: inline-flex; gap: 2px; }
.form i { width: 15px; height: 15px; border-radius: 4px; font-style: normal; font-size: 9px; font-weight: 800; display: inline-flex; align-items: center; justify-content: center; color: #fff; }
.form i.w { background: var(--good); }
.form i.l { background: var(--bad); }
.form i.last { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--ink-2); margin-left: 3px; }

/* head to head */
.h2h-bar { display: flex; height: 10px; border-radius: 5px; overflow: hidden; background: var(--surface-2); margin-bottom: 10px; gap: 2px; }
.h2h-bar .a { background: var(--pa); } .h2h-bar .b { background: var(--pb); }
#h2hTotal { font-weight: 700; }
.meets { list-style: none; margin: 0; padding: 0; font-size: 13px; }
.meets li { display: grid; grid-template-columns: auto 1fr auto; gap: 10px; padding: 6px 0; border-top: 1px solid var(--line); align-items: baseline; }
.meets .who { font-weight: 800; font-size: 11px; padding: 1px 7px; border-radius: 999px; color: #fff; }
.meets .who.a { background: var(--pa); } .meets .who.b { background: var(--pb); }
.meets .sc { font-variant-numeric: tabular-nums; font-weight: 600; }
.meets .ctx { color: var(--muted); font-size: 12px; text-align: right; }

/* feed */
.feed { list-style: none; margin: 0; padding: 0; max-height: 240px; overflow: auto; font-size: 13px; }
.feed li { padding: 5px 0; border-top: 1px solid var(--line); display: flex; gap: 10px; }
.feed li:first-child { border-top: 0; }
.feed .when { color: var(--muted); min-width: 60px; font-variant-numeric: tabular-nums; }
.feed .brk { color: var(--warn); font-weight: 700; }
.feed .setev { font-weight: 800; }

/* bet slip */
.slip { padding: 0; overflow: hidden; }
.stake { display: grid; grid-template-columns: auto 1fr; gap: 10px 12px; align-items: center; padding: 16px 18px;
  background: linear-gradient(135deg, var(--head-2), var(--head-1)); color: #eef5ef; }
.stake label { font-weight: 800; font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: rgba(238, 245, 239, .75); }
.stake-input input { width: 100%; font-size: 20px; font-weight: 800; padding: 6px 12px; border-radius: 10px; border: 2px solid transparent;
  background: #fff; color: #142019; font-variant-numeric: tabular-nums; }
.stake-input input:focus { outline: none; border-color: var(--ball); }
.stake-input input.bad { border-color: #ff7b7b; }
.chips { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(6, 1fr); gap: 5px; }
.chips button { padding: 5px 0; font-size: 13px; font-weight: 700; background: rgba(255, 255, 255, .1); border-color: rgba(255, 255, 255, .16); color: #eef5ef; border-radius: 999px; }
.chips button:hover:not(:disabled) { background: rgba(255, 255, 255, .2); border-color: rgba(255, 255, 255, .35); }
.chips button.on { background: var(--ball); color: var(--ball-ink); border-color: var(--ball); }
.stake-hint { grid-column: 1 / -1; color: #ffb0b0; font-size: 12px; }
.stake-hint:empty { display: none; }
#markets { padding: 4px 18px 16px; }
.market { padding: 12px 0; border-bottom: 1px solid var(--line); }
.market:last-child { border-bottom: 0; padding-bottom: 0; }
.market .mhead { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; }
.market .row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.price { display: grid; grid-template-columns: 1fr auto; align-items: center; background: var(--price); color: var(--price-ink);
  border: 1px solid color-mix(in srgb, var(--price-ink) 28%, transparent); box-shadow: 0 1px 2px rgba(16, 28, 21, .08);
  border-radius: 10px; padding: 8px 12px; text-align: left; gap: 0 6px; }
.price:hover:not(:disabled) { background: var(--price-hot); color: var(--price-hot-ink); border-color: var(--price-hot); box-shadow: 0 6px 14px -8px rgba(21, 54, 107, .7); }
.price:hover:not(:disabled) .sel, .price:hover:not(:disabled) .imp { color: inherit; opacity: .8; }
.price .sel { font-size: 12px; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.price .odds { font-size: 18px; font-weight: 900; font-variant-numeric: tabular-nums; grid-row: span 2; }
.price .imp { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.price.up { animation: flash-up .9s ease-out; } .price.up .odds { color: var(--good); }
.price.down { animation: flash-down .9s ease-out; } .price.down .odds { color: var(--bad); }
@keyframes flash-up { from { box-shadow: inset 0 0 0 2px var(--good); } }
@keyframes flash-down { from { box-shadow: inset 0 0 0 2px var(--bad); } }
.closed { color: var(--muted); font-size: 13px; padding-top: 12px; }

/* bets */
.bets { display: flex; flex-direction: column; gap: 6px; font-size: 13px; }
.bet { display: grid; grid-template-columns: 1fr auto; gap: 2px 8px; padding: 9px 12px; border-radius: 10px; background: var(--surface-2); border-left: 3px solid var(--price-ink); }
.bet .what { font-weight: 700; }
.bet .meta { color: var(--muted); font-size: 12px; }
.bet .res { text-align: right; font-weight: 800; font-variant-numeric: tabular-nums; }
.bet button { grid-column: 2; padding: 3px 10px; font-size: 12px; font-weight: 700; background: var(--ball); color: var(--ball-ink); border-color: var(--ball); }
.bet.won { border-left-color: var(--good); } .bet.won .res { color: var(--good); }
.bet.lost { border-left-color: var(--bad); opacity: .8; } .bet.lost .res { color: var(--bad); }
.bet.push, .bet.cashed { border-left-color: var(--muted); }

/* bankroll KPIs */
.kpis { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.kpi { background: var(--surface-2); padding: 8px 11px; border-radius: 9px; }
.kpi .k { font-size: 11px; color: var(--muted); }
.kpi .v { font-size: 16px; font-weight: 800; font-variant-numeric: tabular-nums; }

/* result overlay */
.result { position: fixed; inset: 0; background: rgba(5, 12, 9, .55); backdrop-filter: blur(3px); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 20; }
.result[hidden] { display: none; }
.result .panel { background: var(--surface); border-radius: 16px; padding: 22px 24px; max-width: 470px; width: 100%; box-shadow: 0 20px 50px rgba(0, 0, 0, .35); border-top: 6px solid var(--ball); }
.result h2 { margin: 0 0 4px; font-size: 21px; }
.result .big { font-size: 32px; font-weight: 900; font-variant-numeric: tabular-nums; margin: 12px 0; }
.result .actions { display: flex; gap: 8px; margin-top: 18px; }
.result button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 800; }

/* header buttons */
.hbtn { background: rgba(255, 255, 255, .1); border: 1px solid rgba(255, 255, 255, .2); color: #eef5ef; border-radius: 8px; padding: 5px 12px; font-weight: 600; }
.hbtn:hover:not(:disabled) { background: rgba(255, 255, 255, .18); border-color: rgba(255, 255, 255, .35); }
.hbtn.armed { background: #c43a3a; border-color: #c43a3a; color: #fff; }
.small-btn { padding: 3px 10px; font-size: 12px; font-weight: 700; background: var(--accent); color: var(--accent-ink); border-color: var(--accent); border-radius: 999px; }

/* orders */
.orders { display: flex; flex-direction: column; gap: 8px; }
.order { display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: start; padding: 10px 12px; border-radius: 10px;
  background: var(--surface-2); border: 1px solid transparent; }
.order.armed { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 7%, var(--surface)); }
.o-name { font-weight: 800; font-size: 13px; }
.o-desc { font-size: 12px; color: var(--ink-2); margin-top: 2px; }
.o-status { font-size: 11px; color: var(--muted); margin-top: 4px; text-transform: uppercase; letter-spacing: .05em; font-weight: 700; }
.order.armed .o-status { color: var(--accent); }
.o-act { display: flex; flex-direction: column; gap: 4px; }
.o-act button { padding: 2px 10px; font-size: 12px; }
.switch { position: relative; width: 34px; height: 20px; margin-top: 2px; cursor: pointer; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch span { position: absolute; inset: 0; background: var(--surface-3); border: 1px solid var(--line); border-radius: 999px; transition: background .15s; }
.switch span::after { content: ""; position: absolute; width: 14px; height: 14px; left: 2px; top: 2px; border-radius: 50%; background: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .25); transition: transform .15s; }
.switch input:checked + span { background: var(--accent); border-color: var(--accent); }
.switch input:checked + span::after { transform: translateX(14px); }
.switch input:focus-visible + span { outline: 2px solid var(--price-ink); outline-offset: 2px; }
.otag { color: var(--accent); font-weight: 700; }
.feed .ord { color: var(--accent); font-weight: 600; }

/* modal (builder, leaderboard) */
.result .panel.wide { max-width: 820px; max-height: 92vh; overflow: auto; }
.m-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.m-head h2 { margin: 0; font-size: 20px; }
.x { background: none; border: 0; font-size: 16px; color: var(--muted); padding: 4px 8px; }
.fields { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
@media (max-width: 600px) { .fields { grid-template-columns: 1fr; } }
.fields label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; font-weight: 700; color: var(--ink-2); }
.panel input, .panel select { background: var(--surface); border: 1.5px solid var(--line); border-radius: 8px; padding: 5px 8px; color: var(--ink); }
.panel input:focus, .panel select:focus { outline: none; border-color: var(--accent); }
.sentence { font-size: 16px; line-height: 2.4; background: var(--surface-2); border-radius: 12px; padding: 10px 16px; margin-bottom: 8px; }
.sentence select, .sentence input { font-weight: 700; font-size: 15px; }
.sentence .w3 { width: 56px; } .sentence .w4 { width: 70px; } .sentence .w5 { width: 84px; } .sentence .w6 { width: 96px; }
.err { color: var(--bad); font-weight: 600; margin-top: 12px; }
button.danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 40%, transparent); }
.bt { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); }
.bt-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; }
.kpis.five { grid-template-columns: repeat(5, 1fr); }
@media (max-width: 700px) { .kpis.five { grid-template-columns: 1fr 1fr; } }

/* leaderboard */
.lb-wrap { overflow-x: auto; }
.lb { width: 100%; border-collapse: collapse; font-size: 13px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.lb th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 0 8px 8px; }
.lb td { padding: 8px; border-top: 1px solid var(--line); }
.lb .n { text-align: right; }
.lb .rk { font-weight: 900; color: var(--muted); width: 28px; }
.lb tr:nth-child(1) .rk { color: #c9a227; } .lb tr:nth-child(2) .rk { color: #9aa3ab; } .lb tr:nth-child(3) .rk { color: #b07642; }
.lb tr.cur td { background: color-mix(in srgb, var(--ball) 18%, var(--surface)); }
.pill { display: inline-block; font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; padding: 1px 7px;
  border-radius: 999px; background: var(--ball); color: var(--ball-ink); margin-left: 4px; vertical-align: 1px; }
.pill.bad { background: var(--bad); color: #fff; }

/* shared leaderboard & share card */
.lb-top { display: flex; justify-content: space-between; align-items: end; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.lb-top .muted { max-width: 460px; }
.nick { display: flex; flex-direction: column; gap: 4px; font-size: 12px; font-weight: 700; color: var(--ink-2); }
.nick input { width: 200px; }
.lb td.who { font-weight: 700; max-width: 180px; overflow: hidden; text-overflow: ellipsis; }
.lb tr.mine td.who { color: var(--accent); }
.card-btn { padding: 2px 10px; font-size: 12px; font-weight: 700; background: var(--ball); color: var(--ball-ink); border-color: var(--ball); border-radius: 999px; }
.card-img { display: block; width: 100%; height: auto; border-radius: 12px; box-shadow: 0 10px 30px rgba(0, 0, 0, .25); margin-bottom: 4px; }
.actions .small { align-self: center; }

/* game modes */
.top .mode button { background: rgba(255, 255, 255, .08); border-color: rgba(255, 255, 255, .18); color: #eef5ef; padding: 4px 14px; font-weight: 700; }
.top .mode button.on { background: var(--ball); color: var(--ball-ink); border-color: var(--ball); }
.top .mode button:hover:not(:disabled):not(.on) { background: rgba(255, 255, 255, .16); }
.bank .prog { color: rgba(238, 245, 239, .65); font-size: 12px; border-left: 1px solid rgba(255, 255, 255, .18); padding-left: 10px; }
.lb-left { display: flex; flex-direction: column; gap: 8px; }
.seg.tabs button { padding: 5px 16px; font-weight: 700; }
.seg.tabs button.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.order input:disabled + span { opacity: .5; cursor: default; }

/* two-player win probability chart */
.line.b { stroke: var(--pb); }
.dot.b { fill: var(--pb); }
#chartNow { display: flex; gap: 14px; flex-wrap: wrap; justify-content: flex-end; color: var(--ink-2); font-size: 13px; }
#chartNow .lg { white-space: nowrap; }
#chartNow .pdot { margin: 0 6px 0 0; }

/* difficulty */
.top select.diff { font-weight: 700; }
.lb-tabrow { display: flex; gap: 10px; flex-wrap: wrap; }
.seg.tabs.sub button { padding: 5px 12px; font-weight: 600; }
.seg.tabs.sub button.on { background: var(--ink-2); color: var(--surface); border-color: var(--ink-2); }
.nick-msg { font-weight: 600; font-size: 11px; color: var(--muted); min-height: 14px; }
.nick-msg.bad { color: var(--bad); }

/* leaderboard views, your runs */
.seg.tabs.views button { padding: 6px 16px; font-weight: 800; font-size: 15px; }
.seg.tabs.views button.on { background: var(--ink); color: var(--surface); border-color: var(--ink); }
.lb td.acts { text-align: right; white-space: nowrap; }
.lb td.acts button + button { margin-left: 6px; }
.lb td.acts button { padding: 2px 10px; font-size: 12px; font-weight: 700; border-radius: 999px; }
.lb-tabrow[hidden] { display: none; }

/* tutorial */
.result .panel.tut { max-width: 640px; }
.t-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.tut h2 { margin: 0 0 6px; font-size: 24px; }
.t-text { margin: 0 0 14px; color: var(--ink-2); font-size: 14.5px; }
.t-widget { background: var(--surface-2); border-radius: 14px; padding: 16px; min-height: 210px; }
.t-nav { display: flex; justify-content: space-between; align-items: center; margin-top: 16px; }
.t-nav .actions { margin: 0; }
.t-dots { display: flex; gap: 6px; }
.t-dot { width: 9px; height: 9px; padding: 0; border-radius: 50%; background: var(--line); border: 0; }
.t-dot.on { background: var(--accent); width: 22px; border-radius: 5px; }
.t-chip { display: inline-block; padding: 3px 11px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); font-weight: 700; font-size: 12.5px; margin-left: 5px; }
.t-chip.on { background: var(--ball); color: var(--ball-ink); border-color: var(--ball); }
.t-price { display: inline-flex; flex-direction: column; min-width: 84px; padding: 5px 11px; border-radius: 9px; background: var(--price); color: var(--price-ink); margin-left: 6px; vertical-align: middle; }
.t-price small { font-size: 11px; color: var(--ink-2); }
.t-price b { font-size: 17px; font-variant-numeric: tabular-nums; }
.t-price.hot { background: var(--price-hot); color: var(--price-hot-ink); }
.t-price.hot small { color: inherit; opacity: .8; }
.t-board { --pa: #8db7ff; --pb: #ffb36b; background: linear-gradient(135deg, #1d4e89, #10325f); color: #fff; border-radius: 10px; padding: 6px 12px; margin-bottom: 12px; }
.t-row { display: flex; align-items: center; gap: 0; padding: 5px 0; font-weight: 700; font-variant-numeric: tabular-nums; }
.t-row + .t-row { border-top: 1px solid rgba(255, 255, 255, .12); }
.t-row .pbar { display: inline-block; width: 4px; height: 18px; border-radius: 2px; margin-right: 10px; }
.t-set { margin-left: auto; width: 30px; text-align: center; }
.t-set + .t-set { margin-left: 0; }
.t-pts { width: 40px; text-align: center; background: var(--ball); color: var(--ball-ink); border-radius: 5px; font-weight: 900; margin-left: 6px; }
.t-flow { display: flex; flex-direction: column; gap: 9px; font-size: 13.5px; }
.t-flow > div { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 0; }
.t-n { display: inline-flex; width: 22px; height: 22px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); font-weight: 800; font-size: 12px; align-items: center; justify-content: center; margin-right: 9px; }
.t-modes, .t-diffs { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.t-diffs { grid-template-columns: repeat(3, 1fr); }
.t-mode, .t-diff { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }
.t-mode.pro { border-color: var(--accent); }
.t-mh { font-weight: 900; font-size: 15px; margin-bottom: 4px; }
.t-big { font-size: 36px; font-weight: 900; line-height: 1; color: var(--accent); }
.t-mode ul { margin: 10px 0 0; padding-left: 18px; font-size: 13px; color: var(--ink-2); }
.t-mode li + li { margin-top: 4px; }
.t-coin { display: flex; margin: 6px 0 8px -6px; }
.t-coin .t-price { min-width: 0; flex: 1; }
.t-diff .small { color: var(--ink-2); }
.t-diff.fair .t-mh { color: var(--good); } .t-diff.hard .t-mh { color: var(--bad); }
.t-lb { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; margin-bottom: 14px; }
.t-lbrow { display: flex; align-items: center; gap: 10px; padding: 9px 14px; font-weight: 700; font-size: 14px; }
.t-lbrow + .t-lbrow { border-top: 1px solid var(--line); }
.t-lbrow b { margin-left: auto; font-variant-numeric: tabular-nums; }
.t-lbrow.me { background: color-mix(in srgb, var(--ball) 18%, var(--surface)); }
.t-rk { color: var(--muted); font-weight: 900; width: 14px; }
.t-steps { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; color: var(--muted); }
.t-steps .t-chip { margin: 0; }
@media (max-width: 600px) { .t-modes, .t-diffs { grid-template-columns: 1fr; } .t-widget { min-height: 0; } }

/* buttons in result panels and dialogs: secondary actions read as buttons too */
.result .actions { flex-wrap: wrap; }
.result .actions button { padding: 8px 16px; font-weight: 700; border-radius: 10px; }
.result .actions button:not(.primary):not(.danger) { background: var(--surface); color: var(--accent); border: 1.5px solid var(--accent); }
.result .actions button:not(.primary):not(.danger):hover:not(:disabled) { background: color-mix(in srgb, var(--accent) 12%, var(--surface)); border-color: var(--accent); }
.result .actions button.primary:hover:not(:disabled) { filter: brightness(1.1); }
.result .actions button.primary:disabled { opacity: 1; background: color-mix(in srgb, var(--good) 16%, var(--surface)); color: var(--good); border-color: var(--good); }
.result .panel:not(.wide) { max-width: 560px; }

/* breaks on the win-probability chart */
.brk { stroke: var(--surface); stroke-width: 2; stroke-linejoin: round; }
.brk.a { fill: var(--pa); } .brk.b { fill: var(--pb); }
#chartNow .dia { display: inline-block; width: 8px; height: 8px; background: var(--ink-2); transform: rotate(45deg); margin-right: 7px; vertical-align: 1px; }

/* difficulty tag on the leaderboard */
.lvl { display: inline-block; font-size: 11px; font-weight: 800; padding: 1px 8px; border-radius: 999px; border: 1.5px solid currentColor; }
.lvl.fair { color: var(--good); } .lvl.medium { color: var(--warn); } .lvl.hard { color: var(--bad); }

/* name dialog before submitting */
.nick.big { font-size: 13px; }
.nick.big input { width: 100%; font-size: 17px; font-weight: 700; padding: 8px 12px; }
#lbScope:empty { display: none; }

/* New run: next to the bankroll, the main header action */
.run-btn { background: transparent; color: var(--ball); border: 1.5px solid var(--ball); border-radius: 999px; padding: 5px 16px; font-weight: 800; margin-left: -16px; }
.run-btn:hover:not(:disabled) { background: var(--ball); color: var(--ball-ink); border-color: var(--ball); }
.run-btn.armed { background: #c43a3a; border-color: #c43a3a; color: #fff; }

/* ===== fewer colours: blue/orange = players, yellow = action, green/red = profit and loss, the rest neutral ===== */
:root[data-theme="light"], :root:not([data-theme]) {
  --price: #f3f5f2; --price-ink: #142019; --price-hot: #142019; --price-hot-ink: #ffffff;
}
:root[data-theme="dark"] {
  --price: #1f2925; --price-ink: #e8eee9; --price-hot: #e8eee9; --price-hot-ink: #0d1612;
}
.match, .match[data-surface] { --hero-1: #1f4033; --hero-2: #12271f; }
h3::before { display: none; }
h3 { gap: 0; }
.lvl, .lvl.fair, .lvl.medium, .lvl.hard { color: var(--ink-2); border-color: var(--line); background: var(--surface-2); }
.t-diff.fair .t-mh, .t-diff.hard .t-mh { color: var(--ink); }
.price:hover:not(:disabled) { box-shadow: 0 6px 14px -8px rgba(0, 0, 0, .45); }

/* header: icons, Pro coming soon */
.hbtn { display: inline-flex; align-items: center; gap: 6px; }
.hbtn .ic, .ic { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.hbtn .ic { display: none; }
.hbtn.icon-only { padding: 5px 8px; }
.hbtn.icon-only .ic { display: block; }
.soon { font-size: 9px; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; padding: 1px 5px; border-radius: 999px;
  background: rgba(255, 255, 255, .14); margin-left: 3px; vertical-align: 1px; }
.top .mode button:disabled { opacity: .55; }
.t-mode.soon { opacity: .6; }
.t-mode .soon { background: var(--surface-2); color: var(--ink-2); }

/* market tabs (before the match) */
.mtabs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; padding: 12px 18px 0; }
.mtabs[hidden] { display: none; }
.mtabs button { padding: 7px 0; font-weight: 800; font-size: 13px; border-radius: 9px; background: var(--surface-2); border: 1px solid var(--line); color: var(--ink-2); }
.mtabs button.on { background: var(--ink); color: var(--surface); border-color: var(--ink); }

/* controls */
.skips { display: contents; }

/* run recap */
.recap { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 14px; }
.rc { background: var(--surface-2); border-radius: 10px; padding: 9px 12px; min-width: 0; }
.rc .k { font-size: 11px; color: var(--muted); font-weight: 700; }
.rc .v { font-size: 18px; font-weight: 900; font-variant-numeric: tabular-nums; }
.rc .d { font-size: 12px; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ===== phones ===== */
@media (max-width: 700px) {
  body { font-size: 14px; }
  .top { position: static; padding: 8px 12px; gap: 8px; }
  .brand { order: 1; font-size: 15px; flex: 1 0 auto; }
  .brand::before { width: 12px; height: 12px; margin-right: 8px; }
  .run-btn { order: 2; margin-left: 0; padding: 4px 12px; }
  .bank { order: 3; flex: 1 1 100%; justify-content: center; padding: 3px 12px; }
  .bank .lbl { display: none; }
  .mode { order: 4; }
  .top select.diff { order: 5; }
  .top-actions { order: 6; margin-left: auto; gap: 6px; }
  .hbtn { padding: 5px 8px; }
  .hbtn .tx { display: none; }
  .hbtn .ic { display: block; }
  .top .mode button { padding: 4px 10px; }

  .layout { display: flex; flex-direction: column; padding: 10px 10px 24px; gap: 10px; }
  .main-col, .side-col, .two, .stack { display: contents; }
  #matchCard { order: 1; } .slip { order: 2; } .c-bets { order: 3; } .c-chart { order: 4; } .c-orders { order: 5; }
  .c-tape { order: 6; } .c-h2h { order: 7; } .c-feed { order: 8; } .c-bank { order: 9; }
  .card { padding: 13px 14px; border-radius: 12px; }
  .match { padding: 14px 14px; }
  .match::before { inset: 8px; }
  .score td { padding: 8px 3px; font-size: 17px; width: 34px; }
  .score td.name { font-size: 15px; }
  .score td.name .rank { display: none; }
  .score td.pts { width: 44px; }
  .score td.prob { width: 46px; font-size: 12px; padding-right: 8px; }
  .score .srv { margin-right: 6px; }
  .score .pbar { margin-right: 8px; }
  .controls { gap: 6px; }
  .controls > button, .seg button { padding: 6px 10px; }
  .skips { display: flex; gap: 6px; width: 100%; }
  .skips button { flex: 1; padding: 6px 4px; }
  .stake { padding: 12px 14px; }
  .mtabs { padding: 10px 14px 0; }
  #markets { padding: 2px 14px 12px; }
  .price { padding: 9px 10px; }
  .price .odds { font-size: 19px; }
  .chart { height: 150px; }
  .kpis { grid-template-columns: 1fr 1fr; }
  .result { padding: 10px; align-items: flex-end; }
  .result .panel { padding: 18px 16px; border-radius: 16px; max-height: 88vh; overflow: auto; }
  .result .actions button { flex: 1 1 auto; }
  .lb-board th:nth-child(n+6):nth-child(-n+10), .lb-board td:nth-child(n+6):nth-child(-n+10) { display: none; }
  .lb .pill { display: none; }
  .lb td.who { max-width: 110px; }
  .lb-mine th:nth-child(2), .lb-mine td:nth-child(2), .lb-mine th:nth-child(n+5):nth-child(-n+6), .lb-mine td:nth-child(n+5):nth-child(-n+6) { display: none; }
  .lb td, .lb th { padding-left: 5px; padding-right: 5px; }
  .tut h2 { font-size: 20px; }
  .layout { align-items: stretch; }
  .top select.diff { order: 5; }
  .form i:nth-child(-n+5) { display: none; }       /* phones: the latest 5 results */
  .form i { width: 16px; height: 16px; }
  .tape td.l, .tape td.r { width: 30%; }
  .tape td.k { font-size: 11px; padding: 6px 4px; }
}
.equity:empty { display: none; }

.top select.diff:disabled { opacity: .55; }
.run-btn[hidden] { display: none; }
.t-price { border: 1px solid color-mix(in srgb, var(--price-ink) 28%, transparent); box-shadow: 0 1px 2px rgba(16, 28, 21, .08); }
.t-board { background: linear-gradient(135deg, #1f4033, #12271f); }

/* frames: every tile and box sitting on a card gets the same subtle edge, so nothing floats */
:root { --frame: color-mix(in srgb, var(--ink) 14%, transparent); }
.rc, .kpi, .bet, .order, .t-widget, .sentence, .t-lb, .t-mode, .t-diff { border: 1px solid var(--frame); }
.bet { border-left-width: 3px; }
.order.armed { border-color: var(--accent); }
.t-mode.pro { border-color: var(--frame); }
.equity svg { border: 1px solid var(--frame); border-radius: 10px; }

/* replay speed: play / fast-forward symbols */
#speeds button { display: inline-flex; align-items: center; justify-content: center; min-width: 46px; }
.spd { height: 11px; width: auto; fill: currentColor; }
#speeds button { min-height: 34px; padding: 6px 12px; } .spd { height: 12px; }

/* controls keep their places: one fixed slot for Start / Play / Pause, skip buttons always shown */
.go { display: inline-flex; width: 132px; }
.go button { width: 100%; justify-content: center; }
.go button[hidden] { display: none; }
.match .skips button:disabled { opacity: .35; }
@media (max-width: 700px) { .go { width: 118px; } }

/* feedback dialog */
.fb-text { width: 100%; box-sizing: border-box; background: var(--surface); color: var(--ink); border: 1.5px solid var(--line); border-radius: 10px;
  padding: 10px 12px; font: inherit; resize: vertical; }
.fb-text:focus { outline: none; border-color: var(--accent); }
.top .hbtn[hidden] { display: none; }

/* admin view */
.result .panel.admin { max-width: 980px; }
.adm { display: flex; flex-direction: column; gap: 14px; }
.adm-sec { border: 1px solid var(--frame); border-radius: 12px; padding: 12px 14px; }
.adm-sec h3 { margin-bottom: 10px; gap: 8px; }
.adm .stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 8px; }
.adm .stat { background: var(--surface-2); border: 1px solid var(--frame); border-radius: 10px; padding: 8px 11px; }
.adm .stat .k { font-size: 11px; color: var(--muted); font-weight: 700; }
.adm .stat .v { font-size: 20px; font-weight: 900; font-variant-numeric: tabular-nums; }
.adm-t { width: 100%; border-collapse: collapse; font-size: 13px; font-variant-numeric: tabular-nums; }
.adm-t th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); padding: 0 8px 6px; }
.adm-t td { padding: 7px 8px; border-top: 1px solid var(--line); }
.adm-t .n { text-align: right; }
.adm-t td.who { font-weight: 700; max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.adm-t td.acts { text-align: right; white-space: nowrap; }
.adm-t td.acts button { padding: 2px 10px; font-size: 12px; border-radius: 999px; }
.adm-t tr.off td { opacity: .45; }
.adm-t.funnel td { border-top: 0; padding: 4px 10px 8px 0; vertical-align: top; }
.adm-t.funnel td:first-child { font-weight: 800; width: 90px; }
.bars { position: relative; display: flex; align-items: flex-end; gap: 2px; height: 90px; border-bottom: 1px solid var(--line); }
.bars .bar { flex: 1; background: var(--accent); border-radius: 3px 3px 0 0; min-height: 2px; }
.bars .bar:hover { background: var(--ink-2); }
.bars-axis { display: flex; justify-content: space-between; margin-top: 4px; }
.fb-row { padding: 8px 0; border-top: 1px solid var(--line); }
.fb-row:first-of-type { border-top: 0; padding-top: 0; }
.fb-msg { white-space: pre-wrap; margin-top: 2px; }

/* head to head: winner + score on one line, the context underneath (long names and tournaments no longer squeeze the score) */
.meets li { grid-template-columns: auto 1fr; gap: 2px 10px; align-items: center; }
.meets .who { max-width: 130px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.meets .sc { white-space: nowrap; }
.meets .ctx { grid-column: 1 / -1; text-align: left; }

/* the line under the scoreboard keeps its height, so the buttons below never move; critical points sit on the
   player's row in the scoreboard instead */
.status { min-height: 22px; line-height: 22px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.score .ptag { display: inline-block; margin-left: 10px; padding: 1px 9px; border-radius: 999px; background: var(--ball); color: var(--ball-ink);
  font-size: 11px; font-weight: 800; letter-spacing: .02em; vertical-align: 2px; animation: pulse 1.4s ease-in-out infinite; }
@media (max-width: 700px) { .score .ptag { margin-left: 6px; padding: 1px 7px; font-size: 10px; } }
.status { height: 22px; }
.status .tag { line-height: 18px; vertical-align: middle; }
.score .ptag { line-height: 16px; vertical-align: middle; }
.controls button { min-height: 34px; box-sizing: border-box; } .match button.primary { padding-top: 6px; padding-bottom: 6px; }
