:root {
  --ink: #1a1814;
  --paper: #f2ece3;
  --muted: #6a5c4a;
  --accent: #b85c38;
  --accent-deep: #8a4028;
  --teal: #4a7a6a;
  --gold: #c9922a;
  --night: #120e0a;
  --font-d: "ZCOOL KuaiLe", "Noto Serif SC", serif;
  --font-b: "Noto Sans SC", system-ui, sans-serif;
  --ui-scale: 1;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
[hidden] { display: none !important; }

body {
  font-family: var(--font-b);
  color: var(--ink);
  font-size: 19px;
  line-height: 1.65;
  background: #0e0a08;
}

.scene {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(ellipse 50% 40% at 15% 0%, rgba(184, 92, 56, 0.22), transparent 55%),
    radial-gradient(ellipse 45% 35% at 90% 20%, rgba(201, 146, 42, 0.15), transparent 50%),
    linear-gradient(165deg, #241810 0%, #120e0a 60%, #080604 100%);
}

.topbar {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1rem 1.2rem 0.4rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  color: #f0e8dc;
}

.back { color: #e8c89a; text-decoration: none; font-weight: 700; }
.brand { display: flex; gap: 0.7rem; align-items: center; flex: 1; }
.mark-img {
  width: 2.7rem; height: 2.7rem;
  border-radius: 14px;
  object-fit: cover;
  border: 2px solid rgba(201, 146, 42, 0.55);
}
.brand h1 { margin: 0; font-family: var(--font-d); font-size: 1.55rem; }
.brand p { margin: 0; font-size: 0.92rem; opacity: 0.75; }

.api-badge {
  font-size: 0.85rem;
  font-weight: 700;
  padding: 0.4rem 0.75rem;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.15);
  white-space: nowrap;
}
.api-badge.checking { background: rgba(255,255,255,0.08); color: #c8bca8; }
.api-badge.ok { background: rgba(74, 122, 106, 0.35); color: #b8f0d8; border-color: rgba(116, 200, 160, 0.45); }
.api-badge.warn { background: rgba(201, 146, 42, 0.3); color: #ffe0a0; border-color: rgba(240, 200, 100, 0.4); }
.api-badge.bad { background: rgba(184, 92, 56, 0.35); color: #ffc8b0; border-color: rgba(255, 140, 100, 0.45); }

.topbar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
}
.topbar-actions .btn.ghost {
  min-width: 3.2rem;
}
.side-save {
  margin: 0.75rem 0 0.5rem;
}
.side-save .save-actions {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.save-side-hint {
  margin: 0.35rem 0 0;
  font-size: 0.78rem;
  color: var(--muted);
}

main {
  max-width: var(--game-max-width, 1100px);
  margin: 0 auto;
  padding: 0.5rem 1rem 3rem;
}

.panel {
  background: var(--paper);
  border-radius: 18px;
  padding: 1.4rem 1.35rem;
  max-width: 640px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.45);
}

.setup-cover-wrap {
  margin: -1.4rem -1.35rem 1rem;
  border-radius: 18px 18px 0 0;
  overflow: hidden;
  max-height: 200px;
}
.setup-cover { display: block; width: 100%; height: 200px; object-fit: cover; }
.setup-hero { display: flex; gap: 1rem; align-items: flex-start; }
.setup-portrait {
  width: 96px; height: 128px;
  object-fit: cover;
  border-radius: 12px;
  border: 2px solid rgba(184, 92, 56, 0.35);
}
.setup-points { padding-left: 1.2rem; color: var(--muted); font-size: 0.95rem; }
.lede { margin: 0.4rem 0 0; line-height: 1.55; color: var(--ink); }
.setup-blurb {
  margin: 1rem 0 0.35rem;
  padding: 0.85rem 1rem 0.95rem;
  border-left: 3px solid rgba(139, 90, 43, 0.45);
  background: linear-gradient(90deg, rgba(232, 223, 210, 0.65), transparent);
}
.setup-blurb p {
  margin: 0 0 0.65rem;
  font-family: "Noto Serif SC", "Songti SC", serif;
  font-size: 0.95rem;
  line-height: 1.75;
  color: #3a3228;
}
.setup-blurb p:last-child { margin-bottom: 0; }

.api-status {
  margin: 0.85rem 0 0.35rem;
  font-size: 0.9rem;
  padding: 0.45rem 0.65rem;
  border-radius: 8px;
  background: #e8dfd2;
  color: var(--muted);
}
.api-status.ok { background: rgba(74, 122, 106, 0.15); color: #2a5a4a; }
.api-status.warn { background: rgba(201, 146, 42, 0.18); color: #6a4a10; }
.api-status.bad { background: rgba(184, 92, 56, 0.15); color: #8a4028; }
.api-hint { margin: 0 0 0.75rem; font-size: 0.82rem; color: var(--muted); }
.api-hint code { font-size: 0.8rem; background: #e8dfd2; padding: 0.1rem 0.3rem; border-radius: 4px; }

.alloc-box {
  margin: 0.85rem 0 1rem;
  padding: 0.9rem 1rem;
  border-radius: 14px;
  background: #ebe3d6;
  border: 1px solid rgba(139, 90, 43, 0.18);
}
.alloc-box h3 {
  margin: 0 0 0.35rem;
  font-family: var(--font-d);
  font-size: 1.15rem;
}
.alloc-hint { margin: 0 0 0.65rem; font-size: 0.9rem; color: var(--muted); line-height: 1.5; }
.alloc-hint strong { color: var(--accent-deep); }
.alloc-guide { display: inline-block; margin-top: 0.25rem; font-size: 0.84rem; opacity: 0.9; }
.alloc-list { display: flex; flex-direction: column; gap: 0.55rem; margin-bottom: 0.65rem; }
.alloc-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 0.55rem 0.65rem;
  align-items: center;
  padding: 0.55rem 0.65rem;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.45);
}
.alloc-meta { display: flex; flex-direction: column; gap: 0.2rem; min-width: 0; }
.alloc-row .name { font-weight: 700; font-size: 0.95rem; color: var(--ink); }
.alloc-row .desc {
  font-size: 0.8rem;
  line-height: 1.45;
  color: var(--muted);
}
.alloc-row .val {
  font-variant-numeric: tabular-nums;
  min-width: 2.6rem;
  text-align: right;
  font-weight: 700;
  font-size: 1rem;
}
.alloc-btns { display: flex; gap: 0.25rem; }

.preload-box {
  margin: 0.85rem 0 1rem;
  padding: 0.85rem 1rem;
  border-radius: 14px;
  background: rgba(232, 223, 210, 0.65);
  border: 1px solid rgba(139, 90, 43, 0.18);
}
.preload-label {
  margin: 0 0 0.5rem;
  font-size: 0.9rem;
  color: var(--muted);
}
.preload-label strong { color: var(--accent-deep); }
.preload-track {
  height: 10px;
  border-radius: 999px;
  background: rgba(139, 90, 43, 0.12);
  overflow: hidden;
}
.preload-track i {
  display: block;
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, #8b5a2b, #c4922a);
  transition: width 0.15s ease-out;
}
.preload-detail {
  margin: 0.45rem 0 0;
  font-size: 0.8rem;
  color: var(--muted);
  opacity: 0.9;
}
.preload-box.done .preload-track i {
  background: linear-gradient(90deg, #4a7a6a, #6a9a7a);
}
#btnBegin:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.save-box {
  margin: 0.85rem 0 0;
  padding: 0.85rem 1rem;
  border-radius: 14px;
  background: rgba(232, 223, 210, 0.55);
  border: 1px solid rgba(139, 90, 43, 0.16);
}
.save-box h3 {
  margin: 0 0 0.35rem;
  font-family: var(--font-d);
  font-size: 1.15rem;
  font-weight: 400;
  color: var(--accent-deep);
}
.save-hint {
  margin: 0 0 0.65rem;
  font-size: 0.85rem;
  color: var(--muted);
}
.save-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.save-msg {
  margin: 0.55rem 0 0;
  font-size: 0.85rem;
  color: var(--teal);
}
.save-msg.err { color: var(--accent-deep); }
.alloc-btns button {
  width: 2rem;
  height: 2rem;
  border: none;
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font-weight: 800;
  cursor: pointer;
}
.alloc-btns button:disabled { opacity: 0.35; cursor: not-allowed; }

@media (max-width: 700px) {
  #game .vn-stage { min-height: calc(380px * var(--ui-scale)); }
  #game .stand { width: 42%; max-width: calc(160px * var(--ui-scale)); }
  #game .stand img { max-height: calc(210px * var(--ui-scale)); }
  #game .vn-dialog { min-height: calc(7.5rem * var(--ui-scale)); padding: calc(0.85rem * var(--ui-scale)); }
  #game .vn-text { font-size: calc(1.15rem * var(--ui-scale)); }
  #game .vn-speaker { font-size: calc(1.2rem * var(--ui-scale)); }
  .chat-stands { min-height: calc(140px * var(--ui-scale)); }
  .chat-stands .stand { max-width: calc(150px * var(--ui-scale)); }
  .chat-stands .stand img { max-height: calc(150px * var(--ui-scale)); }
  .chat-stands .stand-name { font-size: calc(0.85rem * var(--ui-scale)); }
  .bubble { font-size: calc(1.1rem * var(--ui-scale)); }
  .chat-head strong { font-size: calc(1.15rem * var(--ui-scale)); }
  .chat-input-row input { font-size: calc(1.05rem * var(--ui-scale)); }
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 1rem;
  align-items: start;
}
@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
}

.main, .side {
  background: var(--paper);
  border-radius: 18px;
  padding: 1.1rem 1.15rem;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
  min-width: 0;
}
.side { overflow: hidden; }

.status {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}
.zoom-ctrl {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin-left: auto;
  font-size: 0.85rem;
  color: var(--muted);
  font-weight: 700;
}
.zoom-btn {
  min-width: 2rem;
  padding: 0.2rem 0.45rem !important;
  color: var(--accent-deep) !important;
  border-color: rgba(184, 92, 56, 0.35) !important;
  background: #fff !important;
}
#btnVoice {
  min-width: 3.6rem;
  margin-left: 0.25rem;
}
#btnVoice.off {
  opacity: 0.55;
  text-decoration: line-through;
}
/*
 * 界面缩放：不用 zoom（部分环境对绝对定位对话框缩放异常）。
 * 统一用 --ui-scale 计算字号与对话框尺寸，150% 时对话框/正文会一起变大。
 */
#game {
  font-size: calc(1.05rem * var(--ui-scale));
}
#game .vn-stage {
  min-height: calc(520px * var(--ui-scale));
}
#game .vn-stands {
  inset: 0 0 calc(10.5rem * var(--ui-scale));
}
#game .stand {
  max-width: calc(260px * var(--ui-scale));
}
#game .stand img {
  max-height: calc(340px * var(--ui-scale));
}
#game .stand-name {
  font-size: calc(0.9rem * var(--ui-scale));
}
#game .vn-dialog {
  min-height: calc(9.2rem * var(--ui-scale));
  padding: calc(1.05rem * var(--ui-scale)) calc(1.2rem * var(--ui-scale));
  left: calc(0.9rem * var(--ui-scale));
  right: calc(0.9rem * var(--ui-scale));
  bottom: calc(0.85rem * var(--ui-scale));
}
#game .vn-speaker {
  font-size: calc(1.4rem * var(--ui-scale));
}
#game .vn-text {
  font-size: calc(1.32rem * var(--ui-scale));
  line-height: 1.78;
  min-height: calc(3.8em * var(--ui-scale));
}
#game .vn-next {
  font-size: calc(0.9rem * var(--ui-scale));
}
#game .vn-tag {
  font-size: calc(0.88rem * var(--ui-scale));
}
#game .btn {
  font-size: calc(0.95rem * var(--ui-scale));
  padding: calc(0.55rem * var(--ui-scale)) calc(1rem * var(--ui-scale));
}
#game .phase,
#game .ap {
  font-size: calc(0.95rem * var(--ui-scale));
}
.status strong { color: var(--accent-deep); }

/* —— Visual novel stage —— */
.vn-stage {
  position: relative;
  border-radius: 16px;
  overflow: hidden;
  background: #1a1410;
  min-height: 520px;
  margin-bottom: 0.85rem;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.06);
}
.vn-bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: brightness(0.68) saturate(0.92);
}
.vn-stands {
  position: absolute;
  inset: 0 0 8.2rem;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  pointer-events: none;
  padding: 0 0.75rem;
  z-index: 1;
}
.stand {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 38%;
  max-width: 220px;
  transition: opacity 0.25s, filter 0.25s, transform 0.25s;
}
.stand.left { align-items: flex-start; }
.stand.right { align-items: flex-end; margin-left: auto; }
.stand img {
  width: 100%;
  max-height: 280px;
  object-fit: contain;
  object-position: bottom;
  filter: drop-shadow(0 8px 18px rgba(0,0,0,0.55));
}
.stand.dim {
  opacity: 0.38;
  filter: grayscale(0.35);
  transform: translateY(8px) scale(0.96);
}
.stand.empty {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}
.stand-name {
  margin-top: 0.2rem;
  font-family: var(--font-d);
  font-size: 0.8rem;
  font-weight: 400;
  color: #f5ebe0;
  text-shadow: 0 1px 4px #000;
  background: rgba(0,0,0,0.4);
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
}
.vn-dialog {
  position: absolute;
  left: 0.9rem;
  right: 0.9rem;
  bottom: 0.85rem;
  z-index: 2;
  background:
    linear-gradient(180deg, rgba(36, 28, 20, 0.92), rgba(16, 12, 8, 0.96));
  border: 1px solid rgba(232, 200, 154, 0.42);
  border-radius: 16px;
  padding: 1.05rem 1.2rem 1.05rem;
  color: #f7efe4;
  cursor: pointer;
  min-height: 9.2rem;
  box-shadow:
    0 12px 32px rgba(0,0,0,0.5),
    inset 0 1px 0 rgba(255,255,255,0.08);
  backdrop-filter: blur(2px);
  -webkit-user-select: none;
  user-select: none;
}
.vn-dialog:focus { outline: 2px solid rgba(201, 146, 42, 0.55); outline-offset: 2px; }
.vn-dialog:hover { border-color: rgba(240, 200, 120, 0.55); }
.vn-speaker-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.45rem;
}
.vn-speaker {
  display: inline-block;
  font-family: var(--font-d);
  font-size: 1.4rem;
  color: #f0c878;
  padding: 0.1rem 0.65rem 0.15rem;
  background: rgba(240, 200, 120, 0.12);
  border-left: 3px solid #f0c878;
  border-radius: 0 8px 8px 0;
}
.vn-text {
  font-size: 1.32rem;
  line-height: 1.78;
  min-height: 3.8em;
  white-space: pre-wrap;
  color: #f5ebe0;
}
.vn-next {
  flex-shrink: 0;
  font-size: 0.8rem;
  color: #d4c4a8;
  opacity: 0.9;
  animation: nextPulse 1.4s ease-in-out infinite;
}
@keyframes nextPulse {
  0%, 100% { opacity: 0.55; transform: translateX(0); }
  50% { opacity: 1; transform: translateX(3px); }
}
.vn-tag {
  position: absolute;
  top: 0.65rem;
  left: 0.75rem;
  z-index: 2;
  margin: 0;
  font-size: 0.8rem;
  color: #f0e8dc;
  background: rgba(0,0,0,0.5);
  padding: 0.25rem 0.65rem;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.08);
}

/* dice overlay — body 级，覆盖剧情与对话层 */
.dice-overlay {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(8, 6, 4, 0.55);
  backdrop-filter: blur(2px);
}
.dice-overlay[hidden] { display: none !important; }
.dice-card {
  text-align: center;
  padding: 1.25rem 1.75rem;
  border-radius: 18px;
  background: linear-gradient(165deg, #2a2218, #14100c);
  border: 1px solid rgba(232, 200, 154, 0.4);
  box-shadow: 0 16px 40px rgba(0,0,0,0.55);
  min-width: 180px;
}
.dice-label {
  margin: 0 0 0.65rem;
  font-size: 0.9rem;
  color: #e8c89a;
  font-weight: 700;
}
.dice-face {
  display: inline-flex;
  width: 4.5rem;
  height: 4.5rem;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 30% 30%, #3a3028, #120e0a);
  color: #f0e8dc;
  border-radius: 14px;
  font-size: 1.85rem;
  font-weight: 800;
  border: 2px solid rgba(232, 200, 154, 0.45);
  box-shadow: inset 0 0 12px rgba(0,0,0,0.45);
}
.dice-overlay.rolling .dice-face {
  animation: diceShake 0.08s linear infinite;
}
.dice-overlay.ok .dice-face {
  border-color: #7dceb8;
  color: #b8f0d8;
  box-shadow: 0 0 18px rgba(125, 206, 184, 0.35);
}
.dice-overlay.fail .dice-face {
  border-color: #e8925a;
  color: #ffc8a0;
  box-shadow: 0 0 18px rgba(232, 146, 90, 0.35);
}
.dice-overlay.crit-ok .dice-face {
  border-color: #f0d78c;
  color: #fff3c4;
  box-shadow: 0 0 22px rgba(240, 215, 140, 0.55);
}
.dice-overlay.crit-fail .dice-face {
  border-color: #c45c5c;
  color: #ffb0b0;
  box-shadow: 0 0 22px rgba(196, 92, 92, 0.5);
}
@keyframes diceShake {
  0% { transform: rotate(-8deg) scale(1.02); }
  50% { transform: rotate(8deg) scale(0.98); }
  100% { transform: rotate(-4deg) scale(1.04); }
}
.dice-eq {
  font-size: 0.88rem;
  color: #d4c4a8;
  margin: 0.75rem 0 0;
  max-width: 260px;
  line-height: 1.4;
}

.kicker { margin: 0.35rem 0 0; font-size: 0.85rem; color: var(--muted); }
.kicker.light { color: var(--accent-deep); font-weight: 700; }

.flash-note {
  margin-top: 0.5rem;
  padding: 0.65rem 0.85rem;
  background: rgba(74, 122, 106, 0.12);
  border-left: 3px solid var(--teal);
  font-size: 0.95rem;
  border-radius: 0 8px 8px 0;
}

.btn {
  font: inherit;
  cursor: pointer;
  border: none;
  border-radius: 10px;
  padding: 0.55rem 1rem;
  font-weight: 700;
}
.btn.primary { background: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-deep); }
.btn.secondary { background: #e8dfd2; color: var(--ink); }
.btn.ghost { background: transparent; color: #e8c89a; border: 1px solid rgba(232,200,154,0.35); }
.btn.wide { width: 100%; margin-top: 0.5rem; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.choices { display: flex; flex-direction: column; gap: 0.45rem; margin: 0.5rem 0; }
.npc-row .btn { border-left: 3px solid var(--gold); }

.exit-warn { color: var(--accent-deep); font-size: 0.92rem; margin: 0 0 0.5rem; }

.side h2 { margin: 0 0 0.75rem; font-family: var(--font-d); font-size: 1.2rem; }
.stats { list-style: none; padding: 0; margin: 0 0 1rem; }
.stats li {
  display: grid;
  grid-template-columns: 2.6rem minmax(0, 1fr);
  gap: 0.45rem;
  align-items: center;
  margin-bottom: 0.55rem;
}
.stat-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.5rem;
  align-items: center;
  min-width: 0;
}
.lab { font-size: 0.85rem; color: var(--muted); font-weight: 700; }
.bar {
  height: 10px;
  background: #ddd4c8;
  border-radius: 999px;
  overflow: hidden;
  min-width: 0;
}
.bar i { display: block; height: 100%; background: var(--accent); transition: width 0.3s; border-radius: 999px; }
.bar.hp i { background: #c45c26; }
.bar.san i { background: var(--teal); }
.stat-row strong {
  font-size: 0.88rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  color: var(--ink);
  min-width: 3.2rem;
  text-align: right;
}

.flags-h { margin: 0.75rem 0 0.35rem; font-size: 0.85rem; color: var(--muted); font-weight: 700; }
.flags { list-style: none; padding: 0; margin: 0; font-size: 0.9rem; }
.flags li { padding: 0.25rem 0; border-bottom: 1px solid rgba(0,0,0,0.06); word-break: break-word; }
.flags.items li {
  display: grid;
  grid-template-columns: 40px 1fr;
  gap: 0.55rem;
  align-items: start;
  padding: 0.45rem 0;
  cursor: pointer;
  border-radius: 8px;
}
.flags.items li:hover { background: rgba(184, 92, 56, 0.08); }
.flags.items li img {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  object-fit: cover;
  background: #ddd4c8;
}
.flags.items li strong { display: block; font-size: 0.9rem; }
.flags.items li span { color: var(--muted); font-size: 0.78rem; line-height: 1.35; }
.empty { color: var(--muted); font-style: italic; }

.item-modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(8, 6, 4, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.item-modal-card {
  width: min(380px, 100%);
  background: var(--paper);
  border-radius: 18px;
  padding: 1.25rem 1.35rem 1.1rem;
  text-align: center;
  box-shadow: 0 18px 48px rgba(0,0,0,0.45);
  animation: itemPop 0.28s ease;
}
@keyframes itemPop {
  from { transform: translateY(12px) scale(0.96); opacity: 0; }
  to { transform: none; opacity: 1; }
}
.item-modal-kicker {
  margin: 0 0 0.65rem;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--accent-deep);
  text-transform: uppercase;
}
.item-modal-img {
  width: 96px;
  height: 96px;
  border-radius: 18px;
  object-fit: cover;
  margin: 0 auto 0.75rem;
  display: block;
  box-shadow: 0 8px 20px rgba(0,0,0,0.2);
}
.item-modal-card h3 {
  margin: 0 0 0.45rem;
  font-family: var(--font-d);
  font-size: 1.45rem;
  color: var(--ink);
}
.item-modal-desc {
  margin: 0 0 0.55rem;
  color: var(--muted);
  font-size: 0.95rem;
}
.item-modal-use {
  margin: 0 0 1rem;
  padding: 0.65rem 0.75rem;
  background: rgba(74, 122, 106, 0.12);
  border-radius: 10px;
  color: var(--ink);
  font-size: 0.92rem;
  text-align: left;
  line-height: 1.5;
}
.item-modal-use::before {
  content: "作用 · ";
  font-weight: 700;
  color: var(--teal);
}

.rules { margin-top: 1rem; font-size: 0.85rem; color: var(--muted); }
.rules .t { font-weight: 700; margin: 0 0 0.35rem; color: var(--ink); }
.rules ul { margin: 0; padding-left: 1.1rem; }

.combat-meta { font-weight: 700; margin: 0 0 0.35rem; }
.combat-detail { color: var(--muted); margin: 0 0 0.75rem; }

.end-box { margin-top: 1rem; text-align: center; }
.end-banner { font-family: var(--font-d); font-size: 1.6rem; color: var(--accent-deep); margin: 0; }
.end-summary { margin: 0.75rem 0 1rem; }
.host-actions { display: flex; gap: 0.5rem; justify-content: center; flex-wrap: wrap; }

.chat-layer {
  position: fixed;
  inset: 0;
  background: rgba(8, 6, 4, 0.78);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(1rem * var(--ui-scale));
  z-index: 50;
  /* DeepSeek 对话在 #game 外，必须单独吃 --ui-scale */
  font-size: calc(1.1rem * var(--ui-scale));
}
.chat-layer[hidden] {
  display: none !important;
}
.chat-vn {
  width: min(calc(760px * var(--ui-scale)), 100%);
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  gap: calc(0.5rem * var(--ui-scale));
}
.chat-stands {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  min-height: calc(180px * var(--ui-scale));
  padding: 0 0.5rem;
  pointer-events: none;
}
.chat-stands .stand { width: 34%; max-width: calc(220px * var(--ui-scale)); }
.chat-stands .stand img { max-height: calc(220px * var(--ui-scale)); }
.chat-stands .stand-name {
  font-family: var(--font-d);
  font-size: calc(1.05rem * var(--ui-scale));
  padding: calc(0.2rem * var(--ui-scale)) calc(0.65rem * var(--ui-scale));
}
.chat-panel {
  width: 100%;
  max-height: min(62vh, calc(520px * var(--ui-scale)));
  background: var(--paper);
  border-radius: 18px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.chat-head {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  padding: calc(0.95rem * var(--ui-scale)) calc(1.1rem * var(--ui-scale));
  border-bottom: 1px solid rgba(0,0,0,0.08);
}
.chat-head strong {
  font-size: calc(1.25rem * var(--ui-scale));
  font-family: var(--font-d);
  font-weight: 400;
  color: var(--accent-deep);
}
.chat-head img { border-radius: 10px; object-fit: cover; }
.chat-head .btn.ghost {
  margin-left: auto;
  color: var(--accent-deep);
  border-color: rgba(184, 92, 56, 0.35);
  background: #fff;
  font-size: calc(0.95rem * var(--ui-scale));
  padding: calc(0.45rem * var(--ui-scale)) calc(0.85rem * var(--ui-scale));
}
.api-mini {
  font-size: calc(0.8rem * var(--ui-scale));
  font-weight: 700;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  background: #e8dfd2;
  color: var(--muted);
}
.api-mini.ok { background: rgba(74,122,106,0.2); color: #2a5a4a; }
.api-mini.bad { background: rgba(184,92,56,0.18); color: #8a4028; }
.chat-mutter {
  margin: 0.2rem 0 0;
  font-size: calc(1rem * var(--ui-scale));
  color: var(--muted);
  font-style: italic;
}
.chat-hints {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  padding: calc(0.55rem * var(--ui-scale)) calc(1.1rem * var(--ui-scale));
}
.hint-btn {
  font: inherit;
  font-size: calc(0.95rem * var(--ui-scale));
  padding: calc(0.4rem * var(--ui-scale)) calc(0.75rem * var(--ui-scale));
  border-radius: 999px;
  border: 1px solid rgba(184,92,56,0.35);
  background: #fff;
  cursor: pointer;
}
.chat-log {
  flex: 1;
  overflow-y: auto;
  padding: calc(0.85rem * var(--ui-scale)) calc(1.1rem * var(--ui-scale));
  min-height: calc(140px * var(--ui-scale));
  max-height: calc(280px * var(--ui-scale));
}
.bubble {
  margin: 0 0 calc(0.55rem * var(--ui-scale));
  padding: calc(0.75rem * var(--ui-scale)) calc(0.95rem * var(--ui-scale));
  border-radius: 12px;
  max-width: 92%;
  font-size: calc(1.28rem * var(--ui-scale));
  line-height: 1.75;
}
.bubble.you { margin-left: auto; background: rgba(184,92,56,0.15); }
.bubble.npc {
  background: #e8dfd2;
  font-family: var(--font-b);
}
.bubble.tip {
  max-width: 100%;
  background: rgba(74, 122, 106, 0.12);
  border: 1px dashed rgba(74, 100, 122, 0.35);
  color: #3a4a5a;
  font-size: calc(1.05rem * var(--ui-scale));
  line-height: 1.55;
}
.bubble.typing { opacity: 0.6; font-style: italic; }
.chat-input-row {
  display: flex;
  gap: 0.5rem;
  padding: calc(0.85rem * var(--ui-scale)) calc(1.1rem * var(--ui-scale));
  border-top: 1px solid rgba(0,0,0,0.08);
}
.chat-input-row input {
  flex: 1;
  font: inherit;
  font-size: calc(1.15rem * var(--ui-scale));
  padding: calc(0.65rem * var(--ui-scale)) calc(0.8rem * var(--ui-scale));
  border: 1px solid #ccc4b8;
  border-radius: 8px;
}
.chat-input-row .btn {
  font-size: calc(1.05rem * var(--ui-scale));
  padding: calc(0.6rem * var(--ui-scale)) calc(1.1rem * var(--ui-scale));
}
