:root {
  --primary-color: #ff598f;
  --bg-dark: #0c0d11;
  --panel-bg: rgba(10, 12, 18, 0.66);
  --panel-border: rgba(255, 255, 255, 0.12);
  --text-main: #f5f6fa;
  --text-dim: #a6abbc;
  --text-sub: #7a8094;
  --accent-glow: rgba(255, 89, 143, 0.35);
  /* 立绘取景：头顶距屏幕上沿 = --chara-top，立绘总高 = --chara-h；
     裙摆大约在整体高度 58% 处，所以 (box-top - chara-top) / 0.58 ≈ chara-h */
  --chara-top: 8vh;
  --chara-h: 110vh;
  --box-h: 25vh;
}

* {
  box-sizing: border-box;
  user-select: none;
  -webkit-user-select: none;
}

html, body {
  margin: 0;
  padding: 0;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  background-color: var(--bg-dark);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Yu Gothic UI", sans-serif;
}

#game-container {
  position: relative;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  background: #000;
}

/* ================= 舞台背景层 ================= */
#stage-bg-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
}

.stage-bg {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-size: cover;
  background-position: center center;
  opacity: 0;
  transition: opacity 0.8s ease-in-out, transform 4s ease-out;
  transform: scale(1.02);
}

.stage-bg.active {
  opacity: 1;
  transform: scale(1.0);
}

#bg-black-curtain {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: #000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.5s ease;
  z-index: 2;
}

#bg-black-curtain.active {
  opacity: 1;
}

/* ================= 角色立绘舞台层 ================= */
#stage-chara-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 10;
  pointer-events: none;
}

.chara-slot {
  position: absolute;
  /* 取景：以头顶为锚点向下排，立绘高度由 --chara-h 控制，裙摆正好落在对话框上沿 */
  top: var(--chara-top, 6vh);
  bottom: auto;
  width: 32%;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  transition: opacity 0.35s ease, transform 0.35s ease, filter 0.3s ease;
  opacity: 0;
  pointer-events: none;
  z-index: 20;
}

/* 5个相对站位：pos0=左 / pos1=中 / pos2=右（与游戏脚本语义一致），3、4 为极左极右 */
.slot-3 { left: -2%; transform: translateX(-40px); }
.slot-0 { left: 8%; transform: translateX(-20px); }
.slot-1 { left: 35%; transform: translateX(0); }
.slot-2 { left: 62%; transform: translateX(20px); }
.slot-4 { left: 72%; transform: translateX(40px); }

/* 场上只有一名角色时居中显示 */
.chara-slot.solo { left: 35% !important; transform: translateX(0) !important; }

/* 4 名及以上角色同台时压缩间距与宽度，避免互相遮挡 */
#stage-chara-layer[data-count="4"],
#stage-chara-layer[data-count="5"] {
  /* 同台人多时整体收小，否则最外侧的人会被屏幕边缘切掉 */
  --chara-h: 111vh;
  --chara-top: 7vh;
}
#stage-chara-layer[data-count="3"] {
  --chara-h: 110vh;
  --chara-top: 8vh;
}
#stage-chara-layer[data-count="4"] .chara-slot,
#stage-chara-layer[data-count="5"] .chara-slot { width: 26%; }
#stage-chara-layer[data-count="4"] .slot-3,
#stage-chara-layer[data-count="5"] .slot-3 { left: -1%; }
#stage-chara-layer[data-count="4"] .slot-0,
#stage-chara-layer[data-count="5"] .slot-0 { left: 6%; }
#stage-chara-layer[data-count="4"] .slot-1,
#stage-chara-layer[data-count="5"] .slot-1 { left: 32%; }
#stage-chara-layer[data-count="4"] .slot-2,
#stage-chara-layer[data-count="5"] .slot-2 { left: 58%; }
#stage-chara-layer[data-count="4"] .slot-4,
#stage-chara-layer[data-count="5"] .slot-4 { left: 66%; }

.chara-slot.visible {
  opacity: 1;
  transform: translateX(0);
}

.chara-slot img {
  height: calc(var(--chara-h, 114vh) * var(--chara-k, 1));
  width: auto;
  max-height: none;
  max-width: none;
  flex: 0 0 auto;
  object-fit: contain;
  object-position: top center;
  transform-origin: top center;
  transform: scale(1);
  filter: drop-shadow(0 8px 24px rgba(0, 0, 0, 0.45));
  transition: filter 0.3s ease, transform 0.25s ease;
}

/* 说话人：整层抬到最上（z-index 加在 slot 上，img 的 z-index 管不了跨 slot 的层级） */
.chara-slot.speaking {
  z-index: 60;
}
.chara-slot.dimmed {
  z-index: 15;
}
.chara-slot.speaking img {
  filter: drop-shadow(0 0 16px var(--accent-glow)) drop-shadow(0 10px 30px rgba(0,0,0,0.6));
  transform: scale(1.012);
}

.chara-slot.dimmed img {
  filter: brightness(0.65) drop-shadow(0 4px 12px rgba(0, 0, 0, 0.5));
  transform: scale(0.995);
}

/* 矮胖体型（音击猫等吉祥物，图幅接近正方）：整只抬到对话框上方，别再被吃掉半截 */
.chara-slot.chibi {
  top: auto;
  bottom: calc(var(--box-h, 25vh) + 6px);
  align-items: flex-end;
}
.chara-slot.chibi img {
  height: calc(var(--chara-h, 114vh) * 0.42 * var(--chara-k, 1));
}

/* 动作动画: 跳动、震动、淡出 */
@keyframes charaJump {
  0%, 100% { transform: translateY(0); }
  40% { transform: translateY(-45px); }
}

@keyframes charaShake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-12px); }
  40% { transform: translateX(12px); }
  60% { transform: translateX(-8px); }
  80% { transform: translateX(8px); }
}

.chara-slot.act-jump {
  animation: charaJump 0.45s cubic-bezier(0.25, 1, 0.5, 1);
}

.chara-slot.act-shake {
  animation: charaShake 0.45s ease-in-out;
}

/* 退场动画 */
@keyframes charaOut {
  to { opacity: 0; transform: translateY(18px) scale(0.96); }
}

.chara-slot.act-out {
  animation: charaOut 0.32s ease-in forwards;
}

/* ================= 顶部控制栏 ================= */
#top-bar {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 52px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 18px;
  background: linear-gradient(180deg, rgba(8, 10, 16, 0.88) 0%, rgba(8, 10, 16, 0.25) 75%, transparent 100%);
  z-index: 100;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.header-left, .header-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

#chapter-indicator {
  font-size: 14px;
  color: var(--text-dim);
  font-weight: 500;
  margin-left: 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 45vw;
}

#chapter-indicator #story-label {
  color: var(--text-main);
  font-weight: 600;
}

.bar-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: var(--text-main);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 13px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  flex: 0 0 auto;
  transition: all 0.2s ease;
}

.bar-btn .ic {
  font-size: 14px;
  line-height: 1;
  opacity: 0.9;
}

.bar-btn svg {
  width: 16px;
  height: 16px;
}

.bar-btn:hover {
  background: rgba(255, 255, 255, 0.18);
  border-color: rgba(255, 255, 255, 0.3);
}

.bar-btn.active {
  background: var(--primary-color);
  border-color: var(--primary-color);
  color: #fff;
  box-shadow: 0 0 12px var(--accent-glow);
}

/* 窄屏只留图标，靠 title 提示 */
@media (max-width: 1080px) {
  .bar-btn .lb { display: none; }
  .bar-btn { padding: 7px 9px; }
}

/* ================= 每话标题卡 ================= */
.episode-card {
  position: absolute;
  inset: 0;
  z-index: 400;
  background: radial-gradient(circle at 50% 40%, rgba(30, 36, 52, 0.92), rgba(6, 8, 14, 0.97));
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  animation: epFade 0.45s ease;
  backdrop-filter: blur(3px);
}

@keyframes epFade {
  from { opacity: 0; }
  to { opacity: 1; }
}

.episode-card.hidden { display: none !important; }

/* 标题卡显示时隐藏顶部栏与对话框，避免被 backdrop-filter 顶到上层 */
body.ep-card-on #top-bar,
body.ep-card-on #dialogue-box {
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.episode-card-inner {
  text-align: center;
  padding: 0 24px;
  max-width: 720px;
}

.ep-num {
  font-size: 15px;
  letter-spacing: 4px;
  color: var(--primary-color);
  margin-bottom: 12px;
}

.ep-title {
  font-size: 30px;
  font-weight: 700;
  color: #fff;
  line-height: 1.4;
  text-shadow: 0 4px 24px rgba(0, 0, 0, 0.6);
}

.ep-sub {
  margin-top: 10px;
  font-size: 13px;
  color: var(--text-dim);
  letter-spacing: 1px;
}

.ep-hint {
  margin-top: 30px;
  font-size: 12.5px;
  color: var(--text-sub);
  animation: hintPulse 1.6s ease-in-out infinite;
}

@keyframes hintPulse {
  0%, 100% { opacity: 0.45; }
  50% { opacity: 1; }
}

@media (max-aspect-ratio: 1/1) {
  .ep-title { font-size: 24px; }
  .ep-num { font-size: 13px; letter-spacing: 3px; }
}

#dialogue-box.narration .next-indicator {
  animation: none;
  opacity: 0.75;
}

/* ================= 对话框系统 ================= */
#dialogue-box {
  position: absolute;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  width: min(1080px, 94vw);
  min-height: 175px;
  z-index: 50;
  transition: opacity 0.3s ease, transform 0.3s ease;
  cursor: pointer;
}

.dialogue-inner {
  position: relative;
  width: 100%;
  height: 100%;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  padding: 38px 34px 26px 34px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.65), inset 0 1px 0 rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

/* 文本区域压暗 + 向外扩散的柔光暗角（让文字从画面里「浮」出来） */
#dialogue-box::after {
  content: "";
  position: absolute;
  inset: -58px -84px -34px -84px;
  border-radius: 60px;
  background: radial-gradient(ellipse at center,
      rgba(0, 0, 0, 0.62) 0%,
      rgba(0, 0, 0, 0.5) 42%,
      rgba(0, 0, 0, 0.28) 66%,
      rgba(0, 0, 0, 0) 100%);
  z-index: -1;
  pointer-events: none;
}

/* 说话人名牌 */
.speaker-badge {
  position: absolute;
  top: -18px;
  left: 28px;
  background: #1e2230;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-left: 4px solid var(--primary-color);
  border-radius: 6px;
  padding: 5px 18px;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.5);
  transition: border-left-color 0.2s ease;
}

.speaker-badge #speaker-name {
  font-size: 16px;
  font-weight: 700;
  color: #fff;
  letter-spacing: 0.5px;
}

.voice-tag {
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.12);
  color: var(--text-dim);
}

/* 旁白模式（隐藏名牌、居中/斜体显示） */
#dialogue-box.narration .speaker-badge {
  display: none;
}

/* 旁白：整块移到画面正中，文字居中对齐，背景换成柔和的暗色扩散 */
#dialogue-box.narration {
  top: 50%;
  bottom: auto;
  transform: translate(-50%, -50%);
  width: min(920px, 90vw);
  min-height: 0;
}

#dialogue-box.narration .dialogue-inner {
  background: transparent;
  border: none;
  border-radius: 0;
  box-shadow: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  padding: 6px 30px;
}

#dialogue-box.narration .dialogue-inner::before {
  content: "";
  position: absolute;
  inset: -84px -150px;
  border-radius: 50%;
  background: radial-gradient(closest-side,
      rgba(0, 0, 0, 0.68) 0%,
      rgba(0, 0, 0, 0.5) 52%,
      rgba(0, 0, 0, 0.22) 76%,
      rgba(0, 0, 0, 0) 100%);
  z-index: -1;
}

#dialogue-box.narration::after {
  display: none;
}

#dialogue-box.narration .dialogue-text {
  text-align: center;
  color: #f2f4fa;
  font-style: normal;
  font-size: 20px;
  line-height: 1.95;
  letter-spacing: 0.8px;
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.9);
}

#dialogue-box.narration .next-indicator {
  right: 50%;
  transform: translateX(50%);
  bottom: -26px;
}

/* 文本区 */
.text-wrapper {
  min-height: 80px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.dialogue-text {
  margin: 0;
  font-size: 18px;
  line-height: 1.75;
  white-space: pre-wrap;
  letter-spacing: 0.3px;
  font-weight: 700;
  -webkit-font-smoothing: antialiased;
}

.main-text {
  color: var(--text-main);
  font-weight: 700;
}

.sub-text {
  font-size: 14.5px;
  line-height: 1.6;
  color: var(--text-sub);
  border-top: 1px dashed rgba(255, 255, 255, 0.1);
  padding-top: 6px;
  font-weight: 600;
}

/* 闪烁继续箭头 */
.next-indicator {
  position: absolute;
  right: 22px;
  bottom: 14px;
  color: var(--primary-color);
  width: 26px;
  height: 26px;
  animation: bounceDown 1.1s infinite;
}

@keyframes bounceDown {
  0%, 100% { transform: translateY(0); opacity: 0.8; }
  50% { transform: translateY(6px); opacity: 1; }
}

/* 隐藏UI模式 */
body.hide-ui #top-bar {
  opacity: 0;
  transform: translateY(-50px);
  pointer-events: none;
}

body.hide-ui #dialogue-box {
  opacity: 0;
  transform: translate(-50%, 60px);
  pointer-events: none;
}

/* ================= 侧滑抽屉面板 ================= */
.drawer-panel {
  position: absolute;
  top: 0;
  right: 0;
  width: min(520px, 92vw);
  height: 100vh;
  background: rgba(15, 17, 24, 0.95);
  border-left: 1px solid var(--panel-border);
  box-shadow: -10px 0 35px rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  z-index: 200;
  display: flex;
  flex-direction: column;
  transition: transform 0.35s cubic-bezier(0.25, 1, 0.5, 1);
}

.drawer-panel.hidden {
  transform: translateX(105%);
}

.drawer-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--panel-border);
}

.drawer-header h2 {
  margin: 0;
  font-size: 17px;
  color: #fff;
}

.close-btn {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 26px;
  cursor: pointer;
  line-height: 1;
  padding: 0 4px;
}
.close-btn:hover { color: #fff; }

.drawer-filter {
  padding: 12px 20px;
  border-bottom: 1px solid var(--panel-border);
}

.drawer-filter input {
  width: 100%;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 7px;
  padding: 8px 12px;
  color: #fff;
  font-size: 13px;
  outline: none;
}
.drawer-filter input:focus { border-color: var(--primary-color); }

.drawer-story-tabs {
  display: flex;
  gap: 6px;
  padding: 10px 20px;
  overflow-x: auto;
  border-bottom: 1px solid var(--panel-border);
  white-space: nowrap;
}

.story-tab-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-dim);
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 12px;
  cursor: pointer;
}

.story-tab-btn.active, .story-tab-btn:hover {
  background: rgba(255, 89, 143, 0.2);
  border-color: var(--primary-color);
  color: #fff;
}

.drawer-ep-list, .drawer-log-list {
  flex: 1;
  overflow-y: auto;
  padding: 14px 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* 剧集卡片 */
.ep-card {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  padding: 12px 14px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.ep-card:hover {
  background: rgba(255, 255, 255, 0.09);
  border-color: rgba(255, 255, 255, 0.2);
}

.ep-card.active {
  background: rgba(255, 89, 143, 0.15);
  border-color: var(--primary-color);
}

.ep-card-title {
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  margin-bottom: 4px;
}

.ep-card-summary {
  font-size: 12px;
  color: var(--text-dim);
  line-height: 1.5;
}

/* 历史记录条目 */
.drawer-save-hint {
  padding: 10px 20px;
  font-size: 12px;
  color: var(--text-dim);
  border-bottom: 1px solid var(--panel-border);
}

.drawer-save-list {
  flex: 1;
  overflow-y: auto;
  padding: 14px 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.save-slot {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 9px;
  padding: 10px 12px;
}

.save-slot-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.save-slot-name {
  font-size: 13px;
  font-weight: 700;
  color: #fff;
}

.save-slot-time {
  font-size: 11px;
  color: var(--text-sub);
}

.save-slot-info {
  font-size: 12px;
  color: var(--text-dim);
  line-height: 1.5;
  min-height: 32px;
  margin-bottom: 8px;
  word-break: break-all;
}

.save-slot-info.empty {
  color: var(--text-sub);
  font-style: italic;
}

.save-slot-actions {
  display: flex;
  gap: 8px;
}

.save-btn {
  flex: 1;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.16);
  color: #fff;
  border-radius: 6px;
  padding: 5px 0;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s;
}

.save-btn:hover {
  background: rgba(255, 255, 255, 0.18);
}

.save-btn.primary {
  background: rgba(255, 89, 143, 0.22);
  border-color: var(--primary-color);
}

.save-btn.danger:hover {
  background: rgba(255, 80, 80, 0.3);
  border-color: #ff5c5c;
}

.drawer-save-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--panel-border);
}

.save-clear-btn {
  width: 100%;
  background: transparent;
  border: 1px solid rgba(255, 90, 90, 0.45);
  color: #ff8a8a;
  border-radius: 6px;
  padding: 7px 0;
  font-size: 12px;
  cursor: pointer;
}

.save-clear-btn:hover {
  background: rgba(255, 90, 90, 0.15);
}

/* 轻提示 */
.toast {
  position: absolute;
  left: 50%;
  bottom: 220px;
  transform: translateX(-50%);
  background: rgba(20, 24, 34, 0.94);
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: #fff;
  padding: 9px 18px;
  border-radius: 8px;
  font-size: 13.5px;
  z-index: 300;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.toast.hidden {
  opacity: 0;
  transform: translate(-50%, 8px);
}

.log-divider {
  text-align: center;
  color: var(--primary-color);
  font-size: 13px;
  font-weight: 600;
  padding: 10px 0;
  border-bottom: 1px dashed rgba(255, 89, 143, 0.3);
  margin: 6px 0;
}

.log-item-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.log-voice-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 4px;
  color: #fff;
  font-size: 11px;
  padding: 2px 6px;
  cursor: pointer;
  transition: all 0.2s;
}
.log-voice-btn:hover {
  background: var(--primary-color);
  border-color: var(--primary-color);
}

.log-item {
  padding: 8px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.log-item-spk {
  font-size: 13px;
  font-weight: 600;
}

.log-item-text {
  font-size: 14px;
  color: var(--text-main);
  line-height: 1.6;
  white-space: pre-wrap;
}

.hidden { display: none !important; }

/* ================= 触屏模式 ================= */
body.touch-mode #top-bar { height: 56px; }
body.touch-mode .bar-btn { padding: 9px 13px; font-size: 14px; }
body.touch-mode #dialogue-box { cursor: pointer; }
body.touch-mode #dialogue-box::before {
  content: "轻点继续 · 上滑下一句 · 下滑上一句";
  position: absolute;
  right: 16px;
  top: -22px;
  font-size: 11px;
  color: var(--text-sub);
  background: rgba(0, 0, 0, 0.35);
  padding: 2px 8px;
  border-radius: 5px;
}

/* ================= 竖屏 / 窄屏适配 ================= */
@media (max-aspect-ratio: 1/1) {
  #top-bar {
    height: auto;
    min-height: 48px;
    flex-wrap: wrap;
    gap: 6px;
    padding: 6px 10px;
    align-items: center;
  }
  .header-left { flex: 0 0 100%; }
  .header-right {
    flex: 0 0 100%;
    justify-content: flex-start;
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
    padding-bottom: 2px;
  }
  .header-right::-webkit-scrollbar { display: none; }
  #chapter-indicator {
    max-width: 100%;
    font-size: 11.5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
  }
  .bar-btn { padding: 5px 9px; font-size: 12px; }

  /* 竖屏取景：头顶让开两行顶栏，裙摆落在对话框上沿 */
  :root {
    --chara-top: 15vh;
    --chara-h: 99vh;
    --box-h: 27vh;
  }
  .chara-slot {
    width: 46%;
    top: var(--chara-top);
    bottom: auto;
  }
  #stage-chara-layer[data-count="3"] { --chara-h: 98vh; --chara-top: 15vh; }
  #stage-chara-layer[data-count="4"],
  #stage-chara-layer[data-count="5"] { --chara-h: 90vh; --chara-top: 15.5vh; }
  .chara-slot.chibi {
    top: auto;
    bottom: calc(var(--box-h) + 6px);
  }
  .slot-0 { left: 2%; }
  .slot-1 { left: 27%; }
  .slot-2 { left: 52%; }
  .slot-3 { left: -12%; }
  .slot-4 { left: 64%; }
  .chara-slot.solo { left: 27% !important; }
  #stage-chara-layer[data-count="4"] .chara-slot,
  #stage-chara-layer[data-count="5"] .chara-slot { width: 38%; }
  #stage-chara-layer[data-count="4"] .slot-0 { left: 0%; }
  #stage-chara-layer[data-count="4"] .slot-1 { left: 22%; }
  #stage-chara-layer[data-count="4"] .slot-2 { left: 44%; }
  #stage-chara-layer[data-count="4"] .slot-3 { left: -16%; }
  #stage-chara-layer[data-count="4"] .slot-4 { left: 62%; }

  /* 对话框：更高、字号更大，便于手指阅读 */
  #dialogue-box {
    width: 96vw;
    bottom: 12px;
    min-height: 26vh;
  }
  .dialogue-inner { padding: 34px 18px 22px 18px; border-radius: 12px; }
  .speaker-badge { left: 14px; top: -16px; padding: 4px 12px; }
  .speaker-badge #speaker-name { font-size: 15px; }
  .dialogue-text { font-size: 16.5px; line-height: 1.8; }
  .sub-text { font-size: 13.5px; }
  .drawer-panel { width: 100vw; }
  .toast { bottom: auto; top: 92px; }
  body.touch-mode #dialogue-box::before {
    content: "轻点继续 · 上滑/下滑翻页";
    right: 10px;
    font-size: 10.5px;
  }
}

/* 超窄屏（手机竖屏）进一步压缩 */
@media (max-width: 480px) {
  .dialogue-text { font-size: 15.5px; }
  .bar-btn span { font-size: 12px; }
}
