/* === RESET & BASE === */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  height: 100%;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Helvetica Neue', sans-serif;
  -webkit-font-smoothing: antialiased;
}

button {
  border: none;
  cursor: pointer;
  font-family: inherit;
  -webkit-tap-highlight-color: transparent;
}

/* === CSS VARIABLES (默认蓝色主题，结果页动态覆盖) === */
:root {
  --theme-primary: #4a90ff;
  --theme-glow: rgba(74, 144, 255, 0.25);
  --theme-btn-start: #4a90ff;
  --theme-btn-end: #7eb8ff;
  --bg-start: #0d1b4b;
  --bg-end: #1a2d6b;
}

/* === PAGE LAYOUT === */
.page {
  position: fixed;
  inset: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* === SAFE AREA (iPhone notch / home bar) === */
.test-card {
  margin-bottom: max(0px, env(safe-area-inset-bottom));
}

.result-content {
  padding-bottom: max(40px, env(safe-area-inset-bottom));
}

/* === WELCOME PAGE === */
#page-welcome {
  /* Fallback gradient shown instantly while bg.png loads */
  background: linear-gradient(160deg, #0c0818 0%, #1a1030 50%, #0a0510 100%);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  /* position: fixed inherited from .page — do NOT override here */
}

/* Background image layer — fades in after JS confirms load */
.welcome-bg {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(to bottom,
      rgba(8, 4, 24, 0.15) 0%,
      rgba(8, 4, 24, 0.35) 40%,
      rgba(8, 4, 24, 0.82) 68%,
      rgba(8, 4, 24, 0.97) 100%),
    url('bg.png') center top / cover no-repeat;
  opacity: 0;
  transition: opacity 1.4s ease;
  z-index: 0;
}
.welcome-bg.loaded {
  opacity: 1;
}

.welcome-content {
  position: relative;
  z-index: 1;
}

.welcome-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 32px 28px max(40px, env(safe-area-inset-bottom));
  width: 100%;
  max-width: 420px;
}

/* Entrance animations — each child staggers in */
.welcome-content>* {
  opacity: 0;
  transform: translateY(20px);
  animation: welcomeIn 0.6s ease-out forwards;
}

.welcome-content>*:nth-child(1) {
  animation-delay: 0.1s;
}

.welcome-content>*:nth-child(2) {
  animation-delay: 0.3s;
}

.welcome-content>*:nth-child(3) {
  animation-delay: 0.5s;
}

.welcome-content>*:nth-child(4) {
  animation-delay: 0.7s;
}

.welcome-content>*:nth-child(5) {
  animation-delay: 0.85s;
}

.welcome-content>*:nth-child(6) {
  animation-delay: 1.0s;
}

@keyframes welcomeIn {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.brand-orb {
  width: 80px;
  height: 80px;
  background: rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 215, 120, 0.35);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 36px;
  box-shadow: 0 0 32px rgba(255, 200, 80, 0.25), 0 0 0 10px rgba(255, 200, 80, 0.07);
  margin-bottom: 24px;
  animation: orbFloat 4s ease-in-out infinite, welcomeIn 0.6s ease-out 0.1s forwards;
}

.welcome-title {
  font-size: 32px;
  font-weight: 900;
  background: linear-gradient(135deg, #ffffff 0%, #ffe9a0 45%, #ffd060 70%, #ffffff 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 14px;
  text-align: center;
  letter-spacing: 1px;
  line-height: 1.25;
  text-shadow: none;
  background-size: 250% auto;
  animation: welcomeIn 0.6s ease-out 0.3s forwards, titleShimmer 4s linear 1.2s infinite;
}

@keyframes titleShimmer {
  0% {
    background-position: 0% center;
  }

  50% {
    background-position: 100% center;
  }

  100% {
    background-position: 0% center;
  }
}

.welcome-sub {
  font-size: 14px;
  color: rgba(255, 235, 190, 0.75);
  margin-bottom: 36px;
  text-align: center;
  line-height: 1.9;
  font-weight: 400;
  letter-spacing: 1.5px;
}

.btn-primary {
  width: 100%;
  padding: 17px;
  background: linear-gradient(90deg, #c8860a, #f0b830, #f5d060, #f0b830, #c8860a);
  background-size: 200% auto;
  color: #1a0e00;
  border-radius: 50px;
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 1px;
  box-shadow: 0 4px 28px rgba(220, 170, 40, 0.55), 0 0 0 1px rgba(255, 220, 100, 0.3);
  transition: transform 0.1s, box-shadow 0.1s;
  animation: welcomeIn 0.6s ease-out 0.7s forwards, btnGlow 3s ease-in-out 1.5s infinite;
}

.btn-primary:active {
  transform: scale(0.97);
  box-shadow: 0 2px 12px rgba(220, 170, 40, 0.4);
}

@keyframes btnGlow {

  0%,
  100% {
    box-shadow: 0 4px 28px rgba(220, 170, 40, 0.55), 0 0 0 1px rgba(255, 220, 100, 0.3);
  }

  50% {
    box-shadow: 0 4px 40px rgba(220, 170, 40, 0.85), 0 0 0 1px rgba(255, 220, 100, 0.6);
  }
}

.social-proof {
  font-size: 12px;
  color: rgba(255, 235, 190, 0.45);
  margin-top: 14px;
  letter-spacing: 0.5px;
}

.rate-note {
  font-size: 11px;
  color: rgba(255, 210, 120, 0.6);
  margin-top: 10px;
  padding: 6px 14px;
  background: rgba(255, 200, 80, 0.08);
  border: 1px solid rgba(255, 200, 80, 0.2);
  border-radius: 20px;
  letter-spacing: 0.3px;
}

/* === TEST PAGE === */
#page-test {
  background:
    linear-gradient(to bottom,
      rgba(8, 4, 24, 0.55) 0%,
      rgba(8, 4, 24, 0.75) 100%),
    url('bg.png') center top / cover no-repeat;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 20px;
}

.test-card {
  width: 100%;
  max-width: 400px;
  background: rgba(255, 255, 255, 0.07);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 215, 120, 0.15);
  border-radius: 24px;
  padding: 28px 22px 24px;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.4);
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* Progress */
.progress-label {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: rgba(255, 235, 190, 0.5);
  margin-bottom: 8px;
  letter-spacing: 0.5px;
}

.progress-track {
  height: 4px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 2px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #c8860a, #f5c842);
  border-radius: 2px;
  width: 0%;
  transition: width 0.4s ease;
  box-shadow: 0 0 8px rgba(245, 200, 66, 0.6);
}

/* Question */
.question-area {
  min-height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.question-text {
  font-size: 17px;
  font-weight: 600;
  color: rgba(255, 245, 220, 0.95);
  line-height: 1.7;
  text-align: center;
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.4);
}

/* Skeleton */
.skeleton-text {
  width: 80%;
  height: 20px;
  background: linear-gradient(90deg,
      rgba(255, 255, 255, 0.06) 25%,
      rgba(255, 255, 255, 0.12) 50%,
      rgba(255, 255, 255, 0.06) 75%);
  background-size: 200% 100%;
  border-radius: 4px;
  animation: shimmer 1.4s infinite;
}

@keyframes shimmer {
  0% {
    background-position: 200% 0;
  }

  100% {
    background-position: -200% 0;
  }
}

/* Error state */
.error-area {
  text-align: center;
  padding: 8px 0;
}

.error-text {
  font-size: 14px;
  color: #ff7a7a;
  margin-bottom: 12px;
}

.rate-countdown {
  font-size: 13px;
  color: rgba(255, 235, 190, 0.5);
  margin-top: 4px;
}

.btn-retry {
  padding: 10px 24px;
  background: transparent;
  border: 1.5px solid rgba(255, 120, 120, 0.6);
  color: #ff9999;
  border-radius: 50px;
  font-size: 13px;
  font-weight: 600;
}

/* Buttons */
.btn-row {
  display: flex;
  gap: 10px;
}

.btn-prev {
  flex: 1;
  padding: 14px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: rgba(255, 235, 190, 0.6);
  border-radius: 50px;
  font-size: 14px;
  font-weight: 600;
}

.btn-next {
  flex: 2;
  padding: 14px;
  background: linear-gradient(90deg, #c8860a, #f0b830, #f5d060, #f0b830, #c8860a);
  background-size: 200% auto;
  color: #1a0e00;
  border-radius: 50px;
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0.5px;
  box-shadow: 0 4px 20px rgba(220, 170, 40, 0.45);
  transition: opacity 0.2s;
}

.btn-next.disabled {
  opacity: 0.35;
  pointer-events: none;
  box-shadow: none;
}

.btn-next.loading {
  opacity: 0.6;
  pointer-events: none;
}

/* === SCALE COMPONENT === */
.scale-wrap {
  padding: 0 4px;
  margin: 0 -10px;
  /* extend beyond card padding to widen the track */
}

.scale-label-area {
  text-align: center;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 14px;
}

.scale-label-text {
  background: rgba(255, 255, 255, 0.1);
  color: rgba(255, 235, 190, 0.7);
  font-size: 14px;
  font-weight: 600;
  padding: 5px 16px;
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  transition: background 0.2s, color 0.2s, border-color 0.2s;
}

.scale-label-text.agree {
  background: linear-gradient(90deg, rgba(200, 134, 10, 0.7), rgba(245, 200, 66, 0.7));
  color: #fff8e0;
  border-color: rgba(245, 200, 66, 0.4);
}

.scale-label-text.disagree {
  background: rgba(255, 255, 255, 0.06);
  color: rgba(255, 235, 190, 0.45);
  border-color: rgba(255, 255, 255, 0.08);
}

.scale-track-row {
  position: relative;
  padding: 0;
}

.scale-track {
  position: relative;
  height: 4px;
  background: rgba(255, 255, 255, 0.12);
  border-radius: 2px;
  margin: 14px 0;
}

.scale-fill {
  position: absolute;
  top: 0;
  height: 100%;
  border-radius: 2px;
  transition: left 0.15s, width 0.15s, background 0.15s;
}

.scale-thumb {
  position: absolute;
  top: 50%;
  width: 28px;
  height: 28px;
  background: rgba(30, 20, 5, 0.8);
  backdrop-filter: blur(8px);
  border: 2px solid rgba(255, 215, 120, 0.4);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  transition: left 0.15s, border-color 0.2s, box-shadow 0.2s;
  z-index: 2;
}

.scale-thumb.agree {
  border-color: #f5c842;
  box-shadow: 0 0 0 4px rgba(245, 200, 66, 0.2);
}

.scale-thumb.disagree {
  border-color: rgba(255, 255, 255, 0.3);
  box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.06);
}

.scale-thumb.neutral {
  border-color: rgba(255, 215, 120, 0.3);
}

.scale-ticks {
  display: flex;
  justify-content: space-between;
}

.scale-tick {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 28px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.tick-dot {
  width: 6px;
  height: 6px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  margin-bottom: 4px;
  transition: background 0.15s;
}

.tick-num {
  font-size: 12px;
  color: rgba(255, 235, 190, 0.35);
  font-weight: 500;
  transition: color 0.15s, font-weight 0.1s;
}

.scale-tick.active .tick-dot {
  background: #f5c842;
}

.scale-tick.active .tick-num {
  color: #f5c842;
  font-weight: 700;
}

.scale-tick.active-disagree .tick-dot {
  background: rgba(255, 255, 255, 0.4);
}

.scale-tick.active-disagree .tick-num {
  color: rgba(255, 255, 255, 0.5);
  font-weight: 700;
}

.scale-end-labels {
  display: flex;
  justify-content: space-between;
  margin-top: 8px;
  padding: 0 2px;
}

.scale-end-labels span {
  font-size: 11px;
  color: rgba(255, 235, 190, 0.3);
  letter-spacing: 0.3px;
}

/* === RESULT PAGE === */
#page-result {
  background: linear-gradient(160deg, var(--bg-start), var(--bg-end));
  /* inherits position: fixed; inset: 0; overflow-y: auto from .page */
}

/* Particles */
.particles {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.particle {
  position: absolute;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.7);
  animation: particleFloat linear infinite;
}

@keyframes particleFloat {
  0% {
    transform: translateY(100vh) scale(0);
    opacity: 0;
  }

  10% {
    opacity: 1;
  }

  90% {
    opacity: 0.8;
  }

  100% {
    transform: translateY(-40px) scale(1);
    opacity: 0;
  }
}

/* Glow orb */
.glow-orb {
  position: fixed;
  top: -80px;
  left: 50%;
  transform: translateX(-50%);
  width: 280px;
  height: 280px;
  background: radial-gradient(circle, var(--theme-glow) 0%, transparent 70%);
  border-radius: 50%;
  animation: glowPulse 3s ease-in-out infinite;
  pointer-events: none;
  z-index: 0;
}

@keyframes glowPulse {

  0%,
  100% {
    opacity: 0.6;
    transform: translateX(-50%) scale(1);
  }

  50% {
    opacity: 1;
    transform: translateX(-50%) scale(1.3);
  }
}

/* Result content */
.result-content {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 60px 24px 40px;
  max-width: 400px;
  margin: 0 auto;
  gap: 28px;
}

/* Archetype reveal */
.archetype-reveal {
  text-align: center;
  opacity: 0;
  transform: translateY(12px);
}

.archetype-reveal.visible {
  animation: revealUp 0.6s ease-out 0.3s forwards;
}

@keyframes revealUp {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.archetype-emoji-orb {
  width: 88px;
  height: 88px;
  background: radial-gradient(circle at 35% 35%, var(--theme-btn-end), var(--theme-btn-start));
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 36px;
  margin: 0 auto 16px;
  box-shadow: 0 0 40px var(--theme-glow);
  animation: orbFloat 4s ease-in-out infinite;
}

.archetype-name {
  font-size: 28px;
  font-weight: 800;
  color: #fff;
  margin-bottom: 6px;
}

.archetype-score {
  font-size: 14px;
  font-weight: 600;
  color: var(--theme-btn-end);
}

/* Distribution bars */
.distribution-bars {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.dist-row {
  display: flex;
  align-items: center;
  gap: 10px;
  opacity: 0;
}

.dist-row.visible {
  animation: fadeIn 0.4s ease-out forwards;
}

@keyframes fadeIn {
  to {
    opacity: 1;
  }
}

.dist-color-label {
  width: 28px;
  font-size: 13px;
  font-weight: 600;
  color: #aaa;
  flex-shrink: 0;
}

.dist-track {
  flex: 1;
  height: 8px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
  overflow: hidden;
}

.dist-fill {
  height: 100%;
  border-radius: 4px;
  width: 0%;
  min-width: 0;
  transition: width 0.6s ease-out;
}

.dist-pct {
  width: 36px;
  font-size: 12px;
  color: #888;
  text-align: right;
  flex-shrink: 0;
}

/* Result label */
.result-label {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.45);
  margin-bottom: 6px;
  letter-spacing: 0.5px;
}

/* Section blocks */
.result-section {
  width: 100%;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 16px;
  padding: 18px 20px;
  opacity: 0;
}

.result-section.visible {
  animation: fadeIn 0.5s ease-out forwards;
}

.section-title {
  font-size: 12px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.4);
  letter-spacing: 0.5px;
  margin-bottom: 12px;
}

/* Core dynamic */
.core-dynamic {
  font-size: 15px;
  color: rgba(255, 255, 255, 0.85);
  line-height: 1.75;
}

/* Color legend */
.color-legend {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 8px;
  margin-top: 14px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: rgba(255, 255, 255, 0.45);
  line-height: 1.4;
}

.legend-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* Trait lists */
.trait-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.trait-list li {
  font-size: 14px;
  color: rgba(255, 255, 255, 0.8);
  line-height: 1.6;
  padding-left: 16px;
  position: relative;
}

.trait-list li::before {
  content: '·';
  position: absolute;
  left: 0;
  color: var(--theme-btn-end);
  font-size: 18px;
  line-height: 1.3;
}

/* Top matches */
.top-matches {
  width: 100%;
  opacity: 0;
}

.top-matches.visible {
  animation: fadeIn 0.4s ease-out forwards;
}

.match-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  font-size: 13px;
}

.match-item:last-child {
  border-bottom: none;
}

.match-rank {
  color: #666;
  width: 20px;
}

.match-name {
  color: #ccc;
  flex: 1;
  padding: 0 8px;
}

.match-score {
  color: var(--theme-btn-end);
  font-weight: 600;
}

/* Action buttons */
.result-actions {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.btn-poster {
  width: 100%;
  padding: 16px;
  background: linear-gradient(90deg, var(--theme-btn-start), var(--theme-btn-end));
  color: #fff;
  border-radius: 50px;
  font-size: 15px;
  font-weight: 700;
  box-shadow: 0 4px 24px var(--theme-glow);
  animation: btnPulse 2s ease-in-out infinite;
}

@keyframes btnPulse {

  0%,
  100% {
    box-shadow: 0 4px 24px var(--theme-glow);
  }

  50% {
    box-shadow: 0 4px 40px var(--theme-glow);
  }
}

.btn-report {
  width: 100%;
  padding: 14px;
  background: transparent;
  color: var(--theme-btn-end);
  border: 1.5px solid var(--theme-btn-start);
  border-radius: 50px;
  font-size: 14px;
  font-weight: 600;
}

.btn-home {
  width: 100%;
  padding: 12px;
  background: transparent;
  color: rgba(255, 255, 255, 0.35);
  border: none;
  border-radius: 50px;
  font-size: 13px;
}

/* Poster overlay */
.poster-container {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.9);
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  gap: 16px;
}

.poster-hint {
  color: #aaa;
  font-size: 13px;
}

#poster-img {
  max-width: 100%;
  max-height: 70vh;
  border-radius: 12px;
}

.btn-close-poster {
  padding: 12px 32px;
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  border-radius: 50px;
  font-size: 14px;
}

/* === ANIMATIONS === */
@keyframes orbFloat {

  0%,
  100% {
    transform: translateY(0);
  }

  50% {
    transform: translateY(-8px);
  }
}