:root {
  --bg: #f5f3ee;
  --surface: #ffffff;
  --ink: #1c1f24;
  --muted: #5f6672;
  --line: #e2ded5;
  --brand: #0f5c55;
  --brand-ink: #ffffff;
  --win: #157a3c;
  --win-bg: #e5f4ea;
  --lose-bg: #eeece6;
  --wait: #1d4f91;
  --wait-bg: #e6eef9;
  --flag: #d9730d;
  --flag-bg: #fff3e4;
  --pb: #d7262e;
  --mm: #e7b416;
  --mm-ink: #1c1f24;
  --hit: #0f5c55;
  --radius: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121416; --surface: #1b1e22; --ink: #eceae4; --muted: #9aa1ab; --line: #2c3036;
    --brand: #3fb4a6; --brand-ink: #0c1413; --win: #5fd28a; --win-bg: #15291d; --lose-bg: #1f2226;
    --wait: #8fb7ee; --wait-bg: #172235; --flag: #f3a14e; --flag-bg: #2d2214; --hit: #3fb4a6;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #121416; --surface: #1b1e22; --ink: #eceae4; --muted: #9aa1ab; --line: #2c3036;
  --brand: #3fb4a6; --brand-ink: #0c1413; --win: #5fd28a; --win-bg: #15291d; --lose-bg: #1f2226;
  --wait: #8fb7ee; --wait-bg: #172235; --flag: #f3a14e; --flag-bg: #2d2214; --hit: #3fb4a6;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100dvh; display: flex; flex-direction: column;
}
main { width: 100%; max-width: 560px; margin: 0 auto; padding: 0 16px 24px; flex: 1; }
h1, h2, h3 { line-height: 1.2; margin: 0; }
[hidden] { display: none !important; }
.muted { color: var(--muted); font-weight: 400; }

.top {
  display: flex; align-items: center; justify-content: space-between;
  max-width: 560px; width: 100%; margin: 0 auto; padding: 14px 16px;
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; color: var(--ink); text-decoration: none; }
.net { font-size: 13px; padding: 2px 10px; border-radius: 99px; background: var(--lose-bg); color: var(--muted); }

/* Home */
.home { text-align: center; padding-top: 6vh; }
.home h1 { font-size: clamp(30px, 8vw, 42px); letter-spacing: -0.02em; }
.lede { color: var(--muted); margin: 12px auto 28px; max-width: 34ch; }
.lede strong { color: var(--ink); font-weight: 600; }

.scan-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%; max-width: 360px; min-height: 64px; padding: 0 24px;
  background: var(--brand); color: var(--brand-ink); border-radius: 999px;
  font-size: 20px; font-weight: 700; cursor: pointer; user-select: none;
  box-shadow: 0 6px 20px color-mix(in srgb, var(--brand) 35%, transparent);
  transition: transform .12s ease;
}
.scan-btn:active { transform: scale(.98); }
.scan-btn:focus-within { outline: 3px solid color-mix(in srgb, var(--brand) 45%, transparent); outline-offset: 3px; }
.scan-btn svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linejoin: round; }
.scan-btn.small { min-height: 52px; font-size: 17px; max-width: 300px; box-shadow: none; }

.link {
  display: inline-block; margin-top: 14px; background: none; border: 0; padding: 6px 8px;
  color: var(--brand); font: inherit; font-weight: 600; cursor: pointer; text-decoration: underline; text-underline-offset: 3px;
}
.hint { color: var(--muted); font-size: 14px; margin: 4px 0 0; }
@media (pointer: coarse) { .desktop-only { display: none; } }

.latest { display: grid; gap: 12px; margin-top: 40px; text-align: left; }

/* Cards and balls */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-top: 14px; }
.card h3 { font-size: 16px; display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: baseline; }
.card.mini h3 { font-size: 15px; }
.card p { margin: 8px 0 0; }

.balls { display: flex; gap: 6px; flex-wrap: nowrap; align-items: center; }
.balls.static { margin-top: 10px; }
.ball {
  --size: 40px;
  width: var(--size); height: var(--size); border-radius: 50%; flex: none;
  display: inline-grid; place-items: center; text-align: center;
  border: 2px solid var(--line); background: var(--surface); color: var(--ink);
  font: 700 16px/1 ui-monospace, "SF Mono", Menlo, monospace; padding: 0;
}
.ball.bonus.powerball { background: var(--pb); border-color: var(--pb); color: #fff; margin-left: 6px; }
.ball.bonus.megamillions { background: var(--mm); border-color: var(--mm); color: var(--mm-ink); margin-left: 6px; }
input.ball { appearance: none; -moz-appearance: textfield; }
input.ball:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 30%, transparent); }
.ball.hit { background: var(--hit); border-color: var(--hit); color: var(--brand-ink); }
.ball.bonus.hit { box-shadow: 0 0 0 3px var(--surface), 0 0 0 5px var(--hit); }
.ball.flag { border: 2px dashed var(--flag); background: var(--flag-bg); color: var(--ink); }

/* Busy */
.busy { text-align: center; padding-top: 6vh; }
.busy img { max-width: 70%; max-height: 42vh; border-radius: 10px; box-shadow: 0 8px 30px rgb(0 0 0 / .15); }
.busy p { font-weight: 600; margin: 18px 0 10px; }
.bar { height: 6px; background: var(--line); border-radius: 99px; overflow: hidden; max-width: 280px; margin: 0 auto; }
.bar div { height: 100%; width: 0; background: var(--brand); transition: width .3s ease; }

/* Result */
.verdict { border-radius: var(--radius); padding: 20px 18px; margin-top: 8px; }
.verdict h2 { font-size: 28px; letter-spacing: -0.01em; }
.verdict h2 small { display: block; font-size: 14px; font-weight: 500; margin-top: 4px; }
.verdict p { margin: 8px 0 0; }
.verdict.win { background: var(--win-bg); color: var(--win); }
.verdict.win p { color: var(--ink); }
.verdict.lose { background: var(--lose-bg); }
.verdict.lose p { color: var(--muted); }
.verdict.wait { background: var(--wait-bg); color: var(--wait); }
.verdict.wait p { color: var(--ink); }

.warn { background: var(--flag-bg); border-radius: 10px; padding: 10px 14px 10px 30px; margin: 12px 0 0; font-size: 14px; }
.flag-note { color: var(--flag); font-size: 14px; font-weight: 600; }

.fields { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: flex-end; }
.fields label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); font-weight: 600; }
.fields label.check { display: flex; align-items: center; gap: 6px; color: var(--ink); font-size: 15px; min-height: 40px; }
.fields select, .fields input[type=date], .fields input[type=number] {
  font: inherit; color: var(--ink); background: var(--bg); border: 1px solid var(--line);
  border-radius: 8px; padding: 7px 8px; min-height: 40px;
}
.fields input[type=number] { width: 64px; }
.fields input[type=checkbox] { width: 20px; height: 20px; accent-color: var(--brand); }

.lines { list-style: none; padding: 0; margin: 14px 0 0; display: grid; gap: 10px; }
.lines li { display: grid; grid-template-columns: 18px auto 1fr 28px; align-items: center; gap: 8px; }
.lines .label { font-weight: 700; color: var(--muted); }
.lines .prize { font-weight: 700; color: var(--win); text-align: right; white-space: nowrap; }
.del { background: none; border: 0; color: var(--muted); font-size: 22px; cursor: pointer; padding: 0; width: 28px; height: 28px; border-radius: 50%; }
.del:hover { background: var(--lose-bg); }

.wins { margin: 10px 0 0; padding-left: 18px; }
.wins strong { color: var(--win); }

.actions { display: flex; flex-direction: column; align-items: center; margin-top: 22px; }

.debug { margin-top: 24px; font-size: 13px; color: var(--muted); }
.debug summary { cursor: pointer; }
.debug pre { white-space: pre-wrap; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 10px; overflow-x: auto; }

.foot { max-width: 560px; margin: 0 auto; padding: 16px 16px 28px; font-size: 13px; color: var(--muted); text-align: center; }
.foot p { margin: 4px 0; }

/* Phones: shrink balls so a full line fits at 320px wide */
@media (max-width: 420px) {
  .ball { --size: 34px; font-size: 14px; }
  .balls { gap: 4px; }
  .ball.bonus.powerball, .ball.bonus.megamillions { margin-left: 3px; }
  .lines li { grid-template-columns: 14px auto 1fr 24px; gap: 6px; }
}
@media (max-width: 350px) {
  .ball { --size: 30px; font-size: 13px; }
}
