/*
 * World: a paper raffle counter. One accent (ticket red). Signature: the perforated stub.
 * App screens are neutral grey; the front door (.paper) is warm paper. 4px grid.
 * Redesigned with unslop by Damir Sokolovsky (CC BY 4.0), github.com/heydamir/unslop
 */
:root {
  color-scheme: light dark;
  --bg: #fafafa; --surface: #fff; --raised: #f4f4f5; --text: #171717; --text-2: #525252; --muted: #6b6b6b;
  --line: rgb(23 23 23 / .1); --tear: rgb(23 23 23 / .24); --control: #8a8a8a;
  --accent: #b3361b; --accent-strong: #962c15; --on-accent: #fff; --tint: #fbece8;
  --good: #146c35; --bad: #b91c1c;
  --ease: cubic-bezier(.22, 1, .36, 1);
}
.paper { --bg: #f7f4ee; --surface: #fdfbf7; --raised: #efe9df; --text: #1f1b16; --text-2: #5e554a; --muted: #6f6659; --line: rgb(31 27 22 / .12); --tear: rgb(31 27 22 / .28); }
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141415; --surface: #19191b; --raised: #232325; --text: #ededed; --text-2: #b4b4b9; --muted: #96969c;
    --line: rgb(237 237 237 / .1); --tear: rgb(237 237 237 / .24); --control: #6e6e74;
    --accent: #ff8a6b; --accent-strong: #ffa48b; --on-accent: #1f0f0a; --tint: #35201b;
    --good: #4cc38a; --bad: #ff8085;
  }
  .paper { --bg: #161513; --surface: #1c1a18; --raised: #262421; --text: #efe9de; --text-2: #bab2a6; --muted: #9b958a; --line: rgb(239 233 222 / .1); --tear: rgb(239 233 222 / .24); }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 80px; }
body { display: flex; flex-direction: column; min-height: 100vh; margin: 0; background: var(--bg); color: var(--text); font: 16px/24px system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; overflow-wrap: break-word; font-variant-numeric: tabular-nums; }
main { flex: 1; width: 100%; max-width: 72rem; margin: 0 auto; padding: 24px max(16px, env(safe-area-inset-right)) 64px max(16px, env(safe-area-inset-left)); }
main.narrow { max-width: 40rem; }
main.auth { max-width: 26rem; padding-top: 48px; }
h1, h2, h3 { font-weight: 600; margin: 0; text-wrap: balance; }
h1 { font-size: 28px; line-height: 32px; }
h2 { font-size: 20px; line-height: 28px; margin: 48px 0 16px; }
h3 { font-size: 16px; line-height: 24px; }
p { margin: 8px 0; }
b, strong { font-weight: 600; }
a { color: var(--accent); text-underline-offset: 3px; }
code, .hash, td { overflow-wrap: anywhere; }
.muted { color: var(--text-2); }
.small { font-size: 14px; line-height: 20px; }
.center { text-align: center; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.icon { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.skip { position: absolute; left: -999rem; }
.skip:focus { left: 16px; top: 8px; z-index: 50; background: var(--surface); padding: 12px 16px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }

/* Header, desktop links, phone tab bar */
.bar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px; min-height: 60px; padding: 8px max(16px, env(safe-area-inset-right)) 8px max(16px, env(safe-area-inset-left)); background: var(--bg); border-bottom: 1px solid var(--line); }
.logo { display: flex; align-items: center; gap: 8px; min-height: 44px; font-size: 18px; font-weight: 600; color: var(--text); text-decoration: none; white-space: nowrap; }
.top { display: flex; gap: 4px; margin-left: 16px; }
.top a { display: flex; align-items: center; min-height: 44px; padding: 0 12px; border: 1px solid transparent; border-radius: 8px; color: var(--text-2); text-decoration: none; }
.top a:hover { color: var(--text); background: var(--raised); }
.top a[aria-current=page] { color: var(--text); background: var(--raised); border-color: var(--line); font-weight: 500; }
.who, .guest { display: flex; align-items: center; gap: 12px; margin: 0 0 0 auto; }
.name { max-width: 12rem; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; color: var(--muted); }
.guest > a:not(.button) { display: flex; align-items: center; min-height: 44px; color: var(--text); white-space: nowrap; }
.tabs { display: none; }
/* Narrowest phones, logged out: keep the logo mark, so Log in and Sign up still fit. Name stays readable to screen readers. */
@media (max-width: 23rem) {
  .bar:has(.guest) .logo span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
}
@media (max-width: 47.99rem) {
  .top, .name { display: none; }
  .tabs { display: flex; position: fixed; inset: auto 0 0 0; z-index: 20; gap: 4px; background: var(--surface); border-top: 1px solid var(--line); padding: 4px max(4px, env(safe-area-inset-right)) calc(4px + env(safe-area-inset-bottom)) max(4px, env(safe-area-inset-left)); }
  .tabs a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; min-height: 52px; border-radius: 8px; font-size: 12px; line-height: 16px; color: var(--text-2); text-decoration: none; }
  .tabs a[aria-current=page] { color: var(--text); background: var(--raised); font-weight: 500; }
  .tabs a[aria-current=page] .icon { color: var(--accent); }
  .tabs ~ footer { padding-bottom: calc(96px + env(safe-area-inset-bottom)); }
}

/* Footer and trust pages */
.foot { width: 100%; max-width: 72rem; margin: 0 auto; padding: 24px max(16px, env(safe-area-inset-right)) 32px max(16px, env(safe-area-inset-left)); border-top: 1px solid var(--line); font-size: 14px; line-height: 20px; color: var(--text-2); }
.foot p { margin: 0 0 4px; }
.foot nav { display: flex; flex-wrap: wrap; column-gap: 16px; }
.foot nav a { display: inline-flex; align-items: center; min-height: 44px; }
.prose li { margin-bottom: 8px; }
.prose .rows li { margin: 0; }
.promise h2 { margin: 0 0 12px; }
.promise .rows > li:last-child { border-bottom: 0; padding-bottom: 0; }
main.narrow .tiles { grid-template-columns: repeat(auto-fit, minmax(min(45%, 11rem), 1fr)); }
.rows .paid { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex: none; }

/* Buttons */
button, .button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; margin: 0; padding: 8px 16px; font: inherit; font-weight: 500; line-height: 20px; text-align: center; text-decoration: none; color: var(--on-accent); background: var(--accent); border: 1px solid var(--accent); border-radius: 8px; cursor: pointer; touch-action: manipulation; transition: background-color .15s var(--ease), border-color .15s var(--ease), transform .15s var(--ease); }
button:hover, .button:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
button:active, .button:active { transform: scale(.98); }
button:disabled { opacity: .6; cursor: progress; }
button.secondary, .button.secondary { color: var(--text); background: var(--surface); border-color: var(--line); }
button.secondary:hover, .button.secondary:hover { background: var(--raised); border-color: var(--tear); }
.button.small { white-space: nowrap; }
.button.big { min-height: 48px; padding: 12px 20px; }
.wide { width: 100%; }
button.icon-button { width: 44px; padding: 0; color: var(--text-2); background: transparent; border-color: transparent; }
button.icon-button:hover { color: var(--text); background: var(--raised); border-color: transparent; }

/* The ticket: a card with a perforated tear line */
.tix, .card { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 20px; }
.tix { position: relative; display: flex; flex-direction: column; }
.tear { position: relative; height: 0; margin: 20px -20px 16px; border-top: 2px dashed var(--tear); }
.tear::before, .tear::after { content: ""; position: absolute; top: -9px; width: 16px; height: 16px; background: var(--bg); border: 1px solid var(--line); border-radius: 50%; }
.tear::before { left: -9px; clip-path: inset(0 0 0 50%); }
.tear::after { right: -9px; clip-path: inset(0 50% 0 0); }
.stub { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin: 0 0 12px; color: var(--text-2); }
.stub strong { font-size: 28px; line-height: 32px; color: var(--accent); }
.figure { margin: 8px 0 0; font-size: 32px; line-height: 36px; font-weight: 600; }
.meta { margin: 4px 0; font-size: 14px; line-height: 20px; color: var(--muted); }

/* Front page */
.hero { display: grid; gap: 32px; padding: 32px 0 16px; }
.hero h1 { font-size: 40px; line-height: 44px; letter-spacing: -.02em; }
.lead { max-width: 30rem; margin: 16px 0 24px; font-size: 18px; line-height: 28px; color: var(--text-2); }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 0; }
.hero-tix { padding: 24px; box-shadow: 0 8px 24px rgb(0 0 0 / .06); }
.hero-tix .tear { margin-inline: -24px; }
.hero-tix .figure { font-size: 56px; line-height: 60px; letter-spacing: -.03em; }
.hero-tix .stub { margin: 0; }
.hero-tix .stub + .stub { margin-top: 8px; }
.hero-tix .stub strong { font-size: 20px; line-height: 28px; }
@media (min-width: 60rem) {
  .hero { grid-template-columns: 1fr 1fr; align-items: center; gap: 64px; padding: 96px 0 64px; }
  .hero h1 { font-size: 56px; line-height: 60px; letter-spacing: -.03em; }
}
/* Log in: form first on phones; the ticket sits beside it on wide screens. */
.login { display: grid; gap: 32px; max-width: 26rem; padding-top: 32px; }
.login .card { padding: 24px; }
.login .card h1 { margin-bottom: 4px; }
.login .wide { min-height: 48px; }
input[aria-invalid=true] { border-color: var(--bad); }
.caps { margin: -8px 0 16px; color: var(--bad); }
@media (min-width: 60rem) {
  .login { grid-template-columns: 1fr 1fr; align-items: center; max-width: 64rem; gap: 64px; min-height: calc(100vh - 60px); padding-block: 48px; }
  .login > :first-child { order: 2; }
}
.rows { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.rows > li { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 56px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.rows span.grow { display: flex; flex-direction: column; min-width: 0; }
.rows .amount { font-size: 18px; font-weight: 600; white-space: nowrap; }
.steps { counter-reset: step; }
.steps > li { justify-content: flex-start; align-items: baseline; }
.steps > li::before { counter-increment: step; content: counter(step); width: 24px; flex: none; font-weight: 600; color: var(--accent); }
.steps h3, .steps p { margin: 0; }
.trust { display: grid; gap: 24px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 16rem), 1fr)); }
.trust p { color: var(--text-2); }
.cta { margin-top: 48px; padding-top: 24px; border-top: 1px solid var(--line); }
.cta h2 { margin-top: 0; }

/* Grids and lists */
.grid { list-style: none; margin: 0; padding: 0; display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 19rem), 1fr)); }
.list { list-style: none; margin: 16px 0; padding: 0; display: grid; gap: 8px; }
.page-head { margin-bottom: 24px; }
.page-head p { margin: 4px 0 0; }
.section-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; margin-bottom: 16px; }
.section-head:has(> h2) { margin-top: 48px; align-items: baseline; }
.section-head h2 { margin: 0; }
.section-head .row { margin: 0; }
.section-head .row > * { flex: 0 1 auto; }
.row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.row > * { flex: 1 1 8rem; }
.empty { padding: 32px 16px; text-align: center; color: var(--text-2); }
.chip { display: inline-block; padding: 0 8px; font-size: 12px; line-height: 20px; color: var(--text-2); background: var(--raised); border: 1px solid var(--line); border-radius: 4px; }
.chip.good { color: var(--good); }
.draw { scroll-margin-top: 80px; }
.draw:target { border-color: var(--accent); }
.draw p { margin: 4px 0; }
.draw .figure { margin-top: 12px; }
.draw-top { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 12px; }
.draw-top h2, .draw-top h3 { margin: 0; font-size: 18px; line-height: 24px; }
.draw .spots { margin-top: 12px; }
.push { margin-top: auto; }
a.push { margin-top: auto; }
.countdown { font-size: 14px; line-height: 20px; color: var(--muted); white-space: nowrap; }
.countdown.urgent { color: var(--bad); font-weight: 500; }
progress { appearance: none; display: block; width: 100%; height: 4px; margin-top: 12px; border: 0; border-radius: 4px; overflow: hidden; background: var(--raised); }
progress::-webkit-progress-bar { background: var(--raised); }
progress::-webkit-progress-value { background: var(--accent); }
progress::-moz-progress-bar { background: var(--accent); }
summary { display: flex; align-items: center; min-height: 44px; font-weight: 500; cursor: pointer; }
summary::after { content: "+"; margin-left: auto; padding-left: 8px; color: var(--muted); }
details[open] > summary::after { content: "\2212"; }
.ranks-list { list-style: none; margin: 0; padding: 0; }
.ranks-list li { display: flex; justify-content: space-between; gap: 16px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.ranks-list li > span:last-child { text-align: right; }
.ranks-list li:last-child { border-bottom: 0; }
.ranks-list.card { padding: 4px 20px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(45%, 13rem), 1fr)); gap: 12px; margin: 0 0 24px; }
.tiles .card { padding: 16px; }
.tiles dt { font-size: 14px; line-height: 20px; color: var(--muted); }
.tiles dd { margin: 4px 0 0; font-size: 28px; line-height: 32px; font-weight: 600; }
.tiles dd.small-value { font-size: 16px; line-height: 24px; }
.tiles .card.attention { background: var(--tint); }
.attention dt { color: var(--text-2); }
.ticket h2 { margin: 0; font-size: 18px; line-height: 24px; }
.ticket.won { background: var(--tint); }
.ticket.won .meta { color: var(--text-2); }
.won-line { font-size: 20px; line-height: 28px; font-weight: 600; color: var(--accent); }

/* Forms */
label { display: block; margin: 16px 0; font-weight: 500; }
label small { font-weight: 400; color: var(--muted); }
label[for] { margin-bottom: 4px; }
input, select, textarea { display: block; width: 100%; min-height: 44px; margin-top: 4px; padding: 8px 12px; font: inherit; font-weight: 400; color: inherit; background: var(--surface); border: 1px solid var(--control); border-radius: 8px; }
input[type=checkbox] { width: 20px; height: 20px; min-height: 0; margin: 0; accent-color: var(--accent); }
label.inline { display: flex; align-items: center; gap: 8px; min-height: 44px; font-weight: 400; }
.with-button { display: flex; gap: 8px; margin-bottom: 16px; }
.with-button input { margin: 0; min-width: 0; }
.with-button button { flex: none; }
fieldset { min-width: 0; margin: 0 0 16px; }
legend { float: left; width: 100%; padding: 0; font-weight: 600; }
legend + * { clear: both; }
legend + label { padding-top: 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; padding-top: 12px; }
button.chip-button { font-size: 14px; color: var(--text); background: var(--raised); border-color: var(--line); }
button.chip-button:hover { background: var(--raised); border-color: var(--tear); }
.rank-row { display: grid; grid-template-columns: 64px 1fr 1fr; align-items: end; gap: 8px; }
.rank-row label { margin: 8px 0 0; font-size: 14px; }
.rank-name { align-self: center; padding-top: 20px; color: var(--text-2); }
@media (max-width: 24rem) {
  .rank-row { grid-template-columns: 1fr 1fr; }
  .rank-name { grid-column: 1 / -1; }
}
.two-col { display: grid; gap: 16px; margin-top: 24px; }
.preview h2 { margin: 0 0 8px; }
@media (min-width: 60rem) {
  .two-col { grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); align-items: start; }
  .preview { position: sticky; top: 80px; }
}
.ok { color: var(--good); }
.warn { color: var(--bad); }
.alert, .notice { padding: 12px 16px; background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--good); border-radius: 8px; }
.alert { border-left-color: var(--bad); }
p.alert, p.notice { margin: 0 0 16px; }
/* Visible wherever the page has scrolled to; goes away by itself. */
p.toast, .toast { position: fixed; z-index: 30; left: 50%; bottom: calc(16px + env(safe-area-inset-bottom)); transform: translateX(-50%); width: min(28rem, calc(100% - 32px)); margin: 0; font-weight: 500; box-shadow: 0 8px 24px rgb(0 0 0 / .16); animation: dismiss 0s linear 6s forwards; }
@media (max-width: 47.99rem) { .toast { bottom: calc(80px + env(safe-area-inset-bottom)); } }

/* Tables become cards on phones */
.stack { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--line); }
th, td { padding: 12px; text-align: left; vertical-align: middle; border-bottom: 1px solid var(--line); }
th { font-size: 14px; font-weight: 500; color: var(--muted); }
td form { margin: 0; }
@media (max-width: 47.99rem) {
  .stack, .stack tbody, .stack tr { display: block; }
  .stack thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .stack tr { padding: 8px 0; border-bottom: 1px solid var(--line); }
  .stack td { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 4px 12px; text-align: right; border: 0; }
  .stack td::before { content: attr(data-label); text-align: left; color: var(--muted); }
  .stack td[data-label=Action]::before { content: none; }
  .stack td[data-label=Action] form, .stack td[data-label=Action] button { width: 100%; }
}

/* Live room (a moment) and verify */
.stage { text-align: center; }
.stage .figure { margin: 12px 0 0; }
.stage .stub { margin: 0; }
.headline { margin: 24px 0 4px; font-size: 20px; line-height: 28px; font-weight: 500; }
.clock { margin: 0; font-size: 56px; line-height: 60px; font-weight: 600; letter-spacing: -.03em; color: var(--accent); }
.clock:empty { display: none; }
.shuffle { font: 600 56px/60px ui-monospace, Consolas, monospace; color: var(--accent); }
.winner .who-won { display: flex; flex-direction: column; min-width: 0; }
.winner .who-won span { font-size: 14px; line-height: 20px; color: var(--muted); }
.winner { display: grid; grid-template-columns: 56px 1fr auto; align-items: center; gap: 12px; padding: 12px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; animation: rise .4s var(--ease) both; }
.winner .rank { font-size: 14px; color: var(--muted); }
.winner .amount { font-weight: 600; }
.winner:first-child { padding-block: 20px; font-size: 20px; line-height: 28px; }
.winner:first-child .amount { font-size: 28px; color: var(--accent); }
.winner.me { background: var(--tint); border-color: var(--accent); }
.result { padding: 16px; text-align: center; background: var(--raised); border-radius: 12px; }
.result.won { font-size: 28px; line-height: 36px; font-weight: 600; color: var(--accent); background: var(--tint); }
.confetti { position: fixed; inset: 0; z-index: 40; overflow: hidden; pointer-events: none; }
.confetti i { position: absolute; top: -24px; width: 8px; height: 16px; background: var(--accent); animation: fall 2.6s ease-in forwards; }
.confetti i:nth-child(3n) { background: #e8a33d; }
.confetti i:nth-child(3n+1) { background: var(--text-2); }
.checks > li { justify-content: flex-start; align-items: flex-start; }
.checks .chip { flex: none; min-width: 64px; text-align: center; }
.pass { color: var(--good); }
.fail { color: var(--bad); }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }
@keyframes fall { to { transform: translateY(105vh) rotate(540deg); } }
@keyframes dismiss { to { visibility: hidden; } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
