/* 獲得フィルム（js/celebrate.js）
   ease-out: cubic-bezier(.16,1,.3,1) / smooth: (.2,0,0,1) / back: (.34,1.56,.64,1) / shake: (.36,.07,.19,.97) */

.cf {
  --cf-ms: 2400ms;
  --art: min(50vh, 44vw, 17rem);
  position: absolute;
  inset: 0;
  z-index: 30;
  overflow: hidden;
  color: #fff;
  background: #06101e;
  opacity: 0;
  transition: opacity 0.28s ease;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.cf.is-on {
  opacity: 1;
}

/* 溜めの間は本編を止めて隠しておく（弾けた瞬間から時計を回す） */
.cf.is-charging .cf-cam {
  visibility: hidden;
}

.cf.is-charging .cf-cam *,
.cf.is-charging .cf-cam,
.cf.is-charging .cf-wash {
  animation-play-state: paused !important;
}

/* —— 背景 —— */
.cf-wash {
  position: absolute;
  inset: 0;
  transform-origin: 50% 42%;
  animation: cfWash var(--cf-ms) linear both;
}

.cf.rar-N .cf-wash {
  background: radial-gradient(ellipse 90% 80% at 50% 40%, #5b7fa6 0%, #1e3a5f 48%, #070d18 100%);
}

.cf.rar-R .cf-wash {
  background: radial-gradient(ellipse 90% 80% at 50% 40%, #3b82f6 0%, #004899 50%, #04101f 100%);
}

.cf.rar-SR .cf-wash {
  background: radial-gradient(ellipse 90% 80% at 50% 40%, #c77dff 0%, #5b21b6 48%, #12061f 100%);
}

.cf.rar-SSR .cf-wash {
  background: radial-gradient(ellipse 90% 80% at 50% 40%, #ffe082 0%, #f5a800 26%, #8a4b00 58%, #1c1204 100%);
}

.cf.rar-SSR.is-charging .cf-wash {
  filter: brightness(0.22) saturate(0.6);
}

.cf.rar-SSR .cf-wash {
  transition: filter 0.18s ease-out;
}

@keyframes cfWash {
  from {
    transform: scale(1);
  }
  to {
    transform: scale(1.18);
  }
}

/* —— カメラ：最初の拍で強く寄って、半秒ゆさぶる —— */
.cf-cam {
  position: absolute;
  inset: 0;
  transform-origin: 50% 42%;
  animation: cfCam 0.8s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.cf.rar-SSR .cf-cam {
  animation-name: cfCamBig;
  animation-duration: 1s;
}

.cf-shake {
  position: absolute;
  inset: 0;
  animation: cfShake 0.86s 0.05s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
}

.cf.rar-N .cf-shake {
  animation-duration: 0.5s;
}

.cf-flash {
  position: absolute;
  inset: 0;
  background: #fff;
  opacity: 0;
  pointer-events: none;
  animation: cfFlash 0.44s cubic-bezier(0.2, 0, 0, 1) both;
}

.cf.rar-SSR .cf-flash {
  animation-name: cfFlashBig;
  animation-duration: 0.7s;
}

@keyframes cfCam {
  0% {
    transform: scale(1.34);
  }
  52% {
    transform: scale(0.99);
  }
  76% {
    transform: scale(1.02);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes cfCamBig {
  0% {
    transform: scale(1.6);
  }
  40% {
    transform: scale(0.97);
  }
  70% {
    transform: scale(1.03);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes cfShake {
  0% {
    transform: translate3d(0, 0, 0);
  }
  6% {
    transform: translate3d(-9px, 6px, 0) rotate(-0.9deg);
  }
  14% {
    transform: translate3d(8px, -7px, 0) rotate(0.8deg);
  }
  22% {
    transform: translate3d(-7px, -4px, 0) rotate(-0.6deg);
  }
  30% {
    transform: translate3d(6px, 5px, 0) rotate(0.5deg);
  }
  38% {
    transform: translate3d(-4px, 3px, 0) rotate(-0.32deg);
  }
  46% {
    transform: translate3d(3px, -3px, 0) rotate(0.2deg);
  }
  56% {
    transform: translate3d(-2px, 2px, 0);
  }
  66% {
    transform: translate3d(1px, -1px, 0);
  }
  76%,
  100% {
    transform: translate3d(0, 0, 0);
  }
}

@keyframes cfFlash {
  0% {
    opacity: 0.6;
  }
  30% {
    opacity: 0.2;
  }
  100% {
    opacity: 0;
  }
}

@keyframes cfFlashBig {
  0% {
    opacity: 0.95;
  }
  25% {
    opacity: 0.45;
  }
  100% {
    opacity: 0;
  }
}

/* —— 光線・スイープ —— */
.cf-rays {
  position: absolute;
  inset: -40%;
  background: repeating-linear-gradient(118deg, rgba(255, 255, 255, 0) 0 18px, rgba(255, 255, 255, 0.07) 18px 36px);
  transform-origin: 50% 50%;
  animation: cfRays 3.6s cubic-bezier(0.2, 0, 0, 1) both;
}

.cf.rar-SSR .cf-rays {
  background: repeating-conic-gradient(from 0deg at 50% 50%, rgba(255, 255, 255, 0.13) 0 6deg, rgba(255, 255, 255, 0) 6deg 18deg);
  animation: cfRaysSpin 12s linear both;
}

.cf-sweep {
  position: absolute;
  top: -20%;
  bottom: -20%;
  left: -40%;
  width: 38%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.22), transparent);
  transform: skewX(-18deg);
  animation: cfSweep 1.1s 0.18s cubic-bezier(0.2, 0, 0, 1) both;
}

@keyframes cfRays {
  0% {
    transform: rotate(-8deg) scale(1.2);
    opacity: 0;
  }
  18% {
    opacity: 1;
  }
  100% {
    transform: rotate(6deg) scale(1.05);
    opacity: 0.85;
  }
}

@keyframes cfRaysSpin {
  0% {
    transform: rotate(0) scale(1.3);
    opacity: 0;
  }
  8% {
    opacity: 1;
  }
  100% {
    transform: rotate(90deg) scale(1.1);
    opacity: 0.9;
  }
}

@keyframes cfSweep {
  0% {
    left: -50%;
    opacity: 0;
  }
  20% {
    opacity: 1;
  }
  100% {
    left: 110%;
    opacity: 0;
  }
}

/* —— 後光・衝撃波（SR 以上） —— */
.cf-halo {
  position: absolute;
  left: 50%;
  top: 40%;
  width: calc(var(--art) * 2.2);
  aspect-ratio: 1;
  margin: calc(var(--art) * -1.1) 0 0 calc(var(--art) * -1.1);
  border-radius: 50%;
  background: radial-gradient(
    circle,
    rgba(255, 246, 222, 0.4) 0%,
    rgba(255, 204, 96, 0.28) 20%,
    rgba(245, 168, 0, 0.17) 40%,
    rgba(245, 168, 0, 0.06) 58%,
    transparent 74%
  );
  animation:
    cfHaloIn 0.6s 0.05s cubic-bezier(0.16, 1, 0.3, 1) both,
    cfHaloBreath 3.4s 0.7s ease-in-out infinite;
}

.cf.rar-SR .cf-halo {
  background: radial-gradient(circle, rgba(245, 230, 255, 0.4) 0%, rgba(199, 125, 255, 0.28) 24%, rgba(140, 60, 220, 0.12) 50%, transparent 72%);
}

.cf-rings i {
  position: absolute;
  left: 50%;
  top: 40%;
  width: 120px;
  height: 120px;
  margin: -60px 0 0 -60px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.5);
  opacity: 0;
  animation: cfRing 1.1s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.cf-rings i:nth-child(1) {
  animation-delay: 0.02s;
}

.cf-rings i:nth-child(2) {
  animation-delay: 0.16s;
  border-color: color-mix(in srgb, var(--rarity) 80%, transparent);
}

.cf-rings i:nth-child(3) {
  animation-delay: 0.3s;
  border-color: rgba(255, 255, 255, 0.32);
}

@keyframes cfHaloIn {
  from {
    opacity: 0;
    transform: scale(0.4);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes cfHaloBreath {
  0%,
  100% {
    scale: 1;
    opacity: 0.9;
  }
  50% {
    scale: 1.06;
    opacity: 1;
  }
}

@keyframes cfRing {
  0% {
    opacity: 0.9;
    transform: scale(0.25);
  }
  100% {
    opacity: 0;
    transform: scale(4.6);
  }
}

/* —— ステッカー：中央から飛び出して所定の位置に貼りつく —— */
.cf-sticker {
  position: absolute;
  width: var(--w);
  height: var(--h);
  margin: calc(var(--h) / -2) 0 0 calc(var(--w) / -2);
  opacity: 0;
  animation: cfStickerPop 0.92s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.cf-sticker img {
  display: block;
  width: 100%;
  height: 100%;
  animation: cfStickerIdle 1.9s ease-in-out infinite alternate;
}

/* 波2：上から叩きつけて、ぺたっと潰れる */
.cf-sticker.w2 {
  animation: cfStickerSlap 0.5s cubic-bezier(0.2, 0, 0, 1) both;
}

/* 波3：小さいのがその場で弾けて出る */
.cf-sticker.w3 {
  animation: cfStickerSprinkle 0.55s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

@keyframes cfStickerPop {
  0% {
    opacity: 0;
    transform: translate3d(var(--fx), var(--fy), 0) scale(0.18) rotate(var(--spin)) var(--pose);
  }
  14% {
    opacity: 1;
  }
  66% {
    opacity: 1;
    transform: translate3d(0, 0, 0) scale(1.16) rotate(0deg) var(--pose);
  }
  100% {
    opacity: 1;
    transform: translate3d(0, 0, 0) scale(1) rotate(0deg) var(--pose);
  }
}

@keyframes cfStickerSlap {
  0% {
    opacity: 0;
    transform: translate3d(0, -18px, 0) scale(2.3) rotate(var(--spin)) var(--pose);
  }
  30% {
    opacity: 1;
  }
  55% {
    transform: translate3d(0, 0, 0) scale(0.86, 0.8) var(--pose);
  }
  78% {
    transform: scale(1.06) var(--pose);
  }
  100% {
    opacity: 1;
    transform: scale(1) var(--pose);
  }
}

@keyframes cfStickerSprinkle {
  0% {
    opacity: 0;
    transform: scale(0) rotate(var(--spin)) var(--pose);
  }
  40% {
    opacity: 1;
  }
  100% {
    opacity: 1;
    transform: scale(1) rotate(0deg) var(--pose);
  }
}

/* 貼ったあともゆらゆら揺れて、画面が止まって見えないようにする */
@keyframes cfStickerIdle {
  from {
    transform: rotate(-3deg) scale(1);
  }
  to {
    transform: rotate(3deg) scale(1.05);
  }
}

/* —— 紙吹雪・テープ —— */
.cf-confetti,
.cf-tape {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.cf-confetti i {
  position: absolute;
  top: -40px;
  border-radius: 1px;
  opacity: 0;
  animation-name: cfFall;
  animation-timing-function: linear;
  animation-fill-mode: both;
}

@keyframes cfFall {
  0% {
    opacity: 0;
    transform: translate3d(0, 0, 0) rotate(0);
  }
  7% {
    opacity: 1;
  }
  88% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translate3d(var(--dx, 0), 1000px, 0) rotate(var(--spin, 540deg));
  }
}

.cf-tape i {
  position: absolute;
  top: -24px;
  width: 5px;
  height: 16px;
  border-radius: 1px;
  animation: cfTape linear infinite both;
}

@keyframes cfTape {
  from {
    transform: translateY(0) rotate(0);
  }
  to {
    transform: translateY(680px) rotate(420deg);
  }
}

/* —— 中央：取った景品 —— */
.cf-center {
  position: absolute;
  left: 0;
  right: 0;
  top: 40%;
  display: flex;
  justify-content: center;
  transform: translateY(-50%);
  pointer-events: none;
  animation: cfCenter 0.72s 0.08s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.cf-art {
  position: relative;
  display: grid;
  place-items: center;
  width: var(--art);
  height: var(--art);
  animation: cfFloat 2.8s 0.9s ease-in-out infinite;
}

.cf-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 18px 34px rgba(0, 0, 0, 0.55));
}

.cf.rar-SR .cf-img,
.cf.rar-SSR .cf-img {
  filter: drop-shadow(0 14px 26px rgba(0, 0, 0, 0.55)) drop-shadow(0 0 16px color-mix(in srgb, var(--rarity) 50%, transparent))
    drop-shadow(0 0 36px color-mix(in srgb, var(--rarity) 30%, transparent));
}

.cf-emoji {
  font-size: calc(var(--art) * 0.62);
  line-height: 1;
  filter: drop-shadow(0 18px 34px rgba(0, 0, 0, 0.55));
}

.cf-badge {
  position: absolute;
  top: 10%;
  right: 4%;
  padding: 0.22em 0.55em 0.18em;
  border: 2px solid #fff;
  border-radius: 999px;
  background: var(--rarity);
  color: #14161a;
  font: italic 800 clamp(1rem, 5vh, 1.6rem) / 1 "Barlow Condensed", "Bebas Neue", sans-serif;
  letter-spacing: 0.02em;
  transform: rotate(10deg);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.4);
  animation: cfBadge 0.5s 0.42s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.cf-points {
  position: absolute;
  bottom: 4%;
  left: -14%;
  padding: 0.18em 0.5em;
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.2), rgba(255, 255, 255, 0.06));
  border: 1px solid rgba(255, 255, 255, 0.3);
  font: italic 800 clamp(1.4rem, 8vh, 2.4rem) / 1 "Barlow Condensed", sans-serif;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 6px 24px rgba(0, 0, 0, 0.4);
  animation: cfBadge 0.5s 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

@keyframes cfCenter {
  0% {
    opacity: 0;
    transform: translateY(-50%) scale(0.42) rotate(-9deg);
  }
  62% {
    opacity: 1;
    transform: translateY(-50%) scale(1.12) rotate(2deg);
  }
  100% {
    opacity: 1;
    transform: translateY(-50%) scale(1) rotate(0);
  }
}

@keyframes cfFloat {
  0%,
  100% {
    transform: translate3d(0, 0, 0) rotate(0);
  }
  50% {
    transform: translate3d(0, -10px, 0) rotate(1.2deg);
  }
}

@keyframes cfBadge {
  from {
    opacity: 0;
    scale: 0.3;
  }
  to {
    opacity: 1;
    scale: 1;
  }
}

/* —— 見出し —— */
.cf-copy {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 7%;
  padding: 0 24px;
  text-align: center;
  opacity: 0;
  animation: cfCopy var(--cf-ms) 0.12s cubic-bezier(0.2, 0, 0, 1) both;
}

.cf-kicker {
  font: 700 11px/1 "Noto Sans JP", sans-serif;
  letter-spacing: 0.24em;
  opacity: 0.85;
}

.cf-title {
  margin: 6px 0 6px;
  font: italic 800 clamp(3rem, 17vh, 5.2rem) / 0.86 "Barlow Condensed", "Bebas Neue", sans-serif;
  letter-spacing: -0.01em;
  text-shadow: 0 8px 40px rgba(0, 0, 0, 0.35);
  animation: cfSlam 0.52s 0.14s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.cf.rar-SSR .cf-title {
  background: linear-gradient(100deg, #fff6de 20%, #fff 40%, #ffd54a 55%, #fff6de 80%);
  background-size: 200% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 6px 24px rgba(120, 60, 0, 0.55));
  text-shadow: none;
  animation:
    cfSlam 0.52s 0.14s cubic-bezier(0.16, 1, 0.3, 1) both,
    cfShine 1.8s 0.7s linear infinite;
}

.cf-sub {
  font: 600 13px/1.3 "Noto Sans JP", sans-serif;
  opacity: 0.9;
}

@keyframes cfSlam {
  0% {
    opacity: 0;
    transform: scale(2);
    filter: blur(7px);
  }
  58% {
    opacity: 1;
    filter: blur(0);
    transform: scale(0.95);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes cfShine {
  from {
    background-position: 200% 0;
  }
  to {
    background-position: -200% 0;
  }
}

@keyframes cfCopy {
  0% {
    opacity: 0;
    transform: translateY(18px) scale(0.94);
    filter: blur(8px);
  }
  16% {
    opacity: 1;
    transform: none;
    filter: none;
  }
  82% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translateY(-8px);
  }
}

/* —— SSR の溜め —— */
.cf-charge {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 1rem;
  pointer-events: none;
}

.cf.is-go .cf-charge {
  animation: cfChargeOut 0.25s ease-out both;
}

.cf-charge-rays {
  position: absolute;
  inset: -50%;
  background: repeating-conic-gradient(from 0deg at 50% 50%, rgba(255, 213, 74, 0.16) 0 4deg, transparent 4deg 16deg);
  animation: cfChargeRays 0.95s cubic-bezier(0.5, 0, 0.9, 0.4) both;
}

.cf-charge-orb {
  position: relative;
  display: grid;
  place-items: center;
  width: min(26vh, 8rem);
  aspect-ratio: 1;
  border-radius: 50%;
  background: radial-gradient(circle at 38% 32%, #fff6de, #ffd54a 40%, #b36b00 100%);
  box-shadow:
    0 0 40px rgba(255, 213, 74, 0.7),
    0 0 90px rgba(255, 170, 0, 0.45);
  color: #5a3400;
  font: 900 min(12vh, 3.6rem) / 1 "Noto Sans JP", sans-serif;
  animation: cfOrb 0.95s cubic-bezier(0.5, 0, 0.9, 0.4) both;
}

.cf-charge-label {
  position: relative;
  margin: 0;
  font: italic 900 clamp(0.9rem, 4.5vh, 1.3rem) / 1 "Noto Sans JP", sans-serif;
  letter-spacing: 0.2em;
  color: #ffe9a8;
  animation: cfChargeLabel 0.95s ease-in both;
}

@keyframes cfOrb {
  0% {
    transform: scale(0.3) rotate(0);
    opacity: 0;
  }
  15% {
    opacity: 1;
  }
  30% {
    transform: scale(0.8) translate(-2px, 1px) rotate(-4deg);
  }
  45% {
    transform: scale(0.86) translate(3px, -2px) rotate(5deg);
  }
  60% {
    transform: scale(0.94) translate(-4px, 2px) rotate(-7deg);
  }
  75% {
    transform: scale(1.02) translate(5px, -3px) rotate(8deg);
  }
  90% {
    transform: scale(1.14) translate(-6px, 3px) rotate(-10deg);
  }
  100% {
    transform: scale(1.3) rotate(0);
  }
}

@keyframes cfChargeRays {
  from {
    transform: rotate(0) scale(1.6);
    opacity: 0;
  }
  to {
    transform: rotate(40deg) scale(0.9);
    opacity: 1;
  }
}

@keyframes cfChargeLabel {
  0%,
  20% {
    opacity: 0;
    letter-spacing: 0.6em;
  }
  60% {
    opacity: 1;
  }
  100% {
    opacity: 1;
    letter-spacing: 0.2em;
  }
}

@keyframes cfChargeOut {
  to {
    opacity: 0;
    transform: scale(1.6);
  }
}

/* 縦持ち：景品を上寄せ、見出しを大きく */
@media (orientation: portrait) {
  .cf {
    --art: min(34vh, 62vw, 16rem);
  }

  .cf-center,
  .cf-halo,
  .cf-rings i {
    top: 38%;
  }

  .cf-copy {
    bottom: 12%;
  }

  .cf-title {
    font-size: clamp(3.4rem, 17vw, 5rem);
  }
}

@media (prefers-reduced-motion: reduce) {
  .cf-sticker img,
  .cf-cam,
  .cf-shake,
  .cf-wash,
  .cf-flash,
  .cf-title,
  .cf-art,
  .cf-rays {
    animation: none !important;
  }

  .cf-confetti,
  .cf-tape {
    display: none;
  }
}
