/* ==========================================================================
   十四亿分之1 (1in14e / 浮生若梦) - 全局设计系统与视觉规范
   对标 1in8b.life 报章与印章质感，支持 H5 手机仿真对比与微信小程序平滑移植
   ========================================================================== */

:root {
  /* 基础纸质与底色系统 (Paper & Card Surfaces) */
  --paper: #EBF0ED;
  --card: #F7FAF8;
  --card2: #F0F4F2;
  --ink: #13212A;
  --ink2: #4A5A61;
  --ink3: #627278;
  --rule: #C7D2CE;
  --rule2: #DCE4E1;
  --border-soft: rgba(19, 33, 42, 0.14);
  --fg: var(--ink);
  --kicker: var(--ink3);
  --bg-card: var(--card);
  --bg-hover: var(--card2);

  /* 品牌印记与色调 (Burgundy Accent & Forest Stamp) */
  --accent: #8C1D3C;
  --accent-ink: #FFFFFF;
  --accent-soft: #F4E4E8;
  --stamp: #0F6E68;
  --stamp-soft: #DDEEEB;
  --gold: #9C7020;

  /* 语义反馈 (State Indicators) */
  --good: #2B7A4E;
  --bad: #B0362B;
  --warn: #A8730F;
  --loss: #2C2F3A;

  /* 点阵地图与背景 */
  --tg-land: #CBD5D1;
  --bench-bg: #1A2226;
  --bench-card: #242E33;
  --bench-text: #E5ECE9;

  /* 投影系统 (Elevation & Shadows) */
  --shadow-sm: 0 1px 2px rgba(19, 33, 42, 0.05);
  --shadow: 0 1px 0 rgba(19, 33, 42, 0.04), 0 8px 24px -12px rgba(19, 33, 42, 0.16);
  --shadow-lg: 0 16px 40px -10px rgba(19, 33, 42, 0.28);
  --phone-bezel: #1C2429;

  /* 字体家族 (Typography Stacks) */
  --f-display: 'Hahmlet', 'Noto Serif SC', 'Source Han Serif SC', 'Songti SC', 'STSong', serif;
  --f-body: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
  --f-mono: ui-monospace, 'SFMono-Regular', Menlo, Monaco, Consolas, 'Liberation Mono', monospace;

  /* 尺寸与过渡 */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 14px;
  --phone-w: 393px;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
}

/* ==========================================================================
   深色模式支持 (Dark Mode Support)
   支持根据系统自动切换，或通过 [data-theme="dark"] 手动强制切换
   ========================================================================== */
:root[data-theme="dark"] {
  --paper: #0D1316;
  --card: #141D21;
  --card2: #1A2428;
  --ink: #E1E9E6;
  --ink2: #A3B2AF;
  --ink3: #869692;
  --rule: #28373C;
  --rule2: #1D282C;
  --border-soft: rgba(225, 233, 230, 0.16);
  --accent: #E2678A;
  --accent-ink: #1B0910;
  --accent-soft: #381A24;
  --stamp: #4CC0AF;
  --stamp-soft: #12302D;
  --gold: #D9AF59;
  --good: #5CC38B;
  --bad: #F07B6B;
  --warn: #E2B04C;
  --loss: #C9CDD8;
  --tg-land: #253237;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow: 0 1px 0 rgba(0, 0, 0, 0.3), 0 10px 30px -14px rgba(0, 0, 0, 0.6);
  --shadow-lg: 0 18px 44px -12px rgba(0, 0, 0, 0.85);
  color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #0D1316;
    --card: #141D21;
    --card2: #1A2428;
    --ink: #E1E9E6;
    --ink2: #A3B2AF;
    --ink3: #869692;
    --rule: #28373C;
    --rule2: #1D282C;
    --border-soft: rgba(225, 233, 230, 0.16);
    --accent: #E2678A;
    --accent-ink: #1B0910;
    --accent-soft: #381A24;
    --stamp: #4CC0AF;
    --stamp-soft: #12302D;
    --gold: #D9AF59;
    --good: #5CC38B;
    --bad: #F07B6B;
    --warn: #E2B04C;
    --loss: #C9CDD8;
    --tg-land: #253237;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow: 0 1px 0 rgba(0, 0, 0, 0.3), 0 10px 30px -14px rgba(0, 0, 0, 0.6);
    --shadow-lg: 0 18px 44px -12px rgba(0, 0, 0, 0.85);
    color-scheme: dark;
  }
}

/* ==========================================================================
   全局重置与排版基础 (Base & Reset)
   ========================================================================== */
*, *::before, *::after {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bench-bg);
  color: var(--ink);
  font-family: var(--f-body);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

button {
  font-family: inherit;
  font-size: inherit;
  line-height: inherit;
  color: inherit;
  background: none;
  border: none;
  cursor: pointer;
  user-select: none;
}

button:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

[hidden] {
  display: none !important;
}

/* ==========================================================================
   桌面端双模工作台 (Workbench Shell)
   ========================================================================== */
.workbench {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  background: var(--bench-bg);
  padding: 12px 16px 28px;
  transition: background 0.2s ease;
}

/* 顶部开发与对照工具栏 */
.desk-toolbar {
  width: 100%;
  max-width: 900px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 8px 14px;
  margin-bottom: 12px;
  background: var(--bench-card);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-md);
  color: var(--bench-text);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
  flex-wrap: wrap;
}

.desk-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13.5px;
}

.desk-brand b {
  font-family: var(--f-display);
  font-size: 15px;
  color: #fff;
}

.desk-brand small {
  color: #8fa2a8;
  font-family: var(--f-mono);
  font-size: 11px;
}

.desk-badge {
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 3px;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.desk-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.tool-btn, .tool-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  font-size: 12.5px;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-sm);
  color: var(--bench-text);
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s;
}

.tool-btn:hover, .tool-link:hover {
  background: rgba(255, 255, 255, 0.14);
  border-color: rgba(255, 255, 255, 0.22);
}

.tool-link {
  color: #5ec4b6;
  border-color: rgba(94, 196, 182, 0.3);
}

/* 仿真手机外壳 (Phone Mockup Device) */
.device-shell {
  width: var(--phone-w);
  max-width: 100%;
  height: 852px;
  max-height: calc(100vh - 84px);
  max-height: calc(100dvh - 84px);
  background: var(--paper);
  border: 11px solid var(--phone-bezel);
  border-radius: 46px;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.1), var(--shadow-lg);
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
  transition: width 0.3s var(--ease), max-width 0.3s var(--ease), border-radius 0.3s var(--ease);
}

/* 宽屏响应对比模式 (Fluid Mode) */
.workbench.mode-fluid .device-shell {
  width: 720px;
  border-width: 2px;
  border-radius: var(--radius-lg);
  border-color: var(--rule);
}

.workbench.mode-fluid .device-notch {
  display: none;
}

/* 仿真手机顶部状态栏与灵动岛 */
.device-notch {
  flex: none;
  height: 38px;
  background: var(--paper);
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 20px;
  font-family: var(--f-mono);
  font-size: 11.5px;
  font-weight: 600;
  color: var(--ink);
  z-index: 50;
  border-bottom: 1px solid rgba(0, 0, 0, 0.03);
  user-select: none;
  pointer-events: none;
}

.notch-camera {
  width: 90px;
  height: 18px;
  background: var(--phone-bezel);
  border-radius: 12px;
  margin-top: -2px;
}

.notch-icons {
  display: flex;
  align-items: center;
  gap: 4px;
}

/* 应用真实视口容器 (App Viewport) */
.app-viewport {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--paper);
  color: var(--ink);
  overflow: hidden;
  position: relative;
}

/* 彻底隐藏手机仿真器内部的浏览器丑陋默认滚动条 (保留平滑滚动行为) */
.app-viewport, .screen, .life-scroll, .feed, .more-menu, .shop-list, .sheet-choices {
  scrollbar-width: none; /* Firefox */
  -ms-overflow-style: none; /* IE 10+ */
}

.app-viewport::-webkit-scrollbar,
.screen::-webkit-scrollbar,
.life-scroll::-webkit-scrollbar,
.feed::-webkit-scrollbar,
.more-menu::-webkit-scrollbar,
.shop-list::-webkit-scrollbar,
.sheet-choices::-webkit-scrollbar {
  display: none !important;
  width: 0 !important;
  height: 0 !important;
}

/* ==========================================================================
   移动端原生适配 (Mobile Native Viewport & Safe Areas)
   ========================================================================== */
@media (max-width: 600px), (hover: none) and (pointer: coarse) and (max-width: 1024px) and (max-height: 600px) {
  body {
    background: var(--paper);
  }

  .workbench {
    padding: 0;
    background: var(--paper);
    min-height: 100vh;
    min-height: 100dvh;
  }

  .desk-toolbar {
    display: none;
  }

  .device-shell {
    width: 100% !important;
    height: 100vh !important;
    height: 100dvh !important;
    max-height: none !important;
    border: none !important;
    border-radius: 0 !important;
    box-shadow: none !important;
  }

  /* iOS keyboards can shrink only the visual viewport, leaving 100dvh unchanged. */
  html.keyboard-viewport .device-shell {
    position: fixed;
    top: var(--editing-top);
    left: 0;
    right: 0;
    height: var(--editing-height) !important;
  }

  .app-viewport :is(textarea, select) {
    font: inherit;
    font-size: 16px;
  }

  .device-notch {
    display: none !important;
  }

  .screen {
    padding-top: calc(14px + env(safe-area-inset-top, 0px)) !important;
    padding-bottom: calc(24px + env(safe-area-inset-bottom, 0px)) !important;
    padding-left: max(16px, env(safe-area-inset-left, 0px));
    padding-right: max(16px, env(safe-area-inset-right, 0px));
  }

  #lifeview.on {
    padding-top: 0 !important;
    padding-bottom: 0 !important;
  }

  #lifeview .top {
    padding-top: calc(8px + env(safe-area-inset-top, 0px));
  }

  #dead.on,
  #replayview.on,
  #hallview.on,
  #meetview.on {
    padding: 0 !important;
  }

  #dead.on .end-scroll,
  #replayview.on .end-scroll,
  #hallview.on .end-scroll,
  #meetview.on .end-scroll {
    padding: calc(14px + env(safe-area-inset-top, 0px)) 16px 8px;
  }

  #dead.on .end-dock,
  #replayview.on .end-dock,
  #hallview.on .end-dock,
  #meetview.on .end-dock {
    padding: 8px 16px calc(16px + env(safe-area-inset-bottom, 0px));
  }

  #lifeview .life-scroll {
    padding-left: max(12px, env(safe-area-inset-left, 0px));
    padding-right: max(12px, env(safe-area-inset-right, 0px));
  }

  #lifeview .sheet-hd,
  #lifeview .sheet > :is(.sheet-bd, .shop-body) {
    padding-left: max(18px, env(safe-area-inset-left, 0px));
    padding-right: max(18px, env(safe-area-inset-right, 0px));
  }
}

/* ==========================================================================
   屏幕切换与滚动层 (Screen System)
   ========================================================================== */
.screen {
  display: none;
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 16px 16px 28px;
  -webkit-overflow-scrolling: touch;
}

.screen.on {
  display: block;
}

/* ==========================================================================
   排版阶梯与通用组件 (Typography & Components)
   ========================================================================== */
h1 {
  font-family: var(--f-display);
  font-size: 32px;
  font-weight: 700;
  line-height: 1.15;
  margin: 6px 0 10px;
  letter-spacing: -0.02em;
}

h1 em {
  font-style: normal;
  color: var(--accent);
}

h2 {
  font-family: var(--f-display);
  font-size: 22px;
  font-weight: 600;
  margin: 0 0 6px;
}

.kicker {
  font-family: var(--f-mono);
  font-size: 11.5px;
  letter-spacing: 0.04em;
  color: var(--stamp);
  font-weight: 600;
  text-transform: uppercase;
  margin: 0 0 2px;
}

.lbl {
  font-size: 12px;
  letter-spacing: 0.03em;
  color: var(--ink3);
  font-weight: 600;
  margin: 0 0 4px;
}

.note {
  color: var(--ink2);
  font-size: 13px;
  line-height: 1.5;
}

/* 按钮组与触控规范 */
.cta, .ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  font-weight: 600;
  text-align: center;
  transition: transform 0.08s ease, filter 0.15s ease, background 0.15s;
}

.cta:active, .ghost:active, .seg button:active {
  transform: scale(0.97);
}

.cta {
  background: var(--accent);
  color: var(--accent-ink);
  border: 1px solid var(--accent);
  padding: 13px 20px;
  font-size: 16px;
  width: 100%;
  box-shadow: var(--shadow);
  margin-top: 10px;
}

.cta.sm {
  padding: 6px 14px;
  font-size: 13px;
  width: auto;
  margin-top: 0;
}

.cta:hover {
  filter: brightness(1.06);
}

.ghost {
  background: var(--card);
  border: 1px solid var(--rule);
  color: var(--ink);
  padding: 8px 14px;
  font-size: 14px;
}

.ghost.sm {
  padding: 4px 10px;
  font-size: 12.5px;
}

.ghost:hover {
  border-color: var(--ink3);
}

.row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.row .cta, .row .ghost {
  width: auto;
  flex: 1;
}

/* 分段选择器 (Segmented Control Pills) */
.seg {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 6px 0 12px;
}

.seg button {
  border: 1px solid var(--rule);
  background: var(--card);
  color: var(--ink2);
  padding: 7px 12px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  transition: all 0.15s ease;
}

.seg button.on {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
}

#focus button {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1px;
  line-height: 1.2;
}

#focus button small {
  font-size: 10px;
  font-weight: 400;
  opacity: 0.8;
}

/* 下拉表单 */
select {
  width: 100%;
  padding: 9px 12px;
  font: inherit;
  background: var(--card);
  color: var(--ink);
  border: 1px solid var(--rule);
  border-radius: var(--radius-sm);
  margin: 6px 0 12px;
  appearance: auto;
}

/* ==========================================================================
   开场屏幕 (Intro Screen)
   ========================================================================== */
.home .tg-bg {
  position: relative;
  margin: -18px -18px 10px;
  overflow: hidden;
  -webkit-mask-image: linear-gradient(to bottom, #000 0%, #000 70%, transparent 100%);
  mask-image: linear-gradient(to bottom, #000 0%, #000 70%, transparent 100%);
}

.home .tg-bg canvas {
  display: block;
  width: 116%;
  margin-left: -8%;
  cursor: pointer;
}

.home .lede {
  margin: 0 0 14px;
  font-size: 15px;
  line-height: 1.65;
  color: var(--ink2);
}

.home .counter {
  display: flex;
  gap: 22px;
  margin: 18px 0 14px;
  padding: 12px 14px;
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
}

.home .counter div {
  display: flex;
  flex-direction: column;
}

.home .counter strong {
  font-family: var(--f-display);
  font-size: 28px;
  font-weight: 700;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}

.home .counter span {
  font-size: 12px;
  color: var(--ink3);
  margin-top: 2px;
}

.home .floatline {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  margin: 14px 0 16px;
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--ink2);
  background: var(--stamp-soft);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
}

.home .dot {
  width: 8px;
  height: 8px;
  margin-top: 6px;
  border-radius: 50%;
  background: var(--stamp);
  flex: 0 0 auto;
}

.home .mapcap {
  margin: 0 0 8px;
  font-size: 12.5px;
  color: var(--ink3);
  line-height: 1.45;
}

.home .tip {
  position: absolute;
  z-index: 10;
  min-width: 7.5em;
  padding: 8px 12px;
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  line-height: 1.45;
  box-shadow: var(--shadow);
  pointer-events: none;
}

/* 出生几率卡片 */
.home .odds {
  margin-top: 16px;
  padding: 14px 14px;
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
}

.home .odds h2 {
  margin: 0 0 2px;
  font-family: var(--f-display);
  font-size: 18px;
  font-weight: 600;
}

.home .odds .sub,
.home .odds .note {
  margin: 0 0 10px;
  font-size: 12.5px;
  color: var(--ink3);
}

.home .odds .note {
  margin: 8px 0 0;
}

#birthOdds .orow {
  grid-template-columns: 6.4em minmax(0, 1fr) 3.6em;
}

.home .orow {
  display: grid;
  grid-template-columns: 5.6em minmax(0, 1fr) 3.6em;
  gap: 8px;
  align-items: center;
  padding: 3.5px 0;
  font-size: 13.5px;
}

.home .orow .bar {
  height: 8px;
  background: var(--rule2);
  border-radius: 2px;
  overflow: hidden;
}

.home .orow .bar i {
  display: block;
  height: 100%;
  background: var(--stamp);
  border-radius: 2px;
}

.home .orow .v {
  color: var(--ink2);
  font-family: var(--f-mono);
  font-size: 12.5px;
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.home .opts {
  margin-top: 20px;
}

.home-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  margin: 4px 0 8px;
}

.home-links button {
  background: none;
  border: 0;
  padding: 6px 0;
  color: var(--stamp);
  font: inherit;
  font-size: 14px;
}

.soft-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
  font-size: 14px;
  color: var(--ink);
  cursor: pointer;
}

.soft-toggle input {
  width: 16px;
  height: 16px;
  margin: 0;
}

#softHint {
  margin: 6px 0 0;
}

#aboutview #softHelp {
  margin: 0 0 8px;
  font-size: 14px;
  line-height: 1.55;
}

/* 开场把「出生」钉在手机框底部，不用先滚过地图才找得到按钮。 */
#intro.on {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
  padding: 0;
}

#intro .intro-scroll {
  flex: 1;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 16px 16px 28px;
  scrollbar-width: none;
}

.birth-dock {
  flex: none;
  padding: 10px 16px calc(14px + env(safe-area-inset-bottom, 10px));
  background: var(--paper);
  border-top: 1px solid var(--rule);
  box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.06);
  z-index: 20;
}

.birth-dock .cta {
  margin-top: 0;
}

.birth-dock .ghost {
  width: 100%;
  margin-top: 0;
  padding: 12px 14px;
  white-space: normal;
  line-height: 1.35;
}

.birth-dock #resumeBtn {
  margin-bottom: 8px;
}

.birth-dock #rebirthAsk .lbl {
  margin: 0 0 8px;
}

.birth-dock #rebirthAsk .ghost {
  margin-top: 8px;
}

.birth-dock .note {
  margin: 6px 0 0;
  font-size: 12px;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* 针对 A15 优化：出生的世界 4 按钮自适应布局 */
#worlds {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

#worlds button[data-world="any"] {
  grid-column: 1 / -1;
}

/* ==========================================================================
   出生登记与抽签屏幕 (Roll Screen)
   针对需求池 A16, A17 优化：居中与比例协调
   ========================================================================== */
#roll {
  display: none;
  flex-direction: column;
  justify-content: flex-start;
  min-height: 0;
  padding: 0;
}

#roll.on {
  display: flex;
  overflow: hidden;
}

.roll-head {
  flex: none;
  padding: 18px 16px 4px;
  text-align: center;
}

.roll-body {
  flex: 1;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 8px 16px 12px;
  scrollbar-width: none;
}

.roll-banner {
  font-family: var(--f-mono);
  font-size: 12px;
  letter-spacing: 0.08em;
  color: var(--stamp);
  text-transform: uppercase;
  margin-bottom: 6px;
}

.rollname {
  font-family: var(--f-display);
  font-size: 40px;
  font-weight: 700;
  line-height: 1.1;
  min-height: 48px;
  margin: 6px 0 16px;
  color: var(--accent);
  transition: opacity 0.1s ease;
}

.roll-dots {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin-top: 8px;
}

.roll-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--stamp);
  opacity: 0.35;
  animation: rollDot 1s infinite alternate;
}

.roll-dots span:nth-child(2) { animation-delay: 0.2s; }
.roll-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes rollDot {
  from { opacity: 0.25; transform: scale(0.8); }
  to { opacity: 1; transform: scale(1.2); }
}

/* 正式出生公证书 (Certificate of Birth with Guilloche) */
.cert {
  width: 100%;
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
  margin-bottom: 14px;
}

/* 证书印章与头部 */
.cert-title-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  border-bottom: 1px solid var(--rule);
  padding-bottom: 10px;
  margin-bottom: 12px;
}

.cert-name-box h1 {
  margin: 2px 0 0;
  font-size: 30px;
  line-height: 1.1;
}

.cert-seal {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 3px;
}

.seal-badge {
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 2px 7px;
  border-radius: 3px;
  border: 1px solid var(--accent);
}

.seal-num {
  font-family: var(--f-mono);
  font-size: 10.5px;
  color: var(--ink3);
}

/* 结构化公证书表格网格 (V1, V2 规范) */
.cert-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 12px;
  background: rgba(0, 0, 0, 0.02);
  border: 1px solid var(--rule2);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin-bottom: 12px;
}

.cg-cell {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.cg-cell.full {
  grid-column: 1 / -1;
  border-top: 1px dashed var(--rule2);
  padding-top: 6px;
  margin-top: 2px;
}

.cg-cell small {
  font-size: 11px;
  color: var(--ink3);
  letter-spacing: 0.02em;
}

.cg-cell b {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.35;
  white-space: normal;
  overflow-wrap: anywhere;
}

.cg-cell.full b {
  white-space: normal;
}

/* 防伪底纹图层 */
.cert-guilloche {
  position: absolute;
  inset: 0;
  color: var(--stamp);
  opacity: 0.11;
  pointer-events: none;
  z-index: 1;
}

/* 证书眉首印色条 */
.cert-band {
  background: var(--accent);
  color: var(--accent-ink);
  padding: 10px 16px;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  position: relative;
  z-index: 2;
}

.cert-band b {
  font-family: var(--f-display);
  font-size: 15.5px;
  font-weight: 600;
  letter-spacing: 0.05em;
}

.cert-band span {
  font-family: var(--f-mono);
  font-size: 11px;
  opacity: 0.85;
}

/* 证书内容体 */
.cert-body {
  padding: 16px 18px 18px;
  position: relative;
  z-index: 2;
}

.cert-body h1, .cert-body h2 {
  font-family: var(--f-display);
  font-size: 28px;
  font-weight: 700;
  margin: 2px 0 8px;
  color: var(--ink);
}

.cert-body .story {
  font-size: 14px;
  line-height: 1.6;
  color: var(--ink2);
  margin: 0 0 10px;
  white-space: pre-line;
}

.end-kin,
.end-hobby {
  white-space: normal;
  overflow-wrap: anywhere;
}

.bazi-fold {
  margin: 0;
  font-size: 13px;
  color: var(--ink2);
}

.bazi-fold summary {
  cursor: pointer;
  color: var(--ink);
  font-weight: 600;
}

.bazi-fold p {
  margin: 6px 0 0;
  line-height: 1.55;
}

.cert-meta {
  font-size: 12.5px;
  color: var(--ink3);
  border-top: 1px dashed var(--rule);
  padding-top: 10px;
}

/* ==========================================================================
   一生演进屏幕 (Lifeview Screen)
   ========================================================================== */
#lifeview.on {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
  padding: 0;
  position: relative;
  isolation: isolate;
}

.life-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 0 12px 16px;
  -webkit-overflow-scrolling: touch;
  scroll-padding-top: 72px;
  scroll-padding-bottom: 16px;
}

#lifeview .top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 4px;
  position: sticky;
  top: 0;
  background: var(--paper);
  padding: 6px 8px;
  margin: 0 -12px 10px;
  border-bottom: 1px solid var(--rule);
  z-index: 30;
  flex-wrap: nowrap;
}

.top-meta {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
  flex: 1 1 auto;
}

.age {
  font-family: var(--f-display);
  font-size: 20px;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
  flex-shrink: 0;
  display: inline-flex;
  align-items: baseline;
}

.age small {
  font-size: 11px;
  font-weight: 400;
  margin-left: 2px;
  color: var(--ink2);
}

.age-detail {
  display: flex;
  flex-direction: column;
  min-width: 7.4em;
  flex: 1 1 7.4em;
  gap: 2px;
  font-size: 11px;
}

.age-year {
  font-size: 1em;
  color: var(--ink);
  line-height: 1.25;
  white-space: normal;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
}

/* 年内进度平滑条 (Year Progression Bar) */
.yr-bar {
  width: 100%;
  max-width: 76px;
  height: 3px;
  background: var(--rule2);
  border-radius: 1.5px;
  overflow: hidden;
}

.yr-bar i {
  display: block;
  height: 100%;
  background: var(--accent);
  border-radius: 1.5px;
  transition: width 0.15s ease;
}

/* 顶栏控制按钮组 (Toolbar Controls) */
.top-ctrls {
  display: flex;
  align-items: center;
  gap: 3px;
  flex-shrink: 0;
  flex-wrap: nowrap;
  white-space: nowrap;
}

.top-btn {
  height: 30px;
  padding: 0 5px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 500;
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: var(--radius-sm);
  color: var(--ink);
  white-space: nowrap;
  flex-shrink: 0;
  cursor: pointer;
  transition: all 0.15s ease;
}

.top-btn:hover {
  border-color: var(--ink3);
  background: var(--paper);
}

.top-btn.icon-btn {
  width: 30px;
  padding: 0;
  font-size: 13px;
}

#year.top-btn {
  padding: 0 5px;
  font-size: 12px;
}

/* 倍速组合分段按钮 */
.speed-group {
  display: inline-flex;
  align-items: center;
  height: 30px;
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: var(--radius-sm);
  overflow: hidden;
  flex-shrink: 0;
  margin: 0;
  padding: 0;
}

.speed-group button {
  height: 100%;
  border: 0;
  border-radius: 0;
  background: transparent;
  padding: 0 5px;
  font-size: 11px;
  font-weight: 500;
  color: var(--ink2);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  flex-shrink: 0;
  cursor: pointer;
  transition: all 0.15s ease;
}

.speed-group button + button {
  border-left: 1px solid var(--rule);
}

.speed-group button.on {
  background: var(--ink);
  color: var(--paper);
  font-weight: 700;
}

/* 顶栏「更多 ⋯」菜单与下拉 */
.more-wrap {
  position: relative;
  flex-shrink: 0;
}

.morebtn {
  font-size: 15px;
  line-height: 1;
}

.more-menu {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 6px;
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 140px;
  max-height: 320px;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  z-index: 40;
}

.more-menu > * {
  flex-shrink: 0;
}

.more-menu[hidden] {
  display: none !important;
}

.more-menu button {
  text-align: left;
  padding: 7px 10px;
  font-size: 13px;
  color: var(--ink);
  border-radius: var(--radius-sm);
  background: none;
  border: none;
}

.more-menu button:hover {
  background: var(--paper);
  color: var(--accent);
}

.more-menu button.on {
  color: var(--accent);
  font-weight: 600;
}

.more-menu p.note {
  margin: 4px 6px 2px;
  font-size: 11.5px;
  color: var(--stamp);
}

/* 像素插画舞台 */
.stage {
  position: relative;
  height: 84px;
  margin: 0 0 10px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: #17242B;
  box-shadow: var(--shadow-sm);
}

.stage canvas {
  width: 100%;
  height: 84px;
  display: block;
  image-rendering: pixelated;
}

.stage span {
  position: absolute;
  left: 8px;
  bottom: 6px;
  color: #F7FAF8;
  font-size: 11.5px;
  text-shadow: 0 1px 2px #000;
  background: rgba(0, 0, 0, 0.55);
  padding: 2px 6px;
  border-radius: 3px;
}

.house-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin: -2px 0 10px;
}

.house-row > button {
  border: 1px solid var(--stamp);
  background: var(--card);
  color: var(--stamp);
  border-radius: 999px;
  padding: 4px 12px;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

#houseChoices {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

/* 四维状态条与动态浮标 (对齐 1in8b 标准网格) */
.stats {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin: 10px 0 14px;
  padding: 12px 14px;
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
}

.stat-row {
  display: grid;
  grid-template-columns: 4.4em minmax(0, 1fr) 3.2em;
  gap: 10px;
  align-items: center;
  font-size: 13px;
  line-height: 1.2;
}

.stat-row .lbl {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--ink);
  white-space: nowrap;
  letter-spacing: 0.02em;
}

.stat-row .bar {
  height: 8px;
  background: var(--rule2);
  border-radius: 4px;
  overflow: hidden;
  position: relative;
}

.stat-row .bar i {
  display: block;
  height: 100%;
  background: var(--stamp);
  border-radius: 4px;
  transition: width 0.35s ease;
}

.stat-row .v {
  text-align: right;
  font-family: var(--f-mono);
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
  color: var(--ink2);
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 2px;
}

.stat-row .delta {
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
}

.stat-row .delta.up {
  color: var(--good);
}

.stat-row .delta.down {
  color: var(--bad);
}

.stats .note {
  margin: 6px 0 0;
  padding-top: 8px;
  border-top: 1px dashed var(--rule);
  font-size: 12px;
  color: var(--ink3);
  line-height: 1.5;
}

/* 财务与资产看板 (对齐需求池 J11, J12, V12) */
.fin-bar {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  background: var(--card2);
  border: 1px solid var(--rule);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  margin: 0 0 10px;
  box-shadow: var(--shadow-sm);
}

.fin-bar:has(.fin-debt:not([hidden])) {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.fin-item {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.fin-item small {
  font-size: 11px;
  color: var(--ink3);
  white-space: nowrap;
}

.fin-item b {
  font-family: var(--f-mono);
  font-size: 13px;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.fin-debt b {
  color: var(--bad);
}

/* 家庭与人际卡片 (Family Details Card - L3, J23) */
.fam-card {
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: var(--radius-sm);
  margin: 0 0 10px;
  overflow: hidden;
}

.fam-summary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  cursor: pointer;
  font-size: 12.5px;
  color: var(--ink2);
  user-select: none;
  list-style: none;
}

.fam-summary::-webkit-details-marker {
  display: none;
}

.fam-lead {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-right: 8px;
  color: var(--ink);
}

.fam-more-hint {
  font-size: 11px;
  color: var(--stamp);
  flex-shrink: 0;
}

.fam-grid {
  border-top: 1px dashed var(--rule2);
  padding: 8px 12px;
  display: grid;
  gap: 6px;
  background: var(--paper);
  font-size: 12px;
}

.fam-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.fam-row .fam-role {
  font-weight: 600;
  color: var(--ink);
  flex-shrink: 0;
}

.fam-row {
  align-items: flex-start;
}

.fam-row .fam-detail {
  color: var(--ink2);
  text-align: right;
  white-space: normal;
  line-height: 1.4;
}

#famCard {
  scroll-margin-top: 76px;
}

/* 一生页家人分条。选择器停在这一屏，不碰到积蓄、商店和别的页。 */
#lifeview .fam-lead {
  white-space: normal;
  overflow: visible;
  text-overflow: unset;
  overflow-wrap: anywhere;
}

#lifeview .fam-summary {
  align-items: flex-start;
  gap: 8px;
}

#lifeview .fam-grid {
  display: block;
  min-width: 0;
}

#lifeview .fam-sec-title,
#lifeview .hob-title {
  margin: 10px 0 2px;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.4;
  color: var(--ink);
}

#lifeview .fam-person,
#lifeview .hob-item {
  display: grid;
  grid-template-columns: 5.5em minmax(0, 1fr);
  column-gap: 8px;
  row-gap: 2px;
  min-width: 0;
  padding: 8px 0 4px;
  border-top: 1px dashed var(--rule2);
}

#lifeview .fam-field {
  display: contents;
}

#lifeview .fam-k {
  color: var(--ink3);
  font-size: 12px;
  line-height: 1.45;
}

#lifeview .fam-v {
  min-width: 0;
  color: var(--ink);
  font-size: 14px;
  line-height: 1.45;
  overflow-wrap: anywhere;
  word-break: break-word;
}

#lifeview .fam-empty,
#lifeview .hob-empty {
  margin: 4px 0 8px;
  color: var(--ink2);
  font-size: 13px;
  line-height: 1.45;
}

#lifeview .hob-block {
  margin: 0 0 10px;
  padding: 2px 12px 8px;
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: var(--radius-sm);
  min-width: 0;
  max-width: 100%;
}

/* 一生底栏：钱、四态、花钱。贴在滚动区下面，不跟着正文走。 */
.life-dock {
  flex: none;
  background: var(--paper);
  border-top: 1px solid var(--rule);
  padding: 6px 10px calc(8px + env(safe-area-inset-bottom, 0px));
  z-index: 28;
  box-shadow: 0 -8px 18px -14px var(--ink2);
}

.life-dock .fin-bar,
.life-dock .fin-bar:has(.fin-debt:not([hidden])) {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px 10px;
  margin: 0 0 6px;
  padding: 0;
  background: transparent;
  border: 0;
  box-shadow: none;
}

.life-dock .fin-item small {
  font-size: 10px;
}

.life-dock .fin-item b {
  font-size: 12px;
}

.life-dock .stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
  margin: 0;
  padding: 0;
  background: transparent;
  border: 0;
  box-shadow: none;
}

.life-dock .stat-row {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 2px;
  min-width: 0;
}

.life-dock .stat-row .lbl {
  font-size: 11px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.life-dock .stat-row .v {
  justify-content: flex-start;
  font-size: 11px;
}

.life-dock .stats .note {
  grid-column: 1 / -1;
  margin: 2px 0 0;
  padding: 0;
  border: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.life-dock .action-bar {
  margin: 6px 0 0;
}

.life-dock .action-btn {
  min-height: 40px;
  padding: 8px 10px;
}

.fam {
  margin: 0 0 8px;
  color: var(--ink2);
  font-size: 12.5px;
  line-height: 1.5;
}

.hob { margin: -4px 0 8px; color: var(--stamp); font-size: 13px; }

/* 动作操作栏与按钮 */
.action-bar {
  display: flex;
  gap: 8px;
  margin: 6px 0 10px;
}

.action-btn {
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 14px;
  background: var(--card);
  border: 1px solid var(--stamp);
  color: var(--stamp);
  font-size: 13px;
  font-weight: 600;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s ease;
}

.action-btn:hover {
  background: var(--stamp-soft);
}

/* 人生纪录流 (Feed) */
.feed {
  list-style: none;
  margin: 0 0 16px;
  padding: 0;
}

.feed li {
  border-top: 1px solid var(--rule);
  padding: 9px 0;
  font-size: 14px;
  line-height: 1.55;
}

.feed .k {
  font-size: 11.5px;
  font-family: var(--f-mono);
  color: var(--accent);
  font-weight: 600;
  margin-bottom: 2px;
}

/* ==========================================================================
   抉择模态/抽屉 (对齐 需求池 D1-D9)
   ========================================================================== */
.sheet {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  min-height: 0;
  max-height: calc(100% - 12px - env(safe-area-inset-top, 0px));
  overflow: hidden;
  background: var(--card);
  border: 1px solid var(--rule);
  border-bottom: 0;
  border-radius: var(--radius-md) var(--radius-md) 0 0;
  padding: 0;
  margin: 0;
  box-shadow: 0 -8px 28px -6px rgba(0, 0, 0, 0.22);
  z-index: 41;
  animation: slideUp 0.25s var(--ease);
}

.life-sheet-backdrop {
  display: none;
  position: absolute;
  inset: 0;
  z-index: 40;
  background: rgba(13, 19, 22, 0.52);
  touch-action: none;
}

#lifeview:has(> .sheet:not([hidden])) > .life-sheet-backdrop {
  display: block;
}

#lifeview:has(> .sheet:not([hidden])) > .life-scroll {
  overflow-y: hidden;
}

#lifeview:has(> .sheet:not([hidden])) > :is(.life-scroll, .life-dock, .decpeek) {
  pointer-events: none;
}

#lifeview:has(> #shopSheet:not([hidden])) > .life-sheet-backdrop {
  z-index: 42;
}

#lifeview:has(> #musicSheet:not([hidden]), > #feedbackSheet:not([hidden])) > .life-sheet-backdrop {
  z-index: 44;
}

.sheet > :is(.sheet-bd, .shop-body) {
  flex: 0 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 12px 18px calc(18px + env(safe-area-inset-bottom, 0px));
}

#musicSheet,
#feedbackSheet {
  z-index: 45;
}

#shopSheet {
  top: 0;
  max-height: 100%;
  height: 100%;
  z-index: 43;
  background: var(--paper);
  border: 0;
  border-radius: 0;
  box-shadow: 0 -12px 36px rgba(0, 0, 0, 0.28);
}

#shopSheet > .sheet-hd {
  padding-top: calc(12px + env(safe-area-inset-top, 0px));
}

#shopSheet > .shop-body {
  flex: 1 1 auto;
}

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

.sheet-hd {
  display: flex;
  flex: none;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border-bottom: 1px solid var(--rule2);
  margin: 0;
}

.sheet-hd .sheet-min {
  flex: none;
  min-height: 44px;
  margin-left: auto;
}

#sheet .sheet-age {
  flex: 1;
  min-width: 0;
}

.sheet-badge {
  font-family: var(--f-mono);
  font-size: 11px;
  color: var(--accent);
  font-weight: 600;
  background: var(--accent-soft);
  padding: 2px 6px;
  border-radius: 3px;
  letter-spacing: 0.04em;
}

.sheet-age {
  font-family: var(--f-mono);
  font-size: 12px;
  color: var(--ink2);
}

.sheet-min {
  font-size: 12px;
  color: var(--ink2);
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  background: var(--paper);
  border: 1px solid var(--rule);
}

.sheet-min:hover {
  border-color: var(--ink3);
}

.sheet h2 {
  font-family: var(--f-display);
  font-size: 21px;
  margin: 6px 0 6px;
  line-height: 1.25;
}

.sheet-body {
  margin: 0 0 10px;
  font-size: 14.5px;
  color: var(--ink2);
  line-height: 1.55;
}

#sheetInput {
  width: 100%;
  min-height: 72px;
  margin: 8px 0 4px;
  box-sizing: border-box;
}

.fact {
  font-size: 12.5px;
  color: var(--stamp);
  background: var(--stamp-soft);
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  margin: 8px 0 12px;
  line-height: 1.5;
}

.fact[hidden] {
  display: none;
}

.fact .fact-k {
  display: block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  margin-bottom: 2px;
}

.fact .fact-src {
  display: block;
  margin-top: 4px;
  color: var(--ink2);
  font-size: 12px;
}

.log-fact {
  margin-top: 4px;
  color: var(--stamp);
  font-size: 12.5px;
  line-height: 1.45;
}

.log-fact span {
  font-weight: 700;
  margin-right: 4px;
}

.cert-src {
  margin: 0 0 8px;
  font-size: 12px;
  color: var(--ink3);
  line-height: 1.45;
}

.st-table {
  margin: 10px 0 16px;
}

.st-row {
  display: grid;
  grid-template-columns: 4.5em minmax(0, 1fr) minmax(0, 1fr);
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid var(--rule2);
  font-size: 14px;
}

.st-head {
  color: var(--ink3);
  font-size: 12px;
}

/* 各国资料：四列，表身自滚，回到开场与各省资料同宽 */
#worldstatsview .st-table {
  max-height: min(62vh, 560px);
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}

#worldstatsview .st-row {
  grid-template-columns: minmax(4.6em, 1.15fr) minmax(0, 1.35fr) minmax(0, 1.35fr) minmax(4.8em, 1fr);
  align-items: start;
  column-gap: 6px;
}

#worldstatsview .st-row > span {
  min-width: 0;
}

#worldstatsview .ws-num {
  overflow-wrap: anywhere;
}

#worldstatsview .st-head {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--paper);
}

#worldstatsview .ws-year {
  display: block;
  margin-top: 2px;
  color: var(--ink3);
  font-size: 11px;
  line-height: 1.35;
  font-weight: 400;
}

#worldstatsview .ws-note {
  margin: -4px 0 8px;
  color: var(--ink3);
  font-size: 12px;
  line-height: 1.45;
}

#worldstatsview .st-row .stats-src-link {
  display: inline-block;
  margin-top: 2px;
  font-size: 11px;
  color: var(--stamp);
}

#worldStatsSource {
  overflow-wrap: anywhere;
  word-break: break-word;
}

#worldStatsSource .stats-src-link {
  display: inline;
  overflow-wrap: anywhere;
  word-break: break-all;
}

/* 编号选项列表 (Choices 1-4) */
.sheet-choices button {
  display: flex;
  align-items: baseline;
  gap: 10px;
  width: 100%;
  text-align: left;
  margin-top: 8px;
  padding: 11px 14px;
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: var(--radius-sm);
  font-size: 14px;
  transition: all 0.12s;
}

.sheet-choices button .k {
  font-family: var(--f-mono);
  font-weight: 700;
  color: var(--accent);
  font-size: 13.5px;
  width: 12px;
  flex: none;
}

.sheet-choices button b {
  flex: 1;
  font-weight: 600;
  color: var(--ink);
  font-size: 14.5px;
}

.sheet-choices button small {
  display: block;
  color: var(--ink3);
  font-size: 12px;
  margin-top: 2px;
}

.sheet-choices button:hover {
  border-color: var(--accent);
  background: var(--card2);
}

.sheet-auto {
  display: block;
  width: 100%;
  text-align: center;
  margin-top: 14px;
  font-size: 12.5px;
  color: var(--ink3);
  padding: 6px;
  background: none;
  border: none;
  cursor: pointer;
  text-decoration: underline;
}

.sheet-auto.on {
  color: var(--accent);
  font-weight: 600;
  text-decoration: none;
}

/* 等待中的抉择浮条 (Minimized Decision Peek Bar) */
.decpeek {
  position: relative;
  flex: none;
  z-index: 29;
  background: var(--card);
  border: 1px solid var(--accent);
  border-radius: 0;
  padding: 10px 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  box-shadow: var(--shadow);
  margin: 0;
  animation: slideUp 0.2s ease;
}

.dp-text {
  flex: 1;
  min-width: 0;
  overflow-wrap: anywhere;
}

#decReopen {
  flex: none;
  width: auto;
  min-height: 44px;
  margin: 0;
}

.dp-text b {
  display: block;
  font-size: 13.5px;
  color: var(--ink);
}

.dp-text small {
  font-size: 12px;
  color: var(--accent);
}

/* ==========================================================================
   花钱·投资抽屉 (对齐 需求池 B1-B9)
   ========================================================================== */
.shop-sheet {
  overflow: hidden;
}

.shop-wallet {
  font-family: var(--f-display);
  font-size: 24px;
  font-weight: 700;
  color: var(--stamp);
  margin: 6px 0 8px;
}

.shop-notice {
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--ink2);
  margin-bottom: 12px;
}

.shop-list {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
}

.shop-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--rule);
  border-radius: var(--radius-sm);
  background: var(--paper);
  color: inherit;
  font: inherit;
  font-size: 13.5px;
  text-align: left;
  cursor: pointer;
}

.shop-item.disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.shop-item-info b {
  display: block;
  font-size: 14px;
  color: var(--ink);
}

.shop-item-info small {
  display: block;
  font-size: 12px;
  color: var(--ink3);
  margin-top: 2px;
}

.shop-item-cost {
  font-family: var(--f-mono);
  font-weight: 600;
  color: var(--accent);
  font-size: 13px;
  white-space: nowrap;
}

.shop-card {
  padding: 10px 12px;
  border: 1px solid var(--rule);
  border-radius: var(--radius-sm);
  background: var(--paper);
}

.shop-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }

.chip {
  border: 1px solid var(--rule);
  background: var(--card);
  color: var(--ink);
  border-radius: 999px;
  padding: 6px 10px;
  font: inherit;
  font-size: 12.5px;
  cursor: pointer;
}

.chip.on { background: var(--ink); color: var(--paper); }
.chip.off, .chip:disabled { opacity: 0.45; cursor: not-allowed; }

.shop-more { margin-top: 8px; }
.shop-more summary { cursor: pointer; color: var(--ink2); font-size: 13px; }

.shop-lifestyle {
  border: 1px solid var(--rule);
  border-radius: var(--radius-sm);
  background: var(--card2);
  padding: 10px 12px;
  margin-bottom: 14px;
}

.shop-lifestyle summary {
  font-weight: 600;
  font-size: 13.5px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.shop-lifestyle summary small {
  color: var(--ink3);
  font-weight: normal;
  font-size: 12px;
}

.lifestyle-box {
  margin-top: 10px;
  border-top: 1px dashed var(--rule);
  padding-top: 8px;
}

/* ==========================================================================
   结局与追思馆屏幕 (Dead / Replay / Hall Screens - Iteration 3)
   ========================================================================== */
#dead.on,
#replayview.on,
#hallview.on,
#meetview.on {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
}

.end-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.end-dock {
  flex: none;
}

#dead .cert, #replayview .cert, #meetview .cert {
  margin-top: 8px;
}

#dead .cta,
#replayview .cta, #hallview .cta, #meetview .cta,
#statsview .cta, #worldstatsview .cta, #aboutview .cta {
  display: block;
  width: 100%;
  margin-top: 10px;
}

.end-actions {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 10px;
}

.end-actions .ghost {
  display: block;
  width: 100%;
  margin-top: 0;
  padding: 8px 4px;
  font-size: 13px;
  text-align: center;
  white-space: nowrap;
}

/* 终局结构化分区卡片 */
.end-section {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px dashed var(--rule);
}

.end-section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1px;
  color: var(--kicker);
  margin-bottom: 8px;
  text-transform: uppercase;
}

/* 16种人生底色印章 (V9) */
.end-texture-card {
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  padding: 12px;
  margin-top: 6px;
  position: relative;
  overflow: hidden;
}

.texture-header {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 10px;
}

.texture-seal {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #b33939;
  color: #b33939;
  padding: 4px 10px;
  font-family: var(--font-display, serif);
  font-size: 15px;
  font-weight: 700;
  border-radius: 4px;
  letter-spacing: 2px;
  background: rgba(179, 57, 57, 0.05);
  box-shadow: inset 0 0 4px rgba(179, 57, 57, 0.15);
  transform: rotate(-1deg);
  flex-shrink: 0;
}

.texture-meta {
  flex: 1;
  min-width: 0;
}

.texture-motto {
  font-size: 13px;
  font-weight: 600;
  color: var(--fg);
  line-height: 1.45;
  margin: 0;
  white-space: normal;
  overflow-wrap: anywhere;
}

.texture-sub {
  font-size: 11px;
  color: var(--kicker);
  margin-top: 2px;
}

.texture-dimensions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed var(--border-soft);
}

.texture-dim-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
}

.dim-pole {
  width: 58px;
  font-size: 11px;
  color: var(--kicker);
  flex-shrink: 0;
}

.dim-pole.left {
  text-align: right;
}

.dim-pole.right {
  text-align: left;
}

.dim-pole.active {
  color: var(--fg);
  font-weight: 700;
}

.texture-dim-row.is-empty .dim-track {
  height: auto;
  min-height: 16px;
  background: transparent;
}

.dim-empty {
  display: block;
  text-align: center;
  font-size: 11px;
  line-height: 16px;
  color: var(--kicker);
}

.dim-track {
  flex: 1;
  height: 6px;
  background: var(--bg-hover);
  border-radius: 3px;
  position: relative;
  overflow: hidden;
}

.dim-fill {
  height: 100%;
  background: linear-gradient(90deg, #b33939 0%, var(--accent) 100%);
  border-radius: 3px;
  transition: width 0.4s ease;
}

/* 100格人生微缩图 / 10×10 热力图 (V11) */
.lifemap-box {
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  padding: 12px;
  margin-top: 6px;
}

.lifemap-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  flex-wrap: wrap;
  gap: 4px;
}

.lifemap-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--fg);
}

.lifemap-legend {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 10px;
  color: var(--kicker);
}

.lg-item {
  display: inline-flex;
  align-items: center;
  gap: 2px;
}

.lg-item i {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 2px;
}

.lg-item i.c-high, .lifemap-cell.happy-high { background: #e6a23c; color: #fff; }
.lg-item i.c-mid, .lifemap-cell.happy-mid { background: #48bb78; color: #fff; }
.lg-item i.c-low, .lifemap-cell.happy-low { background: #4299e1; color: #fff; }
.lg-item i.c-bad, .lifemap-cell.happy-bad { background: #a0aec0; color: #fff; }
.lg-item i.c-none, .lifemap-cell.happy-unlived {
  background: var(--card2);
  border: 1px dashed var(--border-soft);
  color: transparent;
}

.lifemap-cell.happy-unknown,
.mini-map-cell.happy-unknown {
  background: #d9d3c5;
  color: #5c564c;
}

.lifemap-grid {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 3px;
  margin: 6px 0;
  user-select: none;
}

.lifemap-cell {
  aspect-ratio: 1;
  border-radius: 3px;
  font-size: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: relative;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  border: 1px solid rgba(0, 0, 0, 0.04);
}

.lifemap-cell:not(.happy-unlived):hover {
  transform: scale(1.35);
  z-index: 10;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.2);
}

.lifemap-cell.selected {
  outline: 2px solid var(--fg);
  outline-offset: 1px;
  z-index: 5;
}

.cell-icon {
  font-size: 8px;
  line-height: 1;
  pointer-events: none;
}

.lifemap-tooltip {
  min-height: 32px;
  padding: 6px 10px;
  margin-top: 6px;
  background: var(--bg-hover);
  border-radius: 6px;
  font-size: 11px;
  color: var(--fg);
  line-height: 1.45;
  white-space: pre-line;
}

/* 时间账本 (G4, P3) */
.time-ledger-box {
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  padding: 12px;
  margin-top: 6px;
}

.ledger-bar-stacked {
  display: flex;
  height: 10px;
  border-radius: 5px;
  overflow: hidden;
  margin-bottom: 10px;
  background: var(--bg-hover);
}

.ledger-seg {
  height: 100%;
  transition: width 0.3s ease;
}

.ledger-seg.seg-work { background: #4299e1; }
.ledger-seg.seg-family { background: #ed64a6; }
.ledger-seg.seg-study { background: #ecc94b; }
.ledger-seg.seg-rest { background: #48bb78; }

.ledger-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.ledger-cell {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 8px;
  background: var(--bg-hover);
  border-radius: 6px;
  font-size: 11px;
}

.ledger-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  margin-right: 4px;
}

.ledger-dot.dot-work { background: #4299e1; }
.ledger-dot.dot-family { background: #ed64a6; }
.ledger-dot.dot-study { background: #ecc94b; }
.ledger-dot.dot-rest { background: #48bb78; }

.ledger-val {
  font-weight: 700;
  color: var(--fg);
}

/* 同代生存与死因对照 (P3, G4) */
.cohort-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 6px;
}

.cohort-card {
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: 6px;
  padding: 8px;
  text-align: center;
}

.cohort-val {
  font-size: 14px;
  font-weight: 800;
  color: var(--accent);
  line-height: 1.2;
}

.cohort-lbl {
  font-size: 10px;
  color: var(--kicker);
  margin-top: 2px;
}

/* 生平回响筛选 Tabs */
.replay-filter-tabs {
  display: flex;
  gap: 6px;
  margin: 10px 0;
  overflow-x: auto;
  scrollbar-width: none;
}

.replay-filter-tabs::-webkit-scrollbar {
  display: none !important;
}

.rf-tab {
  flex: 1;
  padding: 5px 8px;
  font-size: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: 6px;
  color: var(--kicker);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s ease;
}

.rf-tab.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  font-weight: 600;
}

/* 追思馆卡片列表 (P4) */
.hall-header-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.hall-count {
  font-size: 11px;
  color: var(--kicker);
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  padding: 2px 8px;
  border-radius: 10px;
}

.hall-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 12px;
}

.hall-card {
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: 10px;
  padding: 14px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
  position: relative;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.hall-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.hall-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.hall-card-title {
  display: flex;
  align-items: baseline;
  gap: 6px;
  flex-wrap: wrap;
}

.hall-card-name {
  font-size: 16px;
  font-weight: 800;
  color: var(--fg);
}

.hall-card-years {
  font-size: 11px;
  color: var(--kicker);
}

.hall-card-badge {
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--bg-hover);
  color: var(--kicker);
}

.hall-card-seal {
  display: inline-block;
  border: 1px solid #b33939;
  color: #b33939;
  padding: 2px 6px;
  font-size: 11px;
  font-weight: 700;
  border-radius: 4px;
  letter-spacing: 1px;
  background: rgba(179, 57, 57, 0.04);
  margin-bottom: 4px;
}

.hall-card-motto {
  display: block;
  margin: 0 0 8px;
  font-size: 13px;
  line-height: 1.45;
  color: var(--ink2);
  white-space: normal;
  overflow-wrap: anywhere;
}

.hall-card-meta {
  font-size: 12px;
  color: var(--fg);
  line-height: 1.5;
  margin-bottom: 8px;
}

.hall-card-mini-map {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 2px;
  margin: 8px 0;
}

.mini-map-cell {
  aspect-ratio: 1;
  border-radius: 1px;
}

.mini-map-cell.happy-high { background: #e6a23c; }
.mini-map-cell.happy-mid { background: #48bb78; }
.mini-map-cell.happy-low { background: #4299e1; }
.mini-map-cell.happy-bad { background: #a0aec0; }
.mini-map-cell.happy-unlived { background: transparent; border: 1px dashed var(--border-soft); }
.mini-map-cell.happy-unknown { background: #d9d3c5; }

.hall-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px dashed var(--border-soft);
  gap: 8px;
}

.hall-card-ledger-brief {
  font-size: 11px;
  color: var(--kicker);
}

.hall-card-actions {
  display: flex;
  gap: 6px;
}

.hall-card-actions button {
  padding: 4px 8px;
  font-size: 11px;
}

.hall-empty {
  text-align: center;
  padding: 30px 16px;
  color: var(--kicker);
  font-size: 13px;
  background: var(--bg-card);
  border: 1px dashed var(--border-soft);
  border-radius: 10px;
}

/* 各省资料出处：390 宽也要整条 URL 可点可看 */
#statsSource {
  overflow-wrap: anywhere;
  word-break: break-word;
}
#statsSource .stats-src-link {
  display: inline;
  overflow-wrap: anywhere;
  word-break: break-all;
}
