/* ==================================================================
   酒品论官职 · 网页版样式
   活泼卡通风 · 移动优先，桌面端居中成"小应用"形态
   两套主题：gold（尊贵365 金红唐风）/ candy（茅福*中国福 糖果色）
   ================================================================== */

/* ---------------- 主题变量 ---------------- */
:root {
  --radius: 26px;
  --radius-sm: 16px;
  --shadow: 0 10px 26px rgba(60, 40, 20, .10);
  --shadow-lift: 0 16px 34px rgba(60, 40, 20, .16);
  --ink: #2B2118;
  --ink-dim: #7A6A5C;
  --line: rgba(90, 60, 30, .12);
  --font: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", system-ui, -apple-system, sans-serif;
}

/* 金红唐风 */
body[data-theme="gold"] {
  --bg-1: #FFF6E4;
  --bg-2: #FFE7CC;
  --bg-3: #FFD9D0;
  --card: #FFFFFF;
  --card-soft: #FFFBF2;
  --brand: #C0392B;
  --brand-2: #E8623C;
  --accent: #D4AF37;
  --accent-soft: #FFF3C4;
  --hero-grad: linear-gradient(135deg, #C0392B 0%, #E8623C 55%, #D4AF37 100%);
}

/* 糖果卡通 */
body[data-theme="candy"] {
  --bg-1: #F3F0FF;
  --bg-2: #E6F7FF;
  --bg-3: #FFEFF6;
  --card: #FFFFFF;
  --card-soft: #FAF7FF;
  --brand: #7C3AED;
  --brand-2: #F472B6;
  --accent: #22D3EE;
  --accent-soft: #E0F7FF;
  --hero-grad: linear-gradient(135deg, #7C3AED 0%, #A855F7 45%, #F472B6 100%);
}

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

html, body { margin: 0; padding: 0; }

/* 双保险：任何未被预见的长内容都不允许把页面撑出横向滚动 */
html { overflow-x: clip; }

body {
  font-family: var(--font);
  color: var(--ink);
  background: linear-gradient(170deg, var(--bg-1) 0%, var(--bg-2) 45%, var(--bg-3) 100%);
  background-attachment: fixed;
  min-height: 100vh;
  overflow-x: hidden;
  line-height: 1.6;
  font-size: 16px;
}

.app {
  position: relative;
  z-index: 2;
  max-width: 720px;
  margin: 0 auto;
  padding: 0 18px 40px;
}

/* ---------------- 背景装饰 ---------------- */
.deco { position: fixed; inset: 0; pointer-events: none; z-index: 1; overflow: hidden; }

.deco__cloud {
  position: absolute;
  width: 190px; height: 62px;
  background: #fff;
  border-radius: 62px;
  opacity: .55;
  filter: blur(1px);
}
.deco__cloud::before, .deco__cloud::after {
  content: ""; position: absolute; background: #fff; border-radius: 50%;
}
.deco__cloud::before { width: 78px; height: 78px; left: 26px; top: -34px; }
.deco__cloud::after  { width: 56px; height: 56px; left: 96px; top: -22px; }
.deco__cloud--1 { top: 8%;  left: -70px;  animation: drift 46s linear infinite; }
.deco__cloud--2 { top: 34%; left: -120px; transform: scale(.72); animation: drift 62s linear infinite 6s; }
.deco__cloud--3 { top: 66%; left: -90px;  transform: scale(.88); animation: drift 54s linear infinite 14s; }

@keyframes drift {
  from { transform: translateX(0) scale(1); }
  to   { transform: translateX(140vw) scale(1); }
}

.deco__lantern {
  position: absolute; font-size: 26px; opacity: .55;
  animation: sway 5s ease-in-out infinite;
}
.deco__lantern--1 { top: 12%; right: 6%;  animation-delay: 0s; }
.deco__lantern--2 { top: 46%; right: 12%; font-size: 20px; animation-delay: 1.2s; }
.deco__lantern--3 { top: 76%; right: 4%;  font-size: 30px; animation-delay: .6s; }

@keyframes sway {
  0%, 100% { transform: rotate(-7deg) translateY(0); }
  50%      { transform: rotate(7deg) translateY(-9px); }
}

.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 60; overflow: hidden; }
.confetti span {
  position: absolute; top: -34px;
  animation: fall 2.8s linear forwards;
}
@keyframes fall {
  0%   { transform: translateY(0) rotate(0); opacity: 0; }
  12%  { opacity: 1; }
  100% { transform: translateY(105vh) rotate(420deg); opacity: 0; }
}

/* ---------------- 顶栏 ---------------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
  padding: 16px 4px 10px;
}
.topbar__brand { display: flex; align-items: center; gap: 8px; min-width: 0; }
.topbar__logo { font-size: 24px; animation: bob 2.6s ease-in-out infinite; }
.topbar__name { font-weight: 800; font-size: 18px; letter-spacing: .5px; }
.topbar__site {
  font-size: 12px; color: #fff; background: var(--brand);
  padding: 2px 10px; border-radius: 20px; white-space: nowrap;
}
.topbar__site:empty { display: none; }

.music-btn {
  border: none; cursor: pointer;
  font-family: inherit; font-size: 13px; font-weight: 700;
  color: var(--brand);
  background: #fff;
  border: 2px solid color-mix(in srgb, var(--brand) 26%, transparent);
  border-radius: 999px;
  padding: 7px 14px;
  white-space: nowrap;
  transition: transform .15s, box-shadow .15s;
  box-shadow: var(--shadow);
}
.music-btn span { margin-right: 4px; }
.music-btn.is-on { color: #fff; background: var(--brand); }
.music-btn:active { transform: scale(.94); }

/* ---------------- 屏幕 ---------------- */
.screen { display: none; animation: fadeUp .34s ease both; }
.screen.is-active { display: block; }

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

/* ---------------- 首页 Hero ---------------- */
.hero { text-align: center; padding: 12px 0 4px; }

.hero__title {
  margin: 0; display: flex; justify-content: center; gap: 6px;
  font-size: 0;
}
.hero__char {
  display: inline-block;
  font-size: 56px; font-weight: 900; line-height: 1.05;
  background: var(--hero-grad);
  -webkit-background-clip: text; background-clip: text;
  color: transparent;
  text-shadow: 0 4px 0 rgba(0, 0, 0, .05);
  animation: charPop .58s cubic-bezier(.2, 1.5, .4, 1) both;
}
.hero__char:nth-child(1) { animation-delay: .04s; }
.hero__char:nth-child(2) { animation-delay: .12s; }
.hero__char:nth-child(3) { animation-delay: .20s; }
.hero__char:nth-child(4) { animation-delay: .28s; }

@keyframes charPop {
  from { opacity: 0; transform: translateY(22px) scale(.7) rotate(-8deg); }
  to   { opacity: 1; transform: none; }
}

.hero__sub { margin: 6px 0 2px; font-size: 15px; color: var(--ink-dim); }
.hero__tag { margin: 0; font-size: 14px; color: var(--ink-dim); }
.hero__tag b { color: var(--brand); font-size: 17px; }
.hero__meta { margin: 14px 0 0; font-size: 12px; color: var(--ink-dim); }

/* ---------------- 卡片 ---------------- */
.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 20px 18px;
  margin: 16px 0;
  box-shadow: var(--shadow);
  border: 1px solid var(--line);
}
.card--hero { text-align: center; padding: 22px 18px 24px; }
.card__title {
  margin: 0 0 12px; font-size: 17px; font-weight: 800;
  display: flex; align-items: center; gap: 8px;
}
.card__title::before {
  content: ""; width: 6px; height: 18px; border-radius: 4px;
  background: var(--hero-grad);
}
.card__note { margin: 12px 0 0; font-size: 13px; color: var(--ink-dim); }

.hero__figure { display: flex; justify-content: center; margin-bottom: 6px; }
.hero__figure svg { animation: bob 3.2s ease-in-out infinite; }

@keyframes bob {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-9px); }
}

/* ---------------- 按钮 ---------------- */
.btn {
  display: block; width: 100%;
  font-family: inherit; font-size: 16px; font-weight: 800;
  border: none; cursor: pointer;
  border-radius: 999px;
  padding: 15px 20px;
  margin: 10px 0 0;
  transition: transform .14s, box-shadow .14s, filter .14s;
}
.btn--primary {
  color: #fff; background: var(--hero-grad);
  box-shadow: 0 10px 22px color-mix(in srgb, var(--brand) 34%, transparent);
}
.btn--primary:hover { filter: brightness(1.06); }
.btn--primary:active { transform: translateY(2px) scale(.985); }

.btn--ghost {
  color: var(--brand); background: transparent;
  border: 2px solid color-mix(in srgb, var(--brand) 30%, transparent);
}
.btn--ghost:active { transform: scale(.985); }

.btn--big { font-size: 19px; padding: 17px 20px; }
.btn--sm { font-size: 14px; padding: 11px 16px; width: auto; display: inline-block; }
.btn__emoji { margin-right: 6px; }

/* ---------------- 官阶阶梯 ---------------- */
.ladder {
  display: flex; gap: 8px; flex-wrap: wrap;
  max-height: 220px; overflow-y: auto;
  padding: 4px 2px 6px;
}
.ladder--result { flex-wrap: nowrap; overflow-x: auto; max-height: none; padding-bottom: 10px; }

.ladder-pill {
  flex: 0 0 auto;
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 12px; color: #fff;
  background: var(--c, #888);
  border-radius: 999px;
  padding: 5px 12px;
  opacity: .92;
  white-space: nowrap;
}
.ladder-pill b { font-size: 11px; opacity: .85; font-weight: 700; }
.ladder-pill.is-me {
  transform: scale(1.1);
  box-shadow: 0 0 0 3px #fff, 0 0 0 6px var(--c, #888);
  opacity: 1;
}

/* ---------------- 怎么算的 ---------------- */
.how { margin: 0; padding-left: 20px; font-size: 14px; }
.how li { margin-bottom: 7px; }
.how b { color: var(--brand); }

/* ---------------- 答题 ---------------- */
.quiz-head { padding: 12px 4px 4px; }
.quiz-progress { display: flex; flex-direction: column; gap: 7px; margin-bottom: 16px; }
.quiz-progress__text { font-size: 13px; color: var(--ink-dim); font-weight: 700; }
.quiz-progress__text b { color: var(--brand); font-size: 16px; }
.quiz-progress__bar {
  height: 10px; border-radius: 999px; background: rgba(255, 255, 255, .8);
  overflow: hidden; box-shadow: inset 0 1px 3px rgba(0, 0, 0, .08);
}
.quiz-progress__bar i {
  display: block; height: 100%; width: 0;
  background: var(--hero-grad);
  border-radius: 999px;
  transition: width .35s cubic-bezier(.4, 1.3, .5, 1);
}
.quiz__title { margin: 0 0 4px; font-size: 24px; font-weight: 900; line-height: 1.35; }
.quiz__hint { margin: 0; font-size: 13px; color: var(--ink-dim); }

.quiz-options { display: grid; gap: 12px; margin: 20px 0; }

.opt {
  display: flex; align-items: center; gap: 14px;
  font-family: inherit; text-align: left;
  background: var(--card);
  border: 3px solid transparent;
  border-radius: 20px;
  padding: 16px 18px;
  font-size: 17px; font-weight: 700; color: var(--ink);
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform .14s, border-color .14s, box-shadow .14s;
}
.opt:hover { transform: translateY(-2px); box-shadow: var(--shadow-lift); }
.opt:active { transform: scale(.975); }
.opt.is-picked {
  border-color: var(--brand);
  background: color-mix(in srgb, var(--brand) 8%, #fff);
  animation: pick .34s cubic-bezier(.2, 1.6, .4, 1);
}
.opt--warn.is-picked { border-color: #DC2626; background: #FEF2F2; }
@keyframes pick {
  0% { transform: scale(1); }
  50% { transform: scale(1.04); }
  100% { transform: scale(1); }
}
.opt__icon { font-size: 26px; flex: 0 0 auto; }
.opt__label { flex: 1; }

/* 籍贯题有 35 个选项，改成多列 chip 网格（排成竖列要翻好几屏） */
.quiz-options.is-compact {
  grid-template-columns: repeat(auto-fill, minmax(78px, 1fr));
  gap: 8px;
}
.opt--chip {
  flex-direction: column;
  justify-content: center;
  gap: 2px;
  padding: 10px 4px;
  border-radius: 14px;
  font-size: 13px;
  text-align: center;
}
.opt--chip .opt__icon { font-size: 19px; line-height: 1.2; }
.opt--chip .opt__label { flex: 0 0 auto; }

.quiz-foot { display: flex; justify-content: flex-start; margin-top: 4px; }

/* ---------------- 结果 ---------------- */
.result-top {
  position: relative;
  text-align: center;
  padding: 10px 0 4px;
}
.portrait { display: flex; justify-content: center; }
.portrait svg { animation: bob 3.4s ease-in-out infinite; filter: drop-shadow(0 12px 20px rgba(0, 0, 0, .12)); }

.stamp {
  position: absolute;
  top: 24px; right: 8px;
  width: 92px; height: 92px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  border: 5px solid #C0392B;
  border-radius: 18px;
  color: #C0392B;
  background: rgba(255, 255, 255, .82);
  transform: rotate(-14deg) scale(2.4);
  opacity: 0;
  pointer-events: none;
}
.stamp.is-stamping { animation: stampIn .5s cubic-bezier(.2, 1.6, .35, 1) .12s forwards; }
@keyframes stampIn {
  0%   { transform: rotate(-14deg) scale(2.4); opacity: 0; }
  60%  { transform: rotate(-14deg) scale(.92); opacity: 1; }
  100% { transform: rotate(-14deg) scale(1);   opacity: 1; }
}
.stamp__grade { font-size: 15px; font-weight: 900; letter-spacing: 1px; }
.stamp__title { font-size: 17px; font-weight: 900; }

.result-name { margin-top: 10px; }
.result-name__grade {
  display: inline-block;
  font-size: 14px; font-weight: 900; color: #fff;
  background: var(--hero-grad);
  padding: 4px 16px; border-radius: 999px;
}
.result-name__title { font-size: 40px; font-weight: 900; margin: 6px 0 2px; letter-spacing: 3px; }
.result-name__alias { font-size: 15px; color: var(--brand); font-weight: 700; }
.result-name__seat {
  display: inline-block; margin-top: 8px;
  font-size: 13px; color: var(--ink-dim);
  background: rgba(255, 255, 255, .85);
  border: 1px dashed var(--line);
  border-radius: 999px; padding: 3px 14px;
}
.result-name__seat[data-seat="central"] { color: #B45309; border-color: #F3D9A4; }
.result-name__seat[data-seat="local"]   { color: #15803D; border-color: #BBE6C6; }

.comment { margin: 0; font-size: 16px; line-height: 1.85; }

.res-warn {
  margin-top: 14px; padding: 12px 14px;
  background: #FEF2F2; color: #B91C1C;
  border-left: 4px solid #DC2626;
  border-radius: 12px;
  font-size: 13.5px; font-weight: 600;
}

.score-grid {
  display: grid;
  /* minmax(0,1fr)：允许列收缩。1fr 默认是 minmax(auto,1fr)，
     长文本（如"四品五品服绯"）会把 min-content 撑出去，导致整页横向溢出 */
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 14px;
}
.score-item {
  text-align: center; background: var(--card-soft);
  border-radius: var(--radius-sm); padding: 12px 4px;
  border: 1px solid var(--line);
  overflow-wrap: anywhere;
}
.score-item b { display: block; font-size: 20px; color: var(--brand); }
.score-item span { font-size: 11px; color: var(--ink-dim); }

.picks { list-style: none; margin: 0; padding: 0; }
.pick {
  display: flex; align-items: center; gap: 9px;
  font-size: 13.5px; padding: 9px 0;
  border-bottom: 1px dashed var(--line);
}
.pick:last-child { border-bottom: none; }
.pick__icon { font-size: 17px; }
.pick__q { color: var(--ink-dim); flex: 0 0 auto; }
.pick__a { flex: 1; font-weight: 700; }
.pick__s { font-weight: 900; color: var(--ink-dim); }
.pick__s.up { color: #15803D; }
.pick__s.down { color: #DC2626; }

.card--share { text-align: center; }
.card--comment { border-left: 6px solid var(--accent); }

.share-banner {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  flex-wrap: wrap;
  background: var(--accent-soft);
  border: 1px solid color-mix(in srgb, var(--accent) 40%, transparent);
  border-radius: var(--radius-sm);
  padding: 12px 14px; margin: 14px 0 4px;
  font-size: 13.5px; font-weight: 700;
}

.share-btns { display: flex; gap: 10px; justify-content: center; margin-top: 10px; flex-wrap: wrap; }

/* ---------------- 图鉴 ---------------- */
.ranks-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin: 12px 0 26px; }
@media (min-width: 560px) { .ranks-grid { grid-template-columns: repeat(3, 1fr); } }

.rank-card {
  background: var(--card); border-radius: 20px; padding: 12px 8px 14px;
  text-align: center; box-shadow: var(--shadow);
  border: 1px solid var(--line);
}
.rank-card__fig { display: flex; justify-content: center; }
.rank-card__grade { font-size: 12px; font-weight: 900; color: #fff; background: var(--brand); border-radius: 999px; display: inline-block; padding: 2px 10px; margin-top: 4px; }
.rank-card__title { font-size: 18px; font-weight: 900; margin-top: 5px; letter-spacing: 2px; }
.rank-card__alias { font-size: 12px; color: var(--brand); font-weight: 700; }
.rank-card__seat { font-size: 11px; color: var(--ink-dim); margin-top: 3px; }

/* ---------------- 广告位 ---------------- */
.ad-slot { margin: 18px 0; min-height: 0; }
.ad-slot--off { display: none; }

.ad-slot--placeholder {
  border: 2px dashed color-mix(in srgb, var(--brand) 26%, transparent);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, .55);
}
.ad-ph {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  flex-wrap: wrap;
  min-height: 78px; padding: 12px;
  font-size: 12px; color: var(--ink-dim);
}
.ad-ph__tag {
  background: var(--brand); color: #fff;
  border-radius: 6px; padding: 2px 7px; font-size: 11px; font-weight: 700;
}
.ad-ph__name { font-weight: 700; color: var(--ink); }
.ad-ph__prov { opacity: .75; }

.ad-slot--note { margin: 14px 0; }
.ad-note {
  display: flex; gap: 8px; align-items: flex-start;
  background: #F1F5F9; color: #475569;
  border-radius: var(--radius-sm);
  padding: 11px 13px; font-size: 12.5px; line-height: 1.7;
}
.ad-note__icon { flex: 0 0 auto; }

/* ---------------- 页脚 ---------------- */
.footer {
  margin-top: 26px; padding: 18px 4px 4px;
  border-top: 1px solid var(--line);
  text-align: center;
}
.footer__line { margin: 5px 0; font-size: 12px; color: var(--ink-dim); }
.footer__line--dim { opacity: .7; }

/* ---------------- Toast ---------------- */
.toast {
  position: fixed; left: 50%; bottom: 34px;
  transform: translate(-50%, 20px);
  background: rgba(30, 20, 12, .92);
  color: #fff; font-size: 14px; font-weight: 600;
  padding: 11px 20px; border-radius: 999px;
  opacity: 0; pointer-events: none;
  transition: opacity .24s, transform .24s;
  z-index: 90; max-width: 84vw; text-align: center;
}
.toast.is-on { opacity: 1; transform: translate(-50%, 0); }

/* ---------------- 无障碍 / 降级 ---------------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}

/* ---------- 历任名人 ---------- */
.fig-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
}
.fig-chip {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  border: 1.5px solid var(--gold, #E8C36A);
  background: rgba(232, 195, 106, 0.08);
  color: var(--gold, #E8C36A);
  border-radius: 999px;
  padding: 8px 18px;
  font-size: 15px;
  cursor: pointer;
  transition: transform 0.15s, background 0.15s;
}
.fig-chip:hover { background: rgba(232, 195, 106, 0.18); transform: translateY(-2px); }
.fig-chip:active { transform: scale(0.95); }
.fig-chip__name { font-weight: 700; }
.fig-chip__era { font-size: 11px; opacity: 0.75; }

/* ---------- 名人介绍弹层 ---------- */
.fig-mask {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
  z-index: 1200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  transition: opacity 0.18s;
}
.fig-mask.is-on { opacity: 1; }
.fig-popup {
  position: relative;
  width: 100%;
  max-width: 460px;
  background: linear-gradient(170deg, #2a1f14, #1c1409);
  border: 1px solid rgba(232, 195, 106, 0.5);
  border-radius: 18px;
  padding: 28px 26px 24px;
  box-shadow: 0 16px 60px rgba(0, 0, 0, 0.55);
  transform: translateY(8px) scale(0.98);
  transition: transform 0.18s;
}
.fig-mask.is-on .fig-popup { transform: none; }
.fig-popup__close {
  position: absolute;
  top: 10px; right: 12px;
  width: 34px; height: 34px;
  border: none;
  background: transparent;
  color: rgba(232, 195, 106, 0.7);
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
  border-radius: 50%;
}
.fig-popup__close:hover { color: #E8C36A; background: rgba(232, 195, 106, 0.12); }
.fig-popup__head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.fig-popup__name {
  font-size: 26px;
  font-weight: 800;
  color: #E8C36A;
  letter-spacing: 2px;
}
.fig-popup__era { font-size: 13px; color: rgba(255, 255, 255, 0.55); }
.fig-popup__office {
  margin-top: 10px;
  font-size: 13px;
  color: #C9A86A;
}
.fig-popup__intro {
  margin: 14px 0 0;
  font-size: 15px;
  line-height: 1.8;
  color: rgba(255, 255, 255, 0.88);
}
