body {
  margin: 0;
  font-family: 'Noto Sans JP', sans-serif;
  background-color: #0e0f1b;
  color: #f9f4ef;
  overflow: hidden;
  -webkit-text-size-adjust: 100%; /* iOSのフォント自動調整を防ぐ */
}

#story-wrapper {
  width: 100%;
  height: 100vh;
  height: 100dvh; /* 動的ビューポート高さ（スマホ対応） */
  overflow: hidden;
}

#story-container {
  position: relative;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

/* 各ページ */
.story-page {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  color: #fff;
  padding: 20px;
  padding-bottom: 120px; /* スマホ用に大きめ */
  box-sizing: border-box;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.5s ease, visibility 0.5s ease;
  overflow: hidden;
  pointer-events: none;
}

.story-page.active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

/* SVG背景 */
.bg-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  display: block;
  transform: translateZ(0);
  will-change: transform;
}

.story-page.parallax-active .bg-svg {
  transition: transform 0.3s ease-out;
}

/* 読みやすさのための暗幕（強化） */
.story-page::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    to bottom,
    rgba(0,0,0,0.2) 0%,
    rgba(0,0,0,0.5) 40%,
    rgba(0,0,0,0.85) 100%
  );
  z-index: 1;
  pointer-events: none;
}

/* Lottieアニメーション */
.story-animation {
  position: absolute;
  top: 25%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 200px;
  height: 200px;
  z-index: 1;
  pointer-events: none;
}

.story-page.active .story-animation {
  animation: fadeInAnimation 1s ease forwards;
  animation-delay: 0.5s;
}

@keyframes fadeInAnimation {
  from { opacity: 0; transform: translate(-50%, -50%) scale(0.8); }
  to { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

/* テキストボックス */
/* テキストボックス */
.story-text {
  position: absolute; /* relative → absolute に変更 */
  bottom: 120px; /* 下からの固定位置 */
  left: 50%;
  transform: translateX(-50%); /* 中央揃え */
  z-index: 2;
  font-size: 1.1rem;
  line-height: 1.8;
  max-width: 90%;
  text-shadow: 2px 2px 8px rgba(0,0,0,1);
  background: rgba(0,0,0,0.7);
  padding: 25px 30px;
  border-radius: 16px;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  word-wrap: break-word;
  color: #fff;
  border: 1px solid rgba(255,255,255,0.1);
}

.story-page.active .story-text {
  animation: slideUpText 0.8s ease;
}

@keyframes slideUpText {
  from { 
    opacity: 0; 
    transform: translateX(-50%) translateY(30px); /* translateX を維持 */
  }
  to { 
    opacity: 1; 
    transform: translateX(-50%) translateY(0); /* translateX を維持 */
  }
}

/* スマホ対応 */
@media (max-width: 768px) {
  .story-page {
    padding: 10px;
  }
  
  .story-text {
    bottom: 140px; /* スマホ用調整 */
    font-size: 1.05rem;
    line-height: 1.9;
    padding: 20px 24px;
    max-width: 92%;
    background: rgba(0,0,0,0.8);
    text-shadow: 2px 2px 10px rgba(0,0,0,1);
  }
  
  .story-animation {
    width: 150px;
    height: 150px;
    top: 20%;
  }
  
  .story-page::before {
    background: linear-gradient(
      to bottom,
      rgba(0,0,0,0.3) 0%,
      rgba(0,0,0,0.6) 30%,
      rgba(0,0,0,0.9) 100%
    );
  }
}

/* 超小型スマホ対応 */
@media (max-width: 400px) {
  .story-text {
    bottom: 160px;
    font-size: 0.95rem;
    line-height: 1.7;
    padding: 18px 20px;
  }
}
/* 次へヒント */
#next-hint {
  position: fixed;
  bottom: 30px;
  right: 20px;
  opacity: 0.9;
  font-size: 1rem;
  color: #f9f4ef;
  background: rgba(0,0,0,0.6);
  padding: 10px 20px;
  border-radius: 20px;
  z-index: 10;
  animation: pulse 2s infinite;
  pointer-events: none;
}

@keyframes pulse {
  0%, 100% { opacity: 0.9; }
  50% { opacity: 0.5; }
}

/* エフェクト */
.effect-fade.active { animation: fadeIn 1s ease; }
.effect-slide.active { animation: slideIn 1s ease; }
.effect-zoom.active { animation: zoomIn 1s ease; }

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

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

@keyframes zoomIn { 
  from { transform: scale(0.9); opacity: 0; } 
  to { transform: scale(1); opacity: 1; } 
}

/* パララックス用トランジション */
.bg-svg,
.story-animation,
.story-text {
  transition: transform 0.15s ease-out;
  will-change: transform;
}

/* パララックス有効時はスムーズに */
.story-page.active .bg-svg,
.story-page.active .story-animation,
.story-page.active .story-text {
  transition: transform 0.2s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.bg-svg-container {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  overflow: hidden;
}

.bg-svg-container .bg-svg {
  width: 100%;
  height: 100%;
  display: block;
}