/* ============================================
   Quiz Factory — Design System (Competitor-matched)
   ============================================ */

:root {
  --bg-primary: #0D1117;
  --bg-secondary: #161B22;
  --bg-card: rgba(255, 255, 255, 0.05);
  --text-primary: #E8E0D0;
  --text-secondary: #9E9484;
  --text-tertiary: #6E6458;
  --accent: #C8A84A;
  --accent-light: rgba(200, 168, 74, 0.15);
  --accent-dark: #A88A30;
  --accent-glow: #FFD700;
  --highlight: #5AABA8;
  --border: rgba(200, 168, 74, 0.15);
  --shadow: rgba(0, 0, 0, 0.3);
  --font-title: 'Noto Serif SC', serif;
  --font-body: 'Noto Serif SC', serif;
  --radius: 12px;
  --radius-sm: 8px;
}

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font-body);
  color: var(--text-primary);
  background: var(--bg-primary);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* --- Screen System --- */
.screen {
  display: none;
  min-height: 100dvh;
  padding: 44px 28px 100px;
  animation: fadeIn 0.32s ease both;
}
.screen.active {
  display: flex;
  flex-direction: column;
  align-items: center;
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: translateY(0); }
}

/* --- Decorative Divider --- */
.divider {
  width: 100%;
  max-width: 480px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  margin: 28px 0;
  position: relative;
}
.divider::after {
  content: '✦';
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  background: var(--bg-primary);
  padding: 0 12px;
  color: var(--accent-glow);
  font-size: 14px;
  text-shadow: 0 0 8px rgba(255, 215, 0, 0.4);
}

/* --- Cover (S0) --- */
.cover {
  width: 100%;
  max-width: 420px;
  margin: 0 auto;
  padding-top: 10px;
  position: relative;
}
.cover-glow {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -55%);
  width: 300px;
  height: 300px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 215, 0, 0.18) 0%, rgba(200, 168, 74, 0.08) 40%, transparent 70%);
  filter: blur(40px);
  animation: coverPulse 4s ease-in-out infinite;
  pointer-events: none;
}
@keyframes coverPulse {
  0%, 100% { transform: translate(-50%, -55%) scale(1); opacity: 0.7; }
  50% { transform: translate(-50%, -55%) scale(1.2); opacity: 1; }
}
.cover-svg {
  width: 100%;
  height: auto;
  display: block;
  position: relative;
  z-index: 1;
}

/* --- Hero (S0) --- */
.hero {
  text-align: center;
  padding: 20px 0 34px;
  max-width: 480px;
}
.hero-badge {
  display: inline-block;
  font-size: 9px;
  letter-spacing: 5px;
  color: var(--accent);
  border: 1px solid var(--border);
  padding: 6px 18px;
  border-radius: 20px;
  margin-bottom: 22px;
}
.hero-title {
  font-family: var(--font-title);
  font-size: clamp(28px, 6vw, 48px);
  font-weight: 700;
  line-height: 1.35;
  letter-spacing: 2px;
  color: var(--text-primary);
  margin-bottom: 16px;
}
.hero-subtitle {
  font-size: 15px;
  color: var(--text-secondary);
  line-height: 2.1;
  margin-bottom: 22px;
}
.hero-stats {
  display: flex;
  justify-content: center;
  gap: 40px;
  font-size: 11px;
  color: var(--text-tertiary);
  letter-spacing: 1px;
}
.hero-stats .stat-num {
  font-size: 28px;
  font-weight: 700;
  color: var(--accent);
  display: block;
  margin-bottom: 2px;
}
.hero-note {
  font-size: 12px;
  color: var(--text-tertiary);
  margin-top: 22px;
  letter-spacing: 1px;
}

/* --- Archetype Grid (12 items: 4x3) --- */
.archetype-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 9px;
  max-width: 480px;
  width: 100%;
  margin: 22px 0;
}
.archetype-card {
  background: var(--bg-card);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 6px;
  text-align: center;
  transition: transform 0.14s;
}
.archetype-card:active { transform: scale(0.96); }
.archetype-card .icon { font-size: 20px; margin-bottom: 4px; }
.archetype-card .name {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: 0.5px;
}
.archetype-card .desc {
  font-size: 9px;
  color: var(--text-tertiary);
  margin-top: 2px;
  line-height: 1.4;
}

/* --- Buttons --- */
.btn-primary {
  display: block;
  width: 100%;
  max-width: 320px;
  padding: 15px 0;
  background: var(--accent);
  color: var(--bg-primary);
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 3px;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.2s;
  margin-top: 22px;
}
.btn-primary:active {
  transform: scale(0.98);
  opacity: 0.85;
}
.btn-secondary {
  padding: 11px 28px;
  background: transparent;
  color: var(--accent);
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 2px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.14s;
}
.btn-secondary:active { background: var(--accent-light); }
.btn-secondary:disabled { opacity: 0.35; cursor: not-allowed; }

/* --- Quiz (S1) --- */
.quiz-header {
  width: 100%;
  max-width: 480px;
  margin-bottom: 22px;
}
.progress-bar {
  height: 2px;
  background: rgba(140, 111, 42, 0.1);
  border-radius: 1px;
  overflow: visible;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-glow));
  border-radius: 1px;
  transition: width 0.55s cubic-bezier(0.4, 0, 0.2, 1);
  width: 0%;
  box-shadow: 0 0 8px rgba(170, 136, 48, 0.35);
}
.progress-text {
  display: block;
  text-align: right;
  font-size: 9px;
  color: var(--text-tertiary);
  margin-top: 8px;
  letter-spacing: 3px;
}
.question-card {
  background: var(--bg-card);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 40px 28px;
  width: 100%;
  max-width: 480px;
  min-height: 320px;
  position: relative;
  box-shadow: 0 2px 28px var(--shadow);
}
/* Top accent line */
.question-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 20%;
  right: 20%;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
}
.question-category {
  font-size: 9px;
  letter-spacing: 4px;
  color: var(--accent);
  text-align: center;
  margin-bottom: 16px;
  padding: 4px 14px;
  border: 1px solid var(--border);
  border-radius: 20px;
  display: inline-block;
}
.question-number {
  font-size: 28px;
  font-weight: 700;
  color: var(--accent);
  opacity: 0.3;
  letter-spacing: 2px;
  margin-bottom: 16px;
}
.question-text {
  font-size: 17px;
  font-weight: 600;
  line-height: 1.95;
  margin-bottom: 34px;
  color: var(--text-primary);
}
.options {
  display: flex;
  flex-direction: column;
  gap: 9px;
}
.option-btn {
  width: 100%;
  padding: 14px 18px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 14px;
  color: var(--text-primary);
  text-align: left;
  cursor: pointer;
  transition: all 0.14s;
  line-height: 1.75;
}
.option-btn:active { transform: translateX(4px); }
.option-btn.selected {
  background: var(--accent-light);
  border-color: var(--accent);
  color: var(--accent-dark);
  font-weight: 600;
}
.quiz-nav {
  display: flex;
  gap: 12px;
  margin-top: 22px;
  width: 100%;
  max-width: 480px;
  justify-content: space-between;
}

/* --- Loading (S2) --- */
.loading-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
  text-align: center;
}
.loading-spinner {
  width: 44px;
  height: 44px;
  border: 2px solid rgba(200, 168, 74, 0.2);
  border-top-color: var(--accent-glow);
  border-radius: 50%;
  animation: spin 1.1s linear infinite;
  margin-bottom: 34px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-text {
  font-size: 17px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 8px;
  letter-spacing: 1px;
}
.loading-sub {
  font-size: 13px;
  color: var(--text-tertiary);
  animation: pulse 2.2s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* --- Result (S3) --- */
.result-container {
  width: 100%;
  max-width: 480px;
}
.result-header {
  text-align: center;
  padding: 44px 0 28px;
}
.result-badge {
  display: inline-block;
  font-size: 9px;
  letter-spacing: 5px;
  color: var(--accent);
  border: 1px solid var(--border);
  padding: 5px 16px;
  border-radius: 20px;
  margin-bottom: 16px;
}
.result-type {
  font-family: var(--font-title);
  font-size: clamp(32px, 8vw, 52px);
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 10px;
  letter-spacing: 4px;
}
.result-tagline {
  font-size: 15px;
  color: var(--text-secondary);
  font-style: italic;
  line-height: 2.0;
}
.result-trait-name {
  font-size: 20px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 6px;
  margin-bottom: 12px;
}
.result-pain {
  font-size: 12px;
  color: var(--highlight);
  margin-top: 10px;
  padding: 5px 14px;
  background: rgba(58, 122, 123, 0.08);
  border: 1px solid rgba(58, 122, 123, 0.15);
  border-radius: 20px;
  display: inline-block;
  letter-spacing: 1px;
}
.result-tags {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-top: 16px;
}
.result-tag {
  font-size: 11px;
  color: var(--accent);
  padding: 4px 12px;
  border: 1px solid var(--border);
  border-radius: 20px;
  letter-spacing: 0.5px;
}
.result-quote {
  text-align: center;
  font-size: 15px;
  font-style: italic;
  color: var(--text-secondary);
  line-height: 2.0;
  padding: 22px 28px;
  margin: 0 auto 8px;
  max-width: 420px;
  position: relative;
}
.result-quote::before {
  content: '"';
  font-size: 48px;
  color: var(--accent-glow);
  opacity: 0.3;
  position: absolute;
  top: -4px;
  left: 8px;
  font-family: Georgia, serif;
}
.result-quote::after {
  content: '"';
  font-size: 48px;
  color: var(--accent-glow);
  opacity: 0.3;
  position: absolute;
  bottom: -20px;
  right: 8px;
  font-family: Georgia, serif;
}

/* Radar */
.result-radar {
  display: flex;
  justify-content: center;
  margin: 28px 0;
}
.result-radar canvas { width: 280px; height: 280px; }

/* Scores */
.result-scores {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 28px;
}
.score-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-secondary);
}
.score-bar {
  flex: 1;
  height: 4px;
  background: rgba(140, 111, 42, 0.1);
  border-radius: 2px;
  overflow: hidden;
}
.score-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-glow));
  border-radius: 2px;
  transition: width 1.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Analysis */
.result-analysis {
  background: var(--bg-card);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 34px 28px;
  margin-bottom: 28px;
  font-size: 15px;
  line-height: 2.1;
  color: var(--text-primary);
  box-shadow: 0 2px 28px var(--shadow);
  position: relative;
}
.result-analysis::before {
  content: '';
  position: absolute;
  top: 0;
  left: 20%;
  right: 20%;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
}
.result-analysis h3 {
  font-size: 15px;
  font-weight: 700;
  color: var(--accent);
  margin: 28px 0 10px;
  letter-spacing: 2px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.result-analysis h3::before {
  content: '✦';
  font-size: 10px;
}
.result-analysis h3:first-child { margin-top: 0; }
.result-analysis p {
  margin-bottom: 14px;
  color: var(--text-primary);
}

/* CTA */
.result-cta {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  margin-bottom: 34px;
}
.result-cta .btn-primary { margin-top: 0; }

/* WeChat Guide */
.wechat-guide {
  text-align: center;
  padding: 28px 0;
  position: relative;
}
.wechat-guide::before {
  content: '';
  position: absolute;
  top: 0;
  left: 10%;
  right: 10%;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--border), transparent);
}
.wechat-guide p {
  font-size: 13px;
  color: var(--text-tertiary);
  margin-bottom: 12px;
  letter-spacing: 1px;
}
.qrcode-placeholder {
  width: 120px;
  height: 120px;
  background: var(--bg-secondary);
  border-radius: var(--radius-sm);
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  color: var(--text-tertiary);
}

/* --- Share Preview (S4) --- */
.share-preview {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  max-width: 480px;
}
.share-preview canvas {
  width: 100%;
  max-width: 360px;
  border-radius: var(--radius);
  box-shadow: 0 8px 32px var(--shadow);
  margin-bottom: 22px;
}
.share-tip {
  font-size: 12px;
  color: var(--text-tertiary);
  margin-bottom: 16px;
  letter-spacing: 1px;
}
.share-sizes {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}
.size-btn {
  padding: 6px 14px;
  font-size: 10px;
  font-family: var(--font-body);
  letter-spacing: 1px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: transparent;
  color: var(--text-tertiary);
  cursor: pointer;
  transition: all 0.14s;
}
.size-btn.active {
  background: var(--accent);
  color: var(--bg-primary);
  border-color: var(--accent);
}

/* --- Toast --- */
.toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: rgba(200, 168, 74, 0.9);
  color: #0D1117;
  padding: 10px 24px;
  border-radius: 20px;
  font-size: 13px;
  letter-spacing: 1px;
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s;
  z-index: 100;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* --- Responsive --- */
@media (max-width: 580px) {
  .screen { padding: 28px 16px 80px; }
  .archetype-grid { grid-template-columns: repeat(3, 1fr); }
  .question-card { padding: 28px 18px; }
  .result-analysis { padding: 22px 18px; }
  .hero-title { font-size: clamp(24px, 7vw, 36px); }
}
@media (max-width: 360px) {
  .archetype-grid { grid-template-columns: repeat(2, 1fr); }
}
