:root {
  --bg: #0d0d0f; --bg2: #141417; --bg3: #1a1a1f; --bg4: #202028;
  --gold: #c9922a; --gold-lt: #e8b84b;
  --red: #c94040;     --red-pale: #c9404020;     --red-text: #f08080;
  --amber: #b87820;   --amber-pale: #b8782018;   --amber-text: #e8c060;
  --blue: #3a7abf;    --blue-pale: #3a7abf18;    --blue-text: #78b0e8;
  --teal: #1e8a6e;    --teal-pale: #1e8a6e18;    --teal-text: #5cc8a8;
  --coral: #b85230;   --coral-pale: #b8523018;   --coral-text: #e89080;
  --green: #3a7a3a;   --green-pale: #3a7a3a18;   --green-text: #7ab87a;
  --purple: #7060c0;  --purple-pale: #7060c020;  --purple-text: #b0a0f0;
  --gray-pale: #ffffff06;
  --text: #e8e4d8; --text2: #a8a49a; --border: #2a2a32;
}
* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--bg); color: var(--text);
  font-family: 'Noto Sans TC', sans-serif;
  font-size: 14px; line-height: 1.7; min-height: 100vh;
}

/* ── Hero ── */
.hero {
  background: linear-gradient(160deg, #1a1208 0%, #0d0d0f 60%);
  border-bottom: 1px solid var(--gold);
  padding: 36px 32px 28px; position: relative; overflow: hidden;
}
.hero::before {
  content: ''; position: absolute; top: -60px; right: -80px;
  width: 320px; height: 320px;
  background: radial-gradient(circle, #c9922a18 0%, transparent 70%);
  pointer-events: none;
}
.hero-label { font-size: 11px; letter-spacing: 3px; color: var(--gold); text-transform: uppercase; margin-bottom: 8px; }
.hero h1 { font-family: 'Noto Serif TC', serif; font-size: 28px; font-weight: 700; color: var(--gold-lt); line-height: 1.2; }
.hero h1 small { color: var(--text2); font-size: 16px; font-weight: 400; margin-left: 10px; }
.hero-sub { color: var(--text2); font-size: 13px; margin-top: 8px; }

/* ── Nav ── */
.nav {
  display: flex; gap: 0; border-bottom: 1px solid var(--border);
  background: var(--bg2); overflow-x: auto;
  position: sticky; top: 0; z-index: 100;
}
.nav button {
  background: none; border: none; color: var(--text2);
  padding: 12px 20px; font-size: 13px; font-family: inherit;
  cursor: pointer; white-space: nowrap;
  border-bottom: 2px solid transparent; transition: all .15s;
}
.nav button:hover { color: var(--text); }
.nav button.active { color: var(--gold-lt); border-bottom-color: var(--gold); }

/* ── Layout ── */
.section { display: none; padding: 24px 28px; max-width: 880px; margin: 0 auto; }
.section.active { display: block; }
.sec-title {
  font-family: 'Noto Serif TC', serif;
  font-size: 18px; color: var(--gold-lt);
  border-left: 3px solid var(--gold); padding-left: 12px; margin-bottom: 20px;
}
.subsec-title {
  font-size: 14px; font-weight: 700; color: var(--gold);
  margin: 22px 0 10px; display: flex; align-items: center; gap: 8px;
}
.subsec-title::after { content: ''; flex: 1; height: 1px; background: var(--border); }

/* ── Skill chip ── */
.skill { color: var(--gold-lt); border-bottom: 1px dashed #c9922a55; cursor: help; padding-bottom: 1px; }
.skill:hover { border-bottom-color: var(--gold); }
.skill-missing { color: var(--red-text); border-bottom-color: var(--red); background: var(--red-pale); padding: 0 4px; border-radius: 3px; }

/* ── Role chip ── */
.role { display: inline-block; padding: 1px 8px; border-radius: 4px; font-size: 12px; font-weight: 500; white-space: nowrap; }
.role-blue   { background: var(--blue-pale);   color: var(--blue-text);   border: 1px solid #3a7abf44; }
.role-teal   { background: var(--teal-pale);   color: var(--teal-text);   border: 1px solid #1e8a6e44; }
.role-coral  { background: var(--coral-pale);  color: var(--coral-text);  border: 1px solid #b8523044; }
.role-purple { background: var(--purple-pale); color: var(--purple-text); border: 1px solid #7060c044; }
.role-red    { background: var(--red-pale);    color: var(--red-text);    border: 1px solid #c9404044; }

/* ── Party box ── */
.party-box { background: var(--bg3); border: 1px solid var(--border); border-radius: 8px; padding: 14px 18px; margin-bottom: 10px; }
.party-box .label { color: var(--text2); font-size: 12px; margin-bottom: 6px; }
.party-row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 13px; }
.party-row .sep { color: var(--text2); }

/* ── Tables ── */
table { width: 100%; border-collapse: collapse; margin: 10px 0; font-size: 13px; }
th { background: var(--bg4); color: var(--gold); font-weight: 500; padding: 8px 12px; text-align: left; border-bottom: 1px solid var(--border); }
td { padding: 8px 12px; border-bottom: 1px solid var(--border); color: var(--text2); }
tr:last-child td { border-bottom: none; }
td:first-child { color: var(--text); font-weight: 500; }
tr:hover td { background: var(--gray-pale); }

/* ── Mech cards ── */
.mech-card { border-radius: 8px; border: 1px solid var(--border); padding: 14px 16px; margin-bottom: 10px; }
.mech-card.fatal { border-left: 3px solid var(--red); background: var(--red-pale); }
.mech-card.warn  { border-left: 3px solid var(--amber); background: var(--amber-pale); }
.mech-card.note  { border-left: 3px solid var(--blue); background: var(--blue-pale); }
.mech-title { font-weight: 700; font-size: 13px; margin-bottom: 6px; }
.mech-title.fatal { color: var(--red-text); }
.mech-title.warn  { color: var(--amber-text); }
.mech-title.note  { color: var(--blue-text); }
.mech-body { font-size: 13px; color: var(--text2); }
.mech-body ul { list-style: none; padding: 0; margin: 6px 0 0; }
.mech-body li { padding: 2px 0 2px 14px; position: relative; }
.mech-body li::before { content: '▸'; position: absolute; left: 0; color: var(--gold); }
.mech-body .resp { color: var(--teal-text); }

/* ── Alt strat ── */
.alt-strat { background: #3a7abf0c; border: 1px solid #3a7abf30; border-radius: 6px; padding: 10px 14px; margin-top: 8px; font-size: 12px; color: var(--text2); }
.alt-strat strong { color: var(--blue-text); }

/* ── Wave header ── */
.wave-header {
  font-family: 'Noto Serif TC', serif;
  font-size: 15px; color: var(--gold-lt);
  padding: 10px 14px; background: var(--bg3);
  border: 1px solid var(--border); border-radius: 6px;
  margin: 18px 0 10px; display: flex; align-items: center; gap: 10px;
}
.wave-hp { font-size: 12px; color: var(--text2); font-family: 'Noto Sans TC', sans-serif; }

/* ── Flow table ── */
.flow-container { background: var(--bg2); border: 1px solid var(--border); border-radius: 8px; overflow: hidden; margin-bottom: 20px; }
.flow-header { background: var(--bg4); padding: 10px 16px; font-size: 13px; font-weight: 500; color: var(--gold); border-bottom: 1px solid var(--border); }
.flow-inner { display: grid; grid-template-columns: 1fr 1fr; gap: 0; }
.flow-col-head {
  padding: 8px 14px; font-size: 11px; font-weight: 500;
  background: var(--bg3); color: var(--text2);
  border-bottom: 1px solid var(--border);
  letter-spacing: 1px; text-transform: uppercase;
}
.flow-col-head:first-child { border-right: 1px solid var(--border); }

.flow-cell { padding: 9px 14px; border-bottom: 1px solid var(--border); font-size: 13px; line-height: 1.5; }
.flow-cell:first-child { border-right: 1px solid var(--border); }
.flow-cell .note { font-size: 11px; color: var(--text2); display: block; margin-top: 2px; }
.flow-cell.fatal  { background: var(--red-pale);    color: var(--red-text); }
.flow-cell.warn   { background: var(--amber-pale);  color: var(--amber-text); }
.flow-cell.green  { background: var(--green-pale);  color: var(--green-text); }
.flow-cell.blue   { background: var(--blue-pale);   color: var(--blue-text); }
.flow-cell.coral  { background: var(--coral-pale);  color: var(--coral-text); }
.flow-cell.teal   { background: var(--teal-pale);   color: var(--teal-text); }
.flow-cell.gray   { background: var(--gray-pale);   color: var(--text2); }
.flow-cell.purple { background: var(--purple-pale); color: var(--purple-text); }

/* ── 全欄 span 系列 ── */
.flow-cell.span2 { grid-column: 1 / -1; background: var(--purple-pale); color: var(--purple-text); font-weight: 500; text-align: center; font-size: 12px; border-right: none !important; }
.flow-cell.span2-mob { grid-column: 1 / -1; background: var(--green-pale); color: var(--green-text); border-right: none !important; }
.flow-cell.span2-danger { grid-column: 1 / -1; background: var(--red-pale); color: var(--red-text); text-align: center; font-weight: 500; font-size: 12px; border-right: none !important; }
.flow-cell.span2-info { grid-column: 1 / -1; background: var(--teal-pale); color: var(--teal-text); font-size: 12px; text-align: center; border-right: none !important; }
.flow-cell.span2-loop { grid-column: 1 / -1; background: var(--gray-pale); color: var(--text2); font-size: 11px; text-align: center; border-right: none !important; padding: 7px 14px; }

/* ════════════════════════════════════════ */
/* ── Branch 分支（新增） ───────────────── */
/* ════════════════════════════════════════ */

/* 橫跨全欄的「隨機分支」標頭 */
.flow-cell.branch-header {
  grid-column: 1 / -1; border-right: none !important;
  background: #7060c018; color: var(--purple-text);
  font-size: 11px; text-align: center;
  padding: 5px 14px; letter-spacing: 1px; font-weight: 500;
  border-top: 1px dashed #7060c044;
}

/* 分支 key 標籤 */
.branch-key { display: inline-block; font-weight: 700; margin-right: 8px; font-size: 12px; }
.branch-key-amber { color: var(--amber-text); }
.branch-key-blue  { color: var(--blue-text); }
.branch-key-teal  { color: var(--teal-text); }
.branch-key-coral { color: var(--coral-text); }

/* 子分支 ①② */
.sub-branch-group { display: inline; }
.sub-branch { display: inline; }
.sub-idx {
  display: inline-flex; align-items: center; justify-content: center;
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--bg4); color: var(--text2);
  font-size: 10px; font-weight: 700; line-height: 1;
  margin: 0 3px; vertical-align: middle;
  border: 1px solid var(--border);
}
.sub-sep { color: var(--text2); margin: 0 2px; opacity: .6; }

/* ── Ref table ── */
.ref-table { font-size: 12px; }
.ref-table th { font-size: 11px; }
.ref-table td { color: var(--text2); }
.ref-table td:first-child { color: var(--blue-text); font-family: monospace; font-size: 12px; }
.ref-table td:nth-child(2) { color: var(--text); }

/* ── Job block ── */
.job-block { margin-bottom: 22px; }
.job-config { background: var(--bg3); border: 1px solid var(--border); border-radius: 8px; padding: 12px 16px; margin: 8px 0; font-size: 13px; color: var(--text2); }
.job-config .label { font-size: 11px; color: var(--gold); font-weight: 500; letter-spacing: 2px; text-transform: uppercase; margin-bottom: 4px; }

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ── Mobile ── */
@media (max-width: 600px) {
  .hero { padding: 24px 16px 18px; }
  .section { padding: 16px; }
  .flow-inner { grid-template-columns: 1fr; }
  .flow-cell:first-child { border-right: none; border-bottom: 1px solid #ffffff18; }
  .flow-cell.span2, .flow-cell.span2-mob,
  .flow-cell.span2-danger, .flow-cell.span2-info,
  .flow-cell.span2-loop, .flow-cell.branch-header { grid-column: 1; }
}

/* ── 序列垂直展開 (→ 變 ↓) ── */
.seq-arrow {
  display: block;
  color: var(--text2);
  font-size: 10px;
  line-height: 1.4;
  opacity: 0.55;
  margin: 1px 0;
  user-select: none;
}

/* ── Prep 預備應對列 ────────────────────────── */
.flow-cell.prep-marker {
  background: var(--teal-pale);
  color: var(--teal-text);
  font-size: 11px;
  font-style: italic;
  border-left: 3px solid var(--teal);
  letter-spacing: 0.5px;
}
.flow-cell.prep-resp {
  background: var(--teal-pale);
  color: var(--text);
  font-size: 12.5px;
}

/* ── Boss / 小怪名稱 chip ── */
.boss { color: var(--text); font-weight: 500; cursor: help; border-bottom: 1px dotted #a8a49a55; padding-bottom: 1px; }
.boss:hover { border-bottom-color: var(--gold-lt); color: var(--gold-lt); }
.boss-missing { color: var(--red-text); border: 1px dashed var(--red); padding: 0 4px; border-radius: 3px; background: var(--red-pale); }