:root {
  color-scheme: light;
  --ink: #301a25;
  --muted: #70535b;
  --paper: #fff4e7;
  --card: #fffaf1;
  --peach: #ff926e;
  --gold: #ffcf64;
  --line: #e7c9b9;
  font-family: system-ui, sans-serif;
  color: var(--ink);
  background: var(--paper);
}

* { box-sizing: border-box; }
body {
  display: flex;
  flex-direction: column;
  min-height: 100svh;
  margin: 0;
  padding: env(safe-area-inset-top) env(safe-area-inset-right)
    env(safe-area-inset-bottom) env(safe-area-inset-left);
  padding-bottom: max(env(safe-area-inset-bottom), var(--email-keyboard-inset, 0px));
}
button, input { font: inherit; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid #934032; outline-offset: 4px; }

.top-inner, .layout, .footer { width: min(100% - 32px, 1080px); margin-inline: auto; }
.top { border-bottom: 1px solid var(--line); }
.top-inner, .footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.top-inner { min-height: 62px; }
.brand { display: flex; align-items: center; gap: 7px; font-weight: 820; letter-spacing: -.03em; }
.brand svg { width: 26px; fill: none; stroke: currentColor; stroke-width: 2; }
.edition { color: var(--muted); font-size: .74rem; font-weight: 750; letter-spacing: .1em; text-transform: uppercase; }

.layout { display: grid; gap: 14px; margin-block: auto; padding-block: 20px; }
.hero {
  position: relative;
  isolation: isolate;
  display: grid;
  align-content: space-between;
  overflow: hidden;
  min-height: 460px;
  padding: 34px;
  color: var(--paper);
  border-radius: 28px;
  background: radial-gradient(ellipse at 85% 100%, #843741, transparent 69%), var(--ink);
}
.hero::before {
  content: '';
  position: absolute;
  z-index: -1;
  inset: 0;
  background: radial-gradient(circle, #fff4e72b 1px, transparent 1.5px) 0 0 / 12px 12px;
  mask-image: linear-gradient(130deg, transparent 45%, black);
}
h1, h2, h3 { margin: 0; font-family: Georgia, serif; font-weight: 700; }
h1 { font-size: clamp(4rem, 8vw, 7rem); line-height: .79; letter-spacing: -.095em; }
h1 em { color: var(--peach); }
.hero-copy p { margin: 22px 0 0; color: #ffe0cd; line-height: 1.45; }
.prize-art { position: relative; width: 245px; max-width: 100%; margin: 20px 6% 9px auto; }
.voucher {
  display: grid;
  justify-items: center;
  padding: 14px 24px;
  color: var(--ink);
  background:
    radial-gradient(circle at left center, #6b2c37 8px, transparent 9px),
    radial-gradient(circle at right center, #793440 8px, transparent 9px),
    linear-gradient(135deg, #ffe38f, var(--gold) 60%, #ffaa65);
  border: 2px solid var(--ink);
  border-radius: 14px;
  box-shadow: 5px 7px 0 var(--ink);
  transform: rotate(-9deg);
}
.voucher span { font-size: .62rem; font-weight: 850; text-transform: uppercase; letter-spacing: .16em; }
.voucher strong { font: 700 4.5rem/.98 Georgia, serif; letter-spacing: -.09em; }
.voucher span:last-child { margin-top: 6px; padding-top: 6px; border-top: 1px dashed #916143; }
.sparkle { position: absolute; z-index: 1; color: #ffe094; line-height: 1; }
.sparkle-top { top: -21px; right: -18px; font-size: 2.7rem; }
.sparkle-bottom { bottom: 0; left: -32px; font-size: 1.6rem; }

.ticket {
  position: relative;
  align-self: center;
  min-width: 0;
  padding: clamp(20px, 3.7vw, 38px);
  border: 1px solid var(--line);
  border-radius: 26px;
  background: var(--card);
  box-shadow: 0 6px 0 #efdbcd, 0 16px 34px #57311f14;
  animation: enter .34s cubic-bezier(.2,.75,.3,1) both;
}
.ticket-heading h2 { font-size: clamp(2rem, 4.4vw, 3.35rem); line-height: .98; letter-spacing: -.065em; }
.step-copy { margin: 16px 0 0; line-height: 1.45; }
.step-note { margin: 8px 0 0; color: var(--muted); font-size: .86rem; line-height: 1.4; }
.primary, #replay {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 48px;
  margin-top: 20px;
  padding: 10px 20px;
  border: 2px solid var(--ink);
  border-radius: 12px;
  background: var(--peach);
  box-shadow: 0 4px 0 var(--ink);
  color: var(--ink);
  font-weight: 820;
  cursor: pointer;
  transition: transform .14s, box-shadow .14s, background .14s;
}
#play { display: flex; width: fit-content; margin-inline: auto; }
.primary:hover, #replay:hover { background: #ffa787; transform: translateY(-2px); box-shadow: 0 6px 0 var(--ink); }
.primary:active, #replay:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
.primary:disabled { opacity: .65; cursor: default; }
.primary span { font-size: 1.3em; line-height: 1; }
.entry-form, .email-field { display: grid; gap: 8px; }
.entry-form { gap: 14px; margin-top: 20px; }
.entry-form .primary { justify-self: center; margin-top: 0; }
.entry-form .step-note { margin-top: 0; }
.email-field label { font-size: .9rem; font-weight: 750; }
.email-field input {
  width: 100%; min-height: 48px; padding: 9px 12px;
  border: 1px solid #ac8075; border-radius: 10px; color: var(--ink); background: white;
}
.newsletter-option { display: flex; align-items: start; gap: 10px; font-size: .9rem; line-height: 1.4; cursor: pointer; }
.newsletter-option input { flex: none; width: 18px; height: 18px; margin: 1px 0 0; accent-color: var(--ink); }

#board { position: relative; width: 100%; aspect-ratio: 900 / 284; margin-top: 20px; touch-action: none; }
#board canvas { position: absolute; inset: 0; display: block; width: 100%; height: 100%; touch-action: none; cursor: crosshair; }
.progress { display: flex; align-items: center; justify-content: center; gap: 10px; margin-top: 14px; color: var(--muted); font-size: .8rem; font-weight: 750; }
.dots { display: inline-flex; gap: 5px; }
.dots i { width: 9px; height: 9px; border: 1px solid #956652; border-radius: 50%; }
.dots i.done { background: #9d3c37; border-color: #9d3c37; animation: dot-pop .28s ease-out; }
.controls { display: flex; justify-content: center; margin-top: 12px; }
#reveal {
  min-height: 44px; padding: 8px 14px; border: 1px solid var(--line);
  border-radius: 10px; color: var(--ink); background: transparent; font-weight: 700; cursor: pointer;
}
#reveal:hover { background: #ffeddb; }
#reveal:disabled { opacity: .65; cursor: wait; }
#replay { margin: 0; }
.result {
  text-align: center; margin-top: 14px; padding: 12px;
  border: 1px solid var(--line); border-radius: 14px; background: var(--paper);
  animation: enter .3s ease-out both;
}
.result.win { background: #ffe08a; border-color: #d99a40; }
.result h3 { font-size: 1.65rem; line-height: 1.1; letter-spacing: -.04em; }
.result p { margin: 5px 0 0; font-size: .85rem; line-height: 1.4; }
#celebration { position: absolute; z-index: 2; inset: 0; overflow: hidden; pointer-events: none; }
.confetti { position: absolute; top: 48%; left: 50%; width: 8px; height: 11px; border-radius: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.footer { flex-wrap: wrap; padding-block: 12px 18px; color: var(--muted); font-size: .78rem; }
.footer a { color: inherit; text-underline-offset: 3px; }

@keyframes enter {
  from { opacity: 0; transform: translateY(9px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes dot-pop {
  50% { transform: scale(1.5); }
}

@media (min-width: 760px) {
  .layout { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: clamp(22px, 4vw, 52px); }
}
@media (max-width: 759px), (max-height: 570px) {
  .top-inner { min-height: 46px; }
  .layout { padding-block: 10px; }
  .hero { min-height: 170px; padding: 20px; border-radius: 20px; }
  h1 { font-size: clamp(2.85rem, 9vw, 4rem); }
  .hero-copy { z-index: 1; max-width: 58%; }
  .hero-copy p { margin-top: 12px; font-size: .8rem; }
  .prize-art { position: absolute; right: 6%; bottom: 30px; width: min(36%, 150px); margin: 0; }
  .voucher { padding: 10px 8px; }
  .voucher strong { font-size: clamp(2rem, 8vw, 3rem); }
  .voucher span { font-size: .52rem; letter-spacing: .08em; }
  .sparkle-top { font-size: 1.6rem; right: -11px; top: -12px; }
  .sparkle-bottom { font-size: .9rem; left: -12px; }
  .ticket { border-radius: 20px; }
  .footer { padding-block: 8px 12px; }
}
@media (max-width: 359px) {
  .hero-copy { max-width: none; }
  .prize-art { display: none; }
}
@media (max-width: 759px) and (max-height: 650px), (max-height: 460px) {
  .layout { gap: 10px; padding-block: 8px; }
  .hero { min-height: 0; padding: 16px; }
  .hero-copy { max-width: none; }
  .hero-copy br, .prize-art { display: none; }
  h1 { font-size: clamp(2rem, 7vw, 3rem); line-height: .95; }
  .hero-copy p { margin-top: 8px; }
  .ticket-heading h2 { font-size: clamp(1.55rem, 4vw, 2.2rem); }
  .email-field input, .primary { min-height: 44px; }
  .entry-form .step-note { font-size: .8rem; }
  .ticket { padding: 16px; }
  .entry-form { gap: 10px; margin-top: 12px; }
  #board, .primary { margin-top: 12px; }
  .progress, .result, .controls { margin-top: 8px; }
}
@media (min-width: 541px) and (max-height: 460px) {
  .layout { grid-template-columns: minmax(0, 1fr) minmax(0, 1.35fr); align-items: center; padding-block: 6px; }
  .ticket { padding: 12px; }
  .entry-form { gap: 8px; margin-top: 8px; }
  #board { width: min(100%, 65svh); margin-inline: auto; }
  #game-step:has(#result:not([hidden])) {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    column-gap: 10px;
    align-items: center;
  }
  #game-step .ticket-heading, .controls { grid-column: 1 / -1; }
  #game-step .progress { grid-column: 1; }
  #result { grid-column: 2; grid-row: 2 / 4; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
