:root {
  font-family: system-ui, sans-serif;
  color: #f8faff;
  background: #080e1c;
  color-scheme: dark;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: 34px;
  background: radial-gradient(ellipse at 24% 0%, #1b3152, transparent 70%), #080e1c;
}

[hidden] { display: none !important; }

.snowfall {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.flake {
  position: absolute;
  top: 0;
  left: var(--x);
  width: var(--size);
  aspect-ratio: 1;
  border-radius: 50%;
  background: #edf6ff;
  opacity: var(--opacity);
  animation: snowfall var(--fall) var(--delay) linear infinite;
}

@keyframes snowfall {
  from { transform: translate(0, -12px); }
  40% { transform: translate(var(--drift), 40vh); }
  72% { transform: translate(calc(var(--drift) * .5), 72vh); }
  to { transform: translate(calc(var(--drift) * 1.3), calc(100vh + 12px)); }
}

.ticket {
  position: relative;
  width: min(100%, 1030px);
  display: grid;
  grid-template-columns: 42% minmax(0, 1fr);
  overflow: hidden;
  border: 1px solid #b5d1ff32;
  border-radius: 24px;
  box-shadow: 0 28px 88px #01040ab3;
  background: #101827;
}

.art {
  position: relative;
  min-height: 490px;
  background: #0c2448;
}

.winter-scene {
  position: absolute;
  inset: 0;
  overflow: hidden;
  container-type: size;
  --landscape: url("/moonlit-winter.png");
  --landscape-ratio: .8;
  background: var(--landscape) center / cover no-repeat;
}

/* Trace the bright side of each crest so the darker sky-side pixels stay behind the snowman. */
.winter-scene::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: max(100cqw, calc(100cqh * var(--landscape-ratio)));
  aspect-ratio: var(--landscape-ratio);
  transform: translate(-50%, -50%);
  background: var(--landscape) center / 100% 100% no-repeat;
  clip-path: polygon(
    0 94.1%, 10% 92.2%, 15% 91.5%, 20% 91.3%, 25% 91.4%, 30% 92%,
    35% 92.8%, 37.5% 93.3%, 40% 93.8%, 42.5% 94.3%, 45% 94.9%,
    48% 95.5%, 50% 95.2%, 52.5% 94.9%, 55% 94.5%, 57.5% 94%,
    60% 93.4%, 65% 92.1%, 70% 90.8%, 75% 89.5%, 85% 87.3%, 95% 86.5%,
    100% 86.7%, 100% 100%, 0 100%
  );
  pointer-events: none;
}

@property --camera-lift {
  syntax: "<number>";
  inherits: true;
  initial-value: 0;
}

.snowman {
  --photo-cycle: 8s;
  position: absolute;
  width: min(95cqw, 72cqh);
  aspect-ratio: 3 / 4;
  container-type: size;
  animation: raise-camera var(--photo-cycle) ease-in-out infinite;
  left: 37%;
  bottom: -8px;
  transform: translateX(-50%);
}

.snowman-art { position: relative; display: block; width: 100%; height: auto; }

.camera-arm { position: absolute; inset: 0; width: 100%; height: 100%; }

.camera {
  position: absolute;
  top: calc(34% - 14.8% * var(--camera-lift));
  left: calc(77% - 34.6% * var(--camera-lift));
  width: 41%;
  transform: rotate(calc(4deg - 8deg * var(--camera-lift)));
}

.camera img { display: block; width: 100%; height: auto; }

.flash {
  position: absolute;
  top: 13.15%;
  left: 51%;
  width: 94%;
  aspect-ratio: 1;
  transform: translate(-50%, -50%);
  background: radial-gradient(circle, #fff 0 5%, #f4faffea 9%, #d1e7ff88 23%, #d1e7ff2c 42%, transparent 68%);
  opacity: 0;
  animation: camera-flash var(--photo-cycle) linear infinite;
}

@keyframes raise-camera {
  0%, 19%, 56%, 100% { --camera-lift: 0; }
  33%, 44% { --camera-lift: 1; }
}

@keyframes camera-flash {
  0%, 37%, 41%, 100% { opacity: 0; }
  38.1% { opacity: 1; }
  39.35% { opacity: .17; }
}

.content { padding: clamp(28px, 5vw, 62px); align-self: center; }
/* The logo file has 23 transparent pixels before the wordmark. */
.brand-logo { display: block; width: clamp(120px, 14vw, 148px); max-width: 100%; height: auto; margin-bottom: 16px; transform: translateX(-5.1%); }
.eyebrow { margin: 0 0 16px; color: #c9dbf4; font-size: .78rem; font-weight: 750; letter-spacing: .14em; text-transform: uppercase; }
h1 { margin: 0; width: max-content; max-width: 100%; color: #fff; font: 850 clamp(2rem, 4.4vw, 3.6rem)/1.04 system-ui, sans-serif; letter-spacing: -.022em; }
.intro { margin: 14px 0 24px; padding-inline-start: 1.3em; color: #c4d0e4; line-height: 1.55; }
.intro li + li { margin-top: 3px; }
.intro li::marker { color: #e7efff; font-weight: 700; }

form { display: grid; gap: 8px; }
input, button { font: inherit; }

input {
  width: 100%;
  min-height: 49px;
  padding: 11px 13px;
  border: 1px solid #9cb1cd70;
  border-radius: 8px;
  background: #0b1323;
  color: #f8faff;
}

input::placeholder { color: #8e9cb3; }
button { cursor: pointer; }
button:disabled { cursor: wait; opacity: .72; }

.primary {
  display: block;
  min-height: 48px;
  margin-top: 4px;
  padding: 12px;
  border: 1px solid #fff;
  border-radius: 8px;
  background: #f3f7fe;
  color: #101827;
  font-weight: 750;
  text-align: center;
  text-decoration: none;
}

.primary:hover { background: #dceaff; }
:focus-visible { outline: 2px solid #a8cbff; outline-offset: 3px; }

.scratch-panel {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 112px;
  margin-top: 12px;
  border: 2px solid #8ca4c5;
  border-radius: 12px;
  background: #ebf3ff;
  color: #10223d;
}

.scratch-panel canvas { position: absolute; inset: 0; z-index: 1; width: 100%; height: 100%; border-radius: 10px; touch-action: none; cursor: crosshair; }
#result { margin: 0; padding: 17px; text-align: center; font-size: clamp(1.2rem, 3.1vw, 1.65rem); line-height: 1.2; overflow-wrap: anywhere; }
#result.no-prize { font-size: clamp(1rem, 2.3vw, 1.125rem); font-weight: 600; line-height: 1.35; }
#result[aria-hidden="true"] { pointer-events: none; user-select: none; }
#result:focus-visible { outline-color: #526f99; }
.claim-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 13px; }
.claim-actions > * { flex: 1 1 auto; }
.secondary { background: #182438; border-color: #829abb; color: #f3f7fe; }
.secondary:hover { background: #273a56; }
.saved-prize { padding: 11px 12px; margin-top: 10px; border: 1px solid #829abb70; border-radius: 8px; }
.saved-prize p { margin: 0; color: #d6e5ff; font-size: .86rem; }
.code-row { display: flex; gap: 8px; margin-top: 9px; }
.code-row input { min-width: 0; font: .85rem ui-monospace, monospace; }
.code-row button { flex: none; margin: 0; }
.terms { display: block; margin-top: 16px; color: #abbad2; font-size: .75rem; line-height: 1.45; }
.actions, .examples { display: flex; flex-wrap: wrap; gap: 5px 14px; margin-top: 8px; }
.actions button, .examples button { padding: 8px 0; border: 0; background: transparent; color: #d6e5ff; font-size: .85rem; text-decoration: underline; text-underline-offset: 3px; }
.demo { margin-top: 21px; padding-top: 13px; border-top: 1px solid #8298b23d; color: #bac8de; font-size: .85rem; }
.demo p { margin: 4px 0; }
.examples { margin: 0; }
#error { color: #ffd0dc; font-weight: 600; }

@media (max-width: 850px) and (min-width: 701px) {
  .content { padding: 26px; }
  .eyebrow { letter-spacing: .08em; }
}

@media (max-width: 700px) {
  body { padding: 16px; }
  .ticket { grid-template-columns: 1fr; max-width: 470px; border-radius: 17px; }
  .art { min-height: 0; aspect-ratio: 3 / 2; }
  .winter-scene {
    --landscape: url("/moonlit-winter-wide.png");
    --landscape-ratio: 1.5008;
  }

  .winter-scene::after {
    clip-path: polygon(
      0 93.7%, 10% 91.2%, 15% 90.4%, 20% 89.9%, 25% 90.1%, 30% 90.7%,
      35% 91.5%, 37.5% 92%, 40% 92.7%, 42.5% 93.3%, 45% 93.8%,
      47.5% 94.3%, 50% 93.4%, 52.5% 92.9%, 55% 92.4%, 57.5% 91.7%,
      60% 91.1%, 65% 89.6%, 70% 88.3%, 75% 87.1%, 85% 85.8%, 95% 86.2%,
      100% 87.1%, 100% 100%, 0 100%
    );
  }
  .snowman { left: 42%; bottom: -5px; }
  .content { padding: 25px; }
  h1 { font-size: clamp(1.9rem, 8.4vw, 2.9rem); }
}

@media (max-width: 430px) {
  body { padding: 10px; place-items: start center; }
  .content { padding: 21px 19px; }
  .brand-logo { margin-bottom: 12px; }
  .eyebrow { margin-bottom: 10px; font-size: .71rem; letter-spacing: .085em; }
  .intro { margin: 11px 0 17px; }
  .actions button, .examples button { min-height: 44px; }
  .demo { margin-top: 10px; }
}

@media (max-width: 360px) {
  .code-row { flex-wrap: wrap; }
  .code-row input { flex-basis: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  .flake { display: none; }
  .snowman, .flash { animation: none; }
}
