:root {
  --ink: #090708;
  --ink-purple: #140B18;
  --cinnabar: #D62F36;
  --neon: #FF334E;
  --moon: #F4E8D2;
  --bronze: #B69255;
  --cyber: #41E5D1;
  --advice-bg: rgba(8, 26, 24, 0.62);   /* 深青黑卡片 */
  --font-title: "Songti SC", "STSong", "SimSun", "Noto Serif SC", serif;
  --font-body: -apple-system, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", sans-serif;
  --font-mono: "SF Mono", "Courier New", ui-monospace, monospace;
  --edge: max(24px, env(safe-area-inset-left));   /* 统一 24px 左右边距 + 安全区 */
  --edge-r: max(24px, env(safe-area-inset-right));
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: var(--font-body);
  /* 更深、更纯黑的留白 */
  background: radial-gradient(120% 70% at 50% 0%, #150c19 0%, #0b070c 55%, #060406 100%);
  color: var(--moon);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ===== 背景层 ===== */
.bg-layer { position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; }
.moon {
  position: absolute; top: -40px; right: -30px; width: 140px; height: 140px;   /* 缩小约 30% */
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #fbf3e0, #cdbf9e 70%, #8a7a55);
  box-shadow: 0 0 40px rgba(244, 232, 210, 0.12);   /* 减弱描边/光晕 */
  opacity: 0.7;
}
.red-thread { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0.2; }  /* 降透明度 */
.red-thread path {
  fill: none; stroke: var(--neon); stroke-width: 1.1; stroke-linecap: round;
  filter: drop-shadow(0 0 3px rgba(255, 51, 78, 0.4));
  stroke-dasharray: 6 8; animation: floatThread 9s ease-in-out infinite;
}
.red-thread #rt2 { animation-delay: -3s; stroke: var(--cinnabar); }
.red-thread .node { fill: var(--neon); filter: drop-shadow(0 0 4px var(--neon)); animation: pulse 2.4s ease-in-out infinite; }
@keyframes floatThread { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-10px); } }
@keyframes pulse { 0%,100% { opacity: 0.3; } 50% { opacity: 0.8; } }

.scanline {
  position: absolute; inset: 0;
  background: repeating-linear-gradient(0deg, rgba(65,229,209,0.02) 0px, rgba(65,229,209,0.02) 1px, transparent 2px, transparent 4px);  /* 减弱 */
  mix-blend-mode: screen; animation: scan 7s linear infinite;
}
@keyframes scan { 0% { background-position: 0 0; } 100% { background-position: 0 100px; } }
.grain { position: absolute; inset: 0; background: radial-gradient(circle at 50% 50%, transparent 55%, rgba(0,0,0,0.6)); }

/* ===== 页面容器 ===== */
#app { position: relative; z-index: 1; max-width: 480px; margin: 0 auto; min-height: 100dvh;  /* 100dvh 适配微信工具栏 */
  display: flex; align-items: stretch; padding: 0 var(--edge-r) 0 var(--edge); }
.page { display: none; width: 100%; flex-direction: column; justify-content: center;
  padding: 52px 0 calc(52px + env(safe-area-inset-bottom));   /* 安全区底部 */
  text-align: left; animation: pageIn 0.5s ease;
  overflow-y: auto; -webkit-overflow-scrolling: touch; }   /* 允许内容超出滚动 */
.page.active { display: flex; }
/* 结果页内容多，改为顶部开始并允许滚动，避免小屏堆在中间 */
.page-result { justify-content: flex-start; padding-top: 44px; padding-bottom: calc(32px + env(safe-area-inset-bottom)); }
@keyframes pageIn { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

/* ===== 通用文字 ===== */
.kicker { font-family: var(--font-title); font-size: 13px; letter-spacing: 4px; color: var(--bronze); opacity: 0.85; margin: 0 0 4px; }
.kicker-en { font-family: var(--font-mono); font-size: 10px; letter-spacing: 3px; color: var(--cyber); opacity: 0.7; margin: 0 0 14px; }
.title { font-family: var(--font-title); font-size: 48px; line-height: 1.15; margin: 0; letter-spacing: 3px;
  color: var(--moon); text-shadow: 0 0 14px rgba(255,51,78,0.2); }   /* 减弱光晕 */
.subtitle { font-size: 14px; letter-spacing: 1px; line-height: 1.7; color: var(--bronze); margin: 14px 0 26px; }
.atmosphere { font-size: 13px; line-height: 1.9; color: rgba(244,232,210,0.7); margin-bottom: 26px; }
.meta-row { font-size: 12px; color: rgba(244,232,210,0.55); margin-bottom: 30px; display: flex; gap: 8px; align-items: center; justify-content: flex-start; }  /* 左对齐 */
.meta-row .dot { color: var(--cyber); }
.seal { position: absolute; top: 40px; left: 0; width: 46px; height: 46px; border: 2px solid var(--cinnabar);
  color: var(--cinnabar); font-family: var(--font-title); font-size: 24px; display: flex; align-items: center; justify-content: center;
  border-radius: 6px; transform: rotate(-6deg); box-shadow: 0 0 12px rgba(214,47,54,0.3); }  /* 减弱光晕 */
.brand { font-family: var(--font-title); font-size: 13px; letter-spacing: 4px; color: var(--bronze); margin-top: 30px; opacity: 0.8; }

/* ===== 按钮 ===== */
.btn-primary {
  font-family: var(--font-body); font-size: 16px; font-weight: 600; letter-spacing: 2px;
  color: #fff; background: linear-gradient(135deg, var(--cinnabar), var(--neon));
  border: none; border-radius: 40px; padding: 16px 28px; cursor: pointer; align-self: flex-start;
  box-shadow: 0 6px 22px rgba(255,51,78,0.3); transition: transform 0.15s, box-shadow 0.15s;
  position: relative; overflow: hidden;
}
.btn-primary:active { transform: scale(0.97); box-shadow: 0 3px 12px rgba(255,51,78,0.28); }
.btn-primary::after { content: ""; position: absolute; inset: 0; border-radius: 40px; border: 1px solid rgba(255,255,255,0.25); }
.btn-ghost {
  font-family: var(--font-body); font-size: 14px; letter-spacing: 1px; color: var(--moon);
  background: transparent; border: 1px solid rgba(182,146,85,0.5); border-radius: 40px;
  padding: 13px 24px; cursor: pointer; margin-top: 12px; transition: border-color 0.2s, background 0.2s;
}
.btn-ghost:active { background: rgba(182,146,85,0.12); }
/* 重新测试：弱化为文字按钮 */
.btn-text {
  background: none; border: none; color: rgba(244,232,210,0.5); font-size: 13px; letter-spacing: 1px;
  cursor: pointer; padding: 4px 0; margin-top: 14px; align-self: flex-start;
  text-decoration: underline; text-underline-offset: 3px; text-decoration-color: rgba(244,232,210,0.3);
}
.btn-text:active { color: rgba(244,232,210,0.8); }

/* ===== 手机号页 ===== */
.page-title { font-family: var(--font-title); font-size: 30px; letter-spacing: 3px; margin: 0 0 16px; }
.page-desc { font-size: 13px; line-height: 1.8; color: rgba(244,232,210,0.68); margin-bottom: 30px; }
.field { margin-bottom: 18px; }
#phoneInput {
  width: 100%; background: rgba(244,232,210,0.05); border: 1px solid rgba(182,146,85,0.4);
  border-radius: 12px; padding: 16px; color: var(--moon); font-size: 18px; letter-spacing: 2px;
  font-family: var(--font-mono); text-align: left; outline: none; transition: border-color 0.2s;   /* 左对齐 */
}
#phoneInput:focus { border-color: var(--neon); }
#phoneInput::placeholder { color: rgba(244,232,210,0.35); letter-spacing: 1px; }
.privacy { display: flex; align-items: flex-start; gap: 10px; font-size: 12px; color: rgba(244,232,210,0.75); cursor: pointer; line-height: 1.6; }
.privacy input { margin-top: 2px; accent-color: var(--neon); width: 16px; height: 16px; flex-shrink: 0; }
.privacy-short { font-size: 11px; color: rgba(65,229,209,0.7); line-height: 1.6; margin: 8px 0 26px 26px; }
.error { color: var(--neon); font-size: 13px; min-height: 18px; margin-top: 14px; text-align: left; letter-spacing: 1px; }  /* 左对齐 */

/* ===== 测试题 ===== */
.quiz-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.quiz-code { font-family: var(--font-mono); font-size: 11px; color: var(--cyber); letter-spacing: 1px; }
.quiz-progress { font-family: var(--font-mono); font-size: 13px; color: var(--bronze); }
.progress-bar { height: 3px; background: rgba(244,232,210,0.12); border-radius: 3px; overflow: hidden; margin-bottom: 30px; }
.progress-bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--cinnabar), var(--neon)); transition: width 0.4s ease; }
.quiz-question { font-family: var(--font-title); font-size: 28px; line-height: 1.35; letter-spacing: 1px; margin: 0 0 26px; font-weight: 600; }  /* 28px / 600 / 1.35 */
.options { display: flex; flex-direction: column; gap: 12px; }  /* 间距 12px */
.option {
  min-height: 76px;   /* 高度 72–82px */
  background: rgba(244,232,210,0.04); border: 1px solid rgba(182,146,85,0.28); border-radius: 14px;
  padding: 16px 18px; font-size: 15px; line-height: 1.5; color: var(--moon); cursor: pointer; text-align: left;  /* 内部左对齐 */
  display: flex; align-items: center; gap: 14px; transition: border-color 0.2s, background 0.2s, transform 0.12s;
  position: relative; overflow: hidden;
}
.option .opt-key { font-family: var(--font-mono); font-size: 13px; color: var(--bronze); border: 1px solid rgba(182,146,85,0.5); border-radius: 50%; width: 26px; height: 26px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.option:active { transform: scale(0.985); }
.option.selected { border-color: var(--neon); background: rgba(255,51,78,0.12); }
.option.selected .opt-key { color: #fff; background: var(--neon); border-color: var(--neon); }
.option.selected::after { content: ""; position: absolute; inset: 0; border-radius: 14px; border: 1px solid var(--neon); animation: sealSpread 0.5s ease; }
@keyframes sealSpread { from { opacity: 0.9; transform: scale(1.02); } to { opacity: 0; transform: scale(1); } }

/* ===== 加载动画 ===== */
.page-loading { align-items: center; text-align: center; }
.disc { position: relative; width: 180px; height: 180px; margin-bottom: 40px; }
.disc-ring { position: absolute; inset: 0; border-radius: 50%; border: 1px solid rgba(182,146,85,0.35); border-top-color: var(--neon); border-right-color: var(--cyber); animation: spin 2.2s linear infinite; }
.disc-ring::after { content: ""; position: absolute; inset: 18px; border-radius: 50%; border: 1px dashed rgba(65,229,209,0.3); animation: spin 3.4s linear infinite reverse; }
.disc-core { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-family: var(--font-title); font-size: 54px; color: var(--moon); text-shadow: 0 0 16px rgba(255,51,78,0.35); }
@keyframes spin { to { transform: rotate(360deg); } }
.loading-steps { list-style: none; padding: 0; margin: 0 0 24px; font-family: var(--font-mono); font-size: 13px; color: rgba(244,232,210,0.6); }
.loading-steps li { opacity: 0.25; transition: opacity 0.4s, color 0.4s; margin: 8px 0; letter-spacing: 1px; }
.loading-steps li.on { opacity: 1; color: var(--cyber); }
.loading-pct { font-family: var(--font-mono); font-size: 28px; color: var(--bronze); }

/* ===== 结果页（文字与角色穿插层次，非左右分栏） ===== */
.result-inner { position: relative; width: 100%; }
.result-text { position: relative; z-index: 2; }
/* 角色图：绝对定位浮层。向左、向上移动并放大（38%–45%）；脸在右上，不被左侧文字遮挡 */
.result-character {
  position: absolute; top: -50px; right: 3%; width: 50%; height: 66vh;
  z-index: 1; pointer-events: none;
}
.result-character img {
  width: 100%; height: 100%; display: block; object-fit: contain; object-position: top right;
  filter: drop-shadow(0 8px 24px rgba(0,0,0,0.5));
}
/* 无角色图时隐藏浮层，文字占满整行 */
.result-inner.no-character .result-character { display: none; }
.brand-sm { font-family: var(--font-title); font-size: 12px; letter-spacing: 4px; color: var(--bronze); margin: 0 0 10px; opacity: 0.85; }
.result-label { font-size: 13px; color: rgba(244,232,210,0.6); letter-spacing: 2px; margin: 0 0 10px; }
.result-name { font-family: var(--font-title); font-size: 34px; line-height: 1.15; letter-spacing: 3px; margin: 0 0 14px; color: var(--moon); text-shadow: 0 0 14px rgba(255,51,78,0.25); }
.result-keywords { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 18px; }
.result-keywords span { font-size: 11px; letter-spacing: 1px; color: var(--neon); border: 1px solid rgba(255,51,78,0.45); border-radius: 20px; padding: 5px 12px; }
/* 行动建议卡片：宽 72%–78%，右侧覆盖角色身体/腿部约 10%–20%，与角色形成完整组合（无空隙） */
.result-advice {
  width: 90%; position: relative; z-index: 3;
  background: var(--advice-bg); border: 1px solid rgba(65,229,209,0.3); border-radius: 12px;
  padding: 16px 18px; margin: 14px 0 0;
  box-shadow: 0 8px 30px rgba(0,0,0,0.35);
  text-align: center;
}
.advice-tag { display: block; font-size: 11px; color: var(--cyber); letter-spacing: 2px; font-family: var(--font-mono); margin: 0; }
/* 今夜宜靠近 / 今夜宜主动 等：25–28px */
.advice-action { font-family: var(--font-title); font-size: 26px; letter-spacing: 2px; color: var(--accent); margin: 4px 0 0; font-weight: 600; text-shadow: 0 0 12px rgba(255,51,78,0.25); }
/* 行动建议正文：18–20px / 行高 1.55；避免碎片化换行（2–3 行） */
.result-advice p { width: 100%; text-align: center; margin: 10px 0 0; font-size: 19px; line-height: 1.55; color: var(--moon); font-weight: 500; text-wrap: pretty; overflow-wrap: break-word; }
/* 结果解析：与行动卡片间距 24–28px，行高 1.65–1.75 */
.result-desc { font-size: 15px; line-height: 1.7; color: rgba(244,232,210,0.6); margin: 30px 0 22px; }
/* 操作按钮区居中，让底部更饱满 */
.result-actions { display: flex; flex-direction: column; align-items: center; gap: 8px; margin-top: 24px; }
/* 小屏：角色略放大、卡片更宽，保持穿插层次 */
@media (max-width: 390px), (max-height: 720px) {
  .result-character { width: 44%; height: 62vh; }
  .result-advice { width: 84%; }
  .result-name { font-size: 30px; }
  .advice-action { font-size: 25px; }
  .result-advice p { font-size: 18px; }
  .result-desc { font-size: 14px; line-height: 1.7; margin: 26px 0 18px; }
  .result-actions { margin-top: 20px; }
}

/* ===== 优惠券弹窗 ===== */
.modal-mask { position: fixed; inset: 0; z-index: 20; background: rgba(5,3,6,0.78); backdrop-filter: blur(3px);
  display: none; align-items: center; justify-content: center; padding: 24px; padding-bottom: calc(24px + env(safe-area-inset-bottom)); }
.modal-mask.show { display: flex; animation: fadeIn 0.3s ease; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal-paper { position: relative; width: 100%; max-width: 340px; background: linear-gradient(160deg, #1c1018, #120a14);
  border: 1px solid rgba(182,146,85,0.5); border-radius: 16px; padding: 34px 26px 28px; text-align: center;
  box-shadow: 0 20px 60px rgba(0,0,0,0.6); animation: riseUp 0.45s cubic-bezier(0.2,0.9,0.3,1.2); }
@keyframes riseUp { from { transform: translateY(40px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.modal-stamp { position: absolute; top: -18px; left: 50%; transform: translateX(-50%) rotate(-8deg); width: 44px; height: 44px;
  background: var(--cinnabar); color: var(--moon); border-radius: 8px; display: flex; align-items: center; justify-content: center;
  font-family: var(--font-title); font-size: 24px; box-shadow: 0 0 16px rgba(214,47,54,0.5); }
.modal-paper h3 { font-family: var(--font-title); font-size: 21px; letter-spacing: 2px; margin: 8px 0 16px; color: var(--moon); }
.modal-paper p { font-size: 13px; line-height: 1.8; color: rgba(244,232,210,0.78); white-space: pre-line; margin: 0 0 22px; }
.modal-note { font-size: 11px !important; color: rgba(244,232,210,0.45) !important; margin: 16px 0 0 !important; }

/* ===== Toast（避开微信底部安全区） ===== */
.toast { position: fixed; left: 50%; bottom: calc(60px + env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(20px); z-index: 40;
  background: rgba(20,11,24,0.95); border: 1px solid rgba(182,146,85,0.5); color: var(--moon);
  padding: 13px 22px; border-radius: 30px; font-size: 13px; letter-spacing: 1px; opacity: 0; pointer-events: none;
  transition: opacity 0.3s, transform 0.3s; max-width: 86%; text-align: center; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ===== 分享页（DOM 卡片，CSS 控制布局；html2canvas 导出） ===== */
.poster-wrap { display: flex; flex-direction: column; align-items: center; gap: 14px; }
.poster-actions { display: flex; gap: 12px; }
.poster-actions .btn-primary, .poster-actions .btn-ghost { margin-top: 0; text-decoration: none; display: inline-flex; align-items: center; }

/* 整体纵向间距收紧（缩小约 20%–30%）；底部 28px 安全距离（24–32） */
.share-card {
  position: relative; width: 100%; max-width: 340px;
  background: linear-gradient(160deg, #1c1018, #120a14 58%, #090708);
  border: 1px solid rgba(182,146,85,0.5); border-radius: 16px;
  padding: 22px 20px 28px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.6); overflow: hidden;
}
/* 9. 顶部 Logo / 副标题 / 结果名称 / 关键词 间距统一收紧；为角色图留出右侧绝对定位空间 */
.share-head { position: relative; padding-right: 38%; }
.share-logo { font-family: var(--font-title); font-size: 14px; letter-spacing: 3px; color: var(--bronze); margin: 0; opacity: 0.9; }
.share-sub { font-family: var(--font-mono); font-size: 10px; letter-spacing: 2px; color: var(--cyber); margin: 2px 0 0; }
.share-label { font-size: 12px; color: rgba(244,232,210,0.6); letter-spacing: 2px; margin: 12px 0 0; }
.share-name { font-family: var(--font-title); font-size: 28px; line-height: 1.2; letter-spacing: 2px; margin: 6px 0 0; color: var(--moon); }
.share-keywords { display: flex; gap: 6px; flex-wrap: wrap; margin: 8px 0 0; }
.share-keywords span { font-size: 10px; letter-spacing: 1px; color: var(--neon); border: 1px solid rgba(255,51,78,0.4); border-radius: 16px; padding: 3px 9px; }
/* 角色图：右上角标题/关键词旁，占头部右侧空间 */
.share-character { position: absolute; top: 0; right: 0; width: 100%; height: 200%; z-index: 1; pointer-events: none; }
.share-character img { width: 110%; height: 100%; object-fit: contain; object-position: top right; display: block; filter: drop-shadow(0 6px 18px rgba(0,0,0,0.5)); }
/* 10. 金句 18–21px / 字重 500–600 / 行高 1.55–1.65 / 建议两行 */
.share-golden { font-family: var(--font-title); font-size: 20px; font-weight: 600; line-height: 1.6; color: rgba(244,232,210,0.92); margin: 18px 0 0; }
/* 11. 金句↔角色区域 28–36px；金句↔今夜宜做 32–40px */
.share-advice { position: relative; z-index: 3; width: 92%; margin: 34px auto 0;
  background: var(--advice-bg); border: 1px solid rgba(65,229,209,0.3); border-radius: 10px; padding: 12px 14px;
  text-align: center; }
/* 12. 今夜宜做模块内部间距收紧，三层级视觉上同一组 */
.share-advice-tag { display: block; font-family: var(--font-mono); font-size: 10px; color: var(--cyber); letter-spacing: 1px; margin: 0; }
.share-advice-action { font-family: var(--font-title); font-size: 22px; letter-spacing: 1px; color: var(--accent); font-weight: 600; margin: 3px 0 0; }
.share-advice p { margin: 4px 0 0; font-size: 14px; line-height: 1.5; color: var(--moon); font-weight: 500; text-wrap: pretty; }
/* 13. 二维码整体上移（紧凑布局）；与行动建议保留 42–52px；14. 说明距二维码 10–14px */
.share-qr { display: flex; flex-direction: column; align-items: center; margin-top: 46px; }
.share-qr img { width: 132px; height: 132px; border-radius: 8px; background: #F4E8D2; padding: 6px; }
.share-qr-tip { font-size: 12px; color: rgba(244,232,210,0.7); margin: 12px 0 0; text-align: center; letter-spacing: 1px; }

@media (max-height: 680px) {
  .title { font-size: 44px; }
  .page { padding-top: 30px; }
  .seal { top: 20px; }
}
/* ===== 结果页最终排版修正 V2 ===== */

/* 整组结果内容在手机页面中垂直居中 */
.page-result {
  justify-content: center !important;
  min-height: 100dvh;
  padding-top: 26px;
  padding-bottom: calc(26px + env(safe-area-inset-bottom));
}

/* 让结果内容在可用高度中居中，不再全部挤在顶部 */
.result-inner {
  margin-top: auto;
  margin-bottom: auto;
}

/* 结果标题与关键词的间距 */
.result-name {
  margin-bottom: 14px;
}

.result-keywords {
  margin-bottom: 20px;
}

/* “今夜宜做”绿色框居中，并增加与上方的距离 */
.result-advice {
  margin: 22px auto 0;
}

/* 绿色框内部三个文字层级的距离 */
.advice-action {
  margin-top: 8px;
}

.result-advice p {
  margin-top: 10px;
  line-height: 1.5;
}

/* 人格解析与绿色框拉开一点距离 */
.result-desc {
  line-height: 1.7;
  margin-top: 34px;
  margin-bottom: 0;
}

/* 按钮区域与人格解析之间增加距离 */
.result-actions {
  margin-top: 34px;
  align-items: center;
  gap: 16px;
}

/* 红色按钮和重新测试都居中 */
.result-actions .btn-primary,
.result-actions .btn-text {
  align-self: center;
}

/* 避免“重新测试”自身又增加多余顶部距离 */
.result-actions .btn-text {
  margin-top: 0;
}

/* 只有特别矮的手机才从顶部排列，避免内容被截断 */
@media (max-height: 620px) {
  .page-result {
    justify-content: flex-start !important;
  }

  .result-inner {
    margin-top: 0;
    margin-bottom: 0;
  }
}