:root {
  --bg-deep: #02030a;
  --bg-mid: #060814;
  --bg-edge: #0a0c1c;
  --gold-light: #fff2c2;
  --gold: #ffcc44;
  --gold-deep: #b8862a;
  --gold-shadow: #5a4012;
  --text: #d8d4e0;
  --muted: #6a6878;
  --card-bg: rgba(10, 12, 22, 0.9);
  --border: rgba(255, 204, 68, 0.15);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  font-family: -apple-system, system-ui, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  /* Pure dark luxury — subtle vignette, no colored glow */
  background:
    radial-gradient(ellipse at center, var(--bg-edge) 0%, var(--bg-deep) 100%);
  background-attachment: fixed;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

#app { position: relative; width: 100vw; height: 100vh; }

.screen {
  position: absolute; inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 14px;
  padding: 32px 16px;
  overflow-y: auto;
}
.screen.visible { display: flex; }

/* Refined gold title — smaller, more elegant */
.title {
  font-size: 32px;
  font-weight: 800;
  letter-spacing: 4px;
  text-transform: uppercase;
  background: linear-gradient(180deg,
    var(--gold-light) 0%,
    var(--gold) 50%,
    var(--gold-deep) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 2px 8px rgba(255, 204, 68, 0.25));
  margin: 0;
  text-align: center;
}

/* Decorative line under title */
.title::after {
  content: '';
  display: block;
  width: 60px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
  margin: 8px auto 0;
}

h2 {
  font-size: 24px;
  color: var(--gold);
  margin-top: 20px;
  letter-spacing: 1px;
}

.hint {
  font-size: 13px;
  color: var(--muted);
  text-align: center;
  margin: 2px 0;
  letter-spacing: 1px;
  text-transform: uppercase;
  min-height: 16px;
}

/* Stats — minimal dark pills */
.stats-row {
  display: flex;
  gap: 8px;
  width: 100%;
  max-width: 380px;
}
.stat-pill {
  flex: 1;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 6px;
  text-align: center;
}
.stat-label {
  display: block;
  font-size: 9px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 1px;
}
.stat-value {
  display: block;
  font-size: 22px;
  font-weight: 800;
  color: var(--gold);
  margin-top: 2px;
}

/* The hero — the card stands out against the dark background */
.card-container {
  position: relative;
  width: 100%;
  max-width: 340px;
  aspect-ratio: 1.6 / 1;
  border-radius: 18px;
  overflow: hidden;
  margin: 12px 0;
  /* Subtle gold frame */
  background:
    linear-gradient(135deg,
      var(--gold-light) 0%,
      var(--gold) 40%,
      var(--gold-deep) 80%,
      var(--gold-shadow) 100%);
  padding: 3px;
  /* Strong glow ONLY around the card — makes it the focal point */
  box-shadow:
    0 0 50px rgba(255, 204, 68, 0.25),
    0 0 100px rgba(255, 204, 68, 0.1),
    0 15px 50px rgba(0, 0, 0, 0.8);
}

/* Prize layer underneath */
.prize-layer {
  position: absolute;
  inset: 3px;
  border-radius: 15px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background:
    radial-gradient(ellipse at center, #1a1228 0%, #050208 100%);
  color: var(--gold-light);
  z-index: 1;
}
.prize-emoji {
  font-size: 64px;
  filter: drop-shadow(0 4px 12px rgba(255, 204, 68, 0.5));
  animation: floatSoft 3s ease-in-out infinite;
}
@keyframes floatSoft {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-5px); }
}
.prize-text {
  font-size: 30px;
  font-weight: 900;
  text-align: center;
  padding: 0 20px;
  letter-spacing: 1px;
  background: linear-gradient(180deg, var(--gold-light), var(--gold), var(--gold-deep));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 0 10px rgba(255, 204, 68, 0.5));
}

#scratch-canvas {
  position: absolute;
  inset: 3px;
  width: calc(100% - 6px);
  height: calc(100% - 6px);
  border-radius: 15px;
  cursor: grab;
  touch-action: none;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
  z-index: 2;
}

/* Make sure no parent steals touches */
.card-container {
  touch-action: none;
}
/* Sparkles inside the card */
.sparkles {
  position: absolute;
  inset: 3px;
  border-radius: 15px;
  pointer-events: none;
  z-index: 3;
  overflow: hidden;
}
.sparkle {
  position: absolute;
  font-size: 18px;
  opacity: 0;
  animation: sparkle 3s ease-in-out infinite;
  filter: drop-shadow(0 0 4px rgba(255, 232, 160, 0.7));
}
.sparkle.s1 { top: 12%; left: 14%; animation-delay: 0s; }
.sparkle.s2 { top: 22%; right: 18%; animation-delay: 0.8s; }
.sparkle.s3 { bottom: 18%; left: 22%; animation-delay: 1.6s; }
.sparkle.s4 { bottom: 28%; right: 14%; animation-delay: 2.4s; }
@keyframes sparkle {
  0%, 100% { opacity: 0; transform: scale(0.5); }
  50%      { opacity: 1; transform: scale(1.1); }
}

/* Buttons — dark with subtle gold accents */
.btn {
  width: 100%;
  max-width: 340px;
  padding: 14px 20px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--card-bg);
  color: var(--text);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 1px;
  cursor: pointer;
  transition: transform 0.1s, border-color 0.2s;
}
.btn:active { transform: scale(0.98); }
.btn:hover { border-color: rgba(255, 204, 68, 0.3); }

/* Primary button: gold but elegant */
.btn.primary {
  background:
    linear-gradient(180deg,
      var(--gold-light) 0%,
      var(--gold) 40%,
      var(--gold-deep) 80%,
      var(--gold-shadow) 100%);
  border: 1px solid var(--gold);
  color: #1a0c00;
  font-weight: 900;
  letter-spacing: 2px;
  text-transform: uppercase;
  box-shadow:
    0 4px 20px rgba(255, 204, 68, 0.35),
    inset 0 1px 0 rgba(255, 255, 255, 0.4);
}

/* Overlay popup */
.overlay {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.92);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 1000;
  backdrop-filter: blur(6px);
}
.overlay.visible { display: flex; }
.result-card {
  background: var(--card-bg);
  border: 1px solid var(--gold);
  border-radius: 18px;
  padding: 28px 24px;
  width: 100%;
  max-width: 380px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 14px;
  animation: popIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow:
    0 0 50px rgba(255, 204, 68, 0.3),
    0 20px 60px rgba(0, 0, 0, 0.9);
}
@keyframes popIn {
  0%   { transform: scale(0.5); opacity: 0; }
  100% { transform: scale(1);   opacity: 1; }
}
.prize-label {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 2px;
}
.trophy {
  font-size: 64px;
  filter: drop-shadow(0 4px 14px rgba(255, 204, 68, 0.5));
}
.amount {
  font-size: 38px;
  font-weight: 900;
  background: linear-gradient(180deg, var(--gold-light), var(--gold), var(--gold-deep));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 0 16px rgba(255, 204, 68, 0.4));
}
.promo-box {
  background: rgba(0, 0, 0, 0.5);
  border: 1px dashed var(--gold);
  border-radius: 10px;
  padding: 14px;
  margin: 8px 0;
}
.promo-label {
  font-size: 10px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 2px;
  margin-bottom: 4px;
}
.promo-code {
  font-family: ui-monospace, "Courier New", monospace;
  font-size: 22px;
  font-weight: 700;
  color: var(--gold);
  letter-spacing: 1px;
}

#confetti-canvas {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 999;
}

#codes-list {
  list-style: none;
  width: 100%;
  max-width: 420px;
  max-height: 60vh;
  overflow-y: auto;
}
#codes-list li {
  display: flex;
  flex-direction: column;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 8px;
}
#codes-list li .label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; }
#codes-list li .code {
  font-family: ui-monospace, monospace;
  font-size: 16px;
  font-weight: 700;
  color: var(--gold);
  margin-top: 4px;
}

.toast {
  position: fixed;
  bottom: 30px; left: 50%;
  transform: translateX(-50%);
  background: rgba(5, 5, 12, 0.98);
  color: var(--text);
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
  border: 1px solid var(--border);
  z-index: 2000;
}
.toast.show { opacity: 1; }

.shake { animation: shake 0.5s; }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-10px); }
  75% { transform: translateX(10px); }
}