/* =======================
   GLOBAL PAGE THEME
========================== */
body {
  margin: 0;
  background: repeating-linear-gradient(
      180deg,
      #dff4ff 0px,
      #dff4ff 140px,
      #eaf8ff 140px,
      #eaf8ff 280px
  );
  font-family: "Fredoka", system-ui;
  display: flex;
  justify-content: center;
  padding-top: 40px;
}

/* Wrapper */
.wrapper {
  width: 360px;
  text-align: center;
}

/* =======================
   TITLE
========================== */
.title {
  font-size: 32px;
  font-weight: 900;
  color: #b071ff;
  text-shadow: 0 2px #11b4ff;
  margin-bottom: 25px;
}

/* =======================
   SHUFFLE BUTTON
========================== */
.shuffle-btn {
  background: linear-gradient(180deg, #58c7ff, #2aa8ff);
  color: white;
  font-size: 18px;
  font-weight: 900;
  padding: 12px 26px;
  border: none;
  border-radius: 30px;
  margin-top: 20px;
  cursor: pointer;
  box-shadow: 0 4px #1b84cc;
  transition: 0.2s;
}

.shuffle-btn.hidden {
  opacity: 0;
  pointer-events: none;
}

.shuffle-btn:active {
  transform: translateY(3px);
  box-shadow: 0 1px #1b84cc;
}

.shuffle-btn:hover {
  transform: translateY(-3px);
  box-shadow:
      0 8px 18px rgba(80,180,255,0.45),
      inset 0 0 10px rgba(255,255,255,0.8);
}

/* =======================
   GRID OF CARDS
========================== */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  justify-items: center;
  position: relative;
  margin-top: 20px; /* moved down for better layout */
}

/* CARD BASE */
.card {
  width: 110px;
  height: 160px;
  position: relative;
  transform-style: preserve-3d;
  transition: transform 0.6s ease;
  cursor: pointer;
}

/* Flip animation */
.card.flip {
  transform: rotateY(180deg);
}

/* CARD FACE BASE */
.card-face {
  position: absolute;
  width: 100%;
  height: 100%;
  border-radius: 12px;
  backface-visibility: hidden;

  box-shadow:
    0 6px 16px rgba(0,0,0,0.10),
    inset 0 0 10px rgba(255,255,255,0.20);

  background-size: cover;
  background-position: center;
}

/* Card back side */
.card-back {
  background-image: url('assets/cards/card_back.svg');
}

/* Face up */
.card-front {
  transform: rotateY(180deg);
}

/* =======================
     POPUP
========================== */
.popup {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  justify-content: center;
  align-items: center;
}

.hidden {
  display: none;
}

.popup-box {
  background: #fff1f6;
  color: #ff4d7a;
  width: 80%;
  max-width: 300px;
  padding: 25px;
  border-radius: 20px;
  text-align: center;
  border: 3px solid #ffc6d2;
}

/* =======================
   SHUFFLE ANIMATIONS
========================== */

/* Simple wobble shuffle */
.card.shuffle {
  animation: shuffleMove 0.45s ease forwards;
  opacity: 0;
}

@keyframes shuffleMove {
  0% { transform: translate(0,0) scale(1) rotate(0); opacity:1; }
  25% { transform: translate(-8px,-16px) scale(0.95) rotate(-4deg); opacity:.6; }
  50% { transform: translate(10px,-10px) scale(.93) rotate(3deg); opacity:.4; }
  75% { transform: translate(-6px,-6px) scale(.97) rotate(-2deg); opacity:.7; }
  100% { transform: translate(0,0) scale(1) rotate(0); opacity:1; }
}

/* Move cards to deck center */
.card.to-center {
  position: absolute;
  left: 50%;
  top: 200px;
  transform: translate(-50%, -50%) scale(0.8);
  transition: all 0.5s ease;
  z-index: 100;
}

/* Deck shake */
@keyframes deckShake {
  0% { transform: translate(-50%,-50%) rotate(0deg); }
  25% { transform: translate(-48%,-52%) rotate(-4deg); }
  50% { transform: translate(-52%,-48%) rotate(4deg); }
  75% { transform: translate(-51%,-49%) rotate(-2deg); }
  100% { transform: translate(-50%,-50%) rotate(0deg); }
}

.deck-shake {
  animation: deckShake 0.45s ease-in-out 2;
}

/* Cards flying out from deck */
.card.fly-out {
  transition: transform 0.6s ease, opacity 0.3s;
  opacity: 0;
}

/* Shuffle background overlay */
.shuffle-stage {
  position: fixed;
  inset: 0;
  background: radial-gradient(circle, rgba(180,220,255,0.4), rgba(180,220,255,0) 70%);
  backdrop-filter: blur(3px);
  z-index: 50;
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
}

.shuffle-stage.show {
  opacity: 1;
}
/* =======================
   MAGIC SPARKLE PARTICLES
========================== */
.sparkle {
  position: fixed;
  width: 6px;
  height: 6px;
  background: radial-gradient(circle, white, rgba(255,255,255,0));
  border-radius: 50%;
  pointer-events: none;
  z-index: 200;
  opacity: 0;
  animation: sparkleFloat 1.2s ease-out forwards;
}

@keyframes sparkleFloat {
  0% {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
  50% {
    transform: translateY(-30px) scale(1.3);
    opacity: 0.8;
  }
  100% {
    transform: translateY(-60px) scale(0.8);
    opacity: 0;
  }
}
