/* ============ MBTI 性格小剧场 · 视觉 v5 ============ */
:root {
  --bg: #FFF6EC;
  --card: #FFFFFF;
  --ink: #3A3335;
  --muted: #9B8F86;
  --line: #F0E4D6;
  --accent: #FF7A59;
  --accent-deep: #E8623C;
  --accent-grad: linear-gradient(135deg, #FF9A5C, #FF6B8A);
  --shadow: 0 6px 24px rgba(216, 178, 138, 0.22);
  --radius: 20px;
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html { font-size: 16px; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "HarmonyOS Sans SC", "Microsoft YaHei", sans-serif;
  background:
    radial-gradient(1100px 520px at 50% -140px, rgba(255, 201, 150, 0.50), transparent 70%),
    radial-gradient(900px 480px at 108% 112%, rgba(255, 214, 186, 0.40), transparent 65%),
    var(--bg);
  background-attachment: fixed;
  color: var(--ink);
  min-height: 100vh;
  min-height: 100dvh;
  line-height: 1.6;
}

/* 纸纹噪点氛围层（极低透明度，只添质感不加噪音） */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0.42 0 0 0 0 0.34 0 0 0 0 0.24 0 0 0 0.045 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  pointer-events: none;
  z-index: 0;
}

#app {
  position: relative;
  z-index: 1;
  max-width: 480px;
  margin: 0 auto;
  padding: 24px 20px calc(env(safe-area-inset-bottom) + 32px);
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* ---------- 屏幕切换动画 ---------- */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: translateY(0); }
}
.screen { animation: fadeUp .38s ease both; display: flex; flex-direction: column; flex: 1; }

/* ---------- 开场页 ---------- */
.hero-img {
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  border-radius: 26px;
  box-shadow: 0 18px 40px -14px rgba(216, 178, 138, 0.55), 0 4px 14px rgba(216, 178, 138, 0.25);
  display: block;
}
.intro-title {
  font-size: 2.02rem;
  font-weight: 900;
  letter-spacing: .5px;
  margin-top: 22px;
  text-align: center;
  line-height: 1.25;
}
.intro-title .hi {
  background: var(--accent-grad);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: var(--accent); /* 兜底 */
}
.intro-sub {
  color: var(--muted);
  text-align: center;
  font-size: .92rem;
  margin-top: 8px;
}
.chips {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 16px;
}
.chip {
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 15px;
  font-size: .8rem;
  font-weight: 600;
  color: #7A6E63;
  box-shadow: 0 3px 10px -4px rgba(216, 178, 138, 0.3);
}
.last-badge {
  margin-top: 18px;
  text-align: center;
  font-size: .82rem;
  color: #8A7A6A;
  background: #FFF0E0;
  border: 1px dashed #F2D9BE;
  border-radius: 12px;
  padding: 8px 12px;
}
.last-badge b { color: var(--accent); }

.btn-main {
  margin-top: auto;
  padding: 17px;
  border: none;
  border-radius: 18px;
  background: var(--accent-grad);
  color: #fff;
  font-size: 1.08rem;
  font-weight: 700;
  letter-spacing: 1px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  box-shadow: 0 12px 26px -6px rgba(255, 122, 89, 0.5);
  transition: transform .15s ease, box-shadow .15s ease;
}
/* 舞台灯光扫过 */
.btn-main::after {
  content: "";
  position: absolute;
  top: -10%;
  left: -80%;
  width: 55%;
  height: 120%;
  background: linear-gradient(100deg, transparent, rgba(255, 255, 255, 0.32), transparent);
  transform: skewX(-18deg);
  animation: btnShine 3.4s ease-in-out infinite;
  pointer-events: none;
}
@keyframes btnShine { 0%, 60% { left: -80%; } 100% { left: 150%; } }
.btn-main:active { transform: scale(.965); box-shadow: 0 6px 16px -4px rgba(255, 122, 89, 0.45); }
.btn-main:disabled { opacity: .6; }

.privacy-note {
  text-align: center;
  font-size: .74rem;
  color: #B8AB9E;
  margin-top: 12px;
}

/* ---------- 答题页 ---------- */
.progress-wrap { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.progress-num {
  font-size: .78rem;
  color: var(--muted);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
/* 12 段分节进度条（12 题 = 12 节） */
.progress-bar {
  flex: 1;
  height: 10px;
  border-radius: 999px;
  background: #F3E7D8;
  overflow: hidden;
  -webkit-mask-image: repeating-linear-gradient(90deg, #000 0 calc(100% / 12 - 4px), transparent calc(100% / 12 - 4px) calc(100% / 12));
  mask-image: repeating-linear-gradient(90deg, #000 0 calc(100% / 12 - 4px), transparent calc(100% / 12 - 4px) calc(100% / 12));
}
.progress-fill {
  height: 100%;
  border-radius: 999px;
  background: var(--accent-grad);
  box-shadow: 0 0 8px rgba(255, 122, 89, 0.45);
  transition: width .45s cubic-bezier(.4, 0, .2, 1);
}

/* 场景图：胶片框 + 场景角标 */
.scene-frame { position: relative; }
.scene-img {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: 20px;
  box-shadow: 0 16px 36px -14px rgba(216, 178, 138, 0.55);
  display: block;
  background: #F3E7D8;
}
.scene-frame::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 20px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.4), inset 0 -60px 48px -40px rgba(58, 51, 53, 0.28);
  pointer-events: none;
}
.scene-tag {
  position: absolute;
  top: 12px;
  left: 12px;
  padding: 5px 11px;
  border-radius: 9px;
  background: rgba(58, 51, 53, 0.55);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  color: #fff;
  font-size: .66rem;
  font-weight: 800;
  letter-spacing: 2px;
  font-variant-numeric: tabular-nums;
}
.scene-label {
  margin-top: 14px;
  font-size: 1.05rem;
  font-weight: 700;
  color: #4E4238;
  text-align: center;
  line-height: 1.65;
  position: relative;
  padding: 0 1.5em;
}
.scene-label::before { content: "「"; position: absolute; left: .3em; top: 0; color: #D8C0A8; }
.scene-label::after { content: "」"; position: absolute; right: .3em; bottom: 0; color: #D8C0A8; }
.q-text {
  font-size: 1.12rem;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.55;
  margin: 12px 4px 18px;
}

/* ---------- TTS 朗读按钮 ---------- */
.tts-row { text-align: center; }
.tts-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 10px auto 0;
  padding: 9px 20px;
  border: 1px solid rgba(232, 98, 60, 0.14);
  border-radius: 999px;
  background: #FFE3D6;
  color: #B84A26;
  font-size: .92rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: transform .15s ease, background .2s ease;
}
.tts-btn:active { transform: scale(.95); }
.tts-btn.playing {
  background: var(--accent);
  color: #fff;
  animation: ttsPulse 1.3s ease-in-out infinite;
}
@keyframes ttsPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255, 122, 89, .38); }
  50% { box-shadow: 0 0 0 9px rgba(255, 122, 89, 0); }
}

/* ---------- 世界同类 & 统计页 ---------- */
.world-line { font-size: 1rem; line-height: 1.7; color: var(--ink); }
.world-line b { color: #B84A26; }
.world-num {
  font-size: 1.3rem;
  font-weight: 900;
  background: var(--accent-grad);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.world-sub { margin-top: 6px; font-size: .88rem; color: var(--muted); line-height: 1.6; }
.stats-link { color: var(--accent-deep); font-weight: 700; text-decoration: none; border-bottom: 1px dashed var(--accent-deep); }

.stats-hero { text-align: center; margin: 6px 0 14px; }
.stats-title {
  font-size: 1.34rem;
  font-weight: 900;
  background: var(--accent-grad);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.stats-sub { margin-top: 6px; font-size: .92rem; color: var(--muted); }
.stat-row { margin: 12px 0; }
.stat-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 6px; font-size: .92rem; }
.stat-name { font-weight: 600; }
.stat-val { color: var(--accent-deep); font-weight: 700; white-space: nowrap; font-variant-numeric: tabular-nums; }
.stat-dot { display: inline-block; width: 11px; height: 11px; border-radius: 50%; margin-right: 6px; box-shadow: 0 0 0 3px rgba(216, 178, 138, 0.14); }

/* ---------- 选项卡 ---------- */
.choices { display: flex; flex-direction: column; gap: 14px; }
.choice {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  text-align: left;
  padding: 16px;
  background: var(--card);
  border: 2px solid var(--line);
  border-radius: var(--radius);
  cursor: pointer;
  font: inherit;
  color: var(--ink);
  position: relative;
  transition: transform .16s ease, border-color .16s ease, box-shadow .16s ease;
  box-shadow: 0 4px 14px -6px rgba(216, 178, 138, 0.3);
}
.choice:active { transform: scale(.97); }
.choice.picked {
  border-color: var(--accent);
  box-shadow: 0 10px 26px -8px rgba(255, 122, 89, 0.45);
  background: linear-gradient(135deg, #FFF6F0, #FFEFDE);
}
/* A / B 角标，选中变 ✓ */
.choice::after {
  content: attr(data-tag);
  position: absolute;
  top: -9px;
  right: 14px;
  min-width: 24px;
  height: 24px;
  padding: 0 7px;
  border-radius: 999px;
  background: var(--card);
  border: 1px solid var(--line);
  color: #B09F8E;
  font-size: .72rem;
  font-weight: 800;
  display: grid;
  place-items: center;
  box-shadow: 0 2px 6px rgba(216, 178, 138, 0.2);
  transition: background .2s ease, border-color .2s ease, color .2s ease;
}
.choice.picked::after {
  content: "✓";
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.choice-icon {
  flex: 0 0 46px;
  width: 46px;
  height: 46px;
  border-radius: 14px;
  background: #FFF0E4;
  display: grid;
  place-items: center;
  font-size: 1.45rem;
  transition: background .2s ease;
}
.choice.picked .choice-icon { background: linear-gradient(135deg, #FFD9C4, #FFC9AD); }
.choice-text { font-size: .95rem; line-height: 1.5; }
.choice-ghost {
  margin-top: auto;
  padding-top: 18px;
  text-align: center;
  font-size: .78rem;
  color: #C2B5A6;
}

/* ---------- 计算中 ---------- */
.calc { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 20px; }
.calc-orbit { font-size: 3.6rem; animation: pulse 1.1s ease-in-out infinite; }
@keyframes pulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.14) rotate(6deg); } }
.calc-status { color: var(--muted); font-size: .95rem; min-height: 1.6em; }
.calc-dots { display: flex; gap: 8px; }
.calc-dots span {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--accent);
  animation: bounceDot 1s ease infinite;
}
.calc-dots span:nth-child(2) { animation-delay: .15s; }
.calc-dots span:nth-child(3) { animation-delay: .3s; }
@keyframes bounceDot { 0%,100% { transform: translateY(0); opacity: .5; } 50% { transform: translateY(-7px); opacity: 1; } }

/* ---------- 结果页 ---------- */
.result-hero {
  border-radius: 28px;
  padding: 32px 22px 28px;
  color: #fff;
  text-align: center;
  box-shadow: 0 20px 44px -12px rgba(0, 0, 0, 0.3);
  position: relative;
  overflow: hidden;
}
/* 聚光灯晕 + 边缘反光 */
.result-hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(340px 220px at 50% -40px, rgba(255, 255, 255, 0.32), transparent 70%),
    radial-gradient(circle at 88% 8%, rgba(255, 255, 255, 0.18), transparent 38%);
  pointer-events: none;
}
.result-emoji { font-size: 3.2rem; display: block; filter: drop-shadow(0 4px 10px rgba(0,0,0,.18)); }
.type-tiles { display: flex; justify-content: center; gap: 8px; margin-top: 14px; }
.type-tile {
  width: 52px; height: 58px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.22);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: grid; place-items: center;
  font-size: 1.65rem; font-weight: 900;
  border: 1px solid rgba(255, 255, 255, 0.35);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.4), 0 4px 10px rgba(0, 0, 0, 0.14);
  animation: tilePop .5s cubic-bezier(.34,1.56,.64,1) both;
}
.type-tile:nth-child(2) { animation-delay: .1s; }
.type-tile:nth-child(3) { animation-delay: .2s; }
.type-tile:nth-child(4) { animation-delay: .3s; }
@keyframes tilePop { from { opacity: 0; transform: translateY(16px) scale(.7); } to { opacity: 1; transform: none; } }
.result-name {
  font-size: 1.5rem;
  font-weight: 800;
  margin-top: 14px;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
}
.result-tagline { font-size: .88rem; opacity: .92; margin-top: 4px; }
.group-badge {
  display: inline-flex; align-items: center; gap: 6px;
  margin-top: 12px;
  background: rgba(255, 255, 255, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.4);
  border-radius: 999px;
  padding: 5px 14px;
  font-size: .78rem;
  font-weight: 600;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.section-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 18px;
  margin-top: 16px;
  border: 1px solid rgba(240, 228, 214, 0.6);
  box-shadow: 0 8px 24px -10px rgba(216, 178, 138, 0.3);
}
.section-title {
  display: flex; align-items: center; gap: 8px;
  font-size: .78rem;
  font-weight: 800;
  color: #B09F8E;
  letter-spacing: 3px;
  margin-bottom: 12px;
}
.section-title::before {
  content: "";
  width: 14px; height: 3px;
  border-radius: 2px;
  background: var(--accent-grad);
}
.result-desc { font-size: .94rem; color: #5C5148; }

.trait-tags { display: flex; flex-wrap: wrap; gap: 8px; }
.trait-tag {
  border-radius: 999px;
  padding: 8px 16px;
  font-size: .85rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: .5px;
  box-shadow: 0 6px 14px -6px rgba(0, 0, 0, 0.3);
}

/* 四维光谱 */
.spectrum { margin-top: 6px; }
.spec-row { margin-bottom: 14px; }
.spec-row:last-child { margin-bottom: 0; }
.spec-head { display: flex; justify-content: space-between; font-size: .8rem; font-weight: 700; margin-bottom: 6px; font-variant-numeric: tabular-nums; }
.spec-head .win { color: var(--accent-deep); }
.spec-head .lose { color: #B8AB9E; }
.spec-track {
  height: 10px;
  border-radius: 999px;
  background: linear-gradient(90deg, #F6ECDE, #F3E7D8);
  overflow: hidden;
  position: relative;
  box-shadow: inset 0 1px 2px rgba(216, 178, 138, 0.25);
}
/* 中线刻度：左右两极的分界 */
.spec-track::after {
  content: "";
  position: absolute;
  left: 50%; top: 2px; bottom: 2px;
  width: 2px;
  border-radius: 1px;
  background: rgba(58, 51, 53, 0.12);
}
.spec-fill {
  height: 100%;
  border-radius: 999px;
  background: var(--accent-grad);
  width: 0;
  transition: width 1s cubic-bezier(.3,.8,.3,1);
}

.tip-card {
  background: #FFF3E4;
  border: 1px dashed #F0C89A;
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-top: 16px;
  font-size: .9rem;
  color: #7A6047;
}
.tip-card b { color: #C97B3D; }

.result-actions { display: flex; gap: 12px; margin-top: 22px; }
.btn-ghost {
  flex: 1;
  padding: 14px;
  border-radius: 16px;
  border: 2px solid var(--line);
  background: var(--card);
  color: var(--ink);
  font-size: .95rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 12px -6px rgba(216, 178, 138, 0.35);
  transition: transform .15s ease;
}
.btn-ghost:active { transform: scale(.96); }
.result-actions .btn-main { margin-top: 0; }

.disclaimer {
  margin-top: 20px;
  text-align: center;
  font-size: .72rem;
  color: #C2B5A6;
  line-height: 1.7;
}

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom) + 28px);
  transform: translateX(-50%) translateY(20px);
  background: rgba(58, 51, 53, 0.92);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  color: #fff;
  padding: 10px 20px;
  border-radius: 999px;
  font-size: .85rem;
  opacity: 0;
  transition: opacity .25s ease, transform .25s ease;
  z-index: 99;
  pointer-events: none;
  max-width: 86vw;
  text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- 响应式 & 无障碍 ---------- */
@media (min-width: 560px) {
  #app { padding-top: 40px; }
  .hero-img { border-radius: 30px; }
  .scene-img, .scene-frame::after { border-radius: 22px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}
