:root {
  --bg: #f6f5f1;
  --surface: #ffffff;
  --text: #1c1b18;
  --muted: #6d6a63;
  --line: #e2dfd7;
  --accent: #2f4bd8;
  --yes: #15803d;
  --yes-bg: #e3f4e8;
  --no: #c2410c;
  --no-bg: #fbe9e0;
  --radius: 12px;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141412;
    --surface: #1e1e1b;
    --text: #ecebe6;
    --muted: #9c988e;
    --line: #33322d;
    --accent: #8a9cff;
    --yes: #4ade80;
    --yes-bg: #12301d;
    --no: #fb923c;
    --no-bg: #3a1e10;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
  font-variant-numeric: tabular-nums;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.6rem; line-height: 1.25; margin: 0 0 0.5rem; text-wrap: balance; }
h2 { font-size: 1.05rem; margin: 2rem 0 0.6rem; }
h3 { font-size: 0.85rem; margin: 1.4rem 0 0.4rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
[hidden] { display: none !important; }

.top {
  display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;
  padding: 0.75rem 16px; border-bottom: 1px solid var(--line); background: var(--surface);
}
.brand { font-weight: 700; color: var(--text); margin-right: auto; }
#nav { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; font-size: 0.95rem; }
#nav a { color: var(--muted); }
#nav a.active { color: var(--text); font-weight: 600; }
#nav .net { font-weight: 600; }
#nav .badge { display: inline-block; min-width: 1.3em; padding: 0 0.35em; margin-left: 0.3em; border-radius: 999px; background: var(--no); color: #fff; font-size: 0.75rem; text-align: center; font-weight: 700; }
tr.paid td { opacity: 0.6; }

main { max-width: 760px; margin: 0 auto; padding: 1.5rem 16px 4rem; }

button, input, select, textarea { font: inherit; color: inherit; }
button {
  border: 1px solid var(--line); background: var(--surface); border-radius: 8px;
  padding: 0.45rem 0.9rem; cursor: pointer;
}
button:hover:not(:disabled) { border-color: var(--muted); }
button:disabled { opacity: 0.5; cursor: default; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
@media (prefers-color-scheme: dark) { button.primary { color: #10131f; } }
button.danger { background: var(--no); border-color: var(--no); color: #fff; font-weight: 600; }
button.linkish { border: 0; background: none; padding: 0; color: var(--muted); text-decoration: underline; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

input, select, textarea {
  border: 1px solid var(--line); background: var(--surface); border-radius: 8px; padding: 0.5rem 0.6rem; width: 100%;
}
input.small, select { width: auto; }
input.small { max-width: 6.5rem; }
label { display: grid; gap: 0.25rem; font-size: 0.9rem; color: var(--muted); margin-bottom: 0.9rem; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem; }
.card > h2:first-child { margin-top: 0; }
.card.narrow { max-width: 360px; margin: 3rem auto; display: grid; }
.card.narrow .linkish { margin-top: 1rem; justify-self: center; }
a.linkish.center { text-align: center; display: block; margin-top: 0.8rem; color: var(--muted); }
.rule h2 { margin-top: 1.6rem; }
.rule p, .rule li { max-width: 62ch; }
.rule ul { padding-left: 1.2rem; }
.rule li { margin: 0.3rem 0; }

/* Market list */
.tabs { display: flex; gap: 0.4rem; margin-bottom: 1rem; flex-wrap: wrap; }
.tabs button { border-radius: 999px; }
.tabs button[aria-selected="true"] { background: var(--text); color: var(--bg); border-color: var(--text); }
.grid { display: grid; gap: 0.8rem; grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr)); }
.market { display: grid; gap: 0.6rem; color: inherit; }
.market:hover { text-decoration: none; border-color: var(--muted); }
.market .q { font-weight: 600; line-height: 1.3; }
.market .row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.prob { font-size: 2rem; font-weight: 700; line-height: 1; }
.prob.none, .bigprob .none { font-size: 1rem; font-weight: 500; color: var(--muted); }
.meta { display: flex; justify-content: space-between; gap: 1rem; color: var(--muted); font-size: 0.85rem; margin: 0; }

/* Charts */
svg.spark { width: 120px; height: 36px; }
svg.history { width: 100%; height: 160px; display: block; margin-top: 0.8rem; }
svg .line { fill: none; stroke: var(--accent); stroke-width: 2; vector-effect: non-scaling-stroke; stroke-linejoin: round; }
svg .mid { stroke: var(--line); stroke-width: 1; stroke-dasharray: 3 4; vector-effect: non-scaling-stroke; }
.spark.empty, .history.empty { color: var(--muted); font-size: 0.85rem; }
.history.empty { height: 80px; display: grid; place-items: center; border: 1px dashed var(--line); border-radius: var(--radius); margin-top: 0.8rem; }

/* Market detail */
.back { font-size: 0.9rem; color: var(--muted); display: inline-block; margin-bottom: 0.6rem; }
.bigprob { display: flex; align-items: baseline; gap: 0.6rem; flex-wrap: wrap; }
.bigprob .num { font-size: 4.5rem; font-weight: 800; line-height: 1; letter-spacing: -0.03em; }
.bigprob .unit { color: var(--muted); font-size: 1.1rem; }
.up { color: var(--yes); }
.down { color: var(--no); }

.betbuttons { display: grid; grid-template-columns: 1fr 1fr; gap: 0.7rem; margin-top: 1.4rem; }
.betbuttons button { padding: 1rem 0.5rem; font-size: 1.15rem; font-weight: 700; border-radius: var(--radius); border-width: 2px; }
.betbuttons .yes { background: var(--yes-bg); border-color: var(--yes); color: var(--yes); }
.betbuttons .no { background: var(--no-bg); border-color: var(--no); color: var(--no); }
.betpanel:not(:empty) {
  margin-top: 0.8rem; padding: 1rem; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface); display: grid; gap: 0.7rem; justify-items: start;
}
.amount { display: flex; align-items: center; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); padding-left: 0.7rem; width: 100%; max-width: 14rem; }
.amount .prefix { color: var(--muted); font-size: 1.3rem; }
.amount input { border: 0; background: none; font-size: 1.3rem; outline-offset: -2px; }
.amount.inline { display: inline-flex; max-width: 8rem; vertical-align: middle; }
.amount.inline .prefix, .amount.inline input { font-size: 1rem; }
.offer { display: flex; align-items: center; gap: 0.4rem; margin: 0; }
.estimate { margin: 0; font-weight: 600; }
button.primary.yes { background: var(--yes); border-color: var(--yes); }
button.primary.no { background: var(--no); border-color: var(--no); }
.banner.warn { border-color: var(--no); }
.banner, .position { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 0.8rem 1rem; margin: 1rem 0 0; }
.rules p { margin: 0 0 0.5rem; }
.rules .meta { display: block; }

details.advanced { margin-top: 2rem; border-top: 1px solid var(--line); padding-top: 1rem; }
details.advanced summary { cursor: pointer; color: var(--muted); }
.book { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.limit { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; }

/* Tables */
table { border-collapse: collapse; width: 100%; font-size: 0.92rem; }
th, td { text-align: left; padding: 0.45rem 0.6rem 0.45rem 0; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: var(--muted); font-weight: 500; font-size: 0.8rem; }
tr.me td { font-weight: 700; }
.scroll { overflow-x: auto; }
.scroll td:last-child { white-space: nowrap; }
.pill { padding: 0.1rem 0.55rem; border-radius: 999px; font-size: 0.8rem; font-weight: 600; }
.pill.yes { background: var(--yes-bg); color: var(--yes); }
.pill.no { background: var(--no-bg); color: var(--no); }
.muted { color: var(--muted); }
.empty-state { color: var(--muted); padding: 2rem 0; text-align: center; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 0.7rem; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 0.8rem 1rem; }
.stat .label { color: var(--muted); font-size: 0.8rem; }
.stat .value { font-size: 1.3rem; font-weight: 700; }

#toast {
  position: fixed; left: 50%; bottom: 1.5rem; transform: translate(-50%, 1rem);
  visibility: hidden; opacity: 0;
  background: var(--text); color: var(--bg); padding: 0.7rem 1.1rem; border-radius: 10px;
  max-width: min(92vw, 480px); transition: transform 0.2s ease, opacity 0.2s ease, visibility 0.2s; z-index: 10; font-size: 0.95rem;
}
#toast.show { transform: translate(-50%, 0); visibility: visible; opacity: 1; }
#toast.bad { background: var(--no); color: #fff; }

@media (max-width: 520px) {
  .bigprob .num { font-size: 3.4rem; }
  .betbuttons button { font-size: 1rem; }
}
@media (prefers-reduced-motion: reduce) { #toast { transition: none; } }
