:root {
  --bg: #f6f5f3;
  --surface: #ffffff;
  --text: #1c1b1f;
  --muted: #6b6870;
  --border: #e4e1e6;
  --accent: #b3264f;
  --accent-soft: #f6dfe6;
  --cold: #3b6fb6;
  --neutral: #eceaee;
  --hot: #c2185b;
  --ball: #ffffff;
  --ball-text: #1c1b1f;
  --ball-border: #cfcbd3;
  --pb: #d32f2f;
  --mega: #e0a800;
  --mega-text: #1c1b1f;
  --shadow: 0 1px 2px rgba(20, 10, 30, .06), 0 4px 16px rgba(20, 10, 30, .04);
  --radius: 14px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #131216;
    --surface: #1d1c21;
    --text: #ece9ef;
    --muted: #a19da8;
    --border: #2f2d35;
    --accent: #f06292;
    --accent-soft: #3a1e2a;
    --cold: #6f9fe0;
    --neutral: #2a2830;
    --hot: #f06292;
    --ball: #2a2830;
    --ball-text: #ece9ef;
    --ball-border: #45424d;
    --pb: #ef5350;
    --mega: #f2c230;
    --mega-text: #1c1b1f;
    --shadow: none;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #131216;
  --surface: #1d1c21;
  --text: #ece9ef;
  --muted: #a19da8;
  --border: #2f2d35;
  --accent: #f06292;
  --accent-soft: #3a1e2a;
  --cold: #6f9fe0;
  --neutral: #2a2830;
  --hot: #f06292;
  --ball: #2a2830;
  --ball-text: #ece9ef;
  --ball-border: #45424d;
  --pb: #ef5350;
  --mega: #f2c230;
  --mega-text: #1c1b1f;
  --shadow: none;
  color-scheme: dark;
}

* { box-sizing: border-box; }

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

.wrap { max-width: 1120px; margin: 0 auto; padding: 0 16px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
h1 { font-size: 28px; font-weight: 700; letter-spacing: -.01em; }
h2 { font-size: 17px; font-weight: 600; }
h3 { font-size: 13px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 10px; }

/* Top bar */
.topbar { background: var(--surface); border-bottom: 1px solid var(--border); }
.topbar-inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; height: 56px; }
.brand { font-weight: 700; color: var(--text); text-decoration: none; }
.nav { display: flex; gap: 4px; }
.nav a { color: var(--muted); text-decoration: none; padding: 6px 10px; border-radius: 8px; font-weight: 500; }
.nav a:hover { color: var(--text); background: var(--neutral); }
.nav a[aria-current="page"] { color: var(--accent); background: var(--accent-soft); }

/* Page head */
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px; margin: 28px 0 20px; }
.page-head p { margin: 4px 0 0; }
.page-title { display: flex; align-items: center; gap: 6px; }
/* The icon image has a light square background; clip to just the ball so it sits cleanly on dark backgrounds too. */
.page-title .logo { width: 44px; height: 44px; flex: none; margin: -4px 0 -4px -4px; clip-path: circle(41%); }
.controls { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }

.segmented { display: inline-flex; background: var(--neutral); border-radius: 10px; padding: 3px; }
.segmented button {
  border: 0; background: transparent; color: var(--muted); font: inherit; font-weight: 600;
  padding: 7px 14px; border-radius: 8px; cursor: pointer;
}
.segmented button[aria-selected="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

.select { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.select select {
  font: inherit; font-size: 14px; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 8px; padding: 7px 10px;
}

/* Tiles */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; margin-bottom: 16px; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.tile .label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; font-weight: 600; }
.tile .value { font-size: 24px; font-weight: 700; margin-top: 6px; font-variant-numeric: tabular-nums; }
.tile .sub { font-size: 13px; color: var(--muted); margin-top: 2px; }

/* Cards */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; margin-bottom: 16px; box-shadow: var(--shadow); min-width: 0; }
.card-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; margin-bottom: 12px; }
.card > p.small { margin: -4px 0 14px; }
.two-col { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; }
.two-col .card { margin-bottom: 16px; }

/* Balls */
.balls { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.ball {
  width: 32px; height: 32px; border-radius: 50%; display: inline-grid; place-items: center;
  background: var(--ball); color: var(--ball-text); border: 1.5px solid var(--ball-border);
  font: 600 13px/1 "JetBrains Mono", ui-monospace, monospace; font-variant-numeric: tabular-nums;
}
.ball.bonus.powerball { background: var(--pb); border-color: var(--pb); color: #fff; }
.ball.bonus.megamillions { background: var(--mega); border-color: var(--mega); color: var(--mega-text); }
.ball.sm { width: 26px; height: 26px; font-size: 11px; }
.mult { font-size: 12px; font-weight: 600; color: var(--muted); background: var(--neutral); border-radius: 6px; padding: 2px 7px; margin-left: 4px; }

/* Latest draws */
.draws { list-style: none; margin: 0; padding: 0; }
.draws li { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; padding: 10px 0; border-top: 1px solid var(--border); }
.draws li:first-child { border-top: 0; padding-top: 0; }
.draws .date { width: 120px; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.draws li:first-child .ball:not(.bonus) { border-color: var(--accent); }

/* Heatmaps */
.legend { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }
.legend-bar { width: 120px; height: 10px; border-radius: 5px; background: linear-gradient(90deg, var(--cold), var(--neutral), var(--hot)); }
.heat-grids { display: grid; grid-template-columns: minmax(0, 2.3fr) minmax(0, 1fr); gap: 24px; }
.heat { display: grid; grid-template-columns: repeat(10, minmax(0, 1fr)); gap: 4px; }
#bonusHeat { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.cell {
  position: relative; aspect-ratio: 1; border-radius: 8px; display: grid; place-items: center;
  font: 600 13px/1 "JetBrains Mono", ui-monospace, monospace; font-variant-numeric: tabular-nums;
  background: var(--neutral); color: var(--text); cursor: default; outline-offset: 2px;
}
.cell.dark-text { color: #1c1b1f; }
.cell.light-text { color: #fff; }
.cell .n { font-size: 9px; font-weight: 500; position: absolute; bottom: 3px; opacity: .8; }
.cell:hover, .cell:focus-visible { outline: 2px solid var(--text); }

.tooltip {
  position: fixed; z-index: 10; pointer-events: none; background: var(--text); color: var(--bg);
  font-size: 12px; padding: 6px 9px; border-radius: 6px; white-space: nowrap; transform: translate(-50%, calc(-100% - 8px));
}

/* Bars */
.hotcold { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.bars, .dist { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.bars li, .dist li { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 8px; font-size: 13px; }
.track { display: block; height: 8px; background: var(--neutral); border-radius: 4px; overflow: hidden; }
.fill { display: block; height: 100%; border-radius: 4px; background: var(--hot); }
.bars.cold .fill, #coldList .fill { background: var(--cold); }
.count { font-variant-numeric: tabular-nums; color: var(--muted); min-width: 28px; text-align: right; }
.dist li { grid-template-columns: 90px 1fr 48px; }
.dist .fill { background: var(--accent); }

/* Overdue */
.overdue { width: 100%; border-collapse: collapse; font-size: 14px; }
.overdue th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; padding: 0 0 8px; }
.overdue td { padding: 6px 0; border-top: 1px solid var(--border); font-variant-numeric: tabular-nums; }
.overdue td:nth-child(2) { font-weight: 600; }

/* Monthly */
.months { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 16px; }
.month h4 { margin: 8px 0 0; font-size: 12px; font-weight: 600; color: var(--muted); text-align: center; }
.mini { display: grid; grid-template-columns: repeat(10, 1fr); gap: 2px; }
.mini span { aspect-ratio: 1; border-radius: 2px; background: var(--neutral); }

/* States */
.skeleton { background: linear-gradient(90deg, var(--neutral) 25%, var(--border) 50%, var(--neutral) 75%); background-size: 200% 100%; animation: shimmer 1.2s infinite; border-radius: 8px; }
@keyframes shimmer { to { background-position: -200% 0; } }
.error { color: var(--pb); }

.intro { margin: 6px 0 0; max-width: 620px; }
.back-link { color: var(--accent); font-weight: 600; }

/* About section */
.about h2 { margin-bottom: 4px; }
.about h3 { margin: 18px 0 4px; font-size: 15px; color: var(--text); text-transform: none; letter-spacing: 0; }
.about p { margin: 0; max-width: 760px; color: var(--muted); }

/* Contact page */
.contact .page-head p { max-width: 560px; }
.email-card h3 { margin-bottom: 8px; }
.email-row { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-bottom: 8px; }
.email-link { font-size: 22px; font-weight: 700; color: var(--accent); text-decoration: none; word-break: break-all; }
.email-link:hover { text-decoration: underline; }
.copy-btn {
  font: inherit; font-size: 13px; font-weight: 600; color: var(--text); background: var(--neutral);
  border: 1px solid var(--border); border-radius: 8px; padding: 6px 12px; cursor: pointer; min-width: 76px;
}
.copy-btn:hover { border-color: var(--muted); }
.email-card p.small { margin: 0; }
.topics { margin: 0; padding-left: 18px; display: grid; gap: 10px; }
.topics-note { margin: 0; }
.contact a:not(.email-link):not(.brand) { color: var(--accent); }

.disclaimer { font-size: 12px; color: var(--muted); margin: 8px 0 40px; max-width: 760px; }

@media (max-width: 720px) {
  .heat-grids { grid-template-columns: 1fr; }
  #bonusHeat { grid-template-columns: repeat(10, minmax(0, 1fr)); }
  .cell { font-size: 11px; border-radius: 6px; }
  .cell .n { display: none; }
  .hotcold { grid-template-columns: 1fr; }
  .two-col { grid-template-columns: 1fr; }
  .draws .date { width: 100%; }
  h1 { font-size: 24px; }
}

@media (prefers-reduced-motion: reduce) {
  .skeleton { animation: none; }
}
