:root {
  --bg: #f3f5f2;
  --surface: #ffffff;
  --surface-2: #eef2ee;
  --border: #d9e0da;
  --text: #121a15;
  --text-2: #4a564e;
  --muted: #6f7b73;
  --accent: #0a8a3a;
  --accent-ink: #ffffff;
  --accent-soft: #dff3e6;
  --frames: #1f5fbf;
  --gold: #a66d00;
  --gold-soft: #fff1cf;
  --bad: #c0302b;
  --bad-soft: #fde5e3;
  --warn: #b26a00;
  --schedule: #8a948d;
  --shadow: 0 1px 2px rgba(0,0,0,.05), 0 4px 16px rgba(0,0,0,.05);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0a120d;
    --surface: #121d16;
    --surface-2: #19271e;
    --border: #25362b;
    --text: #edf3ee;
    --text-2: #b6c3ba;
    --muted: #8c9a90;
    --accent: #3fd77a;
    --accent-ink: #062611;
    --accent-soft: #163a24;
    --frames: #6ea8ff;
    --gold: #f3c14b;
    --gold-soft: #3a2e10;
    --bad: #ff7a72;
    --bad-soft: #3d1715;
    --warn: #f3a640;
    --schedule: #7d8a81;
    --shadow: none;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0a120d; --surface: #121d16; --surface-2: #19271e; --border: #25362b; --text: #edf3ee; --text-2: #b6c3ba;
  --muted: #8c9a90; --accent: #3fd77a; --accent-ink: #062611; --accent-soft: #163a24; --frames: #6ea8ff; --gold: #f3c14b;
  --gold-soft: #3a2e10; --bad: #ff7a72; --bad-soft: #3d1715; --warn: #f3a640; --schedule: #7d8a81; --shadow: none; color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
.wrap { max-width: 1240px; margin: 0 auto; padding: 0 16px; }
h1, h2, h3 { margin: 0; }
button, input, select { font: inherit; color: inherit; }
.num, .big-money, .big-clock, .big-num, td.n, .mini-stats dd { font-variant-numeric: tabular-nums; }

/* header */
.top { background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 5; }
.top-inner { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-top: 10px; padding-bottom: 10px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand h1 { font-size: 20px; line-height: 1.2; }
.sub { margin: 2px 0 0; color: var(--text-2); font-size: 13px; }
.ball8 { flex: none; width: 38px; height: 38px; border-radius: 50%; background: radial-gradient(circle at 50% 50%, #fff 0 9px, #111 10px); display: grid; place-items: center; color: #111; font-weight: 800; font-size: 12px; box-shadow: inset -4px -4px 8px rgba(255,255,255,.15), 0 0 0 1px var(--border); }
.top-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.btn { border: 1px solid var(--border); background: var(--surface-2); padding: 8px 14px; border-radius: 10px; cursor: pointer; text-decoration: none; color: var(--text); font-weight: 600; white-space: nowrap; }
.btn:hover { filter: brightness(1.05); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-donate, .btn-primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn-ghost { background: transparent; }
.btn-bad { background: var(--bad-soft); color: var(--bad); border-color: transparent; }
.btn-sm { padding: 4px 10px; font-size: 13px; border-radius: 8px; }
.badge { padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; background: var(--surface-2); color: var(--text-2); }
.badge.live { background: var(--bad); color: #fff; }
.badge.live::before { content: "● "; animation: blink 1.2s infinite; }
.badge.done { background: var(--accent); color: var(--accent-ink); }
@keyframes blink { 50% { opacity: .2; } }

main { padding-top: 16px; padding-bottom: 40px; display: flex; flex-direction: column; gap: 16px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 18px; box-shadow: var(--shadow); min-width: 0; }
.label { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-2); font-weight: 700; }
.section-title { font-size: 17px; margin-bottom: 12px; }
.meta { color: var(--text-2); font-size: 14px; margin-top: 6px; }
.hint { color: var(--muted); font-size: 12.5px; margin: 10px 0 0; }

.error-bar { background: var(--bad-soft); color: var(--bad); border-radius: 12px; padding: 10px 14px; font-weight: 600; }

/* hero */
.hero { display: grid; grid-template-columns: 1.15fr 1fr 1.1fr; gap: 16px; }
.hero > .card { container-type: inline-size; }
.big-money { font-size: clamp(34px, 16cqi, 84px); font-weight: 800; color: var(--accent); line-height: 1.05; margin-top: 6px; letter-spacing: -.02em; }
.big-clock { font-size: clamp(32px, 17cqi, 76px); font-weight: 800; line-height: 1.05; margin-top: 6px; letter-spacing: -.01em; }
.big-clock.over { color: var(--bad); }
.frames-line { display: flex; align-items: baseline; gap: 8px; margin-top: 6px; }
.big-num { font-size: clamp(44px, 7vw, 72px); font-weight: 800; line-height: 1.05; color: var(--frames); }
.of { font-size: 24px; color: var(--text-2); font-weight: 700; }
.progress { position: relative; height: 10px; border-radius: 999px; background: var(--surface-2); margin-top: 12px; overflow: visible; }
.progress-bar { height: 100%; border-radius: 999px; background: var(--accent); width: 0; transition: width .6s ease; max-width: 100%; }
.progress-bar.alt { background: var(--frames); }
.schedule-mark { position: absolute; top: -4px; width: 3px; height: 18px; border-radius: 2px; background: var(--text); left: 0; display: none; }
.mini-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 16px; margin: 14px 0 0; }
.mini-stats div { min-width: 0; }
.mini-stats dt { font-size: 12px; color: var(--muted); }
.mini-stats dd { margin: 0; font-weight: 700; font-size: 16px; }
.good { color: var(--accent); }
.warnc { color: var(--warn); }
.badc { color: var(--bad); }

/* current frame */
.current-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.frame-timer { font-size: 32px; font-weight: 800; font-variant-numeric: tabular-nums; }
.versus { display: grid; grid-template-columns: 1fr auto 1fr; gap: 12px; align-items: stretch; margin-top: 14px; }
.side { background: var(--surface-2); border-radius: 14px; padding: 12px; min-width: 0; }
.side h3 { font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; margin-bottom: 6px; }
.vs { align-self: center; font-weight: 800; color: var(--muted); }
.pl { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 6px 0; border-top: 1px solid var(--border); }
.pl:first-of-type { border-top: 0; }
.pl-name { font-weight: 700; font-size: 18px; overflow-wrap: anywhere; }
.pl-name .brk { font-size: 11px; font-weight: 700; color: var(--accent-ink); background: var(--accent); border-radius: 6px; padding: 1px 5px; margin-left: 6px; vertical-align: middle; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.chip { font-size: 13px; padding: 2px 8px; border-radius: 999px; background: var(--surface); border: 1px solid var(--border); white-space: nowrap; font-variant-numeric: tabular-nums; }
.chip.f { color: var(--bad); }
.idle { color: var(--text-2); font-size: 16px; margin: 8px 0 0; }

/* scorer */
.scorer { border: 2px solid var(--accent); }
.scorer h2 { margin-bottom: 10px; }
.scorer-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.seg button { border: 0; background: transparent; padding: 8px 14px; cursor: pointer; font-weight: 600; }
.seg button.on { background: var(--accent); color: var(--accent-ink); }
.field { display: flex; flex-direction: column; gap: 4px; margin-top: 10px; min-width: 0; }
.field > span { font-size: 12px; color: var(--muted); font-weight: 600; }
select, input[type=text], input[type=number], input[type=datetime-local], input[type=url], input[type=password] {
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 9px 10px; width: 100%; min-width: 0;
}
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.row > * { flex: 1 1 140px; }
.row > .btn { flex: 0 0 auto; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.pad { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 10px; }
.pad-player { background: var(--surface-2); border-radius: 14px; padding: 12px; }
.pad-player .who { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.pad-player .who b { font-size: 18px; }
.pad-player .who small { color: var(--muted); }
.pad-btns { display: grid; grid-template-columns: 2fr 1fr; gap: 6px; margin-top: 8px; }
.pad-btns .pot { grid-row: span 2; font-size: 20px; padding: 16px 8px; }
.pot-count { display: block; font-size: 12px; font-weight: 600; opacity: .85; margin-top: 2px; }
.pad-btns3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-top: 6px; }
.pad .btn { padding: 10px 6px; }
.end-box { margin-top: 14px; padding-top: 14px; border-top: 1px dashed var(--border); }
.radio-list { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.radio-list label { display: inline-flex; gap: 6px; align-items: center; background: var(--surface-2); border: 1px solid var(--border); padding: 6px 10px; border-radius: 10px; cursor: pointer; }
details.settings { margin-top: 16px; border-top: 1px solid var(--border); padding-top: 12px; }
details.settings summary { cursor: pointer; font-weight: 700; }
.toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-weight: 600; z-index: 20; max-width: calc(100% - 32px); }

/* tables */
.grid-2 { display: grid; grid-template-columns: 1.4fr 1fr; gap: 16px; align-items: start; }
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: right; font-size: 12px; color: var(--muted); font-weight: 700; padding: 6px 8px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { text-align: right; padding: 8px; border-bottom: 1px solid var(--border); white-space: nowrap; font-variant-numeric: tabular-nums; }
.table th:first-child, .table td:first-child { text-align: left; }
.table td.name { font-weight: 700; }
.table tr.top1 td.name::after { content: " 👑"; }
.history td.l, .history th.l { text-align: left; white-space: normal; min-width: 160px; }
.win { font-weight: 700; }
.tag { font-size: 11px; padding: 1px 6px; border-radius: 6px; background: var(--surface-2); color: var(--text-2); font-weight: 700; margin-left: 4px; }
.tag.gold { background: var(--gold-soft); color: var(--gold); }
.tag.bad { background: var(--bad-soft); color: var(--bad); }

/* awards & stats */
.awards { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; }
.award { background: var(--surface-2); border-radius: 12px; padding: 10px 12px; }
.award .ico { font-size: 22px; }
.award .t { font-size: 12px; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.award .w { font-weight: 800; font-size: 17px; overflow-wrap: anywhere; }
.award .v { font-size: 13px; color: var(--text-2); }
.fun-stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; }
.stat { background: var(--surface-2); border-radius: 12px; padding: 10px 12px; }
.stat .v { font-size: 26px; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1.15; }
.stat .t { font-size: 12.5px; color: var(--text-2); }
.empty { color: var(--muted); font-size: 14px; }

.feed { list-style: none; padding: 0; margin: 0; max-height: 380px; overflow-y: auto; }
.feed li { padding: 8px 0; border-bottom: 1px solid var(--border); display: flex; gap: 10px; }
.feed time { color: var(--muted); font-size: 12.5px; flex: none; width: 42px; padding-top: 2px; font-variant-numeric: tabular-nums; }
.feed li.end span { font-weight: 700; }

/* chart */
.chart-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 4px; }
.legend { font-size: 13px; color: var(--text-2); display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.key { display: inline-block; width: 18px; height: 0; border-top: 2px solid; margin-left: 6px; }
.key-actual { border-color: var(--frames); border-top-width: 3px; }
.key-sched { border-color: var(--schedule); border-top-style: dashed; }
.chart { position: relative; }
.chart svg { width: 100%; height: auto; display: block; }
.chart .tip { position: absolute; pointer-events: none; background: var(--text); color: var(--bg); font-size: 12.5px; padding: 6px 9px; border-radius: 8px; white-space: nowrap; transform: translate(-50%, -110%); }
.pairs-list, .fund-list { list-style: none; padding: 0; margin: 0 0 14px; }
.pairs-list li, .fund-list li { display: flex; justify-content: space-between; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--border); }
.subhead { font-size: 13px; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .05em; margin: 4px 0 6px; }

/* bar tab */
.pick-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.pick { border: 1px solid var(--border); background: var(--surface-2); padding: 8px 14px; border-radius: 999px; cursor: pointer; font-weight: 600; }
.pick.on { background: var(--gold); color: #1a1300; border-color: transparent; }
.drink-btns { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 8px; margin-top: 10px; }
.drink-btn { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 12px 8px; white-space: normal; text-align: center; }
.drink-btn .drink-ico { font-size: 26px; line-height: 1; }
.drink-btn small { color: var(--text-2); font-weight: 500; font-size: 12px; }
.bar-table td.l, .bar-table th.l { text-align: left; }
.bar-table tr.top-drinker td.name::after { content: " 🍻"; }
.units-cell { display: flex; align-items: center; gap: 8px; min-width: 170px; }
.units-track { flex: 1; height: 10px; background: var(--surface-2); border-radius: 0 4px 4px 0; overflow: hidden; }
.units-bar { display: block; height: 100%; background: var(--gold); border-radius: 0 4px 4px 0; }
.bar-stats { margin-top: 14px; }
.drink-cfg input { width: 90px; padding: 6px 8px; }

/* donation banner */
.don-banner { display: flex; align-items: center; gap: 12px; background: var(--accent-soft); border: 1px solid var(--accent); border-radius: 14px; padding: 12px 14px; min-height: 64px; }
.don-banner[hidden] { display: none; }
.don-banner.has-new { animation: donpulse 1.2s ease 3; }
@keyframes donpulse { 50% { box-shadow: 0 0 0 6px color-mix(in srgb, var(--accent) 35%, transparent); } }
.don-heart { font-size: 24px; flex: none; }
.don-main { flex: 1; min-width: 0; }
.don-item { animation: donin .5s ease; }
@keyframes donin { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.don-line { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 8px; }
.don-new { background: var(--bad); color: #fff; font-size: 12px; font-weight: 800; letter-spacing: .08em; padding: 2px 8px; border-radius: 6px; align-self: center; }
.don-amount { font-size: 22px; font-weight: 800; color: var(--accent); font-variant-numeric: tabular-nums; }
.don-from { font-size: 17px; font-weight: 700; overflow-wrap: anywhere; }
.don-meta { font-size: 13px; color: var(--text-2); }
.don-msg { margin-top: 3px; font-style: italic; color: var(--text); overflow-wrap: anywhere; }
@media (prefers-reduced-motion: reduce) { .don-item, .don-banner.has-new { animation: none; } }
@media (max-width: 620px) { .don-banner { flex-wrap: wrap; } .don-banner .btn { margin-left: auto; } }

/* rotating panel */
.rotator { padding-top: 10px; }
.rot-bar { display: flex; align-items: center; gap: 8px; }
.rot-tabs { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; flex: 1; min-width: 0; padding: 2px; }
.rot-tabs::-webkit-scrollbar { display: none; }
.rot-tab { flex: none; border: 0; background: transparent; color: var(--text-2); font-weight: 600; font-size: 13.5px; padding: 7px 12px; border-radius: 999px; cursor: pointer; white-space: nowrap; }
.rot-tab:hover { background: var(--surface-2); }
.rot-tab[aria-selected="true"] { background: var(--accent); color: var(--accent-ink); }
.rot-progress { height: 3px; border-radius: 2px; background: var(--surface-2); margin: 8px 0 16px; overflow: hidden; }
.rot-progress > div { height: 100%; width: 0; background: var(--accent); }
.rotator.is-paused .rot-progress > div { background: var(--muted); }
.slide { min-height: 360px; }
.slide:not([hidden]) { animation: slidein .45s ease; }
@keyframes slidein { from { opacity: 0; transform: translateX(14px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .slide:not([hidden]) { animation: none; } }
.grid-2.inner { gap: 24px; }
.slide .feed { max-height: 420px; }
.slide .history { font-size: 14px; }

.foot {color: var(--muted); font-size: 12.5px; display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }

.dlg { border: 1px solid var(--border); border-radius: 16px; background: var(--surface); color: var(--text); padding: 18px; width: min(520px, calc(100% - 32px)); }
.dlg::backdrop { background: rgba(0,0,0,.45); }
.dlg table input { width: 64px; padding: 6px; }

@media (max-width: 980px) {
  .hero { grid-template-columns: 1fr 1fr; }
  .hero-money { grid-column: 1 / -1; }
  .grid-2 { grid-template-columns: 1fr; }
}
@media (max-width: 620px) {
  .hero { grid-template-columns: 1fr; }
  .scorer-grid { grid-template-columns: 1fr; }
  .versus { grid-template-columns: 1fr; }
  .vs { text-align: center; }
  .brand h1 { font-size: 17px; }
  .card { padding: 14px; }
}
.foot .disclaimer { flex-basis: 100%; }
