/* ==========================================================================
   150周年アニバーサリーモーダル演出用共通CSS
   ========================================================================== */

:root {
  --anniversary-primary: #324f8b;
  --anniversary-accent: #ff00de;
  --anniversary-ease-spring: cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

#tab4 {
  position: relative;
  min-height: 400px;
  overflow-x: hidden;
  padding-bottom: 160px;
  /* 移動ルート用スペース */
}

.futto-trigger-container {
  position: absolute;
  left: calc(-1 * var(--futto-offset, 180px));
  /* 初期位置は左の画面外（画面幅に応じてJSがオフセットを調整） */
  bottom: 0px;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: pointer;
  /* CSS変数を使用して速度一定。JSが計算するまでのデフォルトは25s */
  animation: futto-patrol var(--futto-duration, 25s) linear infinite;
}

.futto-sleep-wrap {
  display: flex;
  justify-content: center;
  align-items: center;
  /* 吹き出しの反転を防ぐため、ふっとう君画像用のラッパーにのみ反転アニメーションを適用 */
  animation: futto-patrol-flip var(--futto-duration, 25s) linear infinite;
}

.futto-sleep-btn {
  width: 70px;
  height: auto;
  filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.3));
  /* 縦揺れ浮遊アニメーションを復元 */
  animation: futto-float 3s ease-in-out infinite;
  transition: transform 0.3s var(--anniversary-ease-spring);
  /* 画像下部の透明余白を削り、クリック領域の適正化と表示位置の引き下げを同時に行う */
  margin-bottom: -20px;
}

.futto-trigger-container:hover .futto-sleep-btn {
  transform: scale(1.15);
}

/* 吹き出し（常時表示） */
.futto-balloon {
  position: relative;
  background: rgba(255, 255, 255, 0.95);
  border: 2px solid var(--anniversary-primary);
  border-radius: 12px;
  padding: 6px 12px;
  font-size: 11px;
  color: var(--anniversary-primary);
  font-weight: bold;
  margin-bottom: 8px;
  white-space: nowrap;
  box-shadow: 0 6px 15px rgba(0, 0, 0, 0.15);
  opacity: 1;
  /* 常時表示 */
  transform: translateY(0);
  /* 常時表示 */
  pointer-events: none;
  /* 縦揺れアニメーションを復元 */
  animation: balloon-bob 3s ease-in-out infinite;
}

.futto-balloon::after {
  content: "";
  position: absolute;
  bottom: -6px;
  left: 50%;
  transform: translateX(-50%);
  border-width: 6px 6px 0;
  border-style: solid;
  border-color: rgba(255, 255, 255, 0.95) transparent;
  display: block;
  width: 0;
}

.futto-balloon::before {
  content: "";
  position: absolute;
  bottom: -8px;
  left: 50%;
  transform: translateX(-50%);
  border-width: 8px 8px 0;
  border-style: solid;
  border-color: var(--anniversary-primary) transparent;
  display: block;
  width: 0;
  z-index: -1;
}

@keyframes futto-float {
  0% {
    transform: translateY(0px) rotate(0deg);
  }

  50% {
    transform: translateY(-8px) rotate(3deg);
  }

  100% {
    transform: translateY(0px) rotate(0deg);
  }
}

@keyframes balloon-bob {
  0% {
    transform: translateY(0px);
  }

  50% {
    transform: translateY(-4px);
  }

  100% {
    transform: translateY(0px);
  }
}

/* モーダルウィンドウ */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(6, 12, 24, 0.92);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 10000;
  display: flex;
  justify-content: center;
  align-items: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.6s ease;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-content {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
}

#fireworks-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1;
}

.modal-inner {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  width: 100%;
  height: 100%;
  gap: 30px;
}

.modal-close-btn {
  position: absolute;
  top: 30px;
  right: 30px;
  width: 50px;
  height: 50px;
  background: none;
  border: none;
  cursor: pointer;
  z-index: 10;
  transition: transform 0.4s var(--anniversary-ease-spring), filter 0.3s ease;
  transform-origin: center;
  padding: 0;
  margin: 0;
  filter: drop-shadow(0 0 8px rgba(255, 255, 255, 0.5));
}

.modal-close-btn::before,
.modal-close-btn::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 30px;
  height: 3px;
  background-color: rgba(255, 255, 255, 0.8);
  transition: background-color 0.3s ease;
}

.modal-close-btn::before {
  transform: translate(-50%, -50%) rotate(45deg);
}

.modal-close-btn::after {
  transform: translate(-50%, -50%) rotate(-45deg);
}

.modal-close-btn:hover {
  transform: rotate(90deg) scale(1.1);
  filter: drop-shadow(0 0 12px rgba(255, 255, 255, 0.9));
}

.modal-close-btn:hover::before,
.modal-close-btn:hover::after {
  background-color: #fff;
}

/* 円形エンブレム配置レイアウト */
.emblems-circle-container {
  --radius: 210px;
  --total-items: 11;
  position: relative;
  width: 520px;
  height: 520px;
  display: flex;
  justify-content: center;
  align-items: center;
  /* 背後の花火の明るさを和らげるための透過背景グラデーション */
  background: radial-gradient(circle, rgba(6, 12, 24, 0.75) 0%, rgba(6, 12, 24, 0.55) 50%, rgba(6, 12, 24, 0) 80%);
  border-radius: 50%;
}

.circle-item {
  position: absolute;
  width: 90px;
  height: 110px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  --angle: calc(360deg / var(--total-items) * var(--index) - 90deg);

  transform: translate(0, 0) scale(0);
  opacity: 0;
  transition: transform 0.8s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.8s ease;
}

/* 表示時に順に展開するアニメーション */
.modal-overlay.active .circle-item {
  transform: translate(calc(cos(var(--angle)) * var(--radius)),
      calc(sin(var(--angle)) * var(--radius))) scale(1);
  opacity: 1;
  transition-delay: calc(var(--index) * 0.08s);
}

.circle-item img {
  width: 72px;
  /* 以前より大きく表示 */
  height: 72px;
  /* 以前より大きく表示 */
  object-fit: contain;
  filter: drop-shadow(0 0 10px rgba(255, 255, 255, 0.85));
  transition: transform 0.3s var(--anniversary-ease-spring), filter 0.3s ease;
}

.circle-item:hover img {
  transform: scale(1.2) rotate(5deg);
  filter: drop-shadow(0 0 15px rgba(255, 255, 222, 1)) saturate(1.2);
}

.emblem-caption {
  font-size: 10px;
  color: #fff;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.9), 0 0 8px rgba(255, 255, 255, 0.6);
  margin-top: 6px;
  font-weight: 500;
  white-space: nowrap;
  opacity: 0.85;
}

/* 中央の「踊るふっとう君コンテナ」 */
.circle-center {
  position: absolute;
  width: 170px;
  /* 少し大きめに調整 */
  height: 170px;
  /* 少し大きめに調整 */
  background: radial-gradient(circle, rgba(255, 255, 255, 0.2) 0%, rgba(0, 0, 0, 0) 70%);
  display: flex;
  justify-content: center;
  align-items: center;
  border-radius: 50%;
  transform: scale(0);
  opacity: 0;
  transition: transform 1s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 1s ease;
  z-index: 3;
}

.modal-overlay.active .circle-center {
  transform: scale(1);
  opacity: 1;
  transition-delay: 0.8s;
}

.center-futto {
  position: absolute;
  width: 130px;
  /* 少し大きめに設定 */
  height: auto;
  filter: drop-shadow(0 0 15px rgba(255, 255, 255, 0.8));
}

.center-futto.dance-1 {
  animation: futtoDance1 1.0s steps(1) infinite;
}

.center-futto.dance-2 {
  animation: futtoDance2 1.0s steps(1) infinite;
}

@keyframes futtoDance1 {

  0%,
  49.9% {
    opacity: 1;
  }

  50%,
  100% {
    opacity: 0;
  }
}

@keyframes futtoDance2 {

  0%,
  49.9% {
    opacity: 0;
  }

  50%,
  100% {
    opacity: 1;
  }
}

/* 中心の拡大縮小アニメーションは廃止されました */

/* モーダル下部のお礼文 */
.modal-footer-message {
  font-family: 'Noto Sans JP', sans-serif;
  font-size: 14px;
  color: #fff;
  text-align: center;
  max-width: 600px;
  line-height: 1.8;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.9), 0 0 8px rgba(255, 255, 255, 0.3);
  opacity: 0;
  transform: translateY(15px);
  transition: opacity 1s ease, transform 1s ease;
  /* エンブレムが展開し終わった後に表示 */
  font-weight: 500;
  letter-spacing: 0.5px;
}

.modal-overlay.active .modal-footer-message {
  opacity: 1;
  transform: translateY(0);
  transition-delay: 1.2s;
}

/* レスポンシブ対応 */
@media screen and (max-width: 768px) {
  .emblems-circle-container {
    --radius: 130px;
    width: 340px;
    height: 340px;
  }

  .circle-item {
    width: 60px;
    height: 80px;
  }

  .circle-item img {
    width: 48px;
    /* 以前より大きく（44px -> 54px） */
    height: 48px;
  }

  .emblem-caption {
    font-size: 8px;
    margin-top: 2px;
  }

  .circle-center {
    width: 130px;
    height: 130px;
  }

  .center-futto {
    width: 95px;
  }

  .modal-footer-message {
    font-size: 11px;
    padding: 0 20px;
    margin-top: 10px;
    line-height: 1.6;
  }

  /* スマホ版での吹き出しサイズ調整 */
  .futto-balloon {
    font-size: 10px;
    padding: 5px 10px;
    margin-bottom: 6px;
  }
}

/* ロゴ拡大表示用モーダル（アニバーサリーモーダルの上に重ねて表示） */
.detail-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(6, 12, 24, 0.95);
  backdrop-filter: blur(15px);
  -webkit-backdrop-filter: blur(15px);
  z-index: 20000;
  display: flex;
  justify-content: center;
  align-items: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease;
}

.detail-modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.detail-modal-content {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  max-width: 90%;
  max-height: 90%;
  transform: scale(0.9);
  transition: transform 0.4s var(--anniversary-ease-spring);
  text-align: center;
}

.detail-modal-overlay.active .detail-modal-content {
  transform: scale(1);
}

.detail-modal-content img {
  max-width: 320px;
  max-height: 320px;
  width: 100%;
  height: auto;
  object-fit: contain;
  filter: drop-shadow(0 0 20px rgba(255, 255, 255, 0.9));
  margin-bottom: 20px;
}

.detail-modal-caption {
  font-family: 'Noto Sans JP', sans-serif;
  font-size: 20px;
  font-weight: bold;
  color: #fff;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.8), 0 0 10px rgba(255, 255, 255, 0.4);
  margin: 0;
}

.detail-modal-close-btn {
  position: absolute;
  top: -50px;
  right: -50px;
  width: 44px;
  height: 44px;
  background: none;
  border: none;
  cursor: pointer;
  z-index: 20010;
  transition: transform 0.4s var(--anniversary-ease-spring), filter 0.3s ease;
  transform-origin: center;
  filter: drop-shadow(0 0 8px rgba(255, 255, 255, 0.5));
}

.detail-modal-close-btn::before,
.detail-modal-close-btn::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 24px;
  height: 3px;
  background-color: rgba(255, 255, 255, 0.8);
  transition: background-color 0.3s ease;
}

.detail-modal-close-btn::before {
  transform: translate(-50%, -50%) rotate(45deg);
}

.detail-modal-close-btn::after {
  transform: translate(-50%, -50%) rotate(-45deg);
}

.detail-modal-close-btn:hover {
  transform: rotate(90deg) scale(1.1);
  filter: drop-shadow(0 0 12px rgba(255, 255, 255, 0.9));
}

.detail-modal-close-btn:hover::before,
.detail-modal-close-btn:hover::after {
  background-color: #fff;
}

@media screen and (max-width: 768px) {
  .detail-modal-content img {
    max-width: 200px;
    max-height: 200px;
  }

  .detail-modal-caption {
    font-size: 16px;
  }

  .detail-modal-close-btn {
    top: -45px;
    right: 0px;
  }
}

/* 左右往復パトロールアニメーションのキーフレーム（コンテナの移動のみを制御） */
@keyframes futto-patrol {

  /* --- 往路: 左から右へ --- */
  0% {
    left: calc(-1 * var(--futto-offset, 180px));
  }

  3% {
    left: calc(-1 * var(--futto-offset, 180px));
    /* 待機終了・往路出発 */
  }

  47% {
    left: calc(100% + var(--futto-offset, 180px) - 70px);
    /* 右画面外に到着（ふっとう君の幅70pxを引くことで左右のはみ出し量を対称化） */
  }

  /* --- ターン: 右画面外 --- */
  53% {
    left: calc(100% + var(--futto-offset, 180px) - 70px);
    /* 待機終了・復路出発 */
  }

  /* --- 復路: 右から左へ --- */
  97% {
    left: calc(-1 * var(--futto-offset, 180px));
    /* 左画面外に到着 */
  }

  100% {
    left: calc(-1 * var(--futto-offset, 180px));
  }
}

/* 吹き出しの反転を防ぐため、ふっとう君画像のみを左右反転させるキーフレーム */
@keyframes futto-patrol-flip {

  /* 往路: 右向き */
  0%,
  49.9% {
    transform: scaleX(-1);
  }

  /* ターンして復路: 左向き */
  50%,
  99.9% {
    transform: scaleX(1);
  }

  /* ターンして往路に戻る */
  100% {
    transform: scaleX(-1);
  }
}