/**
 * 长漫互动普法小游戏 - H5样式
 * 响应式设计：支持手机、平板、PC
 * 设计稿基准：375px宽度（移动端）
 * 换算公式：1px = 0.2667vw (100/375)
 */

/* 重置样式 */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* ========== 启动引导页样式 ========== */
.entry-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: 9999999;
  display: flex;
  justify-content: center;
  align-items: center;
  animation: fadeIn 0.3s ease-in;
}

.entry-container {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border-radius: 20px;
  padding: 40px 30px;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  max-width: 85%;
  width: 320px;
  animation: slideUp 0.5s ease-out;
}

/* 文字标题样式 */
.entry-title {
  margin-bottom: 30px;
  text-align: center;
  animation: fadeInDown 0.8s ease-out;
}

.title-line1 {
  font-size: 18px;
  font-weight: 600;
  color: white;
  margin-bottom: 8px;
  letter-spacing: 2px;
}

.title-line2 {
  font-size: 22px;
  font-weight: 700;
  color: white;
  letter-spacing: 1px;
}

.entry-button {
  display: inline-block;
  padding: 12px 50px;
  background: white;
  border-radius: 50px;
  color: #764ba2;
  font-size: 18px;
  font-weight: bold;
  cursor: pointer;
  box-shadow: 0 5px 15px rgba(255, 255, 255, 0.3);
  transition: all 0.3s ease;
  margin-bottom: 15px;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.entry-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(255, 255, 255, 0.4);
}

.entry-button:active {
  transform: translateY(0px);
  box-shadow: 0 3px 10px rgba(255, 255, 255, 0.3);
}

.entry-button span {
  display: inline-block;
  animation: bounce 1.5s ease-in-out infinite;
}

.entry-hint {
  color: rgba(255, 255, 255, 0.9);
  font-size: 13px;
  margin-top: 15px;
  animation: fadeInUp 0.8s ease-out 0.3s both;
}

/* 加载状态 */
.loading-container {
  padding: 10px 0;
}

.loading-spinner {
  width: 40px;
  height: 40px;
  margin: 0 auto 15px;
  border: 4px solid rgba(255, 255, 255, 0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.loading-text {
  color: white;
  font-size: 14px;
  margin-bottom: 15px;
}

.loading-progress {
  width: 200px;
  height: 6px;
  background: rgba(255, 255, 255, 0.3);
  border-radius: 3px;
  margin: 0 auto 10px;
  overflow: hidden;
}

.loading-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #f093fb 0%, #f5576c 100%);
  border-radius: 3px;
  transition: width 0.3s ease;
}

.loading-percent {
  color: rgba(255, 255, 255, 0.9);
  font-size: 12px;
  font-weight: bold;
}

/* 动画效果 */
@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes pulse {
  0%, 100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.05);
  }
}

@keyframes bounce {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-5px);
  }
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* 隐藏引导页的动画 */
.entry-overlay.hide {
  animation: fadeOut 0.5s ease-out forwards;
}

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

html, body {
  height: 100%;
  width: 100%;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  /* 支持深色模式 */
  color-scheme: light dark;
  /* 优化触摸滚动 */
  touch-action: pan-y; /* 只允许垂直滚动 */
}

body {
  display: flex;
  flex-direction: column;
  background: #000;
  justify-content: center;
  align-items: center;
}

/* 滚动区域 - 限制最大宽度，居中显示 */
.scrollarea {
  flex: 1;
  width: 100%;
  max-width: 750px; /* 最大宽度限制，适配大屏幕 */
  overflow-y: auto;
  overflow-x: visible; /* 允许对话框横向超出边界 */
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
  background: #000;
  position: relative; /* 为绝对定位的对话框覆盖层提供定位上下文 */
  
  /* 分页滚动效果 - CSS Scroll Snap */
  scroll-snap-type: y mandatory; /* 垂直方向强制吸附 */
  scroll-padding: 0; /* 吸附时的内边距 */
}

/* 弹窗显示时禁止滚动 */
body.popup-open .scrollarea {
  overflow: hidden;
  position: fixed;
  width: 100%;
  height: 100%;
}

/* 场景通用样式 */
.scene {
  width: 100%;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: center;
  position: relative;
  overflow: visible; /* 允许对话框超出容器边界 */
  
  /* 分页滚动 - 每个场景吸附到顶部 */
  scroll-snap-align: start; /* 吸附到场景开始位置 */
  scroll-snap-stop: always; /* 强制停止在每个吸附点 */
}

/* 开始游戏界面 */
.scene-title {
  position: relative;
  overflow: hidden; /* 隐藏溢出 */
  min-height: 100vh;
  height: 100vh; /* 固定高度 */
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  background: #000; /* 黑色背景 */
}

.homepage-bg {
  width: 100%;
  height: 100%;
  object-fit: cover; /* 填满屏幕 */
  object-position: center; /* 居中显示 */
  display: block;
  z-index: 0;
  position: absolute;
  top: 0;
  left: 0;
}

.title-container {
  position: relative; /* 改为相对定位，确保在flex容器中正常显示 */
  width: 100%;
  height: 100%;
  z-index: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}

/* 标题图片 - 使用百分比定位 */
.title-image {
  position: absolute;
  left: 4.5%;
  top: 25%;
  width: 92%;
  height: auto;
}

/* 开始游戏按钮 - 使用百分比定位 */
.start-button-image {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  top: 51%;
  width: 35%;
  cursor: pointer;
  transition: transform 0.2s;
}

.start-button-image:active {
  transform: translateX(-50%) scale(0.95);
}

/* 展示按钮图片（纯展示，无点击功能） */
.display-button-image {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  top: 95%;
  width: 25%;
}

/* 剧情场景底部「拖动继续剧情」提示图 - 置于最顶层，不被对话框覆盖 */
.scene-story .display-button-image {
  z-index: 100002;
}

/* 剧情场景 */
.scene-story {
  background: #000;
  min-height: 100vh;
  height: 100vh; /* 固定高度，确保对话框位置稳定 */
  position: relative;
  z-index: 1;
  overflow: visible; /* 允许对话框超出容器边界 */
  display: flex;
  flex-direction: column;
  justify-content: center; /* 垂直居中显示内容 */
  align-items: center;
}

.scene-image {
  width: 100%;
  height: 100%;
  object-fit: cover; /* 默认填满屏幕（适合竖屏手机） */
  object-position: center; /* 居中显示 */
  display: block;
  position: relative;
  z-index: 1; /* 背景图片层级较低，确保对话框在上方 */
}

.character-image {
  max-width: 53.33%; /* 200/375 */
  height: auto;
  z-index: 2;
  position: absolute;
}

/* 对话框图片 - 使用百分比定位 */
.dialog-image {
  position: absolute;
  left: 6%;
  top: 13%;
  z-index: 9999; /* 提高层级，确保浮在所有元素之上 */
  width: 73%;
  height: auto;
  pointer-events: none; /* 允许点击穿透到下层 */
}

/* 场景2的对话框位置 - 使用百分比定位 */
#dialogImage1_0 {
  left: 15%; /* 84/375 */
  top: 50%; /* 772/1000 假设场景高度约1000px */
  width: 68%; /* 302/375 */
  height: auto;
}

/* 场景3的对话框位置 - 使用百分比定位 */
#dialogImage2_0 {
  left: 10%; /* 29/375 */
  top: 8%; /* -63/1000 */
  width: 60%; /* 304/375 */
  height: auto;
}

/* 场景4的对话框位置 - 使用百分比定位 */
#dialogImage3_0 {
  left: 7.7%; /* 29/375 */
  top: 10%; /* 49/1000 */
  width: 85.1%; /* 394/375，超过100%说明需要更大宽度 */
  height: auto;
}

#dialogImage3_1 {
  left: 5; /* 70/375 */
  top: 30%; /* 404/1000 */
  width: 90.6%; /* 351/375 */
  height: auto;
  pointer-events: auto; /* 允许点击，跳转到场景5 */
  cursor: pointer; /* 显示手型光标 */
  z-index: 10000; /* 确保在最上层 */
}

#dialogImage3_2 {
  left: 5%; /* 70/375 */
  top: 45%; /* 491/1000 */
  width: 90.6%; /* 352/375 */
  height: auto;
  pointer-events: auto; /* 允许点击，触发弹窗 */
  cursor: pointer; /* 显示手型光标 */
  z-index: 10000; /* 确保在最上层 */
}

/* ========== 独立对话框图层 ========== */
/* 对话框覆盖层容器（与滚动区域同级，绝对定位在页面中） */
.dialog-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none; /* 允许点击穿透到下层滚动区域 */
  z-index: 9999; /* 最高层级，浮在所有内容之上 */
}

/* 浮动对话框图片 */
.dialog-floating {
  position: absolute;
  pointer-events: auto; /* 对话框本身可交互 */
}

/* 场景5的对话框 0-61.png 已删除，直接修改背景 */

/* 场景6的对话框位置 - 使用百分比定位 */
#dialogImage5_0 {
  left: 5.2%; /* 102/375 */
  top: 30%; /* 446/1000 */
  width: 65.9%; /* 521/375 */
  height: auto;
}

/* 场景7的对话框位置 - 使用百分比定位 */
#dialogImage6_0 {
  left: 25.7%; /* 104/375 */
  top: 9.8%; /* 98/1000 */
  width: 68%; /* 471/375 */
  height: auto;
}

/* 场景8的对话框位置 - 使用百分比定位 */
#dialogImage7_0 {
  left: 40%; /* 300/375 */
  top: 3%; /* -32/1000 */
  width: 55.8%; /* 318/375 */
  height: auto;
}

/* 场景8的对话框位置 - 0-101.png 从 scene9 移到此 */
#dialogImage7_1 {
  left: 15%; /* 135/375 */
  top: 78%; /* -528/1000 */
  width: 60%; /* 407/375 */
  height: auto;
}

/* 场景9的对话框位置 - 0-111/112/113.png 从 scene10 移到此 */
#dialogImage8_0 {
  left: 10%;
  top: 10%;
  width: 80%;
  height: auto;
}

#dialogImage8_1 {
  left: 10%;
  top: 30%;
  width: 80%;
  height: auto;
  pointer-events: auto; /* 允许点击，跳转到场景10 */
  cursor: pointer; /* 显示手型光标 */
  z-index: 10000; /* 确保在最上层 */
}

#dialogImage8_2 {
  left: 10%;
  top: 42%;
  width: 80%;
  height: auto;
  pointer-events: auto; /* 允许点击，触发弹窗 */
  cursor: pointer; /* 显示手型光标 */
  z-index: 10000; /* 确保在最上层 */
}

/* 场景10的对话框已删除 */

/* 场景11的对话框位置 - scene-12.png */
/* 0-131.png */
#dialogImage10_0 {
  left: 10%;
  top: 25%;
  width: 70%;
  height: auto;
}

/* 0-141.png (在 0-131 之后) */
#dialogImage10_1 {
  left: 17%;
  top: 85%;
  width: 70%;
  height: auto;
}

/* 场景12的对话框位置 - scene-13.png */
/* 0-151.png */
#dialogImage11_0 {
  left: 25%;
  top: 20%;
  width: 70%;
  height: auto;
}

/* 场景13的对话框位置 - scene-14.png */
/* 0-161.png */
#dialogImage12_0 {
  left: 5%;
  top: 10%;
  width: 75%;
  height: auto;
}

/* 场景14的对话框位置 - scene-15.png */
/* 0-171.png */
#dialogImage13_0 {
  left: 8%;
  top: 10%;
  width: 80%;
  height: auto;
}

/* 0-172.png (与 0-173 同时出现，可点击触发弹窗) */
#dialogImage13_1 {
  left: 5%;
  top: 30%;
  width: 90%;
  height: auto;
  pointer-events: auto; /* 允许点击，跳转到场景15 */
  cursor: pointer; /* 显示手型光标 */
  z-index: 10000; /* 确保在最上层 */
}

/* 0-173.png (与 0-172 同时出现) */
#dialogImage13_2 {
  left: 5%;
  top: 38%;
  width: 90%;
  height: auto;
  pointer-events: auto; /* 允许点击，触发弹窗 */
  cursor: pointer; /* 显示手型光标 */
  z-index: 10000; /* 确保在最上层 */
}

/* 场景15 - scene-16.png (无对话框) */

/* 场景16的对话框 - scene-17.png */
/* 0-201.png */
#dialogImage15_0 {
  left: 25%;
  top: 5%;
  width: 50%;
  height: auto;
}

/* 0-202.png */
#dialogImage15_1 {
  left: 20%;
  top: 60%;
  width: 55%;
  height: auto;
}

/* 场景17的对话框已删除 */

/* 场景18的对话框位置 - 使用百分比定位 */
/* 0-211.png 从场景20移到此 */
#dialogImage17_0 {
  left: 20%;
  top: 41%;
  width: 60%;
  height: auto;
}

/* 场景19的对话框已删除 */

/* 场景20的对话框位置 - 使用百分比定位 */
/* 0-231.png 和 0-232.png 从场景22移到此 */
#dialogImage19_0 {
  left: 13%;
  top: 50%;
  width: 50%;
  height: auto;
}

#dialogImage19_1 {
  left: 33%;
  top: 15%;
  width: 50%;
  height: auto;
}

/* 场景21的对话框已删除 */

/* 场景22的对话框位置 - 使用百分比定位 */
/* 0-241.png、0-242.png、0-243.png 从场景23移到此 */
#dialogImage21_0 {
  left: 0%;
  top: 0%;
  width: 100%;
  height: auto;
}

#dialogImage21_1 {
  left: 15%;
  top: 60%;
  width: 70%;
  height: auto;
  pointer-events: auto; /* 允许点击，回到首页 */
  cursor: pointer; /* 显示手型光标 */
  z-index: 10000; /* 确保在最上层 */
}

#dialogImage21_2 {
  left: 15%;
  top: 40%;
  width: 70%;
  height: auto;
}

/* 场景23的对话框已删除 */

/* 第二个气泡图片 */
.bubble-image {
  position: absolute;
  left: 64%;
  top: 30%;
  z-index: 4;
  width: 25%;
  height: auto;
}

/* 重播按钮 */
.replay-button {
  position: absolute;
  right: 3%;
  bottom: 3%;
  width: 50px;
  height: 50px;
  z-index: 10;
  cursor: pointer;
  opacity: 0.9;
  transition: all 0.3s ease;
}

.replay-button:hover {
  opacity: 1;
  transform: scale(1.15);
}

.replay-button:active {
  transform: scale(0.9);
}

/* 移动端重播按钮调整 */
@media (max-width: 768px) {
  .replay-button {
    width: 45px;
    height: 45px;
    right: 5%;
    bottom: 3%;
  }
}

@media (max-width: 480px) {
  .replay-button {
    width: 40px;
    height: 40px;
  }
}

.scene-content {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.8), transparent);
  color: #fff;
  padding: 5.33%; /* 20/375 */
  font-size: 4vw;
  line-height: 1.6;
  z-index: 10;
}

/* 对话框图片预览 */
.dialog-image-preview {
  position: relative;
  z-index: 2;
}

.hint-text {
  font-size: 3.2vw;
  color: rgba(255, 255, 255, 0.8);
  margin-top: 2.67%;
  position: relative;
}

/* 动画效果 */
@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

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

/* 隐藏滚动条但保持滚动功能 */
.scrollarea::-webkit-scrollbar {
  display: none;
}

.scrollarea {
  -ms-overflow-style: none;
  scrollbar-width: none;
}

/* ========== 响应式媒体查询 ========== */

/* 小手机屏幕 (宽度 < 360px) */
@media screen and (max-width: 359px) {
  .scene-content {
    font-size: 14px;
  }
  
  .title-image {
    width: 95%;
    left: 2.5%;
  }
  
  .start-button-image,
  .display-button-image {
    width: 40%;
  }
}

/* 普通手机屏幕 (360px - 414px) */
@media screen and (min-width: 360px) and (max-width: 414px) {
  .scene-content {
    font-size: 15px;
  }
}

/* 大手机/小平板 (415px - 768px) */
@media screen and (min-width: 415px) and (max-width: 768px) {
  .scene-content {
    font-size: 16px;
  }
  
  .title-image {
    width: 85%;
    left: 7.5%;
  }
  
  .start-button-image,
  .display-button-image {
    width: 32%;
  }
}

/* 平板横屏/小电脑 (769px - 1024px) */
@media screen and (min-width: 769px) and (max-width: 1024px) {
  .scrollarea {
    max-width: 600px;
  }
  
  .scene-content {
    font-size: 16px;
  }
  
  .title-image {
    width: 80%;
    left: 10%;
  }
  
  .start-button-image,
  .display-button-image {
    width: 30%;
  }
  
  .dialog-image {
    width: 70%;
  }
  
  .bubble-image {
    width: 28%;
  }
}

/* 电脑屏幕 (> 1024px) */
@media screen and (min-width: 1025px) {
  .scrollarea {
    max-width: 500px;
    border-left: 1px solid #333;
    border-right: 1px solid #333;
  }
  
  .scene-content {
    font-size: 16px;
  }
  
  .title-image {
    width: 75%;
    left: 12.5%;
  }
  
  .start-button-image,
  .display-button-image {
    width: 28%;
  }
  
  .dialog-image {
    width: 65%;
  }
  
  .bubble-image {
    width: 25%;
  }
}

/* 超大屏幕 (> 1440px) */
@media screen and (min-width: 1441px) {
  .scrollarea {
    max-width: 450px;
  }
}

/* ========== 安全区域适配 ========== */

/* 适配iPhone X等刘海屏 */
@supports (padding-top: env(safe-area-inset-top)) {
  body {
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
  }
}

/* ========== 深色模式适配 ========== */
@media (prefers-color-scheme: dark) {
  body {
    background: #000;
  }
  
  .scrollarea {
    background: #000;
  }
}

/* ========== 图片显示模式适配（根据屏幕尺寸智能选择 cover/contain）========== */

/* 平板竖屏（宽度>600px且竖屏） - 使用contain避免过度裁剪 */
@media screen and (min-width: 600px) and (orientation: portrait) {
  .scene-image {
    object-fit: contain;
  }
  
  .homepage-bg {
    object-fit: contain;
  }
}

/* 横屏模式 - 使用contain保留完整图片 */
@media screen and (orientation: landscape) {
  .scene-image {
    object-fit: contain;
  }
  
  .homepage-bg {
    object-fit: contain;
  }
}

/* 超宽屏（如桌面浏览器） - 使用contain */
@media screen and (min-width: 1024px) {
  .scene-image {
    object-fit: contain;
  }
  
  .homepage-bg {
    object-fit: contain;
  }
}

/* ========== 横屏适配 ========== */
@media screen and (orientation: landscape) and (max-height: 500px) {
  .scrollarea {
    max-width: 400px;
  }
  
  .title-image {
    width: 70%;
    left: 15%;
    top: 15%;
  }
  
  .start-button-image {
    top: 45%;
    width: 25%;
  }
  
  .display-button-image {
    top: 80%;
    width: 25%;
  }
}

/* ========== 触摸设备优化 ========== */
@media (hover: none) and (pointer: coarse) {
  .start-button-image {
    /* 触摸设备增大点击区域 */
    min-width: 120px;
    min-height: 40px;
  }
}

/* ========== 打印样式 ========== */
@media print {
  body {
    background: #fff;
  }
  
  .scrollarea {
    max-width: 100%;
    overflow: visible;
  }
}

/* ========== 弹窗样式 ========== */
.popup-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.7);
  z-index: 999999;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
}

.popup-container {
  position: relative;
  max-width: 75%;
  max-height: 75%;
  display: flex;
  justify-content: center;
  align-items: flex-end; /* 改为底部对齐 */
  transform: translateY(250px);
}

.popup-content {
  max-width: 100%;
  max-height: 90vh;
  width: auto;
  height: auto;
  display: block;
}

.popup-close-btn {
  position: absolute;
  top: -15px;
  right: -15px;
  width: 50px;
  height: 50px;
  cursor: pointer;
  z-index: 1000000;
  transition: transform 0.2s;
  pointer-events: auto;
}

.popup-close-btn:active {
  transform: scale(0.9);
}

/* 点击继续文字样式 */
.popup-continue-btn {
  position: absolute;
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%);
  padding: 10px 20px; /* 增加内边距，扩大点击区域 */
  background: none;
  color: #ffffff;
  border: none;
  font-size: 18px;
  font-weight: normal;
  cursor: pointer;
  z-index: 1000001;
  pointer-events: auto;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
  transition: all 0.3s ease;
  animation: textBlink 1.5s infinite;
  min-width: 100px; /* 确保最小宽度 */
  text-align: center;
  user-select: none; /* 防止文字被选中 */
  -webkit-tap-highlight-color: transparent; /* 移除移动端点击高亮 */
}

.popup-continue-btn:hover {
  transform: translateX(-50%) scale(1.1);
  color: #ffeb3b;
}

.popup-continue-btn:active {
  transform: translateX(-50%) scale(0.95);
}

/* 文字闪烁动画 */
@keyframes textBlink {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.6;
  }
}

/* 移动端适配 */
@media (max-width: 480px) {
  .popup-close-btn {
    width: 40px;
    height: 40px;
    top: -10px;
    right: -10px;
  }
  
  .popup-continue-btn {
    bottom: 10px;
    padding: 10px 30px;
    font-size: 16px;
  }
}

/* 弹窗显示时禁止页面滚动 */
body.popup-open {
  overflow: hidden;
  position: fixed;
  width: 100%;
  height: 100%;
}
