:root {
  --bg: #0a0a12;
  --bg-card: rgba(255, 255, 255, 0.06);
  --bg-option: rgba(255, 255, 255, 0.04);
  --bg-option-hover: rgba(255, 255, 255, 0.10);
  --bg-option-selected: rgba(139, 92, 246, 0.18);
  --text: #f0eef5;
  --text-secondary: rgba(240, 238, 245, 0.55);
  --text-dim: rgba(240, 238, 245, 0.35);
  --accent: #8b5cf6;
  --accent-glow: rgba(139, 92, 246, 0.35);
  --accent-2: #a78bfa;
  --accent-warm: #f59e0b;
  --border: rgba(255, 255, 255, 0.08);
  --border-accent: rgba(139, 92, 246, 0.3);
  --radius: 20px;
  --radius-sm: 14px;
  --radius-pill: 999px;
  --transition: 0.2s ease;
}

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

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 60% at 50% -10%, rgba(139, 92, 246, 0.18), transparent),
    radial-gradient(ellipse 60% 50% at 80% 100%, rgba(59, 130, 246, 0.10), transparent),
    radial-gradient(ellipse 40% 40% at 10% 60%, rgba(245, 158, 11, 0.06), transparent);
  pointer-events: none;
  z-index: 0;
}

button, input, textarea, select { font: inherit; }
.hidden { display: none !important; }

/* ── Shell ── */
.shell {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  padding: 0 16px;
  min-height: 100dvh;
}

/* ── Hero ── */
.hero {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  padding: 40px 0;
  gap: 28px;
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  color: var(--accent-2);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.hero-badge::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent-glow);
}

.hero-tagline {
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.04em;
}

.hero-title {
  font-size: clamp(36px, 11vw, 56px);
  font-weight: 800;
  line-height: 1.05;
  letter-spacing: -0.04em;
  background: linear-gradient(135deg, #fff 0%, var(--accent-2) 50%, var(--accent) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero-desc {
  color: var(--text-secondary);
  font-size: 15px;
  line-height: 1.8;
  max-width: 320px;
}

.hero-start {
  width: 100%;
  max-width: 300px;
  padding: 18px 24px;
  border: none;
  border-radius: var(--radius);
  background: linear-gradient(135deg, var(--accent), #6d28d9);
  color: #fff;
  font-size: 17px;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 12px 40px var(--accent-glow);
  transition: transform var(--transition), box-shadow var(--transition);
  position: relative;
  overflow: hidden;
}

.hero-start::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(255,255,255,0.12), transparent);
  pointer-events: none;
}

.hero-start:hover { transform: translateY(-2px); box-shadow: 0 16px 50px var(--accent-glow); }
.hero-start:active { transform: scale(0.97); }
.hero-start:disabled { opacity: 0.5; cursor: wait; transform: none; box-shadow: none; }

.hero-meta {
  display: flex;
  gap: 20px;
  color: var(--text-dim);
  font-size: 13px;
}

.hero-meta strong {
  color: var(--text-secondary);
  font-weight: 700;
}

.hero-footer {
  color: var(--text-dim);
  font-size: 12px;
  line-height: 1.7;
}

.hero-credits {
  color: var(--text-dim);
  font-size: 12px;
  line-height: 1.8;
  text-align: center;
}

.hero-credits a {
  color: var(--accent-2);
  text-decoration: none;
  font-weight: 600;
}

.hero-credits a:hover {
  text-decoration: underline;
}

/* ── Quiz ── */
.quiz-wrap {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: 0 0 40px;
}

.quiz-topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  padding: 16px 0 12px;
  background: rgba(10, 10, 18, 0.85);
  backdrop-filter: blur(16px);
}

.quiz-topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.quiz-progress-bar {
  flex: 1;
  height: 4px;
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.quiz-progress-fill {
  height: 100%;
  width: 0%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width 0.35s ease;
}

.quiz-progress-text {
  color: var(--text-dim);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.quiz-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 24px 0;
  gap: 24px;
}

.quiz-question-number {
  color: var(--accent-2);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.06em;
}

.quiz-question-text {
  font-size: clamp(22px, 6vw, 28px);
  font-weight: 700;
  line-height: 1.5;
  letter-spacing: -0.01em;
}

.quiz-options {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.quiz-option {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  width: 100%;
  padding: 16px 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-option);
  color: var(--text);
  font-size: 15px;
  line-height: 1.65;
  text-align: left;
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition), transform 0.12s ease;
  -webkit-tap-highlight-color: transparent;
}

.quiz-option:hover {
  background: var(--bg-option-hover);
  border-color: rgba(255, 255, 255, 0.14);
}

.quiz-option:active { transform: scale(0.98); }

.quiz-option-key {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  background: rgba(139, 92, 246, 0.12);
  color: var(--accent-2);
  font-size: 14px;
  font-weight: 800;
  transition: background var(--transition), color var(--transition);
}

.quiz-option-text { padding-top: 4px; }

.quiz-option.selected {
  background: var(--bg-option-selected);
  border-color: var(--border-accent);
}

.quiz-option.selected .quiz-option-key {
  background: var(--accent);
  color: #fff;
}

.quiz-hint {
  color: var(--text-dim);
  font-size: 12px;
  text-align: center;
  padding-top: 8px;
}

/* ── Submitting overlay ── */
.submitting-overlay {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
}

.submitting-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.submitting-text {
  color: var(--text-secondary);
  font-size: 15px;
}

/* ── Result ── */
.result-wrap { padding: 32px 0 60px; }

.result-type-card {
  position: relative;
  padding: 36px 24px;
  border-radius: var(--radius);
  background:
    radial-gradient(ellipse 100% 80% at 50% 0%, rgba(139, 92, 246, 0.22), transparent),
    var(--bg-card);
  border: 1px solid var(--border);
  text-align: center;
  overflow: hidden;
}

.result-type-card::before {
  content: "";
  position: absolute;
  top: -1px;
  left: 20%;
  right: 20%;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
}

.result-label {
  color: var(--accent-2);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.result-name {
  font-size: clamp(36px, 11vw, 52px);
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -0.03em;
  margin-top: 12px;
  background: linear-gradient(135deg, #fff, var(--accent-2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.result-tags {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-top: 16px;
  flex-wrap: wrap;
}

.result-tag {
  display: inline-flex;
  align-items: center;
  padding: 6px 14px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  background: var(--bg-card);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
}

.result-tag.accent { border-color: var(--border-accent); color: var(--accent-2); }
.result-tag.rare { border-color: rgba(245, 158, 11, 0.3); color: var(--accent-warm); }

.result-desc {
  margin-top: 20px;
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 1.85;
  text-align: left;
}

/* ── Result sections ── */
.result-section { margin-top: 20px; }

.result-section-title {
  color: var(--text-dim);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-bottom: 12px;
}

.result-pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.result-card {
  padding: 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-card);
}

.result-card-label {
  color: var(--text-dim);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.result-card-value {
  font-size: 20px;
  font-weight: 800;
  margin-top: 6px;
  line-height: 1.25;
}

.result-card-score {
  color: var(--text-dim);
  font-size: 12px;
  margin-top: 4px;
  font-variant-numeric: tabular-nums;
}

.result-card.highlight {
  background: rgba(139, 92, 246, 0.08);
  border-color: var(--border-accent);
}

.result-card.highlight .result-card-value { color: var(--accent-2); }

/* Axis bars */
.axis-list { display: flex; flex-direction: column; gap: 12px; }

.axis-item {
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-card);
}

.axis-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.axis-name { font-size: 13px; font-weight: 700; }
.axis-dominant { color: var(--accent-2); font-size: 12px; font-weight: 700; }

.axis-bar-wrap {
  display: flex;
  gap: 3px;
  height: 6px;
  border-radius: var(--radius-pill);
  overflow: hidden;
}

.axis-bar-left, .axis-bar-right {
  height: 100%;
  border-radius: var(--radius-pill);
  min-width: 4px;
  transition: width 0.6s ease;
}

.axis-bar-left { background: var(--accent); }
.axis-bar-right { background: rgba(255, 255, 255, 0.12); }

.axis-labels {
  display: flex;
  justify-content: space-between;
  margin-top: 6px;
  font-size: 11px;
  color: var(--text-dim);
}

/* Signal chips */
.signal-list { display: flex; flex-wrap: wrap; gap: 8px; }

.signal-chip {
  padding: 8px 14px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  background: var(--bg-card);
  font-size: 13px;
  font-weight: 600;
}

.signal-chip .signal-score {
  color: var(--accent-2);
  margin-left: 6px;
  font-variant-numeric: tabular-nums;
}

/* Ranking */
.ranking-list { display: flex; flex-direction: column; gap: 8px; }

.ranking-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-card);
}

.ranking-rank {
  width: 24px; height: 24px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 8px;
  background: rgba(139, 92, 246, 0.12);
  color: var(--accent-2);
  font-size: 12px; font-weight: 800;
  flex-shrink: 0;
}

.ranking-item:first-child .ranking-rank { background: var(--accent); color: #fff; }
.ranking-name { flex: 1; font-size: 14px; font-weight: 600; }
.ranking-score-val { color: var(--text-dim); font-size: 13px; font-weight: 700; font-variant-numeric: tabular-nums; }

/* ── New Result: Share Card ── */
.result-share-card {
  position: relative;
  padding: 32px 24px;
  border-radius: var(--radius);
  background:
    radial-gradient(ellipse 100% 80% at 50% 0%, rgba(139, 92, 246, 0.22), transparent),
    var(--bg-card);
  border: 1px solid var(--border);
  text-align: center;
  overflow: hidden;
}

.result-share-card::before {
  content: "";
  position: absolute;
  top: -1px;
  left: 20%;
  right: 20%;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
}

.result-image {
  width: 85vw;
  max-width: 640px;
  min-height: 50vh;
  height: auto;
  object-fit: contain;
  margin: 8px auto 16px;
  display: block;
  border-radius: var(--radius);
}

.result-tagline {
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 1.6;
  margin-top: 12px;
}

.result-quote {
  margin: 20px 0;
  padding: 16px 20px;
  border-left: 3px solid var(--accent);
  background: rgba(139, 92, 246, 0.06);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.7;
  color: var(--text);
  text-align: left;
}

.result-bio {
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 1.85;
  text-align: left;
}

.result-neighbors {
  margin-top: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.result-neighbor-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
}

.neighbor-label {
  color: var(--text-dim);
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 0.05em;
  min-width: 56px;
}

.neighbor-value {
  color: var(--accent-2);
  font-weight: 600;
}

.result-rare-tag {
  margin-top: 16px;
  padding: 8px 16px;
  border-radius: var(--radius-pill);
  border: 1px solid rgba(245, 158, 11, 0.3);
  background: rgba(245, 158, 11, 0.08);
  font-size: 13px;
  font-weight: 600;
  color: var(--accent-warm);
  display: inline-block;
}

.result-watermark {
  margin-top: 20px;
  color: var(--text-dim);
  font-size: 11px;
  letter-spacing: 0.1em;
  opacity: 0.5;
}

/* ── Result Actions ── */
.result-actions {
  display: flex;
  gap: 10px;
  margin-top: 20px;
}

.btn-share {
  flex: 1;
  padding: 16px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: opacity var(--transition);
}

.btn-share:hover { opacity: 0.85; }

.btn-restart {
  flex: 1;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  color: var(--text);
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition);
}

.btn-restart:hover { background: var(--bg-option-hover); border-color: rgba(255, 255, 255, 0.14); }

/* ── Runner Up ── */
.result-runner-up {
  margin-top: 16px;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-card);
  font-size: 14px;
  color: var(--text-secondary);
  text-align: center;
}

.result-runner-up strong { color: var(--accent-2); }

/* ── Collapsible Details ── */
.result-details {
  margin-top: 20px;
}

.result-details-toggle {
  width: 100%;
  padding: 12px;
  text-align: center;
  color: var(--text-dim);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-card);
  list-style: none;
}

.result-details-toggle::-webkit-details-marker { display: none; }
.result-details[open] .result-details-toggle { border-color: var(--border-accent); }

/* ── Error ── */
.error-card {
  padding: 24px;
  border-radius: var(--radius);
  border: 1px solid rgba(239, 68, 68, 0.2);
  background: rgba(239, 68, 68, 0.06);
  color: #fca5a5;
  text-align: center;
  font-size: 14px;
  line-height: 1.7;
  margin-top: 40px;
}

/* ── Loading ── */
.loading-card {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
  font-size: 14px;
}

/* ── Fade animation ── */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

.fade-up { animation: fadeUp 0.35s ease forwards; }

/* ── Result v2: Tier Badge ── */
.result-tier-badge {
  display: inline-block;
  padding: 6px 14px;
  border-radius: var(--radius-pill);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  margin-bottom: 12px;
}

.tier-core {
  background: rgba(139, 92, 246, 0.12);
  border: 1px solid rgba(139, 92, 246, 0.3);
  color: var(--accent-2);
}

.tier-hot {
  background: rgba(245, 158, 11, 0.12);
  border: 1px solid rgba(245, 158, 11, 0.3);
  color: var(--accent-warm);
}

.tier-rare {
  background: rgba(236, 72, 153, 0.12);
  border: 1px solid rgba(236, 72, 153, 0.3);
  color: #f472b6;
}

/* ── Result v2: Portrait ── */
.result-portrait {
  margin-top: 16px;
  text-align: left;
}

.result-portrait p {
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 1.85;
  margin-bottom: 12px;
}

.result-portrait p:last-child { margin-bottom: 0; }

.result-portrait .dynamic-insert {
  color: var(--accent-2);
  font-style: italic;
  padding: 12px 16px;
  margin-top: 12px;
  background: rgba(139, 92, 246, 0.06);
  border-left: 3px solid var(--accent);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

/* ── Result v2: Dynamic Inserts ── */
.result-dynamic {
  margin-top: 12px;
  text-align: left;
}

.dynamic-line {
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 1.7;
  font-style: italic;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}

.dynamic-line:last-child { border-bottom: none; }

/* ── Result v2: Rarity ── */
.result-rarity {
  margin-top: 16px;
  color: var(--text-dim);
  font-size: 13px;
  font-weight: 600;
}

.result-rarity.rarity-rare {
  padding: 8px 16px;
  border-radius: var(--radius-pill);
  border: 1px solid rgba(236, 72, 153, 0.3);
  background: rgba(236, 72, 153, 0.08);
  color: #f472b6;
  display: inline-block;
}

/* ── Result v2: Radar Chart ── */
#radar-chart {
  display: block;
  margin: 0 auto;
  max-width: 100%;
  height: auto;
}

/* ── Result v2: Relationships ── */
.result-relationships {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.rel-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-card);
}

.rel-label {
  color: var(--text-dim);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.rel-value {
  color: var(--accent-2);
  font-size: 14px;
  font-weight: 600;
}

/* ── Result v2: Least Like Reason ── */
.result-least-reason {
  margin-top: 8px;
  color: var(--text-dim);
  font-size: 12px;
  line-height: 1.6;
  font-style: italic;
}

/* ── Result v2: Boundary ── */
.result-boundary {
  margin-top: 4px;
  color: var(--text-dim);
  font-size: 12px;
}

/* ── Desktop ── */
@media (min-width: 768px) {
  .shell { max-width: 520px; }
  .hero-title { font-size: 56px; }
}
