/* Tokens de css/variables.css inlineados acá en vez de @import: un
   @import encadenado agrega una espera de red extra antes de poder
   aplicar el resto de esta hoja (ver también el comentario sobre el
   modal de perfil más abajo, mismo motivo). */
:root {
  --navy: #08202e;
  --teal-deep: #0e4d5c;
  --teal: #1a7a8a;
  --teal-mid: #2aaec2;
  --teal-soft: #7ed6e4;
  --teal-pale: #d4f2f7;
  --cream: #f7f2eb;
  --warm: #7a5c33;
  --warm-lt: #f0e6d3;
  --bg: #f5fafc;
  --text: #0d2535;
  --text-mid: #3a5a6a;
  --text-soft: #5a7583;
  --easing: cubic-bezier(0.16, 1, 0.3, 1);
  --r: 18px;
  --r-lg: 26px;
}
/* Modal de perfil: en línea acá (no @import a perfil-modal.css) a
   propósito — un @import encadenado (juegos.css importa
   perfil-modal.css) resultó no aplicarse en producción por razones
   que no se pudieron determinar del todo (posible interacción con
   caché de CDN o alguna extensión del navegador), dejando el modal
   de perfil invisible pese a que el HTML/JS funcionaban bien. Con
   las reglas en línea, sin nivel de @import adicional, se elimina
   esa dependencia frágil. Mismas reglas que css/perfil-modal.css
   (compartidas con ejercicios.css) — si se edita una copia, replicar
   el cambio en la otra. */
.jp-modal-overlay {
  position: fixed; inset: 0; background: rgba(8,32,46,0.6); backdrop-filter: blur(6px);
  display: flex; align-items: flex-end; justify-content: center; z-index: 900;
}
.jp-modal-overlay[hidden] { display: none; }
.jp-modal {
  background: white; border-radius: 26px 26px 0 0; padding: 28px 22px 34px;
  width: 100%; max-width: 480px; animation: jpModalIn 0.3s var(--easing) both;
}
@media(min-width: 560px) { .jp-modal-overlay { align-items: center; } .jp-modal { border-radius: var(--r-lg); } }
@keyframes jpModalIn { from { transform: translateY(30px); opacity: 0; } to { transform: none; opacity: 1; } }
.jp-modal h2 { font-family: 'Playfair Display', serif; margin-bottom: 16px; }
.jp-avatares { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 18px; }
.jp-avatar-opcion {
  width: 44px; height: 44px; border-radius: 50%; border: 2px solid transparent; background: var(--bg);
  font-size: 1.3rem; cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: transform 0.15s, border-color 0.2s, background 0.2s; touch-action: manipulation;
}
.jp-avatar-opcion:active { transform: scale(0.9); }
.jp-avatar-opcion.activo { border-color: var(--teal-mid); background: var(--teal-pale); }
.jp-modal input[type="text"] {
  width: 100%; border: 2px solid var(--teal-pale); border-radius: var(--r); padding: 12px 16px;
  font-family: inherit; font-size: 1rem; margin-bottom: 18px;
}
.jp-modal-cerrar {
  width: 100%; border: none; border-radius: 50px; padding: 14px; font-weight: 700;
  background: linear-gradient(135deg, var(--teal-deep), var(--teal)); color: white; cursor: pointer;
  transition: transform 0.15s; touch-action: manipulation;
}
.jp-modal-cerrar:active { transform: scale(0.97); }
.jp-nivel-barra { height: 8px; background: var(--teal-pale); border-radius: 8px; overflow: hidden; margin: 6px 0 16px; }
.jp-nivel-barra-fill { width: 100%; height: 100%; background: linear-gradient(90deg, var(--teal), var(--teal-mid)); transform: scaleX(0); transform-origin: left; transition: transform 0.4s; }

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: 'Nunito', sans-serif;
  background: var(--bg); color: var(--text);
  /* deja lugar abajo para que el botón flotante de accesibilidad
     (fixed, bottom:80px) no tape el último contenido de la página. */
  padding-bottom: 140px;
}
a { color: inherit; text-decoration: none; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; scroll-behavior: auto !important; }
}
a:focus-visible, button:focus-visible { outline: 2px solid var(--teal-mid); outline-offset: 2px; border-radius: 4px; }
button { font-family: inherit; }

/* ── HEADER ── */
header.jp-header {
  background: linear-gradient(160deg, var(--navy), var(--teal-deep));
  padding: 20px 20px 60px;
  border-radius: 0 0 32px 32px;
  position: relative; overflow: hidden;
}
header.jp-header::before {
  content: ''; position: absolute; inset: 0;
  background: radial-gradient(ellipse 70% 50% at 80% 0%, rgba(126,214,228,0.25), transparent 60%);
}
.jp-topbar { display: flex; align-items: center; justify-content: space-between; position: relative; z-index: 1; }
.jp-perfil-btn {
  width: 44px; height: 44px; border-radius: 50%; border: 2px solid rgba(255,255,255,0.3);
  background: rgba(255,255,255,0.1); color: white; font-size: 1.3rem; cursor: pointer;
  display: flex; align-items: center; justify-content: center; overflow: hidden; padding: 0;
  transition: transform 0.15s, background 0.2s; touch-action: manipulation;
}
.jp-perfil-btn:active { transform: scale(0.9); background: rgba(255,255,255,0.2); }
.jp-saludo { position: relative; z-index: 1; margin-top: 26px; color: white; }
.jp-saludo h1 { font-family: 'Playfair Display', serif; font-size: 1.7rem; font-weight: 500; }
.jp-saludo p { color: rgba(255,255,255,0.65); margin-top: 4px; font-size: 0.92rem; }

.jp-stats-row { display: flex; gap: 10px; position: relative; z-index: 1; margin-top: 20px; flex-wrap: wrap; }
.jp-stat-chip {
  background: rgba(255,255,255,0.08); border: 1px solid rgba(126,214,228,0.25);
  border-radius: 50px; padding: 8px 16px; color: white; font-size: 0.82rem; font-weight: 700;
  display: flex; align-items: center; gap: 6px;
}

/* ── SECCIÓN ÁNIMO ── */
.jp-animo {
  max-width: 640px; margin: -36px auto 0; padding: 0 18px; position: relative; z-index: 2;
}
.jp-animo-card {
  background: white; border-radius: var(--r-lg); padding: 22px 20px;
  box-shadow: 0 20px 50px rgba(8,32,46,0.15);
}
.jp-animo-card h2 { font-size: 1.05rem; margin-bottom: 14px; color: var(--navy); }
.jp-animo-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.jp-animo-btn {
  border: none; background: var(--bg); border-radius: 14px; padding: 12px 4px;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  font-size: 0.68rem; font-weight: 700; color: var(--text-mid); cursor: pointer;
  transition: background 0.2s, transform 0.2s;
  touch-action: manipulation;
}
.jp-animo-btn:active { background: var(--teal-pale); transform: scale(0.94); }
.jp-animo-btn .emoji { font-size: 1.5rem; }

/* ── BUSCADOR ── */
.jp-buscador { max-width: 640px; margin: 20px auto 0; padding: 0 18px; }
.jp-buscador input { width: 100%; border: 2px solid var(--teal-pale); border-radius: 50px; padding: 12px 20px; font-family: inherit; font-size: 0.95rem; background: white; }

/* ── JUGAR AL AZAR ── */
.jp-azar {
  max-width: 640px; margin: 20px auto 0; padding: 0 18px;
}
.jp-azar-btn {
  width: 100%; border: none; border-radius: var(--r-lg);
  background: linear-gradient(135deg, var(--teal-deep), var(--teal));
  color: white; padding: 20px; font-size: 1.05rem; font-weight: 800;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  box-shadow: 0 12px 30px rgba(42,174,194,0.35); cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
  touch-action: manipulation;
}
.jp-azar-btn:active { transform: scale(0.97); box-shadow: 0 6px 18px rgba(42,174,194,0.3); }

/* ── SECCIONES GENERALES ── */
.jp-seccion { max-width: 640px; margin: 34px auto 0; padding: 0 18px; }
.jp-seccion h2 { font-size: 1.1rem; color: var(--navy); margin-bottom: 14px; display: flex; align-items: center; gap: 8px; }
.jp-seccion h2 .ver-todo { margin-left: auto; font-size: 0.8rem; color: var(--teal); font-weight: 700; }

/* ── CATEGORÍAS ── */
.jp-categorias-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.jp-cat-card {
  background: white; border-radius: var(--r); padding: 16px 8px; text-align: center;
  box-shadow: 0 6px 18px rgba(8,32,46,0.06); border: 1px solid rgba(42,174,194,0.08);
  transition: transform 0.2s, box-shadow 0.2s;
  touch-action: manipulation;
}
.jp-cat-card:active { transform: scale(0.96); box-shadow: 0 3px 10px rgba(8,32,46,0.08); }
.jp-cat-card .emoji { font-size: 1.6rem; display: block; margin-bottom: 6px; }
.jp-cat-card .nombre { font-size: 0.78rem; font-weight: 700; color: var(--text); display: block; }
.jp-cat-card .cantidad { font-size: 0.68rem; color: var(--text-soft); }

/* ── LISTA DE JUEGOS ── */
.jp-juegos-lista { display: flex; flex-direction: column; gap: 10px; }
.jp-juego-card {
  background: white; border-radius: var(--r); padding: 14px 16px;
  display: flex; align-items: center; gap: 14px;
  box-shadow: 0 4px 14px rgba(8,32,46,0.06); border: 1px solid rgba(42,174,194,0.08);
  transition: transform 0.15s;
}
.jp-juego-card .icono { font-size: 1.6rem; flex-shrink: 0; width: 42px; height: 42px; border-radius: 12px; background: var(--teal-pale); display: flex; align-items: center; justify-content: center; }
.jp-juego-card .info { flex: 1; min-width: 0; }
.jp-juego-card .info .nombre { font-weight: 700; font-size: 0.92rem; }
.jp-juego-card .info .desc { font-size: 0.78rem; color: var(--text-soft); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.jp-juego-card .meta { font-size: 0.7rem; color: var(--teal); font-weight: 700; flex-shrink: 0; }
.jp-juego-card .fav-btn { flex-shrink: 0; background: none; border: none; font-size: 1.1rem; cursor: pointer; width: 44px; height: 44px; display: flex; align-items: center; justify-content: center; transition: transform 0.15s; }
.jp-juego-card .fav-btn:active { transform: scale(0.85); }
.jp-juego-card.proximamente { opacity: 0.55; }
.jp-juego-card.proximamente .meta { color: var(--warm); }

/* ── LOGROS ── */
.jp-logros-scroll { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 6px; -webkit-overflow-scrolling: touch; }
.jp-logro-card {
  flex: 0 0 auto; width: 110px; background: white; border-radius: var(--r); padding: 14px 10px;
  text-align: center; box-shadow: 0 4px 14px rgba(8,32,46,0.06); border: 1px solid rgba(42,174,194,0.08);
}
.jp-logro-card.bloqueado { filter: grayscale(1); }
.jp-logro-card.bloqueado .emoji { opacity: 0.35; }
.jp-logro-card.bloqueado .nombre { color: #5a6570; }
.jp-logro-card .emoji { font-size: 1.6rem; display: block; margin-bottom: 6px; }
.jp-logro-card .nombre { font-size: 0.72rem; font-weight: 700; }

.jp-vacio { color: var(--text-soft); font-size: 0.85rem; text-align: center; padding: 20px; }

@media(min-width: 700px) {
  .jp-categorias-grid { grid-template-columns: repeat(4, 1fr); }
  .jp-animo-grid { grid-template-columns: repeat(4, 1fr); }
}


/* Hover con transform/scale: solo en dispositivos que de verdad tienen mouse.
   En touch, :hover se dispara con el tap y queda "pegado" hasta el próximo
   toque en otro lado — mover estas reglas acá evita ese efecto. */
@media (hover: hover) and (pointer: fine) {
  .jp-animo-btn:hover { background: var(--teal-pale); transform: translateY(-2px); }
  .jp-azar-btn:hover { transform: translateY(-2px); }
  .jp-cat-card:hover { transform: translateY(-3px); box-shadow: 0 10px 26px rgba(8,32,46,0.12); }
  .jp-juego-card:hover { transform: translateX(4px); }
}

/* después del bloque de hover, para que gane el feedback de :active si se
   hace click con mouse (hover y active a la vez, misma especificidad). */
.jp-juego-card:active { transform: scale(0.98); }