/* Ticket-stock paper, ink, a silver scratch coating for money that doesn't come back,
   green for money that does, and foil magenta reserved for the million-dollar odds. */
:root {
  --bg: #ECEFEA;
  --surface: #F7F9F5;
  --raised: #FFFFFF;
  --ink: #17202B;
  --muted: #586372;
  --line: #D2D8CF;
  --gain: #0D7658;
  --gain-soft: #D3EBE1;
  --silver: #A8B0B9;
  --silver-hi: #C9CFD5;
  --foil: #A0157D;
  --warn: #9A4A00;
  --focus: #2457D6;
  --shadow: 0 1px 0 rgba(23, 32, 43, .06), 0 8px 24px -12px rgba(23, 32, 43, .25);
  --radius-s: 4px;
  --radius-m: 10px;
  --font: "Archivo", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #11161D; --surface: #171E27; --raised: #1D2530; --ink: #E7EBF0; --muted: #9AA5B3;
    --line: #2A3441; --gain: #3CC79C; --gain-soft: #18362D; --silver: #4C5562; --silver-hi: #5D6775;
    --foil: #E46ACB; --warn: #F0A050; --focus: #7DA2FF; color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font);
  font-size: 16px; line-height: 1.5; font-variant-numeric: tabular-nums;
  padding: env(safe-area-inset-top, 0) env(safe-area-inset-right, 0) env(safe-area-inset-bottom, 0) env(safe-area-inset-left, 0);
}
a { color: inherit; text-underline-offset: 2px; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 3px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--raised); padding: 8px 12px; z-index: 50; }
.skip:focus { left: 8px; }
.muted { color: var(--muted); }

/* ---------- masthead ---------- */
.masthead {
  display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px 32px;
  max-width: 1280px; margin: 0 auto; padding: 28px 24px 16px;
}
h1 {
  margin: 0; font-stretch: 68%; font-weight: 800; font-size: clamp(2.4rem, 6vw, 4.2rem);
  line-height: .9; letter-spacing: -.01em;
}
.tagline { margin: 10px 0 0; max-width: 56ch; color: var(--muted); }
.freshness { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: .9rem; }
.freshness p { margin: 0; text-align: right; }

/* ---------- buttons & inputs ---------- */
.btn {
  font: inherit; font-weight: 600; color: var(--ink); background: var(--raised); border: 1px solid var(--line);
  border-radius: 999px; padding: 7px 14px; cursor: pointer; white-space: nowrap;
}
.btn:hover { border-color: var(--ink); }
.btn-quiet { background: transparent; }
.btn[disabled] { opacity: .55; cursor: progress; }
.link { font: inherit; color: var(--ink); background: none; border: 0; padding: 0; text-decoration: underline; text-underline-offset: 2px; cursor: pointer; }
select, input[type="search"], input[inputmode] {
  font: inherit; color: var(--ink); background: var(--raised); border: 1px solid var(--line);
  border-radius: var(--radius-s); padding: 6px 8px; min-height: 36px;
}
input[type="search"] { width: 100%; }
.check { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; white-space: nowrap; }
.check input { width: 17px; height: 17px; accent-color: var(--gain); }

/* ---------- verdict (summary) ---------- */
.verdict {
  max-width: 1280px; margin: 0 auto 8px; padding: 0 24px;
  display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: 16px;
}
.verdict-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m); padding: 18px 20px;
}
.verdict-card h2 { margin: 0 0 4px; font-size: 1rem; font-weight: 600; color: var(--muted); }
.verdict-big {
  font-stretch: 72%; font-weight: 800; font-size: clamp(1.6rem, 3.2vw, 2.3rem); line-height: 1.05; margin: 0 0 12px;
}
.verdict-big button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; text-align: left; text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 4px; }
.verdict p { margin: 8px 0 0; color: var(--muted); max-width: 70ch; }
.verdict .verdict-big { color: var(--ink); }
.verdict-card.side .verdict-big { font-size: clamp(1.3rem, 2.2vw, 1.6rem); }
.verdict .foil { color: var(--foil); }

/* The dollar: what a $1 ticket gives back (green) vs. what stays scratched off (silver). */
.dollar {
  position: relative; height: 18px; border-radius: 3px; overflow: hidden;
  background: repeating-linear-gradient(118deg, var(--silver) 0 3px, var(--silver-hi) 3px 5px);
}
.dollar .back { position: absolute; inset: 0 auto 0 0; background: var(--gain); }
.dollar .launch { position: absolute; top: -2px; bottom: -2px; width: 2px; background: var(--ink); opacity: .55; }
.dollar.big { height: 34px; border-radius: 5px; }
.dollar-legend { display: flex; justify-content: space-between; font-size: .85rem; color: var(--muted); margin-top: 6px; gap: 12px; }
.dollar-legend b { color: var(--gain); font-weight: 700; }

/* ---------- tabs ---------- */
.tabs {
  max-width: 1280px; margin: 16px auto 0; padding: 0 24px; display: flex; gap: 4px; border-bottom: 1px solid var(--line);
  overflow-x: auto; scrollbar-width: none;
}
.tabs button {
  font: inherit; font-weight: 600; color: var(--muted); background: none; border: 0; padding: 10px 14px;
  border-bottom: 3px solid transparent; margin-bottom: -1px; cursor: pointer; white-space: nowrap;
}
.tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--ink); }
main { max-width: 1280px; margin: 0 auto; padding: 0 24px 40px; }

/* ---------- controls ---------- */
.controls {
  display: flex; flex-wrap: wrap; align-items: flex-end; gap: 14px 22px; padding: 18px 0 14px;
  border-bottom: 1px solid var(--line);
}
.control-group { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; border: 0; margin: 0; padding: 0; min-width: 0; }
.control-group.grow { flex: 1 1 220px; }
.control-label { font-size: .85rem; color: var(--muted); padding: 0; }
.segmented { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; padding: 2px; background: var(--raised); }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented span { display: block; padding: 5px 12px; border-radius: 999px; cursor: pointer; font-weight: 600; font-size: .92rem; }
.segmented input:checked + span { background: var(--ink); color: var(--bg); }
.segmented input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: 1px; }
.chips { display: flex; flex-wrap: wrap; gap: 4px; }
.chip {
  font: inherit; font-size: .9rem; font-weight: 600; min-width: 42px; padding: 5px 9px; cursor: pointer;
  border: 1px dashed var(--silver); background: transparent; color: var(--ink); border-radius: var(--radius-s);
}
.chip[aria-pressed="true"] { background: var(--ink); color: var(--bg); border: 1px solid var(--ink); }
.toggles { gap: 6px 16px; }
.location { position: relative; }
.loc-panel {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 20; width: min(340px, 86vw);
  background: var(--raised); border: 1px solid var(--line); border-radius: var(--radius-m); box-shadow: var(--shadow);
  padding: 14px; display: grid; gap: 10px;
}
.loc-help { margin: 0; font-size: .88rem; color: var(--muted); }
.zip-row { display: flex; align-items: center; gap: 8px; }
.zip-row label { font-size: .9rem; white-space: nowrap; }
.zip-row input { width: 90px; }
.radius { display: flex; align-items: center; gap: 8px; font-size: .9rem; }
.loc-error { margin: 0; color: var(--warn); font-size: .88rem; min-height: 0; }
.loc-error:empty { display: none; }
#locBtn.on { background: var(--ink); color: var(--bg); border-color: var(--ink); }

.list-meta { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 12px 0 4px; font-size: .9rem; color: var(--muted); }
.list-meta p { margin: 0; }

/* ---------- game list ---------- */
.games { --cols: minmax(220px, 2.1fr) minmax(170px, 1.5fr) minmax(130px, 1fr) minmax(96px, .7fr) minmax(84px, .65fr) minmax(76px, .55fr) minmax(70px, .55fr); }
.games.with-near { --cols: minmax(220px, 2.1fr) minmax(170px, 1.5fr) minmax(130px, 1fr) minmax(96px, .7fr) minmax(84px, .65fr) minmax(76px, .55fr) minmax(70px, .55fr) minmax(76px, .6fr); }
.row { display: grid; grid-template-columns: var(--cols); gap: 18px; align-items: center; padding: 12px 10px; border-bottom: 1px solid var(--line); }
.row.head { position: sticky; top: 0; z-index: 5; background: var(--bg); padding-top: 8px; padding-bottom: 8px; align-items: end; }
.sort-btn {
  font: inherit; font-size: .82rem; font-weight: 600; color: var(--muted); background: none; border: 0; padding: 2px 0;
  cursor: pointer; text-align: left; line-height: 1.25;
}
.sort-btn[aria-sort="descending"], .sort-btn[aria-sort="ascending"] { color: var(--ink); }
.sort-btn[aria-sort="descending"]::after { content: " ▼"; font-size: .7em; }
.sort-btn[aria-sort="ascending"]::after { content: " ▲"; font-size: .7em; }
.game { cursor: pointer; border-radius: var(--radius-s); }
.game:hover { background: var(--surface); }
.game:focus-visible { outline-offset: -2px; }
.game.dim { opacity: .62; }

.g-name { display: flex; align-items: center; gap: 12px; min-width: 0; }
/* price printed like a ticket stub with notched edge */
.stub {
  flex: none; display: grid; place-items: center; width: 50px; height: 40px; font-stretch: 75%; font-weight: 800; font-size: 1.15rem;
  background: var(--raised); border: 1px solid var(--line); border-radius: 4px;
  -webkit-mask: radial-gradient(circle 5px at 0 50%, transparent 98%, #000) left / 51% 100% no-repeat,
                radial-gradient(circle 5px at 100% 50%, transparent 98%, #000) right / 51% 100% no-repeat;
          mask: radial-gradient(circle 5px at 0 50%, transparent 98%, #000) left / 51% 100% no-repeat,
                radial-gradient(circle 5px at 100% 50%, transparent 98%, #000) right / 51% 100% no-repeat;
}
.g-title { min-width: 0; }
.g-title strong { display: block; font-weight: 700; line-height: 1.2; overflow-wrap: anywhere; }
.g-sub { display: flex; flex-wrap: wrap; gap: 4px 8px; font-size: .82rem; color: var(--muted); margin-top: 2px; }
.tag { font-size: .76rem; font-weight: 700; padding: 0 6px; border-radius: 3px; border: 1px solid currentColor; line-height: 1.5; }
.tag.warn { color: var(--warn); }
.tag.new { color: var(--gain); }
.tag.gone { color: var(--muted); }

.g-ret { display: grid; gap: 4px; }
.g-ret .nums { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.g-ret .cents { font-stretch: 75%; font-weight: 800; font-size: 1.3rem; line-height: 1; }
.g-ret .roi { font-size: .8rem; color: var(--muted); }
.g-big .odds { font-weight: 700; color: var(--foil); }
.g-big .odds.none { color: var(--muted); font-weight: 500; }
.g-big small, .cell small { display: block; color: var(--muted); font-size: .8rem; line-height: 1.3; }
.pips { display: flex; flex-wrap: wrap; gap: 2px; margin-top: 3px; max-width: 90px; }
.pip { width: 7px; height: 7px; border-radius: 50%; background: var(--foil); }
.pip.off { background: transparent; box-shadow: inset 0 0 0 1.5px var(--silver); }
.cell b { font-weight: 700; }
.sold-bar { height: 4px; border-radius: 2px; background: var(--line); margin-top: 5px; overflow: hidden; }
.sold-bar i { display: block; height: 100%; background: var(--muted); }
.r-label { display: none; }

.empty { padding: 40px 0; text-align: center; color: var(--muted); }
.empty .btn { margin-top: 10px; }
.loading-rows .row { height: 66px; background: linear-gradient(90deg, transparent, var(--surface), transparent) 0 0 / 200% 100%; animation: shimmer 1.4s infinite linear; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ---------- drawer ---------- */
.scrim { position: fixed; inset: 0; background: rgba(10, 14, 20, .38); z-index: 40; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 41; width: min(620px, 100vw); overflow-y: auto;
  background: var(--bg); border-left: 1px solid var(--line); box-shadow: -20px 0 40px -20px rgba(0, 0, 0, .35);
  padding: calc(22px + env(safe-area-inset-top, 0)) 26px calc(40px + env(safe-area-inset-bottom, 0));
  animation: slidein .22s ease-out;
}
@keyframes slidein { from { transform: translateX(24px); opacity: 0; } }
.drawer-close {
  position: sticky; top: 0; float: right; font-size: 1.7rem; line-height: 1; width: 40px; height: 40px; border-radius: 50%;
  border: 1px solid var(--line); background: var(--raised); color: var(--ink); cursor: pointer; z-index: 2;
}
.d-head { display: flex; gap: 14px; align-items: center; margin-right: 48px; }
.d-head h2 { margin: 0; font-stretch: 70%; font-weight: 800; font-size: 2rem; line-height: 1; }
.d-head .stub { width: 62px; height: 50px; font-size: 1.45rem; }
.d-meta { color: var(--muted); font-size: .9rem; margin: 8px 0 18px; }
.d-section { margin-top: 26px; }
.d-section h3 { margin: 0 0 10px; font-size: 1.05rem; font-weight: 700; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--radius-m); overflow: hidden; }
.stat { background: var(--surface); padding: 12px 14px; }
.stat .k { font-size: .82rem; color: var(--muted); }
.stat .v { font-stretch: 78%; font-weight: 800; font-size: 1.35rem; line-height: 1.2; }
.stat .v.foil { color: var(--foil); }
.note { font-size: .88rem; color: var(--muted); margin: 10px 0 0; }
.warnbox { border-left: 3px solid var(--warn); padding: 6px 10px; background: var(--surface); font-size: .9rem; margin-top: 12px; }

.tiers { width: 100%; border-collapse: collapse; font-size: .9rem; }
.tiers th { text-align: left; font-weight: 600; color: var(--muted); font-size: .8rem; padding: 6px 6px; border-bottom: 1px solid var(--line); }
.tiers td { padding: 7px 6px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tiers td.num, .tiers th.num { text-align: right; white-space: nowrap; }
.tiers tr.big td:first-child { color: var(--foil); font-weight: 700; }
.tiers tr.out td { color: var(--muted); }
.mini { display: inline-block; width: 64px; height: 6px; border-radius: 3px; background: var(--line); vertical-align: middle; overflow: hidden; }
.mini i { display: block; height: 100%; background: var(--gain); }
.table-scroll { overflow-x: auto; }

.sim-controls { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.sim-controls input[type="range"] { flex: 1 1 200px; accent-color: var(--ink); }
.sim-out { margin-top: 12px; display: grid; gap: 8px; }
.sim-line { display: flex; justify-content: space-between; gap: 16px; border-bottom: 1px dotted var(--line); padding-bottom: 6px; }
.sim-line span:last-child { font-weight: 700; text-align: right; }

.win-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0; }
.win-list li { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: .9rem; }
.win-list .where { color: var(--muted); font-size: .84rem; }
.win-list .amt { text-align: right; font-weight: 700; }
.win-list .near { color: var(--gain); font-weight: 700; }

/* ---------- map tab ---------- */
.map-intro { max-width: 78ch; padding: 18px 0 4px; }
.map-intro p { margin: 0; }
.map-controls { display: flex; flex-wrap: wrap; gap: 10px 20px; align-items: center; padding: 12px 0; }
.map-controls label { display: inline-flex; gap: 8px; align-items: center; }
.map-layout { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(280px, 1fr); gap: 18px; }
#map { height: 600px; border-radius: var(--radius-m); border: 1px solid var(--line); background: var(--surface); }
.store-list { list-style: none; margin: 0; padding: 0; max-height: 600px; overflow-y: auto; border-top: 1px solid var(--line); counter-reset: none; }
.store-list li { padding: 10px 4px; border-bottom: 1px solid var(--line); cursor: pointer; display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; }
.store-list li:hover { background: var(--surface); }
.store-list .s-name { font-weight: 700; }
.store-list .s-addr { color: var(--muted); font-size: .84rem; grid-column: 1; }
.store-list .s-count { grid-row: 1 / span 2; grid-column: 2; align-self: center; font-stretch: 75%; font-weight: 800; font-size: 1.3rem; color: var(--foil); text-align: right; }
.store-list .s-count small { display: block; font-size: .7rem; font-weight: 500; color: var(--muted); font-stretch: 100%; }
.leaflet-popup-content { font: 14px/1.4 var(--font); }
.leaflet-container { font-family: var(--font); }

/* ---------- method ---------- */
.method { max-width: 72ch; padding: 10px 0 20px; }
.method h2 { font-stretch: 72%; font-weight: 800; font-size: 2rem; margin: 18px 0 8px; line-height: 1.05; }
.method h3 { font-size: 1.1rem; margin: 26px 0 6px; }
.method p, .method li { line-height: 1.6; }
.method li { margin-bottom: 6px; }

.foot { max-width: 1280px; margin: 0 auto; padding: 20px 24px 40px; border-top: 1px solid var(--line); color: var(--muted); font-size: .88rem; }
.foot p { margin: 4px 0; }

/* ---------- responsive ---------- */
@media (max-width: 960px) {
  .verdict { grid-template-columns: 1fr; }
  .map-layout { grid-template-columns: 1fr; }
  #map { height: 420px; }
  .store-list { max-height: none; }
}
@media (max-width: 820px) {
  .masthead { padding: 20px 16px 12px; }
  .verdict, main, .tabs, .foot { padding-left: 16px; padding-right: 16px; }
  .freshness { width: 100%; justify-content: space-between; }
  .freshness p { text-align: left; }
  .row.head { display: none; }
  .games .row, .games.with-near .row {
    grid-template-columns: 1fr 1fr; gap: 10px 16px; padding: 14px 6px;
  }
  .g-name, .c-ret { grid-column: 1 / -1; }
  .r-label { display: block; font-size: .76rem; color: var(--muted); }
  .loc-panel { right: auto; left: 0; }
  .controls { gap: 12px 16px; }
  .drawer { padding-left: 18px; padding-right: 18px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

.foot .foot-legal { margin-top: 14px; }
.foot .foot-links a { margin-right: 14px; }
