/* ============================================================
   元神测试 · 生产样式
   ------------------------------------------------------------
   设计约束：
   · 全篇只允许一处大字号（族名），视线自然落在"我是谁"
   · 宣纸暖白底 + 深墨字 + 族色动态主题（--accent 由 JS 按种族切换）
   · 正文用衬线体、1.95 行距；UI 标签用无衬线体
   · 族色一律「淡底 + 深字」，不用作实底配白字（对比度不达标）
   ============================================================ */

:root {
  /* ---------- 底色层（宣纸暖白）---------- */
  --paper: #f7f2ea;        /* 页面底 */
  --paper-2: #fffdf8;      /* 卡片面 */
  --paper-3: #f0e9dc;      /* 凹陷/分隔块 */
  --paper-edge: #e6ddcc;   /* 纸边 */

  /* ---------- 墨色文字层 ---------- */
  --ink: #2a241f;          /* 标题 13.75:1 */
  --text: #2a241f;         /* 主文字 */
  --text-dim: #4a423a;     /* 正文 8.84:1 */
  --text-mid: #6b6259;     /* 次级 5.36:1 */
  --text-faint: #8d8378;   /* 弱化（非正文） */
  --text-strong: #3d362f;  /* 正文首段 */

  /* ---------- 描边 ---------- */
  --line: rgba(42, 36, 31, .10);
  --line2: rgba(42, 36, 31, .18);

  /* ---------- 金 / 朱 ---------- */
  --gold: #8a6a2c;         /* 4.51:1 —— 浅底上唯一可用的金 */
  --gold-soft: rgba(138, 106, 44, .10);
  --seal: #a8352a;

  /* ---------- 族色 ---------- */
  --accent: #3f6f8f;
  --accent-tint: color-mix(in srgb, var(--accent) 12%, var(--paper));
  --accent-deep: #3a5e76;   /* 由 JS 按种族注入族色深版（浅底文字用）*/
  --accent-line: color-mix(in srgb, var(--accent) 34%, transparent);
  --accent-soft: color-mix(in srgb, var(--accent) 12%, transparent);
  --accent-glow: color-mix(in srgb, var(--accent) 8%, transparent);

  --serif: "Songti SC", "STSong", "Noto Serif SC", "Source Han Serif SC", serif;
  --sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue",
          "Hiragino Sans GB", "Microsoft YaHei", sans-serif;

  --safe-b: env(safe-area-inset-bottom, 0px);
}

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

html { height: 100%; }

body {
  height: 100%;
  background: #efe9df;
  color: var(--text);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;   /* 阻止下拉刷新 */
}

/* 纸纹：极淡的纤维噪点，让暖白底不呆板 */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: .04;
  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='.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)'/%3E%3C/svg%3E");
}

#app {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  height: 100%;
  overflow: hidden;
  background: var(--paper);
  display: flex;
  flex-direction: column;
}

/* ---------- 屏切换 ---------- */
.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity .32s ease, visibility 0s linear .32s;
}
.screen.on {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transition: opacity .32s ease, visibility 0s;
}

/* 族色氛围：浅底上只能极淡，否则发浑 */
.screen::before {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(ellipse 92% 40% at 50% -10%, var(--accent-glow), transparent 70%),
    radial-gradient(ellipse 70% 34% at 10% 104%, rgba(168, 53, 42, .045), transparent 72%);
  opacity: 0;
  transition: opacity .8s ease;
}
.screen.on::before { opacity: 1; }

.scroll {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  position: relative;
  z-index: 1;
}
.scroll::-webkit-scrollbar { display: none; }

.pad { padding: 0 24px; }

/* ============================================================
   一 · 落地页（兑换）
   ============================================================ */
.land { padding: 44px 24px calc(40px + var(--safe-b)); text-align: center; }

.land h1 {
  font-family: var(--serif);
  font-size: 30px;
  font-weight: 500;
  letter-spacing: .1em;
  line-height: 1.4;
  margin-bottom: 12px;
  color: var(--ink);
}
.land .sub {
  font-size: 13px;
  color: var(--text-mid);
  letter-spacing: .16em;
  margin-bottom: 32px;
}

/* 立绘墙：浅底上羽化边缘，让 12 张画融进纸面 */
.wall {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin-bottom: 28px;
}
.wall .cell {
  aspect-ratio: 3 / 4;
  overflow: hidden;
  position: relative;
  background: transparent;
}
.wall .cell img {
  width: 100%; height: 100%;
  object-fit: cover;
  object-position: center 20%;
  opacity: 0;
  transition: opacity .55s ease;
  -webkit-mask-image: radial-gradient(120% 114% at 50% 48%, #000 70%, rgba(0, 0, 0, .72) 90%, transparent 100%);
  mask-image: radial-gradient(120% 114% at 50% 48%, #000 70%, rgba(0, 0, 0, .72) 90%, transparent 100%);
}
.wall .cell img.in { opacity: 1; }

.sample {
  margin: 0 auto 28px;
  max-width: 250px;
  padding: 18px 16px;
  border-radius: 12px;
  background: var(--paper-2);
  border: .5px solid var(--line);
  box-shadow: 0 10px 26px -18px rgba(74, 66, 58, .5);
}
.sample .k {
  font-size: 10px;
  letter-spacing: .18em;
  color: var(--gold);
  margin-bottom: 10px;
}
.sample .n {
  font-family: var(--serif);
  font-size: 21px;
  letter-spacing: .06em;
  margin-bottom: 6px;
  color: var(--ink);
}
.sample .s {
  font-family: var(--serif);
  font-size: 13px;
  line-height: 1.8;
  color: var(--text-dim);
  font-style: italic;
}

.gate { max-width: 320px; margin: 0 auto; }
.gate label {
  display: block;
  font-size: 11px;
  letter-spacing: .12em;
  color: var(--text-mid);
  margin-bottom: 9px;
  text-align: left;
}
.gate .row { display: flex; gap: 8px; }
.gate input {
  flex: 1;
  min-width: 0;
  padding: 12px 14px;
  border-radius: 10px;
  background: var(--paper-2);
  border: .5px solid var(--line2);
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  letter-spacing: .06em;
  outline: none;
  transition: border-color .2s, box-shadow .2s;
}
.gate input:focus {
  border-color: var(--accent-line);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
.gate input::placeholder { color: var(--text-faint); letter-spacing: .02em; }
.gate button {
  padding: 12px 20px;
  border-radius: 10px;
  border: none;
  background: var(--gold);
  color: #fffdf8;
  font-family: var(--serif);
  font-size: 14px;
  letter-spacing: .08em;
  cursor: pointer;
  flex-shrink: 0;
  transition: opacity .2s, transform .12s;
}
.gate button:active { transform: scale(.97); }
.gate button:disabled { opacity: .45; cursor: default; }

.gate .msg {
  margin-top: 12px;
  font-size: 12.5px;
  line-height: 1.7;
  min-height: 20px;
  color: var(--text-mid);
}
.gate .msg.err { color: #b8402f; }
.gate .msg.ok { color: #3f7a52; }

.land .foot {
  margin-top: 30px;
  font-size: 11px;
  color: var(--text-faint);
  letter-spacing: .1em;
  line-height: 2;
}

/* ============================================================
   二 · 答题页
   ============================================================ */
.quiz { padding: 0 24px calc(30px + var(--safe-b)); display: flex; flex-direction: column; min-height: 100%; }

.qhead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 0 0;
  flex-shrink: 0;
}
.qhead .cnt {
  font-size: 12px;
  letter-spacing: .14em;
  color: var(--text-mid);
  font-variant-numeric: tabular-nums;
}
.qhead .back {
  background: none;
  border: none;
  color: var(--text-mid);
  font-size: 12px;
  letter-spacing: .1em;
  cursor: pointer;
  padding: 4px 0;
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s;
}
.qhead .back.on { opacity: 1; pointer-events: auto; }

.qbar {
  height: 3px;
  background: var(--paper-3);
  border-radius: 3px;
  margin: 14px 0 0;
  overflow: hidden;
  flex-shrink: 0;
}
.qbar i {
  display: block;
  height: 100%;
  background: var(--accent);
  border-radius: 3px;
  transition: width .45s cubic-bezier(.25, .8, .3, 1);
}

.qbody { flex: 1; display: flex; flex-direction: column; justify-content: center; padding: 34px 0 20px; }

.qstage {
  font-size: 11px;
  letter-spacing: .2em;
  color: var(--gold);
  margin-bottom: 16px;
}
.qtitle {
  font-family: var(--serif);
  font-size: 22px;
  line-height: 1.6;
  color: var(--ink);
  margin-bottom: 30px;
}

.opts { display: flex; flex-direction: column; gap: 10px; }
.opt {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  width: 100%;
  padding: 15px 16px;
  border-radius: 12px;
  background: var(--paper-2);
  border: .5px solid var(--line);
  color: var(--text-dim);
  font-family: var(--serif);
  font-size: 15px;
  line-height: 1.6;
  text-align: left;
  cursor: pointer;
  box-shadow: 0 4px 14px -12px rgba(74, 66, 58, .45);
  transition: background .18s, border-color .18s, transform .12s, box-shadow .18s;
}
.opt:active { transform: scale(.985); background: var(--paper-3); }
.opt .k {
  flex-shrink: 0;
  width: 20px; height: 20px;
  border-radius: 50%;
  border: .5px solid var(--line2);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--sans);
  font-size: 11px;
  color: var(--text-faint);
  margin-top: 1px;
}
.opt.sel {
  background: var(--accent-tint);
  border-color: var(--accent-line);
  color: var(--ink);
}
.opt.sel .k { background: var(--accent-deep); border-color: var(--accent-deep); color: #fffdf8; }

.qhint {
  margin-top: 22px;
  font-size: 11px;
  color: var(--text-faint);
  letter-spacing: .08em;
  text-align: center;
  flex-shrink: 0;
}

/* ============================================================
   三 · 唤醒页
   ============================================================ */
.reveal {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 22px;
  padding: 24px;
}
.reveal .rname {
  font-family: var(--serif);
  font-size: 30px;
  letter-spacing: .12em;
  color: var(--ink);
  opacity: 0;
  transform: translateY(8px);
}
.reveal.on .rname { animation: rise .7s ease forwards; }
.reveal .glow {
  width: 190px; height: 190px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--accent-glow), transparent 68%);
  opacity: 0;
}
.reveal.on .glow { animation: glowPulse 1.6s ease forwards; }
@keyframes glowPulse {
  0% { opacity: 0; transform: scale(.6); }
  55% { opacity: 1; transform: scale(1.05); }
  100% { opacity: .8; transform: scale(1); }
}
@keyframes rise { to { opacity: 1; transform: none; } }

/* ============================================================
   四 · 结果页
   ============================================================ */
.res { text-align: center; padding: 26px 24px 0; }
.badge {
  display: inline-block;
  padding: 4px 13px;
  border-radius: 20px;
  background: var(--accent-tint);
  border: .5px solid var(--accent-line);
  font-size: 11px;
  letter-spacing: .14em;
  color: var(--accent-deep);
  margin-bottom: 14px;
  opacity: 0;
  transform: scale(.9);
}
.badge.in { animation: pop .45s cubic-bezier(.3, 1.4, .5, 1) forwards; }
@keyframes pop { to { opacity: 1; transform: none; } }

.rname {
  font-family: var(--serif);
  font-size: 34px;
  font-weight: 500;
  letter-spacing: .06em;
  line-height: 1.2;
  color: var(--ink);
}
.rsub {
  margin-top: 9px;
  font-family: var(--serif);
  font-size: 13px;
  color: var(--gold);
  letter-spacing: .12em;
}
.rmyth {
  margin-top: 5px;
  font-size: 11px;
  color: var(--text-faint);
  letter-spacing: .1em;
}

/* 立绘：羽化边缘 + 暖调投影，融进纸面而不是贴上去 */
.art {
  margin: 20px auto 0;
  position: relative;
  width: 78%;
  max-width: 304px;
  opacity: 0;
  transform: translateY(22px) scale(.965);
}
.art.in { animation: emerge .8s cubic-bezier(.16, .84, .34, 1) forwards; }
@keyframes emerge { to { opacity: 1; transform: none; } }
.art img {
  display: block;
  width: 100%;
  -webkit-mask-image: radial-gradient(128% 120% at 50% 48%, #000 78%, rgba(0, 0, 0, .82) 92%, transparent 100%);
  mask-image: radial-gradient(128% 120% at 50% 48%, #000 78%, rgba(0, 0, 0, .82) 92%, transparent 100%);
  filter: drop-shadow(0 12px 26px rgba(74, 66, 58, .13));
}

.purity {
  margin: 16px auto 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  opacity: 0;
}
.purity.in { animation: rise .5s ease .1s forwards; }
.purity .bar { width: 96px; height: 3px; background: var(--paper-3); border-radius: 3px; overflow: hidden; }
.purity .fill { height: 100%; background: var(--accent); border-radius: 3px; width: 0; transition: width 1s ease; }
.purity .lbl { font-size: 11px; color: var(--text-mid); letter-spacing: .08em; white-space: nowrap; }

.lead {
  margin: 24px auto 0;
  max-width: 310px;
  padding: 0 0 0 16px;
  border-left: 2px solid var(--accent-line);
  font-family: var(--serif);
  font-size: 15px;
  line-height: 1.85;
  color: var(--text-dim);
  font-style: italic;
  text-align: left;
  opacity: 0;
}
.lead.in { animation: rise .6s ease .18s forwards; }

.kw {
  margin: 20px 0 0;
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  justify-content: center;
  opacity: 0;
}
.kw.in { animation: rise .6s ease .26s forwards; }
.kw span {
  padding: 4px 11px;
  border-radius: 20px;
  font-size: 12px;
  color: var(--accent-deep);
  border: .5px solid var(--accent-line);
  background: var(--accent-tint);
}

/* ---------- 滚动区 ---------- */
.section { padding: 34px 24px 0; }
.sechead { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }
.sechead h3 {
  font-family: var(--serif);
  font-size: 15px;
  font-weight: 500;
  letter-spacing: .1em;
  color: var(--ink);
}
.sechead .rule { flex: 1; height: .5px; background: var(--line); }
.sechead .hint { font-size: 11px; color: var(--text-faint); }

.radar { display: flex; justify-content: center; }
.radar svg { width: 100%; max-width: 290px; height: auto; overflow: visible; }
.legend {
  display: flex; gap: 16px; justify-content: center;
  margin-top: 8px; font-size: 11px; color: var(--text-mid);
}
.legend i {
  display: inline-block; width: 14px; height: 2px;
  margin-right: 5px; vertical-align: middle; border-radius: 2px;
}

.body p {
  font-family: var(--serif);
  font-size: 14.5px;
  line-height: 1.95;
  color: var(--text-dim);
  margin-bottom: 17px;
  text-align: justify;
}
.body p:first-child { color: var(--text-strong); }
.body p:last-child { margin-bottom: 0; }

.advice {
  padding: 16px 18px;
  border-radius: 12px;
  background: var(--accent-tint);
  border: .5px solid var(--accent-line);
}
.advice .k { font-size: 11px; letter-spacing: .14em; color: var(--gold); margin-bottom: 8px; }
.advice .v { font-family: var(--serif); font-size: 14.5px; line-height: 1.85; color: var(--text-strong); }

.acts { display: flex; gap: 10px; }
.acts button {
  flex: 1;
  padding: 14px 0;
  border-radius: 12px;
  cursor: pointer;
  font-family: var(--serif);
  font-size: 15px;
  letter-spacing: .08em;
  transition: transform .12s, opacity .2s;
}
.acts button:active { transform: scale(.985); }
.acts button.primary { background: var(--gold); border: none; color: #fffdf8; }
.acts button.ghost { background: transparent; border: .5px solid var(--gold); color: var(--gold); }

.allroles {
  margin-top: 14px;
  text-align: center;
  font-size: 11px;
  color: var(--text-mid);
  letter-spacing: .1em;
  cursor: pointer;
  background: none;
  border: none;
  padding: 8px;
  width: 100%;
}

.foot {
  padding: 30px 24px calc(40px + var(--safe-b));
  text-align: center;
  font-size: 11px;
  color: var(--text-faint);
  letter-spacing: .08em;
  line-height: 2;
}

/* ============================================================
   五 · 分享图保存层
   ============================================================ */
#saveMask {
  position: absolute;
  inset: 0;
  z-index: 30;
  background: rgba(58, 50, 42, .62);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
#saveMask.on { display: flex; }
#saveImg {
  max-width: 100%;
  max-height: 76vh;
  border-radius: 6px;
  box-shadow: 0 24px 60px -18px rgba(58, 50, 42, .55);
  -webkit-user-select: none;
  user-select: none;
}
#saveTip {
  margin-top: 16px;
  font-size: 12px;
  color: #fffdf8;
  letter-spacing: .1em;
  text-align: center;
  line-height: 1.9;
  text-shadow: 0 1px 6px rgba(58, 50, 42, .5);
}
#saveTip b { color: #f0d9a8; font-weight: 400; }
#saveClose {
  margin-top: 18px;
  padding: 10px 26px;
  border-radius: 20px;
  background: rgba(255, 253, 248, .16);
  border: .5px solid rgba(255, 253, 248, .4);
  color: #fffdf8;
  font-size: 13px;
  cursor: pointer;
}

/* ============================================================
   六 · 12 族一览
   ============================================================ */
.modal {
  position: absolute;
  inset: 0;
  z-index: 25;
  background: var(--paper);
  display: none;
  flex-direction: column;
}
.modal.on { display: flex; }
.modal .mhead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px 12px;
  border-bottom: .5px solid var(--line);
  background: var(--paper);
}
.modal .mhead h3 { font-family: var(--serif); font-size: 15px; font-weight: 500; letter-spacing: .1em; color: var(--ink); }
.modal .mhead button {
  background: none; border: none; color: var(--text-mid);
  font-size: 13px; cursor: pointer; padding: 4px;
}
.modal .mlist {
  flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding: 8px 24px calc(30px + var(--safe-b));
}
.mrow {
  display: flex; gap: 14px; align-items: center;
  padding: 12px 0;
  border-bottom: .5px solid var(--line);
}
.mrow img {
  width: 44px; height: 60px;
  object-fit: cover; object-position: center 20%;
  border-radius: 4px; flex-shrink: 0;
  -webkit-mask-image: radial-gradient(118% 112% at 50% 48%, #000 66%, rgba(0, 0, 0, .7) 88%, transparent 100%);
  mask-image: radial-gradient(118% 112% at 50% 48%, #000 66%, rgba(0, 0, 0, .7) 88%, transparent 100%);
}
.mrow .mi { min-width: 0; }
.mrow .mn { font-family: var(--serif); font-size: 16px; letter-spacing: .06em; margin-bottom: 4px; color: var(--ink); }
.mrow .mk { font-size: 11px; color: var(--text-faint); letter-spacing: .06em; }

/* ---------- 动画偏好 ---------- */
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
