:root {
  color-scheme: light dark;
  --bg: #F6F4EE;
  --surface: #FFFFFF;
  --surface-2: #EEEAE0;
  --ink: #201E19;
  --ink-2: #6B675B;
  --line: #E3DFD2;
  --accent: #1F6B4F;
  --accent-pressed: #14503A;
  --pending: #0C616B;
  --pending-tint: #DEEEEF;
  --attention: #A93A20;
  --attention-tint: #F8E4DC;
  --pen: #C8332B;
  --strip: #201E19;
  --strip-2: #33302B;
  --strip-text: #F1EDE2;
  --strip-muted: #A8A292;
  --won-text: #6B4A00;
  --won-tint: #F8EFD4;
  --won-strong: #C9930A;
  --font-ui: "Archivo", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-digits: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --space-1: .25rem;
  --space-2: .5rem;
  --space-3: .75rem;
  --space-4: 1rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --gutter: clamp(1rem, 4.65vw, 1.25rem);
  --radius: 1rem;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14130F;
    --surface: #1F1D17;
    --surface-2: #2A2720;
    --ink: #F1EDE2;
    --ink-2: #A8A292;
    --line: #38352B;
    --accent: #2A8A63;
    --accent-pressed: #58B98C;
    --pending: #62C6CE;
    --pending-tint: #123133;
    --attention: #F0876B;
    --attention-tint: #3A1F16;
    --pen: #E05A4E;
    --strip: #000000;
    --strip-2: #24221D;
    --won-text: #F2C14E;
    --won-tint: #2E2412;
    --won-strong: #F2C14E;
  }
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); font-size: 100%; }
body {
  min-width: 20rem;
  min-height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 1rem;
  line-height: 1.35;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  text-rendering: optimizeLegibility;
}
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; text-decoration: none; }
button { font: inherit; }
.digits {
  font-family: var(--font-digits);
  font-variant-numeric: tabular-nums slashed-zero;
  font-feature-settings: "tnum" 1, "zero" 1;
}
.sr-only {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0);
  white-space: nowrap; border: 0;
}
.noscript { margin: 0; padding: 1rem; background: var(--attention-tint); color: var(--attention); }

#app { min-height: 100vh; min-height: 100dvh; }
.screen {
  width: 100%;
  min-height: 100vh;
  min-height: 100dvh;
  padding-top: env(safe-area-inset-top);
  padding-right: env(safe-area-inset-right);
  padding-bottom: env(safe-area-inset-bottom);
  padding-left: env(safe-area-inset-left);
  background: var(--bg);
}
.screen[hidden] { display: none !important; }
.page-gutter { margin-right: var(--gutter); margin-left: var(--gutter); }
.screen-title:focus { outline: none; }
.muted, small, .helper-text { color: var(--ink-2); }
.attention-text { color: var(--attention); }
.won-text { color: var(--won-text); }

.back-link, .summary-back {
  display: inline-flex;
  min-height: 2.75rem;
  align-items: center;
  color: var(--accent);
  font-size: 1.0625rem;
  font-weight: 650;
}
.back-link:active, .summary-back:active, .text-button:active { color: var(--accent-pressed); }
.page-intro { padding: .75rem var(--gutter) .25rem; }
.page-intro h1 { margin: .15rem 0 0; font-size: clamp(1.625rem, 7vw, 1.875rem); line-height: 1.15; letter-spacing: -.025em; }
.page-intro p { margin: .45rem 0 0; color: var(--ink-2); font-size: .9375rem; }
.split-intro { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; }
.photo-count { flex: none; padding-bottom: .15rem; color: var(--ink-2); font-size: .9375rem; }
.helper-text { margin-top: .25rem; margin-bottom: .875rem; font-size: .9375rem; line-height: 1.45; }

.topbar {
  display: grid;
  grid-template-columns: minmax(4.25rem, 1fr) auto minmax(4.25rem, 1fr);
  align-items: center;
  min-height: 3.75rem;
  padding: .5rem var(--gutter) .25rem;
}
.topbar-side:last-child { justify-self: end; }
.topbar-title { margin: 0; font-size: 1.0625rem; line-height: 1.2; text-align: center; }

.primary-button, .secondary-button, .small-button, .text-button {
  display: flex;
  min-height: 3.5rem;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius);
  font-size: 1.0625rem;
  font-weight: 700;
  text-align: center;
}
.primary-button { min-height: 3.75rem; background: var(--accent); color: #FFFFFF; }
.primary-button:active { background: var(--accent-pressed); }
.secondary-button { border: 1.5px solid var(--line); background: var(--surface); color: var(--ink); }
.text-button { color: var(--accent); }
.bottom-actions {
  position: sticky;
  bottom: 0;
  margin-top: auto;
  padding: .875rem var(--gutter) max(1rem, env(safe-area-inset-bottom));
  background: linear-gradient(to bottom, transparent, var(--bg) 1rem, var(--bg));
}
.horizontal-actions { display: flex; gap: .75rem; }
.horizontal-actions .primary-button { flex: 1; }
.compact-button { min-width: 6.75rem; padding: 0 1.25rem; }
.stacked-actions { display: grid; gap: .625rem; }

/* Camera / session home */
.camera-screen { display: flex; flex-direction: column; background: #0B0A08; color: #F1EDE2; }
.camera-header {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: .5rem;
  padding: .75rem var(--gutter) .5rem;
}
.brand-link {
  display: inline-flex;
  min-height: 2.75rem;
  align-items: center;
  gap: .4rem;
  justify-self: start;
  color: #D9D4C8;
  font-size: .875rem;
  font-weight: 650;
}
.mini-mark { display: grid; width: 2rem; height: 2rem; place-items: center; border: 1px solid #4A463C; border-radius: .55rem; font-family: var(--font-digits); color: #58B98C; }
.session-chip {
  display: flex;
  min-height: 2.75rem;
  align-items: center;
  gap: .625rem;
  padding: .55rem 1rem;
  border: 1px solid rgba(255,255,255,.16);
  border-radius: 999px;
  background: rgba(20,19,15,.78);
  font-size: .9375rem;
  white-space: nowrap;
}
.session-chip .digits { font-size: 1.0625rem; }
.dot { width: .25rem; height: .25rem; border-radius: 50%; background: #6B675B; }
.header-spacer { width: 2.75rem; }
.viewfinder {
  position: relative;
  flex: 1;
  min-height: 27rem;
  margin: .5rem 1rem;
  overflow: hidden;
  border-radius: 1.125rem;
  background: radial-gradient(ellipse at 50% 35%, #29261F 0%, #121110 70%);
}
.viewfinder::before { content: ""; position: absolute; inset: 0; background: linear-gradient(115deg, transparent 20%, rgba(255,255,255,.035) 48%, transparent 70%); }
.corner-guide { position: absolute; inset: .875rem; width: calc(100% - 1.75rem); height: calc(100% - 1.75rem); }
.corner-guide path { fill: none; stroke: rgba(255,255,255,.58); stroke-width: 1; vector-effect: non-scaling-stroke; stroke-linecap: round; }
.ticket-shadow { position: absolute; width: 52%; height: 26%; border: 1.5px dashed rgba(241,237,226,.32); border-radius: .375rem; background: rgba(241,237,226,.018); }
.ticket-shadow-one { top: 24%; left: 50%; transform: translateX(-50%) rotate(-2deg); }
.ticket-shadow-two { top: 56%; left: 14%; transform: rotate(1.5deg); opacity: .7; }
.camera-hint {
  position: absolute;
  right: 1rem; bottom: 1rem; left: 1rem;
  width: fit-content;
  max-width: calc(100% - 2rem);
  margin: auto;
  padding: .55rem 1rem;
  border-radius: 999px;
  background: rgba(0,0,0,.52);
  color: rgba(241,237,226,.9);
  font-size: .9375rem;
  font-weight: 650;
  text-align: center;
}
.camera-actions {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: .75rem 1.5rem max(1rem, env(safe-area-inset-bottom));
}
.camera-secondary, .camera-done { display: flex; min-height: 3.5rem; align-items: center; padding: 0 1rem; border-radius: .875rem; font-size: 1rem; font-weight: 650; line-height: 1.15; }
.camera-secondary { justify-self: start; border: 1.5px solid rgba(255,255,255,.3); }
.camera-done { justify-self: end; background: #1F6B4F; color: #FFFFFF; font-weight: 750; }
.shutter { display: grid; width: 5rem; height: 5rem; place-items: center; border: .3125rem solid #FFFFFF; border-radius: 50%; background: rgba(255,255,255,.14); }
.shutter span { display: block; width: 3.75rem; height: 3.75rem; border-radius: 50%; background: #FFFFFF; transition: transform .12s; }
.shutter:active span { transform: scale(.9); }

/* Per-photo results */
.result-list { display: grid; gap: .75rem; }
.result-card {
  position: relative;
  display: flex;
  min-height: 6.25rem;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  padding: 1.1rem 1.25rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}
.result-card > span:first-child { display: grid; min-width: 0; gap: .2rem; }
.result-card small { display: block; font-size: .9375rem; }
.eyebrow { font-size: .875rem; font-weight: 800; letter-spacing: .105em; text-transform: uppercase; }
.won-card { border: 1.5px solid var(--won-strong); }
.result-amount { margin-left: auto; font-size: 2.125rem; }
.result-zero { margin-left: auto; color: var(--ink-2); font-size: 1.5rem; }
.chevron { color: var(--ink-2); font-size: 1.75rem; }
.attention-card { border: 1.5px dashed var(--attention); }
.small-button { min-height: 3.25rem; padding: 0 1.25rem; border-radius: .75rem; }
.attention-button { background: var(--attention); color: #FFFFFF; }

/* Ticket evidence centerpiece */
.ticket-screen { display: flex; flex-direction: column; }
.evidence-card { margin: .25rem var(--gutter) 0; }
.ticket-photo {
  position: relative;
  height: clamp(18rem, 39vh, 21.25rem);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(135deg, #6F6A5D, #35332E 56%, #777165);
  box-shadow: inset 0 0 4rem rgba(0,0,0,.28);
}
.ticket-photo::after { content: ""; position: absolute; inset: 0; background: radial-gradient(circle at 73% 20%, rgba(255,255,255,.14), transparent 31%), linear-gradient(100deg, transparent 46%, rgba(255,255,255,.04) 48%, transparent 50%); pointer-events: none; }
.ticket-paper {
  position: absolute;
  top: 11%; left: 6%;
  width: 88%; height: 78%;
  padding: 1.1rem 1.25rem;
  transform: rotate(-2.1deg);
  overflow: hidden;
  border-radius: .25rem;
  background-color: #EEE9D9;
  background-image: repeating-linear-gradient(0deg, transparent 0, transparent 3px, rgba(62,58,47,.045) 4px);
  color: #3A3830;
  box-shadow: 0 .55rem 1.3rem rgba(0,0,0,.34);
}
.ticket-brand { font-family: var(--font-digits); font-size: 1.25rem; font-weight: 800; letter-spacing: .22em; }
.ticket-rule { height: .2rem; margin: .4rem 0 .6rem; background: #3A3830; opacity: .75; }
.ticket-micro { margin: .5rem 0; font-family: var(--font-digits); font-size: .55rem; letter-spacing: .1em; opacity: .65; }
.print-row { margin: 2.7rem -.25rem 0; font-family: var(--font-digits); font-size: clamp(.72rem, 3vw, .92rem); font-weight: 700; white-space: nowrap; }
.barcode { width: 72%; height: 1.6rem; margin-top: 1.1rem; background: repeating-linear-gradient(90deg, #3A3830 0 1px, transparent 1px 3px, #3A3830 3px 5px, transparent 5px 7px); opacity: .75; }
.read-overlay { position: absolute; z-index: 2; top: 52%; right: 0; left: 0; display: grid; justify-items: center; gap: .65rem; transform: translateY(-50%); pointer-events: none; }
.evidence-digits { display: flex; max-width: calc(100% - 1.25rem); gap: clamp(.16rem, 1.5vw, .44rem); }
.evidence-digits > span {
  position: relative;
  padding: .32rem clamp(.2rem, 1.3vw, .38rem);
  border-radius: .4375rem;
  background: rgba(255,255,255,.92);
  color: #201E19;
  box-shadow: 0 1px .3rem rgba(0,0,0,.28);
  font-size: clamp(.8rem, 4vw, 1.18rem);
  font-weight: 750;
}
.evidence-digits svg { position: absolute; top: 50%; left: 50%; width: 2.7rem; height: 2.5rem; overflow: visible; transform: translate(-50%,-50%); }
.evidence-digits path { fill: none; stroke: var(--pen); stroke-width: 3; stroke-linecap: round; opacity: .92; }
.read-label { max-width: calc(100% - 2rem); padding: .28rem .65rem; border-radius: 999px; background: rgba(0,0,0,.62); color: #FFFFFF; font-size: .75rem; font-weight: 650; text-align: center; }
.evidence-legend { display: flex; flex-wrap: wrap; gap: .625rem 1rem; padding: .6rem 0 0; color: var(--ink-2); font-size: .84375rem; }
.evidence-legend span { display: flex; align-items: center; gap: .38rem; }
.evidence-legend svg { width: 1.25rem; height: 1rem; }
.evidence-legend ellipse { fill: none; stroke: var(--pen); stroke-width: 1.8; }
.evidence-legend b { padding: .08rem .35rem; border: 1px solid var(--line); border-radius: .3rem; background: var(--surface); font-size: .75rem; font-weight: 500; }
.ticket-outcome { display: flex; align-items: center; justify-content: space-between; margin: .75rem var(--gutter) 0; padding: .75rem 1.25rem; border-radius: var(--radius); }
.won-panel { border: 1.5px solid var(--won-strong); background: var(--won-tint); }
.ticket-outcome strong:last-child { font-size: 2.125rem; }
.prize-table { margin: .65rem var(--gutter) 0; padding: .25rem 1.25rem; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.prize-row { display: flex; min-height: 3rem; align-items: center; justify-content: space-between; gap: 1rem; padding: .65rem 0; font-size: 1rem; }
.prize-row + .prize-row { border-top: 1px solid var(--line); }
.prize-row strong.digits { font-size: 1.0625rem; }
.prize-total { font-weight: 800; }
.prize-total strong.digits { font-size: 1.25rem; }
.fix-link { display: flex; min-height: 3.25rem; align-items: center; justify-content: center; margin: .25rem var(--gutter) max(.25rem, env(safe-area-inset-bottom)); font-size: .9375rem; font-weight: 700; }

/* Confirm */
.confirm-photo {
  position: relative;
  display: grid;
  height: clamp(10rem, 25vh, 14.375rem);
  place-items: center;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(155deg, #706B5E, #34322D);
}
.zoom-ticket { display: flex; width: 118%; gap: 1.25rem; justify-content: center; padding: 2rem 0; transform: rotate(-2deg); background: #EEE9D9; color: #3A3830; box-shadow: 0 .6rem 1rem rgba(0,0,0,.3); font-size: clamp(2rem, 10vw, 3.25rem); font-weight: 700; letter-spacing: .05em; }
.zoom-ticket .blurred { filter: blur(.075rem); opacity: .72; }
.mock-label { position: absolute; right: .7rem; bottom: .55rem; padding: .22rem .45rem; background: rgba(0,0,0,.55); color: #FFFFFF; font-family: var(--font-digits); font-size: .6rem; letter-spacing: .08em; }
.confirm-card { margin-top: 1rem; padding: 1.125rem; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.confirm-meta { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: .25rem 1rem; margin-bottom: .7rem; color: var(--ink-2); font-size: .8125rem; }
.confirm-meta strong { font-size: .875rem; letter-spacing: .04em; }
.digit-buttons { display: flex; gap: .5rem; }
.digit-buttons button { flex: 1; min-width: 0; height: 4.5rem; border: 1px solid var(--line); border-radius: .75rem; background: var(--bg); color: var(--ink); font-family: inherit; font-size: clamp(1.7rem, 8vw, 2.125rem); font-weight: 750; cursor: pointer; }
.digit-buttons button.uncertain { border: 2.5px solid var(--attention); background: var(--attention-tint); color: var(--attention); }
.digit-help { display: flex; align-items: flex-start; gap: .5rem; margin: .75rem 0 0; font-size: .9375rem; line-height: 1.45; }
.digit-help > span { flex: none; width: .625rem; height: .625rem; margin-top: .32rem; border-radius: .2rem; background: var(--attention); }

/* Session summary */
.summary-screen { display: flex; flex-direction: column; }
.summary-header { position: relative; padding: 1rem var(--gutter) .875rem; text-align: center; border-width: 0 0 1px; border-radius: 0; }
.summary-back { position: absolute; top: .5rem; left: var(--gutter); }
.summary-header h1 { margin: .5rem 4.25rem 0; line-height: 1.35; }
.summary-amount { display: block; margin-top: .05rem; font-size: clamp(2.75rem, 12vw, 3.25rem); line-height: 1.1; }
.summary-header p { margin: .15rem 0 0; color: var(--ink-2); font-size: .9375rem; }
.summary-list { display: grid; gap: .75rem; margin-top: .75rem; }
.draw-card { overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.draw-strip { display: grid; gap: .45rem; padding: .7rem 1rem; background: var(--strip); color: var(--strip-text); }
.draw-strip > div:first-child { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; }
.draw-strip strong { font-size: .84375rem; letter-spacing: .1em; }
.draw-strip small { color: var(--strip-muted); font-size: .75rem; }
.winning-numbers { display: flex; flex-wrap: wrap; align-items: center; gap: .25rem; }
.winning-numbers b { padding: .22rem .36rem; border-radius: .32rem; background: var(--strip-2); color: var(--won-strong); font-size: .9rem; }
.winning-numbers i { color: var(--strip-muted); font-style: normal; }
.winning-numbers em { padding: .22rem .36rem; border: 1px solid #4A463C; border-radius: .32rem; color: var(--strip-muted); font-size: .9rem; font-style: normal; font-weight: 700; }
.draw-row { display: flex; min-height: 3.75rem; align-items: center; justify-content: space-between; gap: 1rem; padding: .7rem 1rem; }
.draw-row + .draw-row { border-top: 1px solid var(--line); }
.draw-row > span { display: grid; gap: .1rem; }
.draw-row > span > strong { font-size: 1rem; }
.draw-row small { font-size: .8125rem; }
.draw-row > b { font-size: 1.25rem; }
.won-row { background: var(--won-tint); }
.compact-strip { gap: .3rem; }
.draw-results { color: var(--won-strong); font-size: clamp(.72rem, 3.25vw, .9375rem); font-weight: 700; line-height: 1.45; }
.pending-card { display: flex; align-items: center; gap: .75rem; padding: .85rem 1rem; border: 1.5px solid var(--pending); border-radius: var(--radius); background: var(--pending-tint); color: var(--pending); }
.pending-card > span { display: grid; flex: 1; gap: .2rem; }
.pending-card strong { font-size: .9375rem; line-height: 1.3; }
.pending-card small { font-size: .8125rem; }
.pending-card > b { flex: none; padding: .55rem .8rem; border-radius: .55rem; background: var(--pending); color: var(--surface); font-size: .8125rem; letter-spacing: .08em; text-transform: uppercase; }
.summary-actions { display: grid; gap: .25rem; padding-top: .6rem; }

/* About */
.about-screen { display: flex; flex-direction: column; }
.about-content { display: flex; flex: 1; flex-direction: column; align-items: center; gap: 1.5rem; padding: clamp(1.5rem, 6vh, 3.25rem) 1.75rem 1.5rem; text-align: center; }
.app-mark { position: relative; display: grid; width: 5.25rem; height: 5.25rem; place-items: center; border-radius: 1.25rem; background: var(--strip); }
.app-mark span { font-family: var(--font-digits); color: #58B98C; font-size: 2.375rem; font-weight: 700; }
.app-mark svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.app-mark path { fill: none; stroke: var(--pen); stroke-width: 3; stroke-linecap: round; opacity: .9; }
.about-content h2 { margin: 0; font-size: 1.75rem; line-height: 1.2; }
.about-content h2 span { color: var(--ink-2); font-weight: 400; }
.version { margin: .25rem 0 0; color: var(--ink-2); font-size: .9375rem; }
.about-copy { max-width: 20rem; margin: 0; font-size: 1.0625rem; line-height: 1.6; }
.about-content aside { max-width: 20rem; padding: 1rem 1.25rem; border: 1px solid var(--line); border-radius: .875rem; background: var(--surface); color: var(--ink-2); font-size: .875rem; line-height: 1.55; }
.privacy-note { display: flex; min-height: 3.5rem; align-items: center; justify-content: center; padding: .5rem var(--gutter) max(1rem, env(safe-area-inset-bottom)); color: var(--ink-2); font-size: .8125rem; text-align: center; }

@media (min-width: 48rem) {
  body { background: var(--surface-2); }
  #app { width: min(100%, 30rem); margin: 0 auto; box-shadow: 0 0 2.5rem rgba(32,30,25,.15); }
}

@media (max-height: 46rem) {
  .ticket-photo { height: 15.5rem; }
  .viewfinder { min-height: 20rem; }
  .about-content { gap: 1rem; padding-top: 1rem; }
}

@media (prefers-reduced-motion: no-preference) {
  .screen.route-enter { animation: route-in .16s ease-out; }
  @keyframes route-in { from { opacity: .5; transform: translateY(.2rem); } to { opacity: 1; transform: none; } }
}
