:root {
  --bg: #f6f7f9;
  --card: #ffffff;
  --fg: #0f172a;
  --muted: #5b6475;
  --line: #e3e7ee;
  --accent: #0f766e;
  --accent-soft: #e6f4f2;
  --accent-fg: #ffffff;
  --good: #15803d;
  --bad: #b42318;
  --warn: #b45309;
  --c1: #0f766e;
  --c2: #6366f1;
  --c3: #e11d48;
  --c4: #94a3b8;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .05), 0 8px 24px rgba(15, 23, 42, .06);
  color-scheme: light;
}
/* dark: chosen with the switch, or by the system when nothing was chosen */
:root[data-theme="dark"] {
  --bg: #0b1016;
  --card: #121922;
  --fg: #e7ecf3;
  --muted: #9aa5b5;
  --line: #243040;
  --accent: #2dd4bf;
  --accent-soft: #10302d;
  --accent-fg: #04201d;
  --good: #4ade80;
  --bad: #f87171;
  --warn: #fbbf24;
  --c1: #2dd4bf;
  --c2: #a5b4fc;
  --c3: #fb7185;
  --c4: #64748b;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b1016;
    --card: #121922;
    --fg: #e7ecf3;
    --muted: #9aa5b5;
    --line: #243040;
    --accent: #2dd4bf;
    --accent-soft: #10302d;
    --accent-fg: #04201d;
    --good: #4ade80;
    --bad: #f87171;
    --warn: #fbbf24;
    --c1: #2dd4bf;
    --c2: #a5b4fc;
    --c3: #fb7185;
    --c4: #64748b;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
}

/* theme switch */
.theme-btn { display: inline-flex; align-items: center; justify-content: center; width: 38px; height: 38px; border: 1.5px solid var(--line); border-radius: 10px; background: var(--card); color: var(--fg); cursor: pointer; padding: 0; flex: none; }
.theme-btn:hover { border-color: var(--accent); }
.theme-btn svg { width: 18px; height: 18px; }
.theme-btn .moon { display: none; }
.is-dark .theme-btn .sun { display: none; }
.is-dark .theme-btn .moon { display: block; }
.header-right { display: flex; align-items: center; gap: 22px; }

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 72px; }
body {
  margin: 0;
  font: 16px/1.6 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--fg);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); }
code { font: .92em ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; background: var(--accent-soft); padding: .1em .35em; border-radius: 6px; }
.wrap { max-width: 1080px; margin: 0 auto; padding: 0 20px; }
[hidden] { display: none !important; }

/* header */
.site-header { position: sticky; top: 0; z-index: 10; background: color-mix(in srgb, var(--bg) 85%, transparent); backdrop-filter: saturate(1.4) blur(10px); border-bottom: 1px solid var(--line); }
.header-row { display: flex; align-items: center; justify-content: space-between; height: 60px; gap: 16px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--accent); font-weight: 700; text-decoration: none; letter-spacing: -.01em; }
.brand span { color: var(--fg); }
.top-nav { display: flex; gap: 22px; }
.top-nav a { color: var(--muted); text-decoration: none; font-size: 15px; }
.top-nav a:hover { color: var(--fg); }
@media (max-width: 720px) { .top-nav { display: none; } }

/* hero */
.hero { padding-top: 36px; padding-bottom: 8px; }
h1 { font-size: clamp(30px, 5vw, 46px); line-height: 1.1; letter-spacing: -.025em; margin: 0 0 12px; }
.lede { font-size: 18px; color: var(--muted); max-width: 760px; margin: 0; }

@media (max-width: 600px) {
  .hero { padding-top: 22px; }
  .lede { font-size: 16px; }
  .tab { font-size: 14px; padding: 9px 2px; }
  .calc, .result, .chart-card { padding: 16px; }
  .wrap { padding: 0 14px; }
}

/* cards */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }

/* calculator */
.calc-grid { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, .9fr); gap: 20px; margin-top: 24px; align-items: start; }
@media (max-width: 860px) { .calc-grid { grid-template-columns: 1fr; } }
.calc { padding: 22px; display: grid; gap: 18px; }
.tabs { display: grid; grid-template-columns: repeat(3, 1fr); background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: 4px; gap: 4px; }
.tab { border: 0; background: transparent; color: var(--muted); font: inherit; font-weight: 600; font-size: 15px; padding: 9px 6px; border-radius: 9px; cursor: pointer; }
.tab[aria-selected="true"] { background: var(--card); color: var(--fg); box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.mode { display: grid; gap: 18px; }
.field { display: grid; gap: 7px; }
.label { font-weight: 600; font-size: 15px; display: flex; justify-content: space-between; align-items: baseline; }
.label output { font-weight: 700; color: var(--accent); }
.hint { font-size: 13.5px; color: var(--muted); }
.hint.bad { color: var(--bad); }
.input-wrap { display: flex; align-items: center; border: 1.5px solid var(--line); border-radius: 12px; background: var(--card); transition: border-color .15s, box-shadow .15s; }
.input-wrap:focus-within { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.input-wrap.invalid { border-color: var(--bad); }
.input-wrap input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--fg); font: inherit; font-size: 20px; font-weight: 600; padding: 11px 14px; font-variant-numeric: tabular-nums; }
.prefix input { padding-left: 4px; }
.suffix input { padding-right: 4px; }
.affix { color: var(--muted); font-size: 18px; padding: 0 14px; }
.prefix .affix { padding-right: 0; }
.suffix .affix { padding-left: 0; }
.seg { display: flex; gap: 6px; flex-wrap: wrap; }
.seg-btn { flex: 1; border: 1.5px solid var(--line); background: transparent; color: var(--muted); font: inherit; font-size: 14px; font-weight: 600; padding: 7px 10px; border-radius: 10px; cursor: pointer; }
.seg-btn[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
input[type="range"] { width: 100%; accent-color: var(--accent); }

/* result */
.result { padding: 22px; position: sticky; top: 80px; }
@media (max-width: 860px) { .result { position: static; } }
.verdict { display: grid; gap: 2px; padding: 18px; border-radius: 12px; background: var(--accent-soft); }
.verdict.nobet { background: color-mix(in srgb, var(--bad) 12%, transparent); }
.verdict-label { font-size: 14px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.stake { font-size: clamp(38px, 6vw, 52px); font-weight: 800; letter-spacing: -.03em; line-height: 1.1; color: var(--accent); font-variant-numeric: tabular-nums; }
.verdict.nobet .stake { color: var(--bad); }
.stake-sub { color: var(--muted); font-size: 15px; }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 0; margin: 16px 0 0; }
.stats div { padding: 11px 0; border-bottom: 1px solid var(--line); }
.stats div:nth-child(odd) { padding-right: 12px; }
.stats dt { font-size: 13px; color: var(--muted); }
.stats dd { margin: 0; font-weight: 700; font-size: 17px; font-variant-numeric: tabular-nums; }
.stats .pos { color: var(--good); }
.stats .neg { color: var(--bad); }
.note { font-size: 14.5px; color: var(--muted); margin: 14px 0 0; }
.note strong { color: var(--fg); }
.link-btn { margin-top: 12px; border: 0; background: none; color: var(--accent); font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; padding: 0; }
.btn-ghost { border: 1.5px solid var(--line); background: transparent; color: var(--fg); font: inherit; font-size: 14px; font-weight: 600; padding: 7px 14px; border-radius: 10px; cursor: pointer; }
.btn-ghost:hover, .seg-btn:hover { border-color: var(--accent); }

/* charts */
.chart-card { padding: 22px; margin-top: 20px; }
.chart-head h2 { margin: 0 0 4px; font-size: 21px; letter-spacing: -.01em; }
.chart-head p { margin: 0; color: var(--muted); font-size: 15px; }
.sim-controls { display: flex; gap: 12px; align-items: center; margin-top: 12px; flex-wrap: wrap; font-size: 14px; color: var(--muted); }
.sim-controls select { margin-left: 6px; font: inherit; color: var(--fg); background: var(--card); border: 1.5px solid var(--line); border-radius: 8px; padding: 5px 8px; }
.chart { position: relative; margin-top: 14px; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart text { font-size: 12px; fill: var(--muted); font-family: inherit; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .axis { stroke: var(--muted); stroke-width: 1; opacity: .5; }
.chart .zero { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 4 4; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 18px; margin-top: 10px; font-size: 13.5px; color: var(--muted); }
.legend i { display: inline-block; width: 14px; height: 3px; border-radius: 2px; vertical-align: middle; margin-right: 6px; }
.tip { position: absolute; pointer-events: none; background: var(--fg); color: var(--bg); font-size: 12.5px; padding: 6px 9px; border-radius: 8px; white-space: nowrap; transform: translate(-50%, -120%); opacity: 0; transition: opacity .1s; font-variant-numeric: tabular-nums; }

/* tables */
.table-scroll { overflow-x: auto; margin-top: 14px; }
table { width: 100%; border-collapse: collapse; font-size: 15px; font-variant-numeric: tabular-nums; }
caption { text-align: left; font-weight: 600; padding-bottom: 8px; }
th, td { padding: 9px 10px; border-bottom: 1px solid var(--line); text-align: left; }
th { font-size: 13px; color: var(--muted); font-weight: 600; }
.sim-table, .ref-table { min-width: 560px; }
.sim-table td:first-child i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 8px; }

/* article */
.prose { max-width: 780px; margin-top: 48px; }
.prose section { margin-bottom: 44px; }
.prose h2 { font-size: 27px; letter-spacing: -.02em; line-height: 1.2; margin: 0 0 14px; }
.prose h3 { font-size: 19px; margin: 26px 0 8px; }
.prose p, .prose li { font-size: 17px; }
.prose li { margin-bottom: 6px; }
.small { font-size: 14px !important; color: var(--muted); }
.formula { display: flex; align-items: center; justify-content: center; gap: 12px; font-size: 30px; font-family: "Cambria Math", Cambria, Georgia, serif; padding: 26px; margin: 8px 0 16px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
.formula .frac { display: inline-flex; flex-direction: column; text-align: center; }
.formula .frac span:first-child { border-bottom: 2px solid currentColor; padding: 0 8px 2px; }
.formula .frac span:last-child { padding-top: 2px; }
.formula-line { font-family: "Cambria Math", Cambria, Georgia, serif; font-size: 21px !important; text-align: center; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 14px; }
.defs { list-style: none; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 4px 20px; }
@media (max-width: 600px) { .defs { grid-template-columns: 1fr; } }
details { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 0 18px; margin-bottom: 10px; }
summary { cursor: pointer; font-weight: 600; font-size: 17px; padding: 15px 0; list-style: none; position: relative; padding-right: 28px; }
summary::-webkit-details-marker { display: none; }
summary::after { content: "+"; position: absolute; right: 0; top: 12px; font-size: 22px; color: var(--muted); }
details[open] summary::after { content: "−"; }
details p { margin: 0 0 16px; }
.disclaimer { font-size: 14.5px; color: var(--muted); border-left: 3px solid var(--warn); padding: 4px 0 4px 16px; margin-bottom: 40px; }

/* footer */
.site-footer { border-top: 1px solid var(--line); padding: 26px 0; color: var(--muted); font-size: 14px; }
.footer-row { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.footer-row nav a { color: var(--muted); margin-left: 16px; }

/* simple pages */
.page { max-width: 760px; padding-top: 36px; padding-bottom: 40px; }
.page p, .page li { font-size: 17px; }
