/* =========================================================
   セレブレーション演出（ゲームクリア／ゲームオーバー）
   リザルト画面へ切り替える前に、ゲーム画面の上に重ねて見せる。
   - 粒子は #celebration-canvas に Canvas 2D で描画（src/game/celebration.js）
   - 文字まわりのアニメーションはここ。JS は class の付け外しだけ行う
     （CSP が style-src 'self' ＝ インライン style 禁止のため）
   ========================================================= */

.celebration-layer {
  position: fixed;
  inset: 0;
  z-index: 120; /* ポーズオーバーレイ(100)・ミュートボタン(50)より前 */
  pointer-events: none; /* 演出中もクリックは下に素通し（スキップはJS側で拾う） */
  display: none;
  align-items: center;
  justify-content: center;
}

.celebration-layer.is-active {
  display: flex;
}

#celebration-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.celebration-banner {
  position: relative;
  z-index: 1;
  width: min(92vw, 640px);
  padding: 0 var(--space-3);
  text-align: center;
  /* 再生前は見えない。.is-shown が付いたときだけアニメーションで出す */
  opacity: 0;
}

.celebration-banner.is-shown {
  opacity: 1;
}

/* ---------- 大見出し ---------- */
.celebration-banner__title {
  margin: 0;
  font-family: var(--font);
  font-size: clamp(2.5rem, 11vw, 4.6rem);
  font-weight: var(--fw-black);
  line-height: 1.05;
  color: #fff;
  -webkit-text-stroke: 5px var(--primary-strong);
  paint-order: stroke fill;
  text-shadow:
    0 4px 0 #c2480f,
    0 7px 0 #a53d0c,
    0 12px 20px rgba(95, 40, 8, 0.45);
  opacity: 0;
}

/* 失敗側は落ち着いたブラウングレーのフチに差し替える */
.celebration-banner.is-lose .celebration-banner__title {
  -webkit-text-stroke-color: #6d5647;
  text-shadow:
    0 4px 0 #564337,
    0 7px 0 #45352b,
    0 12px 20px rgba(30, 20, 12, 0.5);
}

/* ---------- 添え書き ---------- */
.celebration-banner__sub {
  margin: var(--space-2) 0 0;
  font-family: var(--font);
  font-size: clamp(0.95rem, 3.6vw, 1.3rem);
  font-weight: var(--fw-black);
  color: #fff;
  -webkit-text-stroke: 3px rgba(120, 70, 30, 0.85);
  paint-order: stroke fill;
  text-shadow: 0 3px 8px rgba(80, 45, 15, 0.5);
  opacity: 0;
}

.celebration-banner.is-lose .celebration-banner__sub {
  -webkit-text-stroke-color: rgba(70, 54, 44, 0.9);
}

/* ---------- 成功：ドンッと出てから ゆらゆら ---------- */
.celebration-banner.is-win.is-shown .celebration-banner__title {
  animation:
    celeb-pop 0.5s cubic-bezier(0.2, 1.7, 0.5, 1) both,
    celeb-wobble 1.5s 0.5s ease-in-out infinite;
}

.celebration-banner.is-win.is-shown .celebration-banner__sub {
  animation: celeb-rise 0.45s 0.32s cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes celeb-pop {
  0% { opacity: 0; transform: scale(0.4) translateY(26px); }
  70% { opacity: 1; transform: scale(1.12) translateY(0); }
  100% { opacity: 1; transform: scale(1) translateY(0); }
}

@keyframes celeb-wobble {
  0%, 100% { transform: rotate(-1.6deg) scale(1); }
  50% { transform: rotate(1.6deg) scale(1.04); }
}

@keyframes celeb-rise {
  0% { opacity: 0; transform: translateY(14px); }
  100% { opacity: 1; transform: translateY(0); }
}

/* ---------- 失敗：上からガクンと落ちて、かしいで止まる ---------- */
.celebration-banner.is-lose.is-shown .celebration-banner__title {
  animation: celeb-drop 0.62s cubic-bezier(0.5, 0.05, 0.6, 1) both;
}

.celebration-banner.is-lose.is-shown .celebration-banner__sub {
  animation: celeb-fade 0.5s 0.42s ease-out both;
}

@keyframes celeb-drop {
  0% { opacity: 0; transform: translateY(-90px) rotate(-7deg); }
  55% { opacity: 1; transform: translateY(10px) rotate(2.5deg); }
  75% { transform: translateY(-4px) rotate(-1.5deg); }
  100% { opacity: 1; transform: translateY(0) rotate(-2deg); }
}

@keyframes celeb-fade {
  0% { opacity: 0; }
  100% { opacity: 1; }
}

/* ---------- 動きを減らす設定のときは、揺れを止めてフェードだけにする ---------- */
@media (prefers-reduced-motion: reduce) {
  .celebration-banner.is-shown .celebration-banner__title,
  .celebration-banner.is-shown .celebration-banner__sub {
    animation: celeb-fade 0.3s ease-out both;
  }
}
