<script setup>
import { ref, onMounted, onUnmounted, computed, watch, nextTick } from 'vue'
import { useSceneStore } from '../store/scene'
import { useCollectionStore } from '../store/collection'
import { recordPageVisit, saveUserInfo, generateCoupletPoster } from '../api/api.js'
import LongImageViewer from './LongImageViewer.vue'
import MediaPlayer from './MediaPlayer.vue'
import QianmenScene from './QianmenScene.vue'
import DongzhimenScene from './DongzhimenScene.vue'
import LongfusiScene from './LongfusiScene.vue'
import WangfujingScene from './WangfujingScene.vue'
import ChongwenScene from './ChongwenScene.vue'
import EndPage from './EndPage.vue'
import LotteryFormModal from './LotteryFormModal.vue'
import AICoupletForm from './AICoupletForm.vue'
import CoupletDisplay from './CoupletDisplay.vue'

const sceneStore = useSceneStore()
const collectionStore = useCollectionStore()

// 当前活动场景索引
const activeSceneIndex = ref(0)
// 标题图片是否已显示过（用于保持显示状态）
const titleImageShown = ref(false)
// 滑动容器引用
const scrollContainer = ref(null)
// 是否在滚动中
const isScrolling = ref(false)
// 首页 section ID，用于 scroll-into-view
const homeSectionId = ref('')
// 页面是否准备就绪（滚动完成）
const isPageReady = ref(false)
// 前门板块高度
const qianmenSceneHeight = ref(0)
// 前门板块引用
const qianmenSceneRef = ref(null)
// 是否显示抽奖留资弹窗
const showLotteryForm = ref(false)
// 是否显示AI春联生成弹窗
const showAICoupletForm = ref(false)
// 是否显示春联展示页面
const showCoupletDisplay = ref(false)
// AI春联关键词
const coupletKeyword = ref('')
// 生成的春联
const generatedCouplet = ref(null)
// 页面访问UUID
const pageVisitUuid = ref('')
// 是否已提交用户信息
const hasSubmittedUserInfo = ref(false)
// 是否已手动滑动（用于隐藏滑动提示）
const hasScrolled = ref(false)
// 标记是否正在自动滚动
const isAutoScrolling = ref(false)


// 推荐关键词
const recommendedKeywords = ref(['吉祥', '如意', '平安', '健康', '幸福', '快乐', '富贵', '安康'])

// 场景数据数组
// 顺序：结束页 → 东直门 → 隆福寺 → 王府井 → 崇文门 → 前门 → 首页
const scenes = ref([
  {
    id: 'end',
    name: '结束页',
    description: '恭喜完成全部场景游览'
  },
  {
    id: 'dongzhimen',
    name: '东直门商圈',
    description: '京城东部的交通枢纽和商业中心',
    collectedItem: '团圆福筷'
  },
  {
    id: 'longfusi',
    name: '隆福寺商圈',
    description: '传统文化与现代艺术融合的潮流地标',
    collectedItem: '文化福灯'
  },
  {
    id: 'wangfujing',
    name: '王府井商圈',
    description: '北京最繁华的商业中心之一',
    collectedItem: '金袋福卡'
  },
  {
    id: 'chongwen',
    name: '崇文门商圈',
    description: '融合传统文化与现代商业的活力区域',
    collectedItem: '国潮福字'
  },
  {
    id: 'qianmen',
    name: '前门商圈',
    description: '北京最具历史文化底蕴的商圈之一',
    collectedItem: '非遗福印'
  },
  {
    id: 'home',
    name: '首页',
    description: '马年新春2026'
  }
])

// 交互状态
const sceneInteractiveStates = ref(scenes.value.map(() => false))
// 福印收集状态
const sealCollectedStates = ref(scenes.value.map(() => false))

// 计算当前收集的物品
const collectedItems = computed(() => {
  const items = []
  scenes.value.forEach((scene, index) => {
    if (index > 0 && index < scenes.value.length - 1) {
      if (sealCollectedStates.value[index]) {
        items.push(scene.collectedItem)
      }
    }
  })
  return items
})

// 计算收集进度
const collectionProgress = computed(() => {
  const total = scenes.value.length - 1 // 排除结束页
  const collected = sealCollectedStates.value.filter((state, index) => 
    index > 0 && index < scenes.value.length && state
  ).length
  return Math.round((collected / total) * 100)
})

// 计算福印收集对象（传递给 EndPage）
const collectedSeals = computed(() => {
  return {
    qianmen: sealCollectedStates.value[5] || false,  // 前门 (索引 5)
    chongwen: sealCollectedStates.value[4] || false, // 崇文门 (索引 4)
    wangfujing: sealCollectedStates.value[3] || false, // 王府井 (索引 3)
    longfusi: sealCollectedStates.value[2] || false, // 隆福寺 (索引 2)
    dongzhimen: sealCollectedStates.value[1] || false // 东直门 (索引 1)
  }
})

// 组件挂载后初始化
onMounted(() => {
  // 记录页面访问
  recordPageVisit({
    user_agent: navigator.userAgent,
    page_name: 'home'
  }).then(res => {
    if (res && res.uuid) {
      pageVisitUuid.value = res.uuid
      console.log('页面访问UUID:', res.uuid)
    }
  }).catch(err => {
    console.log('页面访问记录失败:', err)
  })
  
  // 检查并初始化场景交互状态
  scenes.value.forEach((scene, index) => {
    if (index > 0 && index < scenes.value.length) {
      const isCollected = collectionStore.isSceneSealCollected(scene.id)
      sealCollectedStates.value[index] = isCollected
    }
  })
  
  // 添加滚动事件监听 - 使用uniapp的scroll-view事件绑定
  // scroll-view 组件通过 @scroll 事件监听滚动，无需手动添加事件监听器

  
  // 页面加载时滚动到最底部（首页）
  const scrollToHomePage = () => {
    // 标记正在自动滚动
    isAutoScrolling.value = true
    
    if (!scrollContainer.value) {
      console.log('scrollContainer 尚未初始化')
      return
    }
    
    // 保存当前容器引用，避免异步回调中丢失
    const container = scrollContainer.value
    
    console.log('scrollContainer 已初始化:', {
      element: container,
      scrollHeight: container.scrollHeight,
      clientHeight: container.clientHeight,
      scrollTop: container.scrollTop,
      classList: container.classList
    })
    
    // 如果scrollHeight为0，说明内容还未渲染
    if (container.scrollHeight === 0) {
      console.log('内容尚未渲染，延迟重试...')
      setTimeout(scrollToHomePage, 100)
      return
    }
    
    // 首页是最后一个场景，索引为 scenes.value.length - 1
    // 应该位于页面最底部
    const homeIndex = scenes.value.length - 1
    
    // 方法1: 使用 scroll-into-view（uniapp 原生支持）
    console.log('使用 scroll-into-view 滚动到首页')
    homeSectionId.value = 'home-section'
    
    // 设置活动场景为首页
    activeSceneIndex.value = homeIndex
    
    // 设置活动场景为首页
    activeSceneIndex.value = homeIndex
    
    // 验证滚动是否成功，如果不成功，延迟后重试
    setTimeout(() => {
      if (!container) {
        console.log('scrollContainer 已卸载')
        return
      }
      
      console.log('验证滚动结果:', {
        currentScrollTop: container.scrollTop,
        scrollHeight: container.scrollHeight,
        clientHeight: container.clientHeight,
        isAtBottom: Math.abs(container.scrollTop - (container.scrollHeight - container.clientHeight)) < 50
      })
      
      // 检查是否已经滚动到底部
      const isAtBottom = Math.abs(container.scrollTop - (container.scrollHeight - container.clientHeight)) < 50
      
      if (!isAtBottom) {
        console.log('滚动验证失败，使用备用方法重试...')
        // 方法2: 使用 scrollTo 或 scrollTop
        try {
          const targetScrollTop = container.scrollHeight - container.clientHeight
          if (typeof container.scrollTo === 'function') {
            container.scrollTo({
              top: targetScrollTop,
              duration: 0
            })
          } else {
            container.scrollTop = targetScrollTop
          }
        } catch (error) {
          console.log('备用方法失败:', error)
          container.scrollTop = container.scrollHeight - container.clientHeight
        }
        
        // 再次验证后显示容器
        setTimeout(() => {
          // 标记页面准备就绪，隐藏加载提示并显示页面
          isPageReady.value = true
          titleImageShown.value = true
          // 自动滚动结束
          isAutoScrolling.value = false
          console.log('设置 isPageReady = true，准备显示页面')
        }, 50)
      } else {
        console.log('成功滚动到首页')
        // 滚动成功后显示容器
        // 标记页面准备就绪，隐藏加载提示并显示页面
        isPageReady.value = true
        titleImageShown.value = true
        // 自动滚动结束
        isAutoScrolling.value = false
        console.log('设置 isPageReady = true，准备显示页面')
      }
    }, 300)
  }

    // 初始滚动到首页 - 延迟更长时间确保内容渲染
  setTimeout(scrollToHomePage, 800)

  // 额外的确保措施，等待更长时间后再次尝试
  setTimeout(scrollToHomePage, 1500)
})

// 处理滚动事件（从下往上滑动）
const handleScroll = (event) => {
  if (isScrolling.value) return
  
  // 只有在非自动滚动状态下，才标记为已手动滑动
  if (!isAutoScrolling.value && !hasScrolled.value && event.detail.scrollTop > 50) {
    hasScrolled.value = true
  }
  
  // 在uniapp中，scroll-view的scroll事件传递的是event.detail对象
  const scrollTop = event.detail.scrollTop
  const viewportHeight = window.innerHeight
  const totalHeight = scrollContainer.value.scrollHeight
  const totalScenes = scenes.value.length
  
  // 计算当前活动场景（从下往上滚动）
  // 首页在底部（索引6），向上滑动依次看到：前门(5)、崇文门(4)、王府井(3)、隆福寺(2)、东直门(1)、结束页(0)
  const distanceFromBottom = totalHeight - scrollTop - viewportHeight
  const sceneIndexFromBottom = Math.round(distanceFromBottom / viewportHeight)
  
  // 将索引转换为正确的场景顺序
  // sceneIndexFromBottom: 0=首页, 1=前门, 2=崇文门, 3=王府井, 4=隆福寺, 5=东直门, 6=结束页
  const sceneIndex = totalScenes - 1 - sceneIndexFromBottom
  
  // 确保索引在有效范围内
  const clampedIndex = Math.max(0, Math.min(sceneIndex, totalScenes - 1))
  
  if (clampedIndex !== activeSceneIndex.value) {
    activeSceneIndex.value = clampedIndex
    // 激活当前场景
    if (activeSceneIndex.value > 0 && activeSceneIndex.value < scenes.value.length - 1) {
      sceneStore.activateScene(scenes.value[activeSceneIndex.value].id)
    }
    // 如果滚动到首页，标记标题图片已显示
    if (clampedIndex === 6) {
      titleImageShown.value = true
    }
  }
}

// 滚动到指定场景（从下往上滑动逻辑）
const scrollToScene = (index) => {
  if (!scrollContainer.value || isScrolling.value) return
  
  isScrolling.value = true
  const viewportHeight = window.innerHeight
  const totalHeight = scrollContainer.value.scrollHeight
  const totalScenes = scenes.value.length
  
  // 计算目标滚动位置（从下往上滚动）
  // index=0: 结束页（最顶部）
  // index=6: 首页（最底部）
  const targetScrollTop = totalHeight - (totalScenes - index) * viewportHeight
  
  scrollContainer.value.scrollTo({
    top: targetScrollTop,
    duration: 1000
  })
  
  setTimeout(() => {
    isScrolling.value = false
  }, 1000)
}

// 收集福印
const collectSeal = (index) => {
  if (index < 1 || index >= scenes.value.length - 1) return
  
  const scene = scenes.value[index]
  const success = collectionStore.collectSealBySceneId(scene.id)
  
  if (success) {
    sealCollectedStates.value[index] = true
    uni.showToast({
      title: `恭喜获得${scene.name}的${scene.collectedItem}！`,
      duration: 2000
    })
  }
}

// 打开抽奖留资弹窗
const openLotteryForm = () => {
  showLotteryForm.value = true
}

// 关闭抽奖留资弹窗
const closeLotteryForm = () => {
  showLotteryForm.value = false
}

// 提交抽奖表单
const submitLotteryForm = async (formData) => {
  // 检查是否已经提交过
  if (hasSubmittedUserInfo.value) {
    uni.showToast({
      title: '您已经提交过信息了，请勿重复提交',
      icon: 'none',
      duration: 2000
    })
    return
  }
  
  // 检查是否有UUID
  if (!pageVisitUuid.value) {
    uni.showToast({
      title: '系统错误，请刷新页面重试',
      icon: 'none',
      duration: 2000
    })
    return
  }
  
  uni.showLoading({
    title: '提交中...',
    mask: true
  })
  
  try {
    // 调用用户信息保存接口
    await saveUserInfo({
      name: formData.name,
      phone: formData.phone,
      address: formData.address,
      msg: formData.msg,
      page_visit_uuid: pageVisitUuid.value
    })
    
    // 标记为已提交
    hasSubmittedUserInfo.value = true
    
    uni.hideLoading()
    uni.showToast({
      title: '提交成功！我们将在活动结束后通知您抽奖结果',
      duration: 2000
    })
    showLotteryForm.value = false
  } catch (error) {
    uni.hideLoading()
    console.error('提交用户信息失败:', error)
    
    // 直接展示后端返回的错误信息
    let errorMessage = '提交失败，请稍后重试'
    
    // 检查是否有后端返回的错误信息
    if (error.data && error.data.error) {
      errorMessage = error.data.error
    } else if (error.response && error.response.data && error.response.data.error) {
      errorMessage = error.response.data.error
    } else if (error.message) {
      // 如果是网络错误或其他错误，显示通用提示
      errorMessage = '提交失败，请稍后重试'
    }
    
    uni.showToast({
      title: errorMessage,
      icon: 'none',
      duration: 2000
    })
  }
}

// 打开AI春联生成弹窗
const openAICoupletForm = () => {
  showAICoupletForm.value = true
}

// 处理生成春联
const handleGenerateCouplet = async (keyword) => {
  uni.showLoading({
    title: '生成中...',
    mask: true
  })
  
  try {
    // 调用后端 API 生成春联海报
    const response = await generateCoupletPoster({
      title: keyword,
      page_visit_uuid: pageVisitUuid.value
    })
    
    uni.hideLoading()
    
    // 构建春联数据 - 使用 API 返回的参数
    generatedCouplet.value = {
      share_url: response.share_url,
      image_url: response.image_url
    }
    
    showCoupletDisplay.value = true
    showAICoupletForm.value = false
  } catch (error) {
    uni.hideLoading()
    
    // 显示错误信息
    uni.showToast({
      title: error.message || '生成春联失败，请稍后重试',
      icon: 'none',
      duration: 2000
    })
  }
}

// 处理分享春联
const handleShareCouplet = () => {
  // 分享逻辑可以在这里扩展
  console.log('分享春联:', generatedCouplet.value)
}

// 返回顶部
const scrollToTop = () => {
  scrollToScene(0)
}

// 处理图片加载错误
const handleImageError = (event) => {
  event.target.src = 'https://placeholder.pics/svg/640x1136/FDE9DF/FF6B35/2026新春东城商圈'
}

// 处理前门板块高度变化
const handleQianmenHeightChanged = (height) => {
  qianmenSceneHeight.value = height
  // 这里可以添加逻辑，将所有其他场景的高度设置为与前门板块相同的高度
  // 可以通过CSS变量或直接修改DOM元素的高度
  document.documentElement.style.setProperty('--scene-height', `${height}px`)
  console.log('前门板块高度变化:', height, 'px')
  console.log('当前CSS变量:', getComputedStyle(document.documentElement).getPropertyValue('--scene-height'))
}

// 使用scroll-view组件后，不再需要手动处理触摸事件
// scroll-view会自动处理触摸滚动

// 组件卸载前清理资源
onUnmounted(() => {
  // 无需手动移除事件监听器，uniapp会自动处理
})
</script>

<template>
  <div class="single-page-wrapper">
    <!-- 加载提示 -->
    <div class="loading-hint" v-if="!isPageReady">
      <div class="loading-spinner"></div>
      <p>正在加载...</p>
    </div>
    
    <scroll-view
      class="single-page-container"
      :class="{ 'visible': isPageReady }"
      ref="scrollContainer"
      scroll-y="true"
      scroll-with-animation="true"
      enhanced="true"
      :refresher-enabled="false"
      :refresher-triggered="false"
      show-scrollbar="false"
      :bounce="false"
      @scroll="handleScroll"
      :scroll-into-view="homeSectionId"
    >
      <!-- 结束页 -->
      <EndPage
        :is-active="activeSceneIndex === 0"
        :title="scenes[0].description"
        :collection-progress="collectionProgress"
        :collected-count="collectedItems.length"
        :total-count="scenes.length - 1"
        :collected-seals="collectedSeals"
        :has-submitted="hasSubmittedUserInfo"
        :generated-couplet="generatedCouplet"
        @lottery="openLotteryForm"
        @couplet="openAICoupletForm"
        @show-couplet="showCoupletDisplay = true"
        @restart="scrollToTop"
      />

      <!-- 东直门商圈 -->
      <DongzhimenScene 
        :active="activeSceneIndex === 1"
        :scroll-position="scrollContainer && scrollContainer.value ? scrollContainer.value.scrollTop : 0"
        @collect-seal="collectSeal(1)"
      />

      <!-- 隆福寺商圈 -->
      <LongfusiScene 
        :active="activeSceneIndex === 2"
        :scroll-position="scrollContainer && scrollContainer.value ? scrollContainer.value.scrollTop : 0"
        @collect-seal="collectSeal(2)"
      />

      <!-- 王府井商圈 -->
      <WangfujingScene 
        :active="activeSceneIndex === 3"
        :scroll-position="scrollContainer?.value?.scrollTop || 0"
        @collect-seal="collectSeal(3)"
      />

      <!-- 崇文门商圈 -->
      <ChongwenScene 
        :active="activeSceneIndex === 4"
        :scroll-position="scrollContainer?.value?.scrollTop || 0"
        @collect-seal="collectSeal(4)"
      />

      <!-- 前门商圈 -->
      <QianmenScene 
        :active="activeSceneIndex === 5"
        :scroll-position="scrollContainer?.value?.scrollTop || 0"
        @collect-seal="collectSeal(5)"
        @height-changed="handleQianmenHeightChanged"
      />
      
      <!-- 新年文案模块 -->
      <section class="new-year-section">
        <div class="new-year-content">
          <img 
            src="/static/images/main_text.png" 
            alt="新年文案" 
            class="new-year-text"
          />
        </div>
      </section>
      
      <!-- 首页 -->
      <section id="home-section" class="scene-section home-section" :class="{ 'active': activeSceneIndex === 6 }">
        <!-- 背景图片层 -->
        <div class="home-bg">
          <img 
            src="/static/bg/bg_main.jpg" 
            alt="2026新春东城商圈"
            class="bg-image"
            @error="handleImageError"
          />
        </div>
        <!-- 标题图片 -->
        <img 
          src="/static/images/img_title.png" 
          alt="马年新春2026" 
          class="title-image"
          :class="{ 'title-image-active': titleImageShown }"
        />
      </section>

      <!-- 向上滑动提示 -->
      <div class="scroll-tip-bottom" v-if="!hasScrolled">
        <img src="/static/images/icon_hand1.png" class="tip-icon" alt="滑动提示" />
        <p>向上滑动探索商圈</p>
      </div>

    <!-- 抽奖留资弹窗 -->
    <LotteryFormModal
      :visible="showLotteryForm"
      :has-submitted="hasSubmittedUserInfo"
      @close="closeLotteryForm"
      @submit="submitLotteryForm"
    />

    <!-- AI春联生成弹窗 -->
    <AICoupletForm
      :visible="showAICoupletForm"
      @close="showAICoupletForm = false"
      @generate="handleGenerateCouplet"
    />

    <!-- 春联展示页面 -->
    <CoupletDisplay
      :visible="showCoupletDisplay"
      :couplet="generatedCouplet"
      @close="showCoupletDisplay = false"
      @share="handleShareCouplet"
    />
    </scroll-view>
  </div>
</template>

<style scoped>
.single-page-wrapper {
  position: relative;
  width: 100%;
  height: 100vh;
  overflow: hidden;
}

/* 加载提示样式 */
.loading-hint {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  background: rgba(253, 233, 223, 0.95);
  padding: 30px 40px;
  border-radius: 15px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

.loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid #f3f3f3;
  border-top: 3px solid #FF6B35;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 15px;
}

.loading-hint p {
  color: #FF6B35;
  font-size: 16px;
  font-weight: 500;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.single-page-container {
  position: relative;
  width: 100%;
  height: 100%;
  overflow-y: scroll; /* 改为 scroll 确保可以滚动 */
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch; /* 启用iOS平滑滚动 */
  /* 使用 visibility 而不是 opacity，确保完全不可见且不可交互 */
  visibility: hidden;
  touch-action: pan-y; /* 允许垂直方向的触摸滚动 */
  user-select: none; /* 防止触摸时文本被选中 */
}

.single-page-container.visible {
  visibility: visible;
  /* 添加淡入效果 */
  animation: fadeIn 0.4s ease-in-out;
}

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

/* ========== 隐藏滚动条样式（所有浏览器）========== */

/* WebKit 浏览器（Chrome、Safari、新版 Edge）*/
.single-page-container::-webkit-scrollbar {
  width: 0 !important;
  height: 0 !important;
  display: none !important;
}

.single-page-container::-webkit-scrollbar-track {
  background: transparent !important;
}

.single-page-container::-webkit-scrollbar-thumb {
  background: transparent !important;
}

.single-page-container::-webkit-scrollbar-corner {
  background: transparent !important;
}

/* Firefox */
.single-page-container {
  scrollbar-width: none !important;
}

/* IE 和旧版 Edge */
.single-page-container {
  -ms-overflow-style: none !important;
}

/* 通用样式 */
.single-page-container {
  scrollbar-color: transparent transparent !important;
}

/* 场景部分样式 */
.scene-section {
  position: relative;
  width: 100%;
  height: var(--scene-height, 100vh);
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: #f5f5f5;
}

/* 首页样式 */
.home-section {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  height: 100vh;
  overflow: hidden;
}

.home-bg {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
}

.bg-image {
  width: 100%;
  height: 100%;
  object-fit: cover; /* 裁切方式适配不同高度 */
  object-position: center center;
}

/* 向上滑动提示样式 */
.scroll-tip-bottom {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  animation: bounce 1.5s infinite;
  z-index: 100;
  color: white;
}

.tip-icon {
  width: 64rpx;
  height: 78rpx;
}

@keyframes bounce {
  0%, 20%, 50%, 80%, 100% {
    transform: translateX(-50%) translateY(0);
  }
  40% {
    transform: translateX(-50%) translateY(-10px);
  }
  60% {
    transform: translateX(-50%) translateY(-5px);
  }
}

/* 新年文案模块样式 */
.new-year-section {
  width: 100%;
  background-color: #f94332;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  padding: 15px 0;
}

.new-year-content {
  text-align: center;
}

.new-year-text {
  display: inline-block;
  width: 516rpx;
  height: auto;
  object-fit: contain;
}

/* 标题图片样式 */
.title-image {
  width: 80%;
  max-width: 400px;
  height: auto;
  margin: 40rpx auto 20px;
  display: block;
  transform: scale(0);
  transition: transform 0.8s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  position: relative;
  z-index: 2;
}

.title-image-active {
  transform: scale(1);
}

.scroll-tip {
  position: absolute;
  bottom: 50px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  animation: bounce 1.5s infinite;
}

@keyframes bounce {
  0%, 20%, 50%, 80%, 100% {
    transform: translateX(-50%) translateY(0);
  }
  40% {
    transform: translateX(-50%) translateY(-20px);
  }
  60% {
    transform: translateX(-50%) translateY(-10px);
  }
}

/* 响应式设计 */
@media (max-width: 480px) {
  .scene-title {
    font-size: 24px;
  }
  
  .scene-description {
    font-size: 14px;
  }
  
  .couplet-item {
    font-size: 20px;
  }
  
  .top-couplet, .bottom-couplet {
    margin-right: 20px;
    margin-left: 20px;
  }
}
</style>