/* =========================================================
   MEMORIA DE MOMENTOS - ESTILOS
   ========================================================= */

:root {
  --bg-gradient: radial-gradient(circle at 50% 10%, #1f1738 0%, #0d0a1a 60%, #07050d 100%);
  --card-bg-back: linear-gradient(135deg, #6366f1 0%, #ec4899 100%);
  --card-bg-front: #161226;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --primary-glow: rgba(236, 72, 153, 0.45);
  --accent-purple: #8b5cf6;
  --accent-pink: #ec4899;
  --accent-emerald: #10b981;
  --surface-panel: rgba(255, 255, 255, 0.05);
  --surface-border: rgba(255, 255, 255, 0.12);
  --radius-card: 13px;
  --radius-sm: 8px;
  --radius-full: 9999px;
  --transition-fast: 0.25s ease;
  --transition-smooth: 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

body {
  font-family: 'Plus Jakarta Sans', sans-serif;
  background: var(--bg-gradient);
  background-attachment: fixed;
  color: var(--text-main);
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 10px 8px 14px 8px;
  overflow-x: hidden;
  position: relative;
}

/* Luces de fondo decorativas */
.background-decorations {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.blob {
  position: absolute;
  filter: blur(90px);
  border-radius: 50%;
  opacity: 0.35;
  animation: floatBlobs 12s ease-in-out infinite alternate;
}

.blob-1 {
  width: 280px;
  height: 280px;
  background: #ec4899;
  top: -60px;
  left: -60px;
}

.blob-2 {
  width: 320px;
  height: 320px;
  background: #6366f1;
  bottom: 5%;
  right: -80px;
  animation-delay: -4s;
}

.blob-3 {
  width: 220px;
  height: 220px;
  background: #8b5cf6;
  top: 45%;
  left: 50%;
  transform: translate(-50%, -50%);
  opacity: 0.2;
}

@keyframes floatBlobs {
  0% { transform: translateY(0) scale(1); }
  100% { transform: translateY(25px) scale(1.1); }
}

/* Contenedor principal */
.game-container {
  width: 100%;
  max-width: 600px;
  display: flex;
  flex-direction: column;
  align-items: center;
  z-index: 1;
  gap: 10px;
  margin: auto 0;
}

/* Header */
.game-header {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  background: rgba(236, 72, 153, 0.15);
  border: 1px solid rgba(236, 72, 153, 0.35);
  border-radius: var(--radius-full);
  font-size: 0.72rem;
  font-weight: 700;
  color: #f472b6;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  backdrop-filter: blur(8px);
}

.main-title {
  font-family: 'Outfit', sans-serif;
  font-size: clamp(1.4rem, 5.5vw, 2.2rem);
  font-weight: 900;
  letter-spacing: -0.5px;
  background: linear-gradient(135deg, #ffffff 30%, #f472b6 70%, #a855f7 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  line-height: 1.15;
  text-shadow: 0 4px 20px rgba(236, 72, 153, 0.25);
}

.subtitle {
  font-size: clamp(0.72rem, 2.4vw, 0.86rem);
  color: var(--text-muted);
  max-width: 320px;
  line-height: 1.25;
}

/* Panel de estadísticas */
.stats-panel {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  background: var(--surface-panel);
  border: 1px solid var(--surface-border);
  padding: 6px 12px;
  border-radius: 14px;
  backdrop-filter: blur(12px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
}

.stat-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
}

.stat-label {
  font-size: 0.65rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 700;
}

.stat-value {
  font-family: 'Outfit', sans-serif;
  font-size: 1.05rem;
  font-weight: 800;
  color: #ffffff;
  line-height: 1.2;
}

.controls {
  display: flex;
  gap: 5px;
}

.icon-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #fff;
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 0.95rem;
  transition: all var(--transition-fast);
  touch-action: manipulation;
}

.icon-btn:hover {
  background: rgba(255, 255, 255, 0.18);
  transform: translateY(-2px);
  border-color: rgba(255, 255, 255, 0.3);
}

.icon-btn:active {
  transform: translateY(0) scale(0.94);
}

/* Tablero de Cartas: 5 columnas x 2 filas (sin scroll en móvil) */
.board-wrapper {
  width: 100%;
  display: flex;
  justify-content: center;
}

.game-board {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 7px;
  perspective: 1000px;
}

@media (max-width: 360px) {
  .game-board {
    gap: 5px;
  }
}

@media (min-width: 520px) {
  .game-board {
    gap: 12px;
  }
}

/* Tarjeta individual */
.memory-card {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1.15;
  cursor: pointer;
  transform-style: preserve-3d;
  transition: transform 0.55s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  touch-action: manipulation;
  border-radius: var(--radius-card);
}

.memory-card:active {
  transform: scale(0.97);
}

.memory-card.flipped,
.memory-card.matched {
  transform: rotateY(180deg);
}

.memory-card.matched {
  animation: matchGlow 0.8s ease-out forwards;
}

@keyframes matchGlow {
  0% {
    transform: rotateY(180deg) scale(1);
    filter: brightness(1);
  }
  40% {
    transform: rotateY(180deg) scale(1.06);
    filter: brightness(1.3);
  }
  100% {
    transform: rotateY(180deg) scale(1);
    filter: brightness(1);
  }
}

/* Caras de la tarjeta */
.card-face {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border-radius: var(--radius-card);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border: 2px solid transparent;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.35);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

/* Reverso de la tarjeta (Oculta) */
.card-back {
  background: var(--card-bg-back);
  position: relative;
  border-color: rgba(255, 255, 255, 0.2);
}

.card-back::before {
  content: '';
  position: absolute;
  inset: 2px;
  border-radius: calc(var(--radius-card) - 2px);
  border: 1px dashed rgba(255, 255, 255, 0.35);
  pointer-events: none;
}

.card-back-pattern {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
}

.card-back-icon {
  font-size: clamp(1.1rem, 3.8vw, 1.7rem);
  filter: drop-shadow(0 2px 8px rgba(0,0,0,0.3));
  animation: iconPulse 2.5s ease-in-out infinite;
}

.card-back-text {
  font-size: clamp(0.5rem, 1.8vw, 0.65rem);
  font-weight: 800;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.85);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}

@keyframes iconPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.12); }
}

/* Frente de la tarjeta (Con foto) */
.card-front {
  background: var(--card-bg-front);
  transform: rotateY(180deg);
  border-color: rgba(255, 255, 255, 0.15);
}

.card-front img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  pointer-events: none;
}

.memory-card.matched .card-front {
  border-color: var(--accent-pink);
  box-shadow: 0 0 20px var(--primary-glow);
}

/* Modal de Victoria */
.modal-backdrop {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  background: rgba(10, 7, 22, 0.82);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  opacity: 1;
  transition: opacity 0.4s ease, visibility 0.4s ease;
}

.modal-backdrop.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.modal-card {
  width: 100%;
  max-width: 400px;
  max-height: 92dvh;
  overflow-y: auto;
  background: linear-gradient(145deg, rgba(35, 26, 60, 0.95), rgba(20, 15, 36, 0.95));
  border: 1.5px solid rgba(236, 72, 153, 0.4);
  border-radius: 24px;
  padding: 22px 18px 20px 18px;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.7), 0 0 40px rgba(236, 72, 153, 0.25);
  position: relative;
  transform: scale(1);
  transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  animation: modalEnter 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes modalEnter {
  0% {
    transform: scale(0.7) translateY(30px);
    opacity: 0;
  }
  100% {
    transform: scale(1) translateY(0);
    opacity: 1;
  }
}

.modal-sparkles {
  font-size: 1.2rem;
  letter-spacing: 6px;
  margin-bottom: 2px;
}

.modal-avatar {
  width: 58px;
  height: 58px;
  margin: 0 auto 10px auto;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(236, 72, 153, 0.3) 0%, rgba(99, 102, 241, 0.1) 70%);
  border: 2px solid rgba(236, 72, 153, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
  box-shadow: 0 0 25px rgba(236, 72, 153, 0.4);
}

.heart-pulse {
  animation: heartBeat 1.2s infinite;
  display: inline-block;
}

@keyframes heartBeat {
  0%, 100% { transform: scale(1); }
  15% { transform: scale(1.25); }
  30% { transform: scale(1.05); }
  45% { transform: scale(1.2); }
}

.modal-title {
  font-family: 'Outfit', sans-serif;
  font-size: 1.2rem;
  font-weight: 700;
  color: #fbcfe8;
  margin-bottom: 4px;
}

/* El mensaje requerido */
.modal-big-message {
  font-family: 'Outfit', sans-serif;
  font-size: clamp(1.35rem, 5vw, 1.85rem);
  font-weight: 900;
  line-height: 1.15;
  background: linear-gradient(135deg, #ffffff 10%, #f472b6 50%, #c084fc 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 12px;
  text-transform: uppercase;
  letter-spacing: -0.3px;
  text-shadow: 0 4px 20px rgba(236, 72, 153, 0.35);
}

.modal-divider {
  width: 50px;
  height: 3px;
  background: linear-gradient(90deg, #ec4899, #8b5cf6);
  border-radius: var(--radius-full);
  margin: 0 auto 12px auto;
}

.modal-summary {
  display: flex;
  justify-content: center;
  gap: 16px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 8px 14px;
  border-radius: 12px;
  margin-bottom: 12px;
}

.summary-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.summary-label {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.summary-val {
  font-family: 'Outfit', sans-serif;
  font-weight: 800;
  font-size: 1.05rem;
  color: #fff;
}

.modal-note {
  font-size: 0.82rem;
  color: #cbd5e1;
  line-height: 1.4;
  margin-bottom: 16px;
}

.modal-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
}

.primary-btn {
  background: linear-gradient(135deg, #ec4899 0%, #8b5cf6 100%);
  color: #fff;
  border: none;
  border-radius: 14px;
  padding: 11px 18px;
  font-family: 'Outfit', sans-serif;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: 0 8px 24px rgba(236, 72, 153, 0.4);
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.primary-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 28px rgba(236, 72, 153, 0.55);
}

.primary-btn:active {
  transform: translateY(0) scale(0.96);
}

.btn-icon {
  font-size: 1.15rem;
}

/* Pequeños ajustes para pantallas con altura muy baja */
@media (max-height: 600px) {
  body {
    padding: 6px 8px 8px 8px;
  }
  .game-container {
    gap: 6px;
  }
  .main-title {
    font-size: 1.3rem;
  }
  .subtitle {
    display: none;
  }
  .badge {
    padding: 2px 8px;
    font-size: 0.68rem;
  }
  .stats-panel {
    padding: 4px 10px;
  }
}
