:root {
  --bg: #f5f3ee; --paper: #ffffff; --ink: #17191e; --ink-2: #4a4f59; --line: #e2ddd2; --soft: #efece4;
  --accent: #0b6070; --mc: var(--accent); --ball: #fff6d6; --ball-ring: #e2b33a; --ball-ink: #5a4100;
  --up: #11734b; --down: #a3331f;
  --r: 12px; --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", "Roboto Mono", Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #111317; --paper: #1a1d23; --ink: #eceae4; --ink-2: #a9adb6; --line: #2c3038; --soft: #22262d;
          --ball: #2b2512; --ball-ring: #b88a1c; --ball-ink: #f3d27a; --up: #4cc58f; --down: #f08a73; }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.55 var(--sans); }
a { color: inherit; text-decoration-color: color-mix(in srgb, var(--mc) 55%, transparent); text-underline-offset: 3px; }
a:hover { color: var(--mc); }
h1, h2, h3 { line-height: 1.2; letter-spacing: -0.01em; }
h1 { font-size: clamp(1.6rem, 4.5vw, 2.4rem); margin: 0 0 .4rem; }
h2 { font-size: 1.3rem; margin: 2rem 0 .7rem; }
h3 { font-size: 1rem; margin: 1.2rem 0 .5rem; }
.wrap { max-width: 1080px; margin: 0 auto; padding: 0 16px; }
.muted { color: var(--ink-2); }
.small { font-size: .875rem; }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; letter-spacing: .02em; }
.xl { font-size: 1.6rem; font-weight: 700; margin: .2rem 0; }
.cap { text-transform: capitalize; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* header */
.top { background: #16181d; color: #f4f2ec; position: sticky; top: 0; z-index: 10; }
.top-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 56px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 9px; text-decoration: none; font-size: 1.2rem; letter-spacing: -0.02em; color: #e9e6df; }
.brand:hover { color: #fff; }
.brand-mark { flex: none; }
.brand-text b { font-weight: 800; }
.brand-text i { font-style: normal; font-weight: 800; color: #f2c14e; }
.menu-toggle { position: absolute; opacity: 0; pointer-events: none; }
.menu-btn { display: none; align-items: center; gap: 8px; cursor: pointer; font-size: .92rem; padding: 6px 12px;
  border: 1px solid #3a3f49; border-radius: 999px; user-select: none; }
.menu-icon, .menu-icon::before, .menu-icon::after { display: block; width: 14px; height: 2px; background: currentColor; border-radius: 2px; position: relative; }
.menu-icon::before, .menu-icon::after { content: ""; position: absolute; left: 0; }
.menu-icon::before { top: -5px; } .menu-icon::after { top: 5px; }
.menu-toggle:focus-visible + .menu-btn { outline: 2px solid #f2c14e; outline-offset: 2px; }
.main-nav { display: flex; gap: 16px; font-size: .92rem; }
.main-nav a { text-decoration: none; opacity: .85; }
.main-nav a:hover { opacity: 1; color: #f2c14e; }
.market-bar { background: #20232a; border-top: 1px solid #2c3038; }
.market-scroll { display: flex; flex-wrap: wrap; gap: 6px; padding-top: 8px; padding-bottom: 8px; }
.market-scroll a { flex: none; text-decoration: none; font-size: .85rem; padding: 4px 10px; border-radius: 999px;
  border: 1px solid var(--mc); color: #f4f2ec; background: color-mix(in srgb, var(--mc) 35%, transparent); }
.market-scroll a[aria-current="page"], .market-scroll a:hover { background: var(--mc); color: #fff; }
.market-scroll .short { display: none; }
@media (max-width: 760px) {
  .menu-btn { display: inline-flex; }
  .main-nav { display: none; flex-basis: 100%; flex-direction: column; gap: 0; padding: 4px 0 10px; }
  .main-nav a { padding: 10px 2px; border-top: 1px solid #2c3038; font-size: 1rem; opacity: 1; }
  .menu-toggle:checked ~ .main-nav { display: flex; }
  .market-scroll .long { display: none; }
  .market-scroll .short { display: inline; }
  .market-scroll { gap: 6px 5px; }
  .market-scroll a { font-size: .82rem; padding: 4px 9px; }
}

/* layout */
main { padding-bottom: 2rem; }
.hero { padding: 2rem 0 1rem; }
.lede { font-size: 1.06rem; color: var(--ink-2); max-width: 70ch; }
.page-head { padding: 1.2rem 0 .4rem; }
.crumbs { font-size: .82rem; color: var(--ink-2); padding-top: 1rem; }
.crumbs a { text-decoration: none; }
.grid { display: grid; gap: 12px; }
.cards { grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); }
.grid.two, .two-col { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.grid.pred { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); margin-bottom: 12px; }
.grid.stats { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.grid.dream { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
.card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; }
.card h2 { margin-top: 0; }
.card h3 { margin-top: 0; font-size: .82rem; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-2); }
.band { margin-top: 2.2rem; }
.band.two { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.band.two h2 { margin-top: 0; }
.btn { display: inline-block; background: var(--ink); color: var(--bg); padding: 8px 16px; border-radius: 999px; text-decoration: none; font-weight: 600; }
.btn:hover { color: var(--bg); opacity: .9; }
section { margin-top: .4rem; }

/* market cards */
.market-card { border-top: 4px solid var(--mc); display: flex; flex-direction: column; gap: 8px; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.card-head h2 { margin: 0; font-size: 1.1rem; }
.card-head h2 a { text-decoration: none; }
.chip { font-size: .72rem; white-space: nowrap; padding: 2px 8px; border-radius: 999px; background: color-mix(in srgb, var(--mc) 14%, transparent); color: var(--mc); font-weight: 600; }
@media (prefers-color-scheme: dark) { .chip { color: color-mix(in srgb, var(--mc) 40%, #fff); } }
.last { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.mini { margin: 0; display: grid; grid-template-columns: 1fr 1.4fr 1fr; gap: 6px; }
.mini dt { font-size: .7rem; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-2); }
.mini dd { margin: 0; font-weight: 600; font-size: .92rem; }
.card-links { margin: auto 0 0; font-size: .85rem; }

/* number balls */
.balls { display: inline-flex; gap: 5px; }
.ball { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; background: var(--ball);
  border: 2px solid var(--ball-ring); color: var(--ball-ink); font: 700 1rem var(--mono); }
.balls.big .ball { width: 46px; height: 46px; font-size: 1.4rem; }
.result-card { border-left: 4px solid var(--mc); display: flex; flex-direction: column; gap: 6px; margin-top: .6rem; }
.result-card .balls { margin-top: 6px; }

/* tables */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; background: var(--paper); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; font-size: .92rem; }
th, td { padding: 7px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { background: var(--soft); font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-2); }
tbody tr:last-child td { border-bottom: 0; }
tr.hl td { background: color-mix(in srgb, #f2c14e 18%, transparent); }
tr.over td { color: var(--down); }
.lift { font-weight: 700; font-variant-numeric: tabular-nums; }
.lift.up { color: var(--up); } .lift.down { color: var(--down); } .lift.flat { color: var(--ink-2); }

/* heatmap */
.heat { display: grid; gap: 3px; font: .82rem var(--mono); }
.heat-row { display: grid; grid-template-columns: 70px repeat(10, 1fr); gap: 3px; }
.heat-row span { padding: 6px 2px; text-align: center; border-radius: 6px; background: color-mix(in srgb, var(--mc) calc(var(--h, 0) * 70%), var(--soft)); }
.heat-headrow span, .heat-row span:first-child { background: none; color: var(--ink-2); font-family: var(--sans); text-align: left; }
.heat-headrow span { text-align: center; }
.heat-row span[style*="--h: 1"] { color: #fff; }

/* misc blocks */
.stat { background: var(--paper); border: 1px solid var(--line); border-radius: var(--r); padding: 12px 14px; display: flex; flex-direction: column; }
.stat-num { font: 700 1.5rem var(--mono); }
.stat-lbl { font-size: .8rem; color: var(--ink-2); }
.numlist { list-style: none; padding: 0; margin: 0; columns: 2; }
.numlist li { padding: 2px 0; break-inside: avoid; }
.numlist a { font-weight: 700; margin-right: 4px; }
.formulas { columns: 2; padding-left: 1.1rem; }
.methods { padding-left: 1.3rem; } .methods li { margin: .35rem 0; }
.years { display: flex; flex-wrap: wrap; gap: 6px; }
.years a { text-decoration: none; padding: 3px 10px; border: 1px solid var(--line); border-radius: 999px; background: var(--paper); font-size: .85rem; }
.years a[aria-current="page"] { background: var(--mc); color: #fff; border-color: var(--mc); }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 4px 14px; margin: 0; }
.kv dt { color: var(--ink-2); } .kv dd { margin: 0; }
.numlinks { display: flex; gap: 14px; flex-wrap: wrap; } .numlinks a { text-decoration: none; }
.dream-card { display: flex; gap: 12px; align-items: center; text-decoration: none; }
.big-n { font-size: 1.5rem; font-weight: 800; color: var(--accent); min-width: 2.4ch; }
.pager { display: flex; justify-content: space-between; margin-top: 1.5rem; }
.search, input, select { font: inherit; color: var(--ink); background: var(--paper); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; }
.search { width: 100%; max-width: 480px; }
.tool { margin-top: 14px; display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: flex-end; }
.tool h2 { flex-basis: 100%; margin: 0; font-size: 1.1rem; }
.tool label { display: flex; flex-direction: column; gap: 4px; font-size: .85rem; color: var(--ink-2); }
.tool label.toggle, label.toggle { flex-direction: row; align-items: center; gap: 6px; font-size: .9rem; }
.tool input:not([type=checkbox]) { min-width: 130px; }
.tool .out { flex-basis: 100%; margin: 0; word-break: break-word; }
.wheel-in { display: flex; flex-wrap: wrap; gap: 10px; flex-basis: 100%; }
.wheel-in input { width: 130px; min-width: 0 !important; }

/* data table + paito colouring */
.data-table td { padding: 5px 10px; }
.digits span { display: inline-block; width: 1.3em; text-align: center; border-radius: 4px; }
.paito .d0 { background: #f7d6d0; } .paito .d1 { background: #fbe3c3; } .paito .d2 { background: #fff1b8; }
.paito .d3 { background: #dff3c4; } .paito .d4 { background: #c8eedb; } .paito .d5 { background: #c6ecf2; }
.paito .d6 { background: #cfe0fb; } .paito .d7 { background: #ddd5fb; } .paito .d8 { background: #f4d3f1; } .paito .d9 { background: #e5e1d8; }
@media (prefers-color-scheme: dark) { .paito .digits span { color: #17191e; } }

/* collapsed home section */
details.more { background: var(--paper); border: 1px solid var(--line); border-radius: var(--r); padding: 0 16px; }
details.more summary { cursor: pointer; padding: 14px 0; font-weight: 700; list-style: none; display: flex; justify-content: space-between; align-items: center; }
details.more summary::-webkit-details-marker { display: none; }
details.more summary::after { content: "+"; font-size: 1.3rem; color: var(--ink-2); }
details.more[open] summary::after { content: "–"; }
details.more[open] { padding-bottom: 6px; }

.show-m { display: none; }

/* phones: smaller cells; .stack tables turn each row into a labelled card */
@media (max-width: 600px) {
  th, td { padding: 6px 7px; }
  table { font-size: .86rem; }
  .hide-m { display: none; }
  .show-m { display: inline; }
  table.stack, table.stack tbody { display: block; border: 0; background: none; }
  table.stack thead { display: none; }
  table.stack tr { display: grid; grid-template-columns: repeat(auto-fit, minmax(84px, 1fr)); gap: 2px 12px; background: var(--paper);
    border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px; margin-bottom: 8px; }
  table.stack td { border: 0; padding: 2px 0; text-align: left; white-space: normal; }
  table.stack td:first-child { grid-column: 1 / -1; font-weight: 700; padding-bottom: 4px; }
  table.stack td[data-label]::before { content: attr(data-label); display: block; font-size: .72rem; color: var(--ink-2);
    text-transform: uppercase; letter-spacing: .03em; font-weight: 400; font-family: var(--sans); }
  table.stack td.hide-m { display: none; }
  .data-table td { padding: 5px 6px; }
  .heat-row { grid-template-columns: 52px repeat(10, 1fr); }
  .heat { font-size: .72rem; }
  .heat-row span { padding: 5px 0; }
  .numlist, .formulas { columns: 1; }
  .xl { font-size: 1.4rem; }
  .mini { grid-template-columns: 1fr 1.5fr 1fr; }
}

/* footer */
.foot { margin-top: 3rem; border-top: 1px solid var(--line); padding: 1.5rem 0 2.5rem; font-size: .9rem; }
.foot-links a { margin-right: 4px; }
