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

:root {
  /* App UI colors */
  --primary: #E8475F;
  --primary-dark: #C73652;
  --secondary: #FF8C42;
  --accent: #F9C846;
  --bg: #FFF5EE;
  --card: #fff;
  --text: #2D2D2D;
  --muted: #999;
  --green: #27AE60;
  --green-light: #2ECC71;
  --info: #2980B9;
  --info-dark: #1A6090;
  --border: #ece8e4;
  --border-light: #f5f0ec;
  --border-code: #f0ebe7;
  --radius: 18px;
  --shadow: 0 4px 20px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 40px rgba(0,0,0,0.12);

  /* Brand colors (Pantone) */
  --brand-deep-green:   #00703C;
  --brand-navy:         #1A3A6B;
  --brand-emerald:      #00A878;
  --brand-sky-blue:     #5BBCD6;
  --brand-bright-green: #4DB848;
  --brand-teal:         #00AACC;
  --brand-yellow:       #F2E60A;
  --brand-orange:       #F7A11A;
  --brand-red:          #E8473F;
  --brand-gold:         #C6963A;
}

body {
  font-family: -apple-system, "Microsoft JhengHei", "PingFang TC", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  justify-content: center;
}

#app {
  width: 100%;
  max-width: 430px;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
}

/* ── Header ── */
header {
  background: linear-gradient(150deg, #E8475F 0%, #FF8C42 100%);
  color: #fff;
  text-align: center;
  padding: 32px 20px 52px;
  position: relative;
  overflow: hidden;
}

/* Decorative orb */
header::before {
  content: '';
  position: absolute;
  width: 220px; height: 220px;
  border-radius: 50%;
  background: rgba(255,255,255,0.07);
  top: -70px; left: -40px;
  pointer-events: none;
}

/* Wave cut at bottom */
header::after {
  content: '';
  position: absolute;
  bottom: -1px; left: 0; right: 0;
  height: 32px;
  background: var(--bg);
  clip-path: ellipse(55% 100% at 50% 100%);
}

.park-name {
  display: inline-block;
  background: rgba(255,255,255,0.18);
  border: 1px solid rgba(255,255,255,0.3);
  border-radius: 20px;
  padding: 4px 14px;
  font-size: 11px;
  letter-spacing: 2px;
  margin-bottom: 10px;
  position: relative;
}

header h1 {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: 2px;
  text-shadow: 0 2px 10px rgba(0,0,0,0.15);
  position: relative;
}

.header-sub {
  font-size: 12px;
  opacity: 0.72;
  margin-top: 6px;
  letter-spacing: 1px;
  position: relative;
}

/* ── Main ── */
main {
  flex: 1;
  padding: 20px 20px 32px;
}

/* ── Screens ── */
.screen { display: none; flex-direction: column; align-items: center; gap: 16px; }

.screen.active {
  display: flex;
  animation: fadeUp 0.3s ease;
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

.desc {
  font-size: 14px;
  color: var(--muted);
  text-align: center;
  line-height: 1.7;
}

/* ── Input ── */
.input-group { width: 100%; }

input[type="tel"],
input[type="password"] {
  width: 100%;
  height: 54px;
  border: 2px solid #ece8e4;
  border-radius: 14px;
  font-size: 20px;
  text-align: center;
  letter-spacing: 3px;
  outline: none;
  background: #fff;
  transition: border-color 0.2s, box-shadow 0.2s;
  font-family: inherit;
  -webkit-appearance: none;
}

input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(232,71,95,0.12);
}

/* ── Buttons ── */
.btn {
  width: 100%;
  height: 54px;
  border: none;
  border-radius: 14px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s, box-shadow 0.15s;
  font-family: inherit;
  -webkit-tap-highlight-color: transparent;
  letter-spacing: 0.5px;
}

.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none; box-shadow: none !important; }

.btn-primary {
  background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
  color: #fff;
  box-shadow: 0 4px 16px rgba(232,71,95,0.35);
}

.btn-primary:not(:disabled):hover {
  box-shadow: 0 6px 22px rgba(232,71,95,0.45);
  opacity: 0.93;
}

.btn-secondary {
  background: #fff;
  color: var(--muted);
  border: 2px solid #ece8e4;
  height: 46px;
  font-size: 14px;
  font-weight: 600;
  box-shadow: var(--shadow);
}

.btn-redeem {
  background: linear-gradient(135deg, #2980B9, #1A6090);
  color: #fff;
  box-shadow: 0 4px 14px rgba(41,128,185,0.3);
}

.btn-reset {
  background: transparent;
  color: #ccc;
  border: 1px dashed #e0dbd7;
  font-size: 13px;
  height: 40px;
  box-shadow: none;
}

.hidden { display: none !important; }

/* ── Stats Grid ── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  width: 100%;
}

.stat-box {
  background: var(--card);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 16px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.stat-num {
  font-size: 30px;
  font-weight: 800;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.stat-label {
  font-size: 11px;
  color: var(--muted);
  text-align: center;
}

/* ── Prize Table ── */
.prize-stats {
  width: 100%;
  background: var(--card);
  border-radius: 14px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

#prize-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

#prize-table th {
  background: #fafafa;
  padding: 10px 12px;
  text-align: center;
  color: var(--muted);
  font-weight: 600;
  font-size: 12px;
}

#prize-table th:first-child { text-align: left; }

#prize-table td {
  padding: 10px 12px;
  border-top: 1px solid #f5f0ec;
  text-align: center;
}

#prize-table td:first-child { text-align: left; }
#prize-table tr:last-child td { border-bottom: none; }

/* ── QR Wrap ── */
.qr-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  width: 100%;
}

.qr-link-wrap {
  display: block;
  border-radius: 16px;
  transition: transform 0.15s, box-shadow 0.15s;
}
.qr-link-wrap:active { transform: scale(0.97); }
.qr-link-wrap img {
  width: 240px;
  height: 240px;
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  border: 4px solid #fff;
  background: #f0f0f0;
  display: block;
}

/* ── Wheel ── */
.wheel-wrap {
  position: relative;
  width: 100%;
  display: flex;
  justify-content: center;
  padding-top: 20px;
}

/* Glow behind wheel */
.wheel-wrap::before {
  content: '';
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  width: 340px; height: 340px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(232,71,95,0.12) 0%, transparent 68%);
  pointer-events: none;
}

.pointer-wrap {
  position: absolute;
  top: 4px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  filter: drop-shadow(0 3px 6px rgba(0,0,0,0.25));
}

.pointer {
  width: 0; height: 0;
  border-left: 12px solid transparent;
  border-right: 12px solid transparent;
  border-top: 30px solid var(--primary);
}

#wheel-canvas {
  width: 100%;
  max-width: 320px;
  height: auto;
  border-radius: 50%;
  box-shadow:
    0 6px 28px rgba(0,0,0,0.16),
    0 0 0 5px #fff,
    0 0 0 9px rgba(249,200,70,0.55),
    0 0 0 13px rgba(249,200,70,0.15);
  display: block;
}

/* ── Card ── */
.card {
  width: 100%;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 36px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--primary), var(--secondary));
}

/* ── Result ── */
.congrats {
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 2px;
}

.prize-name {
  font-size: 28px;
  font-weight: 800;
  line-height: 1.2;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.card-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.6;
}

.prize-sub {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-top: -8px;
  background: #f5f0ec;
  border-radius: 8px;
  padding: 6px 14px;
}

.result-qr-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin: 8px 0 4px;
}
.result-qr-wrap img {
  width: 150px;
  height: 150px;
  border-radius: 10px;
  border: 3px solid #fff;
  box-shadow: var(--shadow);
}
.qr-save-hint {
  font-size: 12px;
  color: var(--primary);
  font-weight: 600;
  text-align: center;
  line-height: 1.5;
}
.redeem-hint-box {
  background: #fff8e1;
  border: 1px solid #ffe082;
  border-radius: 10px;
  padding: 10px 16px;
  font-size: 13px;
  color: #7a6000;
  text-align: center;
  line-height: 1.6;
  width: 100%;
}
.prize-list {
  width: 100%;
  background: var(--card);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 16px 18px;
}
.prize-list-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: 1px;
  margin-bottom: 12px;
  text-align: center;
}
.prize-list ul {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.prize-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
}
.prize-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.prize-list-name {
  flex: 1;
  font-weight: 600;
  color: var(--text);
}
.prize-list-location {
  font-size: 12px;
  color: var(--muted);
}

.wheel-guide {
  font-size: 14px;
  color: var(--muted);
  text-align: center;
  line-height: 1.6;
}
.steps {
  list-style: none;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 0;
  counter-reset: step;
}
.steps li {
  counter-increment: step;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  font-size: 14px;
  color: var(--text);
  line-height: 1.5;
  text-align: left;
}
.steps li::before {
  content: counter(step);
  min-width: 24px;
  height: 24px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
}

.code-box {
  display: flex;
  align-items: center;
  gap: 6px;
  justify-content: center;
}

.code-label {
  font-size: 11px;
  color: var(--muted);
}

.code-value {
  font-size: 12px;
  color: var(--muted);
  font-family: "Courier New", monospace;
}

.hint {
  font-size: 13px;
  color: var(--muted);
  text-align: center;
  line-height: 1.6;
}

.notice-label {
  font-size: 13px;
  color: var(--secondary);
  font-weight: 700;
}

/* ── Success ── */
.success-card { border: 2px solid rgba(39,174,96,0.18); }
.success-card::before { background: linear-gradient(90deg, #27AE60, #2ECC71); }

.success-icon {
  width: 64px; height: 64px;
  background: linear-gradient(135deg, #27AE60, #2ECC71);
  color: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 30px;
  font-weight: 700;
  box-shadow: 0 4px 16px rgba(39,174,96,0.3);
}

.success-card h2 { color: var(--green); font-size: 22px; font-weight: 800; }

/* ── Modal ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
  backdrop-filter: blur(4px);
}

.modal-overlay.hidden { display: none; }

.modal {
  background: #fff;
  border-radius: var(--radius);
  padding: 32px 24px;
  width: 100%;
  max-width: 320px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  text-align: center;
  box-shadow: var(--shadow-lg);
}

.modal h3 { font-size: 17px; font-weight: 700; }
.modal-btns { display: flex; gap: 12px; }
.modal-btns .btn { flex: 1; width: auto; }

.error { color: var(--primary); font-size: 13px; }
.error.hidden { display: none; }

/* ── Confetti ── */
#confetti-container {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  pointer-events: none;
  z-index: 200;
  overflow: hidden;
}

.confetti-piece {
  position: absolute;
  top: -14px;
  border-radius: 2px;
  animation: confetti-fall linear forwards;
}

@keyframes confetti-fall {
  0%   { transform: translateY(0) rotate(0deg); opacity: 1; }
  85%  { opacity: 1; }
  100% { transform: translateY(108vh) rotate(720deg); opacity: 0; }
}

