/* ===== Reset & Base ===== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html {
  font-size: calc(100vw / 37.5);
  -webkit-text-size-adjust: 100%;
}

@media (min-width: 414px) {
  html {
    font-size: 11.04px;
  }
}

body {
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: #F5F3FF;
  color: #332B5D;
  overflow: hidden;
  height: 100vh;
  height: 100dvh;
  width: 100%;
}

img {
  display: block;
  max-width: 100%;
  pointer-events: none;
}

button {
  border: none;
  background: none;
  cursor: pointer;
  font-family: inherit;
  outline: none;
  -webkit-appearance: none;
}

#app {
  position: relative;
  width: 100%;
  max-width: 414px;
  height: 100vh;
  height: 100dvh;
  margin: 0 auto;
  overflow: hidden;
}

/* ===== Page System ===== */
.page {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  overflow: hidden;
}

.page.active {
  display: flex;
}

.page.fade-out {
  animation: pageFadeOut 0.35s ease forwards;
}

@keyframes pageFadeOut {
  to { opacity: 0; }
}

/* ===== Start Page ===== */
.page-start {
  background: linear-gradient(
    160deg,
    #A8C4E8 0%,
    #C4B8E8 35%,
    #D8C0E8 60%,
    #F0C8D8 100%
  );
  align-items: center;
  justify-content: flex-start;
}

.page-start::before {
  content: '';
  position: absolute;
  top: -10%;
  left: -20%;
  width: 70%;
  height: 50%;
  background: radial-gradient(ellipse, rgba(168, 196, 232, 0.6) 0%, transparent 70%);
  pointer-events: none;
}

.page-start::after {
  content: '';
  position: absolute;
  bottom: 10%;
  right: -15%;
  width: 60%;
  height: 45%;
  background: radial-gradient(ellipse, rgba(240, 200, 216, 0.5) 0%, transparent 70%);
  pointer-events: none;
}

.start-content {
  position: relative;
  z-index: 2;
  width: 100%;
  padding: 12rem 2.4rem 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.start-title {
  font-size: 2.6rem;
  font-weight: 700;
  color: #332B5D;
  line-height: 1.45;
  letter-spacing: 0.02em;
  max-width: 30rem;
}

.start-subtitle {
  margin-top: 1.6rem;
  font-size: 1.5rem;
  font-weight: 400;
  color: #4A4268;
  line-height: 1.6;
}

.btn-start {
  margin-top: 8rem;
  width: 80%;
  max-width: 28rem;
  min-height: 4.8rem;
  opacity: 1;
  transform: translateY(0);
}

.btn-start:active {
  animation: none;
  transform: scale(0.96);
}

.btn-start img {
  width: 100%;
  height: auto;
  filter: drop-shadow(0 0.6rem 1.6rem rgba(108, 99, 255, 0.35));
}

.btn-start.breathing {
  animation: breathe 2s ease-in-out infinite;
}

@keyframes breathe {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.03); }
}

.bubbles-deco {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 1;
  pointer-events: none;
}

.bubbles-deco img {
  width: 100%;
  opacity: 0.85;
  animation: bubbleFloat 6s ease-in-out infinite alternate;
}

@keyframes bubbleFloat {
  from { transform: translateY(0); }
  to { transform: translateY(-1rem); }
}

.float-dots {
  position: absolute;
  bottom: 3rem;
  left: 0;
  right: 0;
  z-index: 1;
  pointer-events: none;
}

.float-dots .dot {
  position: absolute;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.35);
}

.dot-1 {
  width: 0.8rem;
  height: 0.8rem;
  left: 15%;
  animation: dotFloat 3s ease-in-out infinite alternate;
}

.dot-2 {
  width: 1.2rem;
  height: 1.2rem;
  left: 45%;
  animation: dotFloat 4s ease-in-out 0.5s infinite alternate;
}

.dot-3 {
  width: 0.6rem;
  height: 0.6rem;
  right: 18%;
  animation: dotFloat 3.5s ease-in-out 1s infinite alternate;
}

@keyframes dotFloat {
  from { transform: translateY(0); opacity: 0.3; }
  to { transform: translateY(-1.2rem); opacity: 0.6; }
}

/* ===== Quiz Page ===== */
.page-quiz {
  background: linear-gradient(
    180deg,
    #9BB0E0 0%,
    #B8A8D8 40%,
    #E0B8D0 100%
  );
}

.quiz-header {
  padding: 5.5rem 2rem 0;
  flex-shrink: 0;
}

.progress-wrap {
  width: 100%;
}

.progress-track {
  position: relative;
  height: 0.5rem;
  background: rgba(255, 255, 255, 0.45);
  border-radius: 0.25rem;
  overflow: visible;
}

.progress-fill {
  position: absolute;
  left: 0;
  top: 0;
  height: 100%;
  width: 20%;
  background: #6C63FF;
  border-radius: 0.25rem;
  transition: width 0.4s ease;
}

.progress-thumb {
  position: absolute;
  top: 50%;
  left: 20%;
  transform: translate(-50%, -50%);
  width: 2.4rem;
  height: 2.4rem;
  background: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0.2rem 0.8rem rgba(0, 0, 0, 0.12);
  transition: left 0.4s ease;
  z-index: 2;
}

.thumb-icon {
  font-size: 1rem;
  color: #999;
  font-weight: 500;
}

.progress-labels {
  position: relative;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  margin-top: 0.8rem;
  min-height: 2rem;
}

.progress-center {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  font-size: 1.3rem;
  color: rgba(255, 255, 255, 0.85);
  font-weight: 500;
}

.progress-current {
  font-size: 1.4rem;
  color: rgba(255, 255, 255, 0.9);
  font-weight: 500;
}

.quiz-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 3.5rem 2rem 4rem;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.quiz-question {
  font-size: 2.2rem;
  font-weight: 700;
  color: #fff;
  text-align: center;
  line-height: 1.5;
  margin-bottom: 3.5rem;
  padding: 0 0.5rem;
}

.quiz-options {
  display: flex;
  flex-direction: column;
  gap: 1.6rem;
}

.option-card {
  display: flex;
  align-items: center;
  gap: 1.4rem;
  padding: 1.6rem 1.8rem;
  background: #fff;
  border-radius: 1.2rem;
  box-shadow: 0 0.2rem 1.2rem rgba(0, 0, 0, 0.08);
  cursor: pointer;
  border: 0.2rem solid transparent;
  transition: border-color 0.1s ease, transform 0.1s ease, box-shadow 0.1s ease;
  min-height: 5.6rem;
  opacity: 0;
  transform: translateY(2rem);
}

.option-card.show {
  animation: optionPopIn 0.45s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.option-card:nth-child(1).show { animation-delay: 0s; }
.option-card:nth-child(2).show { animation-delay: 0.15s; }
.option-card:nth-child(3).show { animation-delay: 0.3s; }

@keyframes optionPopIn {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.option-card:active {
  transform: scale(0.98);
}

.option-card.selected {
  border-color: #6C63FF;
  box-shadow: 0 0.2rem 1.6rem rgba(108, 99, 255, 0.2);
}

.option-radio {
  flex-shrink: 0;
  width: 2.2rem;
  height: 2.2rem;
  border-radius: 50%;
  border: 0.15rem solid #D0D0D8;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.1s ease, background 0.1s ease;
}

.option-card.selected .option-radio {
  border-color: #6C63FF;
  background: #6C63FF;
}

.option-radio::after {
  content: '';
  width: 0.8rem;
  height: 0.8rem;
  border-radius: 50%;
  background: #fff;
  opacity: 0;
  transition: opacity 0.1s ease;
}

.option-card.selected .option-radio::after {
  opacity: 1;
}

.option-text {
  flex: 1;
  font-size: 1.6rem;
  color: #333;
  font-weight: 500;
  line-height: 1.4;
}

.option-letter {
  display: none;
}

/* ===== Result Page ===== */
.page-result {
  background: linear-gradient(
    180deg,
    #FFB87B 0%,
    #FFD4A8 35%,
    #FFF0D8 70%,
    #FFF8EE 100%
  );
  align-items: center;
  justify-content: center;
}

.particles {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 1;
}

.particle {
  position: absolute;
  opacity: 0;
  animation: particleRise 4s ease-in infinite;
}

.particle.star {
  width: 1.6rem;
  height: 1.6rem;
  background: radial-gradient(circle, #fff 30%, transparent 70%);
  clip-path: polygon(
    50% 0%, 61% 35%, 98% 35%, 68% 57%,
    79% 91%, 50% 70%, 21% 91%, 32% 57%,
    2% 35%, 39% 35%
  );
  filter: drop-shadow(0 0 0.4rem rgba(255, 255, 255, 0.8));
}

.particle.dot {
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.7);
  box-shadow: 0 0 0.6rem rgba(255, 255, 255, 0.6);
}

@keyframes particleRise {
  0% {
    opacity: 0;
    transform: translateY(0) scale(0.5);
  }
  20% {
    opacity: 0.9;
  }
  80% {
    opacity: 0.4;
  }
  100% {
    opacity: 0;
    transform: translateY(-12rem) scale(1);
  }
}

.result-content {
  position: relative;
  z-index: 2;
  width: 100%;
  padding: 4rem 2.4rem 6rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.result-badge-wrap {
  width: 24rem;
  height: 24rem;
  margin-bottom: 2.4rem;
  opacity: 0;
  transform: scale(0);
}

.result-badge {
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 0.8rem 2rem rgba(255, 140, 80, 0.25));
}

.result-title {
  font-size: 2.4rem;
  font-weight: 700;
  color: #C44A20;
  margin-bottom: 1.6rem;
  opacity: 0;
  transform: translateY(2rem);
}

.result-desc {
  font-size: 1.5rem;
  color: #5A4A42;
  line-height: 1.8;
  max-width: 30rem;
  margin-bottom: 4rem;
  opacity: 0;
}

.result-actions {
  display: flex;
  gap: 1.6rem;
  width: 100%;
  max-width: 32rem;
  opacity: 0;
}

.btn-retest,
.btn-share {
  flex: 1;
  height: 4.8rem;
  border-radius: 2.4rem;
  font-size: 1.6rem;
  font-weight: 600;
  min-width: 0;
  transition: transform 0.15s ease, opacity 0.15s ease;
}

.btn-retest:active,
.btn-share:active {
  transform: scale(0.96);
}

.btn-retest {
  background: #FFF8EE;
  color: #C44A20;
  border: 0.15rem solid rgba(196, 74, 32, 0.35);
  box-shadow: 0 0.2rem 0.8rem rgba(0, 0, 0, 0.06);
}

.btn-share {
  background: linear-gradient(90deg, #FFB87B 0%, #FF7A57 100%);
  color: #fff;
  box-shadow: 0 0.4rem 1.2rem rgba(255, 122, 87, 0.35);
}

/* ===== Animations ===== */
.anim-fade-up {
  opacity: 0;
  transform: translateY(3rem);
  animation: fadeUp 0.6s ease-out forwards;
}

.anim-fade-up.delay-1 { animation-delay: 0.3s; }
.anim-fade-up.delay-2 { animation-delay: 0.8s; }

@keyframes fadeUp {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.anim-slide-in {
  animation: slideInLeft 0.4s ease-out forwards;
}

@keyframes slideInLeft {
  from {
    opacity: 0;
    transform: translateX(-2rem);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.anim-badge-pop {
  animation: badgePop 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) 0.1s forwards;
}

@keyframes badgePop {
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.anim-slide-up.delay-1 {
  animation: slideUp 0.5s ease-out 0.3s forwards;
}

.anim-fade-in.delay-2 {
  animation: fadeIn 0.5s ease-out 0.5s forwards;
}

.anim-slide-buttons.delay-3 {
  animation: slideButtons 0.5s ease-out 0.7s forwards;
}

@keyframes slideUp {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeIn {
  to { opacity: 1; }
}

@keyframes slideButtons {
  from {
    opacity: 0;
    transform: translateX(-1.5rem);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.quiz-question.fade-switch {
  animation: questionSwitch 0.35s ease forwards;
}

@keyframes questionSwitch {
  0% { opacity: 1; transform: translateX(0); }
  50% { opacity: 0; transform: translateX(-1.5rem); }
  51% { opacity: 0; transform: translateX(1.5rem); }
  100% { opacity: 1; transform: translateX(0); }
}

/* ===== Toast ===== */
.toast {
  position: fixed;
  bottom: 8rem;
  left: 50%;
  transform: translateX(-50%) translateY(2rem);
  background: rgba(51, 43, 93, 0.88);
  color: #fff;
  padding: 1.2rem 2rem;
  border-radius: 0.8rem;
  font-size: 1.4rem;
  z-index: 999;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.3s ease;
  max-width: 80%;
  text-align: center;
  line-height: 1.5;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ===== Safe Area ===== */
@supports (padding-top: env(safe-area-inset-top)) {
  .quiz-header {
    padding-top: calc(5.5rem + env(safe-area-inset-top));
  }
}
