/* ============================================================
   MENTE ACTIVA — Hoja de estilos
   Diseño pensado para adultos mayores:
   texto grande, botones enormes, colores suaves, alto contraste.
   ============================================================ */

/* ----- Variables de diseño (modo claro) ----- */
:root {
  --bg: #FBFAF7;            /* blanco cálido */
  --card: #FFFFFF;
  --celeste: #BFD9E8;       /* celeste pastel */
  --celeste-suave: #E4F0F7;
  --verde: #9ED8C8;         /* verde agua */
  --verde-suave: #E2F3EE;
  --verde-oscuro: #2F5D53;  /* para texto sobre verde */
  --beige: #F2EAD9;
  --gris: #6E7A7C;          /* texto secundario */
  --texto: #2B3A38;         /* texto principal */
  --borde: #DDE4E2;
  --error: #C96A5B;
  --ok: #3E8E71;
  --sombra: 0 4px 16px rgba(60, 90, 85, 0.10);
  --radio: 22px;
}

[data-theme="dark"] {
  --bg: #1C2426;
  --card: #263033;
  --celeste: #4A6B7E;
  --celeste-suave: #2E3E47;
  --verde: #3E7A6D;
  --verde-suave: #2C4640;
  --verde-oscuro: #DFF3EE;
  --beige: #3A3A30;
  --gris: #A9B6B4;
  --texto: #ECF3F1;
  --borde: #3A4649;
  --error: #E08A7B;
  --ok: #7FD0B0;
  --sombra: 0 4px 16px rgba(0, 0, 0, 0.35);
}

/* ----- Base ----- */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html { font-size: 20px; } /* base grande para lectura cómoda */

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--texto);
  line-height: 1.45;
  min-height: 100vh;
  padding-bottom: 40px;
}

h1, h2, h3, .brand-name, .saludo {
  font-family: Georgia, "Times New Roman", serif;
  letter-spacing: 0.2px;
}

button { font-family: inherit; color: inherit; }

/* Foco visible para navegación con teclado */
button:focus-visible, input:focus-visible, .celda:focus-visible {
  outline: 4px solid var(--celeste);
  outline-offset: 2px;
}

/* Animaciones suaves; se respeta la preferencia del sistema */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ----- Barra superior ----- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px;
  background: linear-gradient(120deg, var(--verde-suave), var(--celeste-suave));
  border-bottom: 1px solid var(--borde);
  position: sticky; top: 0; z-index: 20;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-icon { font-size: 1.4rem; color: var(--verde-oscuro); }
.brand-name { font-size: 1.35rem; font-weight: 700; }

.icon-btn {
  font-size: 1.4rem; background: var(--card); border: 1px solid var(--borde);
  border-radius: 50%; width: 58px; height: 58px; cursor: pointer; box-shadow: var(--sombra);
}

/* ----- Contenedor ----- */
#app { max-width: 980px; margin: 0 auto; padding: 20px; }
.screen { animation: aparecer 0.35s ease; }
@keyframes aparecer { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ----- Hero / saludo ----- */
.hero { text-align: center; padding: 22px 10px 6px; }
.saludo { font-size: 2rem; font-weight: 700; margin: 0 0 6px; }
.hero-sub { color: var(--gris); font-size: 1.1rem; margin: 0 0 14px; }
.ola { width: 220px; height: 24px; color: var(--verde); opacity: 0.8; }

/* ----- Botones ----- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 64px; padding: 12px 26px;
  font-size: 1.15rem; font-weight: 700;
  border-radius: var(--radio); border: none; cursor: pointer;
  transition: transform 0.15s ease, filter 0.15s ease;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--verde); color: var(--verde-oscuro); box-shadow: var(--sombra); }
.btn-soft { background: var(--celeste-suave); color: var(--texto); border: 1px solid var(--borde); }
.btn-ghost { background: transparent; color: var(--gris); text-decoration: underline; min-height: 48px; }
.btn:hover { filter: brightness(1.04); }
.btn[disabled] { opacity: 0.45; cursor: default; }

.pills { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; margin: 10px 0 26px; }
.pill {
  min-height: 60px; padding: 10px 22px; font-size: 1.05rem; font-weight: 700;
  border-radius: 999px; border: 1px solid var(--borde);
  background: var(--card); cursor: pointer; box-shadow: var(--sombra);
}

.fila-botones { display: flex; gap: 14px; flex-wrap: wrap; justify-content: center; margin-top: 14px; }

/* ----- Tarjetas de juegos ----- */
.cards {
  display: grid; gap: 18px;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
}
.card-juego {
  background: var(--card); border: 1px solid var(--borde); border-radius: var(--radio);
  box-shadow: var(--sombra); padding: 22px; text-align: left; cursor: pointer;
  display: flex; flex-direction: column; gap: 8px;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  border-top: 8px solid var(--verde);
}
.card-juego:nth-child(3n+2) { border-top-color: var(--celeste); }
.card-juego:nth-child(3n+3) { border-top-color: var(--beige); }
.card-juego:hover { transform: translateY(-3px); }
.card-icono { font-size: 2.6rem; line-height: 1; }
.card-nombre { font-size: 1.3rem; font-weight: 700; font-family: Georgia, serif; }
.card-desc { color: var(--gris); font-size: 1rem; margin: 0; }

/* ----- Cabecera de juego ----- */
.game-head { display: flex; align-items: center; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.game-head h2 { margin: 0; font-size: 1.6rem; }

/* ----- Paneles genéricos ----- */
.panel {
  background: var(--card); border: 1px solid var(--borde); border-radius: var(--radio);
  box-shadow: var(--sombra); padding: 26px; max-width: 640px; margin: 0 auto;
  display: flex; flex-direction: column; gap: 18px;
}
.field { display: flex; flex-direction: column; gap: 6px; font-weight: 700; }
.field input {
  font-size: 1.2rem; padding: 14px 16px; border-radius: 14px;
  border: 2px solid var(--borde); background: var(--bg); color: var(--texto);
}
.mensaje-ok { color: var(--ok); font-weight: 700; text-align: center; }

.avatar-wrap { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.avatar {
  width: 130px; height: 130px; border-radius: 50%;
  background: var(--celeste-suave); border: 3px solid var(--verde);
  display: flex; align-items: center; justify-content: center;
  font-size: 3.4rem; overflow: hidden; background-size: cover; background-position: center;
}
.file-btn { position: relative; }

/* ----- Modales ----- */
.modal {
  position: fixed; inset: 0; background: rgba(20, 30, 28, 0.55);
  display: flex; align-items: center; justify-content: center; z-index: 50; padding: 20px;
}
.modal[hidden] { display: none; }
.modal-card {
  background: var(--card); border-radius: var(--radio); box-shadow: var(--sombra);
  padding: 28px; width: 100%; max-width: 460px;
  display: flex; flex-direction: column; gap: 18px;
  animation: aparecer 0.25s ease;
}
.modal-card h3 { margin: 0; font-size: 1.5rem; text-align: center; }
.modal-card.centro { text-align: center; align-items: center; }
.cele-icono { font-size: 4rem; }
#cele-detalle { font-size: 1.15rem; color: var(--gris); margin: 0; }

.switch-row {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 1.15rem; font-weight: 700; gap: 14px;
}
.switch { appearance: none; width: 74px; height: 42px; border-radius: 999px;
  background: var(--borde); position: relative; cursor: pointer; transition: background 0.2s; flex-shrink: 0; }
.switch::after { content: ""; position: absolute; top: 4px; left: 4px; width: 34px; height: 34px;
  border-radius: 50%; background: #fff; transition: left 0.2s; box-shadow: 0 2px 6px rgba(0,0,0,0.25); }
.switch:checked { background: var(--verde); }
.switch:checked::after { left: 36px; }

/* ----- Confetti y avisos ----- */
#confetti { position: fixed; inset: 0; pointer-events: none; z-index: 60; }
.toast {
  position: fixed; left: 50%; bottom: 30px; transform: translateX(-50%);
  background: var(--verde-oscuro); color: #fff; padding: 14px 24px;
  border-radius: 999px; font-size: 1.1rem; font-weight: 700; z-index: 70;
  box-shadow: var(--sombra); text-align: center; max-width: 90vw;
}
[data-theme="dark"] .toast { background: var(--verde); color: #14302a; }

/* ============================================================
   ESTILOS COMPARTIDOS DE LOS JUEGOS
   ============================================================ */

.setup { display: flex; flex-direction: column; gap: 20px; align-items: center; text-align: center; }
.setup h3 { margin: 10px 0 0; font-size: 1.3rem; }
.opciones { display: flex; gap: 14px; flex-wrap: wrap; justify-content: center; }
.opcion {
  min-height: 68px; min-width: 120px; padding: 12px 20px;
  font-size: 1.15rem; font-weight: 700; border-radius: var(--radio);
  border: 3px solid var(--borde); background: var(--card); cursor: pointer;
  box-shadow: var(--sombra);
}
.opcion.activa { border-color: var(--verde); background: var(--verde-suave); }

.marcador {
  display: flex; gap: 18px; flex-wrap: wrap; justify-content: center;
  font-size: 1.1rem; font-weight: 700; margin-bottom: 16px; color: var(--gris);
}
.marcador b { color: var(--texto); }

.juego-zona { display: flex; flex-direction: column; gap: 18px; align-items: center; }

/* Botones de respuesta grandes (V/F, opciones múltiples) */
.respuestas { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); width: 100%; max-width: 640px; }
.respuesta {
  min-height: 76px; font-size: 1.3rem; font-weight: 700;
  border-radius: var(--radio); border: 3px solid var(--borde);
  background: var(--card); cursor: pointer; box-shadow: var(--sombra); padding: 12px;
}
.respuesta.bien { background: var(--verde-suave); border-color: var(--ok); }
.respuesta.mal { background: #F6E3DF; border-color: var(--error); }
[data-theme="dark"] .respuesta.mal { background: #4A3230; }

.pregunta-caja {
  background: var(--card); border: 1px solid var(--borde); border-radius: var(--radio);
  box-shadow: var(--sombra); padding: 24px; font-size: 1.35rem; font-weight: 700;
  text-align: center; max-width: 640px; width: 100%;
}
.pregunta-caja .chiquito { display: block; font-size: 0.95rem; color: var(--gris); font-weight: 400; margin-bottom: 8px; }

/* Teclado en pantalla */
.teclado { display: flex; flex-direction: column; gap: 8px; align-items: center; width: 100%; }
.teclado-fila { display: flex; gap: 6px; justify-content: center; width: 100%; }
.tecla {
  flex: 1; max-width: 62px; min-width: 30px; height: 62px;
  font-size: 1.25rem; font-weight: 700; border-radius: 12px;
  border: 2px solid var(--borde); background: var(--card); cursor: pointer;
}
.tecla:active { background: var(--verde-suave); }
.tecla.ancha { max-width: 130px; }

/* Memotest */
.tablero-memo { display: grid; gap: 12px; width: 100%; max-width: 620px; }
.carta { position: relative; aspect-ratio: 3/4; cursor: pointer; perspective: 600px; border: none; background: none; padding: 0; }
.carta-int { position: absolute; inset: 0; transition: transform 0.45s; transform-style: preserve-3d; }
.carta.volteada .carta-int, .carta.lograda .carta-int { transform: rotateY(180deg); }
.cara { position: absolute; inset: 0; border-radius: 16px; backface-visibility: hidden; -webkit-backface-visibility: hidden;
  display: flex; align-items: center; justify-content: center; box-shadow: var(--sombra); }
.cara.frente { background: linear-gradient(135deg, var(--verde), var(--celeste)); font-size: 1.8rem; color: rgba(255,255,255,0.85); }
.cara.dorso { background: var(--card); border: 3px solid var(--borde); transform: rotateY(180deg); font-size: clamp(1.8rem, 8vw, 3rem); }
.carta.lograda .cara.dorso { border-color: var(--ok); background: var(--verde-suave); animation: pulso 0.5s ease; }
@keyframes pulso { 50% { transform: rotateY(180deg) scale(1.08); } }

/* Sopa de letras */
.sopa-grid { display: grid; gap: 4px; user-select: none; }
.sopa-celda {
  width: 100%; aspect-ratio: 1; display: flex; align-items: center; justify-content: center;
  background: var(--card); border: 1px solid var(--borde); border-radius: 8px;
  font-weight: 700; font-size: clamp(0.85rem, 3.4vw, 1.2rem); cursor: pointer;
}
.sopa-celda.marcada { background: var(--celeste); }
.sopa-celda.hallada { background: var(--verde); color: var(--verde-oscuro); }
.sopa-palabras { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.sopa-palabra { background: var(--beige); border-radius: 999px; padding: 8px 16px; font-weight: 700; }
.sopa-palabra.tachada { text-decoration: line-through; opacity: 0.5; }

/* Crucigrama */
.cruci-grid { display: grid; gap: 3px; margin: 0 auto; }
.cruci-celda { position: relative; width: 100%; aspect-ratio: 1; background: var(--card);
  border: 2px solid var(--borde); border-radius: 6px; display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: clamp(0.9rem, 3.5vw, 1.3rem); cursor: pointer; }
.cruci-celda.vacia { background: transparent; border: none; cursor: default; }
.cruci-celda.sel { border-color: var(--verde-oscuro); background: var(--verde-suave); }
.cruci-celda.palabra-sel { background: var(--celeste-suave); }
.cruci-celda.bien { background: var(--verde-suave); border-color: var(--ok); }
.cruci-celda.mal { background: #F6E3DF; border-color: var(--error); }
[data-theme="dark"] .cruci-celda.mal { background: #4A3230; }
.cruci-num { position: absolute; top: 1px; left: 4px; font-size: 0.55rem; color: var(--gris); font-weight: 700; }
.cruci-pistas { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); width: 100%; max-width: 680px; }
.cruci-pistas h4 { margin: 0 0 6px; }
.cruci-pistas ol { margin: 0; padding-left: 0; list-style: none; display: flex; flex-direction: column; gap: 6px; }
.cruci-pistas li { font-size: 1rem; }
.cruci-pistas li.lista { text-decoration: line-through; opacity: 0.55; }

/* Colorear */
.color-lienzo { width: 100%; max-width: 520px; background: #fff; border-radius: var(--radio);
  border: 1px solid var(--borde); box-shadow: var(--sombra); overflow: hidden; }
.color-lienzo svg { display: block; width: 100%; height: auto; }
.col { cursor: pointer; }
.paleta { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; max-width: 560px; }
.color-btn { width: 54px; height: 54px; border-radius: 50%; border: 3px solid var(--borde); cursor: pointer; }
.color-btn.activo { border-color: var(--texto); transform: scale(1.15); box-shadow: var(--sombra); }
.galeria { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); width: 100%; max-width: 640px; }
.galeria .mini { background: #fff; border: 2px solid var(--borde); border-radius: 16px; cursor: pointer; padding: 8px; text-align: center; font-weight: 700; }
.galeria .mini svg { width: 100%; height: auto; }

/* Diferencias / atención / grillas de emojis */
.emoji-grid { display: grid; gap: 8px; width: 100%; max-width: 520px; }
.emoji-celda { aspect-ratio: 1; display: flex; align-items: center; justify-content: center;
  background: var(--card); border: 2px solid var(--borde); border-radius: 12px;
  font-size: clamp(1.3rem, 6vw, 2.2rem); cursor: pointer; }
.emoji-celda.ok { border-color: var(--ok); background: var(--verde-suave); animation: pulsoS 0.4s; }
.emoji-celda.no { animation: sacudir 0.35s; }
@keyframes pulsoS { 50% { transform: scale(1.12); } }
@keyframes sacudir { 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }
.dif-titulo { font-weight: 700; color: var(--gris); }

/* Secuencias */
.seq-destino, .seq-origen { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; min-height: 90px;
  width: 100%; max-width: 640px; padding: 12px; border-radius: var(--radio); }
.seq-destino { background: var(--verde-suave); border: 2px dashed var(--verde); }
.seq-carta { background: var(--card); border: 2px solid var(--borde); border-radius: 16px;
  padding: 12px 16px; cursor: pointer; box-shadow: var(--sombra); text-align: center;
  font-weight: 700; font-size: 1rem; max-width: 160px; }
.seq-carta .emoji { display: block; font-size: 2.2rem; margin-bottom: 4px; }
.seq-carta.fija { cursor: default; border-color: var(--ok); }
.seq-num { display: inline-block; background: var(--verde); color: var(--verde-oscuro);
  border-radius: 50%; width: 30px; height: 30px; line-height: 30px; font-weight: 700; margin-bottom: 4px; }

/* Completar palabras / memoria numérica */
.slots { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.slot { width: 60px; height: 72px; border-radius: 14px; border: 3px solid var(--borde);
  background: var(--card); display: flex; align-items: center; justify-content: center;
  font-size: 1.9rem; font-weight: 700; }
.slot.hueco { border-style: dashed; background: var(--celeste-suave); }
.slot.activo { border-color: var(--verde-oscuro); background: var(--verde-suave); }
.slot.bien { border-color: var(--ok); background: var(--verde-suave); }

/* Asociar */
.asociar-cols { display: flex; gap: 30px; justify-content: center; width: 100%; max-width: 640px; }
.asociar-col { display: flex; flex-direction: column; gap: 12px; flex: 1; }
.asoc-item { min-height: 76px; font-size: 2rem; border-radius: var(--radio);
  border: 3px solid var(--borde); background: var(--card); cursor: pointer; box-shadow: var(--sombra); }
.asoc-item.sel { border-color: var(--verde-oscuro); background: var(--verde-suave); }
.asoc-item.hecho { opacity: 0.45; border-color: var(--ok); cursor: default; }

/* Rompecabezas */
.puzzle-grid { display: grid; gap: 4px; width: 100%; max-width: 560px; }
.puzzle-pieza { width: 100%; border: 2px solid var(--borde); border-radius: 8px; cursor: pointer; display: block; }
.puzzle-pieza.sel { border-color: var(--verde-oscuro); transform: scale(0.96); }
.puzzle-ref { width: 150px; border-radius: 12px; border: 2px solid var(--borde); }

/* Laberinto */
#lab-canvas { width: 100%; max-width: 480px; border-radius: 16px; border: 2px solid var(--borde);
  background: var(--card); touch-action: none; }
.lab-controles { display: grid; grid-template-columns: repeat(3, 84px); grid-template-rows: repeat(2, 84px);
  gap: 10px; justify-content: center; }
.lab-btn { font-size: 1.9rem; border-radius: 18px; border: 2px solid var(--borde);
  background: var(--card); cursor: pointer; box-shadow: var(--sombra); }
.lab-btn:active { background: var(--verde-suave); }

/* Estadísticas */
.stats-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.stat-caja { background: var(--verde-suave); border-radius: 18px; padding: 18px; text-align: center; }
.stat-caja .num { font-size: 2rem; font-weight: 700; font-family: Georgia, serif; }
.stat-caja .lab { color: var(--gris); font-size: 0.95rem; }
.lista-mejores { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 8px; }
.lista-mejores li { display: flex; justify-content: space-between; gap: 10px; border-bottom: 1px dashed var(--borde); padding-bottom: 6px; }

/* Responsive fino */
@media (max-width: 480px) {
  html { font-size: 18px; }
  #app { padding: 14px; }
  .asociar-cols { gap: 14px; }
  .lab-controles { grid-template-columns: repeat(3, 72px); grid-template-rows: repeat(2, 72px); }
}
@media (min-width: 900px) {
  .cards { grid-template-columns: repeat(3, 1fr); }
}
