/* ============ 祖宗保佑 · 祠堂视觉 ============ */
:root {
  --bg: #14100c;
  --bg-2: #1d1712;
  --paper: #241c14;
  --paper-2: #2c2218;
  --line: rgba(212, 162, 78, .18);
  --gold: #d4a24e;
  --gold-bright: #f0c069;
  --red: #b03a2e;
  --red-bright: #d9534a;
  --ink: #e8dcc8;
  --ink-dim: #a89878;
  --ink-faint: #6f6350;
  --good: #7ba05b;
  --shadow: 0 10px 40px rgba(0, 0, 0, .55);
  --radius: 14px;
}

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

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: "Noto Serif SC", "Songti SC", "STSong", "SimSun", serif;
  background:
    radial-gradient(ellipse 120% 60% at 50% -10%, #2a1f12 0%, transparent 60%),
    radial-gradient(ellipse 80% 50% at 50% 110%, #1f150d 0%, transparent 70%),
    var(--bg);
  color: var(--ink);
  min-height: 100dvh;
  line-height: 1.7;
}

#app {
  max-width: 560px;
  margin: 0 auto;
  min-height: 100dvh;
  padding: env(safe-area-inset-top) 16px env(safe-area-inset-bottom);
  position: relative;
}

.screen { display: none; padding: 24px 0 40px; animation: scrIn .45s ease both; }
.screen.active { display: block; }
@keyframes scrIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* ============ 按钮（拇指友好 ≥48px） ============ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 12px 22px;
  font-family: inherit; font-size: 17px; letter-spacing: .06em;
  border-radius: var(--radius); border: 1px solid var(--line);
  background: var(--paper); color: var(--ink);
  cursor: pointer; user-select: none;
  transition: transform .12s ease, box-shadow .12s ease, background .2s;
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: scale(.97); }
.btn-gold {
  background: linear-gradient(160deg, #c99a3f, #a97a2a);
  border-color: rgba(255, 220, 150, .45);
  color: #241a08; font-weight: 700;
  box-shadow: 0 6px 24px rgba(212, 162, 78, .28), inset 0 1px 0 rgba(255,255,255,.35);
}
.btn-gold:hover { filter: brightness(1.08); }
.btn-ghost { background: rgba(255,255,255,.03); color: var(--ink-dim); }
.btn-ghost:hover { color: var(--ink); border-color: rgba(212,162,78,.4); }
.btn-big { width: 100%; font-size: 19px; min-height: 58px; }
.btn-block { width: 100%; margin-top: 14px; }
.btn:disabled { opacity: .38; cursor: not-allowed; }

/* ============ 主页 ============ */
.home-head { text-align: center; padding: 52px 0 16px; position: relative; }
.home-tag { color: var(--ink-dim); font-size: 15px; letter-spacing: .3em; margin-bottom: 18px; }
.home-title {
  font-size: clamp(56px, 17vw, 84px); font-weight: 900; line-height: 1.15;
  color: var(--gold-bright);
  text-shadow: 0 0 40px rgba(212, 162, 78, .35), 0 2px 0 rgba(0,0,0,.6);
  letter-spacing: .08em;
}
.home-title span { color: var(--ink); }
.home-sub {
  margin-top: 10px; color: var(--red-bright); font-size: 15px; letter-spacing: .5em;
  text-indent: .5em;
}

/* 蜡烛 */
.candle { position: absolute; top: 34px; width: 14px; height: 74px; }
.candle-l { left: 10%; } .candle-r { right: 10%; }
.candle::before {
  content: ""; position: absolute; bottom: 0; left: 0; width: 14px; height: 56px;
  background: linear-gradient(#8a2f26, #5c1f19); border-radius: 3px;
}
.candle i {
  position: absolute; top: 0; left: 50%; width: 12px; height: 20px;
  background: radial-gradient(ellipse at 50% 80%, #ffdd88 10%, #ff9a3c 55%, transparent 75%);
  border-radius: 50% 50% 45% 45%; transform: translateX(-50%);
  filter: blur(.6px); transform-origin: 50% 100%;
  animation: flick 2.8s ease-in-out infinite;
}
@keyframes flick {
  0%,100% { transform: translateX(-50%) scale(1) rotate(-2deg); opacity: .95; }
  30% { transform: translateX(-52%) scale(1.08, 1.18) rotate(2deg); }
  60% { transform: translateX(-48%) scale(.94, .9) rotate(-3deg); opacity: .8; }
}

.records {
  display: flex; gap: 10px; margin: 26px 0 22px;
}
.rec {
  flex: 1; text-align: center; padding: 14px 6px;
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius);
}
.rec b { display: block; font-size: 22px; color: var(--gold-bright); }
.rec span { font-size: 12px; color: var(--ink-faint); letter-spacing: .15em; }

.home-actions { display: flex; flex-direction: column; gap: 12px; }
.home-actions-row { display: flex; gap: 12px; }
.home-actions-row .btn { flex: 1; }

/* SEO 文案区 */
.seo-text {
  margin-top: 44px; padding-top: 26px; border-top: 1px dashed var(--line);
  color: var(--ink-dim); font-size: 14.5px;
}
.seo-text h2 { font-size: 17px; color: var(--gold); margin: 20px 0 8px; }
.seo-text strong { color: var(--ink); }
.site-foot { margin-top: 34px; text-align: center; color: var(--ink-faint); font-size: 12px; }

/* 广告位 */
.ad-slot {
  margin: 30px 0 6px; min-height: 96px;
  display: flex; align-items: center; justify-content: center;
  border: 1px dashed rgba(255,255,255,.08); border-radius: var(--radius);
  color: rgba(255,255,255,.12); font-size: 12px; letter-spacing: .3em;
}

/* ============ 发家方式 ============ */
.scr-title { text-align: center; font-size: 26px; color: var(--gold-bright); margin-top: 30px; }
.scr-sub { text-align: center; color: var(--ink-dim); margin: 8px 0 26px; font-size: 15px; }
.origin-list { display: flex; flex-direction: column; gap: 14px; }
.origin-card {
  text-align: left; padding: 18px; border-radius: var(--radius);
  background: linear-gradient(160deg, var(--paper-2), var(--paper));
  border: 1px solid var(--line); cursor: pointer; width: 100%;
  font-family: inherit; color: var(--ink);
  transition: transform .15s, border-color .15s, box-shadow .15s;
}
.origin-card:hover, .origin-card:focus-visible {
  transform: translateY(-2px); border-color: var(--gold);
  box-shadow: 0 8px 30px rgba(212,162,78,.15);
}
.origin-card h3 { font-size: 19px; color: var(--gold-bright); margin-bottom: 4px; }
.origin-card p { font-size: 14px; color: var(--ink-dim); }
.origin-card .o-stats { margin-top: 8px; font-size: 13px; color: var(--ink-faint); letter-spacing: .05em; }

/* ============ 游戏 HUD ============ */
#scr-game { padding-top: 12px; }
#scr-game.active { display: flex; flex-direction: column; height: 100dvh; }
.hud {
  background: linear-gradient(180deg, var(--paper-2), var(--paper));
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px 14px; box-shadow: var(--shadow);
  position: sticky; top: 8px; z-index: 5;
}
.hud-top { display: flex; align-items: baseline; gap: 12px; }
.hud-era b { font-size: 22px; color: var(--gold-bright); }
.hud-era span { font-size: 13px; color: var(--red-bright); margin-left: 6px; letter-spacing: .1em; }
.hud-gen { margin-left: auto; font-size: 14px; color: var(--ink-dim); }
.hud-gen b { color: var(--ink); font-size: 18px; }
.btn-speed {
  min-height: 36px; padding: 4px 12px; font-size: 13px; font-family: inherit;
  background: rgba(255,255,255,.05); color: var(--ink-dim);
  border: 1px solid var(--line); border-radius: 8px; cursor: pointer;
}

.hud-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 10px; }
.stat {
  background: rgba(0,0,0,.28); border: 1px solid var(--line); border-radius: 10px;
  padding: 8px 10px 10px; min-width: 0;
}
.stat-top { display: flex; align-items: center; gap: 5px; margin-bottom: 2px; }
.stat-icon { font-size: 14px; }
.stat-label { font-size: 12px; color: var(--ink-dim); white-space: nowrap; }
.stat-val { display: block; font-size: 20px; color: var(--ink); line-height: 1.3; }
.stat-tier { display: block; font-style: normal; font-size: 10.5px; color: var(--gold); line-height: 1.2; margin: -2px 0 2px; }
.bar {
  height: 5px; margin-top: 6px; background: rgba(0,0,0,.5); border-radius: 3px; overflow: hidden;
}
.bar i { display: block; height: 100%; width: 50%; border-radius: 4px; transition: width .5s ease; }
.stat-incense .bar i, #bar-incense { background: linear-gradient(90deg, #7a5cc0, #b08cff); }
.bar-gold i { background: linear-gradient(90deg, #a97a2a, #f0c069); }
.bar-red i { background: linear-gradient(90deg, #8a2f26, #d9534a); }
/* 香 */
.incense-stick { position: relative; width: 14px; height: 22px; display: flex; justify-content: center; }
.incense-stick i {
  position: absolute; bottom: 0; width: 3px; height: 100%; border-radius: 2px;
  background: linear-gradient(#c56a3a 0%, #7d4526 100%);
}
.incense-stick i::before {
  content: ""; position: absolute; top: -2px; left: -1.5px; width: 6px; height: 6px;
  background: radial-gradient(#ffb066, #d24a1e); border-radius: 50%;
  box-shadow: 0 0 8px 2px rgba(255, 120, 40, .55);
  animation: ember 2s ease-in-out infinite;
}
@keyframes ember { 50% { box-shadow: 0 0 12px 3px rgba(255,120,40,.8); } }
.smoke {
  position: absolute; top: -14px; left: 50%; width: 2px; height: 14px;
  background: linear-gradient(rgba(255,255,255,0), rgba(255,255,255,.25));
  animation: smoke 3s ease-in-out infinite;
}
@keyframes smoke {
  0% { transform: translateX(-50%) scaleY(.6); opacity: 0; }
  40% { opacity: .8; }
  100% { transform: translateX(-30%) translateY(-8px) scaleY(1.3) rotate(8deg); opacity: 0; }
}

.hud-patriarch {
  margin-top: 10px; padding-top: 9px; border-top: 1px dashed var(--line);
  font-size: 13.5px; color: var(--ink-dim); display: flex; gap: 8px; flex-wrap: wrap; align-items: center;
}
.hud-patriarch b { color: var(--ink); font-size: 15px; }
.trait-chip {
  font-size: 11.5px; padding: 1px 8px; border-radius: 999px;
  border: 1px solid var(--line); color: var(--ink-dim); background: rgba(0,0,0,.25);
}
.trait-chip.bad { color: var(--red-bright); border-color: rgba(217,83,74,.35); }
.trait-chip.good { color: var(--good); border-color: rgba(123,160,91,.35); }

/* ============ 事件日志 ============ */
.log-wrap {
  flex: 1; overflow-y: auto; margin-top: 12px; padding: 4px 2px 20px;
  -webkit-overflow-scrolling: touch; scrollbar-width: thin;
}
#log { list-style: none; display: flex; flex-direction: column; gap: 8px; }
#log li {
  padding: 10px 14px; border-radius: 10px; font-size: 14.5px;
  background: rgba(255,255,255,.028); border-left: 3px solid rgba(212,162,78,.25);
  animation: logIn .4s ease both;
}
@keyframes logIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
#log li .y { color: var(--ink-faint); font-size: 12px; margin-right: 8px; }
#log li.t-good { border-left-color: var(--good); }
#log li.t-bad { border-left-color: var(--red-bright); background: rgba(217,83,74,.06); }
#log li.t-gold { border-left-color: var(--gold-bright); background: rgba(212,162,78,.07); }
#log li.t-era {
  text-align: center; border: none; background: none; color: var(--red-bright);
  font-size: 15px; letter-spacing: .25em; padding: 16px 0 6px;
}
#log li.t-death { border-left-color: #888; background: rgba(255,255,255,.05); color: var(--ink); }
#log li .fx { display: block; font-size: 12.5px; color: var(--ink-faint); margin-top: 2px; }

.fade-warning {
  position: sticky; bottom: 0; text-align: center; padding: 10px;
  background: rgba(90, 20, 20, .92); color: #ffb4ab; font-size: 14px;
  border-radius: 10px; animation: pulse 1.6s ease-in-out infinite;
}
@keyframes pulse { 50% { opacity: .65; } }

/* ============ 弹窗 ============ */
.modal {
  position: fixed; inset: 0; z-index: 50;
  display: flex; align-items: center; justify-content: center;
  background: rgba(8, 5, 3, .78); backdrop-filter: blur(3px);
  padding: 18px; animation: scrIn .25s ease both;
}
.modal[hidden] { display: none; }
.modal-card {
  width: 100%; max-width: 480px; max-height: 86dvh; overflow-y: auto;
  background: linear-gradient(170deg, var(--paper-2), var(--paper));
  border: 1px solid rgba(212,162,78,.35); border-radius: 18px;
  padding: 24px 20px; box-shadow: var(--shadow);
}
.modal-card h3 { color: var(--gold-bright); font-size: 20px; text-align: center; }

.crisis-card { border-color: rgba(217,83,74,.5); }
.crisis-flag {
  text-align: center; color: var(--red-bright); font-size: 13px;
  letter-spacing: .3em; margin-bottom: 10px;
}
#crisis-text { margin: 12px 0 18px; font-size: 15.5px; color: var(--ink); }
.crisis-actions { display: flex; flex-direction: column; gap: 10px; }
.crisis-btn {
  width: 100%; text-align: left; padding: 13px 16px; border-radius: 12px;
  font-family: inherit; cursor: pointer;
  background: rgba(255,255,255,.04); border: 1px solid var(--line); color: var(--ink);
  transition: border-color .15s, background .15s;
}
.crisis-btn:hover:not(:disabled) { border-color: var(--gold); background: rgba(212,162,78,.08); }
.crisis-btn:disabled { opacity: .4; cursor: not-allowed; }
.crisis-btn b { font-size: 16px; }
.crisis-btn small { display: block; color: var(--ink-dim); font-size: 12.5px; margin-top: 2px; }
.crisis-btn .cost { float: right; color: #b08cff; font-size: 13px; }

/* 继承 */
.succ-sub { text-align: center; color: var(--ink-dim); font-size: 13.5px; margin: 8px 0 16px; }
.succ-list { display: flex; flex-direction: column; gap: 12px; }
.succ-card {
  width: 100%; text-align: left; padding: 15px 16px; border-radius: 12px;
  background: rgba(255,255,255,.04); border: 1px solid var(--line); color: var(--ink);
  font-family: inherit; cursor: pointer; transition: border-color .15s, transform .12s;
}
.succ-card:hover { border-color: var(--gold); transform: translateY(-1px); }
.succ-card h4 { font-size: 17px; color: var(--gold-bright); }
.succ-card h4 span { font-size: 13px; color: var(--ink-dim); font-weight: 400; margin-left: 8px; }
.succ-card .s-traits { margin-top: 6px; display: flex; gap: 6px; flex-wrap: wrap; }

/* 家训 */
.guxun-list { display: flex; flex-direction: column; gap: 10px; margin-top: 14px; }
.guxun-card {
  width: 100%; text-align: left; padding: 13px 15px; border-radius: 12px;
  background: rgba(255,255,255,.04); border: 1px solid var(--line); color: var(--ink);
  font-family: inherit; cursor: pointer; transition: border-color .15s;
}
.guxun-card:hover { border-color: var(--gold); }
.guxun-card b { color: var(--gold-bright); font-size: 16px; }
.guxun-card p { font-size: 13px; color: var(--ink-dim); margin-top: 3px; }

/* 成就 */
.ach-list { display: flex; flex-direction: column; gap: 8px; margin-top: 14px; }
.ach-item {
  display: flex; gap: 12px; align-items: center; padding: 11px 14px;
  border-radius: 10px; background: rgba(255,255,255,.03); border: 1px solid var(--line);
}
.ach-item .a-icon { font-size: 22px; }
.ach-item b { font-size: 15px; }
.ach-item p { font-size: 12.5px; color: var(--ink-dim); }
.ach-item.locked { opacity: .38; filter: grayscale(1); }

.help-body { margin-top: 12px; font-size: 14.5px; color: var(--ink-dim); }
.help-body p { margin-bottom: 10px; }
.help-body b { color: var(--ink); }

/* ============ 结局 ============ */
#scr-end { padding-top: 30px; }
.end-card {
  background: linear-gradient(170deg, var(--paper-2), var(--paper));
  border: 1px solid rgba(212,162,78,.3); border-radius: 20px;
  padding: 34px 22px 26px; box-shadow: var(--shadow); position: relative; overflow: hidden;
}
.end-stamp {
  position: absolute; top: 22px; right: 14px;
  border: 3px solid var(--red-bright); color: var(--red-bright);
  font-size: 15px; font-weight: 900; padding: 6px 10px; border-radius: 6px;
  transform: rotate(12deg); opacity: .85; letter-spacing: .1em;
  animation: stampIn .5s cubic-bezier(.2, 2, .4, 1) .3s both;
}
@keyframes stampIn { from { transform: rotate(12deg) scale(2.4); opacity: 0; } to { transform: rotate(12deg) scale(1); opacity: .85; } }
.end-title { font-size: 24px; color: var(--gold-bright); text-align: center; margin-top: 6px; }
.end-verdict {
  text-align: center; color: var(--ink); font-size: 15.5px; margin: 14px 0 20px;
  padding: 12px; background: rgba(0,0,0,.25); border-radius: 10px;
}
.end-stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.end-stats .es {
  padding: 10px; text-align: center; background: rgba(255,255,255,.03);
  border-radius: 10px; border: 1px solid var(--line);
}
.end-stats .es b { display: block; font-size: 19px; color: var(--gold-bright); }
.end-stats .es span { font-size: 12px; color: var(--ink-faint); }

.tree-title { text-align: center; color: var(--red-bright); font-size: 14px; letter-spacing: .3em; margin: 24px 0 12px; }
.tree { display: flex; flex-direction: column; align-items: center; }
.tree .node {
  width: 100%; max-width: 340px; padding: 10px 14px; border-radius: 10px;
  background: rgba(255,255,255,.035); border: 1px solid var(--line);
  font-size: 14px; text-align: center;
}
.tree .node b { color: var(--gold-bright); }
.tree .node small { display: block; color: var(--ink-faint); font-size: 12px; }
.tree .link { width: 2px; height: 16px; background: var(--line); }

.end-ach { margin-top: 18px; display: flex; flex-direction: column; gap: 6px; }
.end-ach .new-ach {
  text-align: center; font-size: 14px; color: var(--gold-bright);
  padding: 8px; border: 1px dashed rgba(212,162,78,.4); border-radius: 10px;
  animation: scrIn .5s ease both;
}
.end-actions { margin-top: 22px; display: flex; flex-direction: column; gap: 10px; }

/* toast */
#toast-wrap { position: fixed; top: 14px; left: 50%; transform: translateX(-50%); z-index: 99; display: flex; flex-direction: column; gap: 8px; width: min(92vw, 420px); }
.toast {
  background: rgba(30, 22, 12, .95); border: 1px solid var(--gold);
  color: var(--gold-bright); padding: 12px 16px; border-radius: 12px;
  text-align: center; font-size: 14.5px; box-shadow: var(--shadow);
  animation: toastIn .4s ease both;
}
@keyframes toastIn { from { opacity: 0; transform: translateY(-14px); } to { opacity: 1; transform: none; } }

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

@media (min-width: 600px) {
  .home-title { letter-spacing: .12em; }
  .end-stats { grid-template-columns: repeat(4, 1fr); }
}

/* ============ v2：特效 & 移动端打磨 ============ */

/* 滚动条：日志和弹窗隐藏滚动条但保留滑动；页面滚动条纤细主题化 */
html { scrollbar-width: thin; scrollbar-color: rgba(212,162,78,.3) transparent; }
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-thumb { background: rgba(212,162,78,.25); border-radius: 3px; }
::-webkit-scrollbar-track { background: transparent; }
.log-wrap, .modal-card { scrollbar-width: none; }
.log-wrap::-webkit-scrollbar, .modal-card::-webkit-scrollbar { display: none; }

body { touch-action: manipulation; overflow-x: hidden; }

/* 触屏按压反馈（手机没有 hover） */
.origin-card:active, .succ-card:active, .guxun-card:active { transform: scale(.98); border-color: var(--gold); }
.crisis-btn:active:not(:disabled) { transform: scale(.98); background: rgba(212,162,78,.1); }

/* 标题呼吸金光 */
.home-title { animation: titleGlow 3.8s ease-in-out infinite; }
@keyframes titleGlow {
  0%, 100% { text-shadow: 0 0 40px rgba(212, 162, 78, .35), 0 2px 0 rgba(0,0,0,.6); }
  50% { text-shadow: 0 0 70px rgba(240, 192, 105, .65), 0 0 24px rgba(240,192,105,.3), 0 2px 0 rgba(0,0,0,.6); }
}

/* ---------- 特效层 ---------- */
#fx-layer { position: fixed; inset: 0; pointer-events: none; z-index: 90; overflow: hidden; }

.flash { position: absolute; inset: 0; animation: flashFade .95s ease-out both; }
.flash.gold { background: radial-gradient(ellipse at 50% 40%, rgba(240,192,105,.42), transparent 65%); }
.flash.red { background: radial-gradient(ellipse at 50% 40%, rgba(217,83,74,.38), transparent 65%); }
.flash.purple { background: radial-gradient(ellipse at 50% 40%, rgba(176,140,255,.36), transparent 65%); }
@keyframes flashFade { 0% { opacity: 0; } 15% { opacity: 1; } 100% { opacity: 0; } }

.spark {
  position: absolute; width: 6px; height: 6px; border-radius: 50%;
  background: radial-gradient(#fff6d8, #f0c069);
  box-shadow: 0 0 8px 2px rgba(240,192,105,.7);
  animation: sparkFly 1.4s ease-out both;
}
@keyframes sparkFly {
  0% { transform: translate(0, 0) scale(.4); opacity: 0; }
  15% { opacity: 1; }
  100% { transform: translate(var(--dx), var(--dy)) scale(1); opacity: 0; }
}

.era-banner {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px;
  background: rgba(10, 7, 4, .84); backdrop-filter: blur(2px);
  animation: bannerIn 2.4s ease both;
}
.era-banner b {
  font-size: clamp(38px, 12vw, 60px); color: var(--gold-bright); font-weight: 900;
  letter-spacing: .3em; text-indent: .3em;
  text-shadow: 0 0 40px rgba(212,162,78,.5);
}
.era-banner span { color: var(--ink-dim); font-size: 15px; letter-spacing: .15em; padding: 0 24px; text-align: center; }
@keyframes bannerIn { 0% { opacity: 0; } 12% { opacity: 1; } 78% { opacity: 1; } 100% { opacity: 0; } }

.confetti {
  position: absolute; top: -14px; width: 8px; height: 14px; border-radius: 2px; opacity: .9;
  animation: confFall linear both;
}
@keyframes confFall {
  0% { transform: translate(0, -20px) rotate(0deg); }
  100% { transform: translate(var(--drift), 108vh) rotate(var(--rot)); opacity: .65; }
}

/* 属性飘字 */
.stat { position: relative; }
.float-num {
  position: absolute; right: 2px; top: -6px; font-size: 13px; font-weight: 700;
  color: var(--good); pointer-events: none; animation: floatUp 1.05s ease-out both;
}
.float-num.neg { color: var(--red-bright); }
@keyframes floatUp {
  0% { transform: translateY(5px); opacity: 0; }
  25% { opacity: 1; }
  100% { transform: translateY(-16px); opacity: 0; }
}

/* 大祸震屏 */
.shake { animation: shakeX .5s ease both; }
@keyframes shakeX {
  0%, 100% { transform: none; }
  20% { transform: translateX(-7px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(3px); }
}

/* 香火将尽：画面渐褪色 */
body.fading #scr-game { filter: grayscale(.55) brightness(.85); transition: filter 1.2s ease; }
#scr-game { transition: filter 1.2s ease; }

/* 点香彩蛋 */
.stat-incense { cursor: pointer; -webkit-tap-highlight-color: transparent; }
.incense-stick.puff { animation: incensePop .35s ease; }
@keyframes incensePop { 50% { transform: scale(1.3); } }

/* 稀有事件流光 */
#log li.t-rare {
  border-left-color: var(--gold-bright);
  background: linear-gradient(110deg, rgba(212,162,78,.08) 25%, rgba(240,192,105,.22) 50%, rgba(212,162,78,.08) 75%);
  background-size: 220% 100%;
  animation: logIn .4s ease both, shimmerBg 2.6s linear infinite;
}
@keyframes shimmerBg { from { background-position: 130% 0; } to { background-position: -130% 0; } }

/* 传家宝 */
.hud-relics { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 9px; }
.relic-chip {
  font-family: inherit; font-size: 12.5px; min-height: 32px; padding: 4px 12px;
  border-radius: 999px; border: 1px solid rgba(240,192,105,.45);
  background: rgba(212,162,78,.1); color: var(--gold-bright); cursor: pointer;
  transition: transform .12s;
}
.relic-chip:active { transform: scale(.94); }

.modal-card h4 {
  color: var(--red-bright); font-size: 14px; letter-spacing: .3em;
  text-align: center; margin: 20px 0 4px;
}

/* 危机代价提示 */
.crisis-stakes {
  text-align: center; font-size: 13px; color: var(--red-bright);
  background: rgba(217,83,74,.08); border: 1px dashed rgba(217,83,74,.3);
  border-radius: 8px; padding: 7px 10px; margin: 0 0 14px;
}

/* ============ v3：开局设定（庇佑签 / 方针） ============ */
.blessing-list { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.blessing-card {
  text-align: left; padding: 13px 14px; border-radius: 12px; min-height: 92px;
  background: linear-gradient(160deg, var(--paper-2), var(--paper));
  border: 1px solid var(--line); color: var(--ink); font-family: inherit; cursor: pointer;
  transition: transform .15s, border-color .15s, box-shadow .15s;
  position: relative;
}
.blessing-card .b-icon { font-size: 20px; }
.blessing-card b { display: block; font-size: 15px; color: var(--ink); margin: 2px 0; }
.blessing-card p { font-size: 12px; color: var(--ink-dim); line-height: 1.5; }
.blessing-card:active { transform: scale(.97); }
.blessing-card.picked {
  border-color: var(--gold-bright);
  background: linear-gradient(160deg, rgba(212,162,78,.16), rgba(212,162,78,.06));
  box-shadow: 0 0 20px rgba(212,162,78,.2);
}
.blessing-card.picked::after {
  content: "✓"; position: absolute; top: 8px; right: 10px;
  color: var(--gold-bright); font-weight: 900;
}
#blessing-count { color: var(--gold-bright); font-weight: 700; }

.setup-actions { display: flex; gap: 12px; margin-top: 20px; }
.setup-actions .btn { flex: 1; }

.policy-title { color: var(--gold); font-size: 16px; margin: 22px 0 10px; }
.policy-title small { color: var(--ink-faint); font-size: 12px; font-weight: 400; }
.policy-list { display: flex; flex-direction: column; gap: 8px; }
.policy-card {
  text-align: left; padding: 12px 14px; border-radius: 12px; width: 100%;
  background: rgba(255,255,255,.03); border: 1px solid var(--line);
  color: var(--ink); font-family: inherit; cursor: pointer;
  transition: border-color .15s, background .15s; position: relative;
}
.policy-card b { font-size: 15px; }
.policy-card p { font-size: 12.5px; color: var(--ink-dim); margin-top: 2px; }
.policy-card:active { transform: scale(.98); }
.policy-card.picked {
  border-color: var(--gold-bright); background: rgba(212,162,78,.1);
}
.policy-card.picked::after {
  content: "✓"; position: absolute; top: 10px; right: 12px;
  color: var(--gold-bright); font-weight: 900;
}

/* 危机开场日志 */
#log li.t-crisis {
  border-left-color: #e08a3c;
  background: rgba(224, 138, 60, .07);
}

/* 传说结局：金印 */
.end-stamp.win { border-color: var(--gold-bright); color: var(--gold-bright); }

/* ============ 姓氏选择 ============ */
.surname-row { display: flex; gap: 10px; margin-bottom: 12px; }
#surname-input {
  flex: 1; min-height: 52px; padding: 8px 16px;
  font-family: inherit; font-size: 24px; font-weight: 700; text-align: center;
  letter-spacing: .2em; color: var(--gold-bright);
  background: rgba(0,0,0,.3); border: 1px solid var(--line); border-radius: var(--radius);
  outline: none;
}
#surname-input:focus { border-color: var(--gold); box-shadow: 0 0 16px rgba(212,162,78,.15); }
#surname-input::placeholder { color: var(--ink-faint); font-size: 16px; letter-spacing: .05em; font-weight: 400; }
.surname-poem {
  min-height: 44px; text-align: center; font-size: 13.5px; color: var(--ink-dim);
  padding: 8px 10px; margin-bottom: 14px;
  background: rgba(212,162,78,.05); border: 1px dashed var(--line); border-radius: 10px;
}
.surname-poem b { color: var(--gold-bright); }
.surname-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(52px, 1fr)); gap: 7px;
}
.surname-chip {
  min-height: 44px; font-family: inherit; font-size: 17px; color: var(--ink);
  background: rgba(255,255,255,.03); border: 1px solid var(--line); border-radius: 10px;
  cursor: pointer; transition: border-color .12s, transform .12s;
  -webkit-tap-highlight-color: transparent;
}
.surname-chip:active { transform: scale(.92); }
.surname-chip.picked { border-color: var(--gold-bright); color: var(--gold-bright); background: rgba(212,162,78,.12); }
.surname-chip.fuxing { font-size: 14px; }

/* 结算：家族排名行 */
.end-pct { display: block; margin-top: 8px; font-size: 14px; color: var(--ink-dim); }
.end-pct b { color: var(--gold-bright); font-size: 17px; }

/* ============ v5：姓氏印章 & 交互打磨 ============ */

/* hidden 的广告位必须真正隐藏（.ad-slot 的 display:flex 会覆盖 hidden 属性） */
.ad-slot[hidden] { display: none; }

/* 姓氏印章 */
.seal-wrap { display: flex; justify-content: center; margin: 4px 0 16px; }
.surname-seal {
  min-width: 132px; height: 132px; padding: 0 18px;
  display: flex; align-items: center; justify-content: center;
  background:
    radial-gradient(ellipse at 30% 25%, rgba(255,255,255,.14), transparent 55%),
    linear-gradient(160deg, #c0392b, #8e2a20);
  color: #fff3e2; font-size: 62px; font-weight: 900; line-height: 1;
  border-radius: 20px;
  border: 3px solid rgba(255, 240, 220, .3);
  outline: 2px solid rgba(176, 58, 46, .45); outline-offset: 5px;
  box-shadow: 0 14px 44px rgba(176, 58, 46, .35), inset 0 0 26px rgba(0, 0, 0, .3);
  transform: rotate(-3deg);
  text-shadow: 0 3px 10px rgba(0, 0, 0, .4);
}
.surname-seal.two { font-size: 42px; letter-spacing: .04em; }
.surname-seal.pop { animation: sealPop .35s cubic-bezier(.2, 1.8, .4, 1); }
@keyframes sealPop { 0% { transform: rotate(-3deg) scale(.82); } 100% { transform: rotate(-3deg) scale(1); } }

.btn-dice { min-width: 56px; font-size: 22px; padding: 8px; }
.surname-row { margin-top: 18px; }
.surname-empty {
  text-align: center; color: var(--ink-dim); font-size: 13.5px;
  padding: 14px 10px; border: 1px dashed var(--line); border-radius: 10px; margin-top: 4px;
}

/* 岁月静好的小注脚 */
#log li.t-quiet {
  border-left-color: transparent; background: none;
  color: var(--ink-faint); font-size: 13px; text-align: center; padding: 4px 14px;
}

/* 发家方式：预选态 */
.origin-card { position: relative; }
.origin-card.picked {
  border-color: var(--gold-bright);
  background: linear-gradient(160deg, rgba(212,162,78,.14), rgba(212,162,78,.04));
  box-shadow: 0 0 24px rgba(212,162,78,.18);
}
.origin-card.picked::after {
  content: "✓"; position: absolute; top: 12px; right: 14px;
  color: var(--gold-bright); font-weight: 900; font-size: 18px;
}

/* 家业档位并入标签行，三卡等高对齐 */
.stat-top { min-width: 0; }
.stat-top .stat-tier {
  font-style: normal; color: var(--gold); font-size: 10.5px; margin: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.stat-top .stat-tier { flex: 1 1 auto; }

/* ============ 族谱长图弹窗 ============ */
.poster-card { max-width: 440px; }
.poster-wrap {
  margin-top: 8px; border-radius: 14px; overflow: hidden;
  border: 1px solid rgba(212,162,78,.35); max-height: 52dvh; overflow-y: auto;
  scrollbar-width: none;
}
.poster-wrap::-webkit-scrollbar { display: none; }
#poster-img { display: block; width: 100%; }
.poster-actions { display: flex; gap: 10px; margin-top: 14px; }
.poster-actions .btn { flex: 1; padding: 12px 8px; font-size: 15px; }
.btn-poster { border-color: rgba(212,162,78,.4); color: var(--gold-bright); }
.poster-actions .btn { white-space: nowrap; font-size: 14px; padding: 12px 4px; }

/* ============ 推演全程回看 ============ */
.history-card { max-width: 480px; }
.history-list {
  margin-top: 10px; max-height: 62dvh; overflow-y: auto;
  scrollbar-width: none; -webkit-overflow-scrolling: touch;
}
.history-list::-webkit-scrollbar { display: none; }
.history-list ul { list-style: none; display: flex; flex-direction: column; gap: 7px; }
.history-list li {
  padding: 9px 13px; border-radius: 10px; font-size: 14px; line-height: 1.65;
  background: rgba(255,255,255,.028); border-left: 3px solid rgba(212,162,78,.25);
}
.history-list li .y { color: var(--ink-faint); font-size: 12px; margin-right: 8px; }
.history-list li .fx { display: block; font-size: 12px; color: var(--ink-faint); margin-top: 2px; }
.history-list li.t-good { border-left-color: var(--good); }
.history-list li.t-bad { border-left-color: var(--red-bright); background: rgba(217,83,74,.06); }
.history-list li.t-gold { border-left-color: var(--gold-bright); background: rgba(212,162,78,.07); }
.history-list li.t-era { text-align: center; border: none; background: none; color: var(--red-bright); letter-spacing: .25em; }
.history-list li.t-death { border-left-color: #888; background: rgba(255,255,255,.05); }
.history-list li.t-rare { border-left-color: var(--gold-bright); background: rgba(240,192,105,.1); }
.history-list li.t-crisis { border-left-color: #e08a3c; background: rgba(224,138,60,.07); }
.history-list li.t-quiet { border-left-color: transparent; background: none; color: var(--ink-faint); font-size: 12.5px; text-align: center; }
