/* Light only: the logo has a white background. */
:root {
  color-scheme: light;
  --surface: #ffffff;
  --plane: #f9f9f7;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #898781;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);
  --series-1: #2a78d6;
  --red-ball: #c8102e;

  /* Diverging scale: distance from chance in σ. Blue = colder, red = hotter, gray = ordinary noise. */
  --zc3: #184f95;
  --zc2: #3987e5;
  --zc1: #86b6ef;
  --z0: #f0efec;
  --zh1: #f3a09b;
  --zh2: #e34948;
  --zh3: #a3262a;

  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.45;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--surface); color: var(--ink); }
.wrap { max-width: 1120px; margin: 0 auto; padding: 0 16px; }
h1, h2, p { margin: 0; }
h2 { font-size: 1.1rem; font-weight: 650; margin-bottom: 12px; }
button, select, input { font: inherit; color: inherit; }

/* Masthead */
.masthead-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 20px;
  padding-top: 12px;
  padding-bottom: 12px;
}
.brand img { display: block; width: 132px; height: auto; }
.title { flex: 1 1 220px; }
.title h1 { font-size: 1.5rem; letter-spacing: -0.01em; }
.title-link { color: inherit; text-decoration: none; }
.title-link:hover { text-decoration: underline; text-underline-offset: 0.15em; }
.title-link:focus-visible { outline: 2px solid var(--series-1); outline-offset: 2px; border-radius: 2px; }
.summary { color: var(--ink-2); font-size: 0.85rem; }
.latest { display: flex; flex-direction: column; gap: 4px; }
.latest-label { font-size: 0.8rem; color: var(--ink-2); }
.checked { font-size: 0.75rem; color: var(--muted); }
.balls { display: flex; gap: 6px; }
.latest .ball { width: 34px; height: 34px; font-size: 0.95rem; }

/* Balls */
.ball {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  font-weight: 650;
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
}
.ball-white { background: var(--surface); box-shadow: inset 0 0 0 1.5px var(--axis); }
.ball-red { background: var(--red-ball); color: #fff; }
.ball.is-match { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--ink); }

/* Filter bar + tabs */
.filters {
  position: sticky;
  top: 0;
  z-index: 5;
  background: var(--surface);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}
.filter-row {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 8px 16px;
  padding-top: 10px;
}
.field { display: flex; flex-direction: column; gap: 2px; }
.field-label { font-size: 0.75rem; color: var(--ink-2); }
select, input[type="text"] {
  height: 38px;
  padding: 0 12px;
  border: 1px solid var(--axis);
  border-radius: 8px;
  background-color: var(--surface);
  max-width: 100%;
  font-size: 16px; /* below 16px, iOS Safari zooms the page when the control is tapped */
}
select {
  -webkit-appearance: none;
  appearance: none;
  padding-right: 36px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%2352514e' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 12px 8px;
  cursor: pointer;
}
select:hover, input[type="text"]:hover { border-color: var(--ink-2); }
select:focus-visible, input[type="text"]:focus-visible { outline: 2px solid var(--series-1); outline-offset: 1px; }
select option:disabled { color: var(--muted); }
.in-view { color: var(--ink-2); font-size: 0.85rem; padding-bottom: 9px; }
.tabs { display: flex; gap: 4px; overflow-x: auto; margin-top: 8px; }
.tab {
  border: 0;
  background: none;
  padding: 8px 12px;
  border-bottom: 2px solid transparent;
  color: var(--ink-2);
  cursor: pointer;
  white-space: nowrap;
}
.tab:hover { color: var(--ink); background: var(--plane); }
.tab[aria-current="page"] { color: var(--ink); border-bottom-color: var(--ink); font-weight: 600; }

main.wrap { padding-top: 20px; padding-bottom: 48px; }
.lede { color: var(--ink-2); max-width: 72ch; margin-bottom: 16px; }
.lede strong { color: var(--ink); }
.block { margin-top: 32px; }
.empty { color: var(--ink-2); padding: 32px 0; }

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  justify-content: space-between;
  gap: 12px 24px;
  margin-bottom: 16px;
}
.toolbar-stack { flex-direction: column; align-items: flex-start; justify-content: flex-start; }
.check { display: flex; align-items: center; gap: 6px; padding-bottom: 9px; font-size: 0.9rem; }

/* Color key */
.legend { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; font-size: 0.75rem; color: var(--ink-2); }
.legend-scale { display: flex; gap: 2px; list-style: none; margin: 0; padding: 0; }
.legend-scale li { display: flex; flex-direction: column; align-items: center; gap: 2px; min-width: 48px; }
.swatch { display: block; width: 100%; height: 12px; border-radius: 3px; }
.legend-end { font-weight: 600; color: var(--ink); }

.segmented { display: inline-flex; border: 1px solid var(--axis); border-radius: 8px; padding: 2px; gap: 2px; }
.segmented button { border: 0; background: none; padding: 5px 10px; border-radius: 6px; cursor: pointer; color: var(--ink-2); }
.segmented button[aria-pressed="true"] { background: var(--ink); color: var(--surface); }

/* Heat colors, shared by table cells, swatches and chart columns */
.zc3 { background: var(--zc3); color: #fff; }
.zc2 { background: var(--zc2); }
.zc1 { background: var(--zc1); }
.z0 { background: var(--z0); }
.zh1 { background: var(--zh1); }
.zh2 { background: var(--zh2); }
.zh3 { background: var(--zh3); color: #fff; }
path.zc3 { fill: var(--zc3); }
path.zc2 { fill: var(--zc2); }
path.zc1 { fill: var(--zc1); }
path.z0 { fill: #c3c2b7; }
path.zh1 { fill: var(--zh1); }
path.zh2 { fill: var(--zh2); }
path.zh3 { fill: var(--zh3); }

/* Tables */
.scroll { overflow-x: auto; max-width: 100%; }
table { font-variant-numeric: tabular-nums; }
caption { text-align: left; font-weight: 650; padding-bottom: 8px; }
th { font-weight: 600; text-align: left; vertical-align: bottom; }
.num { text-align: right; }
.th-main { display: block; }
.th-sub { display: block; font-size: 0.7rem; font-weight: 400; color: var(--muted); }
.sort {
  display: inline-flex;
  flex-direction: column;
  align-items: inherit;
  border: 0;
  background: none;
  padding: 0;
  cursor: pointer;
  text-align: inherit;
  font-weight: 600;
  position: relative;
}
.sort:hover .th-main { text-decoration: underline; }
.sort-mark { font-size: 0.6rem; color: var(--ink-2); height: 0.8rem; }

.matrix-grid { display: grid; grid-template-columns: auto auto; justify-content: start; gap: 48px; align-items: start; }
table.matrix { border-collapse: separate; border-spacing: 2px; }
table.matrix th { padding: 4px 6px; text-align: center; }
table.matrix thead th { min-width: 52px; }
table.matrix td {
  min-width: 52px;
  padding: 5px 8px;
  border-radius: 4px;
  text-align: center;
}
table.matrix td.plain { background: none; color: var(--ink-2); }
table.matrix .sort { align-items: center; }
.ball-cell { padding: 2px 6px; }
td.is-hover, th.is-hover { outline: 2px solid var(--ink); outline-offset: -2px; }

table.data { border-collapse: collapse; }
table.split { width: 100%; }
table.data th, table.data td { padding: 6px 10px; border-bottom: 1px solid var(--grid); white-space: nowrap; }
table.data thead th { border-bottom: 1px solid var(--axis); }
table.data .sort { align-items: flex-start; }
table.data th.num .sort, table.data th.num { text-align: right; }
table.data td.zc1, table.data td.zc2, table.data td.zc3,
table.data td.zh1, table.data td.zh2, table.data td.zh3, table.data td.z0 { border-bottom-color: var(--surface); }
table.draws td { padding: 4px 6px; }
table.draws .ball { width: 26px; height: 26px; font-size: 0.8rem; }
.date { color: var(--ink-2); }

/* Draws pager */
.draws-top { scroll-margin-top: 150px; }
.pager { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 4px 0 12px; }
.pager + .scroll + .pager, .scroll + .pager { margin: 12px 0 0; }
.page-info { font-size: 0.85rem; color: var(--ink-2); padding: 0 8px; }
.page-info strong { color: var(--ink); font-weight: 600; }
.page-btn {
  height: 34px;
  padding: 0 12px;
  border: 1px solid var(--axis);
  border-radius: 8px;
  background: var(--surface);
  cursor: pointer;
  font-size: 0.9rem;
}
.page-btn:hover:not(:disabled) { border-color: var(--ink-2); background: var(--plane); }
.page-btn:disabled { color: var(--muted); border-color: var(--grid); cursor: default; }
.page-btn:focus-visible { outline: 2px solid var(--series-1); outline-offset: 1px; }

/* Charts */
.chart-box { width: 100%; margin-bottom: 16px; }
.chart-note { font-size: 0.8rem; color: var(--ink-2); margin-bottom: 6px; }
.chart-note .key-line { display: inline-block; width: 16px; height: 0; border-top: 1.5px solid var(--ink-2); vertical-align: middle; margin-right: 4px; }
.chart-note .key-band { display: inline-block; width: 16px; height: 10px; background: var(--z0); vertical-align: middle; margin: 0 4px 0 12px; border-radius: 2px; }
.chart { display: block; overflow: visible; }
.gridline { stroke: var(--grid); stroke-width: 1; }
.baseline { stroke: var(--axis); stroke-width: 1; }
.tick { fill: var(--muted); font-size: 11px; }
.normal-band { fill: var(--z0); opacity: 0.8; }
.ref { stroke: var(--ink-2); stroke-width: 1.5; }
.col.actual { fill: var(--series-1); }
.expected-tick { stroke: var(--ink); stroke-width: 2; stroke-linecap: round; }
.hit { fill: transparent; cursor: default; }
.hit.is-hover { fill: rgba(11, 11, 11, 0.05); }

.bar-legend { display: flex; gap: 16px; list-style: none; padding: 0; margin: 0 0 12px; font-size: 0.8rem; color: var(--ink-2); }
.bar-legend li { display: flex; align-items: center; gap: 6px; }
.key-bar { width: 14px; height: 10px; border-radius: 0 3px 3px 0; background: var(--series-1); }
.key-tick { width: 2px; height: 14px; border-radius: 1px; background: var(--ink); }

.split-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); gap: 24px; }
table.split .bar-col { width: 40%; min-width: 140px; }
.bar-track { position: relative; display: block; height: 14px; }
.bar-fill {
  position: absolute;
  left: 0;
  top: 2px;
  height: 10px;
  border-radius: 0 4px 4px 0;
  background: var(--series-1);
}
.bar-tick {
  position: absolute;
  top: 0;
  width: 2px;
  height: 14px;
  margin-left: -1px;
  border-radius: 1px;
  background: var(--ink);
}
details { margin-top: 8px; }
summary { cursor: pointer; color: var(--ink-2); font-size: 0.9rem; margin-bottom: 8px; }

/* Stat tiles */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr)); gap: 12px; }
.tile {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--plane);
}
.tile-label { font-size: 0.8rem; color: var(--ink-2); }
.tile-value { font-size: 1.25rem; font-weight: 650; }
.tile-detail { font-size: 0.8rem; color: var(--ink-2); }

/* About */
.prose { max-width: 72ch; }
.prose h2 { margin-top: 28px; }
.prose h2:first-child { margin-top: 0; }
.prose p { margin-bottom: 12px; color: var(--ink-2); }
.prose table { margin: 8px 0 12px; }
blockquote { margin: 28px 0 0; padding: 4px 0 4px 16px; border-left: 3px solid var(--grid); font-style: italic; }
blockquote footer { font-style: normal; font-size: 0.85rem; color: var(--muted); }

/* Tooltip */
.tip {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  gap: 1px;
  max-width: 280px;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--ink);
  color: #c3c2b7;
  font-size: 0.8rem;
  pointer-events: none;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.18);
}
.tip[hidden] { display: none; }
.tip strong { color: #fff; font-size: 0.95rem; }

.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

@media (max-width: 720px) {
  .filters { position: static; }
  .page-info { order: -1; width: 100%; padding: 0; }
  .matrix-grid { grid-template-columns: minmax(0, auto); gap: 32px; }
  .brand img { width: 104px; }
  .legend-scale li { min-width: 38px; }
  table.matrix td, table.matrix thead th { min-width: 40px; padding-left: 4px; padding-right: 4px; }
}

/* Site footer (shared look with the homepage) */
body { min-height: 100vh; display: flex; flex-direction: column; }
main.wrap { flex: 1; width: 100%; }
.site-footer { background: var(--red-ball); color: #fff; }
.site-footer-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 24px;
  padding-top: 18px;
  padding-bottom: 18px;
  font-size: 0.85rem;
}
.footer-links a { color: inherit; text-decoration: none; }
.footer-links a:hover { text-decoration: underline; text-underline-offset: 0.2em; }
.footer-links a:focus-visible { outline: 2px solid currentColor; outline-offset: 2px; }
.footer-links .sep { opacity: 0.6; padding: 0 6px; }
.sl-credit {
  font: inherit;
  color: inherit;
  text-decoration: none;
  text-transform: none;
  letter-spacing: normal;
  white-space: nowrap;
}
.sl-credit:hover {
  text-decoration: underline;
  text-underline-offset: 0.2em;
}
.sl-credit:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 2px;
}

/* Mega Ball */
.ball-gold { background: #f5b800; color: #0b0b0b; }

/* Game switcher under the page title */
.game-nav { display: flex; gap: 6px; margin-top: 6px; }
.game-nav a {
  padding: 2px 10px;
  border: 1px solid var(--axis);
  border-radius: 999px;
  font-size: 0.8rem;
  color: var(--ink-2);
  text-decoration: none;
}
.game-nav a:hover { color: var(--ink); border-color: var(--ink-2); }
.game-nav a[aria-current="page"] { background: var(--ink); border-color: var(--ink); color: var(--surface); }
.game-nav a:focus-visible { outline: 2px solid var(--series-1); outline-offset: 2px; }
