/* ─── Reset & Base ─────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --primary: #FF6B35;
  --primary-dark: #e85a22;
  --gold: #FFD700;
  --gold-dark: #FFA500;
  --bg: #FFF5EE;
  --card: #FFFFFF;
  --text: #2D2D2D;
  --text-muted: #888;
  --radius: 16px;
  --shadow: 0 4px 20px rgba(0,0,0,0.12);
}

html, body {
  height: 100%;
  font-family: -apple-system, 'PingFang SC', 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

/* ─── Screens ──────────────────────────────────────────────────── */
.screen {
  display: none;
  min-height: 100vh;
  padding: 20px 16px 40px;
  animation: fadeIn 0.3s ease;
}
.screen.active { display: block; }

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

/* ─── Header ───────────────────────────────────────────────────── */
.page-header {
  text-align: center;
  padding: 24px 0 20px;
}
.page-header .badge {
  display: inline-block;
  background: var(--primary);
  color: #fff;
  font-size: 12px;
  padding: 4px 12px;
  border-radius: 20px;
  margin-bottom: 10px;
  letter-spacing: 1px;
}
.page-header h1 {
  font-size: 26px;
  font-weight: 700;
  line-height: 1.3;
}
.page-header p {
  margin-top: 8px;
  color: var(--text-muted);
  font-size: 14px;
}

/* ─── Buttons ──────────────────────────────────────────────────── */
.btn {
  display: block;
  width: 100%;
  padding: 16px;
  border: none;
  border-radius: 50px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  letter-spacing: 0.5px;
}
.btn:active { transform: scale(0.97); }
.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff;
  box-shadow: 0 4px 15px rgba(255,107,53,0.4);
}
.btn-primary:disabled,
.btn-primary.btn-locked {
  opacity: 0.5;
  box-shadow: none;
  cursor: not-allowed;
}
.btn-gold {
  background: linear-gradient(135deg, var(--gold), var(--gold-dark));
  color: #7B4000;
  box-shadow: 0 4px 15px rgba(255,165,0,0.4);
}
.btn-outline {
  background: transparent;
  border: 2px solid var(--primary);
  color: var(--primary);
}
.btn-outline:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ─── Upload Screen ─────────────────────────────────────────────── */
.upload-progress {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-bottom: 18px;
}

.upload-dot {
  width: 34px;
  height: 34px;
  border: 1px solid #ead7cc;
  border-radius: 50%;
  background: #fff;
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
}

.upload-dot.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  box-shadow: 0 4px 12px rgba(255,107,53,0.28);
}

.upload-dot.uploaded:not(.active) {
  border-color: var(--primary);
  color: var(--primary);
}

.upload-steps {
  max-width: 420px;
  margin: 0 auto;
}

.upload-step {
  display: none;
  animation: fadeIn 0.22s ease;
}

.upload-step.active {
  display: block;
}

.upload-step-copy {
  text-align: center;
  margin-bottom: 14px;
}

.upload-step-kicker {
  color: var(--primary);
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 6px;
}

.upload-step-copy h2 {
  font-size: 20px;
  line-height: 1.35;
  margin-bottom: 6px;
}

.upload-step-copy p {
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.5;
}

.upload-slot {
  aspect-ratio: 1;
  width: min(100%, 360px);
  margin: 0 auto 16px;
  background: var(--card);
  border-radius: var(--radius);
  border: 2px dashed #ddd;
  position: relative;
  overflow: hidden;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.2s;
}

.upload-slot:active { opacity: 0.8; }

.upload-slot.uploaded {
  border-color: var(--primary);
  border-style: solid;
}

.upload-input { display: none; }

.upload-preview {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: none;
}

.upload-slot.uploaded .upload-preview    { display: block; }
.upload-slot.uploaded .upload-placeholder { display: none; }

.upload-change {
  display: none;
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(0,0,0,0.45);
  color: #fff;
  font-size: 12px;
  text-align: center;
  padding: 5px 0;
  pointer-events: none;
}
.upload-slot.uploaded .upload-change { display: block; }

.upload-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  pointer-events: none;
}

.upload-plus {
  font-size: 38px;
  line-height: 1;
  font-weight: 300;
  color: #ccc;
}

.upload-label {
  font-size: 13px;
  color: #bbb;
}

.upload-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  max-width: 420px;
  margin: 0 auto 14px;
}

.upload-tip {
  text-align: center;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 20px;
}

#btn-generate {
  max-width: 420px;
  margin: 0 auto;
}

/* ─── Report Screen ─────────────────────────────────────────────── */
.report-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}

.report-img-wrap {
  position: relative;
  width: 100%;
  max-width: 360px;
}

#report-img {
  width: 100%;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: block;
  -webkit-touch-callout: default;
}

.report-save-hint {
  width: 100%;
  max-width: 360px;
  padding: 10px 0;
  background: rgba(0,0,0,0.55);
  color: #fff;
  font-size: 15px;
  text-align: center;
  border-radius: var(--radius);
  transition: background 0.3s;
}

.report-save-hint.saved {
  background: rgba(34,197,94,0.75);
}

/* ─── Share Screen ──────────────────────────────────────────────── */
.share-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 28px 20px;
  box-shadow: var(--shadow);
  text-align: center;
}
.share-icon { font-size: 56px; margin-bottom: 16px; }
.share-card h2 { font-size: 20px; font-weight: 700; margin-bottom: 10px; }
.share-card p { color: var(--text-muted); font-size: 14px; line-height: 1.6; }

.share-steps {
  background: var(--card);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  margin-top: 16px;
}
.share-steps h3 { font-size: 15px; font-weight: 600; margin-bottom: 14px; }
.step-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 12px;
}
.step-item:last-child { margin-bottom: 0; }
.step-num {
  width: 24px;
  height: 24px;
  background: var(--primary);
  color: #fff;
  border-radius: 50%;
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 1px;
}
.step-text { font-size: 14px; line-height: 1.5; }

/* ─── Scratch Card Screen ───────────────────────────────────────── */
.scratch-header {
  text-align: center;
  margin-bottom: 24px;
}
.scratch-header h2 { font-size: 22px; font-weight: 700; }
.scratch-header p { color: var(--text-muted); font-size: 14px; margin-top: 6px; }

.scratch-container {
  display: flex;
  justify-content: center;
  margin-bottom: 20px;
}

#scratch-canvas {
  display: block;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  cursor: crosshair;
  touch-action: none;
}

.scratch-hint {
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
  margin-bottom: 24px;
}

/* 已参与提示 */
.already-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 32px 20px;
  box-shadow: var(--shadow);
  text-align: center;
}
.already-card .icon { font-size: 48px; margin-bottom: 12px; }
.already-card h2 { font-size: 18px; font-weight: 700; margin-bottom: 8px; }
.already-card p { color: var(--text-muted); font-size: 14px; }
.already-prize {
  margin: 16px 0;
  padding: 12px;
  background: #FFF5EE;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 600;
  color: var(--primary);
}

/* ─── Loading Overlay ───────────────────────────────────────────── */
#loading-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 999;
  justify-content: center;
  align-items: center;
  flex-direction: column;
  gap: 16px;
  color: #fff;
}
#loading-overlay.show { display: flex; }
.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Toast ─────────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: rgba(0,0,0,0.75);
  color: #fff;
  padding: 10px 20px;
  border-radius: 24px;
  font-size: 14px;
  opacity: 0;
  transition: all 0.3s;
  z-index: 1000;
  white-space: nowrap;
  pointer-events: none;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ─── Shipping Screen ───────────────────────────────────────────── */
.shipping-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 20px;
}

.shipping-prize-label {
  font-size: 15px;
  font-weight: 600;
  color: var(--primary);
  margin-bottom: 16px;
  text-align: center;
}

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: #555;
  margin-bottom: 6px;
}

.form-group input,
.form-group textarea {
  width: 100%;
  border: 2px solid #eee;
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 15px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s;
  resize: none;
}

.form-group input:focus,
.form-group textarea:focus {
  border-color: var(--primary);
}

.shipping-success {
  text-align: center;
  padding: 40px 20px;
}

.shipping-success-icon {
  font-size: 56px;
  margin-bottom: 12px;
}

.shipping-success h2 {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 8px;
}

.shipping-success p {
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1.6;
}

/* ─── Intro Overlay ─────────────────────────────────────────────── */
#intro-overlay {
  position: fixed;
  inset: 0;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  /* 进入：0→1（0.4s），停留，离开：1→0（0.5s，从1.2s开始） */
  animation: introFadeOut 0.5s ease 1.2s forwards;
}

.intro-content {
  text-align: center;
  color: #fff;
  animation: introScale 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.intro-emoji  { font-size: 64px; margin-bottom: 16px; }
.intro-title  { font-size: 26px; font-weight: 700; margin-bottom: 8px; letter-spacing: 1px; }
.intro-sub    { font-size: 14px; opacity: 0.8; letter-spacing: 0.5px; }

@keyframes introScale {
  from { opacity: 0; transform: scale(0.75); }
  to   { opacity: 1; transform: scale(1); }
}

@keyframes introFadeOut {
  to { opacity: 0; pointer-events: none; }
}

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