/* ============ 另世我 · 镜面双世界 ============ */
:root {
  --paper: #f3eee3;        /* 此世 · 宣纸 */
  --paper-deep: #e9e2d2;
  --ink: #1a1714;          /* 墨 */
  --ink-soft: #4a443c;
  --night: #121013;        /* 彼世 · 夜 */
  --night-card: #1b181c;
  --moon: #ece5d8;         /* 彼世的字 */
  --moon-dim: #9a948b;
  --cinnabar: #c3272b;     /* 朱砂 */
  --cinnabar-bright: #e04a4e;
  --serif: 'Noto Serif SC', 'Songti SC', serif;
  --kai: 'LXGW WenKai Screen', 'Kaiti SC', serif;
}

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

html, body { height: 100%; }

body {
  font-family: var(--kai);
  background: var(--paper);
  color: var(--ink);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* 纸纹 */
.grain {
  position: fixed; inset: 0; z-index: 50; pointer-events: none;
  opacity: 0.5; mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3CfeColorMatrix values='0 0 0 0 0.5 0 0 0 0 0.48 0 0 0 0 0.44 0 0 0 0.06 0'/%3E%3C/filter%3E%3Crect width='180' height='180' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ============ 屏幕切换 ============ */
.screen { display: none; min-height: 100vh; min-height: 100dvh; }
.screen.active { display: flex; align-items: center; justify-content: center; }

.btn {
  font-family: var(--kai);
  border: none; cursor: pointer; background: none;
  transition: transform 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease;
}
.btn:active { transform: scale(0.97); }

.btn-primary {
  background: var(--ink); color: var(--paper);
  font-size: 17px; letter-spacing: 0.18em;
  padding: 16px 36px;
  box-shadow: 4px 4px 0 var(--cinnabar);
}
.btn-primary:hover { box-shadow: 6px 6px 0 var(--cinnabar); transform: translate(-1px, -1px); }

/* ============ 落地页 ============ */
#screen-landing { background: var(--paper); position: relative; }
.landing-inner {
  text-align: center; padding: 48px 24px;
  display: flex; flex-direction: column; align-items: center;
  animation: rise 0.9s ease both;
}
.landing-kicker {
  font-size: 15px; letter-spacing: 0.6em; text-indent: 0.6em;
  color: var(--cinnabar); margin-bottom: 18px;
}
.landing-title {
  font-family: var(--serif); font-weight: 900;
  font-size: clamp(96px, 24vw, 168px);
  line-height: 1; letter-spacing: 0.04em;
  display: flex;
}
.landing-title .flip-me { transform: scaleX(-1); color: var(--cinnabar); }
.landing-reflection {
  font-family: var(--serif); font-weight: 900;
  font-size: clamp(96px, 24vw, 168px);
  line-height: 1; letter-spacing: 0.04em;
  display: flex;
  transform: scaleY(-1); margin-top: 6px;
  -webkit-mask-image: linear-gradient(to top, rgba(0,0,0,0.22), transparent 70%);
  mask-image: linear-gradient(to top, rgba(0,0,0,0.22), transparent 70%);
}
.landing-reflection .flip-me { transform: scaleX(-1); color: var(--cinnabar); }
.landing-sub {
  font-size: 18px; line-height: 2; color: var(--ink-soft);
  margin: 8px 0 36px;
}
.landing-sub em { font-style: normal; color: var(--cinnabar); border-bottom: 1px solid var(--cinnabar); }
.landing-foot { margin-top: 28px; font-size: 12px; letter-spacing: 0.2em; color: var(--moon-dim); }

@keyframes rise {
  from { opacity: 0; transform: translateY(24px); }
  to { opacity: 1; transform: none; }
}

/* ============ 答题页 ============ */
#screen-quiz { background: var(--paper); }
.quiz-inner {
  width: 100%; max-width: 520px; padding: 32px 24px 56px;
  min-height: 100dvh; display: flex; flex-direction: column;
}
.quiz-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12vh; }
.quiz-progress { display: flex; gap: 7px; }
.quiz-progress i {
  width: 14px; height: 4px; background: var(--paper-deep);
  transition: background 0.3s;
}
.quiz-progress i.done { background: var(--ink); }
.quiz-progress i.now { background: var(--cinnabar); }
.quiz-count { font-size: 13px; letter-spacing: 0.15em; color: var(--moon-dim); }
.quiz-count span { color: var(--cinnabar); font-size: 16px; }

.quiz-body { flex: 1; }
.quiz-body.slide-in { animation: slideIn 0.35s ease both; }
@keyframes slideIn {
  from { opacity: 0; transform: translateX(28px); }
  to { opacity: 1; transform: none; }
}
.quiz-q {
  font-family: var(--serif); font-weight: 700;
  font-size: clamp(24px, 6vw, 30px); line-height: 1.6;
  margin-bottom: 40px; min-height: 2.6em;
}
.quiz-options { display: flex; flex-direction: column; gap: 16px; }
.option {
  font-family: var(--kai);
  display: flex; align-items: center; gap: 16px;
  text-align: left; font-size: 17px; line-height: 1.7;
  padding: 20px 20px; color: var(--ink);
  background: rgba(255,255,255,0.55);
  border: 1.5px solid var(--ink);
  transition: all 0.15s ease;
}
/* 仅鼠标设备启用悬停变色;触屏上 hover 会粘在点过的选项,像预选了黑框 */
@media (hover: hover) and (pointer: fine) {
  .option:hover { background: var(--ink); color: var(--paper); }
  .option:hover .option-mark { color: var(--cinnabar-bright); }
}
.option.picked { background: var(--cinnabar); border-color: var(--cinnabar); color: #fff; }
.option-mark {
  font-family: var(--serif); font-weight: 900; font-size: 22px;
  color: var(--cinnabar); flex-shrink: 0;
}
.quiz-back {
  margin-top: 28px; padding: 8px 0;
  color: var(--moon-dim); font-size: 14px; letter-spacing: 0.12em;
}
.quiz-back:hover { color: var(--ink); }
.quiz-back.hidden { visibility: hidden; }

/* ============ 翻世动画 ============ */
#screen-reveal { background: var(--night); position: relative; overflow: hidden; }
.reveal-pane {
  position: absolute; top: 0; bottom: 0; width: 50.5%;
  background: var(--paper); z-index: 2;
}
.reveal-pane.left { left: 0; }
.reveal-pane.right { right: 0; }
#screen-reveal.active .reveal-pane.left { animation: paneL 1.15s cubic-bezier(0.7, 0, 0.3, 1) 1.05s forwards; }
#screen-reveal.active .reveal-pane.right { animation: paneR 1.15s cubic-bezier(0.7, 0, 0.3, 1) 1.05s forwards; }
@keyframes paneL { to { transform: translateX(-101%); } }
@keyframes paneR { to { transform: translateX(101%); } }

.reveal-seam {
  position: absolute; left: 50%; top: 0; width: 2px; height: 100%;
  margin-left: -1px; z-index: 3; transform-origin: top;
  background: linear-gradient(to bottom, transparent, var(--cinnabar) 30%, var(--cinnabar) 70%, transparent);
  box-shadow: 0 0 18px rgba(195, 39, 43, 0.55);
}
#screen-reveal.active .reveal-seam {
  animation: seamGrow 0.95s cubic-bezier(0.6, 0, 0.2, 1) both,
             seamFade 0.8s ease 1.5s forwards;
}
@keyframes seamGrow { from { transform: scaleY(0); } to { transform: scaleY(1); } }
@keyframes seamFade { to { opacity: 0; } }

.reveal-text {
  position: absolute; left: 0; right: 0; top: 50%;
  margin-top: -0.7em; text-align: center;
  font-size: 16px; letter-spacing: 0.6em; text-indent: 0.6em;
  opacity: 0;
}
.reveal-text.t1 { color: var(--ink); z-index: 4; }
.reveal-text.t2 { color: var(--moon); z-index: 1; }
#screen-reveal.active .t1 { animation: textIn 0.55s ease 0.25s forwards, textOut 0.4s ease 1.0s forwards; }
#screen-reveal.active .t2 { animation: textIn 0.9s ease 1.7s forwards; }
@keyframes textIn { from { opacity: 0; letter-spacing: 0.95em; } to { opacity: 1; letter-spacing: 0.6em; } }
@keyframes textOut { to { opacity: 0; } }

/* ============ 结果页 · 彼世 ============ */
.otherworld { background: var(--night); color: var(--moon); }
.result-inner {
  width: 100%; max-width: 480px; padding: 40px 20px 64px;
}

/* 结果页分层入场 */
.otherworld.active .result-card { animation: rise 0.7s ease both; }
.otherworld.active .seal {
  animation: stamp 0.5s cubic-bezier(0.2, 1.5, 0.4, 1) 0.45s both;
}
@keyframes stamp {
  from { opacity: 0; transform: scale(2.1) rotate(-7deg); }
  60% { opacity: 1; }
  to { opacity: 1; transform: scale(1) rotate(0deg); }
}
.otherworld.active .seal-caption { animation: fadeUp 0.5s ease 0.85s both; }
.otherworld.active .result-name { animation: fadeUp 0.55s ease 1.0s both; }
.otherworld.active .result-tags { animation: fadeUp 0.5s ease 1.15s both; }
.otherworld.active .result-story,
.otherworld.active .result-quote { animation: fadeUp 0.6s ease 1.3s both; }
.otherworld.active .result-dims,
.otherworld.active .result-foot { animation: fadeUp 0.6s ease 1.5s both; }
.otherworld.active .result-actions { animation: fadeUp 0.6s ease 1.8s both; }
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: none; }
}
.result-card {
  background: var(--night-card);
  border: 1px solid rgba(236,229,216,0.14);
  padding: 36px 26px 28px;
  position: relative;
}
.result-card::before {
  content: ''; position: absolute; inset: 8px;
  border: 1px solid rgba(236,229,216,0.08); pointer-events: none;
}
.result-kicker {
  text-align: center; font-size: 12px; letter-spacing: 0.4em; text-indent: 0.4em;
  color: var(--moon-dim); margin-bottom: 26px;
}
.result-head { text-align: center; margin-bottom: 30px; }

/* 朱砂印章:另世我四字 */
.seal {
  width: 84px; height: 84px; margin: 0 auto 20px;
  background: var(--cinnabar);
  display: grid; grid-template-columns: 1fr 1fr;
  align-items: center; justify-items: center;
  padding: 8px;
  font-family: var(--serif); font-weight: 900; font-size: 26px; color: #f6efe2;
  box-shadow: 0 0 34px rgba(195,39,43,0.4);
}
.seal-caption {
  font-size: 12.5px; letter-spacing: 0.22em;
  color: var(--moon-dim); margin: -8px 0 18px;
}

.result-name {
  font-family: var(--serif); font-weight: 900;
  font-size: clamp(28px, 7.4vw, 34px); line-height: 1.4;
  margin-bottom: 12px;
}
.result-tags { font-size: 13px; letter-spacing: 0.1em; color: var(--cinnabar-bright); }

.result-story p {
  font-size: 15.5px; line-height: 2.05; color: rgba(236,229,216,0.86);
  margin-bottom: 14px; text-align: justify;
}
.result-story p:first-child::first-letter { color: var(--cinnabar-bright); }

.result-quote {
  margin: 26px 0 30px; padding: 20px 18px;
  border-left: 2px solid var(--cinnabar);
  background: rgba(195,39,43,0.07);
}
.result-quote-label { font-size: 12px; letter-spacing: 0.3em; color: var(--moon-dim); margin-bottom: 10px; }
.result-quote-text {
  font-family: var(--serif); font-weight: 700;
  font-size: 18px; line-height: 1.9;
}

/* 镜像维度条 */
.result-dims-label {
  display: flex; justify-content: space-between;
  font-size: 12px; letter-spacing: 0.12em; color: var(--moon-dim);
  margin-bottom: 14px;
}
.result-dims-label span:last-child { color: var(--cinnabar-bright); }
.dim-row { margin-bottom: 16px; }
.dim-words {
  display: flex; justify-content: space-between; align-items: baseline;
  font-size: 13.5px; margin-bottom: 6px;
}
.dim-words .w-you { color: var(--moon); }
.dim-words .w-ta { color: var(--cinnabar-bright); }
.dim-words b { font-family: var(--serif); font-size: 15px; }
.dim-track {
  display: flex; height: 10px;
  background: rgba(236,229,216,0.08);
}
.dim-half { flex: 1; position: relative; }
.dim-half .fill {
  position: absolute; top: 0; height: 100%;
  transition: width 0.8s cubic-bezier(0.22, 1, 0.36, 1);
}
.dim-half.you .fill { right: 0; background: var(--moon); }
.dim-half.ta .fill { left: 0; background: var(--cinnabar); }
.dim-track .axis { width: 2px; background: var(--night-card); }

.result-foot {
  margin-top: 26px; padding-top: 18px;
  border-top: 1px solid rgba(236,229,216,0.1);
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
.result-brand {
  font-family: var(--serif); font-weight: 900;
  font-size: 18px; letter-spacing: 0.2em; margin-bottom: 6px;
}
.result-brand-sub {
  font-size: 11px; letter-spacing: 0.18em; color: var(--moon-dim); line-height: 1.8;
}
.result-qr {
  flex-shrink: 0; padding: 5px; background: var(--moon);
}
.result-qr img, .result-qr canvas { display: block; width: 62px; height: 62px; }

.result-actions { display: flex; flex-direction: column; gap: 14px; margin-top: 28px; }
.result-actions .btn-primary { box-shadow: 4px 4px 0 rgba(195,39,43,0.55); }
.btn-ghost {
  color: var(--moon); border: 1px solid rgba(236,229,216,0.35);
  font-size: 15px; letter-spacing: 0.06em; padding: 14px 20px;
}
.btn-ghost:hover { border-color: var(--moon); background: rgba(236,229,216,0.06); }
.btn-text { color: var(--moon-dim); font-size: 13px; letter-spacing: 0.15em; padding: 6px; }
.btn-text:hover { color: var(--moon); }

/* 保存卡片全屏浮层(微信内长按保存) */
.save-overlay {
  position: fixed; inset: 0; z-index: 90;
  background: rgba(10, 9, 11, 0.95);
  display: none; flex-direction: column; align-items: center; justify-content: center;
  gap: 18px; padding: 24px;
}
.save-overlay.show { display: flex; }
.save-overlay img {
  max-width: 82%; max-height: 68vh; object-fit: contain;
  box-shadow: 0 12px 60px rgba(0,0,0,0.8);
}
.save-hint {
  font-family: var(--serif); font-weight: 700;
  font-size: 17px; letter-spacing: 0.2em; color: var(--moon);
}
.save-hint::before { content: '↓ '; color: var(--cinnabar-bright); }
.save-close { font-size: 12px; letter-spacing: 0.2em; color: var(--moon-dim); }

/* toast */
.toast {
  position: fixed; left: 50%; bottom: 40px; transform: translateX(-50%) translateY(20px);
  background: var(--moon); color: var(--night);
  font-family: var(--kai); font-size: 14px; letter-spacing: 0.08em;
  padding: 12px 22px; opacity: 0; pointer-events: none;
  transition: all 0.3s ease; z-index: 99;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (min-width: 720px) {
  .quiz-top { margin-bottom: 9vh; }
}
