.turn.cards {
  width: 100%;
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow-x: hidden;
  /* border: 1px solid white; */
}
.turn.cards .in {
  width: fit-content;
  margin: auto;
  display: grid;
  grid-template-columns: repeat(var(--perRow), max-content);
  gap: var(--gap, 10px);

  justify-content: center; /* ✅ important */
  place-content: center;
}

/* .turn.cards .enter-wrap {
  flex: 0 0
    calc((100% - (var(--perRow) - 1) * var(--gap, 10px)) / var(--perRow));
  display: flex;
  justify-content: center;
} */

.turn.cards .flip {
  position: relative;
  flex: 0 0 135px;
  height: 180px;
  perspective: 1000px;
  cursor: pointer;
  /* border:1px solid gray */
}

.turn.cards .flip-inner {
  position: relative;
  width: 135px;
  height: 180px;
  transform-style: preserve-3d;
  transition:
    transform 0.6s,
    box-shadow 0.3s ease;
  will-change: transform, box-shadow;
}

.turn.cards .flip.flipped .flip-inner {
  transform: rotateY(180deg);
}

.turn.cards .flip-front,
.turn.cards .flip-back {
  position: absolute;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
  border-radius: 10px;
  overflow: visible;
}

.turn.cards .flip-front img,
.turn.cards .flip-back img {
  width: 160px;
  height: 180px;
  max-height: 100%;
  border-radius: 10px;
  /* object-fit: cover; */
}

.turn.cards .flip-back {
  transform: rotateY(180deg);
}
.card-image-wrapper {
  position: relative;
  display: inline-block;
  overflow: hidden;
  border-radius: 12px;
}

/* --- Foil rainbow shimmer overlay (from the site) --- */
.card-image-wrapper::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  background: repeating-linear-gradient(
    90deg,
    rgba(255, 0, 255, 0.3) 0%,
    rgba(0, 255, 255, 0.3) 10%,
    rgba(255, 255, 0, 0.3) 20%,
    rgba(255, 0, 255, 0.3) 30%,
    rgba(0, 0, 255, 0.3) 40%,
    rgba(255, 0, 255, 0.3) 50%
  );
  background-size: 300% 300%;
  mix-blend-mode: screen;
  opacity: 0.9;
  transition: background-position 0.05s linear;
  filter: brightness(1.3) contrast(1.2);
  z-index: 2;
}

/* --- Card image style --- */
.card-img {
  width: 100%;
  height: auto;
  display: block;
  /* object-fit: cover; */
  transition: transform 0.3s ease;
}

/* --- Optional hover zoom --- */
.card-image-wrapper:hover .card-img {
  transform: scale(1.03);
}

@keyframes foilMove {
  0% {
    background-position: 0% 50%;
  }
  100% {
    background-position: 100% 50%;
  }
}

.card-image-wrapper::after {
  animation: foilMove 6s linear infinite;
}

@media (min-width: 1299px) {
  .turn.cards .in {
    width: 1024px;
    gap: 15px;
  }
  .turn.cards .flip-inner {
    width: 155px;
    height: 205px;
  }
  .turn.cards .flip {
    flex: 0 0 155px;
    height: 205px;
  }
  .turn.cards .flip-front img,
  .turn.cards .flip-back img {
    width: 155px;
    height: 205px;
  }
}
@media (min-width: 1919px) {
  .turn.cards .in {
    width: 1360px;
    gap: 15px;
  }
  .turn.cards .flip-inner {
    width: 180px;
    height: 250px;
  }
  .turn.cards .flip {
    flex: 0 0 180px;
    height: 250px;
  }
  .turn.cards .flip-front img,
  .turn.cards .flip-back img {
    width: 180px;
    height: 250px;
  }
}
@media (min-width: 2599px) {
  .turn.cards .in {
    width: 1800px;
    gap: 30px;
  }
  .turn.cards .flip-inner {
    width: 260px;
    height: 360px;
  }
  .turn.cards .flip {
    flex: 0 0 260px;
    height: 360px;
  }
  .turn.cards .flip-front img,
  .turn.cards .flip-back img {
    width: 300px;
    height: 400px;
  }
}

@keyframes floatY {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-10px);
  }
}

.float-y {
  animation: floatY 2.8s ease-in-out infinite;
  will-change: transform;
}

@keyframes floatArc {
  0%,
  100% {
    transform: translateY(calc(var(--arcY) + 0px))
      rotateZ(calc(var(--tilt) + 0.8deg));
  }
  50% {
    transform: translateY(calc(var(--arcY) + 4px))
      rotateZ(calc(var(--tilt) - 0.4deg));
  }
}

.turn.cards .float-wrap {
  transform: translateY(var(--arcY));
  animation: floatArc 2s ease-in-out infinite;
  animation-delay: var(--delay);
  will-change: transform;
}

/* ===== Glow behind each card ===== */
.turn.cards .flip {
  position: relative;
  border-radius: 14px;
}

.turn.cards .flip::before {
  content: "";
  position: absolute;
  inset: -40px;
  border-radius: 18px;

  filter: blur(9px);
  opacity: 0.35;

  transition:
    opacity 0.25s ease,
    transform 0.25s ease;
  z-index: 0;
  pointer-events: none;
}

.turn.cards .flip:hover::before {
  /*   opacity: 0.75;
  transform: scale(1.015);
  background: radial-gradient(
    circle at 50% 40%,
    rgba(80, 80, 255, 0.55),
    rgba(60, 60, 220, 0.35) 45%,
    transparent 50%
  ); */
}

/* Make actual card appear above the glow */
.turn.cards .flip-inner,
.turn.cards .float-wrap {
  position: relative;
  z-index: 1;
}

/* ===== Last card blinking glow ===== */
/* @keyframes lastGlow {
  0% {
    box-shadow:
      0 0 4px rgba(255, 190, 60, 0.45),
      0 0 8px rgba(255, 160, 40, 0.3);
  }

  50% {
    box-shadow:
      0 0 18px rgba(255, 190, 60, 0.85),
      0 0 18px rgba(255, 160, 40, 0.85);
  }

  100% {
    box-shadow:
      0 0 4px rgba(255, 190, 60, 0.45),
      0 0 8px rgba(255, 160, 40, 0.3);
  }
} */
@keyframes lastGlow {
  0% {
    filter:
      drop-shadow(0 0 2px rgba(255, 190, 60, 0.35))
      drop-shadow(0 0 6px rgba(255, 160, 40, 0.25));
  }
  50% {
    filter:
      drop-shadow(0 0 6px rgba(255, 190, 60, 0.75))
      drop-shadow(0 0 10px rgba(255, 160, 40, 0.55));
  }
  100% {
    filter:
      drop-shadow(0 0 2px rgba(255, 190, 60, 0.35))
      drop-shadow(0 0 6px rgba(255, 160, 40, 0.25));
  }
}

.last-glow {
  animation: lastGlow 2.5s ease-in-out infinite;
}

.turn.cards .flip-front.is-last {
  animation: lastGlow 2.5s ease-in-out infinite;
  border-radius: 10px;
  background: transparent !important;
}

.turn.cards .flip.flipped::before {
  opacity: 0;
  transform: scale(1);
}

.yellow-bg {
  background-color: rgba(255, 190, 60, 0.95);
}

/* .turn.cards .flip.last-locked {
  pointer-events: none;
  opacity: 0.7;
  filter: grayscale(0.2);
} */

@keyframes totalShake {
  0% {
    transform: translateX(0);
  }
  15% {
    transform: translateX(-6px);
  }
  30% {
    transform: translateX(6px);
  }
  45% {
    transform: translateX(-5px);
  }
  60% {
    transform: translateX(5px);
  }
  75% {
    transform: translateX(-3px);
  }
  100% {
    transform: translateX(0);
  }
}

.total-shake {
  animation: totalShake 0.5s ease-in-out;
}

/* highlight/glow */
.total-glow {
  box-shadow:
    0 0 0 2px rgba(255, 230, 0, 0.6),
    0 0 18px rgba(255, 230, 0, 0.35);
  filter: brightness(1.08);
}

@keyframes lastCardShake {
  0% {
    transform: translateX(0) scale(1);
  }
  10% {
    transform: translateX(-6px) scale(1.02);
  }
  20% {
    transform: translateX(6px) scale(1.02);
  }
  30% {
    transform: translateX(-7px) scale(1.03);
  }
  40% {
    transform: translateX(7px) scale(1.03);
  }
  50% {
    transform: translateX(-6px) scale(1.02);
  }
  60% {
    transform: translateX(6px) scale(1.02);
  }
  70% {
    transform: translateX(-4px) scale(1.01);
  }
  80% {
    transform: translateX(4px) scale(1.01);
  }
  100% {
    transform: translateX(0) scale(1);
  }
}

.last-shake {
  animation: lastCardShake 0.45s ease-in-out;
}
