@font-face {
  font-family: "Lora";
  src: url("./assets/lora.woff2") format("woff2");
  font-weight: 400 700;
  font-display: swap;
}
@font-face {
  font-family: "Onest";
  src: url("./assets/onest.woff2") format("woff2");
  font-weight: 400 600;
  font-display: swap;
}
:root {
  color-scheme: dark;
  --page: #172d24;
  --input: #20382e;
  --input-hover: #294438;
  --ink: #fff4df;
  --body: #e5dcc7;
  --muted: #c2c9b6;
  --gold: #e1c58c;
  --line: #f6e4b833;
  --wine: #702d35;
  --ivory: #f7e4bb;
  --ease: cubic-bezier(.22, 1, .36, 1);
  --serif: "Lora", Georgia, serif;
  --sans: "Onest", system-ui, sans-serif;
  font: 400 16px/1.5 var(--sans);
  font-variant-numeric: tabular-nums;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--page); color: var(--ink); }
button, select { font: inherit; }
button { color: inherit; cursor: pointer; }
button:disabled, button[aria-disabled="true"] { cursor: default; }
button:focus-visible, select:focus-visible, a:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 3px;
}
h1, h2, h3, p { margin: 0; }
[hidden] { display: none !important; }
.symbols { display: none; }
.icon {
  flex: none;
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.5;
}
.screen-reader {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
.evergreen {
  position: fixed;
  z-index: -1;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}
.sprig {
  position: absolute;
  width: clamp(280px, 38vw, 600px);
  opacity: .52;
}
.sprig-top { top: -120px; right: -108px; transform: rotate(10deg); }
.sprig-bottom { left: -144px; bottom: -136px; transform: rotate(188deg); }
.page {
  width: min(100% - 96px, 1248px);
  min-height: 100svh;
  margin-inline: auto;
  display: flex;
  flex-direction: column;
}
.masthead {
  min-height: 80px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--line);
}
.wordmark { display: flex; align-items: center; gap: 12px; color: inherit; text-decoration: none; font: 500 20px/1.2 var(--serif); }
.wordmark .icon { width: 24px; height: 24px; color: var(--gold); }
.site-nav { display: flex; align-items: center; gap: 24px; }
.site-nav a {
  padding-block: 10px;
  border-bottom: 1px solid transparent;
  color: var(--muted);
  font-size: 14px;
  text-decoration: none;
  white-space: nowrap;
}
.site-nav a:hover { color: var(--ink); }
.site-nav a[aria-current="page"] { border-color: var(--gold); color: var(--gold); }
.layout {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr);
  grid-template-rows: 1fr 1fr;
  grid-template-areas: "intro cabinet" "filters cabinet";
  align-items: center;
  column-gap: clamp(48px, 6.7vw, 104px);
  row-gap: 32px;
  padding-block: 40px 48px;
}
.intro { grid-area: intro; align-self: end; }
.kicker { display: flex; align-items: center; gap: 12px; color: var(--gold); font-size: 14px; }
.kicker span { width: 28px; height: 1px; background: currentColor; }
h1 {
  margin-block: 16px 20px;
  font: 400 clamp(48px, 5.85vw, 88px)/1.04 var(--serif);
  letter-spacing: -.035em;
}
h1 span { color: var(--gold); }
.intro-copy { max-width: 34ch; color: var(--body); font-size: 17px; line-height: 1.6; }
.filters {
  grid-area: filters;
  align-self: start;
  border-top: 1px solid var(--line);
  padding-top: 20px;
}
.filter-heading { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; }
.filter-heading h2 { font-size: 16px; font-weight: 600; }
.reset {
  min-height: 32px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--gold);
  font-size: 13px;
  text-underline-offset: 4px;
}
.reset:disabled { color: var(--muted); opacity: .72; }
.reset:hover:not(:disabled) { text-decoration: underline; }
.filter-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}
.filter { min-width: 0; display: grid; gap: 6px; }
.filter label, .filter-label { color: var(--muted); font-size: 13px; }
.select-wrap { position: relative; }
.select-wrap .icon { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); pointer-events: none; color: var(--gold); }
select, .year-trigger {
  width: 100%;
  min-height: 48px;
  padding: 8px 32px 8px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--input);
  color: var(--ink);
  font-size: 14px;
  text-overflow: ellipsis;
  transition: background-color 150ms var(--ease), border-color 150ms var(--ease);
}
select { appearance: none; }
select:hover:not(:disabled), .year-trigger:hover:not(:disabled) { background: var(--input-hover); }
select:disabled, .year-trigger:disabled { opacity: .72; }
.year-filter { position: relative; }
.year-trigger { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding-right: 10px; text-align: left; }
.year-trigger .icon { color: var(--gold); }
.year-trigger[aria-expanded="true"] { border-color: var(--gold); }
.year-panel {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  z-index: 5;
  width: min(260px, 84vw);
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--input);
  box-shadow: 0 8px 24px #07130d55;
}
.year-options { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.year-panel select { background: var(--page); }
.year-done {
  width: 100%;
  min-height: 40px;
  margin-top: 12px;
  border: 0;
  border-radius: 8px;
  background: var(--ivory);
  color: #36271a;
  font-size: 14px;
}
.pool-count { margin-top: 16px; min-height: 20px; color: var(--muted); font-size: 13px; }
.cabinet {
  --step: 156px;
  grid-area: cabinet;
  position: relative;
  isolation: isolate;
  display: grid;
  grid-template-rows: auto 1fr auto;
  align-self: center;
  min-height: 648px;
  min-width: 0;
  padding: 32px 24px 40px;
  overflow: hidden;
  border: 1px solid #d7b47b85;
  border-radius: 24px;
  background: var(--wine) url("./assets/engraving.svg") center / cover no-repeat;
}
.cabinet-frame {
  position: absolute;
  z-index: -1;
  inset: 10px;
  border: 1px solid #f8e2b54d;
  border-radius: 14px;
  pointer-events: none;
}
.ornament {
  position: absolute;
  z-index: -1;
  width: clamp(32px, 6.4vw, 104px);
  height: auto;
  opacity: .72;
  pointer-events: none;
}
.ornament-bells { top: 10%; left: 6%; transform: rotate(-15deg); }
.ornament-star { top: 13%; right: 7%; width: clamp(24px, 4.5vw, 72px); transform: rotate(14deg); }
.ornament-tree { bottom: 11%; left: 7%; transform: rotate(-12deg); }
.ornament-bauble { bottom: 9%; right: 6%; transform: rotate(17deg); }
.cabinet-heading {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  color: var(--ivory);
  text-align: center;
}
.cabinet-heading h2 { font: 500 20px/1.4 var(--serif); }
.rule { position: relative; width: 32px; height: 1px; background: #f7e4bb65; }
.rule::after { content: ""; position: absolute; inset: -2px 0 auto auto; width: 5px; height: 5px; background: var(--ivory); transform: rotate(45deg); }
.rule:last-child::after { inset: -2px auto auto 0; }
.stage {
  --reel-card-width: min(72%, 356px);
  --reticle-width: clamp(28px, 4.6vw, 68px);
  --reticle-inset: max(0px, calc((100% - var(--reel-card-width)) / 2 - var(--reticle-width) - 8px));
  position: relative;
  min-height: 432px;
  display: grid;
  place-items: center;
}
.reel {
  position: absolute;
  inset: 0;
  overflow: hidden;
  mask-image: linear-gradient(transparent 0%, #000 19%, #000 81%, transparent 100%);
}
.track {
  position: absolute;
  top: calc(50% - 1.5 * var(--step));
  inset-inline: 0;
}
.stage[data-state="rolling"] .track {
  /* Quadratic ease-out keeps deceleration constant and ends at zero speed. */
  animation: roll-track var(--roll-duration) cubic-bezier(.333333, .666667, .666667, 1) both;
}
@keyframes roll-track {
  from { transform: translateY(0); }
  to { transform: translateY(var(--roll-distance)); }
}
.cell { display: grid; place-items: center; height: var(--step); }
.reel-card {
  position: relative;
  display: grid;
  align-content: center;
  gap: 4px;
  width: var(--reel-card-width);
  min-height: calc(var(--step) - 28px);
  padding: 8px 20px;
  border: 1px solid #f8dfab75;
  border-radius: 8px;
  background: #53242c;
  color: var(--ink);
  text-align: center;
}
.reel-card::before, .reel-card::after {
  content: "";
  position: absolute;
  top: 12px;
  bottom: 12px;
  border-left: 2px dotted #f8dfab55;
}
.reel-card::before { left: 6px; }
.reel-card::after { right: 6px; }
.reel-title {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  overflow: hidden;
  overflow-wrap: anywhere;
  font: 500 clamp(17px, 1.85vw, 25px)/1.16 var(--serif);
}
.reel-title.long-title { font-size: clamp(15px, 1.55vw, 21px); }
.reel-meta { font-size: 12px; color: var(--ivory); }
.track[data-parked] .cell:not([data-selected]) .reel-card { opacity: .78; }
.cell[data-selected] .reel-card { border-color: #f8dfabbf; }
.reticle {
  position: absolute;
  top: 50%;
  width: var(--reticle-width);
  height: auto;
  overflow: visible;
  fill: none;
  stroke: var(--ivory);
  stroke-width: 1;
  transform: translateY(-50%);
  pointer-events: none;
}
.reticle path:first-child { stroke-dasharray: 2 4; opacity: .62; }
.reticle .arrow { fill: var(--ivory); stroke-linejoin: round; }
.reticle-left { left: var(--reticle-inset); }
.reticle-right { right: var(--reticle-inset); transform: translateY(-50%) scaleX(-1); }
.result-layer { position: relative; z-index: 1; display: grid; place-items: center; width: 100%; }
.ticket {
  position: relative;
  width: min(88%, 440px);
  padding: 24px 24px 28px;
  background: var(--ivory);
  color: #432b22;
  text-align: center;
  border-radius: 8px;
  mask: radial-gradient(circle at 0 50%, transparent 8px, #000 8.5px) left / 51% 100% no-repeat,
    radial-gradient(circle at 100% 50%, transparent 8px, #000 8.5px) right / 51% 100% no-repeat;
  animation: show-ticket 360ms var(--ease) both;
}
.ticket::before {
  content: "";
  position: absolute;
  inset: 8px 12px;
  border: 1px solid #77504255;
  border-radius: 4px;
  pointer-events: none;
}
.ticket-label { font-size: 13px; color: #674337; }
.ticket h3 { margin-block: 8px 12px; font: 500 clamp(24px, 3.2vw, 44px)/1.16 var(--serif); overflow-wrap: anywhere; }
.ticket h3.long-title { font-size: clamp(20px, 2.55vw, 32px); }
.result-meta { color: #674337; font-size: 13px; }
.empty {
  width: min(88%, 360px);
  padding: 20px;
  border: 1px solid #f7e4bb70;
  border-radius: 8px;
  background: var(--wine);
  color: var(--ink);
  text-align: center;
  font-size: 15px;
}
.stage[data-state="result"] .cell[data-selected],
.stage[data-state="burst"] .cell[data-selected] { opacity: 0; }
.stage[data-state="result"] .reel { opacity: .68; }
.stage[data-state="empty"] .reticle,
.stage[data-state="result"] .reticle { opacity: .35; }
.confetti { position: fixed; z-index: 10; inset: 0; pointer-events: none; overflow: hidden; }
.particle {
  position: absolute;
  top: var(--origin-y);
  left: var(--origin-x);
  width: var(--size);
  height: calc(var(--size) * .6);
  background: var(--color);
  animation: scatter var(--duration) var(--ease) both;
}
.particle:nth-child(4n) { height: var(--size); border-radius: 50%; }
.particle:nth-child(4n + 2) { height: calc(var(--size) * .36); }
.confetti[data-reduced] .particle {
  transform: translate(var(--x), var(--y)) rotate(var(--turn));
  animation-name: flash-confetti;
}
.stage[data-motion="reduced"] .ticket { animation-name: fade-ticket; }
@keyframes flash-confetti {
  0%, 100% { opacity: 0; }
  16%, 56% { opacity: 1; }
}
@keyframes fade-ticket {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes scatter {
  0% { transform: translate(0, 0) rotate(0); opacity: 0; }
  8%, 72% { opacity: 1; }
  100% { transform: translate(var(--x), var(--y)) rotate(var(--turn)); opacity: 0; }
}
@keyframes show-ticket {
  from { opacity: 0; transform: translateY(8px) scale(.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.cabinet-actions {
  display: grid;
  place-items: center;
  gap: 8px;
}
.spin, .advent-cta {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  min-width: 232px;
  min-height: 56px;
  padding: 12px 24px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: var(--ivory);
  color: #39271b;
  font-size: 16px;
  font-weight: 600;
  transition: background-color 150ms var(--ease), transform 150ms var(--ease);
}
.advent-cta {
  text-decoration: none;
  text-align: center;
}
.advent-cta[hidden] { display: none; }
.spin:hover:not([aria-disabled="true"]) { background: #fff0d2; }
.advent-cta:hover { background: #fff0d2; }
.spin:active:not([aria-disabled="true"]) { transform: scale(.98); }
.spin[aria-disabled="true"] { background: #e4c89e; color: #493027; }
.spin:focus-visible, .advent-cta:focus-visible { outline-color: var(--ink); }
.stage[data-state="result"] + .cabinet-actions {
  width: min(100%, 512px);
  justify-self: center;
  grid-template-columns: minmax(0, 2fr) minmax(0, 3fr);
}
.stage[data-state="result"] + .cabinet-actions > * {
  width: 100%;
  min-width: 0;
  padding-inline: 12px;
}
.stage[data-state="result"] + .cabinet-actions .spin {
  border-color: #f7e4bb91;
  background: transparent;
  color: var(--ivory);
}
.stage[data-state="result"] + .cabinet-actions .spin:hover { background: #f7e4bb16; }
.noscript { margin-top: 12px; text-align: center; color: var(--ivory); }

@media (max-width: 1100px) {
  .page { width: calc(100% - 64px); }
  .layout { column-gap: 40px; }
  .cabinet { --step: 144px; min-height: 608px; }
}
@media (max-width: 780px) {
  .page { width: min(100% - 40px, 560px); }
  .masthead { min-height: 64px; }
  .wordmark { font-size: 17px; gap: 8px; }
  .wordmark .icon { width: 20px; height: 20px; }
  .site-nav { gap: 16px; }
  .site-nav a { font-size: 13px; }
  .layout {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto;
    grid-template-areas: "intro" "cabinet" "filters";
    gap: 24px;
    padding-block: 28px 32px;
  }
  h1 { margin-block: 12px; font-size: clamp(44px, 9.7vw, 64px); letter-spacing: -.03em; }
  .intro-copy { font-size: 15px; }
  .cabinet { --step: 104px; min-height: 444px; padding: 20px 16px 24px; border-radius: 20px; }
  .cabinet-frame { inset: 8px; border-radius: 12px; }
  .cabinet-heading h2 { font-size: 17px; }
  .stage { min-height: 292px; }
  .reel-card { min-height: calc(var(--step) - 14px); padding: 6px 14px; }
  .ornament { opacity: .55; }
  .ornament-bells, .ornament-star { top: 13%; }
  .ornament-tree, .ornament-bauble { bottom: 13%; }
  .spin, .advent-cta { min-height: 48px; }
  .sprig-top { right: -128px; top: -88px; opacity: .33; }
  .sprig-bottom { left: -144px; bottom: -84px; opacity: .32; }
  .year-panel { top: auto; bottom: calc(100% + 8px); }
  select, .year-trigger { font-size: 16px; }
  #length { font-size: 14px; }
}
@media (max-width: 520px) {
  .masthead { flex-wrap: wrap; gap: 4px 16px; padding-top: 16px; }
  .site-nav { width: 100%; gap: 20px; }
  .stage[data-state="result"] + .cabinet-actions {
    width: min(100%, 328px);
    grid-template-columns: minmax(0, 1fr);
  }
}
@media (max-width: 380px) {
  .page { width: calc(100% - 32px); }
  .cabinet { --step: 96px; min-height: 404px; }
  .stage { min-height: 264px; }
  .ticket { width: 90%; }
  .filter-grid { column-gap: 8px; }
  select { padding-left: 8px; padding-right: 26px; }
  .select-wrap .icon { right: 6px; }
}
@media (prefers-reduced-motion: reduce) {
  .spin, .advent-cta { transition: background-color 150ms var(--ease); }
  .spin:active:not([aria-disabled="true"]) { transform: none; }
}
