/* ---------- Токены ---------- */
:root {
  --bg: #0e1a14;
  --bg2: #13241b;
  --card: #182d22;
  --card2: #1f3a2c;
  --line: #2b4a39;
  --text: #e8f0ea;
  --muted: #9bb3a4;
  --soft: #c9d8ce;
  --gold: #ffd54f;
  --gold-ink: #2a2000;
  --green: #5cc160;
  --red: #ef6461;
  --odd: #233f30;
  --odd-h: #2c5140;
  --link: #ffe082;
  --radius: 10px;
  --wrap: 1240px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 76px; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.6 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
main { flex: 1; }
a { color: var(--link); text-underline-offset: 2px; }
a:hover { color: #fff3c4; }
button { font: inherit; color: inherit; cursor: pointer; }
button:disabled { cursor: default; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
img, svg { max-width: 100%; }
.wrap { max-width: var(--wrap); margin: 0 auto; padding: 0 16px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--gold); color: var(--gold-ink); padding: 8px 14px; border-radius: 6px; z-index: 100; }
.skip:focus { left: 8px; }

/* ---------- Шапка и меню ---------- */
.site-header {
  position: sticky; top: 0; z-index: 40;
  background: rgba(14, 26, 20, 0.95);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--line);
}
.header-row { display: flex; align-items: center; gap: 20px; height: 60px; }
.logo { display: inline-flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; font-weight: 800; font-size: 17px; white-space: nowrap; }
.logo:hover { color: var(--text); }
.nav-desktop { margin-left: auto; }
.nav-desktop ul { display: flex; gap: 2px; list-style: none; margin: 0; padding: 0; }
.nav-desktop a { display: block; padding: 8px 11px; border-radius: 8px; color: var(--soft); text-decoration: none; font-size: 15px; font-weight: 600; white-space: nowrap; }
.nav-desktop a:hover { background: var(--card); color: var(--text); }
.nav-desktop a[aria-current="page"] { color: var(--gold); }
.burger { display: none; margin-left: auto; width: 44px; height: 44px; border: 1px solid var(--line); border-radius: 10px; background: transparent; padding: 11px 10px; flex-direction: column; justify-content: space-between; }
.burger span { display: block; height: 2px; background: var(--text); border-radius: 2px; transition: transform .2s, opacity .2s; }
.burger[aria-expanded="true"] span:nth-child(1) { transform: translateY(8px) rotate(45deg); }
.burger[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
.burger[aria-expanded="true"] span:nth-child(3) { transform: translateY(-8px) rotate(-45deg); }
.drawer { border-top: 1px solid var(--line); background: var(--bg); max-height: calc(100vh - 60px); overflow-y: auto; }
.drawer ul { list-style: none; margin: 0; padding: 8px 16px 16px; }
.drawer a { display: block; padding: 12px 4px; color: var(--text); text-decoration: none; font-weight: 600; border-bottom: 1px solid var(--line); }
.drawer a[aria-current="page"] { color: var(--gold); }
.drawer .minor a { font-weight: 400; color: var(--muted); font-size: 15px; }
@media (max-width: 1099px) {
  .nav-desktop { display: none; }
  .burger { display: flex; }
}
@media (min-width: 1100px) { .drawer { display: none; } }
body.menu-open { overflow: hidden; }

/* ---------- Футер ---------- */
.site-footer { border-top: 1px solid var(--line); margin-top: 48px; padding: 32px 0 24px; background: var(--bg2); font-size: 15px; }
.footer-cols { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 28px; }
.footer-cols ul { list-style: none; margin: 0; padding: 0; }
.footer-cols li { margin: 6px 0; }
.footer-cols a { color: var(--soft); text-decoration: none; }
.footer-cols a:hover { color: var(--text); text-decoration: underline; }
.foot-h { font-size: 13px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); margin: 0 0 8px; }
.foot-note { color: var(--muted); max-width: 420px; }
.copy { color: var(--muted); font-size: 13px; margin: 24px 0 0; padding-top: 16px; border-top: 1px solid var(--line); }
.age { display: inline-block; border: 2px solid var(--red); color: var(--red); border-radius: 50%; width: 30px; height: 30px; line-height: 26px; text-align: center; font-weight: 800; font-size: 11px; margin-right: 8px; }
@media (max-width: 760px) { .footer-cols { grid-template-columns: 1fr 1fr; } .footer-cols > div:first-child { grid-column: 1 / -1; } }

/* ---------- Текстовые страницы ---------- */
.crumbs ol { list-style: none; display: flex; flex-wrap: wrap; gap: 6px; margin: 18px 0 0; padding: 0; font-size: 14px; color: var(--muted); }
.crumbs li + li::before { content: "/"; margin-right: 6px; color: var(--line); }
.crumbs a { color: var(--muted); }
.prose { max-width: 820px; padding-bottom: 8px; }
.prose.wide { max-width: none; }
.home .prose { max-width: 860px; margin-top: 40px; }
.prose h1 { font-size: clamp(28px, 4.2vw, 40px); line-height: 1.2; margin: 18px 0 10px; }
.prose h2 { font-size: clamp(21px, 2.8vw, 27px); line-height: 1.3; margin: 36px 0 10px; }
.prose h3 { font-size: 19px; margin: 24px 0 8px; }
.prose p, .prose li { color: var(--soft); }
.prose li { margin: 6px 0; }
.lead { font-size: 18px; color: var(--soft); margin: 0 0 8px; }
.meta { color: var(--muted); font-size: 14px; }
.formula { font-family: ui-monospace, "SFMono-Regular", Consolas, monospace; background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; color: var(--text); overflow-x: auto; }
.example { background: var(--card); border-left: 3px solid var(--gold); border-radius: 0 8px 8px 0; padding: 10px 14px; }
.steps { padding-left: 22px; }
.notice { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; }
.figure { margin: 16px 0; }
.figure figcaption { color: var(--muted); font-size: 14px; margin-top: 6px; }
.cycle { width: 100%; height: auto; display: block; }
.cycle text { fill: #102016; font: 700 15px system-ui, sans-serif; }
.cycle .c-note { fill: var(--muted); font-weight: 500; font-size: 13px; }
.cycle .c-bet { fill: #66bb6a; }
.cycle .c-race { fill: var(--gold); }
.cycle .c-res { fill: #90caf9; }
.cycle .c-tick { stroke: var(--muted); stroke-width: 2; }
.sources { font-size: 15px; }
.faq-item h2 { font-size: 20px; margin: 28px 0 6px; }

table.data { border-collapse: collapse; width: 100%; font-size: 15px; margin: 8px 0 12px; }
table.data th, table.data td { padding: 9px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
table.data thead th { color: var(--muted); font-size: 13px; text-transform: uppercase; letter-spacing: .4px; border-bottom: 2px solid var(--line); white-space: nowrap; }
table.data tbody th { color: var(--text); font-weight: 600; }
table.data td.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.data small { color: var(--muted); }
.tbl-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.empty { color: var(--muted); text-align: center; padding: 24px 8px; }
.more { text-align: center; margin: 14px 0 0; }
.hint { color: var(--muted); font-size: 14px; margin: 6px 0 10px; }

.results-tbl .rr-place { white-space: nowrap; }
.results-tbl .rr-id { font-weight: 700; white-space: nowrap; }
.results-tbl .rr-time { color: var(--muted); white-space: nowrap; }
.lb-block h2 { margin-top: 28px; }
.lb-tbl .rank { font-weight: 800; color: var(--muted); width: 36px; }
.lb-tbl .r1 { color: var(--gold); }
.lb-tbl .r2 { color: #cfd8dc; }
.lb-tbl .r3 { color: #d7a26c; }
.lb-tbl .nick { font-weight: 700; color: var(--text); }
.period { margin: 10px 0 4px; }
.period a { display: inline-block; text-decoration: none; padding: 7px 14px; border-radius: 6px; color: var(--muted); font-weight: 600; }
.period a.on { background: var(--card2); color: var(--text); }

/* ---------- Кнопки ---------- */
.ghost { background: transparent; border: 1px solid var(--line); border-radius: 8px; padding: 8px 14px; }
.ghost:hover:not(:disabled) { background: var(--card2); }
.ghost:disabled { opacity: .45; }
.sm { padding: 4px 10px; font-size: 13px; }
.primary { background: var(--gold); color: var(--gold-ink); border: 0; border-radius: 8px; padding: 10px 14px; font-weight: 800; }
.primary:hover:not(:disabled) { filter: brightness(1.06); }
.primary:disabled { background: #4a4a3a; color: #aaa; }
.link { background: none; border: 0; color: var(--link); text-decoration: underline; padding: 0 2px; font-size: 14px; }

/* ---------- Игра ---------- */
.game-head { margin: 18px 0 10px; }
.game-head h1 { font-size: clamp(26px, 3.6vw, 36px); line-height: 1.2; margin: 0 0 4px; }
.game-head .lead { margin: 0; font-size: 16px; }
.gamebar {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 8px 12px; margin-bottom: 12px; font-size: 14px;
}
.round { display: flex; align-items: center; gap: 10px; color: var(--muted); flex-wrap: wrap; }
.phase { padding: 3px 9px; border-radius: 99px; font-weight: 700; font-size: 12px; background: var(--card2); color: var(--text); }
.phase[data-phase="betting"] { background: #1d5a33; color: #c8f7d4; }
.phase[data-phase="race"] { background: #6b4b00; color: #ffe8a3; }
.phase[data-phase="results"] { background: #233b5a; color: #cfe3ff; }
.timer { font-variant-numeric: tabular-nums; font-weight: 700; color: var(--gold); }
.wallet { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.bal-label { color: var(--muted); }
.wallet strong { font-size: 18px; font-variant-numeric: tabular-nums; }
body.offline .phase { background: #5a2323; color: #ffd1d1; }

.game-grid { display: grid; grid-template-columns: minmax(0, 1fr) 330px; gap: 16px; }
.stage { min-width: 0; }
.canvas-wrap { border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); aspect-ratio: 16 / 7.6; background: #3f9442; }
.canvas-wrap canvas { display: block; width: 100%; height: 100%; }

.results-strip { display: flex; gap: 8px; align-items: center; margin: 10px 0 2px; min-height: 30px; overflow-x: auto; font-size: 13px; }
.res-title { color: var(--muted); white-space: nowrap; }
.res-list { display: flex; gap: 6px; list-style: none; margin: 0; padding: 0; }
.res-item { display: flex; gap: 3px; align-items: center; background: var(--card); padding: 3px 6px; border-radius: 6px; }
.res-id { color: var(--muted); font-size: 11px; margin-right: 3px; }

.tabs { display: flex; gap: 2px; margin: 8px 0 0; overflow-x: auto; align-items: center; scrollbar-width: thin; }
.tab { background: transparent; border: 0; border-bottom: 2px solid transparent; padding: 9px 12px; color: var(--muted); white-space: nowrap; font-weight: 700; font-size: 14px; }
.tab.on { color: var(--text); border-bottom-color: var(--gold); }
.tab-link { margin-left: auto; font-size: 13px; white-space: nowrap; padding: 0 6px; }
.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; min-height: 200px; font-size: 14px; }

.card-tbl { border-collapse: collapse; width: 100%; }
.card-tbl th { color: var(--muted); font-weight: 600; font-size: 12px; padding: 4px 4px 8px; text-align: center; white-space: nowrap; }
.card-tbl th.l { text-align: left; }
.card-tbl td { padding: 4px; border-top: 1px solid var(--line); text-align: center; }
.card-tbl td.horse { text-align: left; min-width: 150px; }
.horse { display: flex; align-items: center; gap: 8px; }
.nm { display: flex; flex-direction: column; font-weight: 700; line-height: 1.3; }
.form { display: flex; gap: 2px; margin-top: 3px; }
.form i { font-style: normal; font-size: 11px; width: 15px; height: 15px; line-height: 15px; text-align: center; border-radius: 3px; background: #2a3a32; color: var(--muted); font-weight: 600; }
.form i.f1 { background: #c79a00; color: #1b1400; }
.form i.f2 { background: #8d99a6; color: #10161c; }
.form i.f3 { background: #9a5b2e; color: #fff; }
.silk { width: 18px; height: 18px; border-radius: 50%; flex: none; background: linear-gradient(135deg, var(--s1) 50%, var(--s2) 50%); border: 1px solid rgba(0,0,0,.5); }
.cloth { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 5px; font-weight: 800; font-size: 13px; border: 1px solid rgba(0,0,0,.45); line-height: 1; vertical-align: middle; }
.cloth.sm { width: 20px; height: 20px; font-size: 11px; border-radius: 4px; }

.odd { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-width: 54px; padding: 7px 8px; border-radius: 7px; border: 1px solid transparent; background: var(--odd); font-variant-numeric: tabular-nums; }
.odd b { font-weight: 700; color: var(--gold); }
.odd:hover:not(:disabled) { background: var(--odd-h); }
.odd.on { background: var(--gold); border-color: var(--gold); }
.odd.on b, .odd.on span { color: var(--gold-ink); }
.odd.win { border-color: var(--green); box-shadow: inset 0 0 0 1px var(--green); }
.odd:disabled { opacity: .55; }
.odd.on:disabled, .odd.win:disabled { opacity: 1; }
.na { color: #557063; }
.ew { padding: 7px 8px; border-radius: 7px; border: 1px dashed var(--line); background: transparent; font-size: 12px; font-weight: 700; color: var(--muted); }
.ew.on { background: var(--gold); color: var(--gold-ink); border-style: solid; border-color: var(--gold); }
.ew:disabled { opacity: .5; }

.seg { display: inline-flex; background: var(--bg2); border-radius: 8px; padding: 3px; gap: 3px; flex-wrap: wrap; }
.seg button { border: 0; background: transparent; padding: 6px 12px; border-radius: 6px; color: var(--muted); font-weight: 600; }
.seg button.on { background: var(--card2); color: var(--text); }
.grid { border-collapse: collapse; }
.grid th { padding: 3px; }
.grid td { padding: 2px; text-align: center; }
.grid .odd { min-width: 48px; padding: 6px 4px; font-size: 13px; }
.grid td.diag { background: repeating-linear-gradient(45deg, transparent 0 6px, rgba(255,255,255,.03) 6px 12px); }

.pickrow { display: flex; align-items: center; gap: 5px; margin-bottom: 6px; flex-wrap: wrap; }
.pl { width: 46px; color: var(--muted); font-size: 13px; }
.pick { width: 36px; height: 36px; border-radius: 7px; border: 2px solid transparent; background: var(--bg2); font-weight: 800; }
.pick.on { background: var(--cb); color: var(--cf); border-color: var(--gold); }
.pick:disabled { opacity: .3; }
.picked { display: flex; gap: 10px; flex-wrap: wrap; margin: 12px 0; padding: 10px; background: var(--bg2); border-radius: 8px; }
.picked > div { display: flex; align-items: center; gap: 10px; font-weight: 600; }
.pk-t { color: var(--muted); font-weight: 500; }
.sub { margin: 16px 0 8px; font-size: 13px; color: var(--muted); font-weight: 700; }
.popular { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px; }
.popular .odd { justify-content: space-between; }
.sp-group { margin-bottom: 14px; }
.sp-title { color: var(--muted); font-weight: 600; margin-bottom: 6px; }
.sp-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; max-width: 420px; }
.sp-btns .odd { justify-content: space-between; padding: 10px 12px; }

.game-side { display: flex; flex-direction: column; gap: 12px; min-width: 0; font-size: 14px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
.player { padding: 10px 12px; }
.pl-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.pl-label { color: var(--muted); }
.pl-nick { font-size: 15px; }
.nick-form label { display: block; color: var(--muted); font-size: 13px; margin-bottom: 4px; }
.nick-form input { width: 100%; background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px; font: inherit; }
.nick-actions { display: flex; gap: 8px; margin-top: 8px; }
.side { padding: 0 12px 12px; }
.side-tabs { display: flex; margin: 0 -12px 10px; border-bottom: 1px solid var(--line); }
.side-tabs button { flex: 1; border: 0; background: transparent; padding: 12px; font-weight: 700; color: var(--muted); border-bottom: 2px solid transparent; }
.side-tabs button.on { color: var(--text); border-bottom-color: var(--gold); }
.side-tabs em { font-style: normal; background: var(--gold); color: var(--gold-ink); border-radius: 99px; padding: 0 6px; font-size: 11px; margin-left: 4px; }
.slip-item { position: relative; background: var(--bg2); border-radius: 8px; padding: 9px 10px; margin-bottom: 8px; }
.rm { position: absolute; top: 2px; right: 4px; background: transparent; border: 0; color: var(--muted); font-size: 20px; line-height: 1; padding: 4px 6px; }
.si-title { color: var(--muted); font-size: 12px; padding-right: 20px; }
.si-pick { display: flex; justify-content: space-between; gap: 8px; font-weight: 700; margin: 2px 0 6px; }
.si-pick b { color: var(--gold); }
.si-stake { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; }
.si-stake input { width: 90px; background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; font: inherit; font-size: 14px; }
.si-pot { margin-left: auto; color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }
.chips { display: flex; gap: 6px; margin: 4px 0 10px; }
.chips button { flex: 1; background: var(--bg2); border: 1px solid var(--line); border-radius: 6px; padding: 5px 0; font-weight: 700; }
.totals div { display: flex; justify-content: space-between; padding: 3px 0; }
.totals span { color: var(--muted); }
.slip-actions { display: grid; grid-template-columns: 1fr 2fr; gap: 8px; margin-top: 10px; }
.note { color: var(--muted); font-size: 11px; margin: 8px 0 0; text-align: center; }
.bets { display: flex; flex-direction: column; gap: 6px; max-height: 520px; overflow-y: auto; }
.bet { background: var(--bg2); border-radius: 8px; padding: 8px 10px; border-left: 3px solid var(--line); }
.bet.won { border-left-color: var(--green); }
.bet.lost { border-left-color: var(--red); opacity: .8; }
.bet.pending { border-left-color: var(--gold); }
.b-top, .b-mid, .b-bot { display: flex; justify-content: space-between; gap: 8px; }
.b-top { color: var(--muted); font-size: 12px; }
.b-mid { font-weight: 600; }
.b-mid b { color: var(--gold); }
.b-bot { font-size: 12px; color: var(--muted); }
.bet.won .b-bot b { color: var(--green); }
.bet.lost .b-bot b { color: var(--red); }
.b-st { text-transform: uppercase; font-size: 10px; letter-spacing: .4px; }
.stats, .mini-lb { padding: 12px; }
.st-title { font-size: 15px; font-weight: 800; margin: 0 0 8px; }
.st-grid { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; }
.st-grid span { color: var(--muted); }
.st-grid b { font-variant-numeric: tabular-nums; text-align: right; }
.pos { color: var(--green); }
.neg { color: var(--red); }
.mini { list-style: none; margin: 0 0 8px; padding: 0; }
.mini li { display: flex; gap: 8px; padding: 4px 0; border-bottom: 1px solid var(--line); }
.mini .r { color: var(--muted); width: 16px; }
.mini .n { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.more-link { font-size: 13px; }

.fab { position: fixed; left: 50%; bottom: 14px; transform: translateX(-50%); z-index: 30; background: var(--gold); color: var(--gold-ink); border: 0; border-radius: 99px; padding: 12px 24px; font-weight: 800; box-shadow: 0 6px 18px rgba(0,0,0,.4); display: none; }
#toast { position: fixed; left: 50%; top: 76px; transform: translate(-50%, -20px); z-index: 50; background: #263a30; border: 1px solid var(--line); padding: 10px 16px; border-radius: 8px; opacity: 0; pointer-events: none; transition: .2s; font-weight: 600; max-width: calc(100vw - 32px); }
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.ok { border-color: var(--green); }
#toast.err { border-color: var(--red); }
#toast.win { background: var(--gold); color: var(--gold-ink); border-color: var(--gold); }

@media (max-width: 980px) {
  .game-grid { grid-template-columns: minmax(0, 1fr); }
  .fab:not([hidden]) { display: block; }
  .canvas-wrap { aspect-ratio: 16 / 9.5; }
}
@media (max-width: 640px) {
  .canvas-wrap { aspect-ratio: 4 / 3; }
  .odd { min-width: 46px; padding: 6px 5px; }
  .card-tbl td.horse { min-width: 120px; }
  .silk { display: none; }
  .wallet { margin-left: 0; width: 100%; }
  .bal-label { display: none; }
  .tab-link { display: none; }
  .lead { font-size: 17px; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; scroll-behavior: auto !important; }
}

/* ---------- Партнёрская кнопка «Play for real» ---------- */
.cta-real { display: inline-flex; align-items: center; justify-content: center; gap: 6px; background: #e53935; color: #fff; font-weight: 800; text-decoration: none; border-radius: 8px; padding: 8px 14px; white-space: nowrap; font-size: 14px; }
.cta-real:hover { background: #f44336; color: #fff; }
.cta-real::after { content: "↗"; font-weight: 700; opacity: .85; }
.cta-real.sm { padding: 4px 10px; font-size: 13px; }
.cta-real.big { padding: 13px 22px; font-size: 17px; }
.cta-real.wide { display: flex; margin: 12px 0 4px; }
.header-row .cta-real { margin-left: 8px; }
.drawer .drawer-cta a { border-bottom: 0; color: #fff; }
.cta-row { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.cta-note { color: var(--muted); font-size: 13px; }
.disclosure { font-size: 13px; }
@media (max-width: 1099px) { .header-row .cta-real { margin-left: auto; } .burger { margin-left: 8px; } }
@media (max-width: 420px) { .header-row .cta-real { padding: 6px 10px; font-size: 13px; } .logo span { font-size: 15px; } }
