@import url('https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;600;700;900&family=Noto+Serif+TC:wght@400;600;700;900&display=swap');

:root {
  --night-desk: #0d0a07;
  --xuan-paper: #f3ece0;
  --xuan-card: #ebe1cf;
  --ink-black: #1c1916;
  --ink-mid: #4a4238;
  --ink-faint: #8a7f71;
  --vermilion: #a8261a;
  --lore-teal: #2f5953;
  --gold-accent: #b8841f;

  --c-de: #b32417;
  --c-cai: #a67311;
  --c-gong: #1f4c73;
  --c-liang: #2b6144;
  --c-rou: #754d43;
  --c-zang: #1f211e;
}

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

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  background-color: var(--night-desk);
  font-family: 'Noto Serif SC', 'Noto Serif TC', 'Songti SC', 'SimSun', serif;
  color: var(--ink-black);
  overflow: hidden;
  display: flex;
  justify-content: center;
  align-items: center;
}

#stage-paper {
  position: relative;
  width: 100vw;
  height: 100dvh;
  max-width: 460px;
  background-color: var(--xuan-paper);
  background-image:
    radial-gradient(circle at 5% 3%, rgba(255, 186, 85, 0.34) 0%, rgba(255, 155, 55, 0.1) 36%, transparent 68%),
    radial-gradient(ellipse at center, transparent 64%, rgba(55, 40, 22, 0.24) 100%),
    radial-gradient(rgba(120, 95, 60, 0.04) 1px, transparent 0);
  background-size: 100% 100%, 100% 100%, 22px 22px;
  box-shadow: 0 0 72px rgba(0, 0, 0, 0.96);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

#stage-paper.rulebook-is-open #sgm-left-dock {
  display: none !important;
  pointer-events: none !important;
}

#stage-paper.endgame-is-open #minimal-header,
#stage-paper.endgame-is-open #jingbao-ticker,
#stage-paper.endgame-is-open #narrative-stream,
#stage-paper.endgame-is-open #bowl-corner {
  visibility: hidden !important;
  pointer-events: none !important;
}

#candle-ambient {
  position: absolute;
  top: -45px;
  left: -45px;
  width: 230px;
  height: 230px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 175, 60, 0.26) 0%, rgba(255, 135, 35, 0.06) 55%, transparent 75%);
  pointer-events: none;
  z-index: 5;
  animation: candleBreathe 4.2s ease-in-out infinite alternate;
}

@keyframes candleBreathe {
  0%   { transform: scale(0.95); opacity: 0.78; }
  50%  { transform: scale(1.06) translate(3px, 2px); opacity: 1; }
  100% { transform: scale(0.98) translate(-2px, 1px); opacity: 0.85; }
}

/* ==========================================================================
 * 1121-7 原版顶部两行极简状态栏
 * ========================================================================== */
#minimal-header {
  position: relative;
  z-index: 30;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  padding: 11px 14px 8px 15px;
  gap: 6px;
  border-bottom: 1px solid rgba(130, 108, 80, 0.2);
  background: linear-gradient(180deg, rgba(243, 236, 224, 0.99) 0%, rgba(243, 236, 224, 0.95) 86%, rgba(243, 236, 224, 0.78) 100%);
}

.header-row-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.header-identity {
  flex: 1;
  min-width: 0;
}

.header-identity-main {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 5px;
  font-size: 0.9rem;
  line-height: 1.32;
}

.player-name-seal {
  font-weight: 900;
  color: var(--ink-black);
  position: relative;
  padding-left: 8px;
}
.player-name-seal::before {
  content: '';
  position: absolute;
  left: 0;
  top: 2px;
  bottom: 2px;
  width: 3px;
  background-color: var(--vermilion);
  border-radius: 1px;
}

.status-divider {
  color: rgba(140, 120, 95, 0.45);
}

.status-post {
  font-weight: 700;
  color: var(--ink-mid);
}
.status-post.clickable-post {
  cursor: pointer;
  border-bottom: 1px dotted rgba(168, 38, 26, 0.42);
  transition: color 0.15s ease;
}
.status-post.clickable-post:hover {
  color: var(--vermilion);
}

.plain-role-sub {
  display: none;
  margin-top: 2px;
  padding-left: 8px;
  font-size: 0.72rem;
  color: var(--ink-faint);
  letter-spacing: 0.03em;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-seals {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.tiny-seal {
  padding: 3px 6px;
  border: 1px solid rgba(168, 38, 26, 0.55);
  color: var(--vermilion);
  font-family: inherit;
  font-size: 0.7rem;
  font-weight: 700;
  border-radius: 2px;
  cursor: pointer;
  background: rgba(168, 38, 26, 0.04);
  transition: all 0.15s ease;
  white-space: nowrap;
  line-height: 1.3;
}
.tiny-seal:active {
  background: var(--vermilion);
  color: #fff;
}
.tiny-seal.off {
  border-color: rgba(120, 110, 95, 0.45);
  color: var(--ink-faint);
  background: transparent;
}

#btn-rulebook {
  padding: 4px 9px;
  background: linear-gradient(180deg, #bc2c1e 0%, #961d12 100%);
  color: #fdf7ec;
  border: 1.4px solid #6e130b;
  border-radius: 3px;
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.06em;
  box-shadow:
    inset 0 0 0 1px rgba(248, 214, 136, 0.52),
    0 2px 7px rgba(140, 24, 14, 0.32);
}

.header-row-sub {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 4px 10px;
  padding-top: 5px;
  border-top: 1px dashed rgba(135, 112, 82, 0.25);
  font-size: 0.74rem;
  color: var(--ink-mid);
  line-height: 1.4;
}

.sub-zone-finance,
.sub-zone-status {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
}
.sub-zone-finance strong,
.sub-zone-status strong {
  color: var(--ink-black);
  font-weight: 900;
}
.sub-dot, .sub-pipe {
  color: rgba(138, 127, 113, 0.55);
  margin: 0 1px;
}

.debt-alert-seal {
  display: none;
  align-items: center;
  padding: 0 5px;
  background: #7c1c14;
  color: #fbf4e6;
  border: 1px solid #56110b;
  border-radius: 2px;
  font-size: 0.7rem;
  font-weight: 900;
  letter-spacing: 0.04em;
  line-height: 1.45;
  box-shadow: 0 1px 3px rgba(124, 28, 20, 0.28);
}
.debt-alert-seal strong {
  color: #ffe8a3 !important;
  margin: 0 2px;
}

.subpost-val {
  color: var(--ink-faint);
  font-weight: 700;
}
.subpost-val.active {
  color: var(--vermilion);
  background: rgba(168, 38, 26, 0.08);
  padding: 0 5px;
  border-radius: 2px;
  border: 1px solid rgba(168, 38, 26, 0.28);
}

/* ==========================================================================
 * 顶部浮动「京报耳闻」邸报条 (#jingbao-ticker)
 * ========================================================================== */
#jingbao-ticker {
  position: absolute;
  left: 12px;
  right: 12px;
  top: 74px;
  z-index: 65;
  background: rgba(248, 242, 231, 0.97);
  border: 1px solid rgba(135, 110, 75, 0.42);
  border-left: 3px solid var(--lore-teal);
  border-radius: 3px;
  box-shadow: 0 5px 18px rgba(24, 15, 6, 0.22);
  opacity: 0;
  transform: translateY(-8px);
  pointer-events: none;
  transition: opacity 0.24s ease, transform 0.24s ease;
}
#jingbao-ticker.visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}
.jingbao-bar-row {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 6px 9px;
  cursor: pointer;
}
.jingbao-seal {
  flex-shrink: 0;
  font-size: 0.68rem;
  font-weight: 900;
  color: #f8f3ea;
  background: var(--lore-teal);
  padding: 1px 5px;
  border-radius: 2px;
  letter-spacing: 0.05em;
}
.jingbao-msg {
  flex: 1;
  min-width: 0;
  font-size: 0.77rem;
  line-height: 1.44;
  color: var(--ink-black);
}
.jingbao-close {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95rem;
  color: var(--ink-faint);
  cursor: pointer;
}
.jingbao-close:hover { color: var(--vermilion); }

.jingbao-dossier-box {
  display: none;
  border-top: 1px dashed rgba(135, 110, 75, 0.34);
  padding: 8px 10px 9px 10px;
  background: rgba(243, 235, 221, 0.94);
  font-size: 0.76rem;
  line-height: 1.54;
}
.jingbao-dossier-box.open { display: block; }

.ticker-npc-link {
  color: var(--vermilion);
  font-weight: 900;
  border-bottom: 1px dotted rgba(168, 38, 26, 0.65);
  cursor: pointer;
}

/* ==========================================================================
 * 主编年体叙事流（完全复刻 1121-7 字体、留白、统一总结卡与常驻两行知识卡）
 * ========================================================================== */
#narrative-stream {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 8px 18px 235px 18px;
  scroll-behavior: smooth;
  position: relative;
  z-index: 15;
  cursor: pointer;
}
#narrative-stream::-webkit-scrollbar { width: 0; }

.turn-group {
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(130, 108, 80, 0.16);
}
.turn-group.slim-turn-group {
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px dashed rgba(130, 108, 80, 0.18);
}

.chronicle-row,
.slim-event-row {
  display: flex;
  align-items: baseline;
  padding: 4px 0;
}
.chronicle-row {
  opacity: 0;
  filter: blur(2px);
  transform: translateY(4px);
  transition: opacity 0.38s ease, filter 0.38s ease, transform 0.38s ease;
}
.chronicle-row.shown {
  opacity: 1;
  filter: blur(0);
  transform: translateY(0);
}

.age-col {
  width: 44px;
  flex-shrink: 0;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--ink-faint);
}

.event-col {
  flex: 1;
  min-width: 0;
  font-size: 0.94rem;
  line-height: 1.64;
  color: var(--ink-black);
  letter-spacing: 0.02em;
}

.chronicle-row.lone-die .event-col {
  color: var(--ink-faint);
  font-size: 0.87rem;
  font-style: italic;
}

.slim-event-row {
  font-size: 0.9rem;
  line-height: 1.56;
}
.slim-event-row.subtle .event-col {
  font-size: 0.8rem;
  color: #5a5045;
}

/* 六字骰标签小印 */
.die-tag {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 900;
  padding: 0 5px;
  border-radius: 2px;
  margin-right: 5px;
  color: #fff;
  vertical-align: 1px;
}
.die-tag.DE    { background-color: var(--c-de); }
.die-tag.CAI   { background-color: var(--c-cai); }
.die-tag.GONG  { background-color: var(--c-gong); }
.die-tag.LIANG { background-color: var(--c-liang); }
.die-tag.ROU   { background-color: var(--c-rou); }
.die-tag.ZANG  { background-color: var(--c-zang); }
.die-tag.LONE  {
  background-color: transparent;
  color: var(--ink-faint);
  border: 1px solid rgba(140, 130, 117, 0.45);
  font-style: normal;
}

.sign-plus  { color: var(--c-de); font-weight: 900; margin-left: 4px; font-size: 0.86rem; }
.sign-minus { color: var(--ink-mid); font-weight: 900; margin-left: 4px; font-size: 0.86rem; }

/* 银两胶囊 */
.money-pill {
  display: inline-block;
  margin-left: 4px;
  padding: 0 5px;
  border-radius: 2px;
  font-size: 0.76rem;
  font-weight: 900;
  vertical-align: 1px;
}
.money-pill.gain { background: rgba(43, 97, 68, 0.14); color: #205237; }
.money-pill.loss { background: rgba(168, 38, 26, 0.12); color: #9c1e14; }
.money-pill.debt { background: rgba(124, 28, 20, 0.14); color: #7c1c14; }

/* 1121-7 统一左红线总结卡 ＋ 内嵌镂空小标常驻两行知识卡 */
.verdict-card-wrap {
  margin: 8px 0 4px 44px;
  background: rgba(168, 38, 26, 0.065);
  border: 1px solid rgba(168, 38, 26, 0.24);
  border-left: 3px solid var(--vermilion);
  border-radius: 3px;
  overflow: hidden;
  opacity: 0;
  transform: translateY(3px);
  transition: opacity 0.38s ease, transform 0.38s ease;
}
.verdict-card-wrap.shown {
  opacity: 1;
  transform: translateY(0);
}
.verdict-card-wrap.bad {
  background: rgba(35, 35, 35, 0.06);
  border-color: rgba(45, 42, 38, 0.25);
  border-left-color: var(--c-zang);
}
.verdict-card-wrap.neutral {
  background: rgba(125, 110, 88, 0.08);
  border-color: rgba(130, 112, 86, 0.26);
  border-left-color: var(--ink-faint);
}

.summary-pill {
  padding: 7px 10px;
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  color: var(--ink-black);
  line-height: 1.54;
}
.verdict-silver-tag {
  color: #a8261a;
  font-weight: 900;
}
.verdict-silver-tag.loss {
  color: #3a352f;
}

.career-brief-card {
  padding: 6px 10px 8px 10px;
  background: rgba(248, 243, 234, 0.78);
  border-top: 1px dashed rgba(150, 120, 88, 0.3);
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.cb-line {
  display: flex;
  align-items: flex-start;
  gap: 7px;
  font-size: 0.77rem;
  line-height: 1.54;
  color: #4b433a;
}
.cb-tag {
  flex-shrink: 0;
  padding: 0 5px;
  border-radius: 2px;
  font-size: 0.69rem;
  font-weight: 800;
  line-height: 1.48;
  margin-top: 1px;
  background: rgba(255, 252, 245, 0.9);
}
.cb-tag.why {
  color: #a8261a;
  border: 1px solid rgba(168, 38, 26, 0.55);
}
.cb-tag.duty {
  color: #2f5953;
  border: 1px solid rgba(47, 89, 83, 0.55);
}
.cb-text {
  flex: 1;
  min-width: 0;
}

/* 外官潜规则精简条 */
.meta-callout-row {
  margin: 5px 0 2px 44px;
  padding: 5px 8px;
  background: rgba(168, 38, 26, 0.06);
  border-left: 2.5px solid var(--vermilion);
  border-radius: 2px;
  font-size: 0.78rem;
  line-height: 1.52;
  color: #4b4238;
}
.meta-callout-badge {
  display: inline-block;
  font-weight: 900;
  color: var(--vermilion);
  margin-right: 4px;
}

/* 1121-7 内文朱砂「你▾」自查卡与「同僚名▾」链接 */
.self-tag {
  display: inline-block;
  font-weight: 900;
  color: #a8261a;
  border-bottom: 1.3px dotted rgba(168, 38, 26, 0.72);
  padding: 0 1px;
  cursor: pointer;
  pointer-events: auto;
}
.self-tag:hover,
.self-tag.expanded {
  background: rgba(168, 38, 26, 0.1);
  border-radius: 2px;
}
.self-caret, .npc-caret {
  display: inline-block;
  font-size: 0.68em;
  margin-left: 1px;
  vertical-align: 1px;
  opacity: 0.85;
}

.npc-link {
  color: #a8261a;
  font-weight: 800;
  border-bottom: 1px dotted rgba(168, 38, 26, 0.62);
  cursor: pointer;
}
.npc-link:hover {
  background: rgba(168, 38, 26, 0.08);
  border-radius: 2px;
}

.self-dossier-card {
  margin: 6px 0 8px 44px;
  padding: 9px 11px;
  background: rgba(248, 242, 230, 0.98);
  border: 1px solid rgba(168, 38, 26, 0.42);
  border-left: 3px solid #a8261a;
  border-radius: 3px;
  font-size: 0.79rem;
  line-height: 1.56;
  color: var(--ink-black);
  box-shadow: 0 3px 10px rgba(32, 18, 10, 0.12);
}
.self-dossier-top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 4px 8px;
  padding-bottom: 5px;
  margin-bottom: 5px;
  border-bottom: 1px dashed rgba(168, 38, 26, 0.26);
}
.self-dossier-name {
  font-size: 0.88rem;
  font-weight: 900;
  color: var(--ink-black);
}
.self-dossier-qual {
  font-size: 0.7rem;
  padding: 1px 6px;
  border-radius: 2px;
  background: rgba(47, 89, 83, 0.12);
  color: var(--lore-teal);
  font-weight: 700;
}
.self-dossier-line {
  margin: 3px 0;
  color: var(--ink-mid);
  font-size: 0.77rem;
}
.jump-post-link {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 1px 6px;
  background: rgba(168, 38, 26, 0.1);
  color: #a8261a;
  border: 1px solid rgba(168, 38, 26, 0.45);
  border-radius: 2px;
  font-weight: 900;
  cursor: pointer;
  transition: all 0.14s ease;
}
.jump-post-link:hover {
  background: #a8261a;
  color: #fbf5ea;
}

/* 原版 4 种朱笔处分抉择区 */
.choice-box {
  margin: 8px 0 4px 44px;
  padding: 8px 10px;
  background: rgba(226, 214, 192, 0.56);
  border-left: 2.5px solid var(--vermilion);
  border-radius: 2px;
}
.choice-prompt {
  font-size: 0.8rem;
  font-weight: 800;
  color: var(--vermilion);
  margin-bottom: 6px;
}
.choice-option {
  padding: 7px 9px 7px 25px;
  margin-bottom: 5px;
  background: rgba(247, 242, 232, 0.9);
  border: 1px solid rgba(130, 105, 75, 0.34);
  border-radius: 2px;
  font-size: 0.84rem;
  line-height: 1.44;
  color: var(--ink-black);
  position: relative;
  cursor: pointer;
  transition: all 0.14s ease;
}
.choice-option:last-child { margin-bottom: 0; }
.choice-option::before {
  content: '○';
  position: absolute;
  left: 8px;
  top: 6px;
  color: var(--vermilion);
  font-size: 0.86rem;
}
.choice-option:hover,
.choice-option.picked {
  border-color: var(--vermilion);
  background: rgba(168, 38, 26, 0.08);
  font-weight: 700;
}
.choice-option:hover::before,
.choice-option.picked::before { content: '✓'; }
.choice-option.dimmed { opacity: 0.4; pointer-events: none; }

/* ==========================================================================
 * 右下角压纸青花碗（朱笔决断时自动退让）
 * ========================================================================== */
#bowl-corner {
  position: absolute;
  bottom: 12px;
  right: 12px;
  z-index: 25;
  display: flex;
  flex-direction: column;
  align-items: center;
  pointer-events: none;
  transition: transform 0.25s ease, opacity 0.25s ease;
}
#bowl-corner.receded {
  opacity: 0.28;
  transform: translate(28px, 28px) scale(0.84);
}
#bowl-touch-area {
  width: 184px;
  height: 184px;
  border-radius: 50%;
  pointer-events: auto;
  position: relative;
  box-shadow: -4px 7px 18px rgba(28, 18, 9, 0.46), 0 1px 4px rgba(20, 12, 5, 0.35);
}
#bowl-canvas {
  width: 100%;
  height: 100%;
  display: block;
  cursor: grab;
  touch-action: none;
}
#bowl-canvas:active { cursor: grabbing; }
#bowl-subtle-tip {
  margin-top: 4px;
  font-size: 0.71rem;
  color: var(--ink-faint);
  letter-spacing: 0.08em;
  opacity: 0.88;
}

/* 浮层容器 */
#rulebook-overlay {
  position: absolute;
  inset: 0;
  z-index: 220;
  background: rgba(12, 9, 6, 0.82);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.28s ease, visibility 0.28s ease;
}
#rulebook-overlay.rb2-ready:not(.closed) {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

#endgame-overlay {
  position: absolute;
  inset: 0;
  z-index: 140;
  background-color: var(--xuan-paper);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}
#endgame-overlay.open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}