:root {
  --bg-1: #cdd3d4;
  --bg-2: #aab1b3;
  --paper: #d1f158;
  --paper-shadow: 0 30px 70px rgba(62, 69, 41, 0.28);
  --ink: #17351d;
  --muted: #496033;
  --panel: rgba(252, 252, 245, 0.72);
  --line: rgba(33, 50, 20, 0.12);
  --win: #0d7f47;
  --lose: #981b1b;
}

* {
  box-sizing: border-box;
}

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

body {
  font-family: "Trebuchet MS", "Apple SD Gothic Neo", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 20% 20%, rgba(255, 255, 255, 0.55), transparent 22%),
    radial-gradient(circle at 80% 10%, rgba(255, 255, 255, 0.35), transparent 18%),
    linear-gradient(180deg, var(--bg-1), var(--bg-2));
}

.page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 18px 14px 24px;
}

.stage {
  width: min(100%, 1180px);
  display: grid;
  gap: 16px;
}

.ticket-wrap {
  perspective: 1400px;
}

.ticket-shell {
  position: relative;
  overflow: hidden;
  border-radius: 26px;
  padding: 16px;
  background:
    radial-gradient(circle at 12% 10%, rgba(255, 255, 255, 0.42), transparent 20%),
    radial-gradient(circle at 82% 26%, rgba(255, 255, 255, 0.24), transparent 24%),
    linear-gradient(180deg, #d7f565, var(--paper) 32%, #b9e23a);
  box-shadow: var(--paper-shadow);
  transform: rotate(-6deg);
}

.ticket-shell::before,
.ticket-shell::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.ticket-shell::before {
  background:
    radial-gradient(circle at 0 50%, transparent 0 12px, rgba(0, 0, 0, 0.08) 12px 13px, transparent 13px) left center / 26px 44px repeat-y,
    radial-gradient(circle at 100% 50%, transparent 0 12px, rgba(0, 0, 0, 0.08) 12px 13px, transparent 13px) right center / 26px 44px repeat-y;
  opacity: 0.45;
}

.ticket-shell::after {
  border: 1px solid rgba(65, 89, 17, 0.14);
  border-radius: 26px;
}

.ticket-header,
.ticket-body,
.summary,
.controls,
.meta-strip {
  display: flex;
  gap: 12px;
}

.ticket-header,
.hero,
.ticket-body {
  position: relative;
  z-index: 1;
}

.ticket-header {
  justify-content: space-between;
  align-items: center;
}

.brand-badge,
.brand-mini,
.eyebrow,
.label {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-weight: 900;
}

.brand-badge,
.ticket-price {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 0 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.86);
  border: 1px solid rgba(56, 78, 15, 0.12);
  box-shadow: 0 10px 18px rgba(102, 128, 20, 0.13);
}

.brand-badge,
.brand-mini,
.label,
.ticket-price {
  font-size: 0.72rem;
}

.brand-mini {
  margin-top: 6px;
  color: var(--muted);
}

.ticket-price {
  font-weight: 900;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition:
    transform 140ms ease,
    box-shadow 140ms ease,
    background 140ms ease;
}

.ticket-price-button {
  appearance: none;
  border: 1px solid rgba(56, 78, 15, 0.12);
  font: inherit;
  color: inherit;
}

#mobile-secret-trigger {
  cursor: pointer;
  pointer-events: auto;
}

#mobile-secret-trigger.is-tapped {
  transform: translateY(1px) scale(0.96);
  box-shadow: 0 6px 10px rgba(102, 128, 20, 0.12);
  background: rgba(255, 244, 187, 0.94);
}

#mobile-secret-trigger:active {
  transform: translateY(1px) scale(0.96);
}

.hero {
  margin-top: 12px;
}

.eyebrow {
  color: #5c7a19;
  font-size: 0.74rem;
}

.hero h1 {
  margin: 6px 0 10px;
  font-size: clamp(2.2rem, 7vw, 4rem);
  line-height: 0.95;
  letter-spacing: -0.05em;
  color: white;
  text-shadow:
    0 0 0 #fff,
    3px 3px 0 #3ea54f,
    6px 6px 0 #f3a329;
}

.description {
  max-width: 72ch;
  margin: 0;
  line-height: 1.38;
  font-weight: 700;
}

.ticket-body {
  margin-top: 14px;
  align-items: stretch;
}

.ticket-side {
  width: 92px;
  flex: 0 0 92px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.52);
  border: 1px solid rgba(67, 95, 15, 0.1);
}

.barcode {
  width: 34px;
  height: 100px;
  display: flex;
  align-items: stretch;
  gap: 2px;
}

.barcode span:nth-child(odd) {
  width: 2px;
  background: #273018;
}

.barcode span:nth-child(even) {
  width: 4px;
  background: #273018;
}

.play-guide {
  display: grid;
  gap: 8px;
  font-size: 0.7rem;
  font-weight: 900;
  color: #33501d;
}

.play-guide p {
  margin: 0;
  writing-mode: vertical-rl;
  text-orientation: mixed;
}

.scratch-stage {
  flex: 1;
  min-width: 0;
}

.scratch-frame {
  position: relative;
  padding: 10px;
  border-radius: 24px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.72), rgba(244, 252, 201, 0.5)),
    rgba(255, 255, 255, 0.35);
  border: 1px solid rgba(78, 104, 23, 0.14);
}

.scratch-board {
  position: relative;
  aspect-ratio: 2.5 / 1;
  border-radius: 22px;
  overflow: hidden;
  background: linear-gradient(180deg, #fffef8, #fff5d7);
  border: 1px solid rgba(135, 101, 54, 0.14);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.34);
}

.symbol-grid {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: repeat(9, minmax(0, 1fr));
  gap: 8px;
  padding: 12px;
}

.symbol-cell {
  min-width: 0;
  border-radius: 16px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.97), rgba(254, 238, 193, 0.92));
  border: 1px solid rgba(120, 88, 43, 0.12);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.72);
  display: grid;
  place-items: center;
  padding: 6px;
}

.number-face {
  font-size: clamp(1.35rem, 2.6vw, 2.25rem);
  font-weight: 900;
  color: #9f1d14;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.75);
}

.number-face.golden-face {
  color: #fff3a8;
  text-shadow:
    0 0 0 #fffef2,
    0 0 10px rgba(255, 215, 80, 0.9),
    0 0 24px rgba(255, 188, 34, 0.72),
    0 2px 0 rgba(148, 85, 8, 0.55);
  filter: saturate(1.15);
  animation: golden-pulse 1.8s ease-in-out infinite;
}

.number-face.empty-face {
  opacity: 0.18;
}

.image-face {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 12px;
}

.scratch-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: grab;
}

.scratch-canvas.is-scratching {
  cursor: grabbing;
}

.scratch-instruction {
  position: absolute;
  right: 12px;
  bottom: 12px;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(22, 29, 34, 0.68);
  color: white;
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  backdrop-filter: blur(8px);
  pointer-events: none;
}

.meta-strip {
  margin-top: 10px;
  flex-wrap: wrap;
}

.meta-strip > div,
.debug-panel,
.hud-panel,
.summary > div {
  border-radius: 18px;
  background: var(--panel);
  border: 1px solid var(--line);
}

.meta-strip > div {
  flex: 1 1 170px;
  padding: 12px 14px;
}

.meta-strip p,
.summary p {
  margin: 6px 0 0;
  font-weight: 800;
}

.hud-panel {
  padding: 14px;
  backdrop-filter: blur(14px);
}

.status-text {
  margin: 0 0 12px;
  font-size: 1rem;
  font-weight: 900;
}

.debug-panel {
  margin: 0 0 12px;
  padding: 12px 14px;
}

.debug-label {
  display: block;
  margin-bottom: 8px;
  font-size: 0.74rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.debug-row {
  display: flex;
  gap: 10px;
  align-items: center;
}

.debug-input {
  flex: 1 1 auto;
  min-width: 0;
  height: 46px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid rgba(58, 82, 18, 0.16);
  background: rgba(255, 255, 255, 0.88);
  color: var(--ink);
  font: inherit;
  font-weight: 800;
}

.debug-input:focus {
  outline: 2px solid rgba(111, 150, 27, 0.28);
  outline-offset: 2px;
}

.status-text.win {
  color: var(--win);
}

.status-text.lose {
  color: var(--lose);
}

.win-modal {
  position: fixed;
  inset: 0;
  z-index: 30;
}

.win-modal[hidden] {
  display: none;
}

.win-modal__backdrop {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at top, rgba(255, 236, 151, 0.22), transparent 30%),
    rgba(17, 22, 29, 0.72);
  backdrop-filter: blur(10px);
  animation: backdrop-glow 1.8s ease-in-out infinite alternate;
}

.win-modal__dialog {
  position: relative;
  width: min(calc(100% - 28px), 520px);
  margin: min(12vh, 88px) auto 0;
  padding: 28px 22px 22px;
  border-radius: 28px;
  text-align: center;
  color: #fffaf0;
  background:
    radial-gradient(circle at top, rgba(255, 255, 255, 0.24), transparent 32%),
    linear-gradient(180deg, #ffcf56, #f56a2b 54%, #bf1f17);
  box-shadow: 0 28px 80px rgba(18, 15, 6, 0.36);
  border: 1px solid rgba(255, 244, 205, 0.38);
  animation: modal-pop 260ms ease;
}

.win-modal--super .win-modal__backdrop {
  background:
    radial-gradient(circle at top, rgba(130, 216, 255, 0.3), transparent 28%),
    radial-gradient(circle at bottom, rgba(255, 120, 214, 0.18), transparent 32%),
    rgba(11, 16, 31, 0.82);
}

.win-modal--super .win-modal__dialog {
  background:
    radial-gradient(circle at top, rgba(255, 255, 255, 0.28), transparent 32%),
    linear-gradient(180deg, #6ce7ff, #5d72ff 48%, #b21fff);
  border: 1px solid rgba(218, 247, 255, 0.44);
  box-shadow: 0 32px 90px rgba(22, 15, 55, 0.5);
}

.win-modal--super .win-modal__dialog::before {
  background: radial-gradient(circle, rgba(215, 251, 255, 0.95), transparent 70%);
}

.win-modal--super .win-modal__title {
  text-shadow:
    0 0 0 #fff,
    3px 3px 0 rgba(47, 17, 152, 0.5),
    7px 7px 24px rgba(25, 6, 79, 0.34);
}

.win-modal--super .win-modal__chips span {
  background: rgba(255, 255, 255, 0.22);
}

.win-modal__dialog::before {
  content: "";
  position: absolute;
  inset: -22% 18% auto;
  height: 120px;
  border-radius: 999px;
  background: radial-gradient(circle, rgba(255, 250, 198, 0.82), transparent 70%);
  filter: blur(12px);
  opacity: 0.8;
  animation: crown-glow 2.2s ease-in-out infinite;
}

.win-modal__eyebrow {
  margin: 6px 0 8px;
  font-size: 0.82rem;
  font-weight: 900;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: rgba(255, 250, 226, 0.88);
  animation: float-up 480ms ease both 80ms;
}

.win-modal__title {
  margin: 0;
  font-size: clamp(2.4rem, 9vw, 4.6rem);
  line-height: 0.95;
  letter-spacing: -0.06em;
  color: white;
  text-shadow:
    0 0 0 #fff,
    3px 3px 0 rgba(179, 24, 15, 0.45),
    7px 7px 18px rgba(88, 17, 5, 0.28);
  animation: title-bounce 780ms cubic-bezier(0.2, 0.9, 0.2, 1.15) both 120ms;
}

.win-modal__text {
  margin: 14px auto 0;
  max-width: 28ch;
  font-size: 1rem;
  line-height: 1.45;
  font-weight: 800;
  animation: float-up 520ms ease both 190ms;
}

.win-modal__chips {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin: 18px 0 20px;
}

.win-modal__chips span {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 0 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.18);
  border: 1px solid rgba(255, 245, 211, 0.32);
  font-size: 0.83rem;
  font-weight: 900;
  letter-spacing: 0.06em;
  animation: chip-pop 520ms ease both;
}

.win-modal__chips span:nth-child(1) {
  animation-delay: 260ms;
}

.win-modal__chips span:nth-child(2) {
  animation-delay: 340ms;
}

.win-modal__chips span:nth-child(3) {
  animation-delay: 420ms;
}

.win-burst {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.win-burst span {
  position: absolute;
  width: 10px;
  height: 28px;
  border-radius: 999px;
  background: linear-gradient(180deg, #fff6bc, #ffd039);
  opacity: 0.85;
  animation: sparkle-ray 1.8s ease-in-out infinite;
}

.win-burst span:nth-child(1) {
  top: 24px;
  left: 14%;
  transform: rotate(-30deg);
}

.win-burst span:nth-child(2) {
  top: 42px;
  left: 28%;
  transform: rotate(-12deg);
}

.win-burst span:nth-child(3) {
  top: 18px;
  left: 44%;
  transform: rotate(8deg);
}

.win-burst span:nth-child(4) {
  top: 30px;
  right: 34%;
  transform: rotate(24deg);
}

.win-burst span:nth-child(5) {
  top: 20px;
  right: 18%;
  transform: rotate(38deg);
}

.win-burst span:nth-child(6) {
  bottom: 28px;
  left: 18%;
  transform: rotate(18deg);
}

.win-burst span:nth-child(7) {
  bottom: 18px;
  right: 22%;
  transform: rotate(-20deg);
}

.win-burst span:nth-child(8) {
  bottom: 38px;
  right: 10%;
  transform: rotate(12deg);
}

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

.win-confetti span {
  position: absolute;
  top: -18px;
  width: 10px;
  height: 18px;
  border-radius: 2px;
  opacity: 0;
  animation: confetti-fall 1.8s linear infinite;
}

.win-confetti span:nth-child(odd) {
  background: #ffe17c;
}

.win-confetti span:nth-child(even) {
  background: #ffffff;
}

.win-confetti span:nth-child(3n) {
  background: #ff7b54;
}

.win-modal--super .win-confetti span:nth-child(odd) {
  background: #8cf6ff;
}

.win-modal--super .win-confetti span:nth-child(even) {
  background: #fbe4ff;
}

.win-modal--super .win-confetti span:nth-child(3n) {
  background: #ffe766;
}

.win-confetti span:nth-child(1) { left: 8%; animation-delay: 0.1s; }
.win-confetti span:nth-child(2) { left: 16%; animation-delay: 0.4s; }
.win-confetti span:nth-child(3) { left: 24%; animation-delay: 0.2s; }
.win-confetti span:nth-child(4) { left: 33%; animation-delay: 0.6s; }
.win-confetti span:nth-child(5) { left: 42%; animation-delay: 0.3s; }
.win-confetti span:nth-child(6) { left: 51%; animation-delay: 0.8s; }
.win-confetti span:nth-child(7) { left: 60%; animation-delay: 0.15s; }
.win-confetti span:nth-child(8) { left: 68%; animation-delay: 0.55s; }
.win-confetti span:nth-child(9) { left: 76%; animation-delay: 0.28s; }
.win-confetti span:nth-child(10) { left: 84%; animation-delay: 0.7s; }
.win-confetti span:nth-child(11) { left: 90%; animation-delay: 0.45s; }
.win-confetti span:nth-child(12) { left: 96%; animation-delay: 0.9s; }

#win-modal-close {
  animation: float-up 540ms ease both 460ms;
}

@keyframes modal-pop {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.96);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes float-up {
  from {
    opacity: 0;
    transform: translateY(14px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes title-bounce {
  0% {
    opacity: 0;
    transform: scale(0.7) rotate(-4deg);
  }

  65% {
    opacity: 1;
    transform: scale(1.08) rotate(1deg);
  }

  100% {
    opacity: 1;
    transform: scale(1) rotate(0);
  }
}

@keyframes chip-pop {
  0% {
    opacity: 0;
    transform: translateY(12px) scale(0.88);
  }

  70% {
    opacity: 1;
    transform: translateY(-2px) scale(1.04);
  }

  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes sparkle-ray {
  0%, 100% {
    opacity: 0.35;
    filter: brightness(0.95);
  }

  50% {
    opacity: 1;
    filter: brightness(1.25);
  }
}

@keyframes confetti-fall {
  0% {
    opacity: 0;
    transform: translateY(-10px) rotate(0deg);
  }

  15% {
    opacity: 1;
  }

  100% {
    opacity: 0;
    transform: translateY(290px) rotate(240deg);
  }
}

@keyframes backdrop-glow {
  from {
    background:
      radial-gradient(circle at top, rgba(255, 236, 151, 0.18), transparent 28%),
      rgba(17, 22, 29, 0.68);
  }

  to {
    background:
      radial-gradient(circle at top, rgba(255, 236, 151, 0.3), transparent 34%),
      rgba(17, 22, 29, 0.78);
  }
}

@keyframes crown-glow {
  0%, 100% {
    opacity: 0.5;
    transform: scale(0.92);
  }

  50% {
    opacity: 0.95;
    transform: scale(1.08);
  }
}

@keyframes golden-pulse {
  0%, 100% {
    transform: scale(1);
    filter: saturate(1.05) brightness(1);
  }

  50% {
    transform: scale(1.06);
    filter: saturate(1.2) brightness(1.08);
  }
}

.summary {
  flex-wrap: wrap;
}

.summary > div {
  flex: 1 1 180px;
  padding: 12px 14px;
}

.controls {
  margin-top: 14px;
  flex-wrap: wrap;
}

button {
  appearance: none;
  border: 0;
  cursor: pointer;
  transition: transform 140ms ease, box-shadow 140ms ease, opacity 140ms ease;
}

.primary-button,
.ghost-button {
  min-height: 46px;
  padding: 0 18px;
  border-radius: 999px;
  font-size: 0.98rem;
  font-weight: 900;
}

.primary-button {
  color: white;
  background: linear-gradient(180deg, #ea5236, #b71f17);
  box-shadow: 0 12px 22px rgba(163, 31, 17, 0.24);
}

.ghost-button {
  color: #233116;
  background: rgba(255, 255, 255, 0.82);
}

button:hover {
  transform: translateY(-1px);
}

button:active {
  transform: translateY(0);
}

@media (max-width: 820px) {
  .ticket-shell {
    transform: rotate(-3deg);
  }

  .ticket-body {
    flex-direction: column;
  }

  .ticket-side {
    width: 100%;
    flex: none;
    flex-direction: row;
    justify-content: space-between;
    padding: 12px 14px;
  }

  .barcode {
    width: 132px;
    height: 28px;
  }

  .play-guide {
    display: flex;
    align-items: center;
  }

  .play-guide p {
    writing-mode: horizontal-tb;
  }

  .scratch-board {
    aspect-ratio: 1.55 / 1;
  }

  .symbol-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
  }

  .number-face {
    font-size: clamp(1.8rem, 7vw, 3rem);
  }
}

@media (max-width: 640px) {
  .page {
    padding: 12px 8px 20px;
  }

  .stage {
    width: min(100%, 430px);
    gap: 12px;
  }

  .ticket-wrap {
    padding: 10px 4px 0;
  }

  .ticket-shell {
    padding: 12px;
    border-radius: 20px;
    transform: rotate(-2.5deg);
    box-shadow: 0 22px 42px rgba(62, 69, 41, 0.26);
  }

  .hero h1 {
    font-size: clamp(2rem, 13vw, 3rem);
  }

  .description {
    font-size: 0.92rem;
  }

  .ticket-header {
    gap: 8px;
  }

  .brand-badge,
  .ticket-price {
    min-height: 30px;
    padding: 0 10px;
    font-size: 0.67rem;
  }

  .brand-mini {
    font-size: 0.64rem;
  }

  .ticket-side {
    padding: 10px 12px;
    border-radius: 14px;
  }

  .play-guide {
    gap: 10px;
    font-size: 0.66rem;
  }

  .scratch-frame {
    padding: 8px;
    border-radius: 18px;
  }

  .scratch-board {
    aspect-ratio: 1 / 1.02;
    border-radius: 18px;
  }

  .symbol-grid {
    gap: 7px;
    padding: 8px;
  }

  .symbol-cell {
    border-radius: 12px;
    padding: 4px;
  }

  .number-face {
    font-size: clamp(1.65rem, 8.8vw, 2.7rem);
  }

  .scratch-instruction {
    left: 8px;
    right: 8px;
    bottom: 8px;
    padding: 7px 10px;
    font-size: 0.68rem;
    text-align: center;
  }

  .meta-strip {
    margin-top: 8px;
    gap: 8px;
  }

  .meta-strip > div {
    flex: 1 1 100%;
    padding: 10px 12px;
    border-radius: 14px;
  }

  .hud-panel {
    padding: 12px;
    border-radius: 16px;
  }

  .debug-panel {
    padding: 10px 12px;
    border-radius: 14px;
  }

  .debug-row {
    flex-direction: column;
    align-items: stretch;
  }

  .summary {
    gap: 8px;
  }

  .summary > div {
    flex: 1 1 100%;
    padding: 10px 12px;
    border-radius: 14px;
  }

  .controls > button {
    flex: 1 1 100%;
  }

  .win-modal__dialog {
    width: min(calc(100% - 20px), 440px);
    margin-top: 72px;
    padding: 24px 16px 18px;
    border-radius: 22px;
  }

  .win-modal__chips {
    gap: 8px;
  }

  .win-modal__chips span {
    min-height: 32px;
    padding: 0 12px;
    font-size: 0.76rem;
  }
}
