/* ============================================================
 *  历史名人匹配 · 样式
 *  风格：小红书爆款帖 / 奶油粉 + 珊瑚红 / 卡片式
 * ============================================================ */

:root {
  --red: #ff2e4d;
  --red-deep: #e01e3c;
  --coral: #ff7a59;
  --cream: #fff8f2;
  --ink: #2b2320;
  --ink-2: #6b5f5a;
  --ink-3: #a2968f;
  --line: #f0e2d8;
  --card: #ffffff;
  --shadow: 0 10px 30px rgba(178, 106, 84, .12);
  --shadow-lg: 0 18px 50px rgba(178, 106, 84, .18);
  --radius: 22px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

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

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
               "Microsoft YaHei", "Noto Sans SC", "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(1200px 600px at 8% -8%, #ffd9cd 0%, rgba(255,217,205,0) 60%),
    radial-gradient(900px 500px at 100% 0%, #ffe6ef 0%, rgba(255,230,239,0) 55%),
    linear-gradient(180deg, #fff5ee 0%, #fffaf6 40%, #fff6f1 100%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  line-height: 1.65;
}

/* 背景漂浮小字，增加"爆款封面感" */
.bg-deco {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 0;
  font-weight: 900;
  color: rgba(255, 46, 77, .05);
  letter-spacing: .1em;
  user-select: none;
}
.bg-deco span {
  position: absolute;
  white-space: nowrap;
  animation: floaty 18s ease-in-out infinite;
}
.bg-deco span:nth-child(1) { top: 6%;  left: -4%; font-size: 64px; animation-delay: 0s; }
.bg-deco span:nth-child(2) { top: 24%; right: -6%; font-size: 48px; animation-delay: -3s; }
.bg-deco span:nth-child(3) { top: 52%; left: -8%; font-size: 56px; animation-delay: -6s; }
.bg-deco span:nth-child(4) { top: 74%; right: -4%; font-size: 40px; animation-delay: -9s; }
.bg-deco span:nth-child(5) { top: 88%; left: 6%; font-size: 52px; animation-delay: -12s; }
@keyframes floaty {
  0%, 100% { transform: translateY(0) rotate(-2deg); }
  50%      { transform: translateY(-18px) rotate(2deg); }
}

.app {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 520px;
  margin: 0 auto;
  padding: 18px 18px calc(40px + var(--safe-b));
}

/* ---------------- 顶部 ---------------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 2px 18px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  font-weight: 900;
  font-size: 15px;
  letter-spacing: .02em;
}
.brand .dot {
  width: 26px; height: 26px;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--red), var(--coral));
  display: grid; place-items: center;
  color: #fff; font-size: 13px;
  box-shadow: 0 5px 14px rgba(255, 46, 77, .35);
}
.topbar .mini {
  font-size: 12px;
  color: var(--ink-3);
  background: #fff;
  border: 1px solid var(--line);
  padding: 5px 10px;
  border-radius: 999px;
}

/* ---------------- 通用卡片 ---------------- */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid rgba(240, 226, 216, .8);
  padding: 22px;
}

/* ---------------- 封面 ---------------- */
.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: linear-gradient(135deg, #ffe1e6, #fff0e6);
  color: var(--red-deep);
  font-size: 12px;
  font-weight: 800;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid #ffd2d9;
}
.hero-badge .pulse {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--red);
  box-shadow: 0 0 0 0 rgba(255,46,77,.6);
  animation: pulse 1.8s infinite;
}
@keyframes pulse {
  70%  { box-shadow: 0 0 0 8px rgba(255,46,77,0); }
  100% { box-shadow: 0 0 0 0 rgba(255,46,77,0); }
}

h1.hero-title {
  font-size: 34px;
  line-height: 1.22;
  margin: 16px 0 10px;
  letter-spacing: -.02em;
  font-weight: 900;
}
h1.hero-title em {
  font-style: normal;
  position: relative;
  color: var(--red-deep);
  white-space: nowrap;
}
h1.hero-title em::after {
  content: "";
  position: absolute;
  left: -2px; right: -2px; bottom: 3px;
  height: 9px;
  background: linear-gradient(90deg, #ffd0d8, #ffe3cf);
  z-index: -1;
  border-radius: 4px;
  transform: rotate(-1.2deg);
}
.hero-sub {
  font-size: 14.5px;
  color: var(--ink-2);
  margin: 0 0 18px;
}
.hero-sub b { color: var(--ink); }

.tags { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 20px; }
.tag {
  font-size: 12px;
  color: var(--red-deep);
  background: #fff2f4;
  border: 1px solid #ffdde2;
  padding: 4px 10px;
  border-radius: 8px;
  font-weight: 600;
}

/* 统计条 */
.stat-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 0 0 20px;
}
.stat {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 12px 10px;
  text-align: center;
}
.stat b { display: block; font-size: 19px; color: var(--red-deep); letter-spacing: -.02em; }
.stat span { font-size: 11.5px; color: var(--ink-3); }

/* 按钮 */
.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  border: 0;
  cursor: pointer;
  font-family: inherit;
  font-size: 16.5px;
  font-weight: 800;
  color: #fff;
  padding: 16px 20px;
  border-radius: 18px;
  background: linear-gradient(135deg, #ff3a5c, #ff7a59);
  box-shadow: 0 12px 26px rgba(255, 58, 92, .34);
  transition: transform .12s ease, box-shadow .12s ease, opacity .2s;
  letter-spacing: .02em;
}
.btn:active { transform: translateY(2px) scale(.99); box-shadow: 0 6px 16px rgba(255,58,92,.28); }
.btn.ghost {
  background: #fff;
  color: var(--ink);
  border: 1.5px solid var(--line);
  box-shadow: none;
}
.btn.ghost:active { background: #fff8f4; }
.btn.small { font-size: 14px; padding: 12px 16px; border-radius: 14px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.hint {
  text-align: center;
  font-size: 12px;
  color: var(--ink-3);
  margin: 12px 0 0;
}

/* 预览结果轮播（社会认同） */
.peek {
  margin-top: 24px;
}
.peek-title {
  font-size: 12.5px;
  color: var(--ink-3);
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}
.peek-title::after {
  content: ""; flex: 1; height: 1px; background: var(--line);
}
.peek-list { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
.peek-list::-webkit-scrollbar { display: none; }
.peek-item {
  flex: 0 0 auto;
  min-width: 132px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 12px;
  box-shadow: 0 6px 16px rgba(178,106,84,.07);
}
.peek-item .p-name { font-weight: 900; font-size: 15px; }
.peek-item .p-desc { font-size: 11.5px; color: var(--ink-3); line-height: 1.5; margin-top: 3px; }
.peek-item .p-ball {
  width: 34px; height: 34px; border-radius: 12px;
  display: grid; place-items: center; font-size: 17px;
  background: linear-gradient(135deg,#fff0e6,#ffe0e6);
  margin-bottom: 8px;
}

/* ---------------- 答题 ---------------- */
.progress-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}
.progress-track {
  flex: 1;
  height: 7px;
  background: #f6e6dc;
  border-radius: 999px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, #ff3a5c, #ffb35c);
  transition: width .35s cubic-bezier(.4, 0, .2, 1);
}
.progress-text { font-size: 12px; color: var(--ink-3); font-weight: 700; white-space: nowrap; }

.q-scene {
  display: inline-block;
  font-size: 11.5px;
  font-weight: 800;
  color: var(--coral);
  background: #fff3ec;
  border-radius: 6px;
  padding: 3px 8px;
  margin-bottom: 10px;
}
.q-title {
  font-size: 21px;
  font-weight: 900;
  line-height: 1.45;
  margin: 0 0 18px;
  letter-spacing: -.01em;
}
.opt {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  width: 100%;
  text-align: left;
  background: #fffdfb;
  border: 1.5px solid var(--line);
  border-radius: 16px;
  padding: 14px 15px;
  margin-bottom: 10px;
  cursor: pointer;
  font-family: inherit;
  font-size: 14.8px;
  line-height: 1.55;
  color: var(--ink);
  transition: all .16s ease;
}
.opt:hover { border-color: #ffc9ba; background: #fff9f5; }
.opt:active { transform: scale(.992); }
.opt .key {
  flex: 0 0 auto;
  width: 24px; height: 24px;
  border-radius: 8px;
  background: #f7ece5;
  color: var(--ink-2);
  font-size: 12px;
  font-weight: 800;
  display: grid; place-items: center;
  margin-top: 1px;
  transition: all .16s ease;
}
.opt.sel {
  border-color: var(--red);
  background: #fff5f6;
  box-shadow: 0 8px 20px rgba(255,46,77,.13);
}
.opt.sel .key { background: var(--red); color: #fff; }

/* 基础信息表单 */
.field { margin-bottom: 16px; }
.field label {
  display: block;
  font-size: 13px;
  font-weight: 800;
  margin-bottom: 7px;
  color: var(--ink);
}
.field label span { font-weight: 500; color: var(--ink-3); font-size: 12px; }
.input, .select {
  width: 100%;
  font-family: inherit;
  font-size: 15px;
  color: var(--ink);
  background: #fffdfb;
  border: 1.5px solid var(--line);
  border-radius: 14px;
  padding: 13px 14px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
  appearance: none;
  -webkit-appearance: none;
}
.input:focus, .select:focus {
  border-color: #ffb9a8;
  box-shadow: 0 0 0 4px rgba(255,122,89,.12);
}
.select {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8'><path d='M1 1l5 5 5-5' stroke='%23a2968f' stroke-width='2' fill='none' stroke-linecap='round'/></svg>");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 38px;
}
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  font-family: inherit;
  font-size: 13px;
  padding: 8px 13px;
  border-radius: 999px;
  border: 1.5px solid var(--line);
  background: #fffdfb;
  color: var(--ink-2);
  cursor: pointer;
  transition: all .15s;
}
.chip.on {
  border-color: var(--red);
  background: #fff0f2;
  color: var(--red-deep);
  font-weight: 800;
}
.chip:active { transform: scale(.97); }

/* ---------------- 计算中 ---------------- */
.loading { text-align: center; padding: 56px 12px 60px; }
.loading .ball {
  width: 76px; height: 76px;
  margin: 0 auto 22px;
  border-radius: 26px;
  background: linear-gradient(135deg, #ff3a5c, #ffb35c);
  display: grid; place-items: center;
  font-size: 34px;
  animation: spinPulse 1.6s ease-in-out infinite;
  box-shadow: 0 16px 36px rgba(255,58,92,.3);
}
@keyframes spinPulse {
  0%,100% { transform: rotate(-8deg) scale(1); }
  50%     { transform: rotate(8deg) scale(1.06); }
}
.loading .ld-title { font-size: 18px; font-weight: 900; margin-bottom: 8px; }
.loading .ld-tip { font-size: 13px; color: var(--ink-3); min-height: 22px; }
.loading .ld-bar {
  width: 180px; height: 6px; margin: 22px auto 0;
  background: #f8e7dd; border-radius: 999px; overflow: hidden;
}
.loading .ld-bar i {
  display: block; height: 100%; width: 0;
  background: linear-gradient(90deg, #ff3a5c, #ffb35c);
  border-radius: 999px;
  transition: width .3s linear;
}

/* ---------------- 结果 ---------------- */
.result-head { text-align: center; padding: 6px 0 4px; }
.r-kicker {
  font-size: 12px;
  letter-spacing: .22em;
  color: var(--ink-3);
  font-weight: 800;
}
.r-emoji {
  font-size: 54px;
  line-height: 1;
  margin: 14px 0 6px;
  filter: drop-shadow(0 10px 18px rgba(255,122,89,.25));
}
.r-name {
  font-size: 42px;
  font-weight: 900;
  letter-spacing: .04em;
  margin: 0;
  line-height: 1.15;
  background: linear-gradient(135deg, #2b2320, #7a4a3a);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.r-en { font-size: 12px; letter-spacing: .18em; color: var(--ink-3); text-transform: uppercase; margin: 4px 0 10px; }
.r-era {
  display: inline-block;
  font-size: 12.5px;
  color: var(--ink-2);
  background: #fbf1ea;
  border-radius: 8px;
  padding: 4px 12px;
}
.r-title {
  font-size: 17px;
  font-weight: 800;
  color: var(--red-deep);
  margin: 14px 0 0;
}

/* 匹配度环 */
.score-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin: 20px 0 4px;
}
.ring { position: relative; width: 104px; height: 104px; flex: 0 0 auto; }
.ring svg { transform: rotate(-90deg); display: block; }
.ring .ring-bg { stroke: #f7e8de; }
.ring .ring-fg {
  stroke: url(#ringGrad);
  stroke-linecap: round;
  transition: stroke-dashoffset 1.1s cubic-bezier(.2,.8,.2,1);
}
.ring .ring-num {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  font-size: 26px; font-weight: 900; letter-spacing: -.03em;
  color: var(--ink);
}
.ring .ring-num small { font-size: 12px; font-weight: 700; color: var(--ink-3); margin-left: 1px; }
.score-note { text-align: left; font-size: 12.5px; color: var(--ink-2); line-height: 1.6; }
.score-note b { display: block; color: var(--ink); font-size: 13.5px; margin-bottom: 2px; }

.divider { height: 1px; background: var(--line); margin: 20px 0; }

.section-label {
  font-size: 12px;
  font-weight: 900;
  letter-spacing: .14em;
  color: var(--ink-3);
  margin: 0 0 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.section-label::after { content: ""; flex: 1; height: 1px; background: var(--line); }

.big-quote {
  font-size: 18px;
  font-weight: 800;
  line-height: 1.7;
  color: var(--ink);
  background: linear-gradient(180deg, #fff9f4, #fffdfb);
  border-left: 4px solid var(--coral);
  border-radius: 4px 14px 14px 4px;
  padding: 14px 16px;
  margin: 0 0 16px;
}

.one-line {
  text-align: center;
  font-size: 15px;
  font-weight: 700;
  color: var(--ink-2);
  margin: 16px 0 14px;
  line-height: 1.6;
}
.one-line::before { content: "“"; color: var(--coral); font-size: 22px; margin-right: 1px; }
.one-line::after  { content: "”"; color: var(--coral); font-size: 22px; margin-left: 1px; }

.trait-line { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 16px; }
.trait-line span {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--red-deep);
  background: #fff1f3;
  border: 1px solid #ffdbe1;
  padding: 5px 11px;
  border-radius: 999px;
}

.kv { margin-bottom: 14px; }
.kv h4 {
  margin: 0 0 5px;
  font-size: 14px;
  font-weight: 900;
  display: flex; align-items: center; gap: 7px;
}
.kv h4 .ic {
  width: 22px; height: 22px; border-radius: 7px;
  display: grid; place-items: center; font-size: 12px;
  background: #eef7f4; color: #1f8a78;
}
.kv.warn h4 .ic { background: #fff4e8; color: #c9821a; }
.kv.tip h4 .ic { background: #eef2ff; color: #3e6bd6; }
.kv p { margin: 0; font-size: 14.2px; color: var(--ink-2); line-height: 1.72; }

/* 六维条 */
.bars { display: grid; gap: 9px; }
.bar-row { display: grid; grid-template-columns: 54px 1fr 30px; align-items: center; gap: 9px; }
.bar-row .bl { font-size: 12px; color: var(--ink-2); font-weight: 700; }
.bar-track { height: 8px; background: #f6e9e0; border-radius: 999px; overflow: hidden; }
.bar-fill {
  height: 100%; width: 0; border-radius: 999px;
  transition: width .9s cubic-bezier(.2,.8,.2,1);
}
.bar-row .bv { font-size: 11.5px; color: var(--ink-3); text-align: right; font-weight: 800; }

/* 第二 / 第三匹配 */
.alt-list { display: grid; gap: 9px; }
.alt {
  display: flex;
  align-items: center;
  gap: 11px;
  background: #fffdfb;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 11px 13px;
}
.alt .a-emoji {
  width: 36px; height: 36px; border-radius: 11px;
  display: grid; place-items: center; font-size: 18px;
  background: linear-gradient(135deg,#fff1e7,#ffe4ea);
  flex: 0 0 auto;
}
.alt .a-main { flex: 1; min-width: 0; }
.alt .a-name { font-weight: 900; font-size: 14.5px; }
.alt .a-why { font-size: 11.5px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.alt .a-score { font-size: 12.5px; font-weight: 900; color: var(--coral); }

/* 备选人物的迷你六维 */
.fig-bar-card {
  background: #fffdfb;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 11px 13px;
  margin-bottom: 9px;
}
.fig-bar-card .fb-head {
  display: flex; align-items: baseline; gap: 8px;
  margin-bottom: 8px;
}
.fig-bar-card .fb-name { font-weight: 900; font-size: 14px; }
.fig-bar-card .fb-title { font-size: 11.5px; color: var(--ink-3); flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fig-bar-card .fb-score { font-size: 12px; font-weight: 900; color: var(--coral); }
.fb-dims { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
.fb-dim { text-align: center; }
.fb-dim .fb-track {
  height: 40px; width: 100%;
  background: #f6e9e0; border-radius: 5px;
  display: flex; align-items: flex-end; overflow: hidden;
}
.fb-dim .fb-fill { width: 100%; border-radius: 5px 5px 0 0; transition: height .7s cubic-bezier(.2,.8,.2,1); }
.fb-dim .fb-label { font-size: 10px; color: var(--ink-3); margin-top: 4px; }
.fb-dim .fb-val { font-size: 9.5px; color: var(--ink-3); font-weight: 700; }

/* 分享卡片预览 */
.share-preview {
  margin-top: 18px;
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: #fff;
}
.share-preview canvas { display: block; width: 100%; height: auto; }

/* 榜单 */
.rank { display: grid; gap: 8px; }
.rank-row {
  display: flex; align-items: center; gap: 10px;
  font-size: 13px;
  padding: 8px 12px;
  background: #fffdfb;
  border: 1px solid var(--line);
  border-radius: 12px;
}
.rank-row .rk { font-weight: 900; color: var(--ink-3); width: 18px; font-size: 12px; }
.rank-row .rn { flex: 1; font-weight: 800; }
.rank-row .rs { font-size: 11.5px; color: var(--coral); font-weight: 900; }
.rank-row .rd { font-size: 11px; color: var(--ink-3); }

.footnote {
  text-align: center;
  font-size: 11.5px;
  color: var(--ink-3);
  line-height: 1.8;
  margin: 22px 0 0;
  padding: 0 6px;
}
.footnote b { color: var(--ink-2); }

/* toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(34px + var(--safe-b));
  transform: translate(-50%, 20px);
  background: rgba(43, 35, 32, .92);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  padding: 10px 18px;
  border-radius: 999px;
  opacity: 0;
  pointer-events: none;
  transition: all .25s ease;
  z-index: 99;
  backdrop-filter: blur(6px);
  max-width: 86vw;
  text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* 屏幕切换 */
.screen { display: none; animation: fadeUp .34s cubic-bezier(.2,.8,.2,1); }
.screen.active { display: block; }
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}

@media (max-width: 380px) {
  h1.hero-title { font-size: 29px; }
  .r-name { font-size: 36px; }
  .card { padding: 18px; }
  .app { padding-left: 14px; padding-right: 14px; }
}

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