:root {
  color-scheme: light;
  --bg: #f2f5f3;
  --surface: #ffffff;
  --surface-soft: #f6f9f7;
  --border: #d5dfd9;
  --border-strong: #b6c7bd;
  --ink: #162622;
  --muted: #4f6359;
  --accent: #19513f;
  --accent-strong: #133f31;
  --accent-soft: #eaf3ee;
  --accent-border: #bfd3c7;
  --hero-bg: linear-gradient(155deg, #143d32 0%, #1d5444 100%);
  --hero-muted: #c7dfd2;
  --hero-line: rgb(255 255 255 / .18);
  --hero-btn: #def3ae;
  --hero-btn-ink: #163327;
  --shadow-sm: 0 1px 2px rgb(16 34 28 / .05), 0 4px 14px rgb(16 34 28 / .04);
  --shadow-md: 0 10px 26px rgb(16 34 28 / .12);
  font: 100%/1.55 -apple-system, BlinkMacSystemFont, "PingFang SC", "Noto Sans CJK SC", "Microsoft YaHei", Inter, sans-serif;
  color: var(--ink);
  background: var(--bg);
}
:root[data-game="ssq"] {
  --accent: #842b3f;
  --accent-strong: #681f30;
  --accent-soft: #fbf1f3;
  --accent-border: #dfbec6;
  --hero-bg: linear-gradient(155deg, #5c1c2c 0%, #862d42 100%);
  --hero-muted: #f0d2da;
  --hero-btn: #fae8b4;
  --hero-btn-ink: #3b121d;
}
:root[data-game="dlt"] {
  --accent: #1e4f73;
  --accent-strong: #163b57;
  --accent-soft: #edf4fa;
  --accent-border: #bad0e2;
  --hero-bg: linear-gradient(155deg, #163a56 0%, #245a82 100%);
  --hero-muted: #cee1f0;
  --hero-btn: #dcf3b4;
  --hero-btn-ink: #112d40;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; -webkit-font-smoothing: antialiased; }
main {
  max-width: 56rem;
  margin: auto;
  padding: max(clamp(.9rem, 4vw, 2.8rem), env(safe-area-inset-top))
           max(1rem, env(safe-area-inset-right))
           max(3.5rem, env(safe-area-inset-bottom))
           max(1rem, env(safe-area-inset-left));
}
h1, h2, h3, p { margin: 0; }
h1 { font-size: clamp(1.3rem, 3.4vw, 1.85rem); letter-spacing: -.03em; line-height: 1.2; }
h2 { font-size: clamp(1.28rem, 2.8vw, 1.7rem); line-height: 1.28; letter-spacing: -.02em; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { opacity: .54; cursor: default; }
:focus-visible { outline: 3px solid #af7318; outline-offset: 2px; }

/* Header & dual-game pill switch */
.top, .draw-head, .draw-foot, .step-actions, .results-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: .85rem;
}
.top { flex-wrap: wrap; margin-bottom: 1.15rem; }
.top h1 a {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  min-height: 44px;
  color: var(--ink);
  text-decoration: none;
}
.brand-mark { flex: none; color: var(--accent); }
.game-nav { display: flex; align-items: center; flex-wrap: wrap; gap: .5rem; }
.game-switch {
  display: inline-grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  padding: .2rem;
  background: #e4ece7;
  border: 1px solid var(--border);
  border-radius: 999px;
}
.game-switch a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: .2rem .85rem;
  border-radius: 999px;
  color: var(--muted);
  font-size: .9rem;
  font-weight: 650;
  text-decoration: none;
  white-space: nowrap;
  transition: background-color .16s ease, color .16s ease;
}
.game-switch a:hover { color: var(--ink); }
.game-switch a[aria-current="page"] {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 1px 3px rgb(0 0 0 / .16);
}

/* Section navigation */
.section-nav {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: .22rem;
  margin-bottom: 1rem;
  padding: .25rem;
  background: #e5ede8;
  border: 1px solid var(--border);
  border-radius: .85rem;
}
.section-nav a {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 2.75rem;
  padding: .3rem .4rem;
  border-radius: .6rem;
  color: #2f4b40;
  font-size: .95rem;
  font-weight: 600;
  text-decoration: none;
  transition: background-color .15s ease, color .15s ease;
}
.section-nav a:hover { background: rgb(255 255 255 / .72); }
.section-nav a[aria-current="page"] {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 1px 4px rgb(0 0 0 / .14);
}

/* Homepage rich game cards */
#game-choice { padding-top: .25rem; }
.home-head { margin-bottom: 1rem; }
.game-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}
.game-card {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: clamp(1.15rem, 3vw, 1.65rem);
  border-radius: 1.15rem;
  color: #fff;
  box-shadow: var(--shadow-md);
}
.game-card.ssq { background: linear-gradient(155deg, #5d1d2d 0%, #892e44 100%); }
.game-card.dlt { background: linear-gradient(155deg, #163a56 0%, #245a82 100%); }
.game-card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: .75rem;
}
.game-card h3 { font-size: clamp(1.38rem, 3vw, 1.75rem); line-height: 1.22; letter-spacing: -.02em; }
.game-rule { margin-top: .25rem; font-size: .86rem; color: rgb(255 255 255 / .82); }
.game-badge {
  flex: none;
  padding: .16rem .6rem;
  border: 1px solid rgb(255 255 255 / .34);
  border-radius: 999px;
  font-size: .78rem;
  font-weight: 600;
  color: rgb(255 255 255 / .92);
  background: rgb(255 255 255 / .1);
}
.card-draw {
  padding: .8rem .9rem;
  border-radius: .8rem;
  background: rgb(0 0 0 / .18);
  border: 1px solid rgb(255 255 255 / .12);
}
.card-draw-meta {
  font-size: .84rem;
  color: rgb(255 255 255 / .84);
  margin-bottom: .55rem;
  font-variant-numeric: tabular-nums;
}
.card-balls .ball {
  width: 2rem;
  height: 2rem;
  font-size: .92rem;
  box-shadow: 0 2px 5px rgb(0 0 0 / .2);
}
.card-actions {
  display: grid;
  grid-template-columns: 1.35fr 1fr;
  gap: .55rem;
  margin-top: auto;
}
.card-actions a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: .5rem .85rem;
  border-radius: .7rem;
  font-weight: 650;
  font-size: .94rem;
  text-decoration: none;
  transition: transform .12s ease, background-color .15s ease;
}
.card-primary { background: #fff; color: #192622; }
.game-card.ssq .card-primary { color: #5b1b2b; }
.game-card.dlt .card-primary { color: #153954; }
.card-primary:hover { background: #f8faf8; }
.card-secondary {
  color: #fff;
  background: rgb(255 255 255 / .14);
  border: 1px solid rgb(255 255 255 / .32);
}
.card-secondary:hover { background: rgb(255 255 255 / .24); }
.home-summary {
  margin-top: 1.1rem;
  padding: .8rem 1rem;
  border-radius: .8rem;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: .88rem;
  text-align: center;
}

/* Main cards & draw hero */
.draw, .panel {
  background: var(--surface);
  padding: clamp(1.15rem, 4vw, 2.2rem);
  border: 1px solid var(--border);
  border-radius: 1.15rem;
  box-shadow: var(--shadow-sm);
}
.draw {
  background: var(--hero-bg);
  border-color: transparent;
  color: #f6fbf8;
  box-shadow: var(--shadow-md);
}
.eyebrow {
  font-size: .86rem;
  font-weight: 650;
  color: var(--accent);
  margin-bottom: .25rem;
}
.draw .eyebrow { color: var(--hero-muted); }
.draw-source-link {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: .25rem .65rem;
  border-radius: .55rem;
  color: #f3f7f4;
  background: rgb(255 255 255 / .1);
  text-decoration: none;
  font-size: .88rem;
  font-weight: 550;
  white-space: nowrap;
}
.draw-source-link:hover { background: rgb(255 255 255 / .18); }
#draw-meta {
  color: var(--hero-muted);
  margin: .4rem 0 1.25rem;
  font-variant-numeric: tabular-nums;
}

/* Tactile lottery balls */
.zones, .ball-group { display: flex; gap: .42rem; align-items: center; flex-wrap: wrap; }
.zones { gap: .55rem .95rem; }
.ball {
  display: inline-grid;
  place-items: center;
  width: 2.18rem;
  height: 2.18rem;
  border-radius: 50%;
  background: radial-gradient(circle at 34% 28%, #fff6f5 0%, #f8e3e1 68%, #efcfd0 100%);
  border: 1px solid rgb(166 56 64 / .24);
  color: #912430;
  font-variant-numeric: tabular-nums;
  font-size: .98rem;
  font-weight: 700;
  line-height: 1;
}
.ball.back {
  background: radial-gradient(circle at 34% 28%, #f4f8ff 0%, #dde9fb 68%, #c7daf7 100%);
  border-color: rgb(42 82 152 / .26);
  color: #244a8e;
}
.draw .ball {
  width: clamp(2.2rem, 5.2vw, 3.05rem);
  height: clamp(2.2rem, 5.2vw, 3.05rem);
  font-size: clamp(1rem, 2.5vw, 1.32rem);
  border-color: rgb(255 255 255 / .55);
  box-shadow: 0 3px 8px rgb(0 0 0 / .24);
}
.ball.hit {
  background: #b1273b;
  border-color: #881b2b;
  color: #fff;
  box-shadow: 0 0 0 2px rgb(177 39 59 / .22);
}
.ball.back.hit {
  background: #2453a6;
  border-color: #193c7a;
  color: #fff;
  box-shadow: 0 0 0 2px rgb(36 83 166 / .22);
}
.ball.miss {
  background: #edf1ef;
  border-color: #d6deda;
  color: #798981;
  font-weight: 550;
}
.ball.banker {
  outline: 2px dashed currentColor;
  outline-offset: -3px;
}
.ball-sep {
  color: var(--muted);
  font-weight: 700;
  padding-inline: .15rem;
}

.draw-foot { border-top: 1px solid var(--hero-line); margin-top: 1.45rem; padding-top: 1.05rem; }
.draw-foot p { font-size: .93rem; color: var(--hero-muted); }

/* Buttons */
.primary {
  background: var(--accent);
  color: #fff;
  border: 0;
  border-radius: .7rem;
  padding: .65rem 1.45rem;
  font-weight: 650;
  flex-shrink: 0;
  min-height: 44px;
  transition: background-color .15s ease, transform .1s ease;
}
.primary:hover:not(:disabled) { background: var(--accent-strong); }
.draw .primary {
  background: var(--hero-btn);
  color: var(--hero-btn-ink);
  box-shadow: 0 2px 8px rgb(0 0 0 / .18);
}
.draw .primary:hover:not(:disabled) { filter: brightness(.96); }
.secondary {
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--accent);
  border-radius: .65rem;
  padding: .48rem .95rem;
  font-weight: 600;
  min-height: 44px;
  transition: background-color .15s ease, border-color .15s ease;
}
.secondary:hover { background: var(--accent-soft); border-color: var(--accent-border); }
.panel { margin-top: 1rem; }
.muted, .note, .hint { color: var(--muted); font-size: .92rem; }
.muted, .hint { margin-top: .5rem; }

/* Results & Tickets */
.results-head { align-items: flex-start; }
.copy-btn { flex-shrink: 0; padding: .4rem .85rem; font-size: .88rem; }
.tickets { padding: 0; margin: 1rem 0 0; list-style: none; }
.tickets li {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: .45rem 1rem;
  padding: .75rem .7rem;
  border-top: 1px solid #e3eae5;
}
.tickets li:nth-child(odd) { background: #fafcfa; border-radius: .55rem; }
.ticket-name { min-width: 7.2rem; font-weight: 650; font-size: .92rem; color: var(--muted); }
.blessing {
  display: flex;
  align-items: center;
  gap: .8rem;
  margin-top: .8rem;
  padding: .85rem 1rem;
  border-radius: .75rem;
  border: 1px solid #edd9bf;
  background: #fcf4e8;
  color: #723728;
  font: 600 1.04rem/1.5 Georgia, "Songti SC", "Noto Serif CJK SC", serif;
}
.seal {
  flex: none;
  display: grid;
  place-items: center;
  border: 3px double currentColor;
  border-radius: .22rem;
  width: 1.75rem;
  height: 1.75rem;
  color: #a04430;
  line-height: 1;
  transform: rotate(-5deg);
}
.note { margin-top: .9rem; }

/* Local records */
summary {
  cursor: pointer;
  font-weight: 650;
  min-height: 36px;
  display: list-item;
  padding-block: .2rem;
}
.audit { border-top: 1px solid #dce5de; padding: .8rem 0 0; margin-top: .8rem; }
.audit p { margin: .35rem 0; }
.audit ol { padding-left: 1.6rem; font-size: .92rem; font-variant-numeric: tabular-nums; }

/* Picker steps & methods */
fieldset { border: 0; padding: 0; margin: 1rem 0; }
legend { font-weight: 650; margin-bottom: .45rem; }
.sr-only { position: absolute; clip-path: inset(50%); width: 1px; height: 1px; overflow: hidden; }
#home-draw[hidden] + #picker { margin-top: 0; }
.steps {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  list-style: none;
  margin: 0 0 1.15rem;
  padding: 0 0 .95rem;
  border-bottom: 1px solid #dce6dd;
}
.steps li {
  position: relative;
  display: grid;
  justify-items: center;
  gap: .32rem;
  text-align: center;
  color: var(--muted);
  font-size: .88rem;
}
.steps li + li::before {
  content: "";
  position: absolute;
  right: 50%;
  top: .91rem;
  width: 100%;
  height: 2px;
  background: #d4dfd6;
}
.steps li.complete::before, .steps li[aria-current]::before { background: var(--accent); opacity: .55; }
.step-dot {
  z-index: 1;
  display: grid;
  place-items: center;
  width: 1.9rem;
  height: 1.9rem;
  border: 1px solid #a6b8ab;
  border-radius: 50%;
  background: #fff;
  line-height: 1;
  font-weight: 650;
}
.steps .complete .step-dot { color: var(--accent); background: var(--accent-soft); border-color: var(--accent-border); }
.steps li[aria-current] { color: var(--accent); font-weight: 700; }
.steps li[aria-current] .step-dot {
  color: #fff;
  background: var(--accent);
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
@media (prefers-reduced-motion: no-preference) {
  .step-dot, .steps li::before { transition: background-color .18s ease, box-shadow .18s ease; }
}
.mode-choices, .method-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .6rem; }
.mode-choices { margin-top: 1rem; }
.mode-choices button, .method-choice {
  border: 1px solid var(--border);
  border-radius: .8rem;
  background: #fff;
  color: inherit;
  text-align: left;
  cursor: pointer;
  transition: background-color .14s ease, border-color .14s ease;
}
.mode-choices button { padding: 1.15rem; }
.mode-tag {
  display: inline-block;
  margin-bottom: .45rem;
  padding: .12rem .5rem;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: .78rem;
  font-weight: 650;
}
.mode-choices strong { display: block; margin-bottom: .25rem; font-size: 1.08rem; }
.mode-choices button:hover, .method-choice:hover { background: var(--surface-soft); border-color: var(--accent-border); }
.method-choice { display: flex; align-items: flex-start; gap: .55rem; padding: .68rem .8rem; }
.method-choice:has(input:checked) { background: var(--accent-soft); border-color: var(--accent); }
.method-choice:focus-within { outline: 2px solid #9c6d25; outline-offset: 1px; }
.method-choice.machine { margin-bottom: .65rem; }
.method-choice input { flex: none; accent-color: var(--accent); margin: .32rem 0 0; }
.method-choice strong { display: flex; align-items: center; gap: .4rem; }
.default-badge {
  font-style: normal;
  font-size: .74rem;
  font-weight: 650;
  padding: .06rem .45rem;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
}
.step-actions { margin-top: 1.2rem; padding-top: .85rem; border-top: 1px solid #dce6dd; }
small { display: block; color: var(--muted); font-size: .86rem; }

/* Lucky form */
.fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .65rem; }
.fields label { display: grid; gap: .25rem; font-size: .92rem; font-weight: 600; }
.fields input {
  min-width: 0;
  width: 100%;
  padding: .5rem .6rem;
  border-radius: .5rem;
  border: 1px solid var(--border-strong);
  background: #fff;
  color: inherit;
  font-weight: 400;
}
.birthday-field { display: grid; gap: .25rem; }
.birthday-label { display: flex; align-items: baseline; gap: .5rem; font-size: .92rem; font-weight: 600; }
#zodiac { font-size: .86rem; font-weight: 650; color: var(--accent); }
.tarot {
  margin: .9rem 0;
  border: 1px solid var(--border);
  border-radius: .8rem;
  background: var(--surface-soft);
}
#draw-tarot, #tarot-reveal { display: flex; align-items: center; gap: 1rem; padding: .75rem 1rem; }
#draw-tarot { width: 100%; border: 0; border-radius: inherit; background: transparent; color: inherit; text-align: left; }
#draw-tarot:hover { background: var(--accent-soft); }
.card-back {
  display: grid;
  place-items: center;
  flex-shrink: 0;
  width: 2.3rem;
  height: 3.4rem;
  border: 3px double #d7c697;
  border-radius: .28rem;
  box-shadow: -3px 2px 0 #264c40;
  background: #1d473a;
  color: #e7d4a0;
  font: 1.65rem/1 Georgia, serif;
  transform: rotate(-5deg);
}
#tarot-face { width: 3.9rem; height: auto; border-radius: .25rem; box-shadow: 0 2px 6px rgb(0 0 0 / .16); }
#tarot-name { display: block; font-size: 1.1rem; }
#return-tarot {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  border: 0;
  padding: .25rem 0;
  background: transparent;
  color: var(--accent);
  font-size: .9rem;
  text-decoration: underline;
  text-underline-offset: .22em;
}
#error { color: #9c2b23; margin-top: .65rem; font-weight: 550; }

/* Explore sections */
.explore { margin-top: 0; }
.explore a { color: var(--accent); text-underline-offset: .22em; }
.explore-controls { display: grid; gap: .75rem; margin: 1.1rem 0; align-items: end; }
#archive-form { grid-template-columns: repeat(3, minmax(0, 1fr)) auto; }
#frequency-controls { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.explore-controls label { display: grid; gap: .28rem; min-width: 0; font-size: .9rem; font-weight: 600; }
.explore-controls :is(input, select) {
  font: inherit;
  font-weight: 400;
  color: var(--ink);
  min-width: 0;
  width: 100%;
  min-height: 2.75rem;
  padding: .45rem .55rem;
  background: #fff;
  border: 1px solid var(--border-strong);
  border-radius: .52rem;
}
.control-actions { display: flex; gap: .45rem; }
.control-actions button { min-height: 2.75rem; padding: .45rem .9rem; }
.report-summary { margin: .8rem 0 .6rem; color: var(--accent); font-size: .93rem; font-weight: 550; }
.date-range { display: inline-block; margin-inline-start: .5rem; font-variant-numeric: tabular-nums; font-weight: 400; color: var(--muted); }

/* Archive list */
.archive-list { list-style: none; margin: 0; padding: 0; }
.archive-list li {
  display: grid;
  grid-template-columns: minmax(7.2rem, .7fr) minmax(0, 2fr) auto;
  align-items: center;
  gap: .45rem 1rem;
  padding: .75rem 0;
  border-top: 1px solid #e1e9e3;
}
.draw-stamp { display: grid; font-variant-numeric: tabular-nums; }
.draw-stamp time { font-size: .86rem; color: var(--muted); }
.archive-list a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding-inline: .35rem;
  font-size: .88rem;
  white-space: nowrap;
}
.archive-list .ball, .frequency-table .ball { width: 1.8rem; height: 1.8rem; font-size: .88rem; }
.archive-list .zones { gap: .38rem .85rem; }
.archive-list .ball-group { gap: .28rem; }
.archive-list .ball-group::before { content: attr(aria-label); font-size: .78rem; color: var(--muted); }
.page-nav { display: flex; align-items: center; justify-content: space-between; gap: .4rem; padding-top: .8rem; border-top: 1px solid #dee7e0; }
.page-nav span { color: var(--muted); font-size: .9rem; font-variant-numeric: tabular-nums; }

/* Frequency highlights & table */
.freq-highlights {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: .55rem;
  margin: .75rem 0 1rem;
}
.freq-chip {
  padding: .68rem .75rem;
  border-radius: .7rem;
  background: var(--accent-soft);
  border: 1px solid var(--accent-border);
  font-variant-numeric: tabular-nums;
}
.freq-chip-label { display: block; font-size: .78rem; color: var(--muted); }
.freq-chip strong { display: block; font-size: 1.12rem; color: var(--accent); margin: .1rem 0; }
.freq-chip small { font-size: .8rem; }
.frequency-table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.frequency-table caption { padding: 0 0 .65rem; text-align: left; font-size: .86rem; color: var(--muted); }
.frequency-table :is(th, td) { text-align: left; padding: .48rem .55rem; border-bottom: 1px solid #e3ebe5; }
.frequency-table thead { background: var(--surface-soft); font-size: .88rem; color: var(--muted); }
.frequency-table meter {
  width: clamp(3rem, 16vw, 9rem);
  height: .72rem;
  margin-right: .6rem;
  vertical-align: middle;
  accent-color: var(--accent);
}
.frequency-table meter::-webkit-meter-bar { background: #e8efea; border: 0; border-radius: 999px; }
.frequency-table meter::-webkit-meter-optimum-value { background: var(--accent); border-radius: 999px; }
.freq-pct { display: inline-block; min-width: 3.9rem; text-align: right; }

/* Probability page */
.explore h3 { margin: 1.35rem 0 .45rem; font-size: 1.08rem; }
.odds-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .7rem; margin: .65rem 0 .85rem; }
.odds-grid > div {
  padding: .9rem 1rem;
  background: var(--accent-soft);
  border: 1px solid var(--accent-border);
  border-radius: .75rem;
}
.odds-grid p { font-size: .9rem; color: var(--muted); }
.odds-grid strong {
  display: block;
  margin: .18rem 0;
  font-size: clamp(1.22rem, 3vw, 1.58rem);
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}
.rule-source { margin-top: 1.15rem; }
.rule-source a { display: inline-flex; align-items: center; min-height: 44px; }

/* Photo check & visual hit matching */
.photo-actions { display: flex; flex-wrap: wrap; align-items: center; gap: .55rem; margin: 1rem 0; }
.photo-file { position: relative; cursor: pointer; overflow: hidden; display: inline-flex; align-items: center; justify-content: center; }
.photo-file input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.photo-file:focus-within { outline: 3px solid #af7318; outline-offset: 2px; }
#ticket-preview { display: block; max-width: 100%; max-height: min(50vh, 23rem); margin: .7rem auto; border-radius: .5rem; box-shadow: var(--shadow-sm); }
#ticket-preview.cropping { cursor: crosshair; touch-action: manipulation; outline: 2px solid var(--accent); }
.crop-actions { justify-content: center; margin-top: .4rem; }
#ticket-video { display: block; width: 100%; max-height: 22rem; background: #19231c; border-radius: .65rem; }
.ticket-fields { grid-template-columns: repeat(auto-fit, minmax(min(9rem, 100%), 1fr)); }
.ticket-numbers { display: grid; gap: .28rem; font-weight: 600; }
.ticket-numbers textarea {
  min-width: 0;
  width: 100%;
  border: 1px solid var(--border-strong);
  border-radius: .55rem;
  padding: .65rem;
  font: 1rem/1.65 ui-monospace, SFMono-Regular, Menlo, monospace;
  color: inherit;
  resize: vertical;
}
#ticket-form .primary { margin-top: .85rem; }
#ticket-error { color: #9c2b23; margin: .75rem 0; font-weight: 550; }
#ticket-result {
  margin-top: 1rem;
  padding: 1.05rem;
  border-radius: .85rem;
  background: var(--accent-soft);
  border: 1px solid var(--accent-border);
}
#ticket-result h3 {
  margin-top: 0;
  font-size: clamp(1.22rem, 3.2vw, 1.48rem);
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}
#ticket-breakdown { margin-top: .35rem; font-size: .92rem; color: var(--muted); }
.ticket-draw-strip {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .45rem .7rem;
  margin-top: .85rem;
  padding: .65rem .75rem;
  border-radius: .65rem;
  background: var(--surface);
  border: 1px solid var(--border);
}
.strip-label { font-size: .82rem; font-weight: 650; color: var(--muted); }
.ticket-draw-strip .ball, .ticket-match-lines .ball { width: 1.85rem; height: 1.85rem; font-size: .88rem; }
.ticket-match-lines {
  list-style: none;
  margin: .75rem 0 0;
  padding: 0;
  display: grid;
  gap: .5rem;
}
.ticket-match-lines li {
  padding: .65rem .75rem;
  border-radius: .65rem;
  background: var(--surface);
  border: 1px solid var(--border);
}
.match-line-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: .5rem;
  margin-bottom: .45rem;
  font-size: .84rem;
}
.match-line-no { font-weight: 650; color: var(--muted); }
.match-tag {
  padding: .08rem .5rem;
  border-radius: 999px;
  font-size: .78rem;
  font-weight: 650;
  background: #edf1ef;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.match-tag.active { background: var(--accent); color: #fff; }
#ticket-awards { padding-left: 1.3rem; margin: .85rem 0 0; font-size: .94rem; }
#ticket-awards li + li { margin-top: .3rem; }

/* Responsive breakpoints */
@media (max-width: 41rem) {
  .game-options { grid-template-columns: 1fr; }
  #archive-form { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .archive-list li { grid-template-columns: 1fr auto; }
  .archive-list .zones { grid-column: 1 / -1; grid-row: 2; }
  .archive-list .draw-stamp { display: flex; flex-wrap: wrap; align-items: baseline; gap: .2rem .65rem; }
}
@media (max-width: 36rem) {
  .section-nav { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  .section-nav a { grid-column: span 2; padding-inline: .15rem; font-size: .92rem; }
  .section-nav a:nth-child(-n+2) { grid-column: span 3; }
  .nav-detail { display: none; }
  #frequency-controls { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  #frequency-controls label:last-child { grid-column: 1 / -1; }
  .date-range { display: block; margin: .12rem 0 0; }
  .odds-grid { grid-template-columns: 1fr; }
}
@media (max-width: 32rem) {
  main {
    padding: max(.85rem, env(safe-area-inset-top))
             max(.75rem, env(safe-area-inset-right))
             max(2.2rem, env(safe-area-inset-bottom))
             max(.75rem, env(safe-area-inset-left));
  }
  .top { gap: .45rem; margin-bottom: .75rem; }
  .game-nav { gap: .35rem; }
  .game-nav .secondary { display: inline-flex; align-items: center; padding: .35rem .65rem; font-size: .88rem; }
  .mode-choices, .method-grid, .fields { grid-template-columns: 1fr; }
  .panel, .draw { padding: 1rem .85rem; border-radius: .95rem; }
  .primary, .secondary, #draw-tarot, #return-tarot, .method-choice, .page-nav button, .control-actions button { min-height: 44px; }
  .fields input, .explore-controls :is(input, select) { min-height: 44px; font-size: 1rem; }
  .sticky-actions {
    position: sticky;
    bottom: 0;
    margin: 1rem -.85rem -1rem;
    padding: .75rem .85rem max(.85rem, env(safe-area-inset-bottom));
    background: rgb(255 255 255 / .94);
    backdrop-filter: blur(8px);
    border-top: 1px solid var(--border);
    border-radius: 0 0 .95rem .95rem;
    z-index: 5;
  }
  .photo-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .45rem; margin: .8rem 0; }
  .photo-actions .primary { grid-column: 1 / -1; }
  .photo-actions :is(button, label) { display: grid; place-items: center; text-align: center; }
  .crop-actions { grid-template-columns: 1fr; }
  #ticket-camera-view .photo-actions { grid-template-columns: 1fr; }
  .ticket-fields { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .55rem; }
  #ticket-form .primary, #ticket-switch { width: 100%; }
  .ticket-numbers textarea { padding: .6rem; line-height: 1.75; }
  .draw .ball, .ball { width: clamp(1.7rem, 7.2vw, 2.2rem); height: clamp(1.7rem, 7.2vw, 2.2rem); font-size: .96rem; }
  .card-balls .ball { width: clamp(1.7rem, 7.4vw, 2.05rem); height: clamp(1.7rem, 7.4vw, 2.05rem); font-size: .9rem; }
  .zones { gap: .32rem .55rem; }
  .tickets li { align-items: flex-start; flex-direction: column; gap: .35rem; padding: .65rem .55rem; }
  .ball-group { gap: .25rem; }
  .draw-foot { flex-direction: column; align-items: stretch; gap: .65rem; }
  .step-actions > button { flex: 1; }
  .freq-highlights { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .4rem; }
  .freq-chip { padding: .55rem .5rem; }
  .freq-chip strong { font-size: 1rem; }
}
@media (max-width: 26rem) {
  #archive-form > :is(label:first-child, .control-actions) { grid-column: 1 / -1; }
  .explore-controls { gap: .55rem; }
  .frequency-table :is(th, td) { padding-inline: .26rem; }
  .game-switch a { padding: .2rem .65rem; font-size: .86rem; }
}
@media (max-width: 22rem) {
  .freq-highlights { grid-template-columns: 1fr; }
  .card-actions { grid-template-columns: 1fr; }
}
