/* ---------- 基礎 ---------- */
:root {
  --ink: #0b0908;
  --ink-2: #141010;
  --paper: #ece2cf;
  --muted: #b0a89a;
  --line: rgba(236, 226, 207, 0.14);
  --blood: #8b1e2d;
  --blood-2: #c0392b;
  --gold: #c9a227;
  --moss: #3f5a44;

  /* 主題色（各 tale-*.css 會覆寫）*/
  --accent: var(--blood-2);
  --accent-deep: var(--blood);

  /* 字型：webfont 抓不到時要優雅退回「系統中文字型」——大陸擋 Google Fonts 就是靠這串。
     同時列了 macOS（Songti/STKaiti）、Windows（SimSun/宋体、KaiTi/楷体）、Linux（Source Han）三邊的名字。 */
  --font-body: "Noto Serif TC", "Source Han Serif TC", "Source Han Serif SC",
               "Songti TC", "Songti SC", "STSong", "SimSun", "宋体", "PMingLiU", serif;
  --font-display: "Ma Shan Zheng", "STKaiti", "Kaiti SC", "KaiTi", "楷体",
                  "Noto Serif TC", "Source Han Serif TC", serif;

  --radius: 16px;
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.6);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }   /* 必須：否則 .modal/.dice-layer 的 display 會蓋掉 hidden */
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--font-body);
  color: var(--paper);
  background: var(--ink);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  line-height: 1.75;
}
button, textarea, input { font-family: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3 { font-weight: 700; margin: 0; }
p { margin: 0 0 0.7em; }
.muted { color: var(--muted); font-size: 0.9em; }
strong { color: #fff; font-weight: 700; }

/* ---------- 背景 ---------- */
.backdrop { position: fixed; inset: 0; z-index: 0; overflow: hidden; background: var(--ink); }
.backdrop-art { position: absolute; inset: -6%; transition: opacity 1.2s ease; opacity: 0.9; }
.backdrop-art svg { width: 100%; height: 100%; display: block; }
.fog {
  position: absolute; inset: -20%; pointer-events: none;
  background: radial-gradient(60% 40% at 30% 60%, rgba(200, 200, 210, 0.06), transparent 70%),
              radial-gradient(50% 40% at 75% 40%, rgba(200, 200, 210, 0.05), transparent 70%);
  animation: drift 40s linear infinite alternate;
  will-change: transform;              /* 純平移，交給合成器處理 */
}
.fog-2 { animation-duration: 70s; animation-direction: alternate-reverse; opacity: 0.7; }
/* 只有平移，不要 scale —— 縮放會迫使每一幀重新光柵化 */
@keyframes drift { from { transform: translate3d(-3%, 0, 0); } to { transform: translate3d(3%, -2%, 0); } }
/* 遊戲畫面時場景圖會完全蓋住背景，霧純屬白做工 → 直接關掉 */
body.in-game .fog { display: none; }
body.in-game .backdrop-art { transition: none; }
.vignette {
  position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(120% 90% at 50% 35%, transparent 40%, rgba(0, 0, 0, 0.55) 78%, rgba(0, 0, 0, 0.9) 100%);
}

/* ---------- 螢幕切換 ---------- */
#app { position: relative; z-index: 2; height: 100%; }
.screen {
  position: absolute; inset: 0;
  display: none;
  padding: 24px;
  overflow-y: auto;
}
.screen.is-active { display: flex; animation: fadein 0.7s ease both; }
@keyframes fadein { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* ---------- 按鈕 ---------- */
.btn {
  border: 1px solid var(--line);
  background: rgba(22, 17, 17, 0.9);
  color: var(--paper);
  padding: 13px 26px;
  border-radius: 999px;
  font-size: 1rem;
  letter-spacing: 0.05em;
  transition: border-color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
}
.btn:hover { border-color: rgba(255, 255, 255, 0.4); }
.btn-primary {
  background: linear-gradient(135deg, var(--blood), var(--blood-2));
  border-color: transparent; color: #fff; font-weight: 600;
  box-shadow: 0 10px 30px rgba(139, 30, 45, 0.45);
}
.btn-primary:hover { filter: brightness(1.12); box-shadow: 0 14px 40px rgba(192, 57, 43, 0.6); }
.btn-ghost { background: transparent; }
.btn:disabled { opacity: 0.35; cursor: not-allowed; transform: none; }

.icon-btn {
  background: rgba(20, 16, 16, 0.6); border: 1px solid var(--line);
  width: 40px; height: 40px; border-radius: 10px; font-size: 1.05rem;
  display: grid; place-items: center; transition: all 0.2s;
}
.icon-btn:hover { border-color: rgba(255, 255, 255, 0.4); }

.link-btn {
  background: none; border: none; color: var(--muted);
  font-size: 0.85rem; text-decoration: underline dotted;
  text-underline-offset: 4px; padding: 6px;
}
.link-btn:hover { color: var(--gold); }

/* ---------- 沒有 AI 時（純網頁版 / 本機沒設 NVIDIA_API_KEY）----------
   自由行動、AI 結局、跟角色對話這幾塊都做不了，直接收起來，不要讓玩家點了才發現壞掉。 */
body.no-ai .free-bar,
body.no-ai #btn-finale,
body.no-ai .choice.chat,
body.no-ai [data-chat] { display: none !important; }

/* ---------- 標題畫面 ---------- */
#screen-title { text-align: center; }
.title-wrap { max-width: 640px; width: 100%; padding: 20px; margin: auto; position: relative; isolation: isolate; }
/* 標題底下壓一層柔和的暗色，確保不論背景插畫長怎樣，亮色標題都讀得出來 */
.title-wrap::before {
  content: ''; position: absolute; inset: -8% -14%; z-index: 0; pointer-events: none;
  background: radial-gradient(ellipse at 50% 44%, rgba(0, 0, 0, .62), rgba(0, 0, 0, .34) 52%, rgba(0, 0, 0, 0) 78%);
}
.title-wrap > * { position: relative; z-index: 1; }
.eyebrow { letter-spacing: 0.4em; font-size: 0.75rem; color: var(--gold); text-transform: uppercase; margin-bottom: 14px; text-shadow: 0 1px 10px rgba(0, 0, 0, .85); }
.game-title {
  font-family: var(--font-display);
  font-size: clamp(3.4rem, 12vw, 7rem);
  line-height: 1; letter-spacing: 0.06em; margin: 0;
  text-shadow: 0 0 40px rgba(192, 57, 43, 0.6), 0 4px 20px rgba(0, 0, 0, 0.9);
}
.game-sub { font-size: 1.15rem; letter-spacing: 0.5em; color: var(--muted); margin: 6px 0 26px; text-shadow: 0 1px 12px rgba(0, 0, 0, .9); }
.title-intro { max-width: 460px; margin: 0 auto 30px; color: #d8cfbd; text-shadow: 0 1px 12px rgba(0, 0, 0, .9); }
.title-actions { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; }
.title-foot { margin-top: 34px; font-size: 0.78rem; color: var(--muted); line-height: 1.9; }

/* ---------- 抽角色 ---------- */
#screen-draw { text-align: center; }
.draw-wrap { width: min(560px, 100%); margin: auto; }
.slot {
  margin: 14px 0; padding: 16px 20px; border-radius: var(--radius);
  border: 1px dashed var(--line); background: rgba(0, 0, 0, 0.35);
}
.slot-emoji { font-size: 2.6rem; filter: drop-shadow(0 0 20px rgba(0,0,0,.6)); }
.slot-name { font-size: 1.45rem; font-weight: 700; margin-top: 4px; min-height: 1.3em; }
.slot-tag { color: var(--muted); font-size: 0.9rem; }
.slot.rolling .slot-emoji { animation: shake 0.12s linear infinite; }
@keyframes shake { 0% { transform: translateY(-6px) rotate(-4deg); } 100% { transform: translateY(6px) rotate(4deg); } }

.arch-card {
  text-align: left; border: 1px solid var(--line); border-radius: var(--radius);
  background: rgba(10, 8, 8, 0.75); padding: 18px; margin-bottom: 14px;
  box-shadow: var(--shadow); animation: fadein 0.5s both;
}
.arch-head { display: flex; align-items: center; gap: 12px; }
.arch-emoji { font-size: 2.2rem; }
.arch-name { font-size: 1.35rem; font-weight: 700; }
.arch-tag { color: var(--muted); font-size: 0.85rem; }
.arch-role { margin-left: auto; font-size: 0.75rem; padding: 4px 10px; border: 1px solid var(--line); border-radius: 999px; color: var(--gold); }
.arch-desc { margin: 10px 0; color: #d8cfbd; font-size: 0.95rem; }
.arch-bias { margin-top: 8px; font-size: 0.85rem; color: var(--gold); }
.arch-ability { margin-top: 8px; padding: 10px 12px; border-radius: 12px; background: rgba(201, 162, 39, 0.08); border: 1px solid rgba(201, 162, 39, 0.25); font-size: 0.86rem; }
.arch-ability b { color: var(--gold); }
.draw-actions { display: flex; gap: 12px; justify-content: center; }

/* ---------- 遊戲畫面 ---------- */
#screen-game { flex-direction: column; padding: 0; }
.hud {
  display: flex; align-items: center; gap: 12px; padding: 12px 18px;
  border-bottom: 1px solid var(--line); background: rgba(8, 6, 6, 0.88);
  z-index: 5;
}
.hud-left, .hud-right { display: flex; align-items: center; gap: 8px; }
.hud-right { margin-left: auto; }
.hud-role { font-weight: 700; font-size: 0.95rem; }
.hud-mid { text-align: center; flex: 1; min-width: 0; }
.hud-chapter { color: var(--gold); font-size: 0.72rem; letter-spacing: 0.2em; display: block; }
.hud-loc { font-size: 0.9rem; color: var(--muted); }

.stage { position: relative; flex: 1; min-height: 0; display: flex; }
.scene-art { position: absolute; inset: 0; z-index: 0; overflow: hidden; }
.scene-art svg { width: 100%; height: 100%; display: block; }
.scene-art::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(to bottom, rgba(0,0,0,0.25), rgba(0,0,0,0.15) 40%, rgba(0,0,0,0.88));
}
.scene-scroll {
  position: relative; z-index: 1; flex: 1; overflow-y: auto;
  padding: 26px; display: flex; flex-direction: column; justify-content: flex-end;
  max-width: 780px; margin: 0 auto; width: 100%;
}
.narration {
  font-size: 1.06rem; color: #efe6d4; text-shadow: 0 2px 12px rgba(0,0,0,0.9);
  white-space: pre-wrap; margin-bottom: 20px; min-height: 3em;
}
.narration .cursor { animation: blink 1s step-end infinite; }
@keyframes blink { 50% { opacity: 0; } }
.result-note {
  border-left: 3px solid var(--gold); padding: 12px 16px; margin-bottom: 18px;
  background: rgba(201, 162, 39, 0.08); border-radius: 0 10px 10px 0; font-size: 0.95rem;
  animation: fadein 0.35s both;
}
.result-text { color: #efe6d4; white-space: pre-wrap; }
.delta-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.delta-chip { font-size: 0.78rem; padding: 3px 10px; border-radius: 999px; border: 1px solid var(--line); white-space: nowrap; }
.delta-chip.up { color: #9de8c6; border-color: #3f9e7a; background: rgba(63, 158, 122, 0.12); }
.delta-chip.down { color: #ffb0a2; border-color: #c0392b; background: rgba(192, 57, 43, 0.12); }
.delta-chip.bond { color: #f0d774; border-color: #c9a227; background: rgba(201, 162, 39, 0.1); }
.delta-chip.bad { color: #d9a0ff; border-color: #8e44ad; background: rgba(142, 68, 173, 0.14); }
.delta-chip.good { color: #9de8c6; border-color: #3f9e7a; background: rgba(63, 158, 122, 0.12); }
.continue-btn { display: block; margin: 14px 0 0; }
.choices { display: flex; flex-direction: column; gap: 10px; }
.choice {
  text-align: left; border: 1px solid var(--line); border-radius: 12px;
  background: rgba(14, 11, 11, 0.9); padding: 14px 18px;
  transition: border-color 0.2s ease, background 0.2s ease, transform 0.2s ease;
  animation: fadein 0.4s both;
}
.choice:hover:not(.locked) { border-color: var(--blood-2); background: rgba(139, 30, 45, 0.22); transform: translateX(4px); }
.choice-top { display: flex; align-items: baseline; gap: 10px; }
.choice-label { font-size: 1.02rem; }
.choice-odds { margin-left: auto; font-size: 0.78rem; padding: 2px 8px; border-radius: 999px; white-space: nowrap; }
.choice-hint { color: var(--muted); font-size: 0.84rem; margin-top: 4px; }
.choice.locked { opacity: 0.5; cursor: not-allowed; }
.choice.locked .choice-label { text-decoration: line-through; text-decoration-color: rgba(255,255,255,.3); }
.choice.chat { border-style: dashed; border-color: rgba(201,162,39,.3); }
.odds-good { background: rgba(63, 158, 122, 0.25); color: #7fe0bb; }
.odds-mid { background: rgba(201, 162, 39, 0.22); color: #f0d774; }
.odds-bad { background: rgba(192, 57, 43, 0.25); color: #ff9a8a; }
.scene-actions { margin-top: 14px; text-align: center; display: flex; gap: 18px; justify-content: center; flex-wrap: wrap; }
.finale-btn { color: #e6cf8f; }
.finale-btn:hover { color: var(--gold); }

/* ---------- 自由行動 ---------- */
.free-bar { margin-top: 16px; }
.free-toggle {
  width: 100%; text-align: left; padding: 11px 16px; border-radius: 12px;
  border: 1px dashed rgba(201, 162, 39, 0.35); background: rgba(201, 162, 39, 0.06);
  color: #e2d3a8; font-size: 0.88rem; transition: all 0.2s;
}
.free-toggle:hover { border-color: var(--gold); background: rgba(201, 162, 39, 0.12); }
.free-toggle.open { border-style: solid; border-bottom-left-radius: 0; border-bottom-right-radius: 0; }
.free-panel {
  border: 1px solid rgba(201, 162, 39, 0.3); border-top: none;
  border-radius: 0 0 12px 12px; padding: 12px; background: rgba(10, 8, 8, 0.6);
  animation: fadein 0.25s both;
}
.free-panel textarea {
  width: 100%; resize: none; background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; font-size: 0.95rem;
}
.free-panel textarea:focus { outline: none; border-color: var(--gold); }
.free-buttons { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.free-buttons .btn-send { border-radius: 10px; padding: 8px 20px; background: var(--blood); border-color: transparent; color: #fff; }
.idea-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.idea-row:empty { display: none; }
.idea-chip { font-size: 0.88rem; border: 1px solid rgba(201,162,39,.45); background: rgba(201,162,39,.1); color: #f2e4bb; border-radius: 999px; padding: 7px 14px; }
.idea-chip:hover { background: rgba(201,162,39,.18); }
.idea-chip:disabled { opacity: .5; }
.free-result {
  margin-top: 12px; padding: 12px 14px; border-radius: 10px;
  background: rgba(255, 255, 255, 0.04); border-left: 3px solid var(--gold);
  font-size: 0.95rem; white-space: pre-wrap; color: #efe6d4;
}
.free-result .fr-label { font-size: 0.72rem; letter-spacing: .2em; color: var(--gold); display: block; margin-bottom: 8px; }
.free-result .delta-row { margin-top: 12px; }
.free-result .delta-chip { font-size: 0.86rem; padding: 5px 13px; }

/* ---------- 狀態面板 ---------- */
.status-panel {
  position: absolute; top: 0; right: 0; bottom: 0; width: min(400px, 92vw);
  background: rgba(10, 8, 8, 0.995); border-left: 1px solid var(--line);
  transform: translateX(105%); visibility: hidden;
  transition: transform 0.35s cubic-bezier(.3,.8,.3,1), visibility 0s linear 0.35s;
  z-index: 20; display: flex; flex-direction: column;
}
.status-panel.open { transform: none; visibility: visible; transition-delay: 0s, 0s; }
.panel-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px; border-bottom: 1px solid var(--line); }
.panel-body { overflow-y: auto; padding: 18px; }
.scrim { position: absolute; inset: 0; background: rgba(0,0,0,.5); z-index: 15; }

.section-title { color: var(--gold); font-size: 0.72rem; letter-spacing: 0.25em; margin: 20px 0 10px; }
.section-title:first-child { margin-top: 0; }
.stat-row { margin-bottom: 12px; }
.stat-line { display: flex; align-items: center; gap: 8px; font-size: 0.88rem; margin-bottom: 5px; }
.stat-line .s-name { flex: 0 0 auto; }
.stat-line .s-val { margin-left: auto; font-variant-numeric: tabular-nums; color: var(--muted); }
.bar { height: 7px; border-radius: 999px; background: rgba(255,255,255,0.08); overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 999px; transition: width 0.6s ease; }
.bond-row { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.bond-emoji { font-size: 1.5rem; }
.bond-info { flex: 1; min-width: 0; }
.bond-name { font-size: 0.9rem; display: flex; gap: 8px; align-items: baseline; }
.bond-name small { color: var(--muted); }
.bond-label { font-size: 0.72rem; color: var(--muted); margin-bottom: 3px; }
.bond-track { position: relative; height: 7px; border-radius: 999px; background: rgba(255,255,255,0.08); }
.bond-track::before { content: ""; position: absolute; left: 50%; top: -3px; bottom: -3px; width: 1px; background: rgba(255,255,255,0.25); }
.bond-fill { position: absolute; top: 0; bottom: 0; border-radius: 999px; }
.bond-chat { font-size: 0.75rem; border: 1px solid var(--line); border-radius: 8px; padding: 5px 9px; background: none; }
.bond-chat:hover { border-color: var(--gold); color: var(--gold); }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line); background: rgba(255,255,255,0.04); font-size: 0.85rem; margin: 0 8px 8px 0; }

/* ---------- 結局 ---------- */
#screen-ending { }
.ending-wrap { max-width: 620px; width: 100%; text-align: center; animation: fadein 1.2s both; margin: auto; }
.ending-meta { color: var(--muted); font-size: .82rem; letter-spacing: .06em; margin: 6px 0 14px; }
.ending-kind { letter-spacing: 0.4em; font-size: 0.75rem; color: var(--gold); }
.ending-title { font-family: var(--font-display); font-size: clamp(2.4rem, 8vw, 4rem); margin: 10px 0 20px;
  text-shadow: 0 3px 20px rgba(0, 0, 0, .85); }
.ending-ai { display: inline-block; margin: -6px 0 14px; padding: 3px 12px; border-radius: 999px; font-size: .74rem; letter-spacing: .08em; color: #ffe9b8; background: rgba(212,175,55,.12); border: 1px solid rgba(212,175,55,.4); }
.ending-text { color: #ded5c2; margin-bottom: 24px; white-space: pre-wrap; }
.ending-grade { display: inline-block; padding: 10px 20px; border: 1px solid var(--gold); border-radius: 999px; color: var(--gold); margin-bottom: 26px; }
.ending-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }

/* ---------- 對話抽屜 ---------- */
.drawer {
  position: fixed; z-index: 40; right: 0; top: 0; bottom: 0; width: min(460px, 100vw);
  background: rgba(10, 8, 8, 0.995); border-left: 1px solid var(--line);
  transform: translateX(105%); visibility: hidden;
  transition: transform 0.4s cubic-bezier(.3,.8,.3,1), visibility 0s linear 0.4s;
  display: flex; flex-direction: column;
}
.drawer.open { transform: none; visibility: visible; transition-delay: 0s, 0s; box-shadow: -30px 0 60px rgba(0,0,0,.6); }
.drawer-head { display: flex; align-items: center; gap: 12px; padding: 16px 18px; border-bottom: 1px solid var(--line); }
.drawer-avatar { font-size: 2rem; }
.drawer-name { font-weight: 700; }
.drawer-bond { font-size: 0.78rem; color: var(--muted); }
.drawer-head .icon-btn { margin-left: auto; }
.drawer-log { flex: 1; overflow-y: auto; padding: 18px; display: flex; flex-direction: column; gap: 12px; }
.msg { max-width: 86%; padding: 11px 15px; border-radius: 14px; font-size: 0.95rem; white-space: pre-wrap; line-height: 1.7; }
.msg.npc { align-self: flex-start; background: rgba(255,255,255,0.06); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.msg.me { align-self: flex-end; background: rgba(139, 30, 45, 0.35); border: 1px solid rgba(192,57,43,.4); border-bottom-right-radius: 4px; }
.msg.sys { align-self: center; color: var(--muted); font-size: 0.82rem; background: none; }
.msg.typing::after { content: "▍"; animation: blink 1s step-end infinite; }
.drawer-input { display: flex; gap: 8px; padding: 14px; border-top: 1px solid var(--line); }
.drawer-input textarea { flex: 1; resize: none; background: rgba(255,255,255,0.05); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; font-size: 0.95rem; }
.drawer-input textarea:focus { outline: none; border-color: var(--blood-2); }
.btn-send { border-radius: 12px; padding: 0 18px; background: var(--blood); border-color: transparent; color: #fff; }
.drawer-suggest { display: flex; gap: 8px; flex-wrap: wrap; padding: 0 14px 14px; }
.suggest { font-size: 0.78rem; border: 1px dashed var(--line); background: none; border-radius: 999px; padding: 6px 12px; color: var(--muted); }
.suggest:hover { color: var(--gold); border-color: var(--gold); }

/* ---------- 骰子 ---------- */
.dice-layer {
  position: fixed; inset: 0; z-index: 60; display: grid; place-items: center;
  background: rgba(0,0,0,0.84); animation: fadein 0.25s both;
}
.dice-box { text-align: center; max-width: 420px; padding: 24px; }
.dice-face {
  width: 120px; height: 120px; margin: 0 auto 18px; border-radius: 20px;
  border: 2px solid var(--gold); background: rgba(10,8,8,.9);
  display: grid; place-items: center; font-size: 3rem; font-weight: 700;
  font-variant-numeric: tabular-nums; box-shadow: 0 0 40px rgba(201,162,39,.35);
}
.dice-face.rolling { animation: tumble 0.5s linear infinite; }
@keyframes tumble { 0% { transform: rotate(-8deg) scale(1.02); } 50% { transform: rotate(8deg) scale(0.98); } 100% { transform: rotate(-8deg) scale(1.02); } }
.dice-title { font-size: 1.2rem; margin-bottom: 6px; }
.dice-break { color: var(--muted); font-size: 0.9rem; font-variant-numeric: tabular-nums; }
.dice-outcome { font-size: 1.3rem; font-weight: 700; margin: 14px 0; }
.dice-outcome.win { color: #7fe0bb; }
.dice-outcome.lose { color: #ff9a8a; }
.dice-note { color: #ded5c2; margin-bottom: 18px; white-space: pre-wrap; }
.dice-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

/* ---------- 說明彈窗 ---------- */
.modal { position: fixed; inset: 0; z-index: 70; display: grid; place-items: center; padding: 20px; background: rgba(0,0,0,.86); animation: fadein .3s both; }
.modal-box { position: relative; max-width: 580px; max-height: 84vh; overflow-y: auto; background: rgba(12,9,9,.98); border: 1px solid var(--line); border-radius: 18px; padding: 30px; box-shadow: var(--shadow); }
.modal-x { position: absolute; top: 14px; right: 14px; }
.modal-box h2 { font-family: var(--font-display); font-size: 2rem; margin-bottom: 16px; }
.modal-box h3 { color: var(--gold); font-size: 0.95rem; margin: 18px 0 8px; }
.modal-box ul { padding-left: 20px; margin: 0 0 10px; }
.modal-box li { margin-bottom: 6px; color: #d8cfbd; }

/* ---------- Toast ---------- */
.toast-layer { position: fixed; z-index: 80; left: 50%; top: 76px; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast {
  padding: 10px 18px; border-radius: 999px; font-size: 0.88rem;
  background: rgba(10,8,8,.95); border: 1px solid var(--line); box-shadow: var(--shadow);
  animation: toastin 0.4s both;
}
.toast.up { border-color: #3f9e7a; color: #9de8c6; }
.toast.down { border-color: #c0392b; color: #ffb0a2; }
.toast.gold { border-color: var(--gold); color: #f0d774; }
@keyframes toastin { from { opacity: 0; transform: translateY(-14px); } to { opacity: 1; transform: none; } }

/* ---------- 響應式 ---------- */
@media (max-width: 640px) {
  .hud-mid { display: none; }
  .scene-scroll { padding: 18px; }
  .narration { font-size: 1rem; }
  .game-sub { letter-spacing: 0.3em; }
}

/* ---------- 童話選擇 ---------- */
.tale-picker { margin: 8px 0 26px; }
.tale-picker .eyebrow { margin-bottom: 12px; }
.tale-list { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; }
.tale-chip {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  min-width: 150px; padding: 12px 18px; border-radius: 14px;
  background: rgba(0,0,0,.32); border: 1px solid var(--line);
  color: var(--paper); transition: transform .18s ease, border-color .18s ease, box-shadow .18s ease;
}
.tale-chip:hover { transform: translateY(-2px); border-color: var(--accent); }
.tale-chip.active { border-color: var(--accent); box-shadow: inset 0 0 26px color-mix(in srgb, var(--accent) 22%, transparent); }
.tale-chip .tc-title { font-family: var(--font-display); font-size: 1.15rem; }
.tale-chip .tc-sub { font-size: .74rem; color: var(--muted); letter-spacing: .12em; }

/* 對話：尊重角色設定開關 */
.chat-respect {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  margin: 0 0 8px; padding: 7px 10px; border-radius: 10px;
  border: 1px solid var(--line); background: rgba(255,255,255,.03);
  font-size: .8rem; color: var(--ink); cursor: pointer; user-select: none;
}
.chat-respect input { accent-color: var(--accent, #d4af37); width: 15px; height: 15px; }
.chat-respect span { font-weight: 600; letter-spacing: .03em; }
.chat-respect em { font-style: normal; color: var(--muted); font-size: .74rem; }
.msg.align-note { color: var(--accent, #d4af37); opacity: .95; font-size: .84rem; font-style: normal; }
.msg.align-note .align-new { font-weight: 600; }
.msg.align-note .align-old { color: var(--muted); font-size: .78rem; margin-top: 3px; }

/* ===== 窄螢幕／手機 ===== */
@media (max-width: 720px) {
  .hud { flex-wrap: wrap; gap: 6px; }
  .hud-mid { order: 3; width: 100%; text-align: center; }
  .hud-right { margin-left: auto; }
  .status-panel { width: 88vw; }
  .drawer { width: 100vw; }
  .modal-box { width: 94vw !important; max-height: 90vh; }
  .map-scroll { max-height: 52vh; }
  .title-actions { flex-direction: column; gap: 8px; }
  .title-actions .btn { width: 100%; }
  .choices .choice { padding: 12px; }
  .choice-odds { font-size: .72rem; }
  .tale-list { grid-template-columns: 1fr !important; }
  .ending-wrap { padding: 0 16px; }
}
@media (max-width: 420px) {
  .game-title { font-size: 2rem; }
  .narration { font-size: 1rem; line-height: 1.8; }
}

/* ===== 今夜的變數（命運牌）===== */
.hud-twist {
  font: inherit; font-size: .72rem; cursor: pointer;
  background: rgba(201,162,39,.12); border: 1px solid rgba(201,162,39,.42);
  color: var(--gold); border-radius: 999px; padding: 2px 9px; margin-left: 8px;
  white-space: nowrap;
}
.hud-twist:hover { background: rgba(201,162,39,.22); }
.twist-badge {
  background: rgba(201,162,39,.10); border: 1px solid rgba(201,162,39,.35);
  border-radius: 10px; padding: 8px 10px; margin-bottom: 10px; color: var(--gold); font-size: .85rem;
}
.twist-badge b { color: #f0e2b0; }
.twist-desc { color: var(--muted); font-size: .78rem; margin-top: 4px; }

/* ===== 種子碼 ===== */
.seed-row { display: flex; align-items: center; gap: 8px; justify-content: center;
  margin-top: 14px; color: var(--muted); font-size: .82rem; flex-wrap: wrap; }
.seed-row input { font: inherit; font-size: .82rem; width: 190px; padding: 5px 9px;
  background: rgba(0,0,0,.28); border: 1px solid var(--line); border-radius: 8px; color: #eaf1f8; }
.seed-badge { border-color: rgba(143,198,224,.42); background: rgba(143,198,224,.08); color: #9fd8e6; }
.seed-badge b { color: #cfeaf6; }
.ending-seed { color: var(--muted); font-size: .82rem; margin: 6px 0 2px; }
.ending-seed b { color: #9fd8e6; }

/* ===== 空狀態（配插圖）===== */
.empty-state { text-align: center; padding: 14px 8px 6px; }
.empty-art { display: block; margin: 0 auto 12px; width: min(350px, 78%); height: auto;
  border-radius: 12px; border: 1px solid var(--line); box-shadow: 0 10px 30px rgba(0,0,0,.45); }
.empty-state .empty-lead { color: #eaf1f8; font-size: .98rem; margin: 0 0 4px; }
.empty-state .muted { margin: 0; }

/* ===== 🌩 今夜的劫數（上帝視角）===== */
.doom-badge {
  background: rgba(143,120,224,.16); border: 1px solid rgba(167,148,240,.55);
  border-radius: 10px; padding: 10px 11px; margin-bottom: 10px; color: #d9ceff; font-size: .86rem;
}
.doom-badge .doom-head { color: #efe6ff; }
.doom-badge .doom-head b { color: #ffffff; }
.doom-badge .doom-desc { color: #cfc6ec; font-size: .77rem; margin: 5px 0 8px; }
.doom-row { display: flex; gap: 8px; align-items: flex-start; padding: 5px 0; border-top: 1px dashed rgba(167,148,240,.32); }
.doom-row:first-of-type { border-top: 0; }
.doom-mark { flex: none; width: 14px; text-align: center; color: #b3a0f5; font-weight: 700; }
.doom-row.ok .doom-mark { color: #7fd6a8; }
.doom-label { color: #f2eefc; font-size: .83rem; font-weight: 600; }
.doom-row.ok .doom-label { color: #a8e6c1; text-decoration: line-through; text-decoration-color: rgba(111,191,154,.55); }
.doom-hint { color: #d5cdec; font-size: .75rem; margin-top: 2px; }
.doom-row.ok .doom-hint { color: #8fd0a8; }
/* 情報戰：還沒問出來的那幾條 */
.doom-row.locked .doom-mark { color: #9b90c0; }
.doom-row.locked .doom-label { color: #bebab8; font-weight: 400; font-style: italic; }
.doom-unknown { color: #b3a0f5; font-size: .76rem; margin-left: 6px; font-weight: 400; }
/* 🌩 避開的劫數：標出「當時是用哪一件道具擋下來的」 */
.doom-via { display: inline-block; margin-left: 8px; padding: 1px 8px; vertical-align: 1px;
  font-size: .7rem; font-weight: 500; color: #0f1116; background: #8fd0a8; border-radius: 999px; }
.doom-pill i { font-style: normal; opacity: .8; }
.doom-reveal { display: inline-block; margin-top: 4px; padding: 3px 10px;
  font: inherit; font-size: .74rem; cursor: pointer;
  background: rgba(167,148,240,.18); border: 1px solid rgba(167,148,240,.6);
  border-radius: 20px; color: #e8e2ff; }
.doom-reveal:hover { background: rgba(167,148,240,.30); }
.ending-dooms { color: #cfc6ec; font-size: .85rem; margin: 8px 0 2px; }
.ending-dooms b { color: #d9ceff; }
.doom-pills { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin-top: 6px; }
.doom-pill { font-size: .74rem; padding: 2px 8px; border-radius: 20px; border: 1px solid var(--line); color: var(--muted); }
.doom-pill.ok { border-color: rgba(111,191,154,.5); color: #9fd8b6; background: rgba(111,191,154,.10); }
.doom-pill.no { border-color: rgba(176,48,96,.35); color: #d089a8; }

/* ===== 🎒 身上的東西 ===== */
.item-row { display: flex; align-items: center; gap: 10px; padding: 9px 2px; border-bottom: 1px solid var(--line); }
.item-row .it-emoji { font-size: 1.4rem; flex: none; }
.item-row .it-info { flex: 1; min-width: 0; }
.item-row .it-name { color: #eaf1f8; font-weight: 600; }
.item-row .it-desc { color: var(--muted); font-size: .78rem; margin-top: 2px; }
.item-row .btn-sm { padding: 5px 12px; font-size: .8rem; }
.item-mini { display: flex; flex-wrap: wrap; gap: 6px; }
.item-mini span { background: rgba(255,255,255,.05); border: 1px solid var(--line); border-radius: 999px;
  padding: 3px 9px; font-size: .78rem; color: #dfe6ef; }

/* ===== 🎬 轉場：換幕字卡 ===== */
#act-card {
  position: fixed; inset: 0; z-index: 60; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 8px; pointer-events: none;
  background: radial-gradient(ellipse at 50% 50%, rgba(0,0,0,.72), rgba(0,0,0,.92));
  opacity: 0; transition: opacity .5s ease;
}
#act-card.show { opacity: 1; }
#act-card .ac-num { font-family: var(--font-display); font-size: clamp(2rem, 7vw, 4rem); color: var(--gold);
  letter-spacing: .3em; text-indent: .3em; text-shadow: 0 4px 26px rgba(0,0,0,.9); }
#act-card .ac-chapter { color: #e6ddc9; font-size: clamp(.9rem, 2.4vw, 1.15rem); letter-spacing: .28em;
  text-indent: .28em; opacity: .92; }
#act-card .ac-rule { width: 0; height: 1px; background: linear-gradient(90deg, transparent, var(--gold), transparent);
  margin-top: 10px; }
#act-card.show .ac-rule { animation: acRule 1.5s .25s ease forwards; }
#act-card.show .ac-num { animation: acIn .8s ease both; }
#act-card.show .ac-chapter { animation: acIn .9s .18s ease both; }
@keyframes acIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes acRule { from { width: 0; } to { width: min(320px, 46vw); } }

/* ===== 🎬 轉場：黑幕 ===== */
#curtain {
  position: fixed; inset: 0; z-index: 70; pointer-events: none; background: #05060a;
  opacity: 0; transition: opacity .42s ease;
  display: flex; align-items: center; justify-content: center;
}
#curtain.on { opacity: 1; }
#curtain .curtain-label { font-family: var(--font-display); font-size: clamp(2.6rem, 11vw, 6rem);
  color: #f0e6cf; letter-spacing: .34em; text-indent: .34em; opacity: .96;
  text-shadow: 0 0 40px rgba(201,162,39,.35); }
#curtain.on .curtain-label { animation: curIn 1s ease both; }
@keyframes curIn { from { opacity: 0; transform: scale(1.14); } to { opacity: .96; transform: none; } }

/* ===== 🎬 結局演出 ===== */
/* 分批揭幕：每個小孩晚一點出現（最多排到第 10 個） */
.ending-wrap.reveal > * { animation: endRise .85s cubic-bezier(.2,.7,.2,1) both; }
.ending-wrap.reveal > *:nth-child(1) { animation-delay: .10s; }
.ending-wrap.reveal > *:nth-child(2) { animation-delay: .30s; }
.ending-wrap.reveal > *:nth-child(3) { animation-delay: .48s; }
.ending-wrap.reveal > *:nth-child(4) { animation-delay: .62s; }
.ending-wrap.reveal > *:nth-child(5) { animation-delay: .76s; }
.ending-wrap.reveal > *:nth-child(6) { animation-delay: .90s; }
.ending-wrap.reveal > *:nth-child(7) { animation-delay: 1.02s; }
.ending-wrap.reveal > *:nth-child(8) { animation-delay: 1.12s; }
.ending-wrap.reveal > *:nth-child(n+9) { animation-delay: 1.22s; }
@keyframes endRise { from { opacity: 0; transform: translateY(16px); filter: blur(3px); } to { opacity: 1; transform: none; filter: none; } }
.ending-wrap.reveal .ending-title { animation: endTitle 1.1s .30s cubic-bezier(.2,.7,.2,1) both; }
@keyframes endTitle { from { opacity: 0; letter-spacing: .3em; filter: blur(6px); } to { opacity: 1; letter-spacing: normal; filter: none; } }
.ending-wrap.reveal .ending-grade { animation: endPop .7s .9s cubic-bezier(.2,1.4,.4,1) both; }
@keyframes endPop { from { opacity: 0; transform: scale(.72); } to { opacity: 1; transform: none; } }

/* 結局粒子層 */
.ending-fx { position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; }
.ending-fx i {
  position: absolute; left: var(--x); bottom: -6vh; width: 6px; height: 6px; border-radius: 50%;
  opacity: 0; transform: scale(var(--s));
  animation: fxRise var(--dur) var(--d) linear infinite;
}
@keyframes fxRise {
  0% { opacity: 0; transform: translateY(0) scale(var(--s)); }
  12% { opacity: .85; }
  100% { opacity: 0; transform: translateY(-112vh) scale(var(--s)); }
}
.ending-fx.mood-warm i { background: #ffd98a; box-shadow: 0 0 10px rgba(255,217,138,.9); }
.ending-fx.mood-nature i { background: #9fe0b4; box-shadow: 0 0 10px rgba(159,224,180,.8); }
.ending-fx.mood-mystic i { background: #d9b0ff; box-shadow: 0 0 12px rgba(217,176,255,.9); }
.ending-fx.mood-calm i { background: #cfd8e3; box-shadow: 0 0 8px rgba(207,216,227,.7); }
/* 黑暗／悲劇：灰燼往下掉 */
.ending-fx.mood-dark i { background: #b05a5a; box-shadow: 0 0 8px rgba(176,90,90,.7); top: -6vh; bottom: auto;
  animation-name: fxFall; }
@keyframes fxFall {
  0% { opacity: 0; transform: translateY(0) scale(var(--s)); }
  12% { opacity: .7; }
  100% { opacity: 0; transform: translateY(112vh) scale(var(--s)); }
}
/* 結局畫面的底色跟著氣氛走 */
#screen-ending.end-dark { background: radial-gradient(ellipse at 50% 40%, rgba(90,20,30,.42), rgba(0,0,0,.86) 72%); }
#screen-ending.end-warm { background: radial-gradient(ellipse at 50% 42%, rgba(201,162,39,.20), rgba(0,0,0,.80) 74%); }
#screen-ending.end-mystic { background: radial-gradient(ellipse at 50% 42%, rgba(150,110,220,.22), rgba(0,0,0,.82) 74%); }
#screen-ending.end-nature { background: radial-gradient(ellipse at 50% 42%, rgba(70,160,120,.18), rgba(0,0,0,.80) 74%); }
#screen-ending.end-calm { background: radial-gradient(ellipse at 50% 42%, rgba(180,190,205,.14), rgba(0,0,0,.80) 74%); }
/* 內容要壓在粒子層上面；但粒子層自己是 fixed，不能被這條規則改成 relative */
#screen-ending > *:not(.ending-fx) { position: relative; z-index: 1; }
#screen-ending > .ending-fx { position: fixed; z-index: 0; }

/* 尊重角色設定：改寫後顯示「換了個說法」＋原句 */
.msg.align-note .align-new { color: #ffe9b8; }

/* ===== 📖 圖鑑 ===== */
.codex-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 14px; }
.codex-tab { font: inherit; font-size: .8rem; cursor: pointer; padding: 5px 11px; border-radius: 999px;
  background: rgba(255,255,255,.04); border: 1px solid var(--line); color: var(--muted); }
.codex-tab span { margin-left: 6px; opacity: .75; }
.codex-tab.active { color: #111; background: var(--gold); border-color: var(--gold); }
.codex-tab.active span { opacity: .9; }
.codex-tab.done { border-color: rgba(201,162,39,.5); }
.codex-cell { display: flex; align-items: flex-start; gap: 10px; padding: 8px 10px; border-radius: 10px;
  background: rgba(255,255,255,.02); margin-bottom: 6px; }
.codex-cell.got { background: rgba(201,162,39,.07); }
.codex-cell .cc-emoji { font-size: 1.3rem; line-height: 1.4; width: 1.6em; text-align: center; flex: none; }
.codex-cell .cc-dot { width: 14px; height: 14px; border-radius: 50%; border: 2px solid #8a93a0; margin-top: 6px; flex: none; }
.codex-cell .cc-body { min-width: 0; }
.codex-cell .cc-name { color: #eaf1f8; font-weight: 600; font-size: .9rem; }
.codex-cell .cc-desc { color: var(--muted); font-size: .78rem; line-height: 1.55; margin-top: 2px; }

/* ===== 🕰 章節重播 ===== */
.md-actions { display: flex; gap: 8px; margin-top: 10px; }

/* ===== 🎭 隱藏結局 ===== */
.ending-row.hid { border-left: 2px solid rgba(176,122,224,.55); padding-left: 10px; flex-wrap: wrap; }
.ending-row .er-hint { flex: 1 0 100%; color: var(--muted); font-size: .74rem; margin-top: 3px; line-height: 1.5; }

/* ===== 🎬 每日挑戰 ===== */
.daily-card { border: 1px solid var(--line); border-radius: 12px; padding: 12px; background: rgba(255,255,255,.03); margin-bottom: 12px; }
.daily-card.done { border-color: rgba(201,162,39,.45); background: rgba(201,162,39,.07); }
.daily-card .dc-date { color: #eaf1f8; font-weight: 600; }
.daily-card .dc-main { color: var(--gold); margin-top: 5px; font-size: .9rem; }
.daily-card .dc-sub { color: var(--muted); font-size: .78rem; margin-top: 4px; }
.daily-row { display: grid; grid-template-columns: 1.2fr .7fr .7fr 1.4fr; gap: 6px; font-size: .8rem;
  color: var(--muted); padding: 6px 2px; border-bottom: 1px solid var(--line); }
.daily-actions { margin-top: 14px; display: flex; justify-content: flex-end; }

/* ===== 🧩 隱藏開場 ===== */
.opening-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; justify-content: center; margin-top: 12px; }
.opening-row .or-label { color: var(--muted); font-size: .8rem; }
.chip-btn { font: inherit; font-size: .82rem; cursor: pointer; border-radius: 999px; padding: 5px 13px;
  background: rgba(201,162,39,.12); border: 1px solid rgba(201,162,39,.45); color: var(--gold); }
.chip-btn:hover { background: rgba(201,162,39,.24); }

/* ===== 地圖：支線標記 ===== */
.map-node.qst rect { stroke-dasharray: none; stroke: rgba(201,162,39,.75); }
.map-node .map-quest { font-size: 13px; }
.map-quests { color: var(--gold); font-size: .8rem; margin-top: 6px; line-height: 1.6; }
.map-legend .lg.qst { background: rgba(201,162,39,.6); }
.map-legend .lg.iv { background: rgba(201,162,39,.25); border: 1px dashed var(--gold); }

/* ===== 🔮 旅人支線進度 ===== */
.quest-row { margin: 0 0 9px; }
.quest-row .qr-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; font-size: .86rem; color: #eaf1f8; }
.quest-row .qr-step { color: var(--gold); font-size: .78rem; flex: none; }
.quest-row .qr-track { height: 4px; border-radius: 2px; background: rgba(255,255,255,.08); margin-top: 5px; overflow: hidden; }
.quest-row .qr-track i { display: block; height: 100%; background: linear-gradient(90deg, rgba(201,162,39,.5), var(--gold)); }
.quest-row.done .qr-top { color: var(--muted); }
.quest-row.done .qr-track i { background: #3f9e7a; }

/* ===== 🃏 合成 ===== */
.craft-row { background: rgba(255,255,255,.03); border-radius: 10px; padding: 9px 10px; border-bottom: none; margin-bottom: 6px; }
.craft-row.can { background: rgba(201,162,39,.08); }
.craft-row .it-desc { display: flex; flex-wrap: wrap; align-items: center; gap: 3px; margin-top: 3px; }
.craft-row .it-hint { color: var(--muted); font-size: .74rem; margin-top: 3px; }
.craft-row .mat { border: 1px solid var(--line); border-radius: 999px; padding: 1px 7px; font-size: .74rem; color: var(--muted); }
.craft-row .mat.have { color: var(--gold); border-color: rgba(201,162,39,.5); }
.craft-row .mat-plus, .craft-row .mat-arrow { color: var(--muted); font-size: .72rem; }
.craft-row .craft-note { color: var(--muted); font-size: .74rem; flex: none; }
.craft-group { color: #cbb46a; font-size: .76rem; letter-spacing: .04em; margin: 10px 0 4px; }
.craft-local { font-size: .66rem; font-weight: 500; color: #0f1116; background: var(--gold);
  border-radius: 999px; padding: 1px 7px; margin-left: 6px; vertical-align: 1px; }
/* 🗺 這部會出現的道具（每一部不一樣；沒找到的留 ?） */
.tale-items { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 6px; }
.tale-item { display: inline-flex; align-items: center; gap: 4px; font-size: .76rem; color: var(--muted);
  border: 1px dashed var(--line); border-radius: 999px; padding: 3px 10px; opacity: .72; }
.tale-item b { font-weight: 600; }
.tale-item.got { color: #eaf1f8; border-style: solid; border-color: rgba(201,162,39,.55);
  background: rgba(201,162,39,.10); opacity: 1; }
.tale-item .ti-q { filter: grayscale(1); opacity: .7; }

/* ===== 隨機插曲 ===== */
.interlude-banner { display: inline-block; margin: 0 0 12px; padding: 5px 12px; border-radius: 999px;
  background: rgba(201,162,39,.12); border: 1px dashed rgba(201,162,39,.5); color: var(--gold);
  font-size: .82rem; letter-spacing: .04em; }

/* ===== 旅人任務的選項 ===== */
.choice.quest { border-color: rgba(201,162,39,.5); background: rgba(201,162,39,.07); }
.choice-odds.quest-tag { background: rgba(201,162,39,.16); color: var(--gold); }

/* ===== 成就徽章 ===== */
.stat-strip { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 14px; }
.stat-strip span { background: rgba(255,255,255,.04); border: 1px solid var(--line); border-radius: 999px;
  padding: 4px 11px; font-size: .8rem; color: var(--muted); }
.stat-strip b { color: var(--gold); }
.ach-row { display: flex; align-items: center; gap: 10px; padding: 8px 2px; border-bottom: 1px solid var(--line); opacity: .55; }
.ach-row.got { opacity: 1; }
.ach-emoji { font-size: 1.3rem; flex: none; width: 26px; text-align: center; }
.ach-info { flex: 1; min-width: 0; }
.ach-name { color: #eaf1f8; font-weight: 600; }
.ach-row:not(.got) .ach-name { color: var(--muted); }
.ach-desc { color: var(--muted); font-size: .78rem; margin-top: 2px; }

/* ===== 結局路線圖 ===== */
.route-box { background: rgba(255,255,255,.03); border: 1px solid var(--line); border-radius: 12px; padding: 12px; margin-bottom: 14px; }
.route-head { color: #eaf1f8; font-weight: 600; margin-bottom: 10px; display: flex; justify-content: space-between; align-items: baseline; }
.route-head span { color: var(--muted); font-size: .8rem; font-weight: 400; }
.route-nodes { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }
.route-node { display: flex; align-items: center; gap: 6px; padding: 4px 8px; border-radius: 999px;
  background: rgba(255,255,255,.04); border: 1px solid var(--line); }
.route-node .rn-dot { width: 9px; height: 9px; border-radius: 50%; border: 1.5px solid var(--muted); flex: none; }
.route-node .rn-name { font-size: .82rem; }
.route-node .rn-kind { font-size: .7rem; color: var(--muted); }
.route-node.got { border-color: rgba(201,162,39,.4); }
.rn-line { width: 14px; height: 1px; background: var(--line); flex: none; }
.route-hint { color: var(--muted); font-size: .76rem; margin-top: 8px; }

/* ===== 第一次玩的引導 ===== */
.modal-box.intro-box { width: min(560px, 94vw); }
.intro-step { display: flex; gap: 12px; margin: 14px 0; }
.intro-step .is-n { flex: none; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center;
  background: rgba(212,175,55,.14); border: 1px solid rgba(212,175,55,.45); color: var(--gold); font-size: .82rem; }
.intro-step b { color: #eaf1f8; }
.intro-step p { margin: 4px 0 0; color: var(--muted); font-size: .85rem; line-height: 1.7; }
.intro-step kbd { font-family: inherit; border: 1px solid var(--line); border-radius: 4px; padding: 0 5px; font-size: .78rem; }
.intro-actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 20px; flex-wrap: wrap; }
.intro-again { color: var(--muted); font-size: .8rem; display: flex; align-items: center; gap: 6px; }

/* ===== 已經玩完的局 ===== */
.ended-row { margin: 10px 0 4px; }
.ended-item { display: flex; align-items: center; gap: 10px; padding: 10px 2px; border-bottom: 1px solid var(--line); }
.ended-item .ei-emoji { font-size: 1.3rem; flex: none; }
.ended-item .ei-main { flex: 1; min-width: 0; }
.ended-item .ei-title { color: #eaf1f8; font-weight: 600; }
.ended-item .ei-sub { color: var(--muted); font-size: .78rem; margin-top: 2px; }
.ended-item .ei-ending { font-size: .82rem; margin-top: 3px; }
.ended-item .btn-sm { padding: 5px 10px; font-size: .78rem; }

/* ===== 這一夜的回顧 ===== */
.modal-box.recap-box { width: min(760px, 94vw); max-height: 90vh; display: flex; flex-direction: column; }
.recap-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.recap-head h2 { margin: 0; }
.btn.btn-sm { padding: 6px 12px; font-size: .82rem; }
.recap-scroll { overflow-y: auto; margin-top: 14px; padding-right: 6px; }
.recap-meta { color: var(--muted); font-size: .84rem; letter-spacing: .04em; margin-bottom: 12px; }
.recap-ending { border: 1px solid var(--gold); border-radius: 10px; padding: 10px 14px; margin-bottom: 16px; display: flex; flex-direction: column; gap: 4px; background: rgba(212,175,55,.06); }
.recap-ending b { font-size: 1.05rem; }
.recap-ending span { color: var(--muted); font-size: .82rem; }
.recap-ending em { color: #cfd9e4; font-size: .8rem; font-style: normal; }
.recap-act { margin: 0 0 16px; }
.ra-head { font-weight: 700; letter-spacing: .1em; color: var(--gold); font-size: .84rem; border-bottom: 1px solid var(--line); padding-bottom: 5px; margin-bottom: 8px; }
.recap-beat { display: flex; gap: 10px; padding: 6px 0; border-bottom: 1px dashed rgba(255,255,255,.06); }
.recap-beat .rb-where { flex: none; width: 92px; color: var(--muted); font-size: .78rem; padding-top: 2px; }
.recap-beat .rb-body { flex: 1; min-width: 0; }
.recap-beat .rb-body b { font-weight: 600; color: #eaf1f8; }
.recap-beat .rb-text { color: #b8c2cd; font-size: .84rem; line-height: 1.7; margin-top: 3px; }
.recap-beat.free .rb-body b { color: #ffe9b8; }
.recap-block { margin: 18px 0; }
.recap-block .rb-title { font-weight: 700; color: #eaf1f8; border-bottom: 1px solid var(--line); padding-bottom: 5px; margin-bottom: 8px; }
.recap-line { color: #cfd9e4; font-size: .86rem; padding: 3px 0; }
.recap-chat { margin: 10px 0; }
.rc-head { color: #eaf1f8; font-weight: 600; font-size: .9rem; margin-bottom: 4px; }
.rc-head span { color: var(--muted); font-weight: 400; font-size: .78rem; margin-left: 8px; }
.rc-line { font-size: .84rem; line-height: 1.7; color: #b8c2cd; padding-left: 10px; border-left: 2px solid rgba(255,255,255,.1); margin: 3px 0; }
.rc-line.me { color: #d8ecff; border-left-color: rgba(140,200,255,.4); }

/* 世界地圖 */
.modal-box.map-box { width: min(1060px, 94vw); max-height: 90vh; display: flex; flex-direction: column; }
.map-meta { color: var(--muted); font-size: .86rem; margin: -4px 0 10px; letter-spacing: .03em; }
.map-scroll { overflow: auto; padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: rgba(255,255,255,.02); max-height: 60vh; }
.map-loading { padding: 34px; text-align: center; color: var(--muted); }
.map-node rect { fill: rgba(255,255,255,.04); stroke: var(--line); stroke-width: 1.5; }
.map-node .map-label { fill: #e9eef5; font-size: 13px; font-family: inherit; }
.map-node .map-night { fill: var(--accent, #d4af37); font-size: 10px; opacity: .9; font-family: inherit; }
.map-node.vis rect { fill: rgba(255,255,255,.09); stroke: rgba(255,255,255,.30); }
.map-node.cur rect { fill: rgba(212,175,55,.22); stroke: var(--accent, #d4af37); stroke-width: 2.6; }
.map-node.near rect { stroke-dasharray: 6 4; opacity: .85; }
.map-node.end rect { stroke: #c0392b; fill: rgba(192,57,43,.15); }
.map-node.iv rect { fill: rgba(201,162,39,.10); stroke: rgba(201,162,39,.55); stroke-dasharray: 5 4; }
.map-node.iv .map-label { fill: var(--gold, #c9a227); font-size: 12px; }
.map-edge { fill: none; stroke: rgba(255,255,255,.18); stroke-width: 2; }
.map-band { fill: #cfd9e4; font-size: 15px; font-weight: 700; font-family: inherit; letter-spacing: .08em; }
.map-band.sub { fill: var(--accent, #d4af37); font-size: 11px; font-weight: 400; }
.map-band-line { stroke: rgba(255,255,255,.10); stroke-width: 1; stroke-dasharray: 2 6; }
.map-legend { display: flex; gap: 16px; flex-wrap: wrap; margin-top: 10px; font-size: .8rem; color: var(--muted); }
.map-legend .lg { display: inline-block; width: 13px; height: 13px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; border: 1.5px solid var(--line); }
.map-legend .lg.cur { background: rgba(212,175,55,.3); border-color: #d4af37; }
.map-legend .lg.vis { background: rgba(255,255,255,.12); border-color: rgba(255,255,255,.4); }
.map-legend .lg.near { border-style: dashed; }
.map-legend .lg.end { background: rgba(192,57,43,.2); border-color: #c0392b; }
.map-node.sel rect { stroke: #fff; stroke-width: 2.6; }
.map-detail { margin-top: 12px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; background: rgba(255,255,255,.03); }
.map-detail .md-head { font-weight: 700; color: #eaf1f8; margin-bottom: 3px; }
.map-detail .md-sub { font-size: .78rem; color: var(--muted); margin-bottom: 8px; }
.map-detail .md-text { font-size: .92rem; line-height: 1.7; color: #dbe5ee; }

/* 彩蛋選項 */
.choice.egg { border-color: rgba(140,200,255,.5); background: linear-gradient(90deg, rgba(140,200,255,.06), transparent); }
.choice.egg .choice-label { color: #d8ecff; }
.odds-good.egg-tag, .egg-tag { background: rgba(140,200,255,.16); color: #bfe0ff; border: 1px solid rgba(140,200,255,.4); }

/* 觀察類／AI 接續類選項，視覺上做區隔 */
.choice.flavor { opacity: .92; }
.choice.flavor .choice-label { font-style: italic; }
.choice.dynamic { border-color: rgba(212,175,55,.55); }

/* 多夜／時間軸：夜數徽章 */
.night-badge {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  margin: 0 0 10px; padding: 7px 10px; border-radius: 10px;
  background: linear-gradient(90deg, rgba(40,60,90,.55), rgba(20,30,45,.25));
  border: 1px solid var(--line); color: var(--ink); font-size: .86rem; letter-spacing: .04em;
}
.night-badge .night-dots { display: inline-flex; gap: 4px; margin-left: auto; }
.night-badge .night-dots i { width: 8px; height: 8px; border-radius: 50%; background: rgba(255,255,255,.16); display: block; }
.night-badge .night-dots i.on { background: var(--accent, #d4af37); box-shadow: 0 0 8px var(--accent, #d4af37); }

/* 存檔清單：匯出／刪除 */
.chip-export, .chip-del {
  position: absolute; top: -8px; z-index: 2;
  width: 24px; height: 24px; border-radius: 50%; line-height: 1;
  background: rgba(10,8,8,.95); border: 1px solid var(--line); color: var(--muted);
  font-size: .78rem; display: grid; place-items: center;
}
.chip-export { right: 18px; }
.chip-del { right: -8px; }
.chip-export:hover { border-color: var(--accent, #d4af37); color: #ffe9b8; }

/* 匯入存檔 */
.import-row { margin-top: 12px; }
.import-row .link-btn { font-size: .82rem; }

/* 結局收藏 */
.modal-box.endings-box { width: min(720px, 92vw); }
.ending-group { margin: 14px 0 18px; }
.ending-group .eg-head { display: flex; justify-content: space-between; font-weight: 700; color: #eaf1f8; border-bottom: 1px solid var(--line); padding-bottom: 6px; }
.ending-group .eg-head span { color: var(--muted); font-weight: 400; font-size: .82rem; }
.ending-group .eg-sub { margin: 10px 0 2px; font-size: .82rem; font-weight: 700; color: #c9a227; letter-spacing: .06em; }
.ending-row { display: flex; align-items: center; gap: 9px; padding: 6px 2px; opacity: .55; }
.ending-row.got { opacity: 1; }
.ending-row .er-dot { width: 10px; height: 10px; border-radius: 50%; border: 1px solid var(--line); flex: none; }
.ending-row .er-title { flex: 1; }
.ending-row .er-kind { font-size: .76rem; color: var(--muted); }

/* 能力按鈕 */
.btn.ability-btn { border-color: var(--accent, #d4af37); color: #ffe9b8; }

/* 存檔清單 */
.resume-chip { position: relative; display: inline-flex; }
.chip-del:hover { border-color: #c0392b; color: #ffb0a2; }

/* 不在場的角色（場景卡：這一格沒有他） */
.bond-here { font-size: .72rem; color: var(--muted); opacity: .6; padding: 4px 8px; white-space: nowrap; }
