/* 🎨 MEMORIA ARTÍSTICA UNIFICADA - Diseño Neumórfico */

.unified-memory-game {
  max-width: 100%;
  margin: 0 auto;
  /* Padding optimizado para maximizar espacio de tarjetas */
  padding: 0.6rem 0.5rem 0.8rem 0.5rem;
  /* Fondo neumórfico sutil en lugar de gradiente fuerte */
  background: var(--neuo-base, #e8ecef);
  border-radius: 20px;
  box-shadow:
    12px 12px 24px rgba(163, 177, 198, 0.6),
    -12px -12px 24px rgba(255, 255, 255, 0.8);
  position: relative;
  /* Evitar desbordamiento horizontal */
  overflow-x: hidden;
}

/* Header Simplificado - ULTRA COMPACTO */
.memory-header-simple {
  text-align: center;
  margin-bottom: 0.5rem;
  position: relative; /* Para posicionar el botón de ayuda */
}

.memory-header-simple h2 {
  font-family: 'Playfair Display', serif;
  font-size: 1.3rem;
  color: var(--gray-900, #2d3748);
  margin: 0 0 0.4rem 0;
  text-shadow: 1px 1px 2px rgba(255, 255, 255, 0.8);
  font-weight: 600;
}

/* Barra de Estadísticas - ULTRA COMPACTA CON NEUMORPHISM */
.memory-stats-bar {
  display: flex;
  justify-content: center;
  gap: 1rem;
  background: var(--neuo-base, #e8ecef);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  border-radius: 12px;
  padding: 0.5rem 1rem;
  box-shadow:
    inset 4px 4px 8px rgba(163, 177, 198, 0.4),
    inset -4px -4px 8px rgba(255, 255, 255, 0.8);
}

.stat-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.1rem;
  min-width: 50px;
}

.stat-label {
  font-size: 0.6rem;
  color: rgba(255, 255, 255, 0.7);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  font-weight: 600;
}

.stat-value {
  font-size: 1.2rem;
  color: #fff;
  font-weight: 700;
  font-family: 'Inter', sans-serif;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

/* Tablero de Cartas - OPTIMIZADO PARA ESPACIO */
.memory-board-container {
  margin: 0.5rem 0 0.8rem 0;
  width: 100%;
  display: flex;
  justify-content: center;
  overflow-x: hidden; /* Prevenir scroll horizontal */
}

.memory-board {
  display: grid;
  /* Layout dinámico adaptativo */
  --um-card-size: 200px; /* valor inicial antes de cálculo JS */
  grid-template-columns: repeat(4, 1fr);
  gap: 1px; /* Gap mínimo por defecto (móvil) */
  perspective: 1100px;
  margin: 0 auto;
  align-content: start;
  max-width: 880px;
  box-sizing: border-box; /* Incluir padding y border en el cálculo del ancho */
}
/* Tablets: mantener 4 columnas */
@media (max-width: 880px){
  .memory-board {
    max-width: 760px;
    gap: 10px;
  }
}
@media (max-width: 720px){
  .memory-board {
    max-width: 100%;
    gap: 8px;
  }
}

/* === Modal Zoom Obra === */
.um-zoom-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.85);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  display: flex;
/*
  Tablero Memoria (control base):
  - Mantener 4 columnas x 5 filas visibles junto al sidebar.
  - El ancho total vuelve a un valor moderado (<= 900px) para no empujar el sidebar fuera.
  - El tamaño de cada carta lo calculará JS dinámicamente y asignará --um-card-size.
*/
  --um-card-size: 200px; /* valor inicial; luego JS recalcula */
  grid-template-columns: repeat(4, var(--um-card-size));
  gap: 0.4rem; /* compacto pero legible */
  perspective: 1100px;
  max-width: 880px; /* ancho moderado que permite coexistir con sidebar */
  margin: 0 auto;
  align-content: start;
  max-height: 90vh;
/* Breakpoints mínimos: reducimos la carta suavemente en pantallas estrechas */
@media (max-width:1100px){ .memory-board { max-width: 820px; } }
@media (max-width:980px){ .memory-board { max-width: 760px; } }
@media (max-width:900px){ .memory-board { max-width: 700px; } }
@media (max-width:820px){ .memory-board { max-width: 640px; } }
@media (max-width:740px){ .memory-board { max-width: 580px; } }
@media (max-width:680px){ .memory-board { max-width: 520px; } }
@media (max-width:620px){ .memory-board { max-width: 480px; } }
@media (max-width:560px){ .memory-board { max-width: 440px; } }
@media (max-width:500px){ .memory-board { max-width: 400px; } }
@media (max-width:460px){ .memory-board { max-width: 370px; } }
@media (max-width:430px){ .memory-board { max-width: 340px; } }
@media (max-width:400px){ .memory-board { max-width: 310px; } }
  position: relative;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 12px 40px rgba(0,0,0,0.5);
  background:#111;
}
.um-zoom-content img { width: 100%; height: 100%; object-fit: contain; display:block; }
.um-zoom-meta {
  position: absolute;
  left:0; right:0; bottom:0;
  background: linear-gradient(to top, rgba(0,0,0,0.7), rgba(0,0,0,0));
  color:#fff;
  padding:.75rem 1rem 1rem;
  font-size:.85rem;
  line-height:1.3;
  font-family:'Inter',sans-serif;
}
.um-zoom-close {
  position: absolute;
  top:8px; right:8px;
  width: 42px; height:42px;
  border-radius:50%;
  background:rgba(255,255,255,0.15);
  border:2px solid rgba(255,255,255,0.35);
  color:#fff;
  font-size:1.3rem;
  cursor:pointer;
  display:flex; align-items:center; justify-content:center;
  transition: background .25s ease, transform .25s ease;
}
.um-zoom-close:hover { background:rgba(255,255,255,0.25); transform:scale(1.08); }
.um-zoom-close:active { transform:scale(.92); }
@media (max-width:640px){
  .um-zoom-content { max-width: 96vw; }
  .um-zoom-meta { font-size:.75rem; padding:.6rem .75rem .75rem; }
  .um-zoom-close { width:38px; height:38px; }
}

/* Carta de Memoria - MÁS GRANDE */
.memory-card {
  aspect-ratio: 1/1; /* fuerza cuadrado verdadero */
  cursor: pointer;
  position: relative;
  transition: transform 0.3s ease;
  background: rgba(255,255,255,0.08); /* fallback visible */
  border: 2.5px solid rgba(255, 215, 0, 0.5); /* Borde dorado más visible por defecto */
  border-radius: 18px; /* puntas un poco más suaves y visibles */
  overflow:hidden; /* asegura que contenido interno no desborde y mantenga forma exacta */
  box-shadow:
    0 4px 10px rgba(0, 0, 0, 0.25),
    inset 0 1px 3px rgba(255, 255, 255, 0.3);
  box-sizing: border-box; /* Incluir border en el cálculo del tamaño */
}

.memory-card:hover:not(.matched):not(.selected) {
  transform: translateY(-4px) scale(1.03);
}

.memory-card:active:not(.matched):not(.selected) {
  transform: translateY(-2px) scale(1.01);
}

/* Carta seleccionada (borde destacado) */
.memory-card.selected .card-front {
  border: 5px solid #FFD700;
  box-shadow: 0 0 20px rgba(255, 215, 0, 0.8), 0 4px 12px rgba(0, 0, 0, 0.2);
  animation: pulse-border 0.6s ease-in-out infinite;
}

@keyframes pulse-border {
  0%, 100% {
    box-shadow: 0 0 20px rgba(255, 215, 0, 0.8), 0 4px 12px rgba(0, 0, 0, 0.2);
  }
  50% {
    box-shadow: 0 0 30px rgba(255, 215, 0, 1), 0 6px 16px rgba(0, 0, 0, 0.3);
  }
}

.card-inner {
  position: relative;
  width: 100%;
  height: 100%;
  /* Giro más lento para contemplación */
  transition: transform 1.85s ease-out;
  transform-style: preserve-3d;
  will-change:transform;
}

.memory-card.flipped .card-inner {
  transform: rotateY(180deg);
  /* Duración simétrica */
  transition: transform 1.85s ease-in;
}

.card-back, .card-front {
  position: absolute;
  width: 100%;
  height: 100%;
  -webkit-backface-visibility: hidden; /* Safari */
  backface-visibility: hidden;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  top:0;
  left:0;
  transform-origin:center center;
}

/* Reverso de la carta - Diseño Pro VISIBLE */
.card-back {
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%),
    linear-gradient(225deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%),
    linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%),
    linear-gradient(315deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%),
    linear-gradient(135deg, #ff6b6b 0%, #f06595 50%, #cc5de8 100%);
  background-size: 30px 30px, 30px 30px, 30px 30px, 30px 30px, 100% 100%;
  background-position: 0 0, 15px 0, 15px -15px, 0 15px, 0 0;
  color: #fff;
  font-size: 3.5rem;
  border: 4px solid rgba(255, 215, 0, 0.7); /* Borde dorado más visible */
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  box-shadow:
    0 10px 30px rgba(255, 107, 107, 0.5),
    0 0 0 1px rgba(255, 215, 0, 0.3); /* Resplandor dorado sutil */
  transition: all 0.3s ease;
  /* Fallback color si gradientes tardan */
  background-color:#d354a5;
}

.card-back::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 120%;
  height: 120%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.1) 0%, transparent 70%);
  transform: translate(-50%, -50%);
  animation: pulse 2s ease-in-out infinite;
}

.card-back::after {
  content: '✨';
  position: absolute;
  top: 10px;
  right: 10px;
  font-size: 1rem;
  opacity: 0.6;
  animation: twinkle 1.5s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% {
    opacity: 0.3;
  }
  50% {
    opacity: 0.6;
  }
}

@keyframes twinkle {
  0%, 100% {
    opacity: 0.3;
    transform: scale(1);
  }
  50% {
    opacity: 0.8;
    transform: scale(1.2);
  }
}

/* Frente de la carta */
.card-front {
  background: #fff;
  /* IMPORTANTE: El frente debe estar pre-rotado 180deg para que cuando
     el contenedor gire, quede en la orientación correcta */
  transform: rotateY(180deg);
  overflow: hidden;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
}

/* Ajuste: ya no invertimos el contenido; solo aseguramos dimensiones */
.card-front > * {
  width: 100%;
  height: 100%;
  display: block;
}

.card-front img {
  display: block !important;
  width: 100% !important;
  height: 100% !important;
  object-fit: cover !important;
}

/* Soporte extra Safari / WebKit para evitar ver reverso transparente */
@supports (-webkit-appearance: none) {
  .memory-card { -webkit-transform-style: preserve-3d; transform-style: preserve-3d; }
  .card-inner { -webkit-transform-style: preserve-3d; transform-style: preserve-3d; }
  .card-back, .card-front { -webkit-backface-visibility: hidden; backface-visibility: hidden; }
}

/* Fix adicional: asegurar que imágenes nunca se volteen accidentalmente */
.card-front img { -webkit-backface-visibility: hidden; backface-visibility: hidden; }

/* PRE-ROTACIÓN: card-front empieza volteado para compensar el flip del container */
.card-front {
  transform: rotateY(180deg);
}

/* Reemplazo de opacity por visibility para evitar salto */
.card-front[data-revealed="false"] { visibility:hidden; }
.memory-card.flipped .card-front { visibility:visible !important; }

/* Carta emparejada */
.memory-card.matched .card-inner {
  /* MANTENER el flip en 180deg para que el frente quede visible */
  transform: rotateY(180deg) scale(0.98);
  opacity: 0.85;
  pointer-events: none;
}

.memory-card.matched .card-front {
  background: linear-gradient(135deg, #a8edea 0%, #fed6e3 100%);
  border: 3px solid #4caf50;
  /* ELIMINAR filter brightness que oscurecía */
  filter: none;
  box-shadow: 0 0 20px rgba(76, 175, 80, 0.5);
}

/* ✅ Con la pre-rotación de .card-front, el texto ya se ve correctamente */

/* 🖼️ Overlay educativo de obras de arte - OCULTO por defecto en juego normal */
.artwork-edu-overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.85) 0%, rgba(0, 0, 0, 0.6) 70%, transparent 100%);
  padding: 0.5rem 0.6rem;
  transform: translateY(100%);
  opacity: 0;
  transition: all 0.3s ease;
  pointer-events: none;
}

.overlay-title {
  font-size: 0.75rem;
  font-weight: 700;
  color: #fff;
  margin-bottom: 0.15rem;
  line-height: 1.2;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
}

.overlay-segment {
  font-size: 0.6rem;
  color: rgba(255, 255, 255, 0.9);
  font-weight: 500;
  line-height: 1.2;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
}

/* Mostrar overlay SOLO en modo preview (cuando el botón "Overlay" o "Vista previa" esté activo) */
.memory-card.preview-open .artwork-edu-overlay,
.memory-card:hover .artwork-edu-overlay {
  transform: translateY(0);
  opacity: 1;
}

/* 🎨 CARTA DE PREGUNTA DE COLOR - Diseño SIMPLE: Círculos lado a lado */
.color-question-card {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.8rem;
  height: 100%;
  background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
  position: relative;
  overflow: hidden;
}

.color-question-card .color-circle-simple {
  width: 28%;
  aspect-ratio: 1/1;
  max-width: 100px;
  border-radius: 50%;
  box-shadow: 0 6px 18px rgba(0,0,0,.25), inset 0 3px 12px rgba(255,255,255,.3);
  position: relative;
  flex-shrink: 1;
}

.color-question-card .color-circle-simple::after {
  content: '';
  position: absolute;
  top: 15%;
  left: 20%;
  width: 40%;
  height: 40%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.5) 0%, transparent 70%);
  border-radius: 50%;
}

.color-question-card .operator-simple {
  font-size: 2.5rem;
  font-weight: 900;
  color: #333;
  font-family: 'Inter', sans-serif;
  text-shadow: 0 2px 8px rgba(0,0,0,.1);
  flex-shrink: 0;
  line-height: 1;
}

/* --- Accesibilidad: clase para contenido sólo para lectores de pantalla --- */
.card-back {
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%),
    linear-gradient(225deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%),
    linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%),
    linear-gradient(315deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%),
    linear-gradient(135deg, #ff6b6b 0%, #f06595 50%, #cc5de8 100%);
  background-size: 30px 30px, 30px 30px, 30px 30px, 30px 30px, 100% 100%;
  background-position: 0 0, 15px 0, 15px -15px, 0 15px, 0 0;
  color: #fff;
  font-size: 3.5rem;
  border: 4px solid rgba(255, 255, 255, 0.6);
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  box-shadow: 0 10px 30px rgba(255, 107, 107, 0.5);
  transition: all 0.3s ease;
  /* Fallback color si gradientes tardan */
  background-color:#d354a5;
  transform: rotateY(180deg); /* ahora solo se rota el reverso */
}
.color-bisect-wrapper::after {
  content:'';
  position:absolute;
  left:0; top:0; right:0; bottom:0;
  background:radial-gradient(circle at 50% 50%, rgba(255,255,255,.55), rgba(255,255,255,0) 55%),
             linear-gradient(90deg, rgba(0,0,0,.25), rgba(0,0,0,0) 35%, rgba(0,0,0,0) 65%, rgba(0,0,0,.25));
  mix-blend-mode: screen;
  pointer-events:none;
  opacity:.35;
  transition:opacity .9s ease;
}

.memory-card.flipped .color-bisect-wrapper::after { opacity:.15; }

/* Animación de entrada para segmentos */
.color-segment, .color-trisegment {
  animation: segIntro .7s ease both;
}
.color-segment.segment-right { animation-delay:.08s; }
.color-trisegment.tri-b { animation-delay:.06s; }
.color-trisegment.tri-c { animation-delay:.12s; }

@keyframes segIntro {
  0% { opacity:0; transform:scale(1.08); filter:blur(6px); }
  55% { opacity:1; }
  100% { opacity:1; transform:scale(1); filter:blur(0); }
}

/* Pulso leve al completar flip */
.memory-card.flipped .color-bisect-wrapper, .memory-card.flipped .color-trisect-wrapper {
  animation: mixPulse 1.2s ease 0.15s both;
}
@keyframes mixPulse {
  0% { transform:scale(1); }
  25% { transform:scale(1.015); }
  60% { transform:scale(0.998); }
  100% { transform:scale(1); }
}
.color-segment {
  position:relative;
  background: var(--seg-color);
  display:flex;
  align-items:center;
  justify-content:center;
  isolation:isolate;
}
.color-segment::after {
  content:'';
  position:absolute;
  inset:0;
  background:linear-gradient(145deg,rgba(255,255,255,.35),rgba(255,255,255,0) 60%);
  mix-blend-mode:screen;
  pointer-events:none;
}
.color-seg-operator {
  width:70px;
  height:70px;
  display:flex;
  align-items:center;
  justify-content:center;
  font-size:3.2rem;
  font-weight:900;
  font-family:'Inter',sans-serif;
  color:#222;
  background:rgba(255,255,255,.85);
  box-shadow:0 4px 14px rgba(0,0,0,.25);
  -webkit-backdrop-filter:blur(4px);
  backdrop-filter:blur(4px);
  border-radius:50%;
  margin: auto .5rem;
  outline:3px solid rgba(255,255,255,.55);
}
.color-two-mix-card .color-mix-inline {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .8rem;
  position: relative;
  width: 100%;
  padding: .5rem .8rem;
}
.color-two-mix-card .color-circle {
  flex:1 1 0;
  aspect-ratio: 1 / 1;
  height: auto;
  min-height: 80px;
  border-radius: 20px;
  box-shadow: inset 0 6px 18px rgba(0,0,0,.18),0 4px 10px rgba(0,0,0,.25);
  position: relative;
  overflow: hidden;
}
.color-two-mix-card .color-circle::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(145deg, rgba(255,255,255,.35), rgba(255,255,255,0) 60%);
  mix-blend-mode: screen;
  pointer-events: none;
}
.color-two-mix-card .color-mix-inline::after {
  content: '';
  position: absolute;
  inset: 0;
  border: 2px dashed rgba(0,0,0,0.04);
  border-radius: 22px;
  pointer-events: none;
}
.color-two-mix-card .color-labels-inline {
  display: flex;
  justify-content: space-around;
  width: 100%;
  font-size: .55rem;
  letter-spacing: .5px;
  font-weight: 600;
  opacity: .55;
  margin-top: .2rem;
  text-transform: uppercase;
}
.mix-op-small {
  font-size: 3rem;
  font-weight: 800;
  color: #222;
  text-shadow: 0 2px 6px rgba(0,0,0,.15);
  font-family: 'Inter', sans-serif;
  background: rgba(255,255,255,0.75);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  padding: .4rem 1.1rem .5rem;
  border-radius: 16px;
  box-shadow:0 3px 10px rgba(0,0,0,.15);
}

/* --- Nuevo layout mezcla triple (A) --- */
.color-triple-mix-card .color-triple-mix-row {
  display: grid;
  grid-template-columns: 1fr auto 1fr auto 1fr;
  align-items: center;
  gap: .5rem;
  padding: .5rem .6rem;
  width: 100%;
  position: relative;
}

/* --- Nuevo layout mezcla triple (trisect) --- */
.color-trisect { padding:0 !important; }
.color-trisect-wrapper {
  display:grid;
  grid-template-columns: 1fr 1fr 1fr;
  width:100%;
  height:100%;
  border-radius:20px;
  overflow:hidden;
  position:relative;
}
.color-trisegment { position:relative; background:var(--seg-color); }
.color-trisegment::after {
  content:''; position:absolute; inset:0; background:radial-gradient(circle at 35% 25%,rgba(255,255,255,.45),rgba(255,255,255,0) 60%); mix-blend-mode:screen; pointer-events:none;
}
.color-trisect-wrapper::before, .color-trisect-wrapper::after {
  content:''; position:absolute; top:0; bottom:0; width:2px; background:rgba(255,255,255,.4); z-index:10; pointer-events:none;
}
.color-trisect-wrapper::before { left:33.333%; }
.color-trisect-wrapper::after { left:66.666%; }

.color-triple-mix-card.color-trisect .color-labels { display:block; font-size:.55rem; letter-spacing:.5px; font-weight:600; opacity:.55; margin-top:.25rem; }

@media (max-width: 640px){
  .color-seg-operator { width:58px; height:58px; font-size:2.6rem; }
  .color-trisect-wrapper::before, .color-trisect-wrapper::after { background:rgba(255,255,255,.3); }
}
.color-triple-mix-card .color-circle {
  width: 100%;
  aspect-ratio: 1 / 1;
  min-height: 60px;
  border-radius: 20px;
  box-shadow: inset 0 6px 18px rgba(0,0,0,.18),0 4px 10px rgba(0,0,0,.25);
  position: relative;
}
.color-triple-mix-card .mix-op-small {
  font-size: 2.4rem;
  padding: .4rem .9rem .5rem;
}
.color-triple-mix-card .color-labels {
  display: block;
  font-size: .65rem;
  letter-spacing: .5px;
  font-weight: 600;
  opacity: .6;
  margin-top: .1rem;
}

/* Ajustes responsive para layouts de mezcla */
@media (max-width: 640px) {
  .color-two-mix-card .color-circle { aspect-ratio: 1 / 1; min-height: 65px; }
  .color-two-mix-card .mix-op-small { font-size: 2.4rem; }
  .color-triple-mix-card .mix-op-small { font-size: 2rem; }
  .color-triple-mix-card .color-circle { aspect-ratio: 1 / 1; min-height: 50px; }
  .emoji-grid { font-size: 2.5rem; }
  .shapes-display { font-size: 3rem; }
  .pattern-item { font-size: 2.8rem; }
}

.color-mix-display {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .25rem;
  width: 100%;
  height: 100%;
}

.color-circle {
  flex:1 1 0;
  height: 100%;
  min-height:100%;
  border: none;
  border-radius: 12px;
  box-shadow: inset 0 4px 12px rgba(0, 0, 0, 0.15),0 2px 6px rgba(0,0,0,.15);
  position: relative;
  overflow:hidden;
}

.color-circle:first-child { outline:2px solid rgba(255,255,255,.35); }

.color-circle::after {
  content: '';
  position: absolute;
  top: 15%;
  left: 25%;
  width: 35%;
  height: 35%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.4) 0%, transparent 70%);
  border-radius: 50%;
}

.mix-operator {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 4.5rem;
  font-weight: 900;
  color: #ffffff;
  text-shadow:0 3px 10px rgba(0,0,0,.4),0 0 22px rgba(0,0,0,.35);
  font-family: 'Inter', sans-serif;
  z-index: 12;
  background: rgba(0,0,0,.25);
  width: 90px;
  height: 90px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  box-shadow:0 4px 14px rgba(0,0,0,.35);
}

.color-labels {
  display: none;
}

/* 🎨 CARTA DE RESPUESTA DE COLOR - CÍRCULO GRANDE SIMPLE */
.color-answer-card {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  padding: 1.2rem;
  background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
  position: relative;
  overflow: hidden;
}

.color-result {
  width: 65%;
  aspect-ratio: 1/1;
  max-width: 140px;
  border-radius: 50%;
  border: none;
  box-shadow: 0 8px 24px rgba(0,0,0,.3), inset 0 4px 16px rgba(255,255,255,.35);
  position: relative;
}

.color-result::after {
  content: '';
  position: absolute;
  top: 15%;
  left: 20%;
  width: 40%;
  height: 40%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.6) 0%, transparent 70%);
  border-radius: 50%;
}

/* Borde degradado dinámico para resultados que tienen colores origen */
.color-result.result-has-source {
  position: relative;
  isolation: isolate;
}
.color-result.enhanced-result { animation: resultIntro .55s ease both; }
@keyframes resultIntro {
  0% { opacity:0; transform:scale(1.06); filter:blur(6px); }
  60% { opacity:1; }
  100% { opacity:1; transform:scale(1); filter:blur(0); }
}
.color-result.result-has-source::before {
  content: '';
  position: absolute;
  inset: 0;
  padding: 4px; /* grosor borde */
  border-radius: 8px;
  background: var(--result-gradient, linear-gradient(135deg,#fff,#eee));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
  z-index: 2;
}

/* Generar gradiente vía atributo (hasta 3 colores) */
[data-source-colors] { --result-colors: attr(data-source-colors); }

/* Fallback JS no soporta attr() en gradients en todos los navegadores, así que definimos degradados genéricos y luego podemos enriquecer en runtime si se desea */
.color-result.result-has-source {
  --result-gradient: linear-gradient(135deg, rgba(255,255,255,.75), rgba(255,255,255,.05));
}

/* Mejora contraste interior */
.color-result.result-has-source::after {
  content:''; position:absolute; inset:0; background:none; pointer-events:none;
}

.color-result::after {
  content: '';
  position: absolute;
  top: 20%;
  left: 25%;
  width: 40%;
  height: 40%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.3) 0%, transparent 70%);
  border-radius: 50%;
}

/* 🔢 CARTA DE CONTADOR DE FORMAS */
.shape-count-card {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
  padding: 1rem;
}

.shapes-display {
  font-size: 3.5rem;
  line-height: 1.6;
  text-align: center;
  font-weight: 400;
  letter-spacing: 0.2rem;
}

/* 🔢 CARTA DE NÚMERO */
.number-card {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
  position: relative;
}

.number-card::before {
  content: '=';
  position: absolute;
  top: 8px;
  right: 12px;
  font-size: 1.25rem;
  font-weight: 800;
  color: rgba(76, 175, 80, 0.15);
  font-family: 'Inter', sans-serif;
}

.number-display { font-size: 7rem; font-weight: 900; font-family:'Inter',sans-serif; text-shadow:0 5px 14px rgba(0,0,0,.18); }

/* ➕ CARTA DE MATEMÁTICAS VISUALES */
.visual-math-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  height: 100%;
  background: linear-gradient(135deg, #FFE0B2 0%, #FFCC80 100%);
  padding: 1rem;
  position: relative;
  border: 2px solid rgba(230, 81, 0, 0.3);
}

.visual-math-card::before {
  content: '?';
  position: absolute;
  top: 8px;
  right: 12px;
  font-size: 1.5rem;
  font-weight: 900;
  color: rgba(230, 81, 0, 0.3);
  font-family: 'Inter', sans-serif;
}

.emoji-large { font-size:5.5rem; line-height:1; filter:drop-shadow(0 4px 12px rgba(0,0,0,.25)); }

.math-operation { font-size:2.4rem; font-weight:900; color:#BF360C; font-family:'Inter',sans-serif; background:rgba(255,255,255,.92); padding:.55rem 1.15rem; border-radius:12px; box-shadow:0 3px 10px rgba(0,0,0,.18); border:2px solid rgba(191,54,12,.25); }

/* 😊 CARTA DE CONTADOR DE EMOJIS */
.emoji-count-card {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  background: linear-gradient(135deg, #E8F5E9 0%, #C8E6C9 100%);
  padding: 1rem;
}

.emoji-grid {
  font-size: 3rem;
  line-height: 1.5;
  text-align: center;
  letter-spacing: 0.3rem;
  filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.1));
}

/* 😊 CARTA DE EMOJI INDIVIDUAL */
.emoji-single-card {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  background: linear-gradient(135deg, #E3F2FD 0%, #BBDEFB 100%);
  padding: 1rem;
}

.emoji-large {
  font-size: 5.5rem;
  filter: drop-shadow(0 3px 10px rgba(0, 0, 0, 0.15));
}

.emoji-xlarge {
  font-size: 7rem;
  filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.2));
}

/* 🔷 CARTA DE PATRÓN DE FORMAS */
.shape-pattern-card {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  background: linear-gradient(135deg, #E1BEE7 0%, #CE93D8 100%);
  padding: 1rem;
  position: relative;
  border: 2px solid rgba(106, 27, 154, 0.3);
}

.shape-pattern-card::before {
  content: '?';
  position: absolute;
  top: 8px;
  right: 12px;
  font-size: 1.5rem;
  font-weight: 900;
  color: rgba(74, 20, 140, 0.4);
  font-family: 'Inter', sans-serif;
}

.pattern-display {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.5);
  padding: 0.5rem 0.75rem;
  border-radius: 10px;
}

.pattern-item {
  font-size: 3.2rem;
  color: #4A148C;
  font-weight: 900;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

/* 🔷 CARTA DE FORMA INDIVIDUAL */
.shape-single-card {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
  position: relative;
}

.shape-single-card::before {
  content: '=';
  position: absolute;
  top: 8px;
  right: 12px;
  font-size: 1.25rem;
  font-weight: 800;
  color: rgba(76, 175, 80, 0.15);
  font-family: 'Inter', sans-serif;
}

.shape-xlarge {
  font-size: 7rem;
  font-weight: 700;
  filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.15));
}

/* Acciones - ULTRA COMPACTO */
.memory-actions {
  display: flex;
  justify-content: center;
  gap: 0.6rem;
  margin-top: 0.8rem;
  padding-top: 0;
  flex-wrap: wrap;
}

/* Optimización móvil para botones */
@media (max-width: 640px) {
  .memory-actions {
    margin-top: 0.4rem;
    gap: 0.4rem;
    padding: 0 0.3rem; /* Padding lateral para alinear con header */
  }
}

.mem-btn {
  padding: 0.6rem 1.4rem;
  border: none;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  font-family: 'Inter', sans-serif;
  min-height: 44px; /* Tamaño táctil mínimo */
}

.mem-btn-restart {
  background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
  color: #fff;
  box-shadow: 0 6px 20px rgba(245, 87, 108, 0.4);
}

.mem-btn-contrast {
  display: none !important;
  background: linear-gradient(135deg,#4b6cb7 0%,#182848 100%);
  color:#fff;
  box-shadow:0 6px 20px rgba(24,40,72,.45);
}
.mem-btn-contrast[aria-pressed="true"] {
  background: linear-gradient(135deg,#ffbf00 0%,#ff8000 100%);
  box-shadow:0 6px 22px rgba(255,128,0,.5);
}
.mem-btn-analytic { display: none !important; background:linear-gradient(135deg,#1d976c 0%,#2bc0e4 100%); color:#fff; box-shadow:0 6px 20px rgba(29,151,108,.45); }
.mem-btn-analytic[aria-pressed="true"] { background:linear-gradient(135deg,#d53369 0%,#daae51 100%); box-shadow:0 6px 22px rgba(213,51,105,.5); }
.mem-btn-visibility { display: none !important; background:linear-gradient(135deg,#485563 0%,#29323c 100%); color:#fff; box-shadow:0 6px 20px rgba(41,50,60,.45); }
.mem-btn-visibility[aria-pressed="true"] { background:linear-gradient(135deg,#ff9966 0%,#ff5e62 100%); box-shadow:0 6px 22px rgba(255,94,98,.55); }

/* Modo analítico: mostrar borde de intersección y valor legible */
.um-analytic .overlap-merge { box-shadow:0 0 0 3px rgba(255,255,255,.65), 0 0 0 5px rgba(0,0,0,.25); font-size:.7rem; font-weight:600; display:flex; align-items:center; justify-content:center; color:#111; text-shadow:0 1px 2px rgba(255,255,255,.6); }
.um-high-contrast.um-analytic .overlap-merge { box-shadow:0 0 0 3px #000, 0 0 0 6px #fff; color:#000; text-shadow:none; }

/* 🔍 Badge analítico ΔE para cartas de mezcla sencilla (se añade desde JS) */
.analytic-badge {
  position: absolute;
  bottom: 6px;
  left: 6px;
  background: rgba(0,0,0,0.55);
  color: #fff;
  font-size: 0.55rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  padding: 3px 6px 4px;
  border-radius: 8px;
  pointer-events: none;
  opacity: 0;
  transform: translateY(4px) scale(.9);
  transition: opacity .25s ease, transform .25s ease;
  line-height: 1;
  box-shadow: 0 2px 6px rgba(0,0,0,.35), 0 0 0 1px rgba(255,255,255,.25);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  z-index: 25;
}
.analytic-badge.visible { opacity: 1; transform: translateY(0) scale(1); }
.um-high-contrast .analytic-badge { background:#000; color:#fff; box-shadow:0 0 0 2px #fff; }
/* Tooltip accesible (solo visual) */
.analytic-badge[data-tooltip]:hover::after,
.analytic-badge[data-tooltip]:focus-visible::after {
  content: attr(data-tooltip);
  position: absolute;
  left: 0;
  bottom: 100%;
  transform: translateY(-6px);
  background: rgba(0,0,0,0.8);
  color: #fff;
  font-size: 0.55rem;
  font-weight: 600;
  padding: 4px 6px 5px;
  border-radius: 6px;
  white-space: nowrap;
  box-shadow: 0 2px 8px rgba(0,0,0,.4);
  z-index: 50;
  pointer-events: none;
}
.um-high-contrast .analytic-badge[data-tooltip]:hover::after,
.um-high-contrast .analytic-badge[data-tooltip]:focus-visible::after { background:#000; box-shadow:0 0 0 2px #fff; }
@media (max-width:640px){ .analytic-badge { font-size:.5rem; padding:2px 5px 3px; } }
@media (max-width:380px){ .analytic-badge { font-size:.45rem; padding:2px 4px 3px; } }

/* Alto contraste - solo aplicar gap amplio en desktop */
@media (min-width: 641px) {
  .um-high-contrast .memory-board { gap: 0.85rem; }
}
.um-high-contrast .memory-card { border:3px solid #000; background:#fff !important; }
.um-high-contrast .card-back { border:5px solid #000; box-shadow:none; }
.um-high-contrast .card-front { border:3px solid #000; }
.um-high-contrast .color-bisect-wrapper::after { opacity:.55; background:linear-gradient(90deg, rgba(0,0,0,.35), rgba(0,0,0,0) 40%, rgba(0,0,0,0) 60%, rgba(0,0,0,.35)), radial-gradient(circle at 50% 50%, rgba(255,255,255,.75), rgba(255,255,255,0) 55%); }
.um-high-contrast .color-trisect-wrapper::before, .um-high-contrast .color-trisect-wrapper::after { background:#000; }
.um-high-contrast .color-result.result-has-source::before { background:linear-gradient(135deg,#000,#444,#000); }
.um-high-contrast .mix-op-small, .um-high-contrast .color-seg-operator { background:#fff !important; color:#000 !important; box-shadow:none; outline:2px solid #000; }
.um-high-contrast .color-labels-inline, .um-high-contrast .color-labels { opacity:.95; color:#000; }
.um-high-contrast .number-display, .um-high-contrast .math-operation, .um-high-contrast .pattern-item { text-shadow:none; color:#000 !important; }
.um-high-contrast .memory-notification { box-shadow:0 0 0 4px #000; }
.um-high-contrast .notification-success { background:linear-gradient(#fff,#0f0); color:#000; }
.um-high-contrast .notification-penalty { background:linear-gradient(#fff,#f00); color:#000; }
.um-high-contrast .notification-neutral { background:linear-gradient(#fff,#ff0); color:#000; }
.um-high-contrast .creator-attribution-toast { border:3px solid #000; box-shadow:none; }
.um-high-contrast .shape-single-card::before, .um-high-contrast .number-card::before, .um-high-contrast .visual-math-card::before, .um-high-contrast .shape-pattern-card::before { color:#000 !important; opacity:0.4; }
.um-high-contrast .memory-stats-bar { background:#fff !important; border:3px solid #000; box-shadow:none; }
.um-high-contrast .stat-value { color:#000 !important; text-shadow:none; }
.um-high-contrast .stat-label { color:#111 !important; }
.um-high-contrast .unified-memory-game { background:#fff !important; box-shadow:none; }
@media (prefers-contrast: more) {
  .unified-memory-game:not(.um-high-contrast) .memory-board .memory-card:focus-visible { outline:3px solid #000; }
}

/* ===== Nuevo layout superpuesto (overlap) para mezcla cognitiva ===== */
.color-overlap-card { position:relative; height:100%; padding:.3rem; display:flex; flex-direction:column; justify-content:center; align-items:center; }
.color-overlap-card.triple { padding:.3rem; }
.overlap-wrapper { position:relative; width:100%; flex:1; min-height:180px; display:flex; align-items:center; justify-content:center; }
.overlap-circle { position:absolute; top:50%; left:50%; width:92%; aspect-ratio:1/1; background:var(--c); border-radius:50%; transform:translate(-50%,-50%); mix-blend-mode:normal; box-shadow:0 6px 20px rgba(0,0,0,.3), inset 0 6px 16px rgba(255,255,255,.3); }
.overlap-circle.oc-left { left:35%; }
.overlap-circle.oc-right { left:65%; }
.overlap-circle.tri-a { left:50%; top:30%; width:75%; }
.overlap-circle.tri-b { left:30%; top:63%; width:75%; }
.overlap-circle.tri-c { left:70%; top:63%; width:75%; }
/* Ajuste: se cambia mix-blend-mode: overlay -> normal para evitar percepción de "círculo lavado" o vacío en algunos navegadores/fondos */
.overlap-merge { position:absolute; top:50%; left:50%; transform:translate(-50%, -50%) scale(.2); width:var(--merge-size,46%); aspect-ratio:1/1; border-radius:50%; background:var(--c); mix-blend-mode:normal; box-shadow:0 0 0 3px rgba(255,255,255,.55), 0 2px 10px rgba(0,0,0,.35), 0 0 0 6px rgba(0,0,0,.08); animation: mergePulse 1.4s ease-in-out infinite alternate; opacity:0; }
.overlap-merge.tri { width:34%; }
.overlap-operator { position:absolute; top:8px; right:10px; font-size:1.2rem; font-weight:700; color:rgba(0,0,0,.55); background:rgba(255,255,255,.7); padding:.15rem .55rem; border-radius:8px; box-shadow:0 2px 6px rgba(0,0,0,.2); }
/* Estados de color desconocido (placeholder) */
.overlap-circle[data-unknown], .overlap-merge[data-unknown] { position:absolute; background:repeating-conic-gradient(#bbb 0deg,#bbb 15deg,#eee 15deg,#eee 30deg); color:#222; }
.overlap-circle[data-unknown]::after, .overlap-merge[data-unknown]::after { content:'?'; position:absolute; inset:0; display:flex; align-items:center; justify-content:center; font-weight:800; font-size:1.8rem; color:#444; text-shadow:0 1px 2px rgba(255,255,255,.6); mix-blend-mode:normal; }
.um-high-contrast .overlap-circle[data-unknown], .um-high-contrast .overlap-merge[data-unknown] { background:repeating-conic-gradient(#000 0deg,#000 15deg,#fff 15deg,#fff 30deg); }
.um-high-contrast .overlap-circle[data-unknown]::after, .um-high-contrast .overlap-merge[data-unknown]::after { color:#000; text-shadow:none; }

/* Modo debug: contornos para inspección */
.unified-memory-game.um-debug .overlap-circle { outline:2px dashed rgba(0,0,0,.55); }
.unified-memory-game.um-debug .overlap-merge { outline:2px solid #ff0066; }
.unified-memory-game.um-debug .overlap-operator { outline:1px dotted #222; }
@keyframes mergePulse { 0% { filter:brightness(1) scale(1); } 100% { filter:brightness(1.15) scale(1.05); } }
@keyframes mergeGrow { 0% { transform:translate(-50%,-50%) scale(.2); opacity:0; } 55% { opacity:1; } 100% { transform:translate(-50%,-50%) scale(1); opacity:1; } }

/* Estado activado al voltear (se aplica en JS via clase en card) */
.memory-card.flipped .overlap-merge { animation: mergeGrow .55s cubic-bezier(.55,.3,.25,1.2) forwards, mergePulse 1.4s ease-in-out .65s infinite alternate; }
.um-high-contrast .memory-card.flipped .overlap-merge { animation: mergeGrow .55s cubic-bezier(.55,.3,.25,1.2) forwards; }

/* Integración alto contraste sobre overlap */
.um-high-contrast .overlap-circle { box-shadow:none; outline:2px solid #000; }
.um-high-contrast .overlap-merge { box-shadow:0 0 0 3px #000, 0 0 0 5px #fff; mix-blend-mode:normal; animation:none; }
/* Modo visibilidad: enfatizar contorno de intersección */
.um-visibility-mode .overlap-merge { box-shadow:0 0 0 4px rgba(255,255,255,.9), 0 0 0 8px rgba(0,0,0,.28), 0 6px 14px rgba(0,0,0,.4); }
.um-visibility-mode.um-high-contrast .overlap-merge { box-shadow:0 0 0 4px #000, 0 0 0 9px #fff; }
/* Intersección marcada como pequeña (data-small) -> enfatizar con anillo */
.overlap-merge[data-small] { box-shadow:0 0 0 4px rgba(255,255,255,.85), 0 0 0 7px rgba(0,0,0,.25), 0 4px 10px rgba(0,0,0,.35); position:relative; }
.overlap-merge[data-small]::after { content:''; position:absolute; inset:0; border-radius:50%; box-shadow:0 0 0 2px rgba(0,0,0,.35) inset, 0 0 6px rgba(255,255,255,.7); mix-blend-mode:normal; }
.um-high-contrast .overlap-merge[data-small] { box-shadow:0 0 0 4px #000, 0 0 0 7px #fff; }
.um-high-contrast .overlap-merge[data-small]::after { box-shadow:0 0 0 2px #000 inset, 0 0 4px #fff; }
/* Badge MIN para intersecciones mínimas */
.overlap-merge[data-small] .small-mix-badge { position:absolute; bottom:-6px; right:-6px; background:linear-gradient(135deg,#ff512f,#f09819); color:#fff; font-size:.55rem; font-weight:800; padding:2px 5px; border-radius:8px; letter-spacing:.5px; box-shadow:0 2px 6px rgba(0,0,0,.35); transform:scale(1); }
.um-high-contrast .overlap-merge[data-small] .small-mix-badge { background:#000; color:#fff; box-shadow:0 0 0 2px #fff, 0 2px 6px rgba(0,0,0,.4); }
@media (max-width:380px){ .overlap-merge[data-small] .small-mix-badge { font-size:.5rem; padding:2px 4px; } }
/* Animación educativa diferenciada para intersecciones pequeñas */
@keyframes smallEducateIntro { 0% { transform:translate(-50%,-50%) scale(.3) rotate(0deg); opacity:0; filter:brightness(0.6); } 55% { opacity:1; } 70% { transform:translate(-50%,-50%) scale(1.08) rotate(8deg); filter:brightness(1.1); } 100% { transform:translate(-50%,-50%) scale(1) rotate(0deg); filter:brightness(1); opacity:1; } }
@keyframes smallEducatePulse { 0% { box-shadow:0 0 0 4px rgba(255,255,255,.85), 0 0 0 7px rgba(0,0,0,.25), 0 4px 10px rgba(0,0,0,.35); } 50% { box-shadow:0 0 0 6px rgba(255,255,255,.75), 0 0 0 9px rgba(0,0,0,.20), 0 6px 14px rgba(0,0,0,.4); } 100% { box-shadow:0 0 0 4px rgba(255,255,255,.85), 0 0 0 7px rgba(0,0,0,.25), 0 4px 10px rgba(0,0,0,.35); } }
.memory-card.flipped .overlap-merge[data-small] { animation: smallEducateIntro .65s cubic-bezier(.55,.3,.25,1.2) forwards, smallEducatePulse 1.6s ease-in-out .75s infinite alternate; }
.um-high-contrast .memory-card.flipped .overlap-merge[data-small] { animation: smallEducateIntro .65s cubic-bezier(.55,.3,.25,1.2) forwards, smallEducatePulse 1.9s ease-in-out .85s infinite alternate; }
@media (prefers-reduced-motion: reduce){
  .memory-card.flipped .overlap-merge[data-small], .um-high-contrast .memory-card.flipped .overlap-merge[data-small] { animation:none; }
}
.um-high-contrast .overlap-operator { background:#fff; color:#000; box-shadow:none; }

@media (max-width: 640px){
  .overlap-circle { width:90%; }
  .overlap-circle.tri-a, .overlap-circle.tri-b, .overlap-circle.tri-c { width:74%; }
  .overlap-merge { width:var(--merge-size,56%); }
  .overlap-merge.tri { width:48%; }
  .mix-operator { font-size: 3.5rem; width: 75px; height: 75px; }
}
.mem-btn-restart:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(245, 87, 108, 0.5);
}

/* Notificaciones de Feedback */
.memory-notification {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.8);
  padding: 1.5rem 3rem;
  border-radius: 16px;
  font-size: 1.5rem;
  font-weight: 700;
  color: #fff;
  z-index: 10000;
  opacity: 0;
  transition: all 0.3s ease;
  pointer-events: none;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

.memory-notification.show {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

.notification-success {
  background: linear-gradient(135deg, #4caf50, #81c784);
}

.notification-penalty {
  background: linear-gradient(135deg, #f44336, #e57373);
}

.notification-neutral {
  background: linear-gradient(135deg, #ff9800, #ffb74d);
}

/* Responsive - Tablet */
/* === 📱 RESPONSIVE MOBILE-FIRST === */

/* Tablets y pantallas medianas (768px - 968px) */
@media (max-width: 968px) {
  /* Eliminado override de grid-template-columns para no interferir con tamaño calculado por JS */

  .memory-stats-bar {
    gap: 1.2rem;
    padding: 0.5rem 1rem;
  }

  .stat-value {
    font-size: 1.3rem;
  }

  .stat-label {
    font-size: 0.65rem;
  }

  .unified-memory-game {
    padding: 1rem 0.8rem 1.2rem;
  }
}

/* Móviles (481px - 768px) */
@media (max-width: 768px) {
  /* Mantener configuración dinámica; sólo podríamos reducir gap si fuera necesario */

  .memory-card {
    border-radius: 12px; /* Bordes menos redondeados para aprovechar espacio */
    border-width: 1.5px;
  }

  /* Cartas más grandes y touch-friendly */
  .memory-card:active:not(.matched):not(.selected) {
    transform: scale(0.95); /* Feedback táctil */
  }

  .stat-value {
    font-size: 1.2rem;
  }

  .memory-header-simple h2 {
    font-size: 1.4rem;
  }
}

/* Desktop (> 640px) - Gap más amplio para mejor visualización */
@media (min-width: 641px) {
  .memory-board {
    gap: 12px; /* Gap amplio para desktop */
  }
}

/* Móviles pequeños (< 640px) - 3 COLUMNAS × 4 FILAS = 12 cartas (6 pares) */
@media (max-width: 640px) {
  .memory-board {
    grid-template-columns: repeat(3, 1fr); /* 3 columnas × 4 filas = 12 cartas perfectas */
    gap: 1px; /* Gap uniforme de 1px entre todas las cartas */
    max-width: 100%;
    padding: 0;
    width: 100%; /* Asegurar que use todo el ancho disponible */
  }

  .memory-card {
    max-width: 100%;
    border-radius: 6px; /* Reducido para ganar espacio */
    border: 1.5px solid rgba(255, 215, 0, 0.75); /* Borde más delgado pero visible */
    aspect-ratio: 1 / 1;
    width: 100%;
    /* Sin min-height/width fijos - dejar que el grid calcule automáticamente */
    box-shadow:
      0 2px 4px rgba(0, 0, 0, 0.25),
      inset 0 0.5px 1px rgba(255, 255, 255, 0.35),
      0 0 0 0.5px rgba(255, 215, 0, 0.3); /* Resplandor dorado */
  }

  .unified-memory-game {
    padding: 0.3rem 0 0.4rem; /* Padding lateral CERO para maximizar ancho */
    min-height: initial;
    border-radius: 14px;
    overflow-x: hidden; /* Prevenir scroll horizontal */
  }

  .memory-header-simple {
    margin-bottom: 0.2rem; /* Mínimo espacio vertical */
    padding: 0 0.3rem; /* Padding lateral mínimo para header */
  }

  .memory-header-simple h2 {
    font-size: 0.95rem;
    margin-bottom: 0.15rem;
  }

  .memory-stats-bar {
    gap: 0.3rem;
    padding: 0.15rem 0.3rem; /* Ultra compacto */
    flex-wrap: nowrap;
    justify-content: space-evenly;
    border-radius: 6px;
  }

  .stat-item {
    min-width: 45px; /* Más compacto */
    gap: 0.05rem;
  }

  .stat-value {
    font-size: 0.85rem;
  }

  .stat-label {
    font-size: 0.48rem;
  }

  /* Contenedor del tablero más compacto */
  .memory-board-container {
    margin: 0.2rem 0 0.3rem 0;
    padding: 0;
  }

  /* Contenedor del tablero ya tiene gap: 1px desde la regla base móvil */

  /* Optimizar cartas de colores para 4 columnas */
  .color-question-card {
    gap: 0.3rem;
    padding: 0.5rem;
    flex-direction: column; /* Círculos en vertical en móvil pequeño */
  }

  .color-question-card .color-circle-simple {
    width: 45%;
  }

  .color-question-card .operator-simple {
    font-size: 2rem;
  }

  .color-result {
    width: 68%;
  }

  .emoji-xlarge {
    font-size: 5.5rem;
  }

  .number-display {
    font-size: 5.5rem;
  }

  .shape-xlarge {
    font-size: 5.5rem;
  }
}

/* Móviles muy pequeños (< 480px) - 3 COLUMNAS mantiene perfección */
@media (max-width: 480px) {
  .memory-board {
    grid-template-columns: repeat(3, 1fr); /* 3 columnas perfectas */
    gap: 1px; /* Gap uniforme de 1px */
    padding: 0;
  }

  .memory-card {
    border-radius: 10px;
    border: 2.5px solid rgba(255, 215, 0, 0.65); /* Borde dorado visible */
  }

  .unified-memory-game {
    padding: 0.25rem 0.25rem 0.35rem;
    border-radius: 14px;
  }

  .memory-header-simple h2 {
    font-size: 1rem;
    margin-bottom: 0.25rem;
  }

  .memory-stats-bar {
    gap: 0.4rem;
    padding: 0.2rem 0.4rem;
    border-radius: 6px;
  }

  .stat-item {
    min-width: 48px;
  }

  .stat-value {
    font-size: 0.9rem;
  }

  .stat-label {
    font-size: 0.5rem;
  }

  /* Botones de control más pequeños */
  .um-mode-toggle button,
  .um-difficulty-selector button {
    padding: 0.4rem 0.8rem;
    font-size: 0.8rem;
  }

  .um-action-buttons button {
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
  }

  .memory-actions {
    margin-top: 0.6rem;
    gap: 0.5rem;
  }

  .mem-btn {
    padding: 0.5rem 1rem;
    font-size: 0.8rem;
  }
}

/* Ultra pequeño: optimización < 380px - 3 COLUMNAS perfectas */
@media (max-width: 380px) {
  .memory-board {
    grid-template-columns: repeat(3, 1fr); /* 3 columnas perfectas */
    gap: 1px; /* Gap uniforme de 1px */
    padding: 0;
  }

  .memory-card {
    border-radius: 8px;
    border: 2px solid rgba(255, 215, 0, 0.65); /* Borde dorado visible */
  }

  .unified-memory-game {
    padding: 0.2rem 0.2rem 0.3rem;
  }

  .memory-header-simple h2 {
    font-size: 0.95rem;
  }

  .stat-value {
    font-size: 0.85rem;
  }

  .stat-label {
    font-size: 0.48rem;
  }

  .stat-item {
    min-width: 45px;
  }

  .memory-stats-bar {
    gap: 0.3rem;
    padding: 0.2rem 0.3rem;
  }

  .color-question-card {
    gap: 0.2rem;
    padding: 0.3rem;
  }

  .color-question-card .color-circle-simple {
    width: 40%;
  }

  .color-question-card .operator-simple {
    font-size: 1.4rem;
  }

  .color-result {
    width: 65%;
  }

  .emoji-xlarge { font-size: 3.5rem; }
  .number-display { font-size: 4rem; }
  .shape-xlarge { font-size: 3.5rem; }

  .mem-btn {
    padding: 0.4rem 0.8rem;
    font-size: 0.75rem;
  }
}

/* Modo ultra-compacto < 320px - 3 COLUMNAS perfectas */
@media (max-width: 320px) {
  .memory-board {
    /* 3 columnas perfectas incluso en pantallas muy pequeñas */
    grid-template-columns: repeat(3, 1fr);
    gap: 1px; /* Gap uniforme de 1px */
    padding: 0;
  }

  .memory-card {
    border-radius: 7px;
    border: 2px solid rgba(255, 215, 0, 0.6); /* Borde dorado visible */
  }

  .unified-memory-game {
    padding: 0.18rem 0.18rem 0.28rem;
  }

  .memory-header-simple h2 {
    font-size: 0.9rem;
  }

  .stat-value {
    font-size: 0.8rem;
  }

  .stat-label {
    font-size: 0.45rem;
  }
}

/* === 📱 MEJORAS TÁCTILES Y ACCESIBILIDAD MÓVIL === */

/* Eliminar hover effects en dispositivos táctiles */
@media (hover: none) and (pointer: coarse) {
  .memory-card:hover:not(.matched):not(.selected) {
    transform: none; /* No hover en touch */
  }

  /* Mejor feedback táctil al tocar */
  .memory-card:active:not(.matched):not(.selected) {
    transform: scale(0.92);
    transition: transform 0.1s ease;
  }

  /* Prevenir double-tap zoom */
  .memory-card {
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
  }
}

/* Optimización para reducir animaciones en móvil si el usuario lo prefiere */
@media (prefers-reduced-motion: reduce) {
  .memory-card,
  .card-inner,
  .memory-card:hover,
  .memory-card:active {
    transition: none !important;
    animation: none !important;
  }

  .card-inner {
    transition: transform 0.5s ease !important; /* Mantener flip básico */
  }
}

/* Touch-friendly: aumentar área táctil de botones en móvil */
@media (max-width: 640px) {
  button,
  .memory-card {
    min-height: 44px; /* iOS/Android guideline */
    min-width: 44px;
  }

  /* Espaciado adicional entre elementos interactivos */
  .um-action-buttons {
    gap: 0.75rem;
  }

  .um-mode-toggle button,
  .um-difficulty-selector button {
    min-height: 44px;
  }
}

/* 📱 Landscape móvil: optimización COMPLETA para modo horizontal (5×4) */
@media (max-width: 968px) and (orientation: landscape) {
  .unified-memory-game {
    padding: 0.3rem 0.5rem;
    display: flex;
    flex-direction: column;
    max-height: 100vh;
  }

  .memory-header-simple { margin-bottom: 0.25rem; }
  .memory-header-simple h2 { font-size: 0.95rem; margin-bottom: 0.2rem; }
  .memory-stats-bar { padding: 0.2rem 0.5rem; gap: 0.6rem; }

  /* Landscape: 5 columnas para aprovechar el ancho */
  .memory-board {
    grid-template-columns: repeat(5, 1fr);
    gap: 6px;
    max-height: calc(100vh - 180px);
    padding: 0;
    align-content: start;
  }

  .memory-card {
    aspect-ratio: 1 / 1;
    width: 100%;
    min-height: 80px;
    min-width: 80px;
  }

  .stat-value {
    font-size: 0.9rem;
  }

  .stat-label {
    font-size: 0.5rem;
  }

  /* Botones más compactos en landscape */
  .memory-actions {
    margin-top: 0.4rem;
    gap: 0.4rem;
  }

  .mem-btn {
    padding: 0.4rem 1rem;
    font-size: 0.8rem;
  }

  /* 💡 Mensaje optimizado en landscape */
  .memory-board-container::before {
    content: '🔄 Modo horizontal · 5 columnas';
    display: block;
    text-align: center;
    color: rgba(255, 255, 255, 0.65);
    font-size: 0.65rem;
    margin-bottom: 0.25rem;
    font-weight: 500;
  }
}

/* 💡 Hint de rotación (solo visible en móvil vertical < 640px) - REMOVIDO para no molestar */
@media (max-width: 640px) and (orientation: portrait) {
  /* El hint de rotación está desactivado para no interrumpir el juego */
  /* Los usuarios pueden descubrir naturalmente el modo landscape */
}

/* 🆘 Botón de Ayuda Flotante */
.memory-help-btn {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border: 2px solid rgba(255, 255, 255, 0.3);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
  z-index: 10;
}

.memory-help-btn:hover {
  transform: scale(1.1) rotate(15deg);
  box-shadow: 0 6px 20px rgba(102, 126, 234, 0.6);
}

.memory-help-btn:active {
  transform: scale(0.95);
}

.memory-help-btn svg {
  width: 20px;
  height: 20px;
  stroke-width: 2.5;
}

/* Modal de Ayuda */
.memory-help-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.memory-help-modal.active {
  display: flex;
  opacity: 1;
}

.memory-help-content {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border-radius: 20px;
  padding: 2rem 1.5rem;
  max-width: 500px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  animation: slideUp 0.3s ease;
}

@keyframes slideUp {
  from {
    transform: translateY(30px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.memory-help-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: white;
  font-size: 1.5rem;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.memory-help-close:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: rotate(90deg);
}

.memory-help-content h3 {
  color: white;
  font-size: 1.5rem;
  margin: 0 0 1.5rem 0;
  text-align: center;
}

.help-rules {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.help-rule {
  display: flex;
  gap: 1rem;
  background: rgba(255, 255, 255, 0.1);
  padding: 1rem;
  border-radius: 12px;
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.help-icon {
  font-size: 1.8rem;
  min-width: 40px;
  text-align: center;
}

.help-text {
  flex: 1;
  color: white;
}

.help-text strong {
  display: block;
  margin-bottom: 0.3rem;
  font-size: 0.95rem;
  color: rgba(255, 255, 255, 0.95);
}

.help-text p {
  margin: 0;
  font-size: 0.85rem;
  line-height: 1.4;
  color: rgba(255, 255, 255, 0.85);
}

.memory-help-play-btn {
  width: 100%;
  padding: 0.9rem;
  background: white;
  color: #667eea;
  border: none;
  border-radius: 12px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.memory-help-play-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}

.memory-help-play-btn:active {
  transform: translateY(0);
}

/* Móvil */
@media (max-width: 640px) {
  .memory-help-btn {
    width: 28px;
    height: 28px;
    top: 0.3rem;
    right: 0.3rem;
    box-shadow: 0 3px 10px rgba(102, 126, 234, 0.4);
  }

  .memory-help-btn svg {
    width: 16px;
    height: 16px;
  }

  .memory-help-content {
    padding: 1.5rem 1rem;
    border-radius: 16px;
    max-width: 92vw;
  }

  .memory-help-content h3 {
    font-size: 1.2rem;
    margin-bottom: 0.8rem;
  }

  .help-rule {
    padding: 0.7rem;
    gap: 0.7rem;
  }

  .help-icon {
    font-size: 1.4rem;
    min-width: 30px;
  }

  .help-text strong {
    font-size: 0.85rem;
  }

  .help-text p {
    font-size: 0.75rem;
  }

  .memory-help-play-btn {
    padding: 0.7rem;
    font-size: 0.9rem;
  }
}

/* ================================================
   📱 MEJORAS CRÍTICAS PARA MÓVIL
   ================================================ */

@media (max-width: 640px) {
  /* Juego más compacto en móvil - ya está optimizado arriba */
  /* Se mantienen los valores del media query principal para consistencia */

  /* Cartas con bordes más visibles y destacados */
  .memory-card {
    border: 3.5px solid rgba(255, 215, 0, 0.6); /* Borde dorado muy visible */
    border-radius: 14px;
    box-shadow:
      0 5px 12px rgba(0, 0, 0, 0.3),
      inset 0 1px 3px rgba(255, 255, 255, 0.4),
      0 0 0 1px rgba(255, 215, 0, 0.2); /* Resplandor dorado */
  }

  /* Texto de cartas más legible */
  .card-front .card-title {
    font-size: 0.65rem !important;
    padding: 0.2rem 0.3rem;
    line-height: 1.2;
  }

  .card-front .card-year {
    font-size: 0.55rem !important;
    padding: 0.15rem 0.25rem;
  }

  /* Botones de control más grandes y táctiles */
  .memory-controls {
    gap: 0.5rem;
    padding: 0.75rem 0.5rem;
  }

  .memory-control-btn {
    padding: 0.65rem 1rem;
    font-size: 0.85rem;
    min-height: 42px;
    touch-action: manipulation;
  }

  /* Modal de victoria */
  .memory-victory-modal {
    padding: 1.5rem 1rem;
    max-width: 90vw;
  }

  .memory-victory-modal h2 {
    font-size: 1.5rem;
  }

  .memory-victory-stats {
    gap: 0.75rem;
  }

  .memory-victory-stat {
    padding: 0.75rem;
  }

  /* Botón de ayuda más accesible */
  .memory-help-button {
    width: 36px;
    height: 36px;
    font-size: 1.1rem;
  }

  /* Overlay de ayuda optimizado */
  .memory-help-overlay-content {
    max-width: 90vw;
    padding: 1.25rem;
  }
}

/* Mejoras para pantallas muy pequeñas (< 480px) */
@media (max-width: 480px) {
  .unified-memory-game {
    padding: 0.3rem 0.2rem 0.5rem 0.2rem;
  }

  .memory-header-simple h2 {
    font-size: 1rem;
  }

  .memory-stats-bar {
    gap: 0.4rem;
    padding: 0.35rem 0.6rem;
  }

  .stat-item {
    min-width: 40px;
  }

  .stat-label {
    font-size: 0.45rem;
  }

  .stat-value {
    font-size: 0.9rem;
  }

  .memory-board {
    gap: 4px;
  }

  /* Cartas aún más compactas pero funcionales */
  .memory-card {
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 12px;
  }

  .card-front .card-title {
    font-size: 0.55rem !important;
    padding: 0.15rem 0.25rem;
  }

  .card-front .card-year {
    font-size: 0.5rem !important;
    padding: 0.12rem 0.2rem;
  }

  /* Controles compactos */
  .memory-control-btn {
    padding: 0.55rem 0.85rem;
    font-size: 0.75rem;
    min-height: 38px;
  }

  /* Reducir animaciones en dispositivos más lentos */
  .card-inner {
    transition: transform 1.2s ease-out;
  }

  .memory-card.flipped .card-inner {
    transition: transform 1.2s ease-in;
  }
}

/* Mejoras de contraste para mejor visibilidad */
@media (max-width: 640px) {
  /* Reverso de carta más visible */
  .card-back {
    background:
      linear-gradient(135deg, rgba(255, 255, 255, 0.2) 25%, transparent 25%),
      linear-gradient(225deg, rgba(255, 255, 255, 0.2) 25%, transparent 25%),
      linear-gradient(315deg, rgba(255, 255, 255, 0.2) 25%, transparent 25%),
      linear-gradient(45deg, rgba(255, 255, 255, 0.2) 25%, transparent 25%);
    background-size: 25px 25px;
    background-position: 0 0, 0 12.5px, 12.5px -12.5px, -12.5px 0;
    background-color: rgba(108, 117, 125, 0.95);
  }

  /* Frente de carta con mejor contraste */
  .card-front {
    box-shadow:
      0 6px 16px rgba(0, 0, 0, 0.3),
      0 2px 6px rgba(0, 0, 0, 0.2);
  }

  /* Borde de carta seleccionada más visible */
  .memory-card.selected .card-front {
    border: 4px solid #FFD700;
    box-shadow:
      0 0 25px rgba(255, 215, 0, 0.9),
      0 6px 16px rgba(0, 0, 0, 0.3);
  }
}
