#gameBoard {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0.6rem;
  max-width: 680px;
  margin: 0 auto;
}

.card {
  aspect-ratio: 2 / 3;
  cursor: pointer;
  position: relative;
  transition: transform 0.15s ease;
}

.card:active:not(.disabled) {
  transform: scale(0.94) translateY(1px);
}

.card-face {
  width: 100%;
  height: 100%;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: absolute;
  inset: 0;
  box-shadow: 
    0 1px 2px rgba(0,0,0,0.15),
    0 3px 8px rgba(0,0,0,0.12),
    inset 0 1px 0 rgba(255,255,255,0.4);
}

/* ===== REVERSO: Baraja española ===== */
.card-front {
  background: #fffef8;
  border: 1.5px solid #c0b090;
}

.card-front .card-pattern {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(45deg, #c62828 25%, transparent 25%),
    linear-gradient(-45deg, #c62828 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #c62828 75%),
    linear-gradient(-45deg, transparent 75%, #c62828 75%);
  background-size: 14px 14px;
  background-position: 0 0, 0 7px, 7px -7px, -7px 0px;
  opacity: 0.18;
}

.card-front::before {
  content: '';
  position: absolute;
  inset: 5px;
  border: 2.5px solid #b71c1c;
  border-radius: 5px;
  z-index: 2;
  pointer-events: none;
}

.card-front .corner-tl,
.card-front .corner-br {
  position: absolute;
  width: 18px;
  height: 18px;
  z-index: 3;
  border-color: #b71c1c;
}

.card-front .corner-tl {
  top: 7px;
  left: 7px;
  border-top: 3px solid;
  border-left: 3px solid;
  border-top-left-radius: 5px;
}

.card-front .corner-br {
  bottom: 7px;
  right: 7px;
  border-bottom: 3px solid;
  border-right: 3px solid;
  border-bottom-right-radius: 5px;
}

.card-front .spade-icon {
  font-size: 2.4rem;
  z-index: 4;
  color: #b71c1c;
  text-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

/* ===== FRENTE: Celebridad ===== */
.card-back {
  background: linear-gradient(180deg, #ffffff 0%, #f8f9fa 100%);
  border: 1.5px solid #d1d5db;
}

.card-back::before {
  content: '';
  position: absolute;
  inset: 4px;
  border: 1.5px solid #e5e7eb;
  border-radius: 4px;
  pointer-events: none;
  z-index: 2;
}

.card.matched .card-back {
  border-color: #22c55e;
  box-shadow: 
    0 0 0 2px rgba(34, 197, 94, 0.4),
    0 3px 10px rgba(34, 197, 94, 0.25);
}

.card.matched .card-back::after {
  content: '✓';
  position: absolute;
  top: 5px;
  right: 8px;
  color: #22c55e;
  font-size: 1.1rem;
  font-weight: bold;
  z-index: 5;
}

/* Icono SVG o emoji */
.card-back .card-icon,
.card-back .emoji {
  width: 40px;
  height: 40px;
  margin-bottom: 4px;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: center;
}

.card-back .card-icon svg {
  width: 100%;
  height: 100%;
  display: block;
}

.card-back .name {
  font-size: 0.6rem;
  font-weight: 700;
  text-align: center;
  padding: 0 6px;
  line-height: 1.25;
  z-index: 3;
}

.card.disabled {
  pointer-events: none;
}

/* ===== Animaciones ===== */
@keyframes dealIn {
  0% { opacity: 0; transform: translateY(-30px) rotate(-5deg) scale(0.7); }
  70% { transform: translateY(4px) rotate(1deg) scale(1.02); }
  100% { opacity: 1; transform: translateY(0) rotate(0) scale(1); }
}

.card {
  animation: dealIn 0.5s ease-out backwards;
}

@keyframes flipReveal {
  0% { transform: scaleX(1) scaleY(1); }
  40% { transform: scaleX(0.05) scaleY(1.05); }
  100% { transform: scaleX(1) scaleY(1); }
}

.card.flipped {
  animation: flipReveal 0.4s ease-in-out;
}

@keyframes shake {
  0%, 100% { transform: translateX(0) rotate(0); }
  20% { transform: translateX(-7px) rotate(-3deg); }
  40% { transform: translateX(7px) rotate(3deg); }
  60% { transform: translateX(-4px) rotate(-2deg); }
  80% { transform: translateX(4px) rotate(2deg); }
}

.card.mismatch {
  animation: shake 0.5s ease-in-out;
}

@keyframes matchPop {
  0% { transform: scale(1); }
  40% { transform: scale(1.12); }
  100% { transform: scale(1); }
}

.card.matched {
  animation: matchPop 0.35s ease-out;
}

@media (max-width: 640px) {
  #gameBoard {
    grid-template-columns: repeat(4, 1fr);
    gap: 0.4rem;
  }
  .card-back .card-icon,
  .card-back .emoji {
    width: 32px;
    height: 32px;
  }
  .card-back .name {
    font-size: 0.5rem;
  }
  .card-front .spade-icon {
    font-size: 1.8rem;
  }
  .card-front::before {
    inset: 3px;
    border-width: 2px;
  }
}
