:root {
  --ink: #14201b;
  --paper: #e7f0ea;
  --moss: #2f5d4a;
  --mist: #b7cfc3;
  --max: 42rem;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: "Source Sans 3", system-ui, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(1200px 700px at 10% -10%, #f4ffe8 0%, transparent 55%),
    radial-gradient(900px 600px at 100% 0%, #cfe4d8 0%, transparent 50%),
    linear-gradient(160deg, #f3faf5 0%, var(--paper) 45%, #d7e6de 100%);
  display: flex;
  flex-direction: column;
}

.grain {
  pointer-events: none;
  position: fixed;
  inset: 0;
  opacity: 0.18;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.55'/%3E%3C/svg%3E");
  mix-blend-mode: multiply;
  z-index: 0;
}

.top,
main,
footer {
  position: relative;
  z-index: 1;
  width: min(100% - 2.5rem, var(--max));
  margin-inline: auto;
}

.top {
  padding: 1.75rem 0 0;
}

.brand {
  margin: 0;
  font-family: Fraunces, Georgia, serif;
  font-weight: 700;
  font-size: 1.15rem;
  letter-spacing: -0.02em;
}

.hero {
  padding: 18vh 0 4rem;
  animation: rise 700ms ease-out both;
}

h1 {
  margin: 0;
  font-family: Fraunces, Georgia, serif;
  font-weight: 500;
  font-size: clamp(2.2rem, 6vw, 3.6rem);
  line-height: 1.05;
  letter-spacing: -0.03em;
  max-width: 14ch;
}

.lede {
  margin: 1.25rem 0 0;
  font-size: 1.125rem;
  line-height: 1.5;
  max-width: 34ch;
  color: color-mix(in srgb, var(--ink) 78%, var(--moss));
}

/* —— Instant scratch ticket —— */
.scratch-section {
  padding: 0 0 3.5rem;
}

.ticket {
  --ticket: #f4efe4;
  --ticket-ink: #1c1814;
  --ticket-red: #b42318;
  position: relative;
  max-width: 22rem;
  margin: 0;
  padding: 1.1rem 1.1rem 0;
  user-select: none;
  -webkit-user-select: none;
  background:
    radial-gradient(circle at 12% 8%, rgba(255, 255, 255, 0.7), transparent 40%),
    repeating-linear-gradient(
      -12deg,
      transparent,
      transparent 10px,
      rgba(180, 35, 24, 0.035) 10px,
      rgba(180, 35, 24, 0.035) 11px
    ),
    linear-gradient(160deg, #f7f2e8 0%, var(--ticket) 55%, #e8dfd0 100%);
  color: var(--ticket-ink);
  border: 1px solid rgba(28, 24, 20, 0.18);
  border-radius: 0.55rem;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.65) inset,
    0 18px 40px rgba(20, 32, 27, 0.14),
    0 2px 6px rgba(20, 32, 27, 0.08);
  overflow: hidden;
  /* No transform here: ancestor transforms make canvas alpha holes paint black. */
}

.ticket__shine {
  pointer-events: none;
  position: absolute;
  inset: 0;
  z-index: 0;
  background: linear-gradient(
    115deg,
    transparent 40%,
    rgba(255, 255, 255, 0.28) 48%,
    transparent 56%
  );
  mix-blend-mode: soft-light;
}

.ticket > *:not(.ticket__shine) {
  position: relative;
  z-index: 1;
}

.ticket__head {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
}

.ticket__agency {
  margin: 0;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ticket-red);
  font-weight: 600;
}

.ticket__title {
  margin: 0.15rem 0 0;
  font-family: "Special Elite", "Courier New", monospace;
  font-size: 1.55rem;
  font-weight: 400;
  letter-spacing: 0.02em;
}

.ticket__price {
  margin: 0;
  padding: 0.2rem 0.45rem;
  border: 2px solid var(--ticket-ink);
  font-weight: 700;
  font-size: 0.95rem;
  line-height: 1;
}

.ticket__tagline {
  margin: 0.75rem 0 0;
  font-size: 0.86rem;
  color: color-mix(in srgb, var(--ticket-ink) 72%, transparent);
}

.ticket__tagline strong {
  color: var(--ticket-ink);
}

.ticket__grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.45rem;
  margin-top: 1rem;
  touch-action: none;
  cursor: none;
}

.ticket__cell {
  position: relative;
  aspect-ratio: 1;
  border: 2px solid color-mix(in srgb, var(--ticket-ink) 40%, transparent);
  border-radius: 0.3rem;
  overflow: hidden;
  background-color: #1a1410;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.15);
}

.ticket__under,
.ticket__latex {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
}

.ticket__under {
  z-index: 0;
  object-fit: cover;
  object-position: center;
  pointer-events: none;
  user-select: none;
  -webkit-user-drag: none;
}

.ticket__latex {
  z-index: 1;
  touch-action: none;
  background: transparent;
}

.ticket.is-coin-active,
.ticket.is-coin-active * {
  cursor: none !important;
}

.scratch-coin {
  position: fixed;
  top: 0;
  left: 0;
  width: 108px;
  height: 108px;
  pointer-events: none;
  z-index: 9999;
  opacity: 0;
  background: url("/assets/coin-cursor.png?v=20261106f") center / contain no-repeat;
  filter: drop-shadow(1px 3px 2px rgba(40, 24, 8, 0.28));
  will-change: transform;
  transition: opacity 0.08s ease;
  transform-origin: 0 0;
}

.scratch-coin.is-visible {
  opacity: 1;
}

.scratch-flakes {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 9998;
}

.ticket__cell.is-revealed .ticket__latex {
  /* Keep remaining latex; only stop counting once enough is cleared */
  pointer-events: auto;
}

.ticket__result {
  margin: 0.75rem 0 0;
  padding: 0.55rem 0.65rem;
  border-radius: 0.3rem;
  font-family: "Special Elite", "Courier New", monospace;
  font-size: 0.92rem;
  line-height: 1.35;
  background: rgba(28, 24, 20, 0.08);
}

.ticket__result[data-state="win"] {
  background: color-mix(in srgb, #ffe08a 55%, white);
  color: #3a2a10;
}

.ticket__result[data-state="lose"] {
  color: color-mix(in srgb, var(--ticket-ink) 70%, transparent);
}

.ticket.is-winner {
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.65) inset,
    0 0 0 2px #c9a227,
    0 18px 40px rgba(20, 32, 27, 0.14);
}

.scratch-note {
  margin: 0.85rem 0 0;
  max-width: 36ch;
  font-size: 0.84rem;
  color: color-mix(in srgb, var(--ink) 62%, var(--moss));
}

.ticket__meta {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 0.75rem;
  font-size: 0.72rem;
  font-variant-numeric: tabular-nums;
  color: color-mix(in srgb, var(--ticket-ink) 65%, transparent);
}

.ticket__void {
  color: var(--ticket-red);
  font-weight: 700;
  letter-spacing: 0.04em;
}

.ticket__barcode {
  margin: 0.7rem 0 1rem;
  height: 2rem;
  border-radius: 0.15rem;
  background: repeating-linear-gradient(
    90deg,
    #111 0 2px,
    transparent 2px 3px,
    #111 3px 4px,
    transparent 4px 7px,
    #111 7px 8px,
    transparent 8px 10px,
    #111 10px 13px,
    transparent 13px 14px
  );
  opacity: 0.85;
}

footer {
  margin-top: auto;
  padding: 2rem 0 6.5rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  font-size: 0.95rem;
}

/* —— Pauline bottom walker: locked head + distinct stride body frames —— */
.pauline-walker {
  /* Width locked to sprite — bubble is absolute so quotes can't shove her sideways. */
  --pauline-bob: 0px;
  position: fixed;
  left: 0;
  bottom: 0;
  bottom: env(safe-area-inset-bottom, 0px);
  z-index: 40;
  width: 144px;
  height: 192px;
  pointer-events: none;
  will-change: transform;
  opacity: 0;
  transition: opacity 0.7s ease;
}

.pauline-walker.is-ready {
  opacity: 1;
}

.pauline-walker.is-flipped .pauline-walker__sprite {
  transform: scaleX(-1);
}

.pauline-walker__sprite {
  display: block;
  width: 144px;
  height: 192px;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.pauline-walker__bubble {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 0.35rem);
  z-index: 1;
  width: max-content;
  max-width: min(14rem, 70vw);
  padding: 0.45rem 0.65rem;
  border-radius: 0.85rem;
  background: #fffaf2;
  color: #1c1814;
  border: 1.5px solid rgba(28, 24, 20, 0.2);
  font-family: "Special Elite", "Courier New", monospace;
  font-size: 0.82rem;
  line-height: 1.3;
  text-align: center;
  box-shadow: 0 6px 16px rgba(20, 32, 27, 0.12);
  opacity: 0;
  /* Bob tracks the gait; only opacity fades so transform stays snappy. */
  transform: translate(-50%, calc(var(--pauline-bob) + 0.35rem)) scale(0.96);
  transition: opacity 0.2s ease;
}

.pauline-walker__bubble.is-on {
  opacity: 1;
  transform: translate(-50%, var(--pauline-bob)) scale(1);
}

.pauline-walker__bubble::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -7px;
  width: 12px;
  height: 12px;
  background: #fffaf2;
  border-right: 1.5px solid rgba(28, 24, 20, 0.2);
  border-bottom: 1.5px solid rgba(28, 24, 20, 0.2);
  transform: translateX(-50%) rotate(45deg);
}

@media (max-width: 520px) {
  .pauline-walker,
  .pauline-walker__sprite {
    width: 110px;
    height: 147px;
  }

  footer {
    padding-bottom: 5.5rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .pauline-walker {
    display: none;
  }
}

footer a {
  color: var(--moss);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
}

footer a:hover {
  color: var(--ink);
}

.sep {
  width: 0.35rem;
  height: 0.35rem;
  border-radius: 50%;
  background: var(--mist);
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(0.8rem);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (prefers-reduced-motion: reduce) {
  .hero {
    animation: none;
  }
}
