:root {
  --bg: #ffffff; --card: #f3f4f6; --text: #111827; --hint: #6b7280; --line: #e5e7eb; --accent: #2481cc; --accent-text: #fff;
  --up: #089981; --down: #f23645; --amber: #d97706; --grey: #9ca3af;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --bg: #17212b; --card: #232e3c; --text: #f5f5f5; --hint: #8b9aa9; --line: #2f3b4a; --accent: #5ea6e8; }
}
:root[data-theme="dark"] { --bg: #17212b; --card: #232e3c; --text: #f5f5f5; --hint: #8b9aa9; --line: #2f3b4a; --accent: #5ea6e8; }

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
body { max-width: 760px; margin: 0 auto; padding: 0 12px 28px; overflow-x: hidden; }
a { color: var(--accent); text-decoration: none; }
header { display: flex; justify-content: space-between; align-items: center; padding: 10px 2px 6px; }
header #brand { color: var(--hint); font-size: 13px; }
body.in-tg header { display: none; }
body.in-tg { padding-top: 8px; }
.loading, .err { color: var(--hint); padding: 40px 0; text-align: center; }

h1 { font-size: 19px; margin: 4px 0 2px; }
h2 { font-size: 15px; margin: 22px 0 8px; color: var(--hint); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.sub { color: var(--hint); font-size: 13px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.chip { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--card); color: var(--hint); white-space: nowrap; }
.chip.up { background: color-mix(in srgb, var(--up) 18%, transparent); color: var(--up); }
.chip.down { background: color-mix(in srgb, var(--down) 18%, transparent); color: var(--down); }
.chip.amber { background: color-mix(in srgb, var(--amber) 20%, transparent); color: var(--amber); }
.chip.blue { background: color-mix(in srgb, var(--accent) 18%, transparent); color: var(--accent); }

.tabs { display: flex; gap: 6px; margin: 10px 0 6px; }
.tabs button { flex: 1; border: 0; padding: 7px 0; border-radius: 8px; background: var(--card); color: var(--text); font: inherit; font-size: 14px; cursor: pointer; }
.tabs button.on { background: var(--accent); color: var(--accent-text); font-weight: 600; }

.chart-wrap { position: relative; height: 56vh; min-height: 300px; max-height: 520px; margin: 0 -4px; }
.chart-wrap .chart { position: absolute; inset: 0; }
.overlay { position: absolute; left: 0; top: 0; overflow: hidden; pointer-events: none; z-index: 2; }
.ov-box { position: absolute; border: 1px solid; border-radius: 1px; }
.live { font-size: 13px; color: var(--hint); margin: 4px 0 0; display: flex; justify-content: space-between; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12px; color: var(--hint); margin: 6px 0; }
.legend i { display: inline-block; width: 14px; height: 0; border-top: 2px solid; vertical-align: middle; margin-right: 5px; }
.legend i.box { height: 10px; border: 1px solid; }

.card { background: var(--card); border-radius: 12px; padding: 12px 14px; margin: 10px 0; }
.card p { margin: 3px 0; }
.result { font-weight: 600; }
.btns { display: flex; gap: 8px; flex-wrap: wrap; margin: 10px 0; }
.btn { flex: 1; min-width: 140px; text-align: center; border: 0; padding: 10px 12px; border-radius: 10px; background: var(--accent); color: var(--accent-text); font: inherit; font-weight: 600; cursor: pointer; }
.btn.ghost { background: var(--card); color: var(--text); }
.shot { width: 100%; border-radius: 10px; margin-top: 8px; display: none; }
.shot.on { display: block; }

.pairs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.pair { background: var(--card); border-radius: 10px; padding: 8px 10px; cursor: pointer; }
.pair b { display: block; font-size: 14px; }
.pair span { font-size: 13px; display: block; white-space: nowrap; }

.list { display: flex; flex-direction: column; }
.item { display: flex; justify-content: space-between; gap: 10px; padding: 10px 2px; border-bottom: 1px solid var(--line); cursor: pointer; }
.item:last-child { border-bottom: 0; }
.item .l { min-width: 0; }
.item .l b { font-size: 14px; }
.item .l div { font-size: 13px; color: var(--hint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .r { text-align: right; font-size: 13px; white-space: nowrap; display: flex; flex-direction: column; align-items: flex-end; gap: 3px; }
.swatch { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 6px; vertical-align: middle; }

table.score { width: 100%; border-collapse: collapse; font-size: 13px; }
table.score th, table.score td { padding: 7px 4px; border-bottom: 1px solid var(--line); text-align: right; }
table.score th:first-child, table.score td:first-child { text-align: left; }
table.score th { color: var(--hint); font-weight: 600; }
.bar { display: flex; height: 6px; border-radius: 3px; overflow: hidden; margin-top: 4px; background: var(--line); }
.bar span { display: block; height: 100%; }
.note { font-size: 12px; color: var(--hint); margin-top: 6px; }
.empty { color: var(--hint); font-size: 14px; padding: 6px 2px; }
.up { color: var(--up); } .down { color: var(--down); }
