:root {
  color-scheme: light;
  --bg: #f6f8f9;
  --surface: #ffffff;
  --soft: #e7eef1;
  --ink: #192d39;
  --muted: #465e6c;
  --line: #bdcbd0;
  --accent: #9b4020;
  --on-accent: #fff;
  --accent-soft: #f7e9df;
  --danger: #98252f;
  --shadow: rgb(24 48 59 / 16%);
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #11212a;
  --surface: #192e39;
  --soft: #203945;
  --ink: #edf3f4;
  --muted: #b2c6ce;
  --line: #49616d;
  --accent: #ffc18a;
  --on-accent: #302112;
  --accent-soft: #413728;
  --danger: #ffa8a8;
  --shadow: rgb(0 0 0 / 35%);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    color-scheme: dark; --bg: #11212a; --surface: #192e39; --soft: #203945;
    --ink: #edf3f4; --muted: #b2c6ce; --line: #49616d; --accent: #ffc18a;
    --on-accent: #302112; --accent-soft: #413728; --danger: #ffa8a8; --shadow: rgb(0 0 0 / 35%);
  }
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-variant-numeric: tabular-nums;
}
[hidden] { display: none !important; }
a { color: var(--accent); text-underline-offset: .18em; }
a:hover { text-decoration-thickness: 2px; }
button, input { font: inherit; color: inherit; }
button {
  min-height: 44px;
  padding: 8px 15px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  font-weight: 590;
  line-height: 1.35;
}
button:not(:disabled):hover { border-color: var(--accent); color: var(--accent); }
button:not(:disabled):active { background: var(--accent-soft); }
button:disabled { color: var(--muted); border-style: dashed; cursor: default; }
button.primary { color: var(--on-accent); background: var(--accent); border-color: var(--accent); }
button.primary:not(:disabled):hover { color: var(--on-accent); box-shadow: inset 0 0 0 1px var(--on-accent); }
button.primary:disabled { background: var(--soft); border-color: var(--line); color: var(--muted); }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
h1, h2, h3, h4, p, figure, dl, dd { margin: 0; }
h1, h2, h3, h4 { text-wrap: balance; }
h1 { font-size: clamp(2.35rem, 4.4vw, 3.9rem); line-height: 1.04; font-weight: 640; letter-spacing: -.057em; }
h2 { font-size: clamp(1.35rem, 2.2vw, 1.78rem); line-height: 1.15; font-weight: 650; letter-spacing: -.038em; }
h3 { font-size: 1.19rem; line-height: 1.26; letter-spacing: -.027em; }
h4 { font-size: 1rem; line-height: 1.35; }
fieldset { min-width: 0; margin: 0; padding: 0; border: 0; }
legend { padding: 0; }
.wrap { width: min(1240px, calc(100% - 2 * clamp(16px, 4vw, 64px))); margin-inline: auto; }
.skip-link, .visually-hidden {
  width: 1px; height: 1px; overflow: hidden; position: absolute;
  clip-path: inset(50%); white-space: nowrap;
}
.skip-link:focus {
  z-index: 20; top: 8px; left: 8px; width: auto; height: auto;
  padding: 12px 16px; clip-path: none; background: var(--surface);
}
.masthead { border-bottom: 1px solid var(--line); background: var(--surface); }
.masthead-inner, .masthead nav, .theme-inner, .footer-inner {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
.masthead-inner { min-height: 68px; }
.masthead a, .theme-open {
  display: inline-flex; align-items: center; min-height: 44px;
  color: var(--ink); text-decoration: none; font-size: 15px;
}
.masthead a:hover, .masthead a[aria-current="page"] { color: var(--accent); }
.masthead .wordmark { gap: 9px; font-weight: 700; font-size: 18px; letter-spacing: -.04em; }
.mark {
  display: inline-grid; place-items: center; width: 31px; height: 31px;
  background: var(--ink); color: var(--surface); border-radius: 4px;
  font: 680 28px/1 system-ui, sans-serif;
}
.theme-open { border-color: transparent; background: transparent; gap: 6px; font-weight: 500; }
.theme-open span { color: var(--muted); font-size: 19px; }
.theme-choice { background: var(--soft); border-bottom: 1px solid var(--line); }
.theme-inner { min-height: 58px; padding-block: 5px; font-size: 14px; }
.theme-inner [data-system-theme] { color: var(--muted); }
.theme-buttons { display: flex; flex-wrap: wrap; gap: 3px; }
.theme-buttons button { background: transparent; border-color: transparent; font-size: 14px; padding-inline: 12px; }
.theme-buttons button[aria-pressed="true"] { color: var(--ink); border-color: var(--line); background: var(--surface); }
.intro { margin-block: clamp(32px, 4.2vw, 64px) clamp(24px, 3vw, 44px); }
.intro p { max-width: 62ch; margin-top: 12px; color: var(--muted); font-size: clamp(1rem, 1.4vw, 1.2rem); }
.workspace {
  display: grid; grid-template-columns: minmax(290px, .78fr) minmax(0, 1.8fr);
  border: 1px solid var(--line); background: var(--surface); border-radius: 8px;
}
.settings, .results { min-width: 0; padding: clamp(20px, 2.45vw, 36px); }
.settings { border-right: 1px solid var(--line); border-radius: 7px 0 0 7px; background: var(--soft); }
.field-heading, .section-heading, .result-actions { display: flex; align-items: center; gap: 6px; }
.field-heading { margin-top: 14px; }
.field-heading label, .criteria legend, .seed-label, .import-label { font-weight: 650; }
.budget-box {
  display: flex; align-items: center; gap: 8px; width: 100%; padding-right: 15px;
  border: 1px solid var(--muted); border-radius: 5px; background: var(--surface); color: var(--muted);
}
.budget-box input {
  width: 100%; min-width: 0; min-height: 56px; padding: 4px 13px; color: var(--ink); border: 0;
  border-radius: 5px; background: transparent; font-size: 29px; font-weight: 600; letter-spacing: -.035em;
}
.budget-box:focus-within { border-color: var(--accent); }
.budget-box input:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
.hint, .section-lead, .empty-state { color: var(--muted); }
.hint { font-size: 14px; line-height: 1.45; margin-top: 7px; }
.hint:empty, #active-options:empty, #metric-notes:empty { display: none; }
.criteria { margin-top: 24px; }
.criteria legend { margin-bottom: 7px; line-height: 1.35; letter-spacing: -.015em; }
.option-row { display: flex; align-items: center; gap: 4px; border-top: 1px solid var(--line); }
.option-row label, .check-label, .game-list label {
  display: flex; align-items: center; gap: 9px; min-height: 44px; padding-block: 5px;
  line-height: 1.36; font-size: 15px; cursor: pointer;
}
.option-row label { flex: 1; }
.option-row label { display: grid; grid-template-columns: 18px minmax(0, 1fr); column-gap: 9px; }
.option-row label small { grid-column: 2; color: var(--muted); font-size: 13px; line-height: 1.4; }
input[type="checkbox"] { margin: 0; flex: 0 0 auto; width: 18px; height: 18px; accent-color: var(--accent); cursor: pointer; }
.help-trigger {
  display: inline-grid; place-items: center; width: 44px; height: 44px; flex: 0 0 44px; padding: 0;
  border-color: transparent; background: transparent; color: var(--muted);
}
.help-trigger span {
  display: grid; place-items: center; width: 18px; height: 18px;
  border: 1px solid currentColor; border-radius: 50%; font: 650 14px/1 Georgia, serif;
}
.help-trigger[aria-expanded="true"] { color: var(--accent); background: var(--accent-soft); }
summary {
  display: flex; justify-content: space-between; align-items: center; min-height: 48px;
  padding-block: 8px; gap: 12px; cursor: pointer; list-style: none; font-weight: 610;
}
summary::-webkit-details-marker { display: none; }
summary::after {
  content: ""; width: 8px; height: 8px; flex: 0 0 8px; margin: 0 4px 4px 0;
  border-bottom: 1.5px solid; border-right: 1.5px solid; transform: rotate(45deg); color: var(--muted);
}
details[open] > summary::after { margin-bottom: -4px; transform: rotate(225deg); }
summary:hover { color: var(--accent); }
.rail-detail { border-top: 1px solid var(--line); }
.criteria + .rail-detail { margin-top: 20px; }
.rail-detail[open] { padding-bottom: 12px; }
.game-list label { gap: 8px; }
.game-list small, .badge {
  display: inline-block; padding: 2px 7px; border: 1px solid var(--line); border-radius: 4px;
  color: var(--muted); background: var(--surface); font-size: 14px; line-height: 1.4;
}
.game-list small { margin-left: auto; }
.seed-label, .import-label { display: block; font-size: 15px; margin: 14px 0 5px; }
#seed { border: 1px solid var(--muted); border-radius: 4px; min-height: 44px; width: 100%; padding: 6px 10px; background: var(--surface); }
.run-actions { display: grid; gap: 8px; margin-top: 14px; }
progress { width: 100%; height: 14px; accent-color: var(--accent); }
#analysis-errors, .notice, .warning { margin-block: 12px; padding: 10px 13px; border-inline-start: 3px solid var(--accent); background: var(--accent-soft); }
#analysis-errors { color: var(--danger); border-color: var(--danger); }
.section-lead { max-width: 62ch; margin: 7px 0 20px; }
#chart { min-width: 0; margin-block: 20px 26px; }
.chart-empty {
  min-height: clamp(130px, 14vw, 205px); display: grid; place-items: center;
  padding: 18px; border: 1px solid var(--line); border-bottom: 2px solid var(--muted); border-radius: 4px;
  background-color: var(--bg);
  background-image: linear-gradient(to right, color-mix(in srgb, var(--line) 54%, transparent) 1px, transparent 1px),
    linear-gradient(to bottom, color-mix(in srgb, var(--line) 54%, transparent) 1px, transparent 1px);
  background-size: 28px 28px;
}
.chart-empty p { padding: 6px 11px; background: var(--bg); color: var(--muted); text-align: center; font-size: 15px; }
#chart svg { display: block; max-width: 100%; height: auto; }
#chart svg text { font-size: 16px; }
@media(max-width:600px){#chart svg text{font-size:32px}}
.goal-list { margin-top: 12px; border-top: 2px solid var(--ink); }
.goal-list > div { display: grid; grid-template-columns: minmax(120px, .8fr) minmax(0, 1.4fr); gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.goal-list dt { font-weight: 600; }
.goal-list dd { color: var(--muted); }
#result-summary, #active-options, #metric-notes { overflow-wrap: anywhere; }
#result-summary { margin-block: 12px; padding-block: 12px; border-block: 1px solid var(--line); }
#active-options, #metric-notes { color: var(--muted); font-size: 15px; }
#portfolio-results { min-width: 0; }
.portfolio { padding: 18px 0; border-top: 1px solid var(--line); min-width: 0; overflow-wrap: anywhere; }
.portfolio-selected { border-inline-start: 3px solid var(--accent); padding-inline-start: 13px; }
.portfolio-top { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px; }
.portfolio-top p, .portfolio > p, .portfolio .allocation-list { margin-top: 7px; }
.portfolio-metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(155px, 100%), 1fr)); gap: 10px; margin-block: 14px; }
.metric { min-width: 0; padding: 10px; border-block-start: 2px solid var(--line); background: var(--bg); }
.metric > :is(span, strong, small) { display: block; }
.metric small { color: var(--muted); font-size: 14px; }
.allocation-list, .portfolio ul, #source-list ul { padding-inline-start: 20px; }
#chart, .table-scroll { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; text-align: left; font-size: 15px; }
.data-table th, .data-table td { padding: 9px 10px; vertical-align: top; border-bottom: 1px solid var(--line); }
.data-table thead th { border-top: 2px solid var(--ink); background: var(--soft); }
.comparison-panel { padding-block: 16px; border-top: 1px solid var(--line); overflow-wrap: anywhere; }
.comparison-panel p + p, .comparison-panel p + button { margin-top: 10px; }
.comparison-panel > p { max-width: 78ch; }
.comparison-scroll { margin-block: 14px; border: 1px solid var(--line); border-radius: 4px; }
.comparison-table { min-width: 58rem; font-variant-numeric: tabular-nums; }
.comparison-table caption { text-align: left; padding: 10px; color: var(--muted); background: var(--bg); }
.comparison-table tbody th { min-width: 7rem; }
.comparison-table th { overflow-wrap: normal; }
.comparison-table td:nth-child(2) { white-space: nowrap; }
.comparison-table button { white-space: nowrap; }
.comparison-scroll:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.details-section { padding-block: clamp(28px, 3vw, 42px) clamp(42px, 6vw, 78px); }
.details-section > h2 { margin-bottom: 18px; }
.details-section > details { padding-inline: clamp(16px, 2.4vw, 32px); border: 1px solid var(--line); background: var(--surface); }
.details-section > details + details { border-top: 0; }
.details-section > details:first-of-type { border-radius: 6px 6px 0 0; }
.details-section > details:last-child { border-radius: 0 0 6px 6px; }
.details-section summary { min-height: 56px; font-size: 17px; }
.detail-body { min-width: 0; padding-block: 2px 18px; overflow-wrap: anywhere; }
.detail-body p + p { margin-top: 8px; }
.jackpot-panel { padding-block: 18px; border-bottom: 1px solid var(--line); }
.jackpot-panel > .hint { max-width: 70ch; }
.jackpot-panel > button { margin-top: 12px; }
#jackpot-status:not(:empty) { margin-top: 12px; }
#jackpot-results { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 23rem), 1fr)); column-gap: 28px; }
.jackpot-row { min-width: 0; margin-top: 14px; padding-top: 10px; border-top: 1px solid var(--line); }
.jackpot-heading { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 12px; }
.jackpot-heading h4 { margin: 0; font-size: 1rem; }
.jackpot-condition { color: var(--muted); font-size: 0.875rem; }
.jackpot-row[data-status="clock_error"] .jackpot-condition { color: var(--danger); }
.jackpot-amount { margin-block: 3px 7px; font-size: 1.25rem; }
.jackpot-amount small { display: block; color: var(--muted); font-size: 0.875rem; }
.jackpot-row dl { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 3px 12px; font-size: 0.875rem; }
.jackpot-row dt { color: var(--muted); }
.result-actions { flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.ticket-game, .source { margin-block: 10px; padding-block: 8px; border-bottom: 1px solid var(--line); }
.ticket-numbers { display: flex; align-items: center; flex-wrap: wrap; gap: 5px; margin-block: 6px; }
.ball { display: inline-grid; place-items: center; min-width: 32px; min-height: 32px; padding: 2px 5px; border-radius: 4px; border: 1px solid var(--line); background: var(--soft); font-variant-numeric: tabular-nums; }
input[type="file"] { width: 100%; max-width: 36rem; }
input::file-selector-button { min-height: 44px; padding: 7px 12px; background: var(--soft); color: var(--ink); border: 1px solid var(--line); border-radius: 4px; font: inherit; cursor: pointer; }
.site-footer { border-top: 1px solid var(--line); background: var(--surface); }
.footer-inner { min-height: 72px; padding-block: 12px; color: var(--muted); font-size: 14px; }
.site-footer a, .help-panel a, .guide-nav a, .back-link { display: inline-flex; align-items: center; min-height: 44px; }
.help-panel {
  position: fixed; z-index: 10; margin: 0; width: min(350px, calc(100vw - 24px)); padding: 18px;
  max-height: calc(100dvh - 24px); overflow: auto; overscroll-behavior: contain;
  border: 1px solid var(--line); border-top: 3px solid var(--accent); border-radius: 5px;
  background: var(--surface); color: var(--ink); box-shadow: 0 7px 22px var(--shadow);
}
.help-panel h2 { padding-right: 40px; font-size: 18px; }
.help-panel p { font-size: 15px; color: var(--muted); margin-top: 10px; }
.help-panel a { font-size: 15px; }
.help-close { position: absolute; right: 5px; top: 3px; padding: 0; width: 44px; border: 0; font-size: 23px; background: transparent; }
.guide-layout { display: grid; grid-template-columns: minmax(200px, .65fr) minmax(0, 2fr); gap: clamp(24px, 5vw, 72px); padding-bottom: 60px; }
.guide-nav { align-self: start; padding: 16px 20px; border-top: 2px solid var(--ink); background: var(--soft); }
.guide-nav h2 { font-size: 18px; margin-bottom: 5px; }
.guide-nav a { display: flex; border-bottom: 1px solid var(--line); color: var(--ink); font-size: 15px; text-decoration: none; }
.guide-nav a:hover { color: var(--accent); }
.guide-nav a:last-child { border-bottom: 0; }
.guide-content { min-width: 0; max-width: 75ch; }
.guide-content section { border-top: 1px solid var(--line); padding-block: 19px 24px; scroll-margin-top: 18px; }
.guide-content section:first-child { border-top: 2px solid var(--ink); }
.guide-content h2 { margin-bottom: 9px; font-size: 23px; }
.guide-content p + p { margin-top: 8px; }
.guide-content p, .guide-content dd { color: var(--muted); }
@media (max-width: 800px) {
  .workspace, .guide-layout { grid-template-columns: 1fr; }
  .settings { border-right: 0; border-bottom: 1px solid var(--line); border-radius: 7px 7px 0 0; }
  .guide-nav { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 16px; }
  .guide-nav h2 { grid-column: 1/-1; }
  .option-row label { font-size: 16px; }
}
@media (max-width: 600px) {
  .theme-inner, .footer-inner { align-items: flex-start; flex-direction: column; gap: 4px; }
  .theme-inner { padding-block: 10px 6px; }
  .theme-buttons button { padding-inline: 14px; }
  .masthead-inner { min-height: 62px; }
  .masthead nav { gap: 3px; }
  .theme-open { padding-inline: 6px; }
  .masthead a, .theme-open { font-size: 14px; }
  .masthead .wordmark { font-size: 16px; gap: 6px; }
  .mark { width: 26px; height: 26px; font-size: 24px; }
  .goal-list > div { grid-template-columns: 1fr; gap: 2px; }
  .result-actions { align-items: stretch; }
  .result-actions button { flex: 1 1 150px; }
}
@media (max-width: 400px) {
  .masthead-inner { flex-wrap: wrap; column-gap: 5px; row-gap: 0; padding-block: 4px; }
  .masthead nav { flex-wrap: wrap; }
  .masthead nav a, .theme-open { padding-inline: 3px; }
  .masthead .theme-open span { display: none; }
  .results, .settings { padding: 17px; }
  .guide-nav { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation: none !important; transition: none !important; }
}
