/* ════════════════════════════════════════════════
   故宫配色体系
   朱红  #A01010   金漆  #D4A820   暗金  #8A5C10
   墨色  #1A0404   宣纸  #F5E8C0   云白  #EEE8D8
════════════════════════════════════════════════ */
:root {
  --red:        #A01010;
  --red-dark:   #6B0A0A;
  --red-deep:   #2A0404;
  --red-bright: #C41818;
  --gold:       #D4A820;
  --gold-light: #F5E070;
  --gold-pale:  #F0D8A0;
  --gold-dim:   #8A5C10;
  --gold-dark:  #5A3A08;
  --ink:        #120404;
  --paper:      #F5E8C0;
  --paper-dim:  #C8A860;
  --text-on-red: #F5E8C0;
  --text-gold:  #F0D070;
  --text-dim:   #C89060;
  --char-color: #F0C0B0;
  --char-accent:#F0C0B0;
}

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

html, body {
  min-height: 100%;
  font-family: 'Noto Serif SC', 'Songti SC', 'STSong', 'SimSun', serif;
  background: var(--red-dark);
  color: var(--text-on-red);
  overflow-x: hidden;
}

/* ── 朱红主背景 + 锦缎暗纹 ───────────────────── */
body {
  background-color: var(--red-dark);
  background-image:
    /* 斜向锦纹 */
    repeating-linear-gradient(45deg,
      transparent 0px, transparent 18px,
      rgba(180,30,30,0.15) 18px, rgba(180,30,30,0.15) 19px),
    repeating-linear-gradient(-45deg,
      transparent 0px, transparent 18px,
      rgba(180,30,30,0.15) 18px, rgba(180,30,30,0.15) 19px),
    /* 底部光 */
    radial-gradient(ellipse 100% 60% at 50% 100%, rgba(180,20,20,0.5) 0%, transparent 70%),
    /* 顶部光 */
    radial-gradient(ellipse 80% 40% at 50% 0%, rgba(200,30,30,0.6) 0%, transparent 60%);
}

/* ── 宫顶横梁（顶部金色装饰带） ─────────────── */
.roof-top {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 200;
  pointer-events: none;
}
.roof-beam {
  height: 8px;
  background: linear-gradient(90deg,
    var(--red-dark) 0%,
    var(--gold-dim) 8%,
    var(--gold) 25%,
    var(--gold-light) 50%,
    var(--gold) 75%,
    var(--gold-dim) 92%,
    var(--red-dark) 100%);
  box-shadow: 0 2px 12px rgba(212,168,32,0.4);
}
.roof-dougong {
  display: flex;
  justify-content: space-around;
  padding: 0 20px;
  height: 28px;
  background: linear-gradient(180deg, rgba(100,10,10,0.95) 0%, transparent 100%);
  align-items: flex-end;
  overflow: hidden;
}
.dougong-unit {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
}
.dougong-unit span {
  display: block;
  background: var(--gold-dim);
  border-radius: 1px;
}
.dg-top  { width: 20px; height: 3px; }
.dg-mid  { width: 14px; height: 4px; margin: 1px 0; }
.dg-bot  { width: 8px;  height: 8px; }

/* ── 宫灯 ─────────────────────────────────────── */
.lanterns {
  position: fixed;
  top: 36px; left: 0; right: 0;
  display: flex;
  justify-content: space-between;
  padding: 0 12px;
  pointer-events: none;
  z-index: 150;
}
.lantern {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
}
.lantern-string {
  width: 1px;
  height: 14px;
  background: var(--gold-dim);
}
.lantern-body {
  width: 18px;
  height: 26px;
  background: linear-gradient(135deg, #D42020 0%, #FF4040 40%, #D42020 70%, #A01010 100%);
  border-radius: 40% 40% 45% 45%;
  border: 1px solid var(--gold-dim);
  position: relative;
  box-shadow: 0 0 10px rgba(220,50,50,0.6), inset 0 0 8px rgba(255,180,0,0.3);
}
.lantern-body::before {
  content: '';
  position: absolute;
  top: 2px; left: 50%; transform: translateX(-50%);
  width: 8px; height: 3px;
  background: var(--gold-dim);
  border-radius: 2px;
}
.lantern-body::after {
  content: '';
  position: absolute;
  bottom: 2px; left: 50%; transform: translateX(-50%);
  width: 8px; height: 3px;
  background: var(--gold-dim);
  border-radius: 2px;
}
.lantern-tassel {
  display: flex;
  gap: 3px;
}
.lantern-tassel span {
  width: 1px;
  height: 12px;
  background: linear-gradient(180deg, var(--gold) 0%, transparent 100%);
}

/* ── 祥云背景装饰 ─────────────────────────────── */
.yun-deco {
  position: fixed;
  pointer-events: none;
  z-index: 1;
  opacity: 0.12;
}
.yun-deco.tl { top: 80px;  left: -20px; transform: scale(0.7); }
.yun-deco.tr { top: 80px;  right: -20px; transform: scale(0.7) scaleX(-1); }
.yun-deco.bl { bottom: 40px; left: -20px; transform: scale(0.7); }
.yun-deco.br { bottom: 40px; right: -20px; transform: scale(0.7) scaleX(-1); }
.yun-svg path { fill: var(--gold-light); }

/* ── 布局 ─────────────────────────────────────── */
#app {
  position: relative;
  z-index: 10;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 80px 16px 40px;
}

.screen { display: none; width: 100%; max-width: 540px; }
.screen.active { display: block; animation: screenIn 0.5s ease both; }

@keyframes screenIn {
  from { opacity: 0; transform: translateY(22px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── 宫殿卡片 ─────────────────────────────────── */
.card {
  position: relative;
  background:
    linear-gradient(160deg, rgba(30,4,4,0.96) 0%, rgba(20,3,3,0.98) 100%);
  padding: 36px 28px 32px;
  /* 三层边框：金-红-金 */
  box-shadow:
    0 0 0 1px var(--gold-dim),
    0 0 0 4px rgba(140,20,20,0.6),
    0 0 0 5px var(--gold-dim),
    0 20px 60px rgba(0,0,0,0.7),
    inset 0 1px 0 rgba(212,168,32,0.15),
    inset 0 -1px 0 rgba(212,168,32,0.08);
  border: none;
}

/* 内框线 */
.card::before {
  content: '';
  position: absolute;
  inset: 10px;
  border: 1px solid rgba(212,168,32,0.2);
  pointer-events: none;
  z-index: 0;
}

/* 四角金色 L 形角花 */
.card-corner {
  position: absolute;
  width: 24px;
  height: 24px;
  z-index: 5;
}
.card-corner.tl { top: 4px;    left: 4px; }
.card-corner.tr { top: 4px;    right: 4px; transform: scaleX(-1); }
.card-corner.bl { bottom: 4px; left: 4px;  transform: scaleY(-1); }
.card-corner.br { bottom: 4px; right: 4px; transform: scale(-1); }
.card-corner svg { width: 100%; height: 100%; }

/* ── 开始页 ───────────────────────────────────── */

/* 宫殿屋檐装饰（卡片顶部） */
.card-palace-roof {
  margin: -36px -28px 22px;
  overflow: hidden;
  height: 70px;
  position: relative;
  background: linear-gradient(180deg, rgba(140,20,20,0.5) 0%, transparent 100%);
}

/* 匾额 */
.plaque {
  text-align: center;
  margin-bottom: 22px;
  position: relative;
  z-index: 2;
}
.plaque-outer {
  display: inline-block;
  padding: 4px;
  background: linear-gradient(180deg, var(--gold) 0%, var(--gold-dim) 50%, var(--gold) 100%);
  box-shadow: 0 4px 20px rgba(0,0,0,0.5);
}
.plaque-inner {
  display: inline-block;
  padding: 14px 28px 12px;
  background: linear-gradient(180deg, #3D0808 0%, #2A0505 100%);
  border: 1px solid rgba(212,168,32,0.3);
  position: relative;
}
/* 匾额两侧挂钩 */
.plaque-inner::before,
.plaque-inner::after {
  content: '◆';
  position: absolute;
  top: 50%; transform: translateY(-50%);
  color: var(--gold-dim);
  font-size: 10px;
}
.plaque-inner::before { left: -18px; }
.plaque-inner::after  { right: -18px; }

/* 金色金属光泽标题 */
.start-title {
  font-size: clamp(22px, 5.5vw, 30px);
  font-weight: 700;
  letter-spacing: 5px;
  line-height: 1.5;
  /* 金属金色渐变 */
  background: linear-gradient(180deg,
    #F8EE80 0%,
    #D4A820 25%,
    #F8EE80 50%,
    #B88010 75%,
    #F0D060 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.6));
}

.start-sub {
  margin-top: 6px;
  font-size: 11px;
  color: var(--gold-dim);
  letter-spacing: 5px;
}

/* 分隔线 */
.divider {
  display: flex;
  align-items: center;
  margin: 18px 0;
}
.divider::before, .divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold-dim) 40%, var(--gold) 50%, var(--gold-dim) 60%, transparent);
}
.divider-icon {
  padding: 0 14px;
  color: var(--gold);
  font-size: 14px;
  flex-shrink: 0;
}

.start-desc {
  font-size: 14px;
  color: #C89870;
  line-height: 2.2;
  text-align: center;
  margin-bottom: 26px;
  letter-spacing: 1px;
  position: relative;
  z-index: 2;
}
.start-desc em {
  font-style: normal;
  color: var(--gold-pale);
}

/* ── 按钮：宫门样式 ───────────────────────────── */
.btn-primary {
  display: block;
  width: 100%;
  padding: 15px 24px;
  position: relative;
  /* 朱红底色 */
  background: linear-gradient(180deg,
    #B82020 0%,
    #8B0F0F 40%,
    #6A0808 60%,
    #8B0F0F 100%);
  border: none;
  color: var(--gold-light);
  font-family: inherit;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 6px;
  cursor: pointer;
  transition: all 0.3s;
  text-shadow: 0 1px 4px rgba(0,0,0,0.7);
  /* 金边 */
  box-shadow:
    0 0 0 1px var(--gold-dim),
    0 0 0 3px rgba(100,10,10,0.5),
    0 0 0 4px var(--gold-dim),
    0 6px 20px rgba(0,0,0,0.5),
    inset 0 1px 0 rgba(255,200,100,0.2),
    inset 0 -1px 0 rgba(0,0,0,0.3);
  z-index: 2;
}
.btn-primary::before,
.btn-primary::after {
  content: '✦';
  position: absolute;
  top: 50%; transform: translateY(-50%);
  font-size: 10px;
  color: var(--gold-dim);
  transition: color 0.3s;
}
.btn-primary::before { left: 16px; }
.btn-primary::after  { right: 16px; }
.btn-primary:hover {
  background: linear-gradient(180deg,
    #D42020 0%,
    #A01010 40%,
    #800C0C 60%,
    #A01010 100%);
  box-shadow:
    0 0 0 1px var(--gold),
    0 0 0 3px rgba(150,20,20,0.5),
    0 0 0 4px var(--gold),
    0 8px 30px rgba(160,16,16,0.4),
    0 0 50px rgba(212,168,32,0.15),
    inset 0 1px 0 rgba(255,220,120,0.3);
  transform: translateY(-1px);
}
.btn-primary:hover::before,
.btn-primary:hover::after { color: var(--gold); }

.btn-ghost {
  display: block;
  width: 100%;
  padding: 11px 24px;
  background: transparent;
  border: 1px solid rgba(212,168,32,0.25);
  color: #A07840;
  font-family: inherit;
  font-size: 13px;
  letter-spacing: 3px;
  cursor: pointer;
  transition: all 0.25s;
  margin-top: 10px;
  z-index: 2;
  position: relative;
}
.btn-ghost:hover {
  border-color: var(--gold-dim);
  color: var(--gold);
}

/* ── 答题页 ───────────────────────────────────── */
.quiz-meta {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 18px;
  padding-bottom: 14px;
  border-bottom: 1px solid rgba(212,168,32,0.18);
  position: relative;
  z-index: 2;
}
.q-number {
  font-size: 11px;
  color: var(--gold-dim);
  letter-spacing: 2px;
  white-space: nowrap;
  flex-shrink: 0;
}
.progress-track {
  flex: 1;
  height: 4px;
  background: rgba(100,10,10,0.5);
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(212,168,32,0.15);
}
.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--red) 0%, var(--gold) 100%);
  transition: width 0.4s ease;
  width: 0%;
  box-shadow: 0 0 8px rgba(212,168,32,0.5);
}

/* 题目：左侧朱红竖纹 */
.q-text {
  font-size: clamp(15px, 3.5vw, 18px);
  color: var(--text-on-red);
  line-height: 1.9;
  letter-spacing: 1.5px;
  margin: 0 0 20px;
  min-height: 52px;
  padding: 10px 14px;
  border-left: 3px solid var(--red-bright);
  background: rgba(160,16,16,0.08);
  position: relative;
  z-index: 2;
}

.options-list {
  display: flex;
  flex-direction: column;
  gap: 9px;
  position: relative;
  z-index: 2;
}

.option-btn {
  width: 100%;
  padding: 12px 18px 12px 44px;
  background: rgba(160,16,16,0.08);
  border: 1px solid rgba(212,168,32,0.2);
  color: #D8B888;
  font-family: inherit;
  font-size: 14px;
  line-height: 1.65;
  text-align: left;
  cursor: pointer;
  transition: all 0.22s;
  position: relative;
  letter-spacing: 0.5px;
}
.option-btn::before {
  content: '○';
  position: absolute;
  left: 16px; top: 50%; transform: translateY(-50%);
  color: var(--gold-dim);
  font-size: 11px;
  transition: all 0.2s;
}
.option-btn:hover {
  background: rgba(160,16,16,0.25);
  border-color: rgba(212,168,32,0.5);
  color: var(--gold-pale);
  border-left: 2px solid var(--gold);
}
.option-btn:hover::before { content: '◆'; color: var(--gold); font-size: 9px; }
.option-btn.selected {
  background: rgba(160,16,16,0.35);
  border-color: var(--gold);
  border-left: 2px solid var(--gold);
  color: var(--gold-pale);
}
.option-btn.selected::before { content: '◆'; color: var(--gold); font-size: 9px; }
.option-btn.dimmed { opacity: 0.25; pointer-events: none; }

#quiz-card.fade-in { animation: fadeSlide 0.35s ease both; }
@keyframes fadeSlide {
  from { opacity: 0; transform: translateX(16px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* ── 加载页 ───────────────────────────────────── */
#screen-loading { text-align: center; }
.loading-inner { padding: 55px 28px; }

.loading-sigil {
  width: 74px; height: 74px;
  margin: 0 auto 26px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}
.loading-sigil::before {
  content: '';
  position: absolute; inset: 0;
  border: 2px solid transparent;
  border-top-color: var(--gold);
  border-right-color: var(--gold-dim);
  border-radius: 50%;
  animation: spin 1.2s linear infinite;
}
.loading-sigil::after {
  content: '';
  position: absolute; inset: 10px;
  border: 1px solid transparent;
  border-bottom-color: var(--red-bright);
  border-left-color: var(--gold-dim);
  border-radius: 50%;
  animation: spin 0.8s linear infinite reverse;
}
.loading-sigil-inner { font-size: 26px; color: var(--gold); z-index: 1; }

@keyframes spin { to { transform: rotate(360deg); } }

.loading-text {
  font-size: 15px;
  color: var(--gold-pale);
  letter-spacing: 3px;
  animation: pulse 1.1s ease-in-out infinite;
}
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:0.3} }

/* ── 结果页 ───────────────────────────────────── */
.result-header { text-align: center; margin-bottom: 20px; position: relative; z-index: 2; }

.result-badge {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 11px;
  letter-spacing: 4px;
  color: var(--gold-dim);
  margin-bottom: 16px;
}
.result-badge::before, .result-badge::after {
  content: '';
  display: inline-block;
  width: 28px; height: 1px;
}
.result-badge::before { background: linear-gradient(90deg, transparent, var(--gold-dim)); }
.result-badge::after  { background: linear-gradient(90deg, var(--gold-dim), transparent); }

/* 金属光泽角色名 */
.result-name {
  font-size: clamp(44px, 10vw, 64px);
  font-weight: 700;
  letter-spacing: 12px;
  background: linear-gradient(180deg,
    #F8EE80 0%,
    #D4A820 30%,
    #F8EE80 55%,
    #A87010 80%,
    #F0D060 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  filter: drop-shadow(0 3px 6px rgba(0,0,0,0.7));
  line-height: 1.1;
  transition: filter 0.5s;
}

/* 红色印章 */
.result-seal {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 10px auto 0;
  padding: 4px 18px;
  border: 2px solid var(--red-bright);
  color: var(--red-bright);
  font-size: 13px;
  letter-spacing: 3px;
  background: rgba(160,16,16,0.1);
}
.result-seal::before, .result-seal::after {
  content: '';
  display: inline-block;
  width: 1px; height: 12px;
  background: rgba(196,24,24,0.4);
}

/* 命格标签 */
.result-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin: 16px 0;
  position: relative;
  z-index: 2;
}
.tag {
  padding: 4px 14px;
  border: 1px solid rgba(212,168,32,0.4);
  background: rgba(160,16,16,0.15);
  font-size: 12px;
  color: var(--gold);
  letter-spacing: 2px;
}
.tag::before { content: '✦ '; font-size: 8px; color: var(--gold-dim); }

/* 描述 */
.result-desc {
  font-size: 14px;
  line-height: 2.2;
  color: #D8B888;
  letter-spacing: 1px;
  margin: 16px 0;
  padding: 18px 20px;
  background: rgba(160,16,16,0.1);
  position: relative;
  border-left: 2px solid var(--red);
  border-right: 2px solid var(--red);
  z-index: 2;
}
.result-desc::before, .result-desc::after {
  content: '';
  position: absolute;
  left: -2px; right: -2px; height: 1px;
  background: linear-gradient(90deg, var(--red), var(--gold-dim), var(--red));
}
.result-desc::before { top: 0; }
.result-desc::after  { bottom: 0; }

/* 今日命格框 */
.result-quote-wrap {
  margin: 14px 0 20px;
  text-align: center;
  padding: 13px 16px;
  border: 1px solid rgba(212,168,32,0.22);
  background: rgba(0,0,0,0.2);
  position: relative;
  z-index: 2;
}
.result-quote-wrap::before {
  content: '今日命格';
  position: absolute;
  top: -9px; left: 50%; transform: translateX(-50%);
  background: #1A0404;
  padding: 0 12px;
  font-size: 10px;
  letter-spacing: 3px;
  color: var(--gold-dim);
}
.result-quote {
  font-size: 13px;
  color: var(--gold);
  line-height: 1.9;
  letter-spacing: 1px;
}

#share-btn { letter-spacing: 3px; font-size: 14px; position: relative; z-index: 2; }
#share-btn.copied {
  background: linear-gradient(180deg, #3D6A10 0%, #254008 50%, #3D6A10 100%);
  box-shadow: 0 0 0 1px #6A9A30, 0 0 0 3px rgba(40,80,10,0.4), 0 0 0 4px #6A9A30;
  color: #A0D060;
}
.btn-ghost { position: relative; z-index: 2; }

/* ── 页脚 ─────────────────────────────────────── */
.page-footer {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  text-align: center;
  padding: 8px;
  font-size: 11px;
  color: rgba(180,100,60,0.4);
  letter-spacing: 2px;
  z-index: 5;
}

/* ── 响应式 ───────────────────────────────────── */
@media (max-width: 380px) {
  .card { padding: 24px 14px; }
  .start-title { font-size: 20px; }
  .plaque-inner { padding: 12px 18px; }
  .lanterns { padding: 0 4px; }
}

/* ── 人格图鉴弹窗 ──────────────────────────────── */
.gallery-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(10,2,2,0.85);
  z-index: 100;
  justify-content: center;
  align-items: flex-start;
  padding: 20px 12px 40px;
  overflow-y: auto;
}
.gallery-overlay.active { display: flex; }

.gallery-modal {
  position: relative;
  background: linear-gradient(160deg, #1a0404 0%, #2a0808 60%, #1a0404 100%);
  border: 1px solid rgba(212,168,32,0.35);
  border-radius: 4px;
  width: 100%;
  max-width: 480px;
  padding: 28px 20px 32px;
  box-shadow: 0 0 40px rgba(160,16,16,0.3);
}

.gallery-close {
  position: absolute;
  top: 12px; right: 14px;
  background: none;
  border: 1px solid rgba(212,168,32,0.3);
  color: var(--gold);
  font-size: 14px;
  width: 28px; height: 28px;
  border-radius: 2px;
  cursor: pointer;
  line-height: 1;
}
.gallery-close:hover { background: rgba(212,168,32,0.1); }

.gallery-title {
  text-align: center;
  font-size: 15px;
  letter-spacing: 4px;
  color: var(--gold);
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(212,168,32,0.2);
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.gallery-card {
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(212,168,32,0.2);
  border-radius: 3px;
  padding: 12px 8px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  transition: background 0.2s, border-color 0.2s;
}
.gallery-card:hover {
  background: rgba(212,168,32,0.08);
  border-color: var(--gc-color, var(--gold));
}
.gc-name {
  font-size: 16px;
  color: var(--gc-color, var(--gold));
  font-weight: 600;
  letter-spacing: 1px;
}
.gc-title {
  font-size: 10px;
  color: rgba(240,216,160,0.5);
  letter-spacing: 1px;
}

.gallery-back {
  background: none;
  border: none;
  color: var(--gold);
  font-size: 12px;
  letter-spacing: 2px;
  cursor: pointer;
  padding: 0 0 16px;
  opacity: 0.7;
  font-family: inherit;
}
.gallery-back:hover { opacity: 1; }
