/* 全局样式 */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* ========== 介绍页 ========== */
#intro-screen {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 500;
  background: linear-gradient(135deg, #0a0520 0%, #1a0a3a 40%, #0d1b2a 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: introFadeIn 0.8s ease;
}

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

.intro-content {
  text-align: center;
  max-width: 100%;
  padding: 30px 20px;
}

.intro-genre {
  display: inline-block;
  color: #c9b1ff;
  font-size: 13px;
  letter-spacing: 2px;
  padding: 4px 16px;
  border: 1px solid rgba(200,177,255,0.3);
  border-radius: 20px;
  margin-bottom: 24px;
}

.intro-genre:empty {
  display: none;
}

.intro-title {
  font-size: 24px;
  font-weight: bold;
  background: linear-gradient(135deg, #a0c4ff, #c9b1ff, #ffd6ff);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 20px;
  line-height: 1.3;
  text-shadow: none;
}

.intro-synopsis {
  color: rgba(200,200,220,0.85);
  font-size: 16px;
  font-style: italic;
  line-height: 1.8;
  margin-bottom: 36px;
  letter-spacing: 0.5px;
}

.intro-synopsis:empty {
  display: none;
}

.intro-protagonist {
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(100,150,255,0.15);
  border-radius: 12px;
  padding: 20px 24px;
  margin-bottom: 36px;
}

.intro-protag-label {
  color: rgba(160,196,255,0.6);
  font-size: 12px;
  letter-spacing: 3px;
  margin-bottom: 8px;
}

.intro-protag-name {
  color: #a0c4ff;
  font-size: 22px;
  font-weight: bold;
  margin-bottom: 8px;
}

.intro-protag-desc {
  color: rgba(200,200,220,0.7);
  font-size: 14px;
  line-height: 1.6;
}

.intro-start-btn {
  background: linear-gradient(135deg, rgba(100,150,255,0.2), rgba(200,177,255,0.2));
  border: 1px solid rgba(100,150,255,0.4);
  color: #a0c4ff;
  font-size: 18px;
  padding: 14px 48px;
  border-radius: 30px;
  cursor: pointer;
  transition: all 0.3s;
  letter-spacing: 4px;
}

.intro-start-btn:hover {
  background: linear-gradient(135deg, rgba(100,150,255,0.35), rgba(200,177,255,0.35));
  transform: translateY(-2px);
  box-shadow: 0 4px 20px rgba(100,150,255,0.3);
  border-color: rgba(100,150,255,0.6);
  color: #fff;
}

@media (max-width: 768px) {
  .intro-content {
    padding: 30px 20px;
  }

  .intro-title {
    font-size: 26px;
  }

  .intro-synopsis {
    font-size: 14px;
    margin-bottom: 28px;
  }

  .intro-protagonist {
    padding: 16px 18px;
    margin-bottom: 28px;
  }

  .intro-protag-name {
    font-size: 18px;
  }

  .intro-protag-desc {
    font-size: 13px;
  }

  .intro-start-btn {
    font-size: 16px;
    padding: 12px 40px;
  }
}

body {
  font-family: 'Microsoft YaHei', 'PingFang SC', 'SimHei', Arial, sans-serif;
  background: #08081a;
  overflow: hidden;
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100vw;
  height: 100vh;
}

/* 游戏容器 — 紧凑竖版视口 */
#game-container {
  width: min(33vw, 480px);
  height: 100vh;
  max-height: calc(min(33vw, 480px) * 16 / 9);
  position: relative;
  display: flex;
  flex-direction: column;
  border-left: 1px solid rgba(100,150,255,0.08);
  border-right: 1px solid rgba(100,150,255,0.08);
  box-shadow: 0 0 80px rgba(80,120,200,0.06);
  overflow: hidden;
}

/* 标题栏 */
#title-bar {
  background: linear-gradient(to bottom, rgba(10,5,30,0.95), rgba(10,5,30,0.5));
  color: #fff;
  padding: 8px 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  z-index: 100;
}

#game-title {
  font-size: 16px;
  font-weight: bold;
  text-shadow: 0 0 10px rgba(100,150,255,0.5), 2px 2px 4px rgba(0,0,0,0.8);
  background: linear-gradient(135deg, #a0c4ff, #c9b1ff, #ffd6ff);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#title-buttons {
  position: absolute;
  top: 50px;
  right: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 101;
}

.title-button {
  display: flex;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  padding: 0;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  background: rgba(10,5,30,0.55);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(100,150,255,0.15);
  color: #a0c4ff;
  cursor: pointer;
  transition: all 0.3s;
  line-height: 1;
}

.title-button:hover {
  background: rgba(100,150,255,0.3);
  border-color: rgba(100,150,255,0.4);
}

/* 背景层 */
#background {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  transition: opacity 0.8s ease;
  z-index: 1;
}

/* 分镜模式背景图适配（竖版场景图，cover 填满无黑边） */
#background.storyboard-mode {
  background-size: cover;
  background-position: center 30%;
}

/* 分镜模式：左上角属性面板区域毛玻璃 */
#background.storyboard-mode::before {
  content: '';
  position: absolute;
  top: 0; left: 0;
  width: 55%; height: 90px;
  background: linear-gradient(135deg, rgba(0,0,0,0.3), transparent);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  mask-image: linear-gradient(to bottom, black, transparent);
  -webkit-mask-image: linear-gradient(to bottom, black, transparent);
  pointer-events: none; z-index: 1;
}

/* 分镜模式：右上角按钮区域毛玻璃 */
#background.storyboard-mode::after {
  content: '';
  position: absolute;
  top: 0; right: 0;
  width: 55px; height: 150px;
  background: linear-gradient(180deg, rgba(0,0,0,0.25), transparent);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  mask-image: linear-gradient(to bottom, black 60%, transparent);
  -webkit-mask-image: linear-gradient(to bottom, black 60%, transparent);
  pointer-events: none; z-index: 1;
}

/* 分镜模式下对话框增强模糊 */
.storyboard-mode ~ #dialogue-layer #dialogue-box {
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

/* 特效层 */
#effects-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 2;
  pointer-events: none;
}

/* 角色层 */
#characters {
  position: absolute;
  top: 15%;
  bottom: -10%;
  left: 0;
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 3%;
  z-index: 3;
  pointer-events: none;
}

.character {
  max-height: 90%;
  max-width: 65%;
  object-fit: contain;
  transition: opacity 0.5s, transform 0.3s;
  filter: drop-shadow(0 4px 12px rgba(0,0,0,0.5));
}

.character-left {
  align-self: center;
  margin-left: 0;
  margin-right: auto;
}

.character-right {
  align-self: center;
  margin-left: auto;
  margin-right: 0;
}

.character-center {
  align-self: center;
  margin: 0 auto;
}

/* 弹幕层 */
#danmaku-layer {
  position: absolute;
  top: 80px;
  left: 0;
  width: 100%;
  height: 40%;
  z-index: 4;
  pointer-events: none;
  overflow: hidden;
}

.danmaku-item {
  position: absolute;
  white-space: nowrap;
  color: rgba(255,255,255,0.85);
  font-size: 16px;
  text-shadow: 1px 1px 2px rgba(0,0,0,0.8);
  animation: danmaku-scroll 8s linear forwards;
}

@keyframes danmaku-scroll {
  from { transform: translateX(480px); }
  to { transform: translateX(-100%); }
}

/* 对话框层 */
#dialogue-layer {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  z-index: 10;
  padding: 20px 12px 12px;
  overflow: visible;
}

#dialogue-box {
  background: linear-gradient(135deg, rgba(10,5,30,0.92), rgba(20,10,50,0.92));
  border: 1px solid rgba(100,150,255,0.25);
  border-radius: 12px;
  padding: 16px 16px 14px;
  max-width: 100%;
  margin: 0 auto;
  box-shadow: 0 4px 30px rgba(0,0,0,0.6), inset 0 1px 0 rgba(100,150,255,0.1);
  cursor: pointer;
  backdrop-filter: blur(10px);
  position: relative;
  overflow: visible;
}

/* Speaker 名称外置标签 — 与框体顶部融合 */
#speaker-name {
  position: absolute;
  top: -12px;
  left: 16px;
  padding: 2px 12px;
  font-size: 12px;
  font-weight: bold;
  border-radius: 6px 6px 0 0;
  border: 1px solid rgba(100,150,255,0.3);
  border-bottom: none;
  z-index: 1;
  white-space: nowrap;
  color: #c9b1ff;
  background: linear-gradient(135deg, rgba(30,15,60,0.95), rgba(50,25,90,0.95));
  text-shadow: 0 0 8px rgba(100,150,255,0.4);
}

#speaker-name.narrator {
  color: #9098b0;
  background: linear-gradient(135deg, rgba(12,12,28,0.95), rgba(18,18,40,0.95));
  border-color: rgba(180,180,220,0.2);
}

#dialogue-text {
  color: #e0e0e0;
  font-size: 15px;
  line-height: 1.8;
  min-height: 50px;
  white-space: pre-wrap;
  text-align: left;
}

/* 旁白分页时限制高度 */
#dialogue-text.paginated {
  max-height: 5.4em;
  overflow: hidden;
}

/* 选项容器 */
#choices {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 12px;
  max-width: 100%;
  margin-left: auto;
  margin-right: auto;
}

.choice-button {
  background: linear-gradient(135deg, rgba(30,15,60,0.85), rgba(50,25,90,0.85));
  border: 1px solid rgba(100,150,255,0.3);
  color: #e0e0e0;
  padding: 15px 25px;
  font-size: 16px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.3s;
  text-align: left;
  backdrop-filter: blur(5px);
}

.choice-button:hover {
  background: linear-gradient(135deg, rgba(50,30,100,0.9), rgba(80,50,140,0.9));
  transform: translateX(10px);
  box-shadow: 0 0 20px rgba(100,150,255,0.3);
  border-color: rgba(100,150,255,0.6);
  color: #fff;
}

.choice-button .choice-label {
  color: #a0c4ff;
  font-weight: bold;
  margin-right: 8px;
}

.continue-button {
  background: linear-gradient(135deg, rgba(20,30,60,0.85), rgba(30,50,90,0.85));
  text-align: center;
  border-color: rgba(100,200,255,0.3);
}

.continue-button:hover {
  background: linear-gradient(135deg, rgba(30,50,90,0.9), rgba(50,80,130,0.9));
  transform: translateY(-3px);
  box-shadow: 0 4px 20px rgba(100,200,255,0.3);
}

/* 变量显示面板 — 左上角 3D 效果 */
#variables-panel {
  position: absolute;
  top: 50px;
  left: 10px;
  right: auto;
  background: linear-gradient(135deg, rgba(10,5,30,0.7), rgba(20,10,50,0.7));
  border: 1px solid rgba(100,150,255,0.15);
  border-top: 1px solid rgba(255,255,255,0.08);
  border-radius: 8px;
  padding: 10px 12px;
  min-width: auto;
  width: auto;
  z-index: 50;
  backdrop-filter: blur(10px);
  transform: perspective(800px) rotateY(-2deg);
  box-shadow: 0 4px 12px rgba(0,0,0,0.4), 0 1px 0 rgba(255,255,255,0.05) inset;
}

.variable-item {
  margin-bottom: 8px;
  position: relative;
}

.variable-item:last-child {
  margin-bottom: 0;
}

.variable-label {
  color: #a0c4ff;
  font-size: 12px;
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 2px;
}

.var-icon {
  margin-right: 2px;
}

.var-text {
  flex: 1;
}

.var-num {
  min-width: 22px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.variable-bar-container {
  width: 100%;
  height: 6px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(100,150,255,0.15);
  border-radius: 3px;
  overflow: hidden;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.08);
}

.variable-bar {
  height: 100%;
  transition: width 0.5s ease;
  border-radius: 3px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.2), 0 1px 3px rgba(0,0,0,0.3);
}

.courage-bar {
  background: linear-gradient(to right, #ff6b6b, #ff9a56);
  box-shadow: 0 0 5px #ff6b6b;
}

.sincerity-bar {
  background: linear-gradient(to right, #56c4ff, #a0c4ff);
  box-shadow: 0 0 5px #56c4ff;
}

.humanity-bar {
  background: linear-gradient(to right, #56ffa0, #a0ffc4);
  box-shadow: 0 0 5px #56ffa0;
}

.conviction-bar {
  background: linear-gradient(to right, #c9b1ff, #ffd6ff);
  box-shadow: 0 0 5px #c9b1ff;
}

/* 动态属性条颜色 (5种循环) */
.dynamic-bar-0 {
  background: linear-gradient(to right, #ff6b6b, #ff9a56);
  box-shadow: 0 0 5px #ff6b6b;
}
.dynamic-bar-1 {
  background: linear-gradient(to right, #56c4ff, #a0c4ff);
  box-shadow: 0 0 5px #56c4ff;
}
.dynamic-bar-2 {
  background: linear-gradient(to right, #56ffa0, #a0ffc4);
  box-shadow: 0 0 5px #56ffa0;
}
.dynamic-bar-3 {
  background: linear-gradient(to right, #c9b1ff, #ffd6ff);
  box-shadow: 0 0 5px #c9b1ff;
}
.dynamic-bar-4 {
  background: linear-gradient(to right, #ffd700, #ffec80);
  box-shadow: 0 0 5px #ffd700;
}

/* ===== 主角对话模式 (desktop) ===== */
#dialogue-box.dialogue-protagonist {
  background: linear-gradient(135deg, rgba(8,15,35,0.92), rgba(15,25,55,0.92));
  border-color: rgba(100,180,255,0.3);
  border-left: 3px solid rgba(100,180,255,0.5);
}

#dialogue-box.dialogue-protagonist #speaker-name {
  color: #80c8ff;
  background: linear-gradient(135deg, rgba(15,25,55,0.95), rgba(25,40,80,0.95));
  border-color: rgba(100,180,255,0.4);
}

/* ===== 配角对话模式 (desktop) ===== */
#dialogue-box.dialogue-other {
  background: linear-gradient(135deg, rgba(10,5,30,0.92), rgba(20,10,50,0.92));
  border-color: rgba(200,177,255,0.3);
  border-left: 3px solid rgba(200,177,255,0.5);
}

#dialogue-box.dialogue-other #speaker-name {
  color: #c9b1ff;
  background: linear-gradient(135deg, rgba(30,15,60,0.95), rgba(50,25,90,0.95));
  border-color: rgba(200,177,255,0.4);
}

/* ===== Narration Mode (desktop) ===== */
#dialogue-box.narration-mode {
  background: linear-gradient(135deg, rgba(5,5,20,0.88), rgba(10,10,35,0.88));
  border-color: rgba(180,180,220,0.15);
  text-align: left;
}

#dialogue-box.narration-mode #speaker-name {
  color: #9098b0;
  background: linear-gradient(135deg, rgba(12,12,28,0.95), rgba(18,18,40,0.95));
  border-color: rgba(180,180,220,0.2);
}

#dialogue-box.narration-mode #dialogue-text {
  color: #b0b8d0;
  line-height: 2;
  letter-spacing: 0.5px;
}

/* ===== Thought Mode (desktop) ===== */
#dialogue-box.thought-mode {
  background: linear-gradient(135deg, rgba(20,8,40,0.92), rgba(35,15,60,0.92));
  border-color: rgba(180,140,255,0.35);
  border-left: 3px solid rgba(180,140,255,0.6);
  box-shadow: 0 4px 30px rgba(0,0,0,0.6), inset 0 0 30px rgba(140,100,220,0.06);
}

#dialogue-box.thought-mode #speaker-name {
  color: #d4c4f0;
  background: linear-gradient(135deg, rgba(35,15,60,0.95), rgba(55,25,90,0.95));
  border-color: rgba(180,140,255,0.4);
}

#dialogue-box.thought-mode #dialogue-text {
  font-style: italic;
  color: #d4c4f0;
  text-shadow: 0 0 8px rgba(180,140,255,0.15);
}

/* 菜单 */
#game-menu {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: linear-gradient(135deg, rgba(10,5,30,0.97), rgba(20,10,50,0.97));
  border: 1px solid rgba(100,150,255,0.3);
  border-radius: 12px;
  padding: 24px 20px;
  min-width: auto;
  width: calc(100% - 32px);
  max-width: 340px;
  z-index: 200;
  display: none;
  backdrop-filter: blur(15px);
}

.menu-title {
  color: #a0c4ff;
  font-size: 24px;
  text-align: center;
  margin-bottom: 20px;
  text-shadow: 0 0 10px rgba(100,150,255,0.4);
}

.menu-section {
  margin-bottom: 20px;
}

.menu-section-title {
  color: #c9b1ff;
  font-size: 16px;
  margin-bottom: 10px;
}

.save-slot {
  display: flex;
  gap: 10px;
  margin-bottom: 10px;
}

.save-button, .load-button {
  flex: 1;
  background: rgba(50,25,90,0.6);
  border: 1px solid rgba(100,150,255,0.2);
  color: #e0e0e0;
  padding: 10px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.3s;
  font-size: 14px;
}

.save-button:hover, .load-button:hover {
  background: rgba(80,50,140,0.8);
  border-color: rgba(100,150,255,0.5);
}

.close-menu-button {
  width: 100%;
  background: rgba(150, 50, 50, 0.5);
  border: 1px solid rgba(255, 100, 100, 0.3);
  color: #ff9a9a;
  padding: 12px;
  border-radius: 4px;
  cursor: pointer;
  margin-top: 20px;
  transition: all 0.3s;
  font-size: 14px;
}

.close-menu-button:hover {
  background: rgba(180, 70, 70, 0.7);
}

/* 章节标题过渡 */
.chapter-title-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.9);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  z-index: 150;
  animation: chapterFade 3s ease forwards;
}

.chapter-title-overlay h2 {
  color: #a0c4ff;
  font-size: 24px;
  text-shadow: 0 0 20px rgba(100,150,255,0.5);
  margin-bottom: 10px;
}

.chapter-title-overlay p {
  color: #c9b1ff;
  font-size: 15px;
}

@keyframes chapterFade {
  0% { opacity: 0; }
  20% { opacity: 1; }
  80% { opacity: 1; }
  100% { opacity: 0; pointer-events: none; }
}

/* 角色切换指示器 */
.character-indicator {
  display: none;
}

/* ========== 对话模式动画 ========== */
@keyframes narratorFloatIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes thoughtPulse {
  0%, 100% { border-color: rgba(200,177,255,0.2); box-shadow: 0 0 15px rgba(100,80,180,0.1); }
  50% { border-color: rgba(200,177,255,0.45); box-shadow: 0 0 25px rgba(100,80,180,0.2); }
}

/* ========== 响应式设计 - 手机端 ========== */
@media (max-width: 768px) {

  /* === 0. 恢复全屏视口 === */
  #game-container {
    width: 100vw;
    height: 100vh;
    max-height: none;
    border-left: none;
    border-right: none;
    box-shadow: none;
  }

  /* === 1. 标题栏：安全区域渐变遮罩 === */
  #title-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    padding: 0;
    background: linear-gradient(to bottom, rgba(0,0,0,0.55) 0%, rgba(0,0,0,0.2) 60%, transparent 100%);
    height: calc(env(safe-area-inset-top, 20px) + 56px);
    z-index: 99;
    pointer-events: none;
    display: block;
  }

  #game-title {
    display: none;
  }

  /* === 2. 数值面板：胶囊徽章 === */
  #variables-panel {
    position: fixed;
    top: calc(env(safe-area-inset-top, 20px) + 8px);
    left: 12px;
    right: 56px;
    bottom: auto;
    width: auto;
    min-width: auto;
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 5px;
    padding: 0;
    background: none;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    border-radius: 0;
    border: none;
    justify-content: flex-start;
    z-index: 100;
    overflow: hidden;
  }

  .variable-item {
    margin-bottom: 0;
    display: flex;
    align-items: center;
    gap: 0;
    flex: 0 1 auto;
    min-width: 0;
    background: rgba(0,0,0,0.35);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: 16px;
    padding: 3px 8px 3px 4px;
    border: 1px solid rgba(255,255,255,0.08);
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    overflow: hidden;
  }

  .variable-label {
    font-size: 14px;
    margin-bottom: 0;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 2px;
  }

  .var-icon {
    font-size: 20px;
    line-height: 1;
    filter: drop-shadow(0 2px 3px rgba(0,0,0,0.4));
    margin-right: 3px;
  }

  .var-text {
    display: inline;
    font-size: 11px;
    color: rgba(255,255,255,0.85);
    margin-right: 2px;
  }

  .var-num {
    font-weight: 700;
    font-size: 14px;
    color: #fff;
    text-shadow: 0 1px 3px rgba(0,0,0,0.5);
    min-width: 14px;
    text-align: center;
  }

  .variable-bar-container {
    display: none;
  }

  /* === 3. 操作按钮：右侧纵向排列 === */
  #title-buttons {
    position: fixed !important;
    top: calc(env(safe-area-inset-top, 20px) + 8px);
    right: 8px;
    display: flex !important;
    flex-direction: column;
    gap: 8px;
    z-index: 101;
    pointer-events: auto;
  }

  .title-button {
    display: flex !important;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    padding: 0;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    background: rgba(10,5,30,0.55);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(100,150,255,0.15);
    color: #a0c4ff;
    line-height: 1;
  }

  .title-button:hover {
    transform: none;
    box-shadow: none;
  }

  /* === 4. 角色层：居中显示，腰部以下与文本框重叠 === */
  #characters {
    top: 15%;
    bottom: -10%;
    height: auto;
    justify-content: center;
    align-items: center;
    padding: 0;
  }

  .character {
    max-width: 80%;
    max-height: 90%;
    transition: opacity 0.4s ease, transform 0.3s ease;
    filter: drop-shadow(0 4px 10px rgba(0,0,0,0.5));
  }

  .character-left {
    margin-right: auto;
    margin-left: 0;
  }

  .character-right {
    margin-left: auto;
    margin-right: 0;
  }

  /* 角色切换指示器：已移除 */
  .character-indicator {
    display: none !important;
  }

  /* === 5. 对话框层 === */
  #dialogue-layer {
    bottom: 14%;
    padding: 18px 0 0;
    overflow: visible;
  }

  #dialogue-box {
    padding: 16px 16px 14px;
    margin: 0 10px;
    border-radius: 14px;
    transition: background 0.3s, border-color 0.3s, border-left 0.3s, border-right 0.3s;
    position: relative;
    overflow: visible;
  }

  /* 说话人名字：外置标签，与框体融合 */
  #speaker-name {
    position: absolute;
    top: -11px;
    left: 16px;
    font-size: 12px;
    padding: 2px 14px;
    border-radius: 10px 10px 0 0;
    background: linear-gradient(135deg, rgba(30,15,60,0.95), rgba(50,25,90,0.95));
    border: 1px solid rgba(100,150,255,0.3);
    border-bottom: none;
    margin-bottom: 0;
    z-index: 1;
    white-space: nowrap;
  }

  #dialogue-text {
    font-size: 14px;
    line-height: 1.7;
    min-height: 40px;
  }

  /* --- 5a. 旁白模式 --- */
  #dialogue-box.narration-mode {
    background: linear-gradient(to top, rgba(0,0,0,0.8) 0%, rgba(0,0,0,0.5) 60%, rgba(0,0,0,0.1) 100%);
    border: none;
    border-radius: 0;
    box-shadow: none;
    margin: 0;
    padding: 32px 24px 20px;
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    text-align: left;
    animation: narratorFloatIn 0.6s ease-out;
  }

  #dialogue-box.narration-mode #speaker-name {
    display: none;
  }

  #dialogue-box.narration-mode #dialogue-text {
    color: rgba(255,255,255,0.92);
    font-size: 14px;
    text-align: left;
    letter-spacing: 0.5px;
    line-height: 1.9;
    text-shadow: 0 1px 8px rgba(0,0,0,0.9);
  }

  /* --- 5b. 内心独白模式：气泡风格 --- */
  #dialogue-box.thought-mode {
    background: linear-gradient(135deg, rgba(65,30,110,0.92), rgba(40,18,75,0.92));
    border: 2px solid rgba(180,140,255,0.25);
    border-radius: 20px;
    box-shadow: 0 0 30px rgba(140,100,220,0.18),
                inset 0 0 25px rgba(120,80,200,0.08);
    animation: thoughtPulse 3s ease-in-out infinite;
  }

  #dialogue-box.thought-mode::before {
    content: "\1F4AD";
    position: absolute;
    top: -24px;
    left: 16px;
    font-size: 22px;
    font-style: normal;
    filter: drop-shadow(0 0 8px rgba(180,140,255,0.5));
  }

  #dialogue-box.thought-mode::after {
    content: "";
    position: absolute;
    top: -8px;
    left: 28px;
    width: 10px;
    height: 10px;
    background: rgba(65,30,110,0.92);
    border: 2px solid rgba(180,140,255,0.25);
    border-radius: 50%;
    border-bottom: none;
    border-right: none;
  }

  #dialogue-box.thought-mode #speaker-name {
    display: none;
  }

  #dialogue-box.thought-mode #dialogue-text {
    font-style: italic;
    color: rgba(210,190,255,0.95);
    text-shadow: 0 0 12px rgba(180,140,255,0.15);
    letter-spacing: 0.3px;
  }

  /* --- 5c. 主角对话（右侧） --- */
  #dialogue-box.dialogue-protagonist {
    border-left: 1px solid rgba(100,150,255,0.1);
    border-right: 3px solid rgba(100,180,255,0.5);
    margin-left: 28px;
    margin-right: 10px;
  }

  #dialogue-box.dialogue-protagonist #speaker-name {
    right: 16px;
    left: auto;
    color: #80b8ff;
    background: linear-gradient(135deg, rgba(20,30,70,0.95), rgba(35,50,100,0.95));
    border-color: rgba(100,180,255,0.4);
  }

  /* --- 5d. 配角对话（左侧） --- */
  #dialogue-box.dialogue-other {
    border-right: 1px solid rgba(100,150,255,0.1);
    border-left: 3px solid rgba(200,177,255,0.5);
    margin-right: 28px;
    margin-left: 10px;
  }

  #dialogue-box.dialogue-other #speaker-name {
    left: 16px;
    right: auto;
    color: #c9b1ff;
    background: linear-gradient(135deg, rgba(40,20,70,0.95), rgba(60,30,100,0.95));
    border-color: rgba(200,177,255,0.4);
  }

  /* === 6. 选项按钮 === */
  #choices {
    gap: 6px;
    margin-top: 10px;
    padding: 0 10px;
  }

  .choice-button {
    padding: 11px 14px;
    font-size: 13px;
  }

  .choice-button:hover {
    transform: none;
  }

  /* === 7. 弹幕 === */
  #danmaku-layer {
    top: calc(env(safe-area-inset-top, 20px) + 60px);
    height: 25%;
  }

  .danmaku-item {
    font-size: 12px;
  }

  /* === 8. 章节标题 === */
  .chapter-title-overlay h2 {
    font-size: 22px;
  }

  .chapter-title-overlay p {
    font-size: 14px;
  }

  /* === 9. 数值变化提示 === */
  .stat-notification {
    font-size: 16px;
    font-weight: 600;
    padding: 6px 16px;
    border-radius: 20px;
    background: rgba(0,0,0,0.4);
    border: none;
    box-shadow: none;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
  }

  .stat-notification.positive {
    color: #4ade80;
    border-color: transparent;
    box-shadow: 0 0 10px rgba(74, 222, 128, 0.15);
  }

  .stat-notification.negative {
    color: #f87171;
    border-color: transparent;
    box-shadow: 0 0 10px rgba(248, 113, 113, 0.15);
  }

  /* === 10. 游戏菜单（手机端弹窗） === */
  #game-menu {
    min-width: auto;
    width: calc(100% - 32px);
    max-width: 340px;
    padding: 24px 20px;
  }

  .menu-title {
    font-size: 20px;
  }

  .save-slot {
    flex-direction: column;
    gap: 6px;
  }
}

/* 菜单遮罩层 */
#menu-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.6);
  z-index: 199;
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
}

/* Toast 提示 */
.toast-notification {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(10,5,30,0.95);
  border: 1px solid rgba(100,150,255,0.3);
  color: #e0e0e0;
  padding: 16px 32px;
  border-radius: 12px;
  font-size: 16px;
  z-index: 300;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  animation: toastFade 1.5s ease forwards;
  pointer-events: none;
}

@keyframes toastFade {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.9); }
  15% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  75% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(0.9); }
}

/* 推进指示器 */
.advance-indicator {
  position: absolute;
  bottom: 6px;
  right: 12px;
  color: rgba(160,196,255,0.5);
  font-size: 10px;
  animation: advancePulse 1.2s ease-in-out infinite;
  pointer-events: none;
}

@keyframes advancePulse {
  0%, 100% { opacity: 0.3; transform: translateY(0); }
  50% { opacity: 0.8; transform: translateY(2px); }
}

/* 数值变化浮动提示 — 游戏区顶部居中弹出 */
#stat-notifications {
  position: absolute;
  top: 40%;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1100;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.stat-notification {
  font-size: 15px;
  font-weight: 700;
  padding: 5px 14px;
  border-radius: 20px;
  background: rgba(0, 0, 0, 0.55);
  border: none;
  white-space: nowrap;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  animation: statPop 2.2s ease-out forwards;
}

.stat-notification.positive {
  color: #4ade80;
  box-shadow: 0 0 12px rgba(74, 222, 128, 0.25);
}

.stat-notification.negative {
  color: #f87171;
  box-shadow: 0 0 12px rgba(248, 113, 113, 0.25);
}

@keyframes statPop {
  0% {
    opacity: 0;
    transform: scale(0.6) translateY(10px);
  }
  12% {
    opacity: 1;
    transform: scale(1.15) translateY(0);
  }
  25% {
    transform: scale(1) translateY(0);
  }
  75% {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
  100% {
    opacity: 0;
    transform: scale(0.9) translateY(-20px);
  }
}

/* 旁白分页指示器 */
.narration-page-indicator {
  position: absolute;
  bottom: 6px;
  right: 12px;
  color: rgba(160,196,255,0.5);
  font-size: 11px;
  pointer-events: none;
  letter-spacing: 1px;
}

/* 淡入淡出动画 */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

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

.fade-in {
  animation: fadeIn 0.5s ease;
}

.fade-out {
  animation: fadeOut 0.5s ease;
}

/* 加载动画 */
.loading {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: #a0c4ff;
  font-size: 20px;
  z-index: 1000;
  text-shadow: 0 0 10px rgba(100,150,255,0.5);
}

/* 粒子效果 */
.particle {
  position: absolute;
  width: 4px;
  height: 4px;
  background: rgba(100,150,255,0.6);
  border-radius: 50%;
  pointer-events: none;
  animation: float-up 4s ease-in infinite;
}

@keyframes float-up {
  0% { opacity: 0; transform: translateY(0) scale(0); }
  20% { opacity: 1; transform: translateY(-20px) scale(1); }
  100% { opacity: 0; transform: translateY(-200px) scale(0.5); }
}
