*,
*::before,
*::after {
  box-sizing: border-box;
  min-width: 0;
}

:root {
  color-scheme: dark;
  scrollbar-gutter: stable;
  text-wrap: pretty;
  overflow-wrap: break-word;
  font-synthesis: none;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;

  --bg: oklch(0.17 0.012 25);
  --surface: oklch(0.22 0.014 25);
  --line: color-mix(in oklch, var(--fg) 14%, transparent);
  --fg: oklch(0.96 0.005 80);
  --muted: color-mix(in oklch, var(--fg) 62%, var(--bg));
  --red: oklch(0.6 0.235 28);
  /* Print inks: mustard is the main accent, red the second ink, olive the faded third */
  --mustard: oklch(0.82 0.15 98);
  --olive: oklch(0.58 0.09 100);
  --gold: var(--mustard);
  --silver: oklch(0.84 0.012 90);
  --bronze: oklch(0.6 0.1 60);
  --paper: oklch(0.975 0.012 90);
  --paper-shade: color-mix(in oklch, var(--paper), oklch(0.6 0.02 80) 18%);
  --ink: oklch(0.22 0 none);
  --ink-muted: color-mix(in oklch, var(--ink) 58%, var(--paper));
  /* Light speckle so the black reads as printed, not flat */
  --bg-grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='260' height='260'%3E%3Cfilter id='g'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0.96 0 0 0 0 0.94 0 0 0 0 0.9 0.26 0 0 0 -0.09'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23g)'/%3E%3C/svg%3E");
  /* Paper grain (fine speckle) and fibers (faint horizontal streaks), both SVG noise */
  --paper-grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0.3 0 0 0 0 0.26 0 0 0 0 0.2 0.45 0 0 0 -0.13'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  --paper-fibers: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='600' height='300'%3E%3Cfilter id='f'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.004 0.28' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0.35 0 0 0 0 0.3 0 0 0 0 0.24 0.3 0 0 0 -0.11'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23f)'/%3E%3C/svg%3E");
  --marker: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 400 100' preserveAspectRatio='none'%3E%3Cfilter id='r' x='-5%25' y='-25%25' width='110%25' height='150%25'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.035 0.09' numOctaves='3' seed='4' result='edge'/%3E%3CfeDisplacementMap in='SourceGraphic' in2='edge' scale='10' result='rough'/%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.004 0.3' numOctaves='2' seed='9' result='streak'/%3E%3CfeColorMatrix in='streak' values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1.8 1.8' result='streakA'/%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='2' seed='2' result='sp'/%3E%3CfeColorMatrix in='sp' values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -2 2.35' result='spA'/%3E%3CfeComposite in='rough' in2='streakA' operator='in' result='streaked'/%3E%3CfeComposite in='streaked' in2='spA' operator='in'/%3E%3C/filter%3E%3Cpath d='M6 20 Q120 10 250 15 T396 13 L393 88 Q260 95 140 90 T4 92 Z' fill='%23d0231b' fill-opacity='0.92' filter='url(%23r)'/%3E%3C/svg%3E");

  --font-display: 'Anton', 'Impact', sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, monospace;
  --font-body: 'Inter', system-ui, sans-serif;

  --text-hero: clamp(3.25rem, 1.6rem + 7vw, 7.5rem);
  --text-total: clamp(2.5rem, 1.4rem + 5vw, 5.5rem);
  --text-h2: clamp(1.75rem, 1.3rem + 2vw, 2.75rem);
  --space-section: clamp(3rem, 1.5rem + 5vw, 6rem);
  --gutter: clamp(1rem, 0.5rem + 2.5vw, 2.5rem);
  --wall-h: clamp(16rem, 10rem + 22vw, 30rem);

  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
}

body {
  margin: 0;
  min-height: 100svh;
  background: var(--bg-grain), var(--bg);
  color: var(--fg);
  font-family: var(--font-body);
  line-height: 1.5;
}

h1, h2 { text-wrap: balance; margin: 0; }
svg { display: block; max-width: 100%; }
input, select { font-size: max(16px, 1rem); }
button { touch-action: manipulation; user-select: none; -webkit-user-select: none; font: inherit; color: inherit; }

:focus-visible { outline: 2px solid var(--mustard); outline-offset: 3px; }

.visually-hidden {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  overflow: clip;
  clip-path: inset(50%);
  white-space: nowrap;
}

.wrap {
  inline-size: min(100% - 2 * var(--gutter), 72rem);
  margin-inline: auto;
}

/* Fine print as texture: short blocks of the rules' fees and points in tiny type, like the
   copy blocks on a screen-printed poster */
.fine-print {
  position: absolute;
  z-index: 0;
  inline-size: min(22rem, 38vw);
  margin: 0;
  color: var(--fg);
  font-family: var(--font-mono);
  font-size: 8px;
  line-height: 1.4;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  text-align: justify;
  opacity: 0.32;
  pointer-events: none;
  user-select: none;
}

.fine-print-tl { inset-block-start: 2rem; inset-inline-start: var(--gutter); }
.fine-print-br { inset-block-end: 2rem; inset-inline-end: var(--gutter); }
.hero > :not(.fine-print) { position: relative; z-index: 1; }

/* Beside section titles, only where there is room for it */
.section-head { position: relative; }
.section-head > :not(.fine-print) { position: relative; z-index: 1; }
.section-head .fine-print { inset-block-start: 0.25rem; inset-inline-end: 0; inline-size: 15rem; opacity: 0.22; }
/* Keep the subtitle clear of the block */
.section-head > p:not(.fine-print) { max-inline-size: calc(100% - 17rem); }

@media (width < 64rem) {
  .section-head .fine-print { display: none; }
  .section-head > p:not(.fine-print) { max-inline-size: none; }
}

@media (width < 48rem) {
  .fine-print-br { display: none; }
  .fine-print-tl { inline-size: auto; inset-inline-end: var(--gutter); inset-block-start: 1.25rem; }
}

/* Hero: one receipt on black */

.hero {
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 2.5rem;
  min-block-size: 100svh;
  padding: var(--space-section) var(--gutter) calc(var(--space-section) * 0.6);
  overflow-x: clip; /* the tilted paper and stamp must not widen the page */
  position: relative;
  background: var(--bg-grain), radial-gradient(ellipse 70% 55% at 50% 42%, oklch(0.23 0.012 25), var(--bg));
}

.hero-paper {
  position: relative;
  inline-size: min(100%, 31rem);
  rotate: -1.2deg;
  /* Shadow on the wrapper: a mask on the paper itself would cut it off */
  filter:
    drop-shadow(0 1px 1px oklch(0 0 none / 0.4))
    drop-shadow(0 28px 36px oklch(0 0 none / 0.6));
}

.paper {
  --tooth: 7px;
  background-color: var(--paper);
  background-image:
    var(--paper-grain),
    var(--paper-fibers),
    linear-gradient(90deg, oklch(0 0 none / 0.07), transparent 7% 93%, oklch(0 0 none / 0.07)),
    linear-gradient(oklch(1 0 none / 0.45), transparent 18% 82%, oklch(0 0 none / 0.05));
  color: var(--ink);
  mask:
    conic-gradient(from 135deg at top, #0000, #000 1deg 89deg, #0000 90deg) top / calc(2 * var(--tooth)) var(--tooth) repeat-x,
    linear-gradient(#000 0 0) center / 100% calc(100% - 2 * var(--tooth)) no-repeat,
    conic-gradient(from -45deg at bottom, #0000, #000 1deg 89deg, #0000 90deg) bottom / calc(2 * var(--tooth)) var(--tooth) repeat-x;
}

.hero-receipt {
  padding: calc(1.75rem + var(--tooth)) clamp(1.25rem, 0.7rem + 2.5vw, 2.25rem) calc(1.75rem + var(--tooth));
  font-family: var(--font-mono);
}

.hr-top {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin: 0;
  color: var(--ink-muted);
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.hero-receipt h1 {
  margin-block: 1.25rem 0;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(2.75rem, 1.9rem + 4vw, 4.25rem);
  line-height: 0.95;
  text-transform: uppercase;
  color: color-mix(in oklch, var(--ink) 92%, var(--paper));
}

.hr-rule { margin-block: 1.25rem; border-block-start: 1px dashed var(--ink-muted); }
.hr-rule-double { border-block-start: 3px double var(--ink); }

.hr-copy { display: grid; gap: 0.75rem; font-size: 0.875rem; line-height: 1.55; }
.hr-copy p { margin: 0; }

.hr-signoff {
  display: grid;
  gap: 0.75rem;
  margin-block-start: 1.25rem;
  padding-block-start: 1.25rem;
  border-block-start: 1px dashed var(--ink-muted);
  font-size: 0.875rem;
  line-height: 1.55;
}

.hr-signoff p { margin: 0; }

.hr-sign {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem 0.75rem;
  margin-block-start: 0.25rem;
}

.hr-name { font-weight: 600; }

.hr-sign a {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  color: inherit;
  text-decoration: underline;
  text-decoration-color: color-mix(in oklch, var(--ink) 40%, transparent);
  text-underline-offset: 0.2em;
}

.hr-sign svg { flex: none; inline-size: 0.875rem; block-size: 0.875rem; fill: currentColor; }
.hr-sign a:active { opacity: 0.7; }

@media (hover: hover) and (pointer: fine) {
  .hr-sign a:hover { color: var(--red); text-decoration-color: currentColor; }
}

.hr-total {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.25rem 1rem;
  margin: 0;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
}

.hr-total > span:last-child { font-size: 1.375rem; font-variant-numeric: tabular-nums; }

.hr-fine {
  margin: 0.375rem 0 0;
  color: var(--ink-muted);
  font-size: 0.7rem;
  text-transform: uppercase;
}

.hr-barcode { display: flex; justify-content: center; margin-block-start: 2.75rem; }
.hr-barcode .barcode { inline-size: 13rem; block-size: 2.75rem; opacity: 0.88; }

.hero-receipt { position: relative; }

/* Marker swipe behind the headline: one rough stroke per line (box-decoration-break clones it),
   same speckled ink as the stamp. */
.marker {
  padding-inline: 0.1em;
  margin-inline: -0.1em;
  background: var(--marker) 0 72% / 100% 80% no-repeat;
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
}

@media (prefers-reduced-motion: no-preference) {
  .marker { animation: swipe 600ms var(--ease-out) 1100ms both; }
  .marker:nth-of-type(2) { animation-delay: 1700ms; }
  @keyframes swipe { from { background-size: 0% 80%; } }
}

/* Rubber stamp: ink speckle comes from the SVG filter, multiply lets the paper show through */
.stamp {
  position: absolute;
  inset-block-end: 0.25rem;
  inset-inline-end: clamp(0.5rem, 0rem + 2vw, 1.5rem);
  inline-size: clamp(7rem, 5.5rem + 6vw, 9rem);
  rotate: -14deg;
  color: color-mix(in oklch, var(--red) 88%, oklch(0.3 0.1 20));
  mix-blend-mode: multiply;
  opacity: 0.9;
  overflow: visible;
}

.stamp-ring { font-family: var(--font-mono); font-weight: 600; font-size: 12.5px; letter-spacing: 1.6px; fill: currentColor; }
.stamp-core { font-family: var(--font-display); font-size: 40px; letter-spacing: 2px; fill: currentColor; }

.scroll-cue {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  text-decoration: none;
}

.scroll-cue:active { opacity: 0.7; }

@media (hover: hover) and (pointer: fine) {
  .scroll-cue:hover { color: var(--fg); }
}

@media (prefers-reduced-motion: no-preference) {
  .hero-paper { animation: drop-in 900ms var(--ease-out) both; }
  .stamp { animation: stamp-down 260ms var(--ease-out) 950ms both; }
  @keyframes drop-in { from { opacity: 0; translate: 0 -2rem; rotate: -4deg; } }
  @keyframes stamp-down { from { opacity: 0; scale: 1.5; } }
}

/* Folded receipt (JS only): an accordion in three. The middle third starts rotated -180deg behind
   the top third; the bottom third hangs from the middle one at +180deg. Both swing flat while the
   fold grows to full height. */

.hero-paper { --unfold-dur: 1300ms; --unfold-ease: cubic-bezier(0.45, 0, 0.2, 1); --peek: 0.875rem; }
.fold { position: relative; }
.fold-top { position: relative; z-index: 1; }

/* Keep the full receipt from flashing before the script folds it */
.js .hero-paper:not(.fold-ready, .is-done) { visibility: hidden; }

/* Top third stays put: the hero no longer re-centers as the receipt grows */
.js .hero {
  align-content: start;
  padding-block-start: max(var(--space-section), (100svh - var(--third, 20rem) - 5rem) / 2);
}

.hero-paper.fold-ready .fold { block-size: calc(var(--third) + var(--peek)); transition: block-size var(--unfold-dur) var(--unfold-ease); }
.hero-paper.fold-ready .fold-top { block-size: var(--third); overflow: clip; }
.hero-paper.is-open .fold { block-size: var(--full); }

.fold-rest {
  position: absolute;
  inset-inline: 0;
  inset-block-start: var(--third);
  perspective: 1800px;
  perspective-origin: 50% 0;
  transition: translate var(--unfold-dur) var(--unfold-ease), rotate var(--unfold-dur) var(--unfold-ease);
}

/* Closed, the folds slip down and fan out from their top-left corner, so the bottom fold peeks
   out under the right side and as a sliver on the left. Pivoting from the top-left keeps their
   top edge below the torn edge of the front panel. */
.hero-paper.fold-ready:not(.is-open) .fold-rest {
  transform-origin: 0 calc(var(--third) * -1);
  translate: 0 var(--peek);
  rotate: 2deg;
}

.fold-mid,
.fold-end {
  position: absolute;
  inset-inline: 0;
  block-size: var(--third);
  transform-origin: top center;
  transform-style: preserve-3d;
  transition: transform var(--unfold-dur) var(--unfold-ease);
}

.fold-mid { inset-block-start: 0; transform: rotateX(-180deg); }
.fold-end { inset-block-start: var(--third); transform: rotateX(180deg); }
.hero-paper.is-open :is(.fold-mid, .fold-end) { transform: rotateX(0deg); }

.fold-slice {
  position: relative;
  block-size: var(--third);
  overflow: clip;
  backface-visibility: hidden;
}

.fold-slice > .paper { translate: 0 calc(var(--third) * var(--slice) * -1); }

/* Light falls off on the panels that are still turning */
.fold-shade {
  position: absolute;
  inset: 0;
  background: linear-gradient(oklch(0 0 none / 0.5), oklch(0 0 none / 0.12));
  pointer-events: none;
  transition: opacity var(--unfold-dur) var(--unfold-ease);
}

.fold-end .fold-shade { background: linear-gradient(oklch(0 0 none / 0.1), oklch(0 0 none / 0.4)); }
.hero-paper.is-open .fold-shade { opacity: 0; }

/* Crease shadow along the fold while it is closed */
.fold-top::after {
  content: "";
  position: absolute;
  inset-inline: 0;
  inset-block-end: 0;
  block-size: 1.5rem;
  background: linear-gradient(to top, oklch(0 0 none / 0.22), transparent);
  opacity: 0;
  pointer-events: none;
  transition: opacity 400ms var(--ease-out);
}

.hero-paper.fold-ready .fold-top::after { opacity: 1; }
.hero-paper.is-open .fold-top::after { opacity: 0; }

/* The paper keeps two faint creases once opened */
.hero-paper.is-open::before,
.hero-paper.is-open::after {
  content: "";
  position: absolute;
  z-index: 1;
  inset-inline: 0;
  inset-block-start: calc(var(--third) - 1px);
  block-size: 3px;
  background: linear-gradient(oklch(0 0 none / 0.09), oklch(1 0 none / 0.35));
  pointer-events: none;
}

/* The second crease folded the other way, so its light and shadow swap */
.hero-paper.is-open::after {
  inset-block-start: calc(var(--third) * 2 - 1px);
  background: linear-gradient(oklch(1 0 none / 0.35), oklch(0 0 none / 0.09));
}

.unfold-hit {
  position: absolute;
  inset: 0;
  z-index: 2;
  border: 0;
  background: none;
  color: transparent;
  cursor: pointer;
}

.unfold-hit[hidden] { display: none; }

/* The stamp lands after the receipt opens */
.hero-paper.fold-ready .stamp { opacity: 0; animation: none; }

@media (prefers-reduced-motion: no-preference) {
  .hero-paper.is-done .stamp { animation: stamp-down 260ms var(--ease-out) both; }
}

/* Summary panel. Stacked under the wall by default; where the bottom-right corner of the wall
   is empty (wide screens), the script adds .is-overlay and it sits in that corner instead. */
.wall-stage { position: relative; }

.wall-stats {
  inline-size: min(100% - 2 * var(--gutter), 72rem);
  margin: 1rem auto 0;
}

.wall-stage.is-overlay .wall-stats {
  position: absolute;
  inset-block-end: 2rem;
  inset-inline-end: max(var(--gutter), (100% - 72rem) / 2);
  inline-size: min(27rem, 46%);
  margin: 0;
}

/* Counts as a funnel: participants make ideas, ideas become finalist entries, some win metals */
.flow {
  display: grid;
  grid-template-columns: repeat(4, auto);
  justify-content: start;
  column-gap: 2.25rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.flow li { position: relative; display: grid; }

.flow li + li::before {
  content: "→";
  position: absolute;
  inset-inline-start: -1.6rem;
  inset-block-start: 0.3rem;
  color: var(--muted);
  font-family: var(--font-mono);
}

.flow b { font-family: var(--font-mono); font-size: 1.5rem; font-weight: 600; font-variant-numeric: tabular-nums; line-height: 1.2; }
.flow span { color: var(--muted); font-size: 0.6875rem; text-transform: uppercase; letter-spacing: 0.08em; }
.flow-sub { margin-block: 0.5rem 0; color: var(--muted); font-size: 0.8rem; }

/* Percentages on the left, the note on the right */
.stats-foot {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: start;
  gap: 1.5rem;
  margin-block-start: 1.5rem;
}

.pcts { display: grid; gap: 0.75rem; }
.pcts p { display: grid; margin: 0; }

.pcts strong {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(2rem, 1.5rem + 1.75vw, 2.75rem);
  line-height: 1;
  color: var(--red);
}

.pcts strong.gold { color: var(--gold); }
.pcts span { font-size: 0.85rem; }

.stats-note { margin: 0; color: var(--muted); font-size: 0.8rem; line-height: 1.5; max-inline-size: 36rem; }

.wall-stats { container-type: inline-size; }

/* Narrow: the funnel goes 2 by 2, without the arrows that would start a row */
@container (max-width: 25rem) {
  .flow { grid-template-columns: repeat(2, auto); row-gap: 0.75rem; }
  .flow li:nth-child(odd)::before { display: none; }
}



/* Wall of tickets */

.wall-section { padding-block: calc(var(--space-section) * 0.4) var(--space-section); }

/* Titles printed in two inks that didn't quite line up: mustard over a slightly offset red */
.section-head h2,
.method h2 {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: var(--text-h2);
  text-transform: uppercase;
  line-height: 1;
  color: var(--mustard);
  text-shadow: 0.05em 0.035em 0 var(--red);
}

.section-head p { margin-block: 0.5rem 0; color: var(--muted); }

/* The rail: tickets hang from a metal bar, each held by a clip, like a kitchen order rail */
.wall {
  --pad: max(var(--gutter), (100% - 72rem) / 2);
  --rail-y: 0.75rem;
  display: flex;
  align-items: flex-start;
  gap: 0.875rem;
  margin-block-start: 1.75rem;
  padding-inline: var(--pad);
  padding-block: 0 2rem;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scroll-padding-inline: var(--pad);
  scrollbar-width: none;
  background:
    linear-gradient(oklch(0 0 none / 0.5), transparent) 0 calc(var(--rail-y) + 0.5rem) / 100% 0.5rem no-repeat,
    linear-gradient(oklch(0.78 0 none), oklch(0.52 0 none) 45%, oklch(0.34 0 none)) 0 var(--rail-y) / 100% 0.5rem no-repeat;
}

.wall::-webkit-scrollbar { display: none; }

@media (hover: hover) and (pointer: fine) {
  .wall { cursor: grab; }
  .wall.is-dragging,
  .wall.is-dragging .ticket { cursor: grabbing; user-select: none; }
}

.ticket-slot { flex: none; }

.ticket {
  position: relative;
  display: block;
  inline-size: 6.25rem;
  padding: 0.875rem 0 0;
  border: 0;
  background: none;
  font: inherit;
  text-align: start;
  cursor: pointer;
  transform-origin: 50% 0.75rem;
  rotate: var(--tilt);
  filter: drop-shadow(0 6px 8px oklch(0 0 none / 0.45));
}

.ticket:focus-visible { outline-offset: 4px; }

/* Binder-style clip over the rail */
.ticket-clip {
  position: absolute;
  z-index: 1;
  inset-block-start: 0.375rem;
  inset-inline-start: 50%;
  inline-size: 1.625rem;
  block-size: 1.25rem;
  translate: -50% 0;
  border-radius: 0.2rem 0.2rem 0.3rem 0.3rem;
  background: linear-gradient(oklch(0.86 0 none), oklch(0.58 0 none) 55%, oklch(0.42 0 none));
  box-shadow: inset 0 1px 0 oklch(1 0 none / 0.6), 0 2px 3px oklch(0 0 none / 0.5);
}

.ticket-clip::after {
  content: "";
  position: absolute;
  inset-inline: 0.375rem;
  inset-block-start: 0.375rem;
  block-size: 2px;
  border-radius: 1px;
  background: oklch(0.3 0 none / 0.6);
}

.ticket-paper {
  --tooth: 5px;
  position: relative;
  display: flex;
  flex-direction: column;
  padding: 0.75rem 0.5rem calc(0.5rem + var(--tooth));
  background-color: var(--paper);
  background-image:
    var(--paper-grain),
    var(--paper-fibers),
    linear-gradient(90deg, oklch(0 0 none / 0.07), transparent 12% 88%, oklch(0 0 none / 0.07));
  color: var(--ink);
  font-family: var(--font-mono);
  mask:
    linear-gradient(#000 0 0) top / 100% calc(100% - var(--tooth)) no-repeat,
    conic-gradient(from -45deg at bottom, #0000, #000 1deg 89deg, #0000 90deg) bottom / calc(2 * var(--tooth)) var(--tooth) repeat-x;
}

/* Fixed-height header so every ticket's lines start at the same height */
.ticket-head {
  display: grid;
  align-content: start;
  gap: 0.125rem;
  block-size: 4.25rem;
  padding-block-end: 0.375rem;
  margin-block-end: 0.375rem;
  border-block-end: 1px dashed var(--ink-muted);
}

.ticket-no { font-size: 0.625rem; color: var(--ink-muted); letter-spacing: 0.06em; }

.ticket-name {
  font-size: 0.8125rem;
  font-weight: 600;
  line-height: 1.2;
  text-wrap: balance;
  overflow-wrap: anywhere;
}

/* The lines are the only part sized by money: together they are exactly the ticket's spend */
.ticket-lines { display: grid; }

.ticket-lines > i {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  block-size: calc(var(--h) * var(--wall-h));
  min-block-size: 3px;
}

.ticket-lines > i::before {
  content: "";
  inline-size: var(--w);
  block-size: 2px;
  border-radius: 1px;
  background: color-mix(in oklch, var(--ink) 28%, transparent);
}

.ticket-lines > i[data-medal]::after {
  content: "";
  flex: none;
  inline-size: 0.4375rem;
  block-size: 0.4375rem;
  margin-inline-start: auto;
  border-radius: 50%;
  box-shadow: inset 0 -1px 0 oklch(0 0 none / 0.25);
}

.ticket-lines > i[data-medal="oro"]::after { background: var(--gold); }
.ticket-lines > i[data-medal="plata"]::after { background: var(--silver); }
.ticket-lines > i[data-medal="bronce"]::after { background: var(--bronze); }

.ticket-total {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.25rem;
  margin-block-start: 0.375rem;
  padding-block-start: 0.375rem;
  border-block-start: 3px double var(--ink);
  font-size: 0.5625rem;
  text-transform: uppercase;
}

.ticket-total b { font-size: 0.75rem; font-variant-numeric: tabular-nums; }

/* Mini rubber stamp for the big awards, same ink as the hero stamp */
.ticket-stamp {
  position: absolute;
  inset-block-end: 2.5rem;
  inset-inline-end: 0.25rem;
  display: grid;
  place-items: center;
  inline-size: 2.5rem;
  block-size: 2.5rem;
  border: 2px solid currentColor;
  border-radius: 50%;
  box-shadow: inset 0 0 0 2px var(--paper), inset 0 0 0 3px currentColor;
  rotate: -14deg;
  color: color-mix(in oklch, var(--red) 88%, oklch(0.3 0.1 20));
  font-family: var(--font-display);
  font-size: 0.75rem;
  letter-spacing: 0.04em;
  mix-blend-mode: multiply;
  opacity: 0.88;
  filter: url(#ink);
}

/* Selected: lifts off the rail and gets a mustard band along the paper's top edge */
.ticket[aria-pressed="true"] {
  scale: 1.05;
  filter: drop-shadow(0 12px 16px oklch(0 0 none / 0.6));
}

.ticket[aria-pressed="true"] .ticket-paper { box-shadow: inset 0 5px 0 var(--mustard); }

.ticket:active { scale: 0.98; }

@media (hover: hover) and (pointer: fine) and (prefers-reduced-motion: no-preference) {
  .ticket:hover { animation: swing 1100ms var(--ease-out); }
  @keyframes swing {
    0% { rotate: var(--tilt); }
    25% { rotate: calc(var(--tilt) + 1deg); }
    55% { rotate: calc(var(--tilt) - 0.6deg); }
    80% { rotate: calc(var(--tilt) + 0.25deg); }
    100% { rotate: var(--tilt); }
  }
}

@media (prefers-reduced-motion: no-preference) {
  /* Tickets drop onto the rail one after another */
  .ticket-slot { animation: hang 700ms var(--ease-out) both; animation-delay: calc(var(--i, 0) * 45ms); }
  @keyframes hang { from { opacity: 0; translate: 0 -1.5rem; } }
  .ticket { transition: scale 200ms var(--ease-out), filter 200ms var(--ease-out); }
}

/* Controls */

.receipt-section { padding-block-end: var(--space-section); }

.controls {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: center;
  gap: 1rem 1.5rem;
  margin-block-end: 2rem;
}

.field { display: grid; gap: 0.375rem; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }

/* Participant picker: own chevron instead of the system arrow */
select {
  appearance: none;
  inline-size: 20rem;
  max-inline-size: 100%;
  block-size: 3rem;
  padding-inline: 1rem 2.75rem;
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%23b8b1aa' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat right 1rem center / 0.75rem;
  color: var(--fg);
  font-family: var(--font-mono);
  font-weight: 600;
  letter-spacing: 0.02em;
  cursor: pointer;
}

@media (hover: hover) and (pointer: fine) {
  select:hover { border-color: color-mix(in oklch, var(--fg) 30%, transparent); }
}

/* Where the list itself can be styled (customizable select), it opens as a strip of receipt
   paper. Elsewhere the system list stays and only the closed control above applies. */
@supports (appearance: base-select) {
  select,
  ::picker(select) { appearance: base-select; }

  select { display: flex; align-items: center; }
  select::picker-icon { display: none; }

  ::picker(select) {
    max-block-size: min(24rem, 60svh);
    margin-block-start: 0.375rem;
    padding: 0.5rem;
    border: 0;
    border-radius: 0.25rem;
    background-color: var(--paper);
    background-image: var(--paper-grain), var(--paper-fibers);
    color: var(--ink);
    box-shadow: 0 18px 40px oklch(0 0 none / 0.55);
  }

  option {
    padding: 0.5rem 0.625rem;
    border-radius: 0.25rem;
    font-family: var(--font-mono);
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
  }

  option + option { border-block-start: 1px dashed color-mix(in oklch, var(--ink) 18%, transparent); }
  option::checkmark { content: "→"; color: var(--red); }
  option:checked { color: var(--red); }
  option:focus-visible { outline: 2px solid var(--mustard); outline-offset: -2px; }

  @media (hover: hover) and (pointer: fine) {
    option:hover { background: color-mix(in oklch, var(--ink) 8%, transparent); }
  }
}

.segmented {
  display: flex;
  block-size: 2.75rem;
  padding: 0.25rem;
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  background: var(--surface);
}

.segmented button {
  min-inline-size: 3.5rem;
  border: 0;
  border-radius: 0.3rem;
  background: none;
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
}

.segmented button[aria-pressed="true"] { background: var(--fg); color: var(--bg); }
.segmented button:active { scale: 0.97; }

/* Printer + receipt */

.printer {
  display: grid;
  justify-items: center;
  scroll-margin-block-start: 1rem;
}

.printer-body {
  position: relative;
  z-index: 1;
  inline-size: min(100%, 28rem);
  block-size: 3.5rem;
  border-radius: 0.75rem 0.75rem 0.25rem 0.25rem;
  background: linear-gradient(oklch(0.32 0.01 25), oklch(0.24 0.01 25));
  box-shadow: 0 10px 20px oklch(0 0 none / 0.45);
}

.printer-slot {
  position: absolute;
  inset-inline: 1rem;
  inset-block-end: 0.625rem;
  block-size: 0.375rem;
  border-radius: 1rem;
  background: oklch(0.08 0 none);
}

/* No paper until a participant is picked */
.receipt:empty { display: none; }
.printer:has(.receipt:empty) .printer-light { background: oklch(0.4 0 none); box-shadow: none; }

.printer-light {
  position: absolute;
  inset-block-start: 0.75rem;
  inset-inline-end: 1rem;
  inline-size: 0.5rem;
  block-size: 0.5rem;
  border-radius: 50%;
  background: var(--mustard);
  box-shadow: 0 0 10px var(--mustard);
}

/* The paper's top sits at the slot's center line; everything above it is clipped, so while
   printing the receipt feeds out of the slot. The lip below the slot is behind the paper. */
.printer-out {
  position: relative;
  z-index: 2;
  inline-size: min(100% - 2rem, 25rem);
  margin-block-start: calc(-0.625rem - 0.1875rem);
  clip-path: inset(0 -3rem -4rem -3rem);
}

.receipt {
  --tooth: 8px;
  display: block;
  padding: 1.75rem 1.25rem calc(1.5rem + var(--tooth));
  background:
    linear-gradient(oklch(0 0 none / 0.18), transparent 2.5rem),
    var(--paper-grain),
    var(--paper-fibers),
    var(--paper);
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  line-height: 1.45;
  text-transform: uppercase;
  filter: drop-shadow(0 18px 24px oklch(0 0 none / 0.45));
  mask:
    linear-gradient(#000 0 0) top / 100% calc(100% - var(--tooth)) no-repeat,
    conic-gradient(from -45deg at bottom, #0000, #000 1deg 89deg, #0000 90deg) bottom / calc(2 * var(--tooth)) var(--tooth) repeat-x;
}

.r-line { min-block-size: 1.45em; }
.r-center { text-align: center; }
.r-end { text-align: end; }
.r-small { font-size: 0.6875rem; }
.r-muted { color: var(--ink-muted); }
.r-strong { font-weight: 600; }


.r-stamp {
  display: inline-block;
  margin-block: 0.625rem 0.25rem;
  padding: 0.125rem 0.625rem;
  border: 2px solid var(--red);
  border-radius: 0.25rem;
  rotate: -2deg;
  color: var(--red);
  font-weight: 600;
  letter-spacing: 0.12em;
}

.r-rule {
  min-block-size: 0;
  margin-block: 0.625rem;
  border-block-start: 1px dashed var(--ink-muted);
}

.r-double { border-block-start: 3px double var(--ink); }

.r-row {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  font-variant-numeric: tabular-nums;
}

.r-row > span:last-child { text-align: end; }

/* Each idea is its own block: number tag, title, then its entries */
.r-rule-idea { margin-block: 1rem 0.875rem; border-block-start: 1px dashed var(--ink-muted); }

.r-idea-line {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  font-size: 0.875rem;
  font-weight: 600;
}

.r-idea-no {
  flex: none;
  padding-inline: 0.3rem;
  background: var(--ink);
  color: var(--paper);
  font-size: 0.6875rem;
}

.r-item {
  padding-block: 0.15rem;
  display: grid;
  grid-template-columns: 3.75rem 1fr auto;
  gap: 0.5rem;
  font-size: 0.75rem;
}

.r-code { color: var(--ink-muted); }
.r-amt { font-variant-numeric: tabular-nums; text-align: end; }

.r-subtotal {
  padding-block-start: 0.125rem;
  border-block-start: 1px dotted var(--ink-muted);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--red);
}

.r-total {
  font-size: 1.125rem;
  font-weight: 600;
}

.r-barcode { display: flex; justify-content: center; margin-block: 1rem 0.5rem; }
.barcode { inline-size: 14rem; block-size: 3rem; fill: var(--ink); }

.error { color: var(--red); text-transform: none; }

@media (prefers-reduced-motion: no-preference) {
  /* Printing: four print-and-feed jerks first (a line's worth out, then a pause while it prints),
     then a steady feed for the rest. The steady part only fills forwards, so it doesn't override
     the jerks while it waits. */
  .receipt.printing {
    --chop: 1200ms;
    --step: 2.5rem;
    animation:
      feed-chop var(--chop) linear both,
      feed var(--feed, 1600ms) linear var(--chop) forwards;
  }

  @keyframes feed-chop {
    0% { translate: 0 -100%; animation-timing-function: var(--ease-out); }
    10%, 25% { translate: 0 calc(-100% + var(--step)); animation-timing-function: var(--ease-out); }
    35%, 50% { translate: 0 calc(-100% + var(--step) * 2); animation-timing-function: var(--ease-out); }
    60%, 75% { translate: 0 calc(-100% + var(--step) * 3); animation-timing-function: var(--ease-out); }
    85%, 100% { translate: 0 calc(-100% + var(--step) * 4); }
  }

  @keyframes feed {
    from { translate: 0 calc(-100% + var(--step) * 4); }
    to { translate: 0 0; } /* explicit: an implicit end would pick up feed-chop's held value */
  }

  /* The printer jolts on each jerk, then hums through the steady feed */
  .printer.is-printing .printer-body {
    animation:
      jolt 300ms var(--ease-out) 4,
      hum 90ms linear 1200ms infinite;
  }
  @keyframes jolt { 0%, 40%, 100% { translate: 0 0; } 15% { translate: 0 1.5px; } }
  @keyframes hum { 50% { translate: 0 0.5px; } }
  .printer.is-printing .printer-light { animation: blink 320ms step-end infinite; }
  @keyframes blink { 50% { opacity: 0.25; box-shadow: none; } }
}

.pager {
  display: flex;
  justify-content: center;
  gap: 0.75rem;
  margin-block-start: 2rem;
}

.pager button {
  block-size: 2.75rem;
  padding-inline: 1.125rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  cursor: pointer;
}

.pager button:active { scale: 0.97; }

@media (hover: hover) and (pointer: fine) {
  .pager button:hover { border-color: var(--mustard); }
  .segmented button:hover:not([aria-pressed="true"]) { color: var(--fg); }
}

@media (prefers-reduced-motion: no-preference) {
  .pager button, .segmented button { transition: scale 120ms var(--ease-out), border-color 150ms var(--ease-out); }
}

/* Winners */

.winners { padding-block: calc(var(--space-section) * 0.4); container-type: inline-size; }

/* 4 across, 2 by 2, or stacked: never 3 + 1 */
.winner-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.75rem;
  margin-block-start: 1.5rem;
}

.winner {
  display: grid;
  align-content: start;
  gap: 0.375rem;
  padding: 1.25rem;
  border: 1px solid var(--line);
  border-block-start: 3px solid var(--gold);
  border-radius: 0.5rem;
  background: var(--surface);
  text-align: start;
  cursor: pointer;
}

.winner:active { scale: 0.98; }

.winner-award {
  color: var(--gold);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.winner-name {
  font-family: var(--font-display);
  font-size: 1.75rem;
  line-height: 1.05;
  text-transform: uppercase;
}

.winner-amount {
  margin-block-start: 0.5rem;
  font-family: var(--font-mono);
  font-size: 1.375rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.winner-amount .currency { color: var(--mustard); }
.winner-split {
  display: grid;
  gap: 0.125rem;
  margin: 0.5rem 0 0;
  padding: 0.5rem 0 0;
  border-block-start: 1px dashed var(--line);
  list-style: none;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--muted);
}

.winner-split li { display: flex; justify-content: space-between; gap: 1rem; }

div.winner { cursor: default; }

.winner-by { color: var(--muted); font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.04em; }
.winner-meta { color: var(--muted); font-size: 0.85rem; }

@media (hover: hover) and (pointer: fine) {
  .winner:hover { border-color: color-mix(in oklch, var(--gold) 60%, var(--line)); }
}

@media (prefers-reduced-motion: no-preference) {
  .winner { transition: scale 120ms var(--ease-out), border-color 150ms var(--ease-out); }
}

/* Five cards: 3 company awards, then brand + idea. Never leaves a lone orphan. */
@container (min-width: 32rem) {
  .winner-grid { grid-template-columns: repeat(2, 1fr); }
  .winner:last-child:nth-child(odd) { grid-column: span 2; }
}
@container (min-width: 56rem) {
  .winner-grid { grid-template-columns: repeat(6, 1fr); }
  .winner { grid-column: span 2; }
  .winner:nth-child(n + 4):nth-last-child(-n + 2) { grid-column: span 3; }
  .winner:last-child:nth-child(odd) { grid-column: span 3; }
}

.star { color: var(--gold); }

.r-award {
  display: inline-block;
  margin-block: 0.375rem 0;
  padding: 0.125rem 0.5rem;
  background: var(--ink);
  color: var(--gold);
  font-weight: 600;
  font-size: 0.75rem;
  letter-spacing: 0.08em;
}

/* Medals */


.pips { display: inline-flex; flex-wrap: wrap; gap: 0.25rem; }

.pip {
  display: inline-grid;
  place-items: center;
  min-inline-size: 1.5rem;
  block-size: 1.5rem;
  padding-inline: 0.375rem;
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 600;
  color: oklch(0.2 0 none);
}

.pip-oro { background: var(--gold); }
.pip-plata { background: var(--silver); }
.pip-bronce { background: var(--bronze); }

.winner-medals { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; margin-block-start: 0.25rem; font-size: 0.85rem; color: var(--gold); }

.r-result { display: flex; flex-wrap: wrap; gap: 0.25rem; margin-block: 0.125rem 0.25rem; }

.r-medal {
  padding: 0 0.375rem;
  border: 1px solid var(--ink-muted);
  font-size: 0.6875rem;
  font-weight: 600;
}

.r-medal-oro { background: var(--gold); border-color: transparent; }
.r-medal-plata { background: var(--silver); border-color: transparent; }
.r-medal-bronce { background: var(--bronze); border-color: transparent; color: var(--paper); }
.r-per { font-size: 0.75rem; color: var(--ink-muted); }

/* Zero-height anchor so the stamp can sit over the lines above it */
.r-paid-anchor { position: relative; min-block-size: 0; block-size: 0; }

.r-paid {
  position: absolute;
  inset-block-start: -3.4rem;
  inset-inline-start: var(--x);
  display: inline-grid;
  justify-items: center;
  padding: 0.15rem 0.75rem 0.25rem;
  border: 4px double currentColor;
  border-radius: 0.3rem;
  rotate: var(--rot);
  color: var(--olive);
  font-family: var(--font-display);
  font-size: 1.75rem;
  letter-spacing: 0.14em;
  line-height: 1.1;
  mix-blend-mode: multiply;
  opacity: 0.8;
  filter: url(#ink);
  pointer-events: none;
}

.r-paid small { font-family: var(--font-mono); font-size: 0.55rem; letter-spacing: 0.2em; }

/* Stamped once the printer finishes */
.printer.is-printing .r-paid { opacity: 0; }

@media (prefers-reduced-motion: no-preference) {
  .printer:not(.is-printing) .r-paid { animation: stamp-down 280ms var(--ease-out) both; }
}

/* Cost per metal */

.cost { padding-block: calc(var(--space-section) * 0.4); }
.cost-toggle { inline-size: fit-content; margin-block-start: 1.25rem; }
.cost-toggle button { padding-inline: 0.875rem; }

.cost-list {
  display: grid;
  gap: 0.25rem;
  margin: 1.25rem 0 0;
  padding: 0;
  list-style: none;
}

.cost { container-type: inline-size; }

/* Narrow: name and value on top, full-width bar under them */
.cost-row {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-areas: "name value" "bar bar" "meta meta";
  align-items: center;
  column-gap: 1rem;
  row-gap: 0.375rem;
  padding-block: 0.625rem;
  border-block-end: 1px solid var(--line);
}

@container (min-width: 40rem) {
  .cost-row {
    grid-template-columns: minmax(7rem, 11rem) 1fr auto;
    grid-template-areas: "name bar value" "name meta meta";
    row-gap: 0;
    padding-block: 0.5rem;
  }
}

.cost-name {
  grid-area: name;
  justify-self: start;
  padding: 0;
  border: 0;
  background: none;
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 0.85rem;
  text-align: start;
  cursor: pointer;
}

.cost-name:active { opacity: 0.7; }

.cost-bar {
  grid-area: bar;
  block-size: 0.875rem;
  inline-size: calc(var(--len) * 100%);
  border-radius: 0 0.25rem 0.25rem 0;
  background: var(--mustard);
}

.cost-value { grid-area: value; font-family: var(--font-mono); font-weight: 600; font-variant-numeric: tabular-nums; }

.cost-meta {
  grid-area: meta;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  color: var(--muted);
  font-size: 0.8rem;
}

.cost-meta .pip { min-inline-size: 1.25rem; block-size: 1.25rem; font-size: 0.7rem; }

@media (hover: hover) and (pointer: fine) {
  .cost-name:hover { color: var(--mustard); }
}

@media (prefers-reduced-motion: no-preference) {
  .cost-bar { transition: inline-size 400ms var(--ease-out); }
}

/* Method */

.method {
  padding-block: var(--space-section);
  border-block-start: 1px solid var(--line);
  color: var(--muted);
}

.method ul { margin-block: 1.25rem 0; padding-inline-start: 1.25rem; max-inline-size: 44rem; }
.method li + li { margin-block-start: 0.5rem; }
.method b { color: var(--fg); }
.method a { color: var(--mustard); }
