/* ============================================================
   牧神记 · 全屏中国神话游戏界面
   配色：墨黑 / 米白 / 朱红 / 青玉 / 金色
   无装饰渐变、无光球；卡片圆角 ≤ 8px
   ============================================================ */

:root {
  /* 墨黑 */
  --ink: #0e0d0a;
  --ink-raised: #16140f;
  --ink-panel: #1b1711;
  --ink-deep: #090806;
  /* 米白 */
  --rice: #eee5d3;
  --rice-dim: #c6bba4;
  /* 朱红 */
  --vermilion: #b23a2a;
  --vermilion-bright: #cf4633;
  /* 青玉 */
  --jade: #7ea793;
  --jade-bright: #a9cfbd;
  /* 金色 */
  --gold: #c9a45c;
  --gold-bright: #e0bd7c;

  --line: rgba(201, 164, 92, 0.3);
  --line-soft: rgba(238, 229, 211, 0.14);
  --radius: 8px;
  --radius-sm: 6px;
  --topbar-h: 52px;
  --actionbar-h: 62px;

  --font-sans: "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", system-ui, sans-serif;
  --font-serif: "Noto Serif CJK SC", "Source Han Serif SC", "Songti SC", "SimSun", serif;
}

.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  overflow: hidden !important;
  clip: rect(0 0 0 0) !important;
  clip-path: inset(50%) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

* {
  box-sizing: border-box;
}

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

body {
  overflow-x: hidden;
  background: var(--ink);
  color: var(--rice);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.6;
}

button,
input {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

img {
  max-width: 100%;
}

.screen {
  min-height: 100%;
}

.hidden {
  display: none !important;
}

/* ---------- 按钮 ---------- */

.btn {
  display: inline-flex;
  min-width: 44px;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  padding: 8px 16px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
  background: var(--ink-raised);
  color: var(--rice);
  cursor: pointer;
  text-decoration: none;
  transition: border-color 0.2s ease, background-color 0.2s ease, color 0.2s ease;
}

.btn:hover {
  border-color: var(--gold);
}

.btn:focus-visible,
.act:focus-visible,
.qa:focus-visible,
.tab:focus-visible,
.drawer-close:focus-visible,
#cmd-input:focus-visible {
  outline: 2px solid var(--gold-bright);
  outline-offset: 2px;
}

.btn.primary {
  border-color: var(--vermilion);
  background: var(--vermilion);
  color: #f7ede0;
  font-weight: 700;
}

.btn.primary:hover {
  border-color: var(--vermilion-bright);
  background: var(--vermilion-bright);
}

.btn.ghost {
  min-height: 44px;
  padding: 5px 12px;
  border-color: var(--line-soft);
  background: transparent;
  color: var(--rice-dim);
}

.btn.ghost:hover {
  border-color: var(--gold);
  color: var(--gold-bright);
}

/* ---------- 进入动画：黑暗退去 / 灯火 / 标题 / 进度 / 跳过 ---------- */

#boot {
  position: fixed;
  inset: 0;
  width: 100%;
  display: grid;
  min-height: 100dvh;
  z-index: 9999;
  place-items: center;
  padding: 24px;
  overflow: hidden;
  background: #000;
  animation: boot-dark-recede 2.2s ease-out both;
}

@keyframes boot-dark-recede {
  0% {
    background-color: #000;
  }
  55% {
    background-color: #070604;
  }
  100% {
    background-color: var(--ink);
  }
}

.boot-stage {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  animation: boot-rise 0.9s ease-out 0.45s both;
}

/* 灯火：朱红灯笼 + 金色火苗 */
.boot-stage::before {
  content: "";
  width: 26px;
  height: 34px;
  margin-bottom: 22px;
  border: 1px solid rgba(14, 13, 10, 0.65);
  border-radius: 4px;
  background: var(--vermilion);
  animation: lantern-flicker 2.6s ease-in-out 1s infinite;
}

.boot-stage::after {
  content: "";
  position: absolute;
  top: -8px;
  left: 50%;
  width: 10px;
  height: 12px;
  transform: translateX(-50%);
  border-radius: 50% 50% 50% 50% / 62% 62% 38% 38%;
  background: var(--gold-bright);
  animation: lantern-flicker 2.6s ease-in-out 1s infinite;
}

@keyframes lantern-flicker {
  0%, 100% {
    opacity: 1;
  }
  8% {
    opacity: 0.72;
  }
  14% {
    opacity: 1;
  }
  36% {
    opacity: 0.84;
  }
  42% {
    opacity: 1;
  }
  64% {
    opacity: 0.78;
  }
  70% {
    opacity: 1;
  }
}

.boot-title {
  margin: 0;
  color: var(--gold-bright);
  font-family: var(--font-serif);
  font-size: clamp(40px, 9vw, 64px);
  font-weight: 800;
  letter-spacing: 0.35em;
  text-indent: 0.35em;
  animation: boot-title-in 1.1s ease-out 0.3s both;
}

@keyframes boot-title-in {
  0% {
    opacity: 0;
    letter-spacing: 0.55em;
  }
  100% {
    opacity: 1;
    letter-spacing: 0.35em;
  }
}

.boot-tagline {
  margin: 14px 0 26px;
  color: var(--rice-dim);
  animation: boot-rise 0.8s ease-out 0.95s both;
}

.boot-progress {
  position: relative;
  width: min(320px, 70vw);
  height: 4px;
  overflow: visible;
  border-radius: 2px;
  background: rgba(238, 229, 211, 0.14);
  animation: boot-rise 0.8s ease-out 0.12s both;
}

.boot-progress-bar {
  width: 0;
  height: 100%;
  border-radius: 2px;
  background: var(--gold);
  transition: width 0.12s ease;
}

.boot-progress-value {
  position: absolute;
  top: 10px;
  left: 50%;
  color: var(--rice-dim);
  font-size: 12px;
  line-height: 1;
  transform: translateX(-50%);
  white-space: nowrap;
}

@keyframes boot-progress-fill {
  0% {
    width: 0;
  }
  55% {
    width: 68%;
  }
  78% {
    width: 82%;
  }
  100% {
    width: 100%;
  }
}

#boot .btn.ghost {
  margin-top: 20px;
  animation: boot-rise 0.7s ease-out 1.55s both;
}

@keyframes boot-rise {
  0% {
    opacity: 0;
    transform: translateY(14px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ---------- 未登录：全屏主视觉，官方背景清晰可见 ---------- */

#unauth {
  position: relative;
  display: grid;
  min-height: 100dvh;
  place-items: center;
  padding: 24px;
  overflow: hidden;
  background: var(--ink);
}

.unauth-art {
  position: absolute;
  inset: 0;
  background-repeat: no-repeat;
  background-position: center;
  background-size: cover;
  animation: scene-switch 0.9s ease-out both;
}

.unauth-box {
  position: relative;
  z-index: 1;
  width: min(100%, 400px);
  padding: 30px 26px;
  text-align: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(14, 13, 10, 0.88);
  animation: boot-rise 1s ease-out 0.3s both;
}

.brand {
  color: var(--gold-bright);
  font-family: var(--font-serif);
  font-size: 32px;
  font-weight: 800;
  letter-spacing: 0.18em;
  text-indent: 0.18em;
}

.tagline {
  margin: 12px 0 26px;
  color: var(--rice-dim);
}

.btn-login {
  width: 100%;
  min-height: 48px;
}

.invite-form {
  display: grid;
  gap: 10px;
  margin: 14px 0;
}

#invite-code,
#linuxdo-username {
  width: 100%;
  height: 44px;
  padding: 0 14px;
  font-size: 14px;
  text-align: center;
  color: var(--rice);
  background: rgba(22, 20, 16, 0.95);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  box-sizing: border-box;
}

#invite-code:focus,
#linuxdo-username:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 2px rgba(212, 175, 55, 0.2);
}

.invite-hint {
  margin: 0;
  font-size: 12px;
  color: var(--rice-dim);
  text-align: center;
  line-height: 1.4;
  transition: color 0.2s ease;
}

.invite-hint.error {
  color: var(--vermilion-bright);
}

.bind-hint {
  color: #b23a2a;
  font-size: 12px;
  margin: 4px 0 0;
  text-align: center;
  line-height: 1.5;
}

.bind-hint a {
  color: var(--gold-bright);
  text-decoration: underline;
}

.login-divider {
  text-align: center;
  color: #9a8c7d;
  font-size: 12px;
  margin: 8px 0;
}


/* ---------- 游戏主界面：固定 100dvh ---------- */

#game {
  display: flex;
  height: 100vh;
  height: 100dvh;
  flex-direction: column;
  overflow: hidden;
  background: var(--ink);
}

/* ---------- 顶栏（尺寸稳定） ---------- */

.topbar {
  position: relative;
  z-index: 5;
  display: flex;
  height: var(--topbar-h);
  min-height: var(--topbar-h);
  flex: none;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  border-bottom: 1px solid var(--line);
  background: var(--ink-raised);
}

.brand-sm {
  flex: none;
  max-width: 240px;
  overflow: hidden;
  color: var(--gold-bright);
  font-family: var(--font-serif);
  font-weight: 800;
  letter-spacing: 0.08em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar-status {
  display: flex;
  min-width: 0;
  margin-left: auto;
  align-items: center;
  gap: 14px;
}

.player-avatar {
  width: 38px;
  height: 38px;
  flex: none;
  border: 1px solid rgba(231, 194, 111, 0.78);
  border-radius: 50%;
  object-fit: cover;
  object-position: center 24%;
  box-shadow: 0 0 0 2px rgba(84, 53, 112, 0.44), 0 0 18px rgba(186, 123, 230, 0.26);
}

.player-name {
  min-width: 0;
  max-width: 30vw;
  overflow: hidden;
  color: var(--rice);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.admin-title {
  flex: none;
  padding: 3px 7px;
  border: 1px solid rgba(194, 137, 230, 0.5);
  border-radius: 4px;
  color: #ead9f7;
  background: rgba(91, 49, 117, 0.34);
  font-family: var(--font-serif);
  font-size: 11px;
  white-space: nowrap;
}

/* ---------- 顶栏与聊天流称号品质徽章与光晕特效 ---------- */
@keyframes title-pulse-gold {
  0%, 100% { box-shadow: 0 0 6px rgba(212, 160, 23, 0.4), inset 0 0 4px rgba(212, 160, 23, 0.2); }
  50% { box-shadow: 0 0 12px rgba(212, 160, 23, 0.8), inset 0 0 8px rgba(212, 160, 23, 0.4); }
}
@keyframes title-pulse-purple {
  0%, 100% { box-shadow: 0 0 4px rgba(155, 114, 207, 0.3); }
  50% { box-shadow: 0 0 8px rgba(155, 114, 207, 0.6); }
}

.player-title {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 3px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.2;
  margin-right: 4px;
  vertical-align: middle;
}
.player-title.rarity-basic { border: 1px solid rgba(136, 176, 160, 0.4); color: #a8d8c0; background: rgba(18, 24, 22, 0.6); }
.player-title.rarity-sect { border: 1px solid rgba(194, 94, 64, 0.6); color: #f08a6c; background: rgba(32, 18, 16, 0.6); }
.player-title.rarity-rare { border: 1px solid rgba(155, 114, 207, 0.7); color: #caa8f5; background: rgba(26, 18, 36, 0.6); animation: title-pulse-purple 3s infinite; }
.player-title.rarity-legendary { border: 1px solid rgba(212, 160, 23, 0.9); color: #ffd700; background: linear-gradient(180deg, #2a1f0f, #120e0a); animation: title-pulse-gold 2.5s infinite; }

.chat-sender-title {
  font-size: 11px;
  padding: 0 4px;
  border-radius: 2px;
  margin-right: 3px;
  opacity: 0.9;
}
.chat-sender-title.rarity-basic { border: 1px solid rgba(136, 176, 160, 0.4); color: #a8d8c0; background: rgba(18, 24, 22, 0.6); }
.chat-sender-title.rarity-sect { border: 1px solid rgba(194, 94, 64, 0.6); color: #f08a6c; background: rgba(32, 18, 16, 0.6); }
.chat-sender-title.rarity-rare { border: 1px solid rgba(155, 114, 207, 0.7); color: #caa8f5; background: rgba(26, 18, 36, 0.6); }
.chat-sender-title.rarity-legendary { border: 1px solid rgba(212, 160, 23, 0.9); color: #ffd700; background: linear-gradient(180deg, #2a1f0f, #120e0a); }

.topbar-status > .player-title {
  flex: none;
  font-family: var(--font-serif);
  font-size: 12px;
  white-space: nowrap;
}

.stat-hp {
  flex: none;
  color: var(--jade);
  font-weight: 700;
  white-space: nowrap;
}

.stat-realm {
  flex: none;
  color: var(--gold);
  white-space: nowrap;
}

.stat-currency {
  flex: none;
  color: var(--gold-bright);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.stat-spirit {
  min-width: 44px;
  min-height: 44px;
  max-width: 10rem;
  flex: 0 1 auto;
  padding: 4px 8px;
  overflow: hidden;
  border: 1px solid rgba(126, 167, 147, 0.5);
  border-radius: var(--radius-sm);
  background: rgba(36, 71, 55, 0.28);
  color: var(--jade-bright);
  cursor: pointer;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stat-spirit:hover,
.stat-spirit:focus-visible {
  border-color: var(--jade);
  outline: 0;
}

#btn-logout {
  min-height: 44px;
  padding: 4px 12px;
  font-size: 13px;
}

/* ---------- 场景：全幅，背景图铺满 ---------- */

.scene {
  position: relative;
  display: grid;
  min-height: 0;
  flex: 1 1 auto;
  grid-template-columns: clamp(270px, 21vw, 320px) minmax(0, 1fr) clamp(280px, 23vw, 340px);
  grid-template-areas: "world stage activity";
  gap: 12px;
  padding: 12px;
  overflow: hidden;
  background: var(--ink);
}

/* 三档布局容器：桌面三栏 / 平板两栏 / 手机单栏（HTML 已定义唯一归属，不做 DOM 搬动） */
.world-context {
  grid-area: world;
  display: flex;
  min-width: 0;
  min-height: 0;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.scene-stage {
  grid-area: stage;
  position: relative;
  display: flex;
  min-width: 0;
  min-height: 0;
  flex-direction: column;
}

.activity-rail {
  grid-area: activity;
  min-width: 0;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.scene-viz {
  position: absolute;
  inset: 0;
  z-index: 0;
  background-repeat: no-repeat;
  background-position: center;
  background-size: cover;
  transition: opacity 0.45s ease;
  animation: scene-switch 0.9s ease-out both;
}

/* 场景切换：淡入，无闪烁无光晕 */
@keyframes scene-switch {
  0% {
    opacity: 0;
    transform: scale(1.03);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

/* 热点：玩家 / 出口 / NPC / 敌人 可辨 */
.hotspot {
  position: absolute;
  display: inline-flex;
  min-width: 44px;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  padding: 4px 10px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
  background: rgba(14, 13, 10, 0.8);
  color: var(--rice);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

/* NPC 热点小头像：仅作标识，加载失败只隐藏小图（.hidden），不用主视觉当头像 */
.npc-mini {
  width: 22px;
  height: 22px;
  flex: none;
  margin-right: 6px;
  border: 1px solid var(--line-soft);
  border-radius: 50%;
  object-fit: cover;
  object-position: center 24%;
  vertical-align: middle;
}

.npc-mini-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  flex: none;
  margin-right: 6px;
  border: 1px solid var(--line-soft);
  border-radius: 50%;
  background: var(--ink-panel);
  color: var(--gold-bright);
  font-size: 12px;
  font-family: var(--font-serif);
  font-weight: 700;
  vertical-align: middle;
  user-select: none;
}

.hotspot-player {
  border-color: var(--gold);
  background: rgba(14, 13, 10, 0.88);
  color: var(--gold-bright);
  right: 14px;
  bottom: 14px;
}

/* 同房玩家热点：在热点栏内并排换行，不继承浮动偏移，避免重叠 */
.scene-hotspots button.hotspot-player {
  position: relative;
  right: auto;
  bottom: auto;
}

/* 玩家显示：头像 + [称号] 名称 + 角色小字（专用类，不触碰顶栏样式） */
.player-display {
  display: inline-flex;
  max-width: 100%;
  align-items: center;
  vertical-align: middle;
}

.room-player-avatar {
  width: 1.3em;
  height: 1.3em;
  flex: none;
  margin-right: 0.25em;
  border: 0;
  border-radius: 50%;
  object-fit: cover;
  object-position: center;
  box-shadow: none;
  vertical-align: middle;
}

.room-player-name {
  min-width: 0;
  overflow-wrap: anywhere;
  white-space: normal;
}

.room-player-role {
  flex: none;
  margin-left: 0.4em;
  font-size: 0.8em;
  opacity: 0.75;
}

.scene-img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
}

.scene-img.scene-fallback {
  background: var(--ink-deep);
}

.scene-hotspots {
  position: relative;
  z-index: 1;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  width: 100%;
  margin: 0;
  pointer-events: none;
}

.scene-hotspots.empty {
  display: none;
}

.scene-hotspots button {
  position: relative;
  pointer-events: auto;
  min-width: 44px;
  min-height: 44px;
  padding: 4px 10px;
  border: 1px solid var(--jade);
  border-radius: var(--radius-sm);
  background: rgba(14, 13, 10, 0.8);
  color: var(--jade-bright);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.scene-hotspots button[data-kind="npc"],
.scene-hotspots button[data-type="npc"] {
  border-color: var(--gold);
  color: var(--gold-bright);
}

.scene-hotspots button[data-kind="enemy"],
.scene-hotspots button[data-type="enemy"],
.scene-hotspots button[data-kind="monster"],
.scene-hotspots button[data-type="monster"] {
  border-color: var(--vermilion);
  color: #f3bdb3;
}

.scene-hotspots button.locked,
.room-exits .exit-chip.locked {
  border-color: var(--line-soft);
  background: rgba(14, 13, 10, 0.56);
  color: var(--rice-dim);
  cursor: not-allowed;
  opacity: 0.72;
}

/* 场景信息面板 */
.room-card,
.quest-strip,
.log {
  position: relative;
  z-index: 1;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: rgba(14, 13, 10, 0.88);
}

.room-card {
  width: 100%;
  margin: 0;
  padding: 14px 16px;
  animation: panel-in 0.6s ease-out 0.15s both;
}

@keyframes panel-in {
  0% {
    opacity: 0;
    transform: translateY(10px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

.room-name {
  margin: 0 0 6px;
  color: var(--gold-bright);
  font-family: var(--font-serif);
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 0.06em;
}

.room-desc {
  margin: 0;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
  font-size: 14px;
}

/* 场景危险警语：克制呈现，无弹窗、无红点、无倒计时 */
#room-ambient {
  margin: 10px 0 0;
  padding: 6px 10px 6px 12px;
  border-left: 2px solid var(--jade);
  background: rgba(126, 167, 147, 0.07);
  color: var(--jade);
  font-family: var(--font-serif);
  font-size: 13px;
  line-height: 1.6;
  letter-spacing: 0.05em;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

#room-ambient.stable {
  border-left-color: var(--jade);
  color: var(--jade);
}

#room-ambient.weak {
  border-left-color: var(--gold);
  background: rgba(201, 164, 92, 0.07);
  color: var(--gold);
}

#room-ambient.dark {
  border-left-color: var(--vermilion);
  background: rgba(178, 58, 42, 0.08);
  color: var(--vermilion-bright);
}

@media (max-width: 430px) {
  #room-ambient {
    padding: 5px 8px 5px 10px;
    font-size: 12px;
  }
}

.room-exits {
  display: none;
  margin-top: 10px;
  color: var(--jade);
  overflow-wrap: anywhere;
  font-size: 13px;
}

.quest-strip {
  position: relative;
  z-index: 2;
  width: 100%;
  padding: 12px 14px;
  animation: panel-in 0.6s ease-out 0.3s both;
}

.quest-strip.hidden {
  display: none !important;
}

.quest-title {
  margin: 0 0 8px;
  color: var(--gold);
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0.1em;
}

.quest-list {
  margin: 0;
  padding: 0;
  list-style: none;
  color: var(--rice-dim);
  font-size: 13px;
}

.quest-list li {
  padding: 4px 0;
  border-bottom: 1px solid var(--line-soft);
  overflow-wrap: anywhere;
}

.quest-list li:last-child {
  border-bottom: 0;
}

/* 事件记录：新行浮现（治疗 / 受击等反馈） */
.log {
  flex: 0 1 auto;
  width: 100%;
  max-height: min(24vh, 180px);
  margin: auto 0 0;
  padding: 12px 14px;
  overflow-y: auto;
  font-size: 14px;
  animation: panel-in 0.6s ease-out 0.45s both;
}

.log:empty {
  display: none;
}

.log-line {
  margin-bottom: 8px;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
  animation: heal-rise 0.45s ease-out both;
}

@keyframes heal-rise {
  0% {
    opacity: 0;
    transform: translateY(10px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

.log-cmd {
  color: var(--gold-bright);
}

.log-err {
  color: var(--vermilion-bright);
}

.log-sys {
  color: var(--rice-dim);
}

.command-actions {
  position: relative;
  z-index: 4;
  display: flex;
  width: 100%;
  min-width: 0;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 14px 14px;
}

.command-actions.hidden {
  display: none !important;
}

.command-actions .qa {
  flex: 1 1 132px;
  min-width: 44px;
  min-height: 44px;
  text-align: center;
}

/* 战斗 HUD（受击动画） */
.combat-hud {
  position: absolute;
  z-index: 3;
  bottom: 18px;
  left: 50%;
  width: min(420px, calc(100% - 28px));
  padding: 12px 16px;
  transform: translateX(-50%);
  border: 1px solid var(--vermilion);
  border-radius: var(--radius);
  background: rgba(14, 13, 10, 0.92);
}

.combat-hud:not(.hidden) {
  animation: combat-hit 0.5s cubic-bezier(0.2, 0.9, 0.3, 1.15) both;
}

/* 战斗 HUD 出现时给日志让位：日志上抬，不被 HUD 遮挡 */
.scene-stage:has(.combat-hud:not(.hidden)) .log {
  margin-bottom: 132px;
}

@keyframes combat-hit {
  0% {
    opacity: 0;
    transform: translateX(-50%) translateY(16px) scale(0.96);
  }
  35% {
    opacity: 1;
    transform: translateX(-50%) translateY(0) scale(1.02);
  }
  100% {
    opacity: 1;
    transform: translateX(-50%) translateY(0) scale(1);
  }
}

.combat-target {
  margin-bottom: 8px;
  color: var(--vermilion-bright);
  font-family: var(--font-serif);
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 0.04em;
  overflow-wrap: anywhere;
}

.combat-bar {
  height: 8px;
  overflow: hidden;
  border-radius: 4px;
  background: rgba(238, 229, 211, 0.14);
}

.combat-bar-fill {
  width: 100%;
  height: 100%;
  border-radius: 4px;
  background: var(--vermilion);
  transition: width 0.35s ease, background-color 0.35s ease;
}

/* 独立生命文字节点：与战斗血条分离，不写回 combat-bar 容器 */
.combat-bar-text {
  margin-top: 6px;
  overflow-wrap: anywhere;
  color: var(--rice-dim);
  font-size: 12px;
  line-height: 1.5;
  text-align: right;
  white-space: nowrap;
}

/* ---------- 底部行动栏（尺寸稳定，触控 ≥ 44px） ---------- */

.actionbar {
  position: relative;
  z-index: 5;
  display: grid;
  height: var(--actionbar-h);
  min-height: var(--actionbar-h);
  flex: none;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 8px;
  padding: 8px 12px calc(8px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: var(--ink-raised);
}

.act {
  min-width: 44px;
  min-height: 44px;
  padding: 6px 4px;
  overflow: hidden;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
  background: var(--ink-panel);
  color: var(--rice);
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: border-color 0.2s ease, color 0.2s ease, background-color 0.2s ease;
}

.act:hover {
  border-color: var(--gold);
  color: var(--gold-bright);
}

#act-attack {
  border-color: rgba(178, 58, 42, 0.55);
  color: #f0b3a8;
}

#act-attack:hover {
  border-color: var(--vermilion-bright);
  color: #ffd9d0;
}

#act-observe {
  border-color: rgba(126, 167, 147, 0.5);
  color: #bcd8c9;
}

#act-observe:hover {
  border-color: var(--jade);
  color: var(--jade-bright);
}

#act-talk {
  border-color: rgba(238, 229, 211, 0.35);
  color: var(--rice);
}

#act-move {
  border-color: rgba(201, 164, 92, 0.5);
  color: #e5cd9c;
}

#act-move:hover {
  border-color: var(--gold);
  color: var(--gold-bright);
}

#act-inventory,
#act-more {
  color: var(--rice-dim);
}

/* ---------- 抽屉：从边缘进入 ---------- */

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 60;
  display: flex;
  width: min(420px, 92vw);
  height: 100vh;
  height: 100dvh;
  flex-direction: column;
  overflow-y: auto;
  overscroll-behavior: contain;
  border-left: 1px solid var(--line);
  background: var(--ink-raised);
  animation: drawer-in 0.3s ease-out both;
}

#drawer-npc-dialog {
  right: auto;
  left: 0;
  border-right: 1px solid var(--line);
  border-left: 0;
  animation-name: drawer-in-left;
}

@keyframes drawer-in {
  0% {
    transform: translateX(100%);
  }
  100% {
    transform: translateX(0);
  }
}

@keyframes drawer-in-left {
  0% {
    transform: translateX(-100%);
  }
  100% {
    transform: translateX(0);
  }
}

.drawer-head {
  display: flex;
  min-height: 52px;
  flex: none;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 16px;
  border-bottom: 1px solid var(--line);
}

.drawer-head h2 {
  margin: 0;
  color: var(--gold-bright);
  font-family: var(--font-serif);
  font-size: 17px;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.drawer-close {
  width: 44px;
  height: 44px;
  flex: none;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--rice-dim);
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
  transition: border-color 0.2s ease, color 0.2s ease;
}

.drawer-close:hover {
  border-color: var(--vermilion);
  color: var(--vermilion-bright);
}

/* NPC 交谈 */
.npc-portrait-wrap {
  display: flex;
  justify-content: center;
  align-items: center;
  margin: 16px auto 6px;
  position: relative;
  width: 88px;
  height: 88px;
}

.npc-portrait {
  width: 88px;
  height: 88px;
  flex: none;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--ink-panel);
  background-position: center;
  background-size: cover;
}

.npc-portrait-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 88px;
  height: 88px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--ink-panel);
  color: var(--gold-bright);
  font-size: 36px;
  font-family: var(--font-serif);
  font-weight: 700;
  user-select: none;
}

.npc-intro {
  margin: 6px 20px 4px;
  font-size: 13px;
  color: var(--rice-dim);
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.npc-responsibility {
  margin: 2px 20px 8px;
  font-size: 13px;
  color: var(--gold);
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.npc-line {
  margin: 10px 20px 14px;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
  font-size: 15px;
}

.npc-choices {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 0 20px 20px;
}

/* 可选差事：available 差事只在发布 NPC 抽屉出现 */
.npc-quests {
  padding: 0 20px 20px;
}

.npc-quests h3 {
  margin: 4px 0 8px;
  color: var(--gold);
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0.1em;
}

.npc-quest {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line-soft);
  overflow-wrap: anywhere;
}

.npc-quest:last-child {
  border-bottom: 0;
}

.npc-quest-info {
  min-width: 0;
  flex: 1 1 auto;
  color: var(--rice-dim);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.npc-quest-take {
  flex: none;
  min-width: 44px;
  min-height: 44px;
  padding: 6px 12px;
  border: 1px solid var(--jade);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--jade-bright);
  cursor: pointer;
}

.npc-quest-take:hover {
  border-color: var(--jade-bright);
}

/* 背包 */
.tabs {
  display: grid;
  flex: none;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
  margin: 14px 16px 8px;
}

.tab {
  min-width: 44px;
  min-height: 44px;
  padding: 6px 2px;
  overflow: hidden;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
  background: var(--ink-panel);
  color: var(--rice-dim);
  cursor: pointer;
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: border-color 0.2s ease, color 0.2s ease, background-color 0.2s ease;
}

.tab:hover {
  border-color: var(--gold);
  color: var(--gold-bright);
}

.tab.active {
  border-color: var(--gold);
  background: var(--gold);
  color: #1a1408;
  font-weight: 800;
}

.bag-list {
  margin: 0;
  padding: 4px 16px 20px;
  list-style: none;
  font-size: 14px;
}

.bag-list li {
  padding: 9px 0;
  border-bottom: 1px solid var(--line-soft);
  overflow-wrap: anywhere;
}

.bag-list li:last-child {
  border-bottom: 0;
}

.bag-empty {
  color: var(--rice-dim);
}

/* 队伍与任务 */
.party-panel,
.quest-detail {
  padding: 12px 16px;
}

.party-panel h3,
.quest-detail h3 {
  margin: 4px 0 8px;
  color: var(--gold);
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0.1em;
}

.party-list,
.quest-detail-list {
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 14px;
  color: var(--rice-dim);
}

.party-list li,
.quest-detail-list li {
  padding: 6px 0;
  border-bottom: 1px solid var(--line-soft);
  overflow-wrap: anywhere;
}

.party-list li:last-child,
.quest-detail-list li:last-child {
  border-bottom: 0;
}

.party-actions,
.party-events {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 8px 0 14px;
}

.party-actions button,
.party-event {
  min-height: 44px;
  padding: 7px 12px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
  background: var(--ink-deep);
  color: var(--rice);
  cursor: pointer;
}

.party-event:hover,
.party-actions button:hover {
  border-color: var(--gold);
}

.party-cooperation {
  margin: 8px 0 14px;
  padding: 10px 0;
  border-top: 1px solid var(--line-soft);
}

.party-cooperation-note {
  margin: 0 0 8px;
  color: var(--rice-dim);
  font-size: 13px;
  line-height: 1.6;
}

.party-cooperation-roles {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.party-cooperation-role {
  min-width: 44px;
  min-height: 44px;
  padding: 7px 12px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
  background: var(--ink-deep);
  color: var(--rice);
  cursor: pointer;
}

.party-cooperation-role:hover {
  border-color: var(--gold);
}

.party-cooperation-choices {
  margin: 8px 0 0;
  padding: 0;
  list-style: none;
  color: var(--rice-dim);
  font-size: 12px;
}

.party-cooperation-choices li {
  padding: 3px 0;
}

/* 独行入口：请当地人物相助（用 solo_command），与真人组队按钮区分 */
.party-event.solo {
  border-color: rgba(126, 167, 147, 0.55);
  color: var(--jade-bright);
}

.party-event.solo:hover {
  border-color: var(--jade);
}

.nearby-note {
  margin: 6px 0 0;
  color: var(--rice-dim);
  font-size: 12px;
}

/* 附近玩家操作：查看 / 招呼（≥44px 触控目标，不继承热点浮动） */
.nearby-actions {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 6px 0 2px;
}

.nearby-actions button.nearby-action,
.party-invitation-actions button.nearby-action {
  min-width: 44px;
  min-height: 44px;
  padding: 6px 14px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
  background: var(--ink-deep);
  color: var(--rice);
  font-size: 13px;
  cursor: pointer;
}

.nearby-actions button.nearby-action:hover,
.party-invitation-actions button.nearby-action:hover {
  border-color: var(--gold);
}

.nearby-actions button.nearby-action.greet {
  border-color: rgba(126, 167, 147, 0.55);
  color: var(--jade-bright);
}

.nearby-actions button.nearby-action.greet:hover {
  border-color: var(--jade);
}

.party-invitations {
  margin: 8px 0 12px;
}

.party-invitation-list {
  margin: 0;
  padding: 0;
  list-style: none;
  color: var(--rice-dim);
  font-size: 14px;
}

.party-invitation-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line-soft);
}

.party-invitation-item:last-child {
  border-bottom: 0;
}

.party-invitation-text {
  flex: 1 1 180px;
  min-width: 0;
  overflow-wrap: anywhere;
}

.party-invitation-actions {
  display: inline-flex;
  flex: 0 1 auto;
  flex-wrap: wrap;
  gap: 8px;
}

.nearby-action.accept,
.nearby-action.invite,
.player-action-btn.invite {
  border-color: rgba(126, 167, 147, 0.55);
  color: var(--jade-bright);
}

.nearby-action.accept:hover,
.nearby-action.invite:hover,
.player-action-btn.invite:hover {
  border-color: var(--jade);
}

.nearby-action.decline {
  border-color: rgba(196, 90, 90, 0.5);
}

/* 随处游历：当前房间项目优先，同章去处其后；参与按钮发服务端命令 */
.roam-panel {
  padding: 12px 16px;
}

.roam-panel h3 {
  margin: 4px 0 8px;
  color: var(--gold);
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0.1em;
}

.roam-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.roam-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 0;
  border-bottom: 1px solid var(--line-soft);
  overflow-wrap: anywhere;
}

.roam-item:last-child {
  border-bottom: 0;
}

.roam-name {
  min-width: 0;
  flex: 1 1 auto;
  color: var(--rice-dim);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.roam-goal .roam-name {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 3px 8px;
}

.roam-goal .roam-name strong {
  min-width: 0;
}

.roam-optional {
  align-self: center;
  color: #1f6a50;
  font-size: 11px;
  font-weight: 700;
}

.roam-prompt {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.topbar-entry {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.roam-go {
  flex: none;
  min-width: 44px;
  min-height: 44px;
  padding: 6px 12px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
  background: var(--ink-deep);
  color: var(--rice);
  cursor: pointer;
}

.roam-go:hover {
  border-color: var(--gold);
  color: var(--gold-bright);
}

/* 更多命令：常驻 MUD 指令栏（已移入 #game，位于 scene 与 actionbar 之间） */
.cmd-form {
  position: relative;
  z-index: 5;
  display: flex;
  flex: none;
  flex-wrap: nowrap;
  gap: 8px;
  padding: 8px 12px;
  border-top: 1px solid var(--line);
  background: var(--ink-raised);
}

.cmd-form input,
.cmd-form button {
  min-height: 44px;
}

#cmd-input {
  min-width: 0;
  min-height: 44px;
  flex: 1;
  padding: 9px 12px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
  outline: 0;
  background: var(--ink-deep);
  color: var(--rice);
  transition: border-color 0.2s ease;
}

#cmd-input::placeholder {
  color: rgba(238, 229, 211, 0.4);
}

#cmd-input:focus-visible {
  border-color: var(--gold);
}

#cmd-send {
  flex: none;
  min-width: 76px;
}

.more-commands {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 0;
  padding: 8px 16px 20px;
  list-style: none;
}

.more-commands .qa {
  text-align: center;
}

.qa {
  min-width: 44px;
  min-height: 44px;
  padding: 8px 12px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
  background: var(--ink-panel);
  color: var(--rice);
  cursor: pointer;
  font-size: 14px;
  overflow-wrap: anywhere;
  text-align: left;
  transition: border-color 0.2s ease, color 0.2s ease;
}

.qa:hover {
  border-color: var(--jade);
  color: var(--jade-bright);
}

/* ---------- 奖励 / 提示（弹出动画） ---------- */

.toast {
  position: fixed;
  z-index: 100;
  pointer-events: none;
  bottom: calc(20px + env(safe-area-inset-bottom));
  left: 50%;
  max-width: min(560px, calc(100vw - 32px));
  padding: 12px 20px;
  transform: translateX(-50%);
  border: 1px solid var(--gold);
  border-radius: var(--radius-sm);
  background: var(--ink-raised);
  color: var(--gold-bright);
  font-weight: 700;
  text-align: center;
  overflow-wrap: anywhere;
}

.toast:not(.hidden) {
  animation: reward-pop 0.5s cubic-bezier(0.2, 0.9, 0.3, 1.15) both;
}

@keyframes reward-pop {
  0% {
    opacity: 0;
    transform: translateX(-50%) translateY(18px) scale(0.92);
  }
  100% {
    opacity: 1;
    transform: translateX(-50%) translateY(0) scale(1);
  }
}

/* ---------- 其他 ---------- */

.noscript-hint {
  padding: 14px 16px;
  background: var(--vermilion);
  color: #f7ede0;
  font-weight: 700;
  text-align: center;
}

::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-thumb {
  border-radius: 4px;
  background: rgba(201, 164, 92, 0.4);
}

::-webkit-scrollbar-track {
  background: transparent;
}

/* ---------- 平板：600-1099（横屏右轨 / 竖屏上场景下双列） ---------- */

@media (min-width: 600px) and (max-width: 1099px) {
  .scene {
    grid-template-columns: minmax(0, 1fr) clamp(260px, 30vw, 300px);
    grid-template-rows: auto minmax(0, 1fr);
    grid-template-areas:
      "stage world"
      "stage activity";
    gap: 10px;
    padding: 10px;
  }

  /* 竖屏（600-1099 全部竖屏）：场景在上、world / activity 两列在下，不再单列长堆 */
  @media (orientation: portrait) {
    .scene {
      grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
      grid-template-rows: minmax(0, 1fr) minmax(0, 1fr);
      grid-template-areas:
        "stage stage"
        "world activity";
    }
  }
}

/* 横屏矮屏（如 844x390 手机横屏）：右轨 world / activity 各占一半高度、各自滚动，
   .activity-rail 高度永不为 0；抽屉保持 fixed 覆盖层（z-index 50），不挤占场景网格 */
@media (min-width: 600px) and (max-width: 1099px) and (orientation: landscape) and (max-height: 600px) {
  .scene {
    grid-template-rows: minmax(0, 1fr) minmax(0, 1fr);
  }
}

/* ---------- 桌面：三栏（>= 1100） ---------- */

@media (min-width: 1100px) {
  .scene {
    grid-template-columns: clamp(270px, 21vw, 320px) minmax(0, 1fr) clamp(280px, 23vw, 340px);
    grid-template-areas: "world stage activity";
    gap: 14px;
    padding: 14px;
  }
}

/* ---------- 超宽屏：>= 1920 内容限宽 2160 并居中，页面背景铺满 ---------- */

@media (min-width: 1920px) {
  .scene,
  .cmd-form,
  .actionbar {
    width: 100%;
    max-width: 2160px;
    margin-inline: auto;
  }
}

/* ---------- 中窄屏通用微调 ---------- */

@media (max-width: 860px) {
  .topbar {
    gap: 8px;
    padding-inline: 10px;
  }

  .topbar-status {
    gap: 8px;
  }

  .stat-hp,
  .stat-realm,
  .stat-spirit {
    font-size: 13px;
  }

  #hotspot-player {
    right: 10px;
    bottom: 10px;
  }

  .combat-hud {
    bottom: 10px;
  }

  .actionbar {
    gap: 6px;
    padding-inline: 8px;
  }

  .act {
    font-size: 13px;
  }

  .drawer {
    width: min(400px, 92vw);
  }

  .brand {
    font-size: 28px;
  }
}

@media (max-width: 640px) {
  .drawer {
    width: 100vw;
  }

  .scene-hotspots {
    gap: 6px;
  }

  .scene-hotspots button {
    flex: 1 1 auto;
  }
}

/* ---------- 手机：单栏纵向（world → scene-stage → activity） ---------- */

@media (max-width: 599px) {
  .scene {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(260px, 44dvh) auto;
    grid-template-areas:
      "world"
      "stage"
      "activity";
    gap: 10px;
    padding: 10px;
    overflow-y: auto;
    overflow-x: hidden;
    overscroll-behavior: contain;
  }

  .world-context,
  .activity-rail {
    min-height: 0;
    max-height: 34dvh;
    overflow-y: auto;
    overflow-x: hidden;
  }

  .scene-hotspots {
    position: relative;
    max-height: 144px;
    flex-wrap: wrap;
    overflow-y: auto;
    overflow-x: hidden;
  }

  .scene-stage {
    position: relative;
    min-height: clamp(260px, 44dvh, 380px);
    overflow: hidden;
    isolation: isolate;
  }

  .scene-viz {
    position: absolute;
    inset: 0;
    z-index: 0;
    width: 100%;
    height: 100%;
    min-height: 0;
    border-radius: var(--radius);
    overflow: hidden;
  }

  .log {
    position: relative;
    z-index: 2;
    width: 100%;
    max-height: 40%;
    margin: auto 0 0;
    overflow-y: auto;
    background: rgba(14, 13, 10, 0.88);
  }

  .combat-hud {
    bottom: 10px;
  }

  /* 行动栏 7 项：4 列 2 行，全部保留，触控 ≥ 44px */
  .actionbar {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    grid-auto-rows: minmax(44px, auto);
    height: auto;
    min-height: auto;
    gap: 6px;
    padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
  }

  .act {
    min-height: 44px;
    font-size: 13px;
  }

  /* 命令栏可达：保持横向可用并贴底 */
  .cmd-form {
    flex-wrap: nowrap;
    gap: 6px;
    padding: 8px calc(10px + env(safe-area-inset-left)) 8px calc(10px + env(safe-area-inset-right));
  }
}

@media (max-width: 430px) {
  /* 顶栏允许换行：境界 / 灵体 / 称号全部保持可见，不做隐藏 */
  .topbar {
    height: auto;
    min-height: auto;
    flex-wrap: wrap;
    row-gap: 4px;
    padding-block: 6px;
  }

  .brand-sm {
    max-width: 30vw;
    font-size: 14px;
  }

  .stat-spirit {
    max-width: 27vw;
    min-height: 44px;
    padding-inline: 6px;
    font-size: 11px;
  }

  .player-avatar {
    width: 34px;
    height: 34px;
  }

  .topbar-status {
    flex-wrap: wrap;
    row-gap: 4px;
    gap: 6px;
  }

  .actionbar {
    gap: 4px;
    padding-inline: 6px;
  }

  .act {
    font-size: 12px;
  }

  .tab {
    font-size: 12px;
  }

  #boot,
  #unauth {
    padding: 16px;
  }

  .boot-title {
    font-size: 40px;
  }

  .unauth-box {
    padding: 26px 20px;
  }
}

/* 矮屏：防止信息面板挤压重叠 */
@media (max-height: 640px) {
  .room-card {
    max-height: 36vh;
    overflow-y: auto;
  }

  .quest-strip {
    max-height: 30vh;
  }
}

/* ---------- 减少动态效果：关闭位移与闪烁 ---------- */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation: none !important;
    transition: none !important;
  }

  .boot-progress-bar {
    width: 100%;
  }
}

/* ---------- 玩家字徽：头像缺失 / 加载失败时显示道号首字 ---------- */
.player-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  border-radius: 50%;
  background: linear-gradient(160deg, rgba(84, 53, 112, 0.85), rgba(14, 13, 10, 0.92));
  border: 1px solid rgba(231, 194, 111, 0.78);
  color: var(--gold-bright);
  font-family: var(--font-serif);
  font-weight: 800;
  line-height: 1;
  text-align: center;
  user-select: none;
  overflow: hidden;
}

#player-avatar-badge {
  width: 38px;
  height: 38px;
  font-size: 19px;
}

.player-display .player-badge {
  width: 1.3em;
  height: 1.3em;
  font-size: 1.3em;
  margin-right: 0.25em;
  vertical-align: middle;
}

@media (max-width: 430px) {
  #player-avatar-badge {
    width: 34px;
    height: 34px;
    font-size: 17px;
  }
}

/* ---------- 玩家操作面板（场景头像 / 附近玩家行共用，轻量互斥） ---------- */
.player-action-panel {
  position: fixed;
  left: 50%;
  bottom: max(16px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 60;
  width: min(340px, calc(100vw - 32px));
  max-height: min(70vh, 480px);
  overflow-y: auto;
  box-sizing: border-box;
  padding: 12px;
  background: var(--ink-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
}

.player-action-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}

.player-action-title {
  margin: 0;
  font-size: 1rem;
  color: var(--gold-bright);
  overflow-wrap: anywhere;
  min-width: 0;
}

.player-action-close {
  flex: none;
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--gold-bright);
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
}

.player-action-buttons {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.player-action-btn {
  width: 100%;
  min-height: 44px;
  box-sizing: border-box;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--line-soft);
  color: var(--gold-bright);
  font-size: 0.95rem;
  text-align: left;
  cursor: pointer;
  overflow-wrap: anywhere;
}

/* ============================================================
   Chat-first MUD workspace
   The scene artwork is a separate atmospheric layer. Messages and controls
   always render on opaque ink surfaces above it.
   ============================================================ */

:root {
  --mud-topbar-h: 54px;
  --mud-channel-w: 220px;
  --mud-context-w: 280px;
  --mud-composer-min-h: 90px;
  --mud-panel-shadow: 0 18px 48px rgba(0, 0, 0, 0.48);
}

#game.game {
  min-width: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--ink-deep);
}

#game .topbar,
#game .mud-workspace,
#game .chat-shell,
#game .channel-rail,
#game .context-panel,
#game .quick-command-panel,
#game .cmd-form,
#game .chat-message,
#game .chat-header {
  letter-spacing: 0;
}

/* ---------- Stable game status bar ---------- */

#game .topbar {
  z-index: 40;
  display: grid;
  width: 100%;
  height: var(--mud-topbar-h);
  min-height: var(--mud-topbar-h);
  grid-template-columns: auto auto minmax(140px, 1fr) auto auto;
  gap: 10px;
  padding: 0 max(12px, env(safe-area-inset-right)) 0 max(12px, env(safe-area-inset-left));
  border-bottom-color: rgba(201, 164, 92, 0.34);
  background: #15130f;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
}

.topbar-brand,
.topbar-actions,
.topbar-player,
.topbar-vitals {
  display: flex;
  min-width: 0;
  align-items: center;
}

.topbar-brand {
  gap: 8px;
  white-space: nowrap;
}

.brand-sub {
  color: var(--rice-dim);
  font-size: 12px;
}

#game .topbar-status {
  margin-left: 0;
}

.topbar-player {
  justify-content: flex-start;
  overflow: hidden;
}

.topbar-vitals {
  justify-content: flex-end;
  gap: 8px;
  overflow-x: auto;
  overflow-y: hidden;
  overscroll-behavior-inline: contain;
  scrollbar-width: none;
  white-space: nowrap;
}

.topbar-vitals::-webkit-scrollbar {
  display: none;
}

.player-combat-stats {
  display: inline-grid;
  grid-template-columns: repeat(4, auto);
  min-width: max-content;
  flex: 0 0 auto;
  align-items: center;
  gap: 2px 8px;
  padding-left: 8px;
  border-left: 1px solid var(--line-soft);
  color: var(--rice-dim);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  line-height: 1.25;
}

.player-combat-stat {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
}

.player-combat-stat.stat-attack,
.player-combat-stat.stat-defense {
  color: var(--gold-bright);
}

.player-combat-stat.stat-energy,
.player-combat-stat.stat-speed,
.player-combat-stat.stat-mastery {
  color: var(--jade-bright);
}

.player-combat-stat.stat-penalty {
  color: #d79b8f;
}

.topbar-actions {
  justify-content: flex-end;
  gap: 6px;
}

.topbar-toggle,
.channel-btn,
.lounge-create,
.lounge-invitations button {
  min-width: 44px;
  min-height: 44px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--rice-dim);
  font: inherit;
  cursor: pointer;
}

.topbar-toggle {
  padding: 6px 10px;
  font-size: 13px;
  white-space: nowrap;
}

.topbar-toggle:hover,
.topbar-toggle:focus-visible,
.channel-btn:hover,
.channel-btn:focus-visible,
.lounge-create:hover,
.lounge-create:focus-visible,
.lounge-invitations button:hover,
.lounge-invitations button:focus-visible {
  border-color: var(--gold);
  color: var(--gold-bright);
  outline: 0;
}

.topbar-toggle[aria-expanded="true"] {
  border-color: rgba(126, 167, 147, 0.58);
  color: var(--jade-bright);
}

#game.is-status-collapsed .topbar-vitals,
#game.status-collapsed .topbar-vitals {
  display: none;
}

/* ---------- Three-band workspace ---------- */

#game .mud-workspace {
  --mud-channel-col: var(--mud-channel-w);
  --mud-context-col: var(--mud-context-w);
  position: relative;
  isolation: isolate;
  display: grid;
  width: min(100%, 2160px);
  min-width: 0;
  min-height: 0;
  margin-inline: auto;
  flex: 1 1 auto;
  grid-template-columns: var(--mud-channel-col) minmax(0, 1fr) var(--mud-context-col);
  grid-template-rows: minmax(0, 1fr);
  grid-template-areas: "channel chat context";
  gap: 0;
  padding: 0;
  overflow: hidden;
  background: #0d0c09;
}

#game.is-channel-collapsed .mud-workspace,
#game:has(.channel-rail.is-collapsed) .mud-workspace {
  --mud-channel-col: 0px;
}

#game.is-context-collapsed .mud-workspace,
#game:has(.context-panel.is-collapsed) .mud-workspace {
  --mud-context-col: 0px;
}

#game .channel-rail,
#game .context-panel {
  position: relative;
  z-index: 8;
  min-width: 0;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  background: #171510;
  transition: transform 0.22s ease, opacity 0.18s ease;
}

#game .channel-rail {
  grid-area: channel;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 14px 12px max(16px, env(safe-area-inset-bottom));
  border-right: 1px solid var(--line);
}

#game .context-panel {
  grid-area: context;
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 0 0 max(16px, env(safe-area-inset-bottom));
  border-left: 1px solid var(--line);
}

#game.is-channel-collapsed .channel-rail,
#game .channel-rail.is-collapsed,
#game.is-context-collapsed .context-panel,
#game .context-panel.is-collapsed {
  visibility: hidden;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
}

.channel-current {
  display: flex;
  min-height: 48px;
  flex-direction: column;
  justify-content: center;
  padding: 4px 10px 10px;
  border-bottom: 1px solid var(--line-soft);
}

.channel-current span,
.channel-group h2 {
  color: var(--rice-dim);
  font-size: 12px;
  font-weight: 600;
}

.channel-current strong {
  color: var(--gold-bright);
  font-family: var(--font-serif);
  font-size: 17px;
}

.channel-list,
.lounge-invitations {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 4px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.channel-list li,
.lounge-invitations li {
  min-width: 0;
}

.channel-btn {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: flex-start;
  padding: 8px 10px;
  overflow: hidden;
  border-color: transparent;
  color: var(--rice);
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.channel-btn.is-active,
.channel-btn[aria-current="true"] {
  border-color: rgba(126, 167, 147, 0.46);
  background: rgba(126, 167, 147, 0.12);
  color: var(--jade-bright);
}

.channel-btn .unread-count,
.channel-unread {
  display: inline-flex;
  min-width: 20px;
  min-height: 20px;
  margin-left: auto;
  align-items: center;
  justify-content: center;
  padding: 0 6px;
  border-radius: 10px;
  background: var(--vermilion);
  color: #fff4e8;
  font-size: 11px;
  line-height: 1;
}

.channel-group {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 8px;
}

.channel-group h2 {
  margin: 0;
  padding: 0 10px;
}

.lounge-create {
  width: 100%;
  padding: 8px 10px;
  border-style: dashed;
  color: var(--gold);
}

.lounge-invitations li {
  padding: 9px 10px;
  border-top: 1px solid var(--line-soft);
  color: var(--rice-dim);
  overflow-wrap: anywhere;
}

.lounge-invitations button {
  margin: 8px 6px 0 0;
  padding: 6px 10px;
}

/* ---------- The message stream is the primary surface ---------- */

#game .chat-shell {
  position: relative;
  isolation: isolate;
  grid-area: chat;
  display: grid;
  min-width: 0;
  min-height: 0;
  grid-template-rows: 48px minmax(0, 1fr) auto auto auto;
  overflow: hidden;
  background: #100f0c;
}

.chat-header {
  position: relative;
  z-index: 7;
  display: flex;
  min-width: 0;
  min-height: 48px;
  align-items: center;
  gap: 10px;
  padding: 0 16px;
  border-bottom: 1px solid var(--line);
  background: rgba(20, 18, 14, 0.98);
}

.chat-channel-title {
  min-width: 0;
  margin: 0;
  overflow: hidden;
  color: var(--gold-bright);
  font-family: var(--font-serif);
  font-size: 16px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-unread {
  min-height: 44px;
  min-width: 0;
  padding: 2px 8px;
  overflow: hidden;
  border: 1px solid rgba(178, 58, 42, 0.48);
  border-radius: 4px;
  background: rgba(178, 58, 42, 0.12);
  color: var(--vermilion-bright);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-unread:hover,
.chat-unread:focus-visible {
  border-color: rgba(207, 70, 51, 0.82);
  background: rgba(178, 58, 42, 0.2);
}

.chat-connection {
  display: inline-flex;
  min-height: 28px;
  margin-left: auto;
  align-items: center;
  padding: 2px 8px;
  border: 1px solid var(--line-soft);
  border-radius: 4px;
  color: var(--rice-dim);
  font-size: 12px;
  white-space: nowrap;
}

.chat-connection[data-state="online"],
.chat-connection[data-state="connected"] {
  border-color: rgba(126, 167, 147, 0.5);
  color: var(--jade-bright);
}

.chat-connection[data-state="error"],
.chat-connection[data-state="offline"] {
  border-color: rgba(178, 58, 42, 0.56);
  color: #f0b3a8;
}

.chat-viewport {
  position: relative;
  isolation: isolate;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background: #0e0d0a;
}

.chat-viewport::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background: rgba(10, 9, 7, 0.68);
}

#game .chat-viewport .scene-viz {
  position: absolute;
  inset: 0;
  z-index: 0;
  width: 100%;
  height: 100%;
  opacity: 0.28;
  filter: saturate(0.72) contrast(0.92);
  pointer-events: none;
}

#game .chat-viewport .scene-viz .scene-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

#game .chat-feed,
#game .log.chat-feed {
  position: relative;
  z-index: 2;
  display: flex;
  width: 100%;
  height: 100%;
  max-height: none;
  margin: 0;
  flex-direction: column;
  gap: 6px;
  padding: 8px clamp(10px, 1.8vw, 18px) 12px;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  scroll-behavior: smooth;
  border: 0;
  border-radius: 0;
  background: rgba(14, 13, 10, 0.66);
  font-size: 13px;
  line-height: 1.55;
  animation: none;
  scrollbar-gutter: stable;
}

#game .chat-feed:empty,
#game .log.chat-feed:empty {
  display: flex;
}

.chat-message {
  display: flex;
  width: fit-content;
  max-width: min(88%, 760px);
  align-self: flex-start;
  align-items: flex-start;
  gap: 8px;
  margin: 1px 0;
  color: var(--rice);
  font-size: 13px;
  line-height: 1.55;
  animation: none;
}

.chat-message.is-new {
  animation: chat-message-in 0.2s ease-out both;
}

.chat-message:not(.is-own):not(.is-npc):not(.is-bot) .message-bubble,
.chat-message:not(.is-own):not(.is-npc):not(.is-bot) .message-body {
  border-left: 2px solid var(--gold);
}

.chat-message.is-own,
.chat-message.own,
.chat-message[data-own="true"] {
  align-self: flex-end;
  flex-direction: row;
}

.chat-avatar,
.message-avatar,
.chat-message-avatar {
  position: static;
  display: grid;
  width: 30px;
  height: 30px;
  min-width: 30px;
  flex: none;
  place-items: center;
  overflow: hidden;
  border: 1px solid rgba(201, 164, 92, 0.48);
  border-radius: 50%;
  background: #211d15;
  color: var(--gold-bright);
  object-fit: cover;
  text-align: center;
  line-height: 28px;
  font-size: 14px;
}

.message-avatar > img,
.chat-avatar > img,
.chat-message-avatar > img,
.message-avatar-badge {
  grid-area: 1 / 1;
  width: 100%;
  height: 100%;
}

.message-avatar > img,
.chat-avatar > img,
.chat-message-avatar > img {
  z-index: 2;
  object-fit: cover;
  object-position: center;
}

.message-avatar-badge {
  z-index: 1;
  display: grid;
  place-items: center;
  font-family: var(--font-serif);
  font-weight: 800;
  line-height: 1;
}

.chat-message.is-npc .chat-avatar,
.chat-message.is-npc .message-avatar,
.chat-message.is-npc .chat-message-avatar,
.chat-message[data-kind="npc"] .chat-avatar,
.chat-message[data-kind="npc"] .message-avatar {
  border-color: rgba(126, 167, 147, 0.72);
}

.chat-message-main,
.chat-message-content,
.message-content,
.message-bubble,
.chat-bubble {
  min-width: 0;
}

.chat-message-main,
.chat-message-content,
.message-content {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.chat-message.is-own .chat-message-main,
.chat-message.is-own .chat-message-content,
.chat-message.is-own .message-content,
.chat-message.own .chat-message-main,
.chat-message.own .chat-message-content {
  align-items: flex-end;
}

.message-bubble,
.chat-bubble,
.chat-message-body,
.chat-message-text,
.message-body,
.message-text {
  max-width: 100%;
  margin: 0;
  padding: 5px 8px;
  font-size: 13px;
  line-height: 1.55;
  border: 1px solid rgba(238, 229, 211, 0.16);
  border-radius: 6px;
  background: rgba(32, 29, 22, 0.97);
  color: #f2eadb;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.chat-message.is-own .message-bubble,
.chat-message.is-own .chat-bubble,
.chat-message.is-own .chat-message-body,
.chat-message.is-own .chat-message-text,
.chat-message.is-own .message-body,
.chat-message.is-own .message-text,
.chat-message.own .message-bubble,
.chat-message.own .chat-bubble {
  border-color: rgba(201, 164, 92, 0.54);
  border-right: 2px solid var(--gold-bright);
  border-left-color: rgba(238, 229, 211, 0.12);
  background: rgba(62, 48, 26, 0.98);
}

.chat-message.is-command .message-bubble,
.chat-message.is-command .message-body {
  border-style: dashed;
  border-color: rgba(201, 164, 92, 0.72);
  border-right: 2px dashed var(--gold-bright);
  background: rgba(48, 39, 24, 0.98);
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

.chat-message.is-command:not(.is-own) .message-bubble,
.chat-message.is-command:not(.is-own) .message-body {
  border-right: 1px dashed rgba(201, 164, 92, 0.72);
  border-left: 2px dashed var(--gold-bright);
}

.chat-message.is-bot .message-bubble,
.chat-message.is-bot .chat-bubble,
.chat-message.is-bot .chat-message-body,
.chat-message.is-bot .chat-message-text,
.chat-message[data-kind="bot"] .message-bubble {
  border-color: rgba(207, 70, 51, 0.68);
  border-left: 2px dashed var(--vermilion-bright);
  border-style: dashed;
  background: rgba(49, 25, 20, 0.98);
  color: #f4dfda;
}

.chat-message.is-npc .message-bubble,
.chat-message.is-npc .chat-bubble,
.chat-message.is-npc .chat-message-body,
.chat-message[data-kind="npc"] .message-bubble {
  border-color: rgba(126, 167, 147, 0.62);
  border-left: 2px solid var(--jade-bright);
  border-style: solid;
  background: rgba(24, 43, 35, 0.98);
  color: #e7f2ec;
}

.chat-message-meta,
.message-meta,
.chat-meta {
  display: flex;
  max-width: 100%;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin: 0 2px 4px;
  color: var(--rice-dim);
  font-size: 12px;
  line-height: 1.4;
}

.chat-message.is-own .chat-message-meta,
.chat-message.is-own .message-meta,
.chat-message.own .chat-message-meta {
  justify-content: flex-end;
}

.chat-author,
.message-author,
.chat-message-author,
.message-name {
  color: var(--gold-bright);
  font-weight: 700;
}

.chat-message.is-npc .chat-author,
.chat-message.is-npc .message-author,
.chat-message[data-kind="npc"] .chat-author,
.chat-message.is-npc .message-name {
  color: var(--jade-bright);
}

.message-title {
  color: var(--gold);
}

.message-delivery {
  display: inline-flex;
  min-height: 24px;
  align-items: center;
  padding: 0 4px;
  border: 0;
  background: transparent;
  color: rgba(198, 187, 164, 0.8);
  font: inherit;
  font-size: 11px;
}

.message-delivery.is-pending {
  color: var(--gold-bright);
}

button.message-delivery.is-failed {
  border-radius: var(--radius-sm);
  color: #f0b3a8;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}

button.message-delivery.is-failed:hover,
button.message-delivery.is-failed:focus-visible {
  background: rgba(178, 58, 42, 0.16);
  outline: 1px solid rgba(178, 58, 42, 0.5);
}

.chat-message.is-pending {
  opacity: 0.82;
}

.chat-message.is-failed .message-bubble,
.chat-message.is-failed .message-body {
  border-color: rgba(178, 58, 42, 0.66);
}

.chat-message.is-deleted .message-body {
  color: var(--rice-dim);
  font-style: italic;
}

.message-report {
  display: inline-flex;
  min-width: 44px;
  min-height: 44px;
  margin: 0 -8px 0 auto;
  align-items: center;
  justify-content: center;
  padding: 0 8px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: rgba(198, 187, 164, 0.78);
  cursor: pointer;
  font: inherit;
  font-size: 11px;
}

.message-report:hover,
.message-report:focus-visible {
  background: rgba(178, 58, 42, 0.14);
  color: #f0b3a8;
  outline: 1px solid rgba(178, 58, 42, 0.48);
  outline-offset: -1px;
}

.message-report:disabled {
  color: var(--rice-dim);
  cursor: default;
  opacity: 0.72;
}

.chat-time,
.message-time,
.chat-message-time {
  color: rgba(198, 187, 164, 0.76);
  font-variant-numeric: tabular-nums;
}

#game .chat-feed > .log-line {
  width: fit-content;
  max-width: min(82%, 760px);
  margin: 0;
  padding: 8px 11px;
  border-left: 2px solid var(--line);
  background: rgba(24, 22, 17, 0.94);
  color: var(--rice-dim);
  line-height: 1.65;
}

#game .chat-feed > .log-line.log-cmd {
  align-self: flex-end;
  border-right: 2px solid var(--gold);
  border-left: 0;
  color: var(--gold-bright);
}

#game .chat-feed > .log-line.log-err {
  border-left-color: var(--vermilion);
  color: #f0b3a8;
}

@keyframes chat-message-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ---------- Optional combat and quick-command bands ---------- */

#game .combat-hud {
  position: relative;
  inset: auto;
  z-index: 6;
  width: auto;
  margin: 8px 12px;
  transform: none;
}

#game .combat-hud:not(.hidden) {
  animation: chat-combat-in 0.22s ease-out both;
}

#game .chat-shell:has(.combat-hud:not(.hidden)) .chat-feed,
#game .scene-stage:has(.combat-hud:not(.hidden)) .log {
  margin-bottom: 0;
}

@keyframes chat-combat-in {
  from {
    opacity: 0;
    transform: translateY(5px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

#game .quick-command-panel {
  position: relative;
  z-index: 7;
  display: flex;
  min-width: 0;
  flex-direction: column;
  border-top: 1px solid var(--line);
  background: #171510;
}

#game.is-quick-collapsed .quick-command-panel,
#game .quick-command-panel.is-collapsed {
  display: none;
}

#game .quick-command-panel .command-actions {
  padding: 8px 12px 0;
}

#game .quick-command-panel .actionbar {
  width: 100%;
  max-width: none;
  height: auto;
  min-height: 60px;
  margin: 0;
  padding: 8px 12px;
  border-top: 0;
  background: transparent;
}

/* ---------- Composer ---------- */

#game .cmd-form {
  position: relative;
  z-index: 8;
  display: grid;
  width: 100%;
  max-width: none;
  min-height: var(--mud-composer-min-h);
  margin: 0;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-rows: auto minmax(44px, auto);
  align-items: end;
  gap: 8px;
  padding: 10px 12px max(10px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: #15130f;
}

#game .composer-mode {
  grid-column: 1 / -1;
  min-height: 18px;
  color: var(--rice-dim);
  font-size: 11px;
  line-height: 1.4;
}

#game .composer-mode.is-command {
  color: var(--gold-bright);
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

#game #cmd-input {
  grid-column: 1;
  grid-row: 2;
  display: block;
  width: 100%;
  min-width: 0;
  min-height: 44px;
  max-height: min(28dvh, 180px);
  resize: none;
  padding: 9px 12px;
  overflow-y: auto;
  border: 1px solid rgba(238, 229, 211, 0.22);
  border-radius: var(--radius-sm);
  background: #211e18;
  color: var(--rice);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.55;
}

#game #cmd-input::placeholder {
  color: rgba(198, 187, 164, 0.72);
}

#game #cmd-send {
  grid-column: 2;
  grid-row: 2;
  min-width: 76px;
  min-height: 44px;
}

/* ---------- Context band: compact, scannable, not nested cards ---------- */

#game .context-panel .room-card,
#game .context-panel .quest-strip {
  width: 100%;
  max-height: none;
  margin: 0;
  padding: 16px;
  overflow: visible;
  border: 0;
  border-bottom: 1px solid var(--line-soft);
  border-radius: 0;
  background: transparent;
  animation: none;
}

#game .context-panel .scene-hotspots {
  display: flex;
  width: auto;
  max-height: none;
  margin: 0;
  padding: 12px 16px;
  overflow: visible;
  border-bottom: 1px solid var(--line-soft);
}

#game .context-panel .activity-rail {
  min-height: auto;
  overflow: visible;
}

#game .context-panel .room-exits {
  display: none;
}

#game .quest-item {
  display: block;
  width: 100%;
  min-width: 44px;
  min-height: 44px;
  padding: 8px 10px;
  border: 0;
  border-bottom: 1px solid var(--line-soft);
  background: transparent;
  color: var(--rice);
  text-align: left;
  cursor: pointer;
}

#game .quest-item:hover,
#game .quest-item:focus-visible {
  background: rgba(126, 167, 147, 0.1);
  color: var(--jade-bright);
  outline: 1px solid rgba(126, 167, 147, 0.46);
  outline-offset: -1px;
}

.context-fab {
  z-index: 42;
}

@media (max-width: 1099px) {
  #game.is-quick-open #hotspot-player.context-fab {
    visibility: hidden;
    opacity: 0;
    pointer-events: none;
  }
}

/* ---------- Tablet: chat stays central; side bands become drawers ---------- */

@media (min-width: 1100px) {
  #game .mud-workspace {
    --mud-channel-col: 232px;
    --mud-context-col: 320px;
    grid-template-columns: var(--mud-channel-col) minmax(0, 1fr) var(--mud-context-col);
  }

  #game.is-channel-collapsed .mud-workspace,
  #game:has(.channel-rail.is-collapsed) .mud-workspace {
    --mud-channel-col: 0px;
  }

  #game.is-context-collapsed .mud-workspace,
  #game:has(.context-panel.is-collapsed) .mud-workspace {
    --mud-context-col: 0px;
  }
}

@media (min-width: 600px) and (max-width: 1099px) {
  :root {
    --mud-topbar-h: 58px;
  }

  #game .topbar {
    height: var(--mud-topbar-h);
    min-height: var(--mud-topbar-h);
    grid-template-columns: auto auto minmax(120px, 1fr) auto auto;
    gap: 7px;
    padding-inline: max(8px, env(safe-area-inset-left)) max(8px, env(safe-area-inset-right));
  }

  .brand-sub {
    display: none;
  }

  #game .topbar-status {
    gap: 7px;
  }

  #game .mud-workspace {
    --mud-channel-col: 0px;
    --mud-context-col: 0px;
    width: 100%;
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: "chat";
  }

  #game .channel-rail,
  #game .context-panel {
    position: fixed;
    top: var(--mud-topbar-h);
    bottom: 0;
    z-index: 32;
    visibility: hidden;
    width: min(360px, 88vw);
    height: auto;
    max-height: none;
    overflow-y: auto;
    opacity: 0;
    pointer-events: none;
    box-shadow: var(--mud-panel-shadow);
  }

  #game .channel-rail {
    right: auto;
    left: 0;
    transform: translateX(-102%);
  }

  #game .context-panel {
    right: 0;
    left: auto;
    transform: translateX(102%);
  }

  #game.is-channel-open .channel-rail,
  #game .channel-rail.is-open,
  #game.is-context-open .context-panel,
  #game .context-panel.is-open {
    visibility: visible;
    opacity: 1;
    transform: translateX(0);
    pointer-events: auto;
  }

  #game .quick-command-panel {
    position: fixed;
    right: max(8px, env(safe-area-inset-right));
    bottom: var(--mud-composer-live-h, var(--mud-composer-min-h));
    left: max(8px, env(safe-area-inset-left));
    z-index: 34;
    visibility: hidden;
    max-height: min(52dvh, 420px);
    overflow-y: auto;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    opacity: 0;
    transform: translateY(calc(100% + 16px));
    pointer-events: none;
    box-shadow: var(--mud-panel-shadow);
    transition: transform 0.2s ease, opacity 0.18s ease;
  }

  #game.is-quick-open .quick-command-panel,
  #game .quick-command-panel.is-open {
    visibility: visible;
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
  }

  #game.is-quick-collapsed .quick-command-panel,
  #game .quick-command-panel.is-collapsed {
    display: flex;
  }

  #game .chat-message {
    max-width: min(86%, 700px);
  }

  #game #hotspot-player.context-fab {
    right: max(10px, env(safe-area-inset-right));
    bottom: calc(var(--mud-composer-min-h) + 10px + env(safe-area-inset-bottom));
  }
}

@media (min-width: 600px) and (max-width: 799px) {
  :root {
    --mud-topbar-h: 96px;
  }

  #game .topbar {
    height: var(--mud-topbar-h);
    min-height: var(--mud-topbar-h);
    grid-template-columns: auto 44px minmax(100px, 1fr) auto;
    grid-template-rows: 48px 48px;
    gap: 0 6px;
  }

  #game .topbar-brand {
    grid-column: 1;
    grid-row: 1;
  }

  #channel-rail-toggle {
    grid-column: 2;
    grid-row: 1;
    padding-inline: 2px;
    font-size: 11px;
  }

  #game .topbar-player {
    grid-column: 3;
    grid-row: 1;
  }

  #game .topbar-actions {
    grid-column: 4;
    grid-row: 1;
  }

  #game .topbar-vitals {
    grid-column: 1 / -1;
    grid-row: 2;
    justify-content: flex-start;
    overflow-x: auto;
  }
}

/* ---------- Phone: full-screen chat with side and bottom drawers ---------- */

@media (max-width: 599px) {
  :root {
    --mud-topbar-h: 96px;
    --mud-composer-min-h: 86px;
  }

  #game.game {
    height: 100vh;
    height: 100dvh;
    padding: 0;
  }

  #game .topbar {
    height: var(--mud-topbar-h);
    min-height: var(--mud-topbar-h);
    grid-template-columns: 44px minmax(70px, 1fr) auto;
    grid-template-rows: 48px 48px;
    gap: 0 6px;
    padding: 0 max(6px, env(safe-area-inset-right)) 0 max(6px, env(safe-area-inset-left));
  }

  #game .topbar-brand {
    display: none;
  }

  #channel-rail-toggle {
    grid-column: 1;
    grid-row: 1;
    width: 44px;
    padding-inline: 2px;
    font-size: 11px;
  }

  #game .topbar-player {
    grid-column: 2;
    grid-row: 1;
    gap: 5px;
  }

  #game .topbar-vitals {
    grid-column: 1 / -1;
    grid-row: 2;
    justify-content: flex-start;
    gap: 6px;
    overflow-x: auto;
    overflow-y: hidden;
  }

  #game .topbar-actions {
    grid-column: 3;
    grid-row: 1;
    gap: 2px;
  }

  #game .topbar-actions > button,
  #game .topbar-actions > .topbar-entry {
    width: 44px;
    min-width: 44px;
    padding-inline: 2px;
    font-size: 11px;
  }

  #game .player-avatar,
  #player-avatar-badge {
    width: 34px;
    height: 34px;
    min-width: 34px;
  }

  #game .admin-title,
  #game .topbar-player > .player-title {
    max-width: 38vw;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  #game .stat-hp,
  #game .stat-realm,
  #game .stat-currency,
  #game .stat-spirit {
    flex: 0 0 auto;
    font-size: 12px;
  }

  #game.is-status-collapsed .topbar,
  #game.status-collapsed .topbar {
    height: 48px;
    min-height: 48px;
    grid-template-rows: 48px;
  }

  #game.is-status-collapsed,
  #game.status-collapsed {
    --mud-topbar-h: 48px;
  }

  #game .mud-workspace {
    --mud-channel-col: 0px;
    --mud-context-col: 0px;
    width: 100%;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr);
    grid-template-areas: "chat";
    overflow: hidden;
  }

  #game .chat-shell {
    min-height: 0;
    grid-template-rows: 44px minmax(0, 1fr) auto auto auto;
  }

  #game .chat-header {
    min-height: 44px;
    padding-inline: 10px;
  }

  #game .chat-feed,
  #game .log.chat-feed {
    gap: 11px;
    padding: 14px 10px 18px;
    background: rgba(14, 13, 10, 0.8);
    font-size: 16px;
    line-height: 1.65;
  }

  #game .chat-viewport::before {
    background: rgba(10, 9, 7, 0.76);
  }

  #game .chat-viewport .scene-viz {
    opacity: 0.22;
  }

  #game .chat-message,
  #game .chat-feed > .log-line {
    max-width: 92%;
  }

  .chat-avatar,
  .message-avatar,
  .chat-message-avatar {
    width: 34px;
    height: 34px;
    min-width: 34px;
    line-height: 32px;
  }

  .message-bubble,
  .chat-bubble,
  .chat-message-body,
  .chat-message-text,
  .message-body,
  .message-text {
    padding: 9px 11px;
  }

  #game .channel-rail,
  #game .context-panel {
    position: fixed;
    top: var(--mud-topbar-h);
    bottom: 0;
    z-index: 32;
    visibility: hidden;
    width: min(360px, 90vw);
    height: auto;
    max-height: none;
    overflow-y: auto;
    opacity: 0;
    pointer-events: none;
    box-shadow: var(--mud-panel-shadow);
  }

  #game .channel-rail {
    right: auto;
    left: 0;
    transform: translateX(-102%);
  }

  #game .context-panel {
    right: 0;
    left: auto;
    transform: translateX(102%);
  }

  #game.is-channel-open .channel-rail,
  #game .channel-rail.is-open,
  #game.is-context-open .context-panel,
  #game .context-panel.is-open {
    visibility: visible;
    opacity: 1;
    transform: translateX(0);
    pointer-events: auto;
  }

  #game .quick-command-panel {
    position: fixed;
    right: max(6px, env(safe-area-inset-right));
    bottom: var(--mud-composer-live-h, var(--mud-composer-min-h));
    left: max(6px, env(safe-area-inset-left));
    z-index: 34;
    visibility: hidden;
    max-height: min(52dvh, 420px);
    overflow-y: auto;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    opacity: 0;
    transform: translateY(calc(100% + 16px));
    pointer-events: none;
    box-shadow: var(--mud-panel-shadow);
    transition: transform 0.2s ease, opacity 0.18s ease;
  }

  #game.is-quick-open .quick-command-panel,
  #game .quick-command-panel.is-open {
    visibility: visible;
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
  }

  #game.is-quick-collapsed .quick-command-panel,
  #game .quick-command-panel.is-collapsed {
    display: flex;
  }

  #game .quick-command-panel .actionbar {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    grid-auto-rows: minmax(44px, auto);
    min-height: 0;
  }

  #game .cmd-form {
    min-height: var(--mud-composer-min-h);
    gap: 6px;
    padding: 8px max(8px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
  }

  #game #cmd-send {
    min-width: 62px;
    padding-inline: 10px;
  }

  #game .combat-hud {
    margin: 6px 8px;
    padding: 9px 11px;
  }

  .context-fab {
    right: max(8px, env(safe-area-inset-right));
    bottom: calc(var(--mud-composer-live-h, var(--mud-composer-min-h)) + 8px);
  }

  #game #hotspot-player.context-fab {
    right: max(8px, env(safe-area-inset-right));
    bottom: calc(var(--mud-composer-live-h, var(--mud-composer-min-h)) + 8px);
  }

  .drawer {
    width: 100vw;
    max-width: 100vw;
    padding-bottom: env(safe-area-inset-bottom);
  }
}

/* ---------- Ultra-small phone (<=340px) topbar adaptation ---------- */

@media (max-width: 340px) {
  #game .topbar {
    grid-template-columns: 40px minmax(40px, 1fr) auto;
    gap: 0 4px;
    padding: 0 max(4px, env(safe-area-inset-right)) 0 max(4px, env(safe-area-inset-left));
  }

  #channel-rail-toggle {
    width: 40px;
    padding-inline: 1px;
    font-size: 10px;
  }

  #game .topbar-actions {
    gap: 2px;
  }

  #game .topbar-actions > button,
  #game .topbar-actions > .topbar-entry {
    width: 40px;
    min-width: 40px;
    padding-inline: 1px;
    font-size: 10px;
  }

  #game .topbar-vitals,
  .topbar-vitals {
    gap: 4px;
    font-size: 11px;
  }

  #game .stat-hp,
  #game .stat-realm,
  #game .stat-currency,
  #game .stat-spirit {
    font-size: 11px;
    white-space: nowrap;
  }

  #game .player-combat-stats {
    gap: 2px 4px;
    font-size: 10px;
    padding-left: 4px;
  }
}

/* ---------- Short landscape phones/tablets ---------- */

@media (min-width: 600px) and (max-width: 1099px) and (orientation: landscape) and (max-height: 560px) {
  :root {
    --mud-topbar-h: 50px;
    --mud-composer-min-h: 78px;
  }

  #game .topbar {
    height: var(--mud-topbar-h);
    min-height: var(--mud-topbar-h);
  }

  #game .topbar-brand,
  #game .topbar-player > .player-title {
    display: inline-block;
    max-width: 24vw;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  #game .chat-shell {
    grid-template-rows: 40px minmax(0, 1fr) auto auto auto;
  }

  #game .chat-header {
    min-height: 40px;
  }

  #game .chat-feed,
  #game .log.chat-feed {
    padding-block: 10px;
  }

  #game .quick-command-panel {
    position: fixed;
    right: max(8px, env(safe-area-inset-right));
    bottom: var(--mud-composer-live-h, var(--mud-composer-min-h));
    left: max(8px, env(safe-area-inset-left));
    z-index: 34;
    visibility: hidden;
    max-height: min(58dvh, 260px);
    overflow-y: auto;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    opacity: 0;
    transform: translateY(calc(100% + 16px));
    pointer-events: none;
    box-shadow: var(--mud-panel-shadow);
  }

  #game.is-quick-open .quick-command-panel,
  #game .quick-command-panel.is-open {
    visibility: visible;
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
  }

  #game.is-quick-collapsed .quick-command-panel,
  #game .quick-command-panel.is-collapsed {
    display: flex;
  }

  #game .quick-command-panel .actionbar {
    min-height: 0;
  }

  #game .cmd-form {
    min-height: var(--mud-composer-min-h);
    padding-block: 6px max(6px, env(safe-area-inset-bottom));
  }
}

/* ---------- Very narrow phones ---------- */

@media (max-width: 374px) {
  #game .topbar {
    gap: 0 3px;
    padding-inline: max(3px, env(safe-area-inset-left)) max(3px, env(safe-area-inset-right));
  }

  #game .topbar-actions {
    gap: 0;
  }

  #game .player-name {
    max-width: 18vw;
  }

  #game .topbar-player > .player-title {
    display: inline-block;
    max-width: 22vw;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .chat-message {
    gap: 7px;
  }
}

/* ---------- Motion accessibility ---------- */

@media (prefers-reduced-motion: reduce) {
  #game .channel-rail,
  #game .context-panel,
  #game .quick-command-panel,
  #game .chat-message,
  #game .scene-viz,
  #game .combat-hud {
    animation: none !important;
    scroll-behavior: auto !important;
    transition: none !important;
  }
}

/* ---------- 世界钩子条与悬念卡 (P0-F1) ---------- */

.world-hook-bar,
.channel-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 4px 12px 2px;
  padding: 8px 14px;
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(15, 23, 42, 0.92) 0%, rgba(30, 41, 59, 0.88) 100%);
  border: 1px solid rgba(6, 182, 212, 0.35);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.08);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 1;
  flex: none;
}

.world-hook-bar.is-compact {
  padding: 6px 12px;
  margin: 4px 14px 2px;
  background: rgba(15, 23, 42, 0.7);
  border-color: rgba(6, 182, 212, 0.2);
}

.world-hook-bar.is-compact .hook-text {
  display: none;
}

.hook-content {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1 1 auto;
}

.hook-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(6, 182, 212, 0.2);
  border: 1px solid rgba(6, 182, 212, 0.4);
  color: #38bdf8;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  white-space: nowrap;
  flex: none;
}

.hook-text {
  margin: 0;
  font-size: 13px;
  line-height: 1.45;
  color: #e2e8f0;
  font-family: var(--font-serif);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hook-card {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  padding: 6px 14px;
  min-height: 42px;
  border-radius: 14px;
  background: radial-gradient(circle at var(--mouse-x, 50%) var(--mouse-y, 50%), rgba(6, 182, 212, 0.3) 0%, rgba(37, 99, 235, 0.2) 60%, rgba(15, 23, 42, 0.9) 100%);
  border: 1px solid rgba(6, 182, 212, 0.5);
  box-shadow: 0 2px 10px rgba(6, 182, 212, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.15);
  color: #ffffff;
  cursor: pointer;
  flex: none;
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.hook-card:hover {
  transform: translateY(-1px) scale(1.02);
  border-color: #38bdf8;
  box-shadow: 0 4px 18px rgba(6, 182, 212, 0.35);
}

.hook-kicker {
  font-size: 10px;
  font-weight: 700;
  color: #38bdf8;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  line-height: 1;
}

.hook-title {
  font-size: 13px;
  font-weight: 700;
  color: #ffffff;
  letter-spacing: 0.02em;
  line-height: 1.3;
}

/* ---------- 秘箓帮助蒙层 (P0-F2) ---------- */

.help-overlay {
  position: fixed;
  inset: 0;
  z-index: 95;
  background: rgba(6, 5, 4, 0.85);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  animation: drawer-in 0.25s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.help-modal-card {
  width: min(880px, 96vw);
  max-height: min(88vh, 820px);
  background: #0d0c0a;
  border: 1px solid rgba(238, 229, 211, 0.2);
  border-radius: 18px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.9), 0 0 0 1px rgba(255, 255, 255, 0.06);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.help-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px 12px;
  border-bottom: 1px solid var(--line-soft);
}

.help-modal-title-group {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.help-modal-tag {
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(37, 99, 235, 0.2);
  border: 1px solid rgba(37, 99, 235, 0.4);
  color: #60a5fa;
  font-size: 11px;
  font-weight: 700;
}

.help-modal-head h2 {
  margin: 0;
  font-size: 18px;
  font-family: var(--font-serif);
  color: var(--gold-bright);
}

.help-search-row {
  padding: 12px 20px 6px;
}

.help-search-input {
  width: 100%;
  height: 44px;
  padding: 0 16px;
  background: rgba(22, 20, 16, 0.95);
  border: 1px solid var(--line);
  border-radius: 12px;
  color: #f8fafc;
  font-size: 14px;
  box-sizing: border-box;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.help-search-input:focus {
  border-color: #06b6d4;
  box-shadow: 0 0 0 2px rgba(6, 182, 212, 0.25);
}

.help-categories {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
  padding: 14px 20px;
  overflow-y: auto;
  overscroll-behavior: contain;
  flex: 1 1 auto;
}

.help-category-card {
  background: rgba(18, 17, 14, 0.95);
  border-radius: 16px;
  padding: 14px;
  border: 1px solid var(--line-soft);
  display: flex;
  flex-direction: column;
  transition: transform 0.2s ease, border-color 0.2s ease;
}

.help-category-card.effect-cyan {
  border-color: rgba(6, 182, 212, 0.35);
  box-shadow: inset 0 0 20px rgba(6, 182, 212, 0.05);
}

.help-category-card.effect-gold {
  border-color: rgba(212, 175, 55, 0.35);
  box-shadow: inset 0 0 20px rgba(212, 175, 55, 0.05);
}

.help-category-card.effect-vermilion {
  border-color: rgba(225, 29, 72, 0.35);
  box-shadow: inset 0 0 20px rgba(225, 29, 72, 0.05);
}

.help-cat-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.help-cat-icon {
  font-size: 18px;
}

.help-cat-header h3 {
  margin: 0;
  font-size: 15px;
  color: var(--rice-bright);
  font-weight: 700;
}

.help-cat-desc {
  margin: 0 0 10px;
  font-size: 12px;
  color: var(--rice-dim);
}

.help-pill-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.help-cmd-pill {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 40px;
  padding: 8px 12px;
  border-radius: 10px;
  background: rgba(30, 27, 21, 0.9);
  border: 1px solid var(--line-soft);
  color: #f8fafc;
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
  transition: all 0.2s ease;
}

.help-cmd-pill small {
  font-family: var(--font-sans);
  font-size: 11px;
  color: var(--rice-dim);
  font-weight: normal;
}

.help-cmd-pill:hover {
  background: rgba(45, 40, 31, 0.95);
  border-color: var(--gold);
  color: var(--gold-bright);
  transform: translateX(2px);
}

.help-modal-foot {
  padding: 10px 20px 14px;
  border-top: 1px solid var(--line-soft);
  font-size: 12px;
  color: var(--rice-dim);
  line-height: 1.4;
}

.help-modal-foot strong {
  color: var(--gold-bright);
}

/* ---------- 卡片光斑与差异化边框 (P1-F1, P1-F2) ---------- */

.spotlight-card {
  position: relative;
  border-radius: 18px;
  background-image: radial-gradient(
    circle 260px at var(--mouse-x, 50%) var(--mouse-y, 50%),
    rgba(255, 255, 255, 0.04),
    transparent 100%
  );
}

.spotlight-card::before {
  content: '';
  position: absolute;
  inset: -1px;
  border-radius: inherit;
  padding: 1px;
  background: radial-gradient(
    circle 220px at var(--mouse-x, 50%) var(--mouse-y, 50%),
    rgba(6, 182, 212, 0.4),
    transparent 70%
  );
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
  opacity: var(--hover-active, 0);
  transition: opacity 0.3s ease;
}

/* ---------- 出口胶囊条样式优化 (P0-F3) ---------- */

.room-exits {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.exit-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 36px;
  padding: 4px 12px;
  border-radius: 999px;
  background: rgba(14, 165, 233, 0.12);
  border: 1px solid rgba(14, 165, 233, 0.38);
  color: #38bdf8;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
}

.exit-chip:hover:not(:disabled) {
  background: rgba(14, 165, 233, 0.24);
  border-color: #38bdf8;
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(14, 165, 233, 0.3);
}

.exit-chip.locked {
  background: rgba(30, 27, 21, 0.6);
  border-color: var(--line-soft);
  color: var(--rice-dim);
  cursor: not-allowed;
  opacity: 0.75;
}

/* ---------- 首胜 / 破境仪式 (3a) ---------- */
.is-ritual,
.chat-message.is-ritual,
.chat-message.is-ritual .message-bubble,
.chat-message.is-bot.is-ritual .message-bubble {
  border: 1px solid rgba(212, 160, 23, 0.35) !important;
  border-style: solid !important;
  background: linear-gradient(180deg, #1e160f, #0e0d0a) !important;
  box-shadow: 0 0 0 1px rgba(212, 160, 23, 0.15) inset !important;
  color: var(--gold-bright) !important;
  border-radius: 8px !important;
  text-align: center !important;
  margin: 6px 0 !important;
  padding: 8px 12px !important;
  z-index: 2 !important;
  font-weight: 600;
}

.is-ritual .message-bubble,
.is-ritual.log-line {
  color: var(--gold-bright) !important;
  letter-spacing: 0.05em;
}

/* ---------- @ 高亮 (is-mention) ---------- */
.is-mention,
.chat-message.is-mention,
.chat-message.is-mention .message-bubble {
  background: #2a1f0f !important;
  border-left: 3px solid #d4a017 !important;
}

@keyframes rewardPopAnim {
  0% { transform: scale(0.96); opacity: 0.8; }
  50% { transform: scale(1.03); filter: brightness(1.3); }
  100% { transform: scale(1); opacity: 1; filter: brightness(1); }
}

.reward-pop {
  animation: rewardPopAnim 0.45s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

/* ---------- 故事右栏 (3b) ---------- */
.story-strip {
  padding: 10px 14px;
  margin-bottom: 12px;
  background: rgba(22, 20, 16, 0.75);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
  font-size: 13px;
  line-height: 1.5;
}

.story-progress {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
}

.story-chapter-title {
  color: var(--gold-bright);
  font-weight: 600;
}

.story-blocks {
  letter-spacing: 2px;
  color: var(--rice);
}

.story-next-hint {
  color: #06b6d4; /* 青玉色 */
  font-size: 12px;
}

