:root {
  --bg-top: #050810;
  --bg-bot: #0f1828;
  --gold: #ffcc44;
  --accent: #6ec6ff;
  --text: #e8f4ff;
  --muted: #8db4d1;
  --card: rgba(15, 20, 35, 0.85);
  --border: rgba(255, 204, 68, 0.25);
}

* { 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);
  background: linear-gradient(180deg, var(--bg-top), var(--bg-bot));
  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: 16px;
  padding: 24px 16px;
  overflow-y: auto;
}
.screen.visible { display: flex; }

.title {
  font-size: 38px;
  font-weight: 800;
  letter-spacing: 1px;
  color: var(--gold);
  text-shadow: 0 4px 24px rgba(255, 204, 68, 0.4);
  margin: 8px 0;
}

h2 { font-size: 28px; color: var(--gold); margin-top: 20px; }

.stats-row {
  display: flex;
  gap: 8px;
  width: 100%;
  max-width: 400px;
}
.stat-pill {
  flex: 1;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 6px;
  text-align: center;
}
.stat-label {
  display: block;
  font-size: 10px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.stat-value {
  display: block;
  font-size: 20px;
  font-weight: 800;
  color: var(--gold);
}

.wheel-container {
  position: relative;
  width: 100%;
  max-width: 380px;
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.wheel-pointer {
  position: absolute;
  top: -10px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 2;
  width: 36px;
  height: 50px;
  pointer-events: none;
  font-size: 0;
  background:
    linear-gradient(180deg, #fff2c2 0%, #ffd766 30%, #b8862a 70%, #5a4012 100%);
  clip-path: polygon(50% 100%, 0% 0%, 100% 0%);
  filter:
    drop-shadow(0 0 12px rgba(255, 204, 68, 0.9))
    drop-shadow(0 2px 4px rgba(0, 0, 0, 0.8));
}
.wheel-pointer::before {
  content: '';
  position: absolute;
  top: 6px; left: 50%;
  transform: translateX(-50%);
  width: 22px; height: 22px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #fff8e0, #ffcc44 60%, #8a6520);
  box-shadow: 0 0 6px rgba(255, 204, 68, 0.6);
}

#wheel-canvas {
  width: 100%;
  height: 100%;
}

.btn {
  width: 100%;
  max-width: 360px;
  padding: 14px 20px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.1s ease, background 0.2s ease;
}
.btn:active { transform: scale(0.98); }
.btn.primary {
  background: linear-gradient(135deg, var(--gold), #ff8d3a);
  border-color: var(--gold);
  color: #2a1500;
  font-weight: 800;
  box-shadow: 0 4px 20px rgba(255, 204, 68, 0.4);
}
.btn.big {
  font-size: 22px;
  padding: 18px 20px;
  letter-spacing: 2px;
  animation: spinBtnPulse 1.6s ease-in-out infinite;
}

@keyframes spinBtnPulse {
  0%, 100% {
    box-shadow:
      0 4px 20px rgba(255, 204, 68, 0.4),
      0 0 0 0 rgba(255, 204, 68, 0.7);
  }
  50% {
    box-shadow:
      0 4px 30px rgba(255, 204, 68, 0.8),
      0 0 0 12px rgba(255, 204, 68, 0);
  }
}

.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.big:disabled { animation: none; }

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

#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);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 14px;
  margin-bottom: 8px;
}
#codes-list li .label { font-size: 13px; color: var(--muted); }
#codes-list li .code {
  font-family: ui-monospace, monospace;
  font-size: 16px;
  font-weight: 700;
  color: var(--gold);
}

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