/* ============================================
   FluidLab 剧情对话系统样式
   深色玻璃态主题 · 视觉小说风格
   ============================================ */

/* ========== 叠加层容器 ========== */
.story-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 10000;
  align-items: flex-end;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.4s ease;
}

.story-overlay.active {
  opacity: 1;
}

/* ========== 背景模糊层 ========== */
.story-bg-blur {
  position: absolute;
  inset: 0;
  background: rgba(2, 4, 9, 0.92);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

/* ========== 剧情容器 ========== */
.story-container {
  position: relative;
  width: 100%;
  max-width: 900px;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0;
}

/* ========== 场景信息条 ========== */
.story-scene-info {
  position: absolute;
  top: 40px;
  left: 50%;
  transform: translateX(-50%);
  color: rgba(0, 242, 255, 0.6);
  font-size: 13px;
  letter-spacing: 2px;
  text-transform: uppercase;
  opacity: 0;
  transition: opacity 0.6s ease;
  text-align: center;
  max-width: 80%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ========== 角色头像区 ========== */
.story-portrait-area {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding-top: 60px;
  padding-bottom: 20px;
}

.story-portrait-area.has-character {
  padding-bottom: 0;
}

.story-portrait-placeholder {
  width: 1px;
  height: 1px;
}

/* ========== 角色头像 ========== */
.story-portrait {
  position: relative;
  width: 140px;
  height: 140px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(18, 22, 32, 0.6);
  border: 2px solid var(--char-color, #00f2ff);
  opacity: 0.5;
  transition: all 0.4s ease;
  transform: scale(0.9);
}

.story-portrait.speaking {
  opacity: 1;
  transform: scale(1);
  box-shadow: 0 0 30px rgba(0, 242, 255, 0.2),
              0 0 60px rgba(0, 242, 255, 0.1);
  border-color: var(--char-color, #00f2ff);
}

.story-portrait-icon {
  font-size: 56px;
  line-height: 1;
  filter: drop-shadow(0 0 10px var(--char-color, #00f2ff));
}

.story-portrait-glow {
  position: absolute;
  inset: -10px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--char-color, #00f2ff) 0%, transparent 70%);
  opacity: 0.15;
  pointer-events: none;
}

/* ========== 对话框 ========== */
.story-dialogue-box {
  position: relative;
  width: 100%;
  max-width: 860px;
  min-height: 180px;
  max-height: 55vh;
  background: rgba(18, 22, 32, 0.95);
  border: 1px solid rgba(0, 242, 255, 0.2);
  border-radius: 16px 16px 0 0;
  padding: 28px 36px 20px;
  cursor: pointer;
  display: flex;
  flex-direction: row;
  gap: 24px;
  box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  transition: border-color 0.3s ease;
  overflow-y: auto;
}

/* ========== 左侧图片区 ========== */
.story-img-area {
  flex-shrink: 0;
  width: 220px;
  min-height: 140px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(0, 242, 255, 0.1);
}

.story-img-area:empty {
  display: none;
}

.story-side-img {
  width: 100%;
  max-height: 460px;
  object-fit: contain;
  border-radius: 10px;
  flex-shrink: 0;
}

/* ========== 右侧文字区 ========== */
.story-text-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.story-dialogue-box::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg,
    transparent,
    rgba(0, 242, 255, 0.4),
    rgba(0, 242, 255, 0.6),
    rgba(0, 242, 255, 0.4),
    transparent);
}

/* ========== 说话者名字 ========== */
.story-speaker-name {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 1px;
  margin-bottom: 12px;
  color: #00f2ff;
  text-shadow: 0 0 10px rgba(0, 242, 255, 0.3);
  opacity: 0;
  transition: opacity 0.3s ease;
  font-family: "Inter", "Noto Sans SC", sans-serif;
}

/* ========== 对话文本区 ========== */
.story-text-area {
  flex: 1;
  font-size: 16px;
  line-height: 1.8;
  color: rgba(255, 255, 255, 0.92);
  font-family: "Noto Sans SC", "Inter", sans-serif;
  letter-spacing: 0.3px;
  overflow-y: auto;
  max-height: 30vh;
  padding-right: 8px;
  min-height: 40px;
}

.story-text-area::-webkit-scrollbar {
  width: 4px;
}

.story-text-area::-webkit-scrollbar-thumb {
  background: rgba(0, 242, 255, 0.2);
  border-radius: 2px;
}

.story-text-area.typing::after {
  content: '▋';
  color: #00f2ff;
  animation: story-cursor-blink 0.8s infinite;
}

@keyframes story-cursor-blink {
  0%, 50% { opacity: 1; }
  51%, 100% { opacity: 0; }
}

/* ========== 选择区域 ========== */
.story-choices-area {
  display: none;
  flex-direction: column;
  gap: 10px;
  margin-top: 16px;
  padding-bottom: 8px;
}

.story-choices-area.active {
  display: flex;
}

.story-choice-prompt {
  font-size: 13px;
  color: rgba(0, 242, 255, 0.6);
  margin-bottom: 4px;
  letter-spacing: 1px;
}

.story-choice-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  background: rgba(0, 242, 255, 0.05);
  border: 1px solid rgba(0, 242, 255, 0.15);
  border-radius: 10px;
  color: rgba(255, 255, 255, 0.9);
  font-size: 15px;
  cursor: pointer;
  transition: all 0.25s ease;
  font-family: "Noto Sans SC", "Inter", sans-serif;
  text-align: left;
  opacity: 0;
  transform: translateX(-20px);
}

.story-choice-btn.appear {
  opacity: 1;
  transform: translateX(0);
}

.story-choice-btn:hover {
  background: rgba(0, 242, 255, 0.12);
  border-color: rgba(0, 242, 255, 0.4);
  transform: translateX(4px);
  box-shadow: 0 4px 20px rgba(0, 242, 255, 0.1);
}

.story-choice-text {
  flex: 1;
  line-height: 1.5;
}

.story-choice-tag {
  font-size: 11px;
  color: rgba(0, 242, 255, 0.5);
  padding: 3px 10px;
  border: 1px solid rgba(0, 242, 255, 0.2);
  border-radius: 20px;
  white-space: nowrap;
  margin-left: 12px;
}

/* ========== 控制区 ========== */
.story-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 12px;
  padding-top: 8px;
}

.story-continue-hint {
  font-size: 12px;
  color: rgba(0, 242, 255, 0.5);
  letter-spacing: 1px;
  opacity: 0;
  transition: opacity 0.3s ease;
  animation: story-hint-pulse 2s ease-in-out infinite;
}

@keyframes story-hint-pulse {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 0.7; }
}

.story-skip-btn {
  background: none;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  padding: 6px 14px;
  color: rgba(255, 255, 255, 0.4);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: "Noto Sans SC", "Inter", sans-serif;
  letter-spacing: 0.5px;
}

.story-skip-btn:hover {
  color: rgba(255, 255, 255, 0.7);
  border-color: rgba(255, 255, 255, 0.3);
  background: rgba(255, 255, 255, 0.05);
}

/* ========== 响应式 ========== */
@media (max-width: 768px) {
  .story-dialogue-box {
    flex-direction: column;
    gap: 12px;
  }

  .story-img-area {
    width: 100%;
    max-height: 120px;
    min-height: 80px;
  }

  .story-portrait {
    width: 100px;
    height: 100px;
  }

  .story-portrait-icon {
    font-size: 40px;
  }

  .story-dialogue-box {
    padding: 20px 20px 16px;
    min-height: 160px;
    max-height: 40vh !important;
  }

  .story-text-area {
    font-size: 14px;
    line-height: 1.7;
  }

  .story-speaker-name {
    font-size: 13px;
  }

  .story-choice-btn {
    padding: 12px 16px;
    font-size: 13px;
  }

  .story-scene-info {
    font-size: 11px;
    top: 20px;
  }

  .story-portrait-area {
    padding-top: 30px;
    min-height: 40vh !important;
  }
}

/* ========== 入场动画 ========== */
.story-overlay.active .story-dialogue-box {
  animation: story-box-slide-up 0.5s ease-out;
}

@keyframes story-box-slide-up {
  from {
    transform: translateY(100%);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.story-overlay.active .story-portrait {
  animation: story-portrait-fade-in 0.6s ease-out 0.2s both;
}

@keyframes story-portrait-fade-in {
  from {
    opacity: 0;
    transform: scale(0.8);
  }
  to {
    opacity: 0.5;
    transform: scale(0.9);
  }
}

/* ========== 章节标题动画 ========== */
.story-chapter-title {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.9);
  text-align: center;
  pointer-events: none;
  z-index: 5;
  opacity: 0;
  transition: opacity 0.6s ease, transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.story-chapter-title.show {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

.story-chapter-title.exit {
  opacity: 0;
  transform: translate(-50%, -50%) scale(1.1);
  transition: opacity 0.5s ease, transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.story-chapter-title h2 {
  font-size: 32px;
  font-weight: 800;
  color: #00f2ff;
  text-shadow: 0 0 30px rgba(0, 242, 255, 0.5),
               0 0 60px rgba(0, 242, 255, 0.2);
  margin: 0;
  letter-spacing: 6px;
  animation: story-title-glow 2.5s ease-in-out;
}

.story-chapter-title p {
  font-size: 14px;
  color: rgba(255, 255, 255, 0.5);
  margin-top: 12px;
  letter-spacing: 3px;
  animation: story-title-sub-fade 2.5s ease-in-out;
}

@keyframes story-title-glow {
  0% {
    opacity: 0;
    letter-spacing: 20px;
    filter: blur(10px);
  }
  30% {
    opacity: 1;
    letter-spacing: 6px;
    filter: blur(0);
  }
  70% {
    opacity: 1;
    letter-spacing: 6px;
    filter: blur(0);
  }
  100% {
    opacity: 1;
    letter-spacing: 6px;
    filter: blur(0);
  }
}

@keyframes story-title-sub-fade {
  0%, 20% { opacity: 0; transform: translateY(10px); }
  40% { opacity: 0.5; transform: translateY(0); }
  100% { opacity: 0.5; transform: translateY(0); }
}

@media (max-width: 768px) {
  .story-chapter-title h2 {
    font-size: 22px;
    letter-spacing: 4px;
  }
  .story-chapter-title p {
    font-size: 12px;
    letter-spacing: 2px;
  }
}

/* ========== 增强过渡效果 ========== */

/* 叠加层淡入增强 — 添加景深感 */
.story-overlay.active .story-bg-blur {
  animation: story-bg-fade-in 0.6s ease-out;
}

@keyframes story-bg-fade-in {
  from { opacity: 0; backdrop-filter: blur(0); }
  to { opacity: 1; backdrop-filter: blur(20px); }
}

/* 对话框入场增强 — 添加轻微弹动 */
.story-overlay.active .story-dialogue-box {
  animation: story-box-slide-up 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes story-box-slide-up {
  from {
    transform: translateY(100%) scale(0.98);
    opacity: 0;
  }
  to {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
}

/* 角色头像入场增强 */
.story-overlay.active .story-portrait {
  animation: story-portrait-fade-in 0.6s ease-out 0.2s both;
}

@keyframes story-portrait-fade-in {
  from {
    opacity: 0;
    transform: scale(0.7) translateY(20px);
  }
  to {
    opacity: 0.5;
    transform: scale(0.9) translateY(0);
  }
}

/* 场景信息条入场 */
.story-overlay.active .story-scene-info {
  animation: story-scene-slide-down 0.5s ease-out 0.3s both;
}

@keyframes story-scene-slide-down {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(-15px);
  }
  to {
    opacity: 0;
    transform: translateX(-50%) translateY(0);
  }
}

/* 对话文本切换过渡 */
.story-text-area {
  transition: opacity 0.2s ease;
}

/* 选择按钮增强 hover */
.story-choice-btn {
  position: relative;
  overflow: hidden;
}

.story-choice-btn::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--char-color, #00f2ff);
  opacity: 0;
  transition: opacity 0.25s ease;
}

.story-choice-btn:hover::before {
  opacity: 1;
}

/* 跳过按钮增强 */
.story-skip-btn {
  position: relative;
  overflow: hidden;
}

.story-skip-btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.05), transparent);
  transform: translateX(-100%);
  transition: transform 0.4s ease;
}

.story-skip-btn:hover::after {
  transform: translateX(100%);
}


/* ============================================================
   v3.0 内嵌模式样式（界面嵌入，非弹窗）
   所有 .story-inline-* 类用于 showInlineStory() 渲染
   ============================================================ */

/* 内嵌剧情区域容器 */
.story-inline-area {
  display: none;
  margin-bottom: 16px;
}

.story-inline-area:empty {
  display: none !important;
}

/* 内嵌根元素 */
.story-inline-root {
  background: linear-gradient(145deg, rgba(0,242,255,0.06), rgba(168,85,247,0.04));
  border: 1px solid rgba(0,242,255,0.18);
  border-radius: 16px;
  overflow: hidden;
  opacity: 0;
  transform: translateY(12px);
  transition: all 0.4s cubic-bezier(0.22, 1, 0.36, 1);
}

.story-inline-root.active {
  opacity: 1;
  transform: translateY(0);
}

.story-inline-root.exiting {
  opacity: 0;
  transform: translateY(-8px);
  transition: all 0.3s ease-in;
}

/* 章节标题栏 */
.story-inline-title-bar {
  padding: 18px 22px 14px;
  border-bottom: 1px solid rgba(255,255,255,0.07);
  text-align: center;
}

.si-title {
  display: block;
  font-size: 20px;
  font-weight: 800;
  color: #00f2ff;
  letter-spacing: 4px;
  text-shadow: 0 0 20px rgba(0,242,255,0.35);
}

.si-subtitle {
  display: block;
  font-size: 12px;
  color: rgba(255,255,255,0.4);
  margin-top: 6px;
  letter-spacing: 2px;
}

/* 主内容区 */
.story-inline-body {
  padding: 20px 22px;
  position: relative;
}

/* 场景信息 */
.story-inline-scene-info {
  font-size: 11px;
  font-weight: 600;
  color: #ffb300;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  opacity: 0;
  height: 16px;
  margin-bottom: 10px;
  transition: opacity 0.3s ease;
}

/* 角色头像区 */
.story-inline-portrait-area {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 48px;
  margin-bottom: 14px;
  padding-left: 4px;
}

.si-portrait-placeholder {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(255,255,255,0.04);
  border: 1px dashed rgba(255,255,255,0.15);
}

.story-inline-portrait-area.has-char .si-portrait-placeholder {
  display: none;
}

/* 单个角色头像 */
.si-portrait {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  animation: siPortraitIn 0.35s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

@keyframes siPortraitIn {
  from { opacity: 0; transform: scale(0.7) translateY(8px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.si-portrait-icon {
  font-size: 32px;
  line-height: 1;
  filter: drop-shadow(0 0 8px var(--char-color, rgba(0,242,255,0.5)));
}

.si-portrait-name {
  font-size: 10px;
  font-weight: 700;
  color: var(--char-color, #00f2ff);
  white-space: nowrap;
  letter-spacing: 0.5px;
}

.si-portrait-glow {
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--char-color, rgba(0,242,255,0.15)), transparent 70%);
  pointer-events: none;
  z-index: -1;
}

/* 对话框 */
.story-inline-dialogue-box {
  background: rgba(0,0,0,0.35);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 12px;
  padding: 16px 18px;
  cursor: pointer;
  transition: border-color 0.25s ease, box-shadow 0.25s ease;
  user-select: none;
}

.story-inline-dialogue-box:hover {
  border-color: rgba(0,242,255,0.2);
  box-shadow: 0 0 20px rgba(0,242,255,0.05);
}

/* 说话者名称 */
.story-inline-speaker {
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 1.5px;
  margin-bottom: 8px;
  min-height: 18px;
  transition: opacity 0.2s ease;
  text-shadow: 0 0 10px currentColor;
}

/* 对话文本 */
.story-inline-text {
  font-size: 14px;
  line-height: 1.75;
  color: rgba(255,255,255,0.9);
  min-height: 48px;
  word-break: break-word;
}

.story-inline-text.typing::after {
  content: '▌';
  color: #00f2ff;
  animation: siBlink 0.7s step-end infinite;
  margin-left: 1px;
}

@keyframes siBlink { 50% { opacity: 0; } }

/* 选择按钮区域 */
.story-inline-choices {
  margin-top: 14px;
  max-height: 0;
  opacity: 0;
  overflow: hidden;
  transition: all 0.3s ease;
}

.story-inline-choices.active {
  max-height: 400px;
  opacity: 1;
  margin-top: 14px;
}

.si-choice-prompt {
  font-size: 13px;
  font-weight: 700;
  color: #ffb300;
  margin-bottom: 10px;
}

/* 内嵌选择按钮 */
.story-inline-choice-btn {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  padding: 12px 16px;
  margin-bottom: 8px;
  background: linear-gradient(135deg, rgba(0,242,255,0.08), rgba(0,242,255,0.02));
  border: 1px solid rgba(0,242,255,0.2);
  border-radius: 10px;
  color: rgba(255,255,255,0.9);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.25s ease;
  opacity: 0;
  transform: translateX(-12px);
  text-align: left;
  position: relative;
  overflow: hidden;
}

.story-inline-choice-btn.appear {
  opacity: 1;
  transform: translateX(0);
}

.story-inline-choice-btn:hover {
  background: linear-gradient(135deg, rgba(0,242,255,0.18), rgba(0,242,255,0.06));
  border-color: rgba(0,242,255,0.45);
  box-shadow: 0 0 16px rgba(0,242,255,0.12);
  transform: translateX(4px);
}

.sic-text { flex: 1; }
.sic-tag {
  font-size: 10px;
  font-weight: 700;
  color: #a855f7;
  background: rgba(168,85,247,0.15);
  padding: 2px 8px;
  border-radius: 8px;
  margin-left: 8px;
  letter-spacing: 0.5px;
}

/* 控制栏 */
.story-inline-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid rgba(255,255,255,0.05);
}

.story-inline-hint {
  font-size: 11px;
  color: rgba(255,255,255,0.3);
  letter-spacing: 1px;
  transition: opacity 0.2s ease;
}

.story-inline-skip-btn {
  font-size: 11px;
  color: rgba(255,255,255,0.3);
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 4px 10px;
  border-radius: 6px;
  transition: all 0.2s ease;
  letter-spacing: 0.5px;
}

.story-inline-skip-btn:hover {
  color: rgba(255,255,255,0.65);
  background: rgba(255,255,255,0.06);
}

/* 操作栏（关闭按钮） */
.story-inline-action-bar {
  padding: 10px 22px 14px;
  display: flex;
  justify-content: center;
  border-top: 1px solid rgba(255,255,255,0.05);
}

.story-inline-close-btn {
  font-size: 12px;
  font-weight: 600;
  color: rgba(255,255,255,0.35);
  background: transparent;
  border: 1px solid rgba(255,255,255,0.1);
  padding: 6px 20px;
  border-radius: 20px;
  cursor: pointer;
  transition: all 0.2s ease;
  letter-spacing: 0.5px;
}

.story-inline-close-btn:hover {
  color: rgba(255,255,255,0.7);
  border-color: rgba(255,179,0,0.3);
  background: rgba(255,179,0,0.08);
}

/* 响应式适配 */
@media (max-width: 640px) {
  .si-title { font-size: 16px; letter-spacing: 2px; }
  .si-subtitle { font-size: 11px; }
  .story-inline-body { padding: 14px 16px; }
  .story-inline-dialogue-box { padding: 12px 14px; }
  .story-inline-text { font-size: 13px; min-height: 36px; }
  .si-portrait-icon { font-size: 26px; }
}

/* ========== 场景可视化（水桶动画等）========== */
.story-portrait-area.has-visual {
  padding-top: 30px;
  padding-bottom: 0;
  align-items: flex-start;
}
/* ========== 全局canvas尺寸规则 ========== */
#story-visual-canvas {
  width: 100% !important;
  max-width: 100% !important;
  height: auto !important;
  display: block !important;
}



/* ============================================================
   桌面端布局优化 - 图片与对话左右分栏布局
   ============================================================ */
@media (min-width: 769px) {
  /* 叠加层：垂直居中 */
  .story-overlay {
    align-items: center !important;
  }
  
  /* 容器：改为Grid左右分栏布局 */
  .story-container {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    grid-template-rows: auto minmax(0, 1fr) !important;
    grid-template-areas:
      "scene scene"
      "portrait dialogue" !important;
    max-width: 1200px !important;
    width: calc(100% - 48px) !important;
    max-height: 600px !important;
    height: auto !important;
    gap: 0 28px !important;
    padding: 20px 24px !important;
    box-sizing: border-box !important;
    overflow: hidden !important;
  }
  
  /* 场景信息：横跨顶部 */
  .story-scene-info {
    grid-area: scene !important;
    position: relative !important;
    top: auto !important;
    left: auto !important;
    transform: none !important;
    padding: 0 0 12px 0 !important;
    text-align: center !important;
  }
  
  /* 左侧：图片区域，固定高度+滚动查看完整图片 */
  .story-portrait-area {
    grid-area: portrait !important;
    max-height: 480px !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: flex-start !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    padding: 8px 0 !important;
    box-sizing: border-box !important;
  }
  
  .story-portrait-area.has-visual {
    padding: 4px 0 !important;
  }
  
  /* 图片区域滚动条美化 */
  .story-portrait-area::-webkit-scrollbar {
    width: 6px;
  }
  .story-portrait-area::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 3px;
  }
  .story-portrait-area::-webkit-scrollbar-thumb {
    background: rgba(0, 242, 255, 0.35);
    border-radius: 3px;
  }
  .story-portrait-area::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 242, 255, 0.6);
  }
  
  /* canvas: 宽度填满左栏，高度按比例自动，允许超出后滚动 */
  #story-visual-canvas {
    width: 100% !important;
    max-width: 100% !important;
    height: auto !important;
    max-height: none !important;
    display: block !important;
    border-radius: 12px !important;
    flex-shrink: 0 !important;
  }
  
  /* 右侧：对话框区域 */
  .story-dialogue-box {
    grid-area: dialogue !important;
    max-height: 480px !important;
    min-height: 0 !important;
    border-radius: 12px !important;
    margin-top: 0 !important;
    padding: 24px 28px 18px !important;
    overflow-y: auto !important;
    display: flex !important;
    flex-direction: column !important;
    box-shadow: 0 0 30px rgba(0, 0, 0, 0.3) !important;
    box-sizing: border-box !important;
  }
  
  /* 对话框顶部装饰线 */
  .story-dialogue-box::before {
    border-radius: 12px 12px 0 0 !important;
  }
  
  /* 文本区：自适应填满剩余空间 */
  .story-text-area {
    flex: 1 !important;
    max-height: none !important;
    overflow-y: auto !important;
  }
  
  /* 对话框滚动条美化 */
  .story-dialogue-box::-webkit-scrollbar {
    width: 6px;
  }
  .story-dialogue-box::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 3px;
  }
  .story-dialogue-box::-webkit-scrollbar-thumb {
    background: rgba(0, 242, 255, 0.3);
    border-radius: 3px;
  }
  .story-dialogue-box::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 242, 255, 0.5);
  }
  
  /* 对话框入场动画适配 */
  .story-overlay.active .story-dialogue-box {
    animation: none !important;
  }
}


/* ============================================================
   手机端横屏布局 - 自动切换为左右分栏
   ============================================================ */
@media (max-width: 768px) and (orientation: landscape) {
  /* 提示用户横屏时，使用左右布局 */
  .story-overlay {
    align-items: center !important;
  }
  
  .story-container {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    grid-template-rows: auto minmax(0, 1fr) !important;
    grid-template-areas:
      "scene scene"
      "portrait dialogue" !important;
    width: calc(100% - 24px) !important;
    height: 92vh !important;
    max-height: 92vh !important;
    gap: 0 16px !important;
    padding: 8px 12px !important;
    box-sizing: border-box !important;
    overflow: hidden !important;
  }
  
  .story-scene-info {
    grid-area: scene !important;
    position: relative !important;
    top: auto !important;
    left: auto !important;
    transform: none !important;
    padding: 0 0 6px 0 !important;
    font-size: 11px !important;
    text-align: center !important;
  }
  
  .story-portrait-area {
    grid-area: portrait !important;
    height: 100% !important;
    max-height: 100% !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: flex-start !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    padding: 4px 0 !important;
    box-sizing: border-box !important;
  }
  
  .story-portrait-area.has-visual {
    padding: 2px 0 !important;
  }
  
  .story-portrait-area::-webkit-scrollbar {
    width: 4px;
  }
  .story-portrait-area::-webkit-scrollbar-thumb {
    background: rgba(0, 242, 255, 0.35);
    border-radius: 2px;
  }
  
  #story-visual-canvas {
    width: 100% !important;
    max-width: 100% !important;
    height: auto !important;
    max-height: none !important;
    display: block !important;
    border-radius: 8px !important;
    flex-shrink: 0 !important;
  }
  
  .story-dialogue-box {
    grid-area: dialogue !important;
    height: 100% !important;
    max-height: 100% !important;
    min-height: 0 !important;
    border-radius: 10px !important;
    margin-top: 0 !important;
    padding: 14px 16px 12px !important;
    overflow-y: auto !important;
    display: flex !important;
    flex-direction: column !important;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.3) !important;
    box-sizing: border-box !important;
  }
  
  .story-dialogue-box::before {
    border-radius: 10px 10px 0 0 !important;
  }
  
  .story-speaker-name {
    font-size: 13px !important;
    margin-bottom: 6px !important;
  }
  
  .story-text-area {
    flex: 1 !important;
    max-height: none !important;
    font-size: 14px !important;
    line-height: 1.6 !important;
    overflow-y: auto !important;
  }
  
  .story-text-area::-webkit-scrollbar {
    width: 3px;
  }
  .story-text-area::-webkit-scrollbar-thumb {
    background: rgba(0, 242, 255, 0.2);
    border-radius: 2px;
  }
  
  .story-choices-area {
    margin-top: 6px !important;
  }
  
  .story-controls {
    padding-top: 6px !important;
  }
  
  .story-continue-hint {
    font-size: 12px !important;
  }
  
  .story-skip-btn {
    font-size: 12px !important;
    padding: 4px 10px !important;
  }
  
  .story-overlay.active .story-dialogue-box {
    animation: none !important;
  }
}


/* 桌面端：左侧图片区 + 右侧文字区 */
@media (min-width: 769px) {
  .story-portrait-area .story-img-area {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 100% !important;
    max-width: 100% !important;
    height: auto !important;
    max-height: 480px !important;
    background: rgba(0, 0, 0, 0.3) !important;
    border: 1px solid rgba(0, 242, 255, 0.1) !important;
  }
  .story-portrait-area .story-img-area:empty {
    display: none !important;
  }
  .story-portrait-area .story-img-area .story-side-img {
    max-width: 100% !important;
    max-height: 460px !important;
    width: auto !important;
    height: auto !important;
    object-fit: contain !important;
    border-radius: 10px !important;
  }
}

/* ============================================================
   电影级氛围分级 —— 危险/紧急字幕变红特效
   数据侧给台词加 _mood:"danger" 触发, 引擎给容器加 .mood-danger
   ============================================================ */

/* —— 文字区: 整体变红 + 发光脉动 —— */
.story-text-area.mood-danger {
  color: #ff4d4d !important;
  text-shadow:
    0 0 8px rgba(255, 45, 45, 0.85),
    0 0 20px rgba(255, 20, 20, 0.55),
    0 0 40px rgba(255, 0, 0, 0.35);
  animation: story-danger-pulse 1.4s ease-in-out infinite;
  letter-spacing: 0.6px;
  font-weight: 500;
}

/* 打字机光标也变红 */
.story-text-area.mood-danger.typing::after {
  color: #ff2d2d;
  text-shadow: 0 0 10px rgba(255, 30, 30, 0.9);
}

@keyframes story-danger-pulse {
  0%, 100% {
    text-shadow:
      0 0 8px rgba(255, 45, 45, 0.85),
      0 0 20px rgba(255, 20, 20, 0.5),
      0 0 40px rgba(255, 0, 0, 0.3);
  }
  50% {
    text-shadow:
      0 0 14px rgba(255, 70, 70, 1),
      0 0 34px rgba(255, 30, 30, 0.8),
      0 0 60px rgba(255, 0, 0, 0.5);
  }
}

/* —— 对话框: 边框与顶条变红 —— */
.story-dialogue-box.mood-danger {
  border-color: rgba(255, 45, 45, 0.55) !important;
  box-shadow:
    0 -10px 40px rgba(0, 0, 0, 0.5),
    0 0 50px rgba(255, 0, 0, 0.18) !important;
}
.story-dialogue-box.mood-danger::before {
  background: linear-gradient(90deg,
    transparent,
    rgba(255, 45, 45, 0.5),
    rgba(255, 80, 80, 0.85),
    rgba(255, 45, 45, 0.5),
    transparent) !important;
  animation: story-danger-bar 1.4s ease-in-out infinite;
}
@keyframes story-danger-bar {
  0%, 100% { opacity: 0.7; }
  50%      { opacity: 1; }
}

/* —— 说话者名字(若有)在危险态也偏红 —— */
.story-dialogue-box.mood-danger .story-speaker-name {
  color: #ff5c5c !important;
  text-shadow: 0 0 10px rgba(255, 40, 40, 0.5) !important;
}

/* —— 全屏警报晕染 + 轻微震动 —— */
.story-overlay.mood-danger::after {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 5;
  box-shadow: inset 0 0 180px 40px rgba(180, 0, 0, 0.28);
  animation: story-danger-vignette 1.6s ease-in-out infinite;
}
@keyframes story-danger-vignette {
  0%, 100% { opacity: 0.55; }
  50%      { opacity: 1; }
}

/* 进入危险态时对话框来一次极轻微的紧张震颤(仅一次, 不干扰阅读) */
.story-dialogue-box.mood-danger {
  animation: story-danger-shake 0.5s ease-in-out 1;
}
@keyframes story-danger-shake {
  0%, 100% { transform: translateX(0); }
  20%      { transform: translateX(-3px); }
  40%      { transform: translateX(3px); }
  60%      { transform: translateX(-2px); }
  80%      { transform: translateX(2px); }
}

/* —— 警戒级(alert): 橙红, 比 danger 温和一档 —— */
.story-text-area.mood-alert {
  color: #ff9d3d !important;
  text-shadow:
    0 0 8px rgba(255, 140, 40, 0.7),
    0 0 20px rgba(255, 110, 20, 0.4);
  animation: story-danger-pulse 1.8s ease-in-out infinite;
}
.story-dialogue-box.mood-alert {
  border-color: rgba(255, 140, 40, 0.5) !important;
}
.story-dialogue-box.mood-alert::before {
  background: linear-gradient(90deg,
    transparent,
    rgba(255, 140, 40, 0.5),
    rgba(255, 170, 60, 0.85),
    rgba(255, 140, 40, 0.5),
    transparent) !important;
}
