/* 缄默之王 · 跑团桌 —— 黑暗奇幻主题 */
:root {
  --bg: #100e0b;
  --bg-2: #17130f;
  --panel: #1b1712;
  --panel-2: #221d17;
  --line: #372d23;
  --line-soft: #29221b;
  --text: #e8ddc9;
  --text-dim: #c3b39a;
  --muted: #9b8b74;
  --dim: #6f6353;
  --gold: #d9b26a;
  --gold-dim: #9a7c42;
  --ember: #d0763f;
  --blood: #b4554a;
  --green: #7fa86a;
  --blue: #8fb0d0;
  --violet: #a48ec9;
  --radius: 12px;
  --ui: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", "PingFang SC", sans-serif;
  --serif: "Noto Serif SC", "Source Han Serif SC", "Songti SC", "SimSun", Georgia, serif;
  --mono: "Cascadia Mono", "Consolas", "SF Mono", monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
}

body {
  background:
    radial-gradient(1100px 520px at 50% -12%, #2a2118 0%, rgba(42, 33, 24, 0) 62%),
    radial-gradient(700px 420px at 88% 8%, rgba(93, 62, 34, 0.22), transparent 70%),
    var(--bg);
  color: var(--text);
  font-family: var(--ui);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

@media (max-width: 1000px) {
  body { overflow: auto; }
}

.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.spacer { flex: 1; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.row > .btn { flex: 1 1 auto; min-width: max-content; }
/* 1.0.0：按钮文字不许溢出边框（放不下就换行，不缩到比文字还窄） */
.row > .btn, .row > label.btn { max-width: 100%; }

/* ---------- 按钮 / 表单 ---------- */
.btn {
  appearance: none;
  border: 1px solid var(--line);
  background: linear-gradient(#241e17, #1d1812);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  padding: 9px 14px;
  border-radius: 9px;
  cursor: pointer;
  transition: border-color .15s, background .15s, transform .06s, color .15s;
  white-space: nowrap;
}
.btn:hover { border-color: var(--gold-dim); color: #fff2d8; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary {
  background: linear-gradient(#5c4526, #3c2d18);
  border-color: #7b5f33;
  color: #ffe9c2;
  font-weight: 600;
}
.btn.primary:hover { background: linear-gradient(#6d5230, #47351d); }
.btn.ghost { background: rgba(255, 255, 255, .02); }
.btn.danger { border-color: #5a2f2a; color: #e2a89f; background: rgba(122, 52, 44, .14); }
.btn.danger:hover { border-color: var(--blood); color: #ffd6cf; }
.btn.wide { width: 100%; }
.btn.small { font-size: 12px; padding: 5px 9px; border-radius: 7px; }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field > span { font-size: 12.5px; color: var(--muted); letter-spacing: .04em; }
.field > span em { font-style: normal; color: var(--dim); }
.field.compact { margin-bottom: 10px; }
input[type="text"], input[type="number"], input:not([type]), select, textarea {
  font: inherit;
  color: var(--text);
  background: #0e0c09;
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 10px 12px;
  width: 100%;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--gold-dim);
  box-shadow: 0 0 0 3px rgba(217, 178, 106, .1);
}
select { cursor: pointer; }
textarea { resize: vertical; min-height: 44px; }
.check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
}
.check input { accent-color: var(--gold-dim); width: 14px; height: 14px; }
.error { color: #e2917f; font-size: 13px; min-height: 18px; margin: 6px 0 0; }

/* ---------- 加入屏 ---------- */
.join-screen {
  height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
  overflow: auto;
}
.join-card {
  width: min(440px, 100%);
  background: linear-gradient(170deg, #201a14, #16120e);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 34px 30px 26px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, .55), inset 0 1px 0 rgba(255, 235, 200, .06);
  text-align: center;
}
.sigil {
  font-size: 34px;
  line-height: 1;
  color: var(--gold);
  text-shadow: 0 0 26px rgba(217, 178, 106, .45);
}
.sigil.small { font-size: 17px; text-shadow: none; }
.join-card h1 {
  font-family: var(--serif);
  font-size: 30px;
  letter-spacing: .22em;
  margin: 14px 0 8px;
  font-weight: 600;
  text-indent: .22em;
  color: #f0e2c7;
}
.join-card .sub { color: var(--muted); font-size: 13.5px; margin: 0 0 24px; }
.join-card form { text-align: left; }
.join-card .field > span { letter-spacing: .02em; }
.join-card .btn.primary { margin-top: 4px; padding: 12px; font-size: 15px; letter-spacing: .08em; }
.hint { color: var(--dim); font-size: 12px; line-height: 1.7; margin: 16px 0 0; text-align: center; }

/* ---------- 顶栏 ---------- */
.app { height: 100dvh; display: flex; flex-direction: column; }
.topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 18px;
  border-bottom: 1px solid var(--line-soft);
  background: rgba(18, 15, 11, .86);
  backdrop-filter: blur(10px);
  flex: 0 0 auto;
  z-index: 5;
}
.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--serif);
  font-size: 16.5px;
  letter-spacing: .12em;
  color: #f0e2c7;
  white-space: nowrap;
}
.meta-pills { display: flex; gap: 6px; flex-wrap: wrap; }
.pill {
  font-size: 11.5px;
  color: var(--text-dim);
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, .02);
  padding: 3px 9px;
  border-radius: 999px;
  white-space: nowrap;
}
.pill.mode { color: #d9c48d; border-color: #4a3b22; background: rgba(217, 178, 106, .08); }
.pill.cut { color: #f0c98a; border-color: #7a5a2e; background: rgba(230, 168, 96, .16); cursor: pointer; }
.pill.cut:hover { background: rgba(230, 168, 96, .28); }
.top-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.online { display: flex; gap: -6px; align-items: center; }
.avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 700;
  color: #14100b;
  border: 2px solid #14110d;
  margin-left: -6px;
}
.avatar:first-child { margin-left: 0; }
.avatar.kp { box-shadow: 0 0 0 1px rgba(217, 178, 106, .7); }
.conn {
  font-size: 11.5px;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--muted);
  white-space: nowrap;
}
.conn.on { color: var(--green); border-color: #37502c; background: rgba(127, 168, 106, .08); }
.conn.off { color: #d19a8f; border-color: #57332c; }

/* ---------- 布局 ---------- */
.layout {
  flex: 1 1 auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 416px;
  min-height: 0;
}
.board {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  position: relative;
  border-right: 1px solid var(--line-soft);
}

/* 地图做对话框背景：压到很淡，只留一层地形纹理，不抢字 */
.board::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: url("map.jpg?v=1101c");
  background-size: cover;
  background-position: center 42%;
  background-repeat: no-repeat;
  opacity: .17;
  filter: saturate(.75) contrast(.85);
  pointer-events: none;
  z-index: 0;
}
.board::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(115% 75% at 50% 38%, rgba(16, 14, 11, .42) 0%, rgba(16, 14, 11, .86) 68%, rgba(16, 14, 11, .97) 100%),
    linear-gradient(180deg, rgba(16, 14, 11, .55) 0%, rgba(16, 14, 11, 0) 22%, rgba(16, 14, 11, 0) 74%, rgba(16, 14, 11, .75) 100%);
  pointer-events: none;
  z-index: 0;
}
.board > * { position: relative; z-index: 1; }
@media (max-width: 1000px) {
  .board::before { background-position: center 30%; opacity: .13; }
}

/* ---------- 日志 ---------- */
.log {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 26px 26px 12px;
  scroll-behavior: smooth;
  scrollbar-width: thin;
  scrollbar-color: #3b3125 transparent;
}
.log::-webkit-scrollbar { width: 10px; }
.log::-webkit-scrollbar-thumb { background: #332a20; border-radius: 10px; border: 2px solid transparent; background-clip: padding-box; }
.log-empty {
  max-width: 560px;
  margin: 8vh auto;
  text-align: center;
  color: var(--dim);
  font-family: var(--serif);
  line-height: 2;
}
.log-empty strong { display: block; color: var(--gold); font-size: 20px; letter-spacing: .3em; margin-bottom: 10px; text-indent: .3em; }

.msg {
  max-width: 800px;
  margin: 0 auto 16px;
  animation: rise .22s ease-out;
}
@keyframes rise { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: none; } }

.msg-head {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 5px;
  font-size: 12.5px;
}
.msg-head .who { font-weight: 700; letter-spacing: .04em; }
.msg-head .tag {
  font-size: 10.5px;
  color: var(--dim);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 0 4px;
  line-height: 1.5;
}
.msg-head .time { color: var(--dim); font-size: 11px; font-variant-numeric: tabular-nums; margin-left: auto; }
.msg-body {
  font-family: var(--serif);
  font-size: 16px;
  line-height: 1.95;
  color: var(--text);
  overflow-wrap: anywhere;
}
.msg-body p { margin: 0 0 .72em; }
.msg-body p:last-child { margin-bottom: 0; }
.msg-body em { color: #cbb98f; font-style: italic; }
.msg-body strong { color: #fff1d4; font-weight: 700; }

/* KP 旁白：无气泡，左侧金线 */
.msg-kp { padding: 2px 0 2px 18px; border-left: 2px solid rgba(217, 178, 106, .38); }
.msg-kp .msg-head .who { color: var(--gold); }
.msg-kp .msg-body { color: #efe4cf; }

/* 玩家：气泡 */
.msg-player, .msg-ooc, .msg-whisper, .msg-agent {
  background: linear-gradient(180deg, rgba(38, 31, 24, .9), rgba(28, 23, 18, .9));
  border: 1px solid var(--line-soft);
  border-radius: 12px;
  padding: 10px 14px;
}
.msg-player .msg-body { font-family: var(--ui); font-size: 14.5px; line-height: 1.8; color: #ded2bd; }
.msg-player .msg-body p { margin: 0 0 .4em; }
.msg-ooc { background: transparent; border-style: dashed; }
.msg-ooc .msg-body { font-family: var(--ui); font-size: 13.5px; color: var(--muted); }
.msg-ooc .msg-head .who { color: var(--muted); font-weight: 500; }
.msg-whisper { border-color: #4a3a55; background: rgba(60, 45, 74, .16); }
.msg-whisper .msg-body { font-family: var(--ui); font-size: 14px; color: #cbb9d6; }
.msg-agent { border-color: #3f4a55; }
.msg-agent .msg-body { font-family: var(--ui); font-size: 14.5px; }

.msg-dice {
  background: #15110d;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 9px 14px;
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  font-family: var(--mono);
  max-width: 800px;
}
.msg-dice .dice-who { font-size: 12px; color: var(--muted); font-family: var(--ui); }
.msg-dice .dice-total {
  font-size: 24px;
  font-weight: 700;
  color: var(--gold);
  font-variant-numeric: tabular-nums;
  line-height: 1;
}
.msg-dice .dice-detail { font-size: 12.5px; color: var(--text-dim); flex: 1 1 200px; }
.msg-dice .dice-label { font-size: 12px; color: var(--muted); font-family: var(--ui); }
.msg-dice .verdict {
  font-size: 11px;
  font-family: var(--ui);
  padding: 2px 7px;
  border-radius: 999px;
  border: 1px solid var(--line);
}
.verdict.crit { color: #ffe08a; border-color: #7a6224; background: rgba(255, 224, 138, .1); }
.verdict.success { color: #b6d49e; border-color: #37502c; }
.verdict.fail { color: #d8a49a; border-color: #57332c; }
.verdict.critfail { color: #ff9b8a; border-color: #7a2f24; background: rgba(180, 85, 74, .16); }

.msg-system { text-align: center; color: var(--dim); font-size: 12px; font-family: var(--ui); }
.msg-system span {
  display: inline-block;
  padding: 2px 12px;
  border-top: 1px solid var(--line-soft);
  border-bottom: 1px solid var(--line-soft);
}

/* 流式气泡 */
.msg-live .msg-body { color: #f4e9d4; }
.msg-live .msg-body::after {
  content: "";
  display: inline-block;
  width: 7px;
  height: 15px;
  margin-left: 2px;
  background: var(--gold);
  vertical-align: -2px;
  animation: blink 1s steps(2) infinite;
}
@keyframes blink { 50% { opacity: 0; } }

.typing {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 26px 8px;
  color: var(--muted);
  font-size: 12.5px;
}
.typing .dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 10px rgba(217, 178, 106, .8);
  animation: pulse 1.1s ease-in-out infinite;
}
@keyframes pulse { 50% { opacity: .25; transform: scale(.8); } }

/* ---------- 输入区 ---------- */
.composer {
  flex: 0 0 auto;
  padding: 10px 26px 18px;
  background: linear-gradient(rgba(16, 14, 11, 0), rgba(16, 14, 11, .96) 40%);
}
.composer textarea {
  background: #13100c;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 11px 14px;
  font-family: var(--ui);
  font-size: 14.5px;
  line-height: 1.65;
  max-height: 210px;
  resize: none;
}
.composer-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 2px 0;
  flex-wrap: wrap;
}

/* ---------- 右侧栏 ---------- */
.side {
  overflow-y: auto;
  padding: 16px 16px 28px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: linear-gradient(180deg, rgba(24, 20, 15, .55), rgba(16, 14, 11, .2));
  scrollbar-width: thin;
  scrollbar-color: #332a20 transparent;
}
.panel {
  background: linear-gradient(175deg, rgba(35, 29, 23, .92), rgba(24, 20, 16, .92));
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  padding: 12px 13px 13px;
  box-shadow: inset 0 1px 0 rgba(255, 236, 200, .04);
}
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.panel-head h2 {
  margin: 0;
  font-family: var(--serif);
  font-size: 13.5px;
  font-weight: 600;
  letter-spacing: .18em;
  color: var(--gold);
  text-indent: .18em;
}
.panel-head .muted { font-size: 11.5px; }

/* 角色卡 */
.party { display: flex; flex-direction: column; gap: 9px; }
.pcard {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 9px 10px;
  background: #14110d;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.pcard:hover { border-color: var(--gold-dim); background: #181410; }
.pcard.mine { border-color: #6b5529; box-shadow: 0 0 0 1px rgba(217, 178, 106, .18); }
.pcard.dead { opacity: .55; }
.pcard-head { display: flex; align-items: center; gap: 8px; margin-bottom: 7px; }
.swatch { width: 8px; height: 26px; border-radius: 3px; flex: 0 0 auto; box-shadow: 0 0 10px currentColor; }
.pcard-name { min-width: 0; flex: 1 1 auto; }
.pcard-name strong { display: block; font-size: 13.5px; color: #f1e5cd; font-weight: 600; letter-spacing: .02em; }
.pcard-name span { display: block; font-size: 11px; color: var(--dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pcard-owner { font-size: 10.5px; color: var(--muted); white-space: nowrap; max-width: 84px; overflow: hidden; text-overflow: ellipsis; }
.pcard-owner.empty { color: var(--dim); font-style: italic; }

.bar {
  position: relative;
  height: 15px;
  border-radius: 5px;
  background: #0c0a08;
  border: 1px solid var(--line-soft);
  overflow: hidden;
  margin-bottom: 4px;
}
.bar i { position: absolute; inset: 0 auto 0 0; display: block; transition: width .3s; }
.bar span {
  position: relative;
  display: block;
  font-size: 10px;
  line-height: 13px;
  text-align: center;
  color: #f3e8d3;
  font-family: var(--mono);
  text-shadow: 0 1px 2px #000;
}
.bar.hp i { background: linear-gradient(90deg, #7e2f26, #b4554a); }
.bar.mp i { background: linear-gradient(90deg, #2b4668, #5b86b5); }
.bar.hp.low i { background: linear-gradient(90deg, #a33124, #e0664f); }
.pcard-chips { display: flex; gap: 5px; flex-wrap: wrap; margin-top: 6px; }
.pcard-chips span {
  font-size: 10.5px;
  color: var(--muted);
  border: 1px solid var(--line-soft);
  border-radius: 5px;
  padding: 0 5px;
  line-height: 1.6;
}
.pcard-chips span.warn { color: #e0b26a; border-color: #5a4322; }
.pcard-actions { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.pcard-actions .btn { flex: 1 1 auto; min-width: max-content; font-size: 11.5px; padding: 4px 9px; }

/* 骰子 */
.quick-dice { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-bottom: 8px; }
.quick-dice button {
  font-family: var(--mono);
  font-size: 12.5px;
  padding: 8px 4px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #14110d;
  color: var(--text-dim);
  cursor: pointer;
  transition: border-color .15s, color .15s, background .15s;
}
.quick-dice button:hover { border-color: var(--gold-dim); color: #ffe9c2; background: #1c1710; }

/* DSH 令牌 */
.dsh-box { margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--line); }
.token-row { display: flex; align-items: center; gap: 6px; margin-top: 5px; }
.token-row code {
  flex: 1 1 auto;
  min-width: 0;
  font-family: var(--mono);
  font-size: 11px;
  color: #b9a887;
  background: #0c0a08;
  border: 1px solid var(--line-soft);
  border-radius: 6px;
  padding: 5px 7px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
#usage { margin-top: 8px; line-height: 1.6; }

.kv { list-style: none; margin: 0 0 10px; padding: 0; display: flex; flex-direction: column; gap: 5px; }
.kv li { display: flex; justify-content: space-between; gap: 10px; font-size: 12.5px; color: var(--muted); }
.kv li b { color: var(--text-dim); font-weight: 500; text-align: right; overflow-wrap: anywhere; }

/* ---------- 对话框 ---------- */
.dialog {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: linear-gradient(170deg, #221c16, #16120e);
  color: var(--text);
  padding: 0;
  width: min(620px, calc(100vw - 24px));
  max-height: min(86dvh, 900px);
  box-shadow: 0 40px 100px rgba(0, 0, 0, .7);
  overflow: hidden;
}
.dialog::backdrop { background: rgba(5, 4, 3, .72); backdrop-filter: blur(3px); }
.dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 15px 18px;
  border-bottom: 1px solid var(--line-soft);
  position: sticky;
  top: 0;
  background: #1e1913;
  z-index: 2;
}
.dialog-head h2 {
  margin: 0;
  font-family: var(--serif);
  font-size: 17px;
  font-weight: 600;
  letter-spacing: .1em;
  color: #f1e5cd;
}
.icon-btn {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  width: 30px;
  height: 30px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  flex: 0 0 auto;
}
.icon-btn:hover { color: #fff; border-color: var(--gold-dim); }
.dialog-body { padding: 16px 18px 20px; overflow-y: auto; max-height: calc(86dvh - 60px); }

.char-title { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.char-title .swatch { height: 38px; width: 10px; }
.char-title h3 { margin: 0; font-family: var(--serif); font-size: 20px; letter-spacing: .05em; }
.char-title p { margin: 1px 0 0; color: var(--muted); font-size: 12.5px; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(86px, 1fr)); gap: 7px; margin-bottom: 14px; }
.stat {
  background: #14110d;
  border: 1px solid var(--line-soft);
  border-radius: 9px;
  padding: 7px 9px;
  text-align: center;
}
.stat b { display: block; font-size: 17px; color: #f0e3c8; font-variant-numeric: tabular-nums; }
.stat span { font-size: 11px; color: var(--muted); letter-spacing: .1em; }

.sec-title {
  font-size: 12px;
  letter-spacing: .16em;
  color: var(--gold);
  margin: 16px 0 7px;
  padding-bottom: 5px;
  border-bottom: 1px solid var(--line-soft);
}
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
table.tbl th, table.tbl td { text-align: left; padding: 5px 6px; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
table.tbl th { color: var(--muted); font-weight: 500; font-size: 11.5px; letter-spacing: .06em; }
table.tbl td.num { font-family: var(--mono); color: var(--gold); white-space: nowrap; }
.tags { display: flex; gap: 6px; flex-wrap: wrap; }
.tag-item {
  font-size: 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px 9px;
  color: var(--text-dim);
  background: rgba(255, 255, 255, .02);
}
.note-text { font-family: var(--serif); line-height: 1.9; color: var(--text-dim); white-space: pre-wrap; }

.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(128px, 1fr)); gap: 10px; }
.form-grid .field { margin-bottom: 0; }
.dialog-actions { display: flex; gap: 8px; margin-top: 18px; flex-wrap: wrap; }
.dialog-actions .btn { flex: 1 1 auto; }
.dialog-actions .btn.primary { flex: 2 1 auto; }

.state-row { display: grid; grid-template-columns: 1fr 1.15fr 30px; gap: 7px; margin-bottom: 7px; align-items: center; }
.state-row input { padding: 7px 9px; font-size: 13px; }
.state-row .icon-btn { width: 30px; height: 30px; }

.gear-row { display: grid; grid-template-columns: 62px 1.1fr 1.3fr 58px 30px; gap: 6px; margin-bottom: 7px; align-items: center; }
.gear-row input { padding: 7px 9px; font-size: 13px; min-width: 0; }
.gear-row .icon-btn { width: 30px; height: 30px; }
.btn.small { padding: 6px 12px; font-size: 12.5px; }
.map-img { display: block; width: 100%; border-radius: 10px; border: 1px solid var(--line); }
@media (max-width: 560px) {
  .gear-row { grid-template-columns: 50px 1fr 1.1fr 46px 28px; gap: 4px; }
  .gear-row input { padding: 6px; font-size: 12.5px; }
}

.dice-preview {
  font-family: var(--mono);
  font-size: 12.5px;
  color: var(--text-dim);
  background: #0e0c09;
  border: 1px dashed var(--line);
  border-radius: 9px;
  padding: 9px 11px;
  margin-top: 10px;
  line-height: 1.7;
}
.dice-preview b { color: var(--gold); }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translate(-50%, 16px);
  background: #2a221a;
  border: 1px solid var(--gold-dim);
  color: #ffe9c2;
  padding: 9px 16px;
  border-radius: 10px;
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
  z-index: 100;
  max-width: min(520px, calc(100vw - 32px));
  text-align: center;
  box-shadow: 0 16px 40px rgba(0, 0, 0, .5);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- 响应式 ---------- */
@media (max-width: 1000px) {
  .app { height: auto; min-height: 100dvh; }
  .layout { grid-template-columns: minmax(0, 1fr); }
  .board { border-right: none; border-bottom: 1px solid var(--line-soft); }
  .log { padding: 16px 14px 8px; max-height: none; }
  .composer { position: sticky; bottom: 0; padding: 8px 14px 14px; backdrop-filter: blur(8px); }
  .side { padding: 14px 14px 90px; }
  .msg, .msg-dice { max-width: none; }
  .topbar { padding: 8px 12px; gap: 10px; position: sticky; top: 0; }
  .brand { font-size: 14px; letter-spacing: .06em; }
  .meta-pills { display: none; }
  .msg-body { font-size: 15.5px; line-height: 1.9; }
}

@media (max-width: 520px) {
  .join-card { padding: 26px 20px 20px; }
  .join-card h1 { font-size: 25px; }
  .quick-dice { grid-template-columns: repeat(3, 1fr); }
  .panel { padding: 11px 11px 12px; }
}

/* ---------- 角色卡：背包数量与占格 ---------- */
.bag-count {
  float: right;
  font-size: 12px;
  letter-spacing: .04em;
  color: var(--gold);
  font-weight: 400;
}
.bag-meter {
  height: 4px;
  border-radius: 3px;
  background: #241d16;
  border: 1px solid var(--line-soft);
  overflow: hidden;
  margin: 2px 0 6px;
}
.bag-meter i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, #8a6a34, var(--gold));
  opacity: .85;
}
.bag-sub { font-size: 11.5px; color: var(--muted); margin-bottom: 8px; line-height: 1.6; }
.bag-tbl td, .bag-tbl th { font-size: 13px; }
.bag-tbl .num { width: 64px; text-align: right; white-space: nowrap; }
.bag-key {
  display: inline-block;
  font-size: 10.5px;
  padding: 0 5px;
  margin-left: 4px;
  border-radius: 3px;
  border: 1px solid #4a3c2a;
  color: #b9a071;
  vertical-align: 1px;
}
.bag-live {
  display: inline-block;
  padding-top: 8px;
  font-family: var(--serif);
  color: var(--text-dim);
  letter-spacing: .04em;
}
.bag-live.over { color: #e0846b; }
/* ---------- 线索 / 关键物品 ---------- */
.row.tight { gap: 6px; margin: 2px 0 10px; }
.clue-row {
  border: 1px solid var(--line-soft);
  border-radius: 7px;
  padding: 9px 11px;
  margin-bottom: 8px;
  background: rgba(255,255,255,.012);
}
.clue-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 13.5px;
  color: var(--gold);
  letter-spacing: .03em;
}
.clue-head b { font-size: 12.5px; color: var(--text-dim); font-weight: 500; }
.clue-val {
  margin-top: 4px;
  font-size: 13px;
  line-height: 1.65;
  color: var(--text-dim);
  word-break: break-word;
}
.prog {
  margin-top: 7px;
  height: 4px;
  border-radius: 3px;
  background: #241d16;
  border: 1px solid var(--line-soft);
  overflow: hidden;
}
.prog i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, #8a6a34, var(--gold));
  opacity: .9;
}
/* ---------- 输入框常驻底部 ----------
   坑：.log 作为 flex 子项没写 min-height:0 时，内容一多就把 .board 撑高，
   composer 被顶出视口 —— 这才是「输入框跑掉」的真正原因。 */
.board { overflow: hidden; }
.log { min-height: 0; overscroll-behavior: contain; }
.composer {
  position: sticky;
  bottom: 0;
  z-index: 3;
  padding-bottom: max(18px, env(safe-area-inset-bottom));
}
@media (max-width: 1000px) {
  .composer {
    position: sticky;
    bottom: 0;
    background: linear-gradient(rgba(16, 14, 11, .72), rgba(16, 14, 11, .98) 34%);
    backdrop-filter: blur(10px);
  }
}
/* ---------- 布局兜底：三行网格，输入框永远在最后一行 ----------
   flex 在部分浏览器/缩放下会把 composer 排到奇怪的位置，改用 grid 明确分区。 */
.board {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto auto;
}
.log { grid-row: 1; min-height: 0; }
.typing { grid-row: 2; }
.composer { grid-row: 3; position: static; }
/* ---------- 开场：开始 → 背景故事 → 角色故事 → 难度 ---------- */
.board > .start-layer {
  position: absolute;
  inset: 0;
  z-index: 6;
  display: grid;
  place-items: center;
  padding: 20px;
  overflow-y: auto;
  background:
    radial-gradient(120% 80% at 50% 38%, rgba(14, 12, 9, .74) 0%, rgba(10, 9, 7, .95) 60%, rgba(8, 7, 5, .99) 100%);
}
.start-card {
  width: 100%;
  max-width: 760px;
  margin: auto;
  padding: 30px 34px 26px;
  border: 1px solid rgba(217, 178, 106, .26);
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(30, 25, 19, .96), rgba(18, 15, 12, .97));
  box-shadow: 0 30px 90px rgba(0, 0, 0, .65), inset 0 1px 0 rgba(255, 255, 255, .04);
}
.start-hero { text-align: center; padding: 18px 0 6px; }
.start-kicker {
  font-size: 12px;
  letter-spacing: .32em;
  color: var(--gold-dim, #9c7c46);
  text-transform: uppercase;
}
.start-hero h1 {
  margin: 12px 0 6px;
  font-size: 34px;
  letter-spacing: .12em;
  color: var(--gold, #d9b26a);
  font-weight: 600;
}
.start-sub { margin: 0 0 26px; color: var(--muted); font-size: 13.5px; letter-spacing: .18em; }
.start-big { min-width: 190px; padding: 13px 30px; font-size: 16px; letter-spacing: .22em; }
.start-foot { margin: 20px 0 0; font-size: 12.5px; color: #7d7466; line-height: 1.8; }
.start-title {
  margin: 0 0 4px;
  font-size: 20px;
  letter-spacing: .1em;
  color: var(--gold, #d9b26a);
}
.start-note { margin: 0 0 18px; font-size: 12.5px; color: #7d7466; letter-spacing: .08em; }
.start-text p {
  margin: 0 0 14px;
  font-size: 15px;
  line-height: 2.05;
  color: #ddd4c4;
  text-indent: 2em;
}
.start-chars { display: grid; gap: 12px; margin: 4px 0 6px; }
.start-char {
  padding: 13px 15px;
  border-left: 2px solid rgba(217, 178, 106, .5);
  border-radius: 0 8px 8px 0;
  background: rgba(255, 255, 255, .022);
}
.start-char h3 {
  margin: 0 0 2px;
  font-size: 15px;
  color: var(--gold, #d9b26a);
  letter-spacing: .06em;
}
.start-char .role { margin: 0 0 7px; font-size: 11.5px; color: #7d7466; letter-spacing: .18em; }
.start-char p { margin: 0; font-size: 13.5px; line-height: 1.85; color: #c8c0b2; }
.start-diffs { display: grid; gap: 11px; margin: 4px 0 6px; }
.start-diff {
  text-align: left;
  padding: 14px 16px;
  border: 1px solid rgba(217, 178, 106, .22);
  border-radius: 10px;
  background: rgba(255, 255, 255, .022);
  color: var(--text, #e8e0d2);
  cursor: pointer;
  transition: border-color .16s, background .16s, transform .12s;
}
.start-diff:hover:not(:disabled) {
  border-color: rgba(217, 178, 106, .62);
  background: rgba(217, 178, 106, .075);
  transform: translateY(-1px);
}
.start-diff:disabled { opacity: .45; cursor: default; }
.start-diff-head { display: flex; align-items: baseline; gap: 10px; }
.start-diff-head b { font-size: 16px; color: var(--gold, #d9b26a); letter-spacing: .1em; }
.start-diff-head span { font-size: 12px; color: #8d8477; }
.start-diff ul { margin: 9px 0 0; padding-left: 18px; }
.start-diff li { font-size: 12.5px; line-height: 1.9; color: #b8b0a2; }
.start-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid rgba(217, 178, 106, .14);
}
.start-actions .spacer { flex: 1 1 auto; }
@media (max-width: 640px) {
  .start-card { padding: 22px 18px 20px; border-radius: 10px; }
  .start-hero h1 { font-size: 26px; }
  .start-text p { font-size: 14px; line-height: 1.95; }
}
/* 开局前锁住输入区 */
.composer.locked { opacity: .8; }
.composer.locked textarea { cursor: text; }
#quick-dice button:disabled, #open-dice:disabled { opacity: .35; cursor: not-allowed; }

/* ---------- 日志滚动条（显式重写，之前 grid 化之后滚动条消失了） ---------- */
.layout { min-height: 0; }
.board {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto auto;
  height: 100%;
  min-height: 0;
  overflow: hidden;
}
.log {
  grid-row: 1;
  flex: none;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-gutter: stable;
  scrollbar-width: thin;
  scrollbar-color: #4b3d2b #14110d;
}
.log::-webkit-scrollbar { width: 11px; height: 11px; }
.log::-webkit-scrollbar-track { background: rgba(20, 17, 13, .6); }
.log::-webkit-scrollbar-thumb {
  background: #4b3d2b;
  border: 2px solid rgba(20, 17, 13, .6);
  border-radius: 10px;
  background-clip: padding-box;
}
.log::-webkit-scrollbar-thumb:hover { background: #6a5638; }
.typing { grid-row: 2; }
.composer { grid-row: 3; position: static; }

/* ---------- 存档对话框 ---------- */
.saves-wrap { display: flex; flex-direction: column; gap: 10px; }
.save-new { display: flex; gap: 8px; }
.save-new .input { flex: 1 1 auto; min-width: 0; }
.saves-h {
  margin: 8px 0 0;
  font-size: 12.5px;
  letter-spacing: .1em;
  color: var(--gold-dim, #9c7c46);
  font-weight: 500;
}
.saves-h .muted { letter-spacing: 0; font-weight: 400; }
.save-list { display: flex; flex-direction: column; gap: 6px; max-height: 32vh; overflow-y: auto; padding-right: 2px; }
.save-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: rgba(255, 255, 255, .022);
}
.save-main { min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.save-main b { font-weight: 500; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.save-meta { font-size: 11.5px; color: var(--muted); }
.save-act { margin-left: auto; display: flex; gap: 6px; flex: none; }
.save-empty { font-size: 12.5px; color: var(--muted); padding: 10px 2px; line-height: 1.75; }
.save-foot { display: flex; gap: 8px; padding-top: 8px; border-top: 1px solid var(--line-soft); }

/* 快捷存档 / 重命名（1102l） */
.save-row.is-quick { border-color: rgba(217,178,106,.42); }
.tag-quick { display: inline-block; margin-top: 2px; font-size: 10.5px; letter-spacing: .06em; color: #d9b26a; border: 1px solid rgba(217,178,106,.45); border-radius: 4px; padding: 0 4px; }
.save-act .btn[data-rename] { min-width: 30px; padding: 0 6px; font-size: 13px; line-height: 1; }
#quick-save, #quick-load { padding: 5px 9px; font-size: 12px; }

/* 开场第一步的「读取存档」（1102m） */
.start-saves { display: block; width: 100%; margin: 10px auto 0; max-width: 320px; }

/* 删除存档：两级确认（1102n） */
.save-act .btn[data-del].armed { background: #4a1b1b; border-color: #8d3a3a; color: #ffd7d7; }
.save-act .btn[data-del].armed:hover { background: #5a2020; }

/* 接管角色卡 / 通用两级确认（1102o） */
.btn.armed, .pcard-actions .btn.armed { background: #4a1b1b; border-color: #8d3a3a; color: #ffd7d7; }
.btn.armed:hover, .pcard-actions .btn.armed:hover { background: #5a2020; }

/* ===== 1103a：三栏（左玩家聊天室）+ 角色卡展开 + 骰点表单 + 对话框滚动修复 ===== */
.layout { grid-template-columns: 236px minmax(0, 1fr) 416px; }

/* 左侧聊天室：只有玩家之间的对话，KP 与模型都收不到 */
.chatpane {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  border-right: 1px solid var(--line-soft);
  background: rgba(0, 0, 0, .26);
}
.chatpane .panel-head {
  flex: none;
  padding: 9px 12px 8px;
  border-bottom: 1px solid var(--line-soft);
}
.chat-log {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 7px;
  scrollbar-width: thin;
  scrollbar-color: #4b3d2b #14110d;
}
.chat-log::-webkit-scrollbar { width: 9px; }
.chat-log::-webkit-scrollbar-thumb { background: #4b3d2b; border-radius: 6px; }
.chat-row { font-size: 12.5px; line-height: 1.7; word-break: break-word; }
.chat-row b { color: var(--ch, #bdb29b); font-weight: 500; margin-right: 4px; }
.chat-row b::after { content: '：'; opacity: .6; }
.chat-row span { color: #ded4c0; }
.chat-form {
  flex: none;
  display: flex;
  gap: 6px;
  padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line-soft);
}
.chat-form input {
  flex: 1 1 auto;
  min-width: 0;
  background: #14110d;
  border: 1px solid var(--line-soft);
  border-radius: 7px;
  color: var(--text);
  padding: 7px 9px;
  font-size: 12.5px;
  font-family: inherit;
}
.chat-form input:focus { outline: none; border-color: rgba(217, 178, 106, .5); }

/* 角色卡：自己的那张展开、别人的只留 HP/MP 与属性格 */
.pcard.compact { padding: 10px 11px; opacity: .93; }
.pcard.expanded { border-color: rgba(217, 178, 106, .45); }
.pcard-attrs {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 2px;
  margin: 8px 0 2px;
}
.mini-attr {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  font-size: 9px;
  color: var(--muted);
  border: 1px solid var(--line-soft);
  border-radius: 5px;
  padding: 3px 0 2px;
  background: rgba(255, 255, 255, .02);
  overflow: hidden;
  white-space: nowrap;
}
.mini-attr b { font-size: 12px; font-weight: 600; color: var(--text); line-height: 1.15; }
.pcard-chips .money { color: #d9b26a; }
.pcard-chips .cd { color: #e6a860; border-color: #5d4326; background: rgba(230,168,96,.08); }

/* 剧情里按角色上色：整条消息左侧一道角色色 */
.msg[style*="--ch"] { border-left: 2px solid var(--ch); padding-left: 10px; }

/* 骰点表单：DC 与手报点数都要完整显示 */
.dice-form { grid-template-columns: repeat(auto-fit, minmax(158px, 1fr)); }
.dice-form label.field span { font-size: 11.5px; }
.dice-form input, .dice-form select { width: 100%; min-width: 0; }
.dice-preview { line-height: 1.8; word-break: break-word; }

/* 对话框：头部固定、正文自身滚动，保存/关闭按钮不再被裁掉 */
.dialog[open] { display: flex; flex-direction: column; }
.dialog-head { flex: none; }
.dialog-body { flex: 1 1 auto; min-height: 0; max-height: none; overflow-y: auto; }

@media (max-width: 1200px) {
  .layout { grid-template-columns: 200px minmax(0, 1fr) 384px; }
  .chat-log { padding: 8px 10px; }
}
@media (max-width: 1000px) {
  .layout { grid-template-columns: minmax(0, 1fr) 320px; }
  .chatpane {
    grid-column: 1 / -1;
    grid-row: 2;
    border-right: none;
    border-top: 1px solid var(--line-soft);
    max-height: 34vh;
  }
  .chat-row { font-size: 12px; }
}
@media (max-width: 820px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .chatpane { grid-row: auto; max-height: 30vh; }
  .pcard-attrs { grid-template-columns: repeat(8, minmax(0, 1fr)); }
  .mini-attr { font-size: 9px; }
}
/* ===== 1103b：图层顺序统一 + 滚动体检 =====
   原生 <dialog> 在浏览器顶层（top layer），层级数字对它无效；
   toast 由 app.js 在有对话框时挪进对话框里，这里只保证普通状态它在最上。 */
:root {
  --z-board: 1;
  --z-composer: 20;
  --z-start: 30;
  --z-topbar: 40;
  --z-toast: 200;   /* 要压过地图(90)/章节过场(95)，但仍在原生 dialog 之下 */
}
.topbar { position: relative; z-index: var(--z-topbar); }
.composer { z-index: var(--z-composer); }
.board > .start-layer { z-index: var(--z-start); }
.toast { z-index: var(--z-toast); }

/* 对话框：没有 dvh 的老浏览器退回 vh；内容区自己滚，底部留出安全区 */
.dialog { max-height: 88vh; max-height: min(88dvh, 880px); overflow: hidden; }
.dialog-body {
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding-bottom: calc(24px + env(safe-area-inset-bottom));
  scrollbar-gutter: stable;
  scrollbar-width: thin;
  scrollbar-color: #4b3d2b #14110d;
}
.dialog-body::-webkit-scrollbar { width: 10px; }
.dialog-body::-webkit-scrollbar-track { background: rgba(20, 17, 13, .6); }
.dialog-body::-webkit-scrollbar-thumb {
  background: #4b3d2b;
  border: 2px solid rgba(20, 17, 13, .6);
  border-radius: 9px;
  background-clip: padding-box;
}
.dialog-body::-webkit-scrollbar-thumb:hover { background: #6a5638; }
.dialog-body table, .dialog-body .stat-grid { max-width: 100%; }

/* 三个滚动区用同一套滚动条，避免有的粗有的没有 */
.side, .chat-log, .save-list {
  scrollbar-width: thin;
  scrollbar-color: #4b3d2b #14110d;
  scrollbar-gutter: stable;
}
.side::-webkit-scrollbar, .save-list::-webkit-scrollbar { width: 10px; }
.side::-webkit-scrollbar-thumb, .save-list::-webkit-scrollbar-thumb {
  background: #4b3d2b;
  border-radius: 8px;
  border: 2px solid transparent;
  background-clip: padding-box;
}

/* 窄屏：右栏不要被裁掉，整页允许滚动 */
@media (max-width: 1000px) {
  .layout { grid-template-rows: minmax(0, 1fr) auto; }
}
@media (max-width: 820px) {
  .layout { grid-template-rows: minmax(0, 1fr) auto auto; overflow-y: auto; }
  .side { overflow: visible; }
  .chatpane { max-height: 32vh; }
}

/* ---- 1103c 开场四步：角色背景故事可滚动 + 领卡 ---- */
.start-card { max-height: min(88dvh, 900px); overflow-y: auto; scrollbar-width: thin; scrollbar-color: #4b3d2b #14110d; }
.start-chars.rich { display: grid; gap: 14px; }
.start-char.rich, .start-chars.rich .start-char { text-align: left; }
.start-chars.rich .start-char h3 { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.start-chars.rich .start-char h3 .role { font-size: 12px; color: #b8a887; font-weight: 400; letter-spacing: .08em; }
.story-p { font-size: 13px; line-height: 1.9; color: #cfc4b4; margin: 7px 0; text-indent: 0; }
.story-p b { color: var(--gold); font-weight: 600; letter-spacing: .02em; }
.story-tag { font-size: 12px; color: #8f8574; margin: 8px 0 0; }
.start-chars.rich .start-char.mine { border-color: #8a6f3c; background: rgba(217,178,106,.06); }

/* ---- 1104a 骰点动画 + 规则纠正提示 ---- */
.msg-dice { position: relative; }
.die-stage {
  display: inline-flex; align-items: center; justify-content: center;
  width: 26px; height: 26px; margin-right: 8px; vertical-align: middle;
}
.die {
  display: inline-flex; align-items: center; justify-content: center;
  width: 26px; height: 26px; box-sizing: border-box;
  border-radius: 26%;
  background: linear-gradient(160deg, #2b2418 0%, #171310 100%);
  border: 1px solid #6b5734;
  color: #e6c786;
  font: 600 12px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.07), 0 1px 3px rgba(0,0,0,.5);
  will-change: transform;
}
.die.rolling { animation: die-roll .62s linear infinite; color: #d9b26a; }
@keyframes die-roll {
  0%   { transform: rotate(0deg)   scale(1); }
  25%  { transform: rotate(92deg)  scale(.88); }
  50%  { transform: rotate(180deg) scale(1.08); }
  75%  { transform: rotate(268deg) scale(.9); }
  100% { transform: rotate(360deg) scale(1); }
}
.die.landed { animation: die-land .5s cubic-bezier(.2,.8,.2,1); }
@keyframes die-land {
  0%   { transform: scale(.55) rotate(-24deg); opacity: .25; }
  60%  { transform: scale(1.16) rotate(6deg);   opacity: 1; }
  100% { transform: none; }
}
.die.v-success  { border-color: #4f7a48; color: #cfe3b8; }
.die.v-fail     { border-color: #7a4a4a; color: #e0b9b9; }
.die.v-crit     { border-color: #d9b26a; color: #ffe9b8; box-shadow: 0 0 10px rgba(217,178,106,.45), inset 0 1px 0 rgba(255,255,255,.1); }
.die.v-critfail { border-color: #9b3a3a; color: #f0a0a0; box-shadow: 0 0 10px rgba(155,58,58,.4); }
.dice-note {
  display: block; width: 100%; margin-top: 5px;
  font-size: 11px; line-height: 1.6; color: #c9a05a; letter-spacing: .02em;
}
@media (prefers-reduced-motion: reduce) {
  .die.rolling, .die.landed { animation: none; }
}

/* ---------- 1105a 状态 chip ---------- */
.status-row{display:flex;flex-wrap:wrap;gap:6px;margin:2px 0 10px}
.status-chip{font-size:11.5px;padding:3px 9px;border-radius:11px;background:#221d17;border:1px solid #4b3d2b;color:#d9c7a3}
.status-chip.bad{background:#2a1a1a;border-color:#6d3333;color:#e3b3b3}

/* 1105h：编辑弹窗的保存按钮永远可点（滚到底也粘着） */
.dialog-actions{
  position: sticky;
  bottom: 0;
  z-index: 2;
  display: flex;
  gap: 10px;
  padding: 12px 0 calc(6px + env(safe-area-inset-bottom));
  margin-top: 4px;
  background: linear-gradient(to top, rgba(16,14,11,.98) 55%, rgba(16,14,11,.86));
  border-top: 1px solid rgba(217,178,106,.18);
}
.dialog-actions .btn{ flex: 1 1 auto; min-width: 0; white-space: nowrap; padding: 9px 10px; font-size: 13px; }
@media (max-width:520px){ .dialog-actions{ flex-wrap: wrap; } .dialog-actions .btn{ flex: 1 1 44%; } }

/* 1105k：KP 旁白底部的动作条（让 KP 掷骰） */
.msg-tools{
  display: flex;
  gap: 8px;
  margin: 8px 0 2px 10px;
  opacity: .62;
  transition: opacity .15s ease;
}
.msg:hover .msg-tools, .msg-tools:focus-within{ opacity: 1; }
.msg-tools .btn.small{ font-size: 12px; padding: 4px 10px; }


/* ===== 1106b：地图全屏 + 章节过场 ===== */
.map-full {
  position: fixed; inset: 0; z-index: 90;
  background: radial-gradient(120% 120% at 50% 40%, rgba(14, 12, 9, .96), rgba(4, 3, 2, .99));
  display: flex; align-items: center; justify-content: center;
  overflow: hidden; touch-action: none;
}
.map-full[hidden] { display: none !important; }
.map-full .map-stage { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; }
.map-full #map-img {
  max-width: 96vw; max-height: 88vh; width: auto; height: auto;
  border-radius: 6px; border: 1px solid #3a2f21;
  box-shadow: 0 18px 60px rgba(0, 0, 0, .7), 0 0 0 6px rgba(20, 17, 13, .55);
  cursor: grab; user-select: none; -webkit-user-drag: none;
  transition: transform .12s ease-out;
  will-change: transform;
}
.map-full:active #map-img { cursor: grabbing; }
.map-bar {
  position: absolute; left: 50%; bottom: calc(18px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px; border-radius: 999px;
  background: rgba(20, 17, 13, .82); border: 1px solid rgba(217, 178, 106, .22);
  backdrop-filter: blur(8px); z-index: 2;
}
.map-bar .map-hint { font-size: 11px; color: var(--muted, #8b8272); margin-right: 4px; white-space: nowrap; }
.map-bar .btn.small { padding: 4px 10px; font-size: 12px; }
body.map-open { overflow: hidden; }

.chapter-fx {
  position: fixed; inset: 0; z-index: 95;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  background: radial-gradient(circle at 50% 50%, rgba(10, 9, 7, .92), rgba(3, 3, 2, .99));
  opacity: 0; pointer-events: none;
  transition: opacity .7s ease;
}
.chapter-fx.show { opacity: 1; }
.chapter-fx.hide { opacity: 0; }
.chapter-fx .fx-line {
  width: 0; height: 1px;
  background: linear-gradient(90deg, transparent, #d9b26a, transparent);
  transition: width 1s cubic-bezier(.2, .8, .2, 1);
}
.chapter-fx.show .fx-line { width: min(62vw, 460px); }
.chapter-fx .fx-kicker {
  font-size: 11px; letter-spacing: .5em; color: #9a8a6a; text-transform: uppercase;
  margin-top: 6px; opacity: 0; transform: translateY(6px);
  transition: opacity .6s ease .25s, transform .6s ease .25s;
}
.chapter-fx.show .fx-kicker { opacity: .9; transform: none; }
.chapter-fx .fx-title {
  font-family: "Songti SC", "Noto Serif SC", "SimSun", serif;
  font-size: clamp(30px, 6vw, 54px); letter-spacing: .16em; color: #efe2c6;
  text-shadow: 0 0 26px rgba(217, 178, 106, .35);
  opacity: 0; transform: scale(.96);
  transition: opacity .8s ease .35s, transform .8s ease .35s;
}
.chapter-fx.show .fx-title { opacity: 1; transform: none; }
.chapter-fx .fx-sub {
  font-size: clamp(13px, 2.2vw, 17px); letter-spacing: .34em; color: #b9a77f;
  opacity: 0; transform: translateY(8px);
  transition: opacity .8s ease .6s, transform .8s ease .6s;
}
.chapter-fx.show .fx-sub { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) {
  .chapter-fx, .chapter-fx .fx-line, .chapter-fx .fx-kicker,
  .chapter-fx .fx-title, .chapter-fx .fx-sub { transition: none; }
}

/* 1106c NPC 标记 */
.npc-tag{display:inline-block;margin-left:6px;padding:1px 5px;border:1px solid rgba(143,191,154,.5);
  border-radius:3px;color:#8fbf9a;font-style:normal;font-size:10px;letter-spacing:.18em;vertical-align:1px}
.pcard:has(.npc-tag){border-left:2px solid rgba(143,191,154,.45)}

/* ---------- 1107a：开局人数选择 ---------- */
.party-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin: 4px 0 10px;
}
.party-row .party-label {
  font-size: 12px;
  letter-spacing: 0.14em;
  color: var(--gold);
  opacity: 0.85;
  margin-right: 4px;
}
.party-row .btn.small {
  padding: 3px 9px;
  font-size: 12px;
}
.party-hint {
  font-size: 12px;
  color: var(--muted, #8b8378);
  margin-left: 6px;
}
.party-hint.bad {
  color: #e0a0a0;
}
.btn[disabled] {
  opacity: 0.45;
  cursor: not-allowed;
}

/* 1109t：地图只展示，不缩放不拖动 */
.map-full #map-img { cursor: default; }
.map-full .map-stage { cursor: default; }

/* 1109bb：剧情大纲（轻量 markdown 渲染） */
.guide-body{ max-width: 100%; }
.guide-body h4{ margin: 18px 0 8px; font-size: 14.5px; color:#e9d3a3; letter-spacing:.4px; }
.guide-body h4:first-child{ margin-top: 2px; }
.guide-body p{ margin: 0 0 10px; line-height: 1.9; font-size: 13.5px; color:#cfc6b8; }
.guide-body .md-li{ padding-left: 14px; position: relative; }
.guide-body .md-row{ color:#b9ae9c; font-size: 12.8px; }
.guide-body strong{ color:#f0dcae; font-weight: 600; }

/* 1109bc：弹窗内容给吸底动作条留出空间 + 站内确认弹窗排版 */
#modal-body{ padding-bottom: 8px; }
.confirm-body p{ margin: 0 0 9px; line-height: 1.85; font-size: 13.5px; color:#cfc6b8; }
.confirm-body p:last-child{ margin-bottom: 2px; }

/* KP 叙述里的角色名着色：只上色，不加粗不加底色 */
.msg-body .cname{ font-weight: 500; }

/* NPC 自动掷骰开关：一行横排，不要撑成两段 */
.row-inline{
  display:flex; align-items:center; gap:8px;
  margin-top:10px; padding:8px 10px;
  border:1px solid rgba(217,178,106,.18); border-radius:8px;
  cursor:pointer; line-height:1.5;
}
.row-inline input[type="checkbox"]{ width:16px; height:16px; margin:0; flex:0 0 auto; accent-color:#d9b26a; }
.row-inline > span:nth-of-type(1){ color:#e8dcc2; font-size:13px; flex:0 0 auto; }
.row-inline .muted{ font-size:12px; }

/* 开场生成期间：输入区半透明，提示「开场正在写」 */
#composer.opening{ opacity: .55; }
#composer.opening #input{ cursor: progress; }

/* 角色立绘：队伍卡小头像 + 详情顶部横幅 */
.pcard-face{ width:34px; height:34px; border-radius:9px; object-fit:cover; object-position:50% 18%; flex:0 0 auto; border:1px solid rgba(255,255,255,.12); }
/* 角色详情：立绘右浮动（随页面滚动），正文绕排并在其下方补满 */
.char-sheet{ display:block; }
.char-main{ display:block; }
.char-side{ float:right; width:248px; max-width:40%; margin:2px 0 14px 18px; }
/* v1.1.6 木纹相框：纯 CSS 画（两道金线 + 深木渐变 + 内阴影），不引外部素材 */
.char-art-wrap{
  padding:9px; border-radius:14px; position:relative;
  background:
    linear-gradient(90deg, rgba(255,255,255,.06) 0%, rgba(0,0,0,.18) 22%, rgba(255,255,255,.05) 47%, rgba(0,0,0,.22) 72%, rgba(255,255,255,.04) 100%),
    linear-gradient(180deg, #4a3423 0%, #3a2819 42%, #2e2013 100%);
  border:1px solid #5b4028;
  box-shadow:0 10px 26px rgba(0,0,0,.45), inset 0 0 0 1px rgba(214,176,112,.28);
}
.char-art-wrap::after{
  content:""; position:absolute; inset:4px; border-radius:11px; pointer-events:none;
  border:1px solid rgba(214,176,112,.35);
}
.char-art{
  display:block; width:100%; height:auto; aspect-ratio:3/4; object-fit:cover; border-radius:8px;
  border:1px solid rgba(0,0,0,.55); background:#141010;
  box-shadow:inset 0 0 18px rgba(0,0,0,.55);
}
.char-sheet::after{ content:""; display:block; clear:both; }
/* 没有立绘的卡：占位块保持同样尺寸，几张卡翻起来高度一致 */
.char-art-empty{
  aspect-ratio:3/4; display:flex; flex-direction:column; align-items:center; justify-content:center;
  gap:10px; background:linear-gradient(160deg, color-mix(in srgb, var(--c) 24%, #171310) 0%, #14100d 70%);
  border-color:rgba(255,255,255,.08);
}
.char-art-empty span{ font-size:56px; line-height:1; color:var(--c); opacity:.5; font-weight:600; }
.char-art-empty em{ font-style:normal; font-size:12px; letter-spacing:.14em; color:#8b8272; }
/* 钱袋：金币/银币图标 + 数字，始终一行 */
.coin{ width:12px; height:12px; vertical-align:-1.5px; margin-right:2px; flex:0 0 auto; }
.coin-wrap{ display:inline-flex; align-items:center; gap:1px; white-space:nowrap; }
.coin-wrap b{ font-family:var(--mono); font-weight:600; margin:0 5px 0 1px; }
.coin-wrap b:last-child{ margin-right:0; }
.coin-wrap.stack{ flex-direction:column; align-items:flex-start; gap:2px; }
.coin-wrap.stack .coin-line{ display:inline-flex; align-items:center; }
.coin-wrap.stack .coin-line b{ margin:0 0 0 3px; }
/* 属性八项一行（立绘旁那一块尽量用满，别折行浪费高度） */
@media (min-width:720px){
  /* 八维排成两行四列：每格宽度够放下「数值 + 加值」，不会折行 */
  #modal-body .stat-grid.attr-grid{ grid-template-columns:repeat(4, minmax(0,1fr)); }
}
/* 属性八项一行（立绘旁那一块尽量用满，别折行浪费高度） */
/* 装备表：加成列吃掉剩余宽度，饰品那一行属性再多也只在自己格子里折行 */
#modal-body .gear-tbl{ table-layout:fixed; }
#modal-body .gear-tbl td{ word-break:break-word; }
#modal-body .gear-tbl td:nth-child(4){ text-align:right; }
/* 技能段从立绘下方开始，占满整行宽度 */
.sec-clear{ clear:both; height:0; }
#modal-body .sec-clear + .sec-title{ margin-top:18px; }
.stat .money-b .coin{ width:13px; height:13px; }
/* 详情页紧凑排版：能并排的并排 */
/* 表格单独成一个 BFC，才能贴着右浮动立绘排（否则整块被挤到立绘下方留白） */
#modal-body .tbl-wrap{ overflow:hidden; }
#modal-body .tbl-wrap table.tbl{ width:100%; }
#modal-body .stat-grid{ grid-template-columns:repeat(6, minmax(0,1fr)); gap:6px; margin-bottom:10px; }
#modal-body .sec-title{ margin:14px 0 6px; }
#modal-body table.tbl th, #modal-body table.tbl td{ padding:4px 6px; }
#modal-body .note-text{ font-size:12.5px; line-height:1.65; }
@media (max-width:860px){
  .char-side{ float:none; width:100%; max-width:100%; margin:0 0 12px; }
  .char-art-wrap{ max-width:320px; margin:0 auto; }
  .char-art{ border-radius:8px; }
  #modal-body .stat-grid{ grid-template-columns:repeat(3, minmax(0,1fr)); }
}

/* 战场条：KP 用 [[敌人|名字|血|闪避]] 登记后出现 */
.encounter{ display:flex; flex-direction:column; gap:8px; }
.enc-row{ border:1px solid #4a3826; border-radius:8px; padding:7px 9px; background:rgba(255,255,255,.02); }
.enc-row.down{ opacity:.45; }
.enc-head{ display:flex; align-items:baseline; gap:8px; }
.enc-name{ font-size:13px; color:#e8dcc6; flex:1 1 auto; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.enc-dodge{ font-size:11px; color:#9b8f7a; }
.enc-hp{ font-size:12px; color:#e0b8a4; font-variant-numeric:tabular-nums; }
.enc-row.down .enc-hp{ color:#8d8377; }
.enc-bar{ margin-top:5px; height:4px; border-radius:2px; background:rgba(255,255,255,.08); overflow:hidden; }
.enc-bar i{ display:block; height:100%; background:linear-gradient(90deg,#8c3b32,#c8664f); }

/* 讲义：一张图 + 一行说明，点开看大图 */
.msg-handout { padding: 6px 0; }
.msg-handout .handout { margin: 0; }
.handout-img {
  display: block; max-width: min(420px, 100%); border-radius: 10px;
  border: 1px solid var(--line); box-shadow: 0 6px 18px rgba(0, 0, 0, .38);
  cursor: zoom-in;
}
.handout-cap { margin-top: 6px; font-size: 12px; color: var(--muted); line-height: 1.6; }
.handout-zoom-wrap { text-align: center; }
.handout-zoom { max-width: 100%; border-radius: 10px; border: 1px solid var(--line); }

/* v1.1.7 线索门 */
.clue-gate{ display:flex; gap:8px; align-items:baseline; padding:5px 2px; border-bottom:1px dashed rgba(255,255,255,.07); font-size:13px; color:#cbb89c; }
.clue-gate:last-of-type{ border-bottom:0; }
.clue-gate.got{ color:#9fd3a6; }
.clue-gate-mark{ width:14px; text-align:center; opacity:.8; }
.clue-gate-name{ flex:1; }

/* 装备耐久归零 */
#modal-body .gear-broken{ color:#e0776b; font-size:11px; border:1px solid #6a3230; border-radius:4px; padding:1px 4px; margin-left:6px; }
#modal-body td.gear-broken{ color:#e0776b; }

/* 备查敌人（还没出场）：只列名字，不占战场条的位置 */
#encounter .enc-reserved{
  padding:6px 8px; font-size:12px; color:#8c8272;
  background:rgba(255,255,255,.03); border:1px dashed #3a352c; border-radius:8px;
  word-break:break-word;
}

/* 线索门：结论 + 三条路线 */
.clue-gate-routes{ display:block; margin-left:20px; color:var(--muted,#9a8f7d); font-size:12px; line-height:1.5; }
#chapter-force-hint{ font-size:12px; }

/* 立绘木框加强 */
.char-art-wrap{
  padding:11px; border-radius:14px; border:1px solid #241408;
  background:linear-gradient(160deg,#6b4527,#9a6132 34%,#4a2e1a 72%,#7a4f2c);
  box-shadow: inset 0 0 0 1px rgba(255,214,150,.55), inset 0 0 22px rgba(0,0,0,.55), 0 12px 28px rgba(0,0,0,.55);
  position:relative;
}
.char-art-wrap::before{
  content:''; position:absolute; inset:4px; border-radius:10px; pointer-events:none;
  box-shadow: inset 0 0 0 1px rgba(240,206,150,.5), inset 0 0 0 5px rgba(70,42,22,.55);
}
.char-art-wrap::after{
  content:''; position:absolute; inset:0; border-radius:14px; pointer-events:none;
  background:repeating-linear-gradient(92deg, rgba(0,0,0,.10) 0 2px, rgba(255,255,255,.02) 2px 5px);
  mix-blend-mode:overlay; opacity:.55;
}



/* 木纹贴图框：img/ui/wood.webp 九宫格铺边 */
#modal-body .char-art, .char-art{
  border:16px solid transparent !important;
  border-image: url('img/ui/wood.webp') 28 round !important;
  box-shadow:
    0 0 0 2px #c9a45c,
    0 0 0 4px #6b4527,
    0 0 0 5px #d9bb7c,
    inset 0 0 0 2px rgba(0,0,0,.45),
    0 16px 34px rgba(0,0,0,.62) !important;
}

/* 立绘再放大一档（只在宽屏生效，别压过 860px 的单列布局） */
@media (min-width:861px){
  .char-side{ width:344px !important; max-width:46% !important; }
  #modal-body .char-art, .char-art{ max-height:540px !important; }
}
@media (max-width:860px){
  .char-side{ float:none !important; width:100% !important; max-width:100% !important; margin:0 0 12px !important; }
  .char-side .char-art{ max-height:none !important; width:100% !important; }
}
#modal-body .stat-grid{ grid-template-columns:repeat(auto-fit, minmax(74px, 1fr)); }
#modal-body .stat{ min-width:0; overflow:hidden; }
#modal-body .stat b{ font-variant-numeric:tabular-nums; }

.pcard-head .swatch{ width:4px !important; height:34px !important; border-radius:2px; flex:0 0 auto; }

/* ==== 树皮木框（v1.3.x 收尾）==== */
/* 立绘相框：切片收到 22，让纹理本身当边框 */
.char-art{
  border:14px solid transparent !important;
  border-image:url('img/ui/wood.webp') 22 round !important;
}
/* 顶栏底边：一条木纹带收住整页 */
header, #topbar, .topbar{
  border-bottom:6px solid transparent !important;
  border-image:url('img/ui/wood.webp') 18 / 6px repeat !important;
}
/* 右栏板块与弹窗：细木边，不盖底色 */
#side .panel, .panel, #modal .dialog{
  border:1px solid transparent;
  border-image:url('img/ui/wood.webp') 18 / 4px stretch;
  background-clip:padding-box;
}

/* ---- 2026-12-04 窄屏（≤640，含 375 手机）：顶栏会换行，别再撑出横向滚动 ---- */
@media (max-width: 640px) {
  html, body { max-width: 100%; overflow-x: hidden; }
  .topbar { flex-wrap: wrap; row-gap: 6px; padding: 8px 12px; gap: 10px; }
  .topbar h1, #room-title { font-size: 15px; }
  .pill { font-size: 11px; padding: 3px 7px; }
  .board > .start-layer { padding: 10px; }
  .start-card { padding: 22px 16px 20px; max-width: 100%; }
  .start-hero h1 { font-size: 26px; letter-spacing: .08em; }
  .start-sub { letter-spacing: .05em; font-size: 12.5px; }
  .start-text p { font-size: 14px; line-height: 1.9; }
  dialog.dialog { width: 94vw; max-width: 94vw; padding: 16px 14px; }
  .side { padding: 8px 10px; }
  .msg { padding-left: 10px; padding-right: 10px; }
  .composer { padding: 6px 10px; }

  /* 340 窄屏：日志自己滚，不要让整页撑到 4700px——否则队伍/骰子要滑半天才看得到 */
  .log { max-height: calc(100dvh - 236px); overflow-y: auto; -webkit-overflow-scrolling: touch; }
  .chatpane { max-height: 22vh; }
  .side { padding-bottom: 20px; }
  .composer { background: linear-gradient(180deg, rgba(18,15,12,.72), rgba(16,14,11,.94)); }
}
