/* Colour roles. Ramps were checked with the dataviz palette validator (ordinal, light and dark). */
:root {
  color-scheme: light;
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #898781;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --ring: rgba(11, 11, 11, 0.10);
  --series-1: #2a78d6;

  /* Binned magnitude, 5 steps. The low end still clears 2:1 so a rare cell never looks empty. */
  --seq-1: #86b6ef; --seq-2: #5598e7; --seq-3: #2a78d6; --seq-4: #1c5cab; --seq-5: #104281;
  /* Ordinal, 4 steps (to-hit 6+, 5+, 4+, 3+). */
  --ord-1: #86b6ef; --ord-2: #3987e5; --ord-3: #1c5cab; --ord-4: #0d366b;
  /* Diverging: good (blue) <- neutral -> bad (red), 3 steps per arm. */
  --good-3: #1c5cab; --good-2: #3987e5; --good-1: #86b6ef;
  --neutral: #e1e0d9;
  --bad-1: #f09a98; --bad-2: #e34948; --bad-3: #a8302f;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #0d0d0d; --surface: #1a1a19; --ink: #ffffff; --ink-2: #c3c2b7; --muted: #898781;
    --grid: #2c2c2a; --axis: #383835; --ring: rgba(255, 255, 255, 0.10); --series-1: #3987e5;
    --seq-1: #184f95; --seq-2: #3987e5; --seq-3: #6da7ec; --seq-4: #9ec5f4; --seq-5: #cde2fb;
    --ord-1: #184f95; --ord-2: #2a78d6; --ord-3: #6da7ec; --ord-4: #b7d3f6;
    --neutral: #383835;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d; --surface: #1a1a19; --ink: #ffffff; --ink-2: #c3c2b7; --muted: #898781;
  --grid: #2c2c2a; --axis: #383835; --ring: rgba(255, 255, 255, 0.10); --series-1: #3987e5;
  --seq-1: #184f95; --seq-2: #3987e5; --seq-3: #6da7ec; --seq-4: #9ec5f4; --seq-5: #cde2fb;
  --ord-1: #184f95; --ord-2: #2a78d6; --ord-3: #6da7ec; --ord-4: #b7d3f6;
  --neutral: #383835;
}

* { box-sizing: border-box; }
html { background: var(--page); }
body {
  margin: 0 auto;
  max-width: 1120px;
  padding: 24px 16px 64px;
  background: var(--page);
  color: var(--ink);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif;
}
h1 { font-size: 24px; margin: 0 0 4px; font-weight: 600; }
h2 { font-size: 17px; margin: 0 0 2px; font-weight: 600; }
h3 { font-size: 13px; margin: 18px 0 8px; font-weight: 600; color: var(--ink-2); }
code { font-size: 12.5px; }
.sub, .note { color: var(--ink-2); margin: 0; }
.note { font-size: 12.5px; margin-top: 12px; }

.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
.toc { display: flex; flex-wrap: wrap; gap: 4px 16px; margin: 16px 0 20px; }
.toc a { color: var(--ink-2); text-decoration: none; border-bottom: 1px solid var(--axis); }
.toc a:hover { color: var(--ink); }

button, select { font: inherit; color: var(--ink); }
.ghost {
  background: transparent; border: 1px solid var(--axis); border-radius: 6px;
  padding: 4px 10px; cursor: pointer;
}
.ghost:hover { background: var(--ring); }
select {
  background: var(--surface); border: 1px solid var(--axis); border-radius: 6px; padding: 4px 8px; max-width: 100%;
}
:focus-visible { outline: 2px solid var(--series-1); outline-offset: 2px; }

/* ---- tiles ------------------------------------------------------------- */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 16px; }
.tile { background: var(--surface); border: 1px solid var(--ring); border-radius: 10px; padding: 14px 16px; }
.tile .label { color: var(--ink-2); font-size: 12.5px; }
.tile .value { font-size: 28px; font-weight: 600; margin-top: 2px; }
.tile .value small { font-size: 14px; font-weight: 400; color: var(--muted); }

/* ---- cards ------------------------------------------------------------- */
.card {
  background: var(--surface); border: 1px solid var(--ring); border-radius: 12px;
  padding: 20px; margin-bottom: 16px; scroll-margin-top: 16px;
}
.card-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.controls { display: flex; gap: 16px; flex-wrap: wrap; align-items: flex-end; }
.field { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; color: var(--ink-2); max-width: 100%; }
.stepper { display: flex; align-items: center; gap: 6px; }
.stepper output { min-width: 3ch; text-align: center; color: var(--ink); font-variant-numeric: tabular-nums; }
.segmented { display: inline-flex; border: 1px solid var(--axis); border-radius: 6px; overflow: hidden; }
.segmented button { border: 0; background: transparent; padding: 4px 12px; cursor: pointer; }
.segmented button[aria-checked="true"] { background: var(--ink); color: var(--surface); }

details { margin-top: 16px; }
summary { cursor: pointer; color: var(--ink-2); }
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; margin-top: 8px; font-size: 12.5px; }
th, td { text-align: left; padding: 5px 12px 5px 0; border-bottom: 1px solid var(--grid); vertical-align: top; }
th { color: var(--ink-2); font-weight: 600; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---- legend ------------------------------------------------------------ */
.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12px; color: var(--ink-2); align-items: center; }
.legend .key { display: inline-flex; align-items: center; gap: 6px; }
.legend .sw { width: 12px; height: 12px; border-radius: 3px; flex: none; }
.legend .ramp { display: inline-flex; gap: 2px; }
.legend .ramp span { width: 18px; height: 12px; }
.legend .ramp span:first-child { border-radius: 3px 0 0 3px; }
.legend .ramp span:last-child { border-radius: 0 3px 3px 0; }

/* ---- horizontal bars (roll odds) --------------------------------------- */
.hbars { display: grid; grid-template-columns: minmax(120px, max-content) 1fr 56px; gap: 6px 12px; align-items: center; }
.hbars .lab { color: var(--ink); font-size: 13px; overflow-wrap: anywhere; }
.hbars .track { height: 20px; position: relative; border-left: 1px solid var(--axis); }
.hbars .bar { height: 100%; background: var(--series-1); border-radius: 0 4px 4px 0; min-width: 2px; }
.hbars .val { text-align: right; font-variant-numeric: tabular-nums; color: var(--ink-2); }
.hbars .row { display: contents; }
.hbars .row:hover .bar, .hbars .row:focus-visible .bar { filter: brightness(1.15); }
.hbars .row:focus-visible .lab { text-decoration: underline; }
.hbars .row.unmatched .bar { background: var(--muted); }

/* ---- heat grids -------------------------------------------------------- */
.heat { display: grid; gap: 2px; font-size: 12px; min-width: min-content; }
.heat .h { color: var(--ink-2); font-weight: 600; padding: 2px 4px; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; text-align: center; line-height: 1.2; }
.heat .h.group { border-bottom: 1px solid var(--axis); padding-bottom: 4px; }
.heat .rl { color: var(--ink); padding-right: 10px; display: flex; align-items: center; white-space: nowrap; }
.heat .rl.grouphead { color: var(--ink-2); font-weight: 600; padding-top: 10px; }
.heat .c {
  height: 30px; min-width: 40px; border-radius: 3px; display: flex; align-items: center; justify-content: center;
  font-variant-numeric: tabular-nums; font-weight: 600; position: relative;
}
.heat .c.empty { background: transparent; box-shadow: inset 0 0 0 1px var(--grid); }
.heat .c[tabindex]:hover, .heat .c[tabindex]:focus-visible { outline: 2px solid var(--ink); outline-offset: 0; z-index: 1; }
.heat .c.target { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--ink); z-index: 1; }
.heat .side { color: var(--ink-2); padding-left: 10px; display: flex; align-items: center; white-space: nowrap; font-variant-numeric: tabular-nums; }

/* ---- stacked bars (landing) -------------------------------------------- */
.landing-layout { display: grid; grid-template-columns: 1fr 260px; gap: 24px; }
@media (max-width: 760px) { .landing-layout { grid-template-columns: 1fr; } }
.stack { display: grid; grid-template-columns: 34px 1fr 96px; gap: 4px 10px; align-items: center; }
.stack .m { text-align: right; font-variant-numeric: tabular-nums; color: var(--ink-2); }
.stack .bar { display: flex; gap: 2px; height: 18px; }
.stack .seg { height: 100%; min-width: 0; }
.stack .seg:first-child { border-radius: 4px 0 0 4px; }
.stack .seg:last-child { border-radius: 0 4px 4px 0; }
.stack .seg:only-child { border-radius: 4px; }
.stack .seg:hover, .stack .seg:focus-visible { filter: brightness(1.15); outline: none; }
.stack .end { font-variant-numeric: tabular-nums; color: var(--ink-2); font-size: 12px; }
.stack .row { display: contents; }
.stack .row.hit .m, .stack .row.hit .end { color: var(--ink); font-weight: 600; }
.stack .row.hit .bar { box-shadow: 0 0 0 2px var(--surface), 0 0 0 3px var(--ink); border-radius: 4px; }
.mods { display: flex; flex-direction: column; gap: 6px; font-size: 12.5px; }
.mods label { display: grid; grid-template-columns: auto 1fr auto; gap: 8px; align-items: baseline; cursor: pointer; }
.mods .v { font-variant-numeric: tabular-nums; color: var(--ink-2); }
.net { margin-top: 14px; font-weight: 600; }

/* ---- tooltip ----------------------------------------------------------- */
.tip {
  position: fixed; pointer-events: none; z-index: 10; max-width: 280px;
  background: var(--surface); color: var(--ink); border: 1px solid var(--ring);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12); border-radius: 8px; padding: 8px 10px; font-size: 12.5px;
}
.tip .v { font-weight: 600; font-size: 14px; }
.tip .l { color: var(--ink-2); }
.tip .t { color: var(--muted); margin-top: 4px; }

@media (forced-colors: active) {
  .hbars .bar, .stack .seg, .heat .c { forced-color-adjust: none; }
}

/* ---- the site's navigation (shared.js siteNav) ----------------------------------- */
.site-nav {
  display: flex; align-items: center; gap: 6px 18px; flex-wrap: wrap; margin: -8px 0 16px; padding: 6px 0 8px;
  border-bottom: 1px solid var(--grid);
}
.site-nav .brand { display: inline-flex; align-items: center; gap: 8px; color: var(--ink); text-decoration: none; font-weight: 700; margin-right: 6px; }
.site-nav .brand-sub { font-weight: 400; color: var(--ink-2); }
.site-nav .brand-mark { width: 42px; height: 15px; }
.brand-mark .ins-bar { fill: #fff; stroke: #1f3b78; stroke-width: 3; }
.brand-mark .ins-disc { fill: #1f3b78; }
.brand-mark .ins-star { fill: #fff; }
.site-nav ul { display: flex; flex-wrap: wrap; gap: 2px 4px; list-style: none; margin: 0; padding: 0; flex: 1; }
.site-nav ul a { display: block; padding: 4px 10px; border-radius: 6px; color: var(--ink-2); text-decoration: none; }
.site-nav ul a:hover { background: var(--ring); color: var(--ink); }
.site-nav ul a[aria-current="page"] { color: var(--ink); font-weight: 600; box-shadow: inset 0 -2px 0 var(--series-1); border-radius: 6px 6px 0 0; }
.site-nav .auth-slot { display: flex; align-items: center; }
.site-nav .theme-switch { margin-left: auto; font-size: 12.5px; }
@media (max-width: 640px) { .site-nav .brand-sub { display: none; } .site-nav ul { order: 3; flex-basis: 100%; } }
@media print { .site-nav { display: none !important; } }
