:root {
  --bg: #0e1016;
  --panel: #161a23;
  --panel-2: #1d2230;
  --ink: #eceff5;
  --muted: #8b93a6;
  --line: #2a3142;
  --red: #ff5b52;
  --red-soft: rgba(255, 91, 82, 0.14);
  --blue: #5b8cff;
  --blue-soft: rgba(91, 140, 255, 0.14);
  --gold: #f2c14e;
  --good: #3ecf8e;
  --bad: #ff6b61;
  --even: #a7adbb;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #f3f1ec; --panel: #ffffff; --panel-2: #f7f5f0; --ink: #1b1d22; --muted: #646a78; --line: #e0dbd0;
    --red: #cf3029; --red-soft: rgba(207, 48, 41, 0.1); --blue: #2856d6; --blue-soft: rgba(40, 86, 214, 0.1);
    --gold: #a8780a; --good: #18865a; --bad: #c4302b; --even: #6f7480;
  }
}
:root[data-theme="light"] {
  --bg: #f3f1ec; --panel: #ffffff; --panel-2: #f7f5f0; --ink: #1b1d22; --muted: #646a78; --line: #e0dbd0;
  --red: #cf3029; --red-soft: rgba(207, 48, 41, 0.1); --blue: #2856d6; --blue-soft: rgba(40, 86, 214, 0.1);
  --gold: #a8780a; --good: #18865a; --bad: #c4302b; --even: #6f7480;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
button { font: inherit; cursor: pointer; }
.num { font-variant-numeric: tabular-nums; }

/* Top bar */
.top { display: flex; align-items: center; gap: 12px; padding: 10px 16px; border-bottom: 1px solid var(--line); background: var(--panel); flex-wrap: wrap; }
.brand { font-weight: 800; letter-spacing: 0.02em; }
.brand span { color: var(--red); }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; border: 1px solid var(--line); font-size: 12px; color: var(--muted); }
.pill .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--good); }
.spacer { flex: 1; }
.wallet { font-weight: 700; }
.wallet small { color: var(--muted); font-weight: 500; }

/* Layout */
.layout { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 16px; padding: 16px; max-width: 1400px; margin: 0 auto; }
@media (max-width: 1000px) { .layout { grid-template-columns: 1fr; } }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; }
.card > header { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.card > header h2 { margin: 0; font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.card > .body { padding: 14px; }

/* Fight HUD */
.hud { display: grid; grid-template-columns: 1fr auto 1fr; gap: 14px; align-items: center; padding: 14px; }
.corner .name { font-weight: 800; font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.corner.c1 .name { color: var(--red); }
.corner.c2 { text-align: right; }
.corner.c2 .name { color: var(--blue); }
.stats { display: flex; gap: 4px; margin-top: 4px; flex-wrap: wrap; }
.corner.c2 .stats { justify-content: flex-end; }
.stat { font-size: 11px; color: var(--muted); border: 1px solid var(--line); border-radius: 6px; padding: 1px 6px; }
.hpbar { height: 10px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 6px; overflow: hidden; margin-top: 8px; }
.hpbar i { display: block; height: 100%; transition: width 0.25s ease; }
.c1 .hpbar i { background: var(--red); }
.c2 .hpbar i { background: var(--blue); margin-left: auto; }
.hptext { font-size: 12px; color: var(--muted); margin-top: 3px; }
.clock { text-align: center; min-width: 140px; }
.clock .round { font-size: 22px; font-weight: 800; }
.clock .phase { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.clock .timer { font-size: 13px; color: var(--gold); margin-top: 2px; min-height: 1.2em; }

/* The embedded Unity view */
.stage { position: relative; aspect-ratio: 16 / 9; background: #000; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); overflow: hidden; }
.stage iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.banner { position: absolute; left: 50%; top: 18%; transform: translate(-50%, 0) scale(0.9); padding: 10px 22px; border-radius: 10px;
  background: rgba(10, 12, 18, 0.82); border: 1px solid rgba(255, 255, 255, 0.15); color: #fff; font-weight: 900; font-size: 26px;
  letter-spacing: 0.06em; opacity: 0; pointer-events: none; transition: opacity 0.2s, transform 0.2s; white-space: nowrap; }
.banner.show { opacity: 1; transform: translate(-50%, 0) scale(1); }
.banner.gold { color: var(--gold); }
.banner small { display: block; font-size: 13px; font-weight: 600; letter-spacing: 0.02em; color: #c9cfdb; text-align: center; }
.stage .warn { position: absolute; right: 8px; bottom: 8px; font-size: 12px; color: var(--gold); background: rgba(0,0,0,0.6); padding: 3px 8px; border-radius: 6px; }

/* Round strip */
.rounds { display: grid; grid-template-columns: repeat(12, 1fr); gap: 4px; padding: 12px 14px; }
.rcell { border: 1px solid var(--line); border-radius: 6px; padding: 4px 0; text-align: center; font-size: 11px; color: var(--muted); background: var(--panel-2); }
.rcell b { display: block; font-size: 13px; color: var(--ink); }
.rcell.live { border-color: var(--gold); color: var(--gold); }
.rcell.c1 { background: var(--red-soft); border-color: var(--red); }
.rcell.c2 { background: var(--blue-soft); border-color: var(--blue); }
.rcell.even { border-color: var(--even); }
.rcell.void { opacity: 0.4; text-decoration: line-through; }

/* Scorecards */
.table-wrap { overflow-x: auto; }
table.cards { width: 100%; border-collapse: collapse; font-size: 12px; font-variant-numeric: tabular-nums; }
.cards th, .cards td { padding: 5px 6px; border-bottom: 1px solid var(--line); text-align: center; white-space: nowrap; }
.cards th:first-child, .cards td:first-child { text-align: left; }
.cards td .r { color: var(--red); } .cards td .b { color: var(--blue); }
.cards td.total { font-weight: 800; }
.cards .win { font-weight: 800; }
.verdict { padding: 10px 14px; font-size: 13px; border-top: 1px solid var(--line); }
.verdict:empty { display: none; }

/* Fairness */
.fair { font-size: 12px; color: var(--muted); padding: 10px 14px; display: grid; gap: 4px; word-break: break-all; }
.fair code { color: var(--ink); }
.ok { color: var(--good); } .bad { color: var(--bad); }

/* Bet slip */
.tabs { display: flex; gap: 4px; }
.tabs button { background: transparent; border: 1px solid var(--line); color: var(--muted); padding: 5px 10px; border-radius: 8px; font-size: 12px; }
.tabs button[aria-selected="true"] { color: var(--ink); border-color: var(--ink); }
.market { border: 1px solid var(--line); border-radius: 10px; padding: 10px; margin-bottom: 10px; background: var(--panel-2); }
.market h3 { margin: 0 0 6px; font-size: 13px; display: flex; justify-content: space-between; gap: 8px; }
.market h3 .state { font-size: 11px; color: var(--muted); font-weight: 500; }
.market h3 .state.open { color: var(--good); }
.outs { display: grid; grid-template-columns: repeat(var(--n, 2), 1fr); gap: 6px; }
.out { border: 1px solid var(--line); background: var(--panel); color: var(--ink); border-radius: 8px; padding: 6px; text-align: center; }
.out .lbl { font-weight: 700; font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.out .est { font-size: 11px; color: var(--muted); }
.out.c1 .lbl { color: var(--red); } .out.c2 .lbl { color: var(--blue); }
.out[aria-pressed="true"] { outline: 2px solid var(--gold); outline-offset: -1px; }
.out:disabled { opacity: 0.45; cursor: not-allowed; }
.out.won { border-color: var(--good); }
.pool { font-size: 11px; color: var(--muted); margin-top: 6px; }
.roundrow { display: grid; grid-template-columns: 26px 44px 1fr; align-items: center; gap: 6px; padding: 4px 0; border-bottom: 1px dashed var(--line); }
.roundrow:last-child { border-bottom: 0; }
.roundrow .outs { --n: 3; }
.roundrow .out { padding: 3px; }
.roundrow input { width: 16px; height: 16px; }
.slip { display: grid; gap: 8px; }
.slip label { font-size: 12px; color: var(--muted); }
.slip input[type="number"] { width: 100%; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel-2); color: var(--ink); font: inherit; }
.place { width: 100%; padding: 10px; border-radius: 8px; border: 0; background: var(--gold); color: #1b1d22; font-weight: 800; }
.place:disabled { opacity: 0.4; cursor: not-allowed; }
.msg { font-size: 12px; min-height: 1.2em; }
.msg.bad { color: var(--bad); } .msg.good { color: var(--good); }
.tickets { display: grid; gap: 6px; font-size: 12px; }
.ticket { display: flex; justify-content: space-between; gap: 8px; border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; }
.ticket .st { font-weight: 700; }
.ticket .st.won { color: var(--good); } .ticket .st.lost { color: var(--bad); } .ticket .st.refund { color: var(--muted); }
.note { font-size: 12px; color: var(--muted); }
.house { display: flex; justify-content: space-between; font-size: 12px; padding: 8px 10px; border-radius: 8px; background: var(--panel-2); border: 1px solid var(--line); }
.log { font-size: 12px; display: grid; gap: 4px; max-height: 220px; overflow: auto; }
.log div { border-left: 2px solid var(--line); padding-left: 8px; }
.champ { border: 1px dashed var(--line); border-radius: 10px; padding: 10px; font-size: 12px; color: var(--muted); }
.champ b { color: var(--gold); }
@media (prefers-reduced-motion: reduce) { .hpbar i, .banner { transition: none; } }
