:root {
  --ink: #21003f;
  --purple: #4d1290;
  --purple-bright: #782fc1;
  --gold: #ffd84a;
  --orange: #ff9e2c;
  --paper: #f4f1f7;
  --white: #ffffff;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-height: 100%;
  margin: 0;
  background: var(--ink);
}

body {
  min-width: 0;
  min-height: 100vh;
  min-height: 100dvh;
  color: var(--white);
  font-family: "Trebuchet MS", "Avenir Next", sans-serif;
  overscroll-behavior: none;
  overflow-x: hidden;
}

button,
canvas {
  -webkit-tap-highlight-color: transparent;
}

.game-shell {
  position: relative;
  display: flex;
  min-height: 100vh;
  min-height: 100dvh;
  width: 100%;
  margin: 0 auto;
  padding:
    max(10px, env(safe-area-inset-top))
    max(5px, env(safe-area-inset-right))
    max(16px, env(safe-area-inset-bottom))
    max(5px, env(safe-area-inset-left));
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  overflow-x: hidden;
  isolation: isolate;
  background:
    linear-gradient(145deg, rgba(120, 47, 193, 0.2), transparent 45%),
    var(--ink);
}

.viewport-fallback .game-shell {
  width: var(--viewport-fix-width);
  min-height: var(--viewport-fix-height);
  margin: 0;
  transform: scale(var(--viewport-fix-scale));
  transform-origin: top left;
}

.game-shell::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -3;
  background: url("assets/reference.png") center / cover no-repeat;
  opacity: 0.035;
  mix-blend-mode: screen;
  pointer-events: none;
}

.burst {
  position: absolute;
  inset: -24%;
  z-index: -2;
  background: repeating-conic-gradient(
    from -8deg,
    transparent 0deg 14deg,
    rgba(120, 47, 193, 0.38) 14deg 28deg
  );
  transform: rotate(-3deg);
  animation: drift 12s ease-in-out infinite alternate;
}

.spark {
  position: absolute;
  width: 24px;
  aspect-ratio: 1;
  background: var(--gold);
  clip-path: polygon(50% 0, 61% 37%, 100% 50%, 61% 63%, 50% 100%, 39% 63%, 0 50%, 39% 37%);
  filter: drop-shadow(0 0 8px rgba(255, 216, 74, 0.75));
  opacity: 0.75;
}

.spark-one {
  top: 13%;
  left: 9%;
  transform: rotate(17deg) scale(0.72);
}

.spark-two {
  right: 8%;
  bottom: 17%;
  transform: rotate(40deg) scale(0.48);
}

.coin {
  position: absolute;
  display: grid;
  width: 34px;
  aspect-ratio: 1;
  place-items: center;
  border: 3px solid #ffe878;
  border-radius: 50%;
  color: #7c3700;
  background: var(--orange);
  font-family: "Arial Black", Impact, sans-serif;
  box-shadow: inset 0 0 0 3px #ffc33d, 0 5px 12px rgba(0, 0, 0, 0.25);
  opacity: 0.9;
}

.coin-one {
  top: 27%;
  right: -9px;
  transform: rotate(22deg);
}

.coin-two {
  bottom: 10%;
  left: -11px;
  transform: rotate(-18deg) scale(0.82);
}

.campaign-brand {
  position: relative;
  z-index: 2;
  display: flex;
  width: min(100%, 430px);
  margin-bottom: 9px;
  align-items: center;
  flex-direction: column;
}

.campaign-logo-wrap {
  width: min(88%, 350px);
  padding: 9px 28px;
  border: 0;
  border-radius: 0;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(255, 255, 255, 0.18) 8%,
    rgba(255, 255, 255, 0.72) 24%,
    rgba(255, 255, 255, 0.72) 76%,
    rgba(255, 255, 255, 0.18) 92%,
    transparent 100%
  );
  box-shadow: none;
}

.campaign-logo {
  display: block;
  width: 100%;
  height: auto;
  opacity: 0.78;
  filter: drop-shadow(0 2px 5px rgba(255, 255, 255, 0.22));
}

.scratch-promo {
  width: 100%;
  margin: -2px 0 10px;
  padding: 6px 8px;
  border-top: 1px solid rgba(255, 216, 74, 0.3);
  border-bottom: 1px solid rgba(255, 216, 74, 0.3);
  color: var(--gold);
  background: rgba(255, 216, 74, 0.07);
  font-size: 1.1rem;
  font-weight: 900;
  letter-spacing: 0;
  text-align: center;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.42);
}

.brand {
  position: relative;
  z-index: 2;
  display: flex;
  margin-bottom: -15px;
  transform: rotate(-2deg);
  flex-direction: column;
  align-items: center;
  font-family: "Arial Black", Impact, sans-serif;
  font-style: italic;
  line-height: 0.72;
  letter-spacing: 0;
  filter: drop-shadow(0 7px 0 rgba(28, 0, 55, 0.7));
}

.brand-top {
  font-size: 3.85rem;
  color: var(--white);
  -webkit-text-stroke: 3px var(--purple-bright);
  text-shadow: 0 4px 0 #d7c5e8;
}

.brand-bottom {
  font-size: 4.4rem;
  color: #ffc84b;
  -webkit-text-stroke: 3px #a95209;
  text-shadow: 0 5px 0 #d47a1f;
}

.brand-bottom b {
  font-size: 0.72em;
}

.ticket {
  position: relative;
  width: min(calc(100% - 4px), 430px);
  padding: 19px 16px 15px;
  border: 4px solid var(--gold);
  border-radius: 22px 7px 22px 7px;
  background: linear-gradient(155deg, #501292, #27004c 65%);
  box-shadow:
    0 0 0 4px #9d5a12,
    0 0 0 7px #fff16d,
    0 16px 30px rgba(12, 0, 24, 0.5),
    0 0 27px rgba(255, 216, 74, 0.55);
}

.ticket-copy {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: end;
  margin: 0 4px 14px;
}

.eyebrow,
.serial {
  margin: 0;
  color: #decdf2;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0;
}

.ticket-copy h1 {
  grid-column: 1 / -1;
  margin: 3px 0 0;
  font-family: "Arial Black", Impact, sans-serif;
  font-size: 2.55rem;
  font-style: italic;
  line-height: 0.82;
  letter-spacing: 0;
  text-shadow: 0 4px 0 rgba(0, 0, 0, 0.28);
}

.ticket-copy h1 span {
  color: var(--gold);
}

.serial {
  align-self: end;
  grid-column: 2;
  grid-row: 1;
}

.scratch-stage {
  position: relative;
  width: 100%;
  aspect-ratio: 1.52;
  overflow: hidden;
  border: 3px solid rgba(255, 255, 255, 0.78);
  border-radius: 15px 5px 15px 5px;
  background: var(--paper);
  box-shadow: inset 0 0 0 2px rgba(38, 0, 79, 0.25);
  touch-action: none;
  user-select: none;
}

.prize {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  color: var(--ink);
  background:
    radial-gradient(circle at 18% 20%, rgba(255, 255, 255, 0.95) 0 3px, transparent 4px),
    radial-gradient(circle at 82% 72%, rgba(255, 255, 255, 0.8) 0 2px, transparent 3px),
    repeating-linear-gradient(-45deg, #ffd740 0 13px, #ffbf31 13px 26px);
}

.prize::before {
  content: "";
  position: absolute;
  inset: 11px;
  border: 2px dashed rgba(86, 40, 0, 0.3);
  border-radius: 10px 3px 10px 3px;
}

.prize-kicker,
.prize-note {
  position: relative;
  font-size: 0.9rem;
  font-weight: 800;
}

.prize strong {
  position: relative;
  margin: 1px 0;
  color: #4b0c83;
  font-family: "Arial Black", Impact, sans-serif;
  font-size: 3.7rem;
  line-height: 1;
  letter-spacing: 0;
  text-shadow: 0 3px 0 rgba(255, 255, 255, 0.75);
}

#scratch-canvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  cursor: crosshair;
}

.scratch-label {
  position: absolute;
  top: 50%;
  left: 50%;
  color: #686868;
  font-family: "Arial Black", Impact, sans-serif;
  font-size: 1.25rem;
  letter-spacing: 0;
  text-shadow: 0 2px 0 #efefef;
  transform: translate(-50%, -50%) rotate(-2deg);
  pointer-events: none;
  transition: opacity 180ms ease;
}

.ticket-footer {
  display: flex;
  min-height: 44px;
  margin-top: 13px;
  align-items: center;
  justify-content: space-between;
}

.ticket-footer > span {
  font-family: "Arial Black", Impact, sans-serif;
  font-size: 0.88rem;
  font-style: italic;
  color: var(--gold);
}

#reset-button {
  min-height: 42px;
  padding: 0 20px;
  border: 2px solid #fff07a;
  border-radius: 7px 3px 7px 3px;
  color: var(--ink);
  background: linear-gradient(#ffe96a, var(--orange));
  box-shadow: 0 4px 0 #b75812;
  font: 800 0.9rem "Trebuchet MS", "Avenir Next", sans-serif;
  cursor: pointer;
}

#reset-button:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 #b75812;
}

#reset-button:disabled {
  cursor: default;
  filter: saturate(0.72);
  opacity: 0.86;
}

#reset-button:focus-visible {
  outline: 3px solid var(--white);
  outline-offset: 3px;
}

.tagline {
  position: relative;
  display: inline-flex;
  min-height: 46px;
  max-width: calc(100% - 20px);
  margin: 18px 0 0;
  padding: 10px 22px 8px;
  border: 3px solid #fff07a;
  border-radius: 8px 3px 8px 3px;
  color: #4b2100;
  background: linear-gradient(#ffe870, var(--orange));
  box-shadow: 0 5px 0 #b75b1e, 0 8px 18px rgba(0, 0, 0, 0.3);
  font-family: "Arial Black", Impact, sans-serif;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  font-style: italic;
  letter-spacing: 0;
  text-align: center;
  text-decoration: none;
  transform: rotate(1deg);
  appearance: none;
  cursor: default;
  transition: transform 180ms ease, filter 180ms ease;
}

.tagline.claim-ready {
  cursor: pointer;
  animation: claim-pulse 1.5s ease-in-out infinite;
}

.tagline[aria-disabled="true"] {
  pointer-events: none;
}

.tagline.claim-ready:active {
  transform: translateY(3px) rotate(1deg);
}

.tagline:focus-visible {
  outline: 3px solid var(--white);
  outline-offset: 4px;
}

.safety-note {
  position: relative;
  z-index: 2;
  width: min(94%, 520px);
  margin: 14px 0 0;
  color: rgba(255, 255, 255, 0.5);
  font: 500 0.56rem/1.45 "Trebuchet MS", "PingFang TC", sans-serif;
  letter-spacing: 0;
  text-align: center;
}

.confetti {
  position: absolute;
  inset: 0;
  z-index: 10;
  overflow: hidden;
  pointer-events: none;
}

.draw-total {
  position: absolute;
  bottom: max(8px, env(safe-area-inset-bottom));
  left: max(9px, env(safe-area-inset-left));
  z-index: 1;
  color: rgba(255, 255, 255, 0.28);
  font: 600 0.62rem/1 "Trebuchet MS", "Avenir Next", sans-serif;
  letter-spacing: 0;
  pointer-events: none;
  user-select: none;
}

.confetti-piece {
  position: absolute;
  top: 38%;
  width: 8px;
  height: 14px;
  border-radius: 1px;
  animation: confetti-fall 1.35s cubic-bezier(0.12, 0.58, 0.3, 1) forwards;
}

.revealed .scratch-label {
  opacity: 0;
}

.revealed .prize strong {
  animation: prize-pop 560ms cubic-bezier(0.17, 0.89, 0.32, 1.45);
}

.revealed.restored .prize strong {
  animation: none;
}

@keyframes drift {
  to { transform: rotate(4deg) scale(1.04); }
}

@keyframes prize-pop {
  0% { transform: scale(0.55) rotate(-8deg); }
  70% { transform: scale(1.1) rotate(2deg); }
  100% { transform: scale(1) rotate(0); }
}

@keyframes claim-pulse {
  0%, 100% { filter: brightness(1); }
  50% { filter: brightness(1.16) drop-shadow(0 0 9px rgba(255, 216, 74, 0.65)); }
}

@keyframes confetti-fall {
  0% { transform: translate(0, 0) rotate(0); opacity: 1; }
  100% { transform: translate(var(--x), 52svh) rotate(var(--r)); opacity: 0; }
}

@media (min-height: 780px) {
  .ticket-copy { margin-bottom: 18px; }
  .tagline { margin-top: 24px; }
}

@media (max-height: 740px) {
  .game-shell {
    justify-content: flex-start;
  }
}

@media (hover: hover) and (pointer: fine) and (min-height: 741px) {
  .game-shell {
    justify-content: center;
  }
}

@media (max-height: 680px) {
  .game-shell { padding-top: 14px; padding-bottom: 14px; }
  .campaign-brand { margin-bottom: 9px; }
  .campaign-logo-wrap { width: min(78%, 300px); padding-top: 6px; padding-bottom: 6px; }
  .scratch-promo { margin-bottom: 7px; padding-top: 4px; padding-bottom: 4px; font-size: 0.98rem; }
  .brand { margin-bottom: -12px; }
  .brand-top { font-size: 2.35rem; }
  .brand-bottom { font-size: 2.75rem; }
  .ticket { padding-top: 15px; }
  .ticket-copy { margin-bottom: 9px; }
  .ticket-copy h1 { font-size: 1.85rem; }
  .scratch-stage { aspect-ratio: 1.9; }
  .tagline { margin-top: 14px; }
}

@media (max-width: 360px) {
  .game-shell {
    padding-right: max(4px, env(safe-area-inset-right));
    padding-left: max(4px, env(safe-area-inset-left));
  }

  .brand-top { font-size: 2.85rem; }
  .brand-bottom { font-size: 3.3rem; }
  .campaign-logo-wrap { width: 88%; padding: 7px 22px; }
  .scratch-promo { font-size: 1rem; }
  .ticket { padding: 16px 12px 13px; }
  .ticket-copy h1 { font-size: 2rem; }
  .prize strong { font-size: 2.85rem; }
  .scratch-label { font-size: 1rem; }
  .tagline { font-size: 0.84rem; }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
