/* Juegos Cristal — un salón de cristal pastel: fondo iridiscente, cristales flotando y tarjetas de vidrio con una joya por juego */
:root {
  --ink: #3b2a5a;
  --muted: #7d6b99;
  --deep: #6a4fc4;
  --pink: #ff8fb8;
  --pink-deep: #e2658f;
  --aqua: #7fdde6;
  --lilac: #b9a3f0;
  --gold: #ffd86b;
  --glass: rgba(255, 255, 255, 0.66);
  --edge: rgba(255, 255, 255, 0.9);
  --shadow: 0 10px 30px rgba(106, 79, 196, 0.16);
  --font-display: 'Mochiy Pop One', 'Arial Rounded MT Bold', system-ui, sans-serif;
  --font-body: 'M PLUS Rounded 1c', 'Trebuchet MS', system-ui, sans-serif;
  color-scheme: light;
}
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { min-height: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  background: linear-gradient(135deg, #f1e6ff 0%, #def6fa 48%, #ffe6f2 100%) fixed;
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.45;
}
a { color: var(--deep); font-weight: 800; }
button, input { font: inherit; }
:focus-visible { outline: 3px solid var(--deep); outline-offset: 3px; }

/* Cristales del fondo */
.cielo { position: fixed; inset: 0; overflow: hidden; pointer-events: none; z-index: 0; }
.cristal {
  position: absolute;
  width: 90px; height: 120px;
  clip-path: polygon(50% 0, 100% 30%, 82% 100%, 18% 100%, 0 30%);
  background: linear-gradient(140deg, rgba(255, 255, 255, 0.9), rgba(185, 163, 240, 0.55) 45%, rgba(127, 221, 230, 0.55) 70%, rgba(255, 143, 184, 0.5));
  opacity: 0.55;
  animation: flotar 12s ease-in-out infinite;
}
.c1 { left: 4%; top: 12%; transform: rotate(-14deg); }
.c2 { right: 6%; top: 8%; width: 60px; height: 82px; animation-delay: -3s; }
.c3 { left: 12%; bottom: 8%; width: 70px; height: 96px; animation-delay: -6s; }
.c4 { right: 14%; bottom: 14%; width: 110px; height: 150px; animation-delay: -2s; }
.c5 { left: 46%; top: 3%; width: 40px; height: 54px; animation-delay: -8s; }
.c6 { right: 38%; bottom: 3%; width: 50px; height: 68px; animation-delay: -4s; }
@keyframes flotar { 50% { translate: 0 -18px; rotate: 6deg; } }

/* Joya del logo */
.gema-logo {
  display: inline-block;
  width: 34px; height: 30px;
  clip-path: polygon(22% 0, 78% 0, 100% 32%, 50% 100%, 0 32%);
  background:
    linear-gradient(115deg, transparent 38%, rgba(255, 255, 255, 0.85) 40%, transparent 48%),
    conic-gradient(from 200deg at 50% 40%, #ff9ec7, #b9a3f0, #7fdde6, #ffe08a, #ff9ec7);
  filter: drop-shadow(0 3px 0 rgba(106, 79, 196, 0.25));
  flex: none;
}
.gema-logo.grande { width: 92px; height: 80px; }
.gema-logo.girando { animation: brillar 1.6s ease-in-out infinite; }
@keyframes brillar { 50% { transform: scale(1.08) rotate(4deg); filter: drop-shadow(0 6px 10px rgba(106, 79, 196, 0.35)); } }

/* Botones */
.boton {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 18px;
  border-radius: 999px;
  border: 2px solid var(--edge);
  font-weight: 800;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
}
.boton.principal {
  border: none;
  padding: 14px 26px;
  background: linear-gradient(135deg, var(--pink), #b98bff);
  color: #fff;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 1.1rem;
  box-shadow: 0 5px 0 rgba(106, 79, 196, 0.35);
}
.boton.principal:active { transform: translateY(3px); box-shadow: 0 2px 0 rgba(106, 79, 196, 0.35); }
.boton.suave { background: var(--glass); color: var(--ink); }

/* ---------- Entrada ---------- */
.entrada { position: relative; z-index: 1; min-height: 100vh; display: flex; padding: 24px 16px; }
.tarjeta-entrada {
  margin: auto;
  width: min(440px, 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 30px 24px;
  border-radius: 32px;
  background: var(--glass);
  border: 2px solid var(--edge);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  text-align: center;
}
.marca-titulo {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(2rem, 8vw, 2.6rem);
  line-height: 1.1;
  color: var(--deep);
}
.marca-titulo b, .marca b {
  font-weight: 400;
  background: linear-gradient(90deg, #ff6fa5, #a26bff, #2fb8d6);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.lema { margin: 0; color: var(--muted); font-weight: 700; }
.pestanas { display: flex; gap: 6px; padding: 5px; border-radius: 999px; background: rgba(255, 255, 255, 0.6); }
.pestanas a { padding: 8px 18px; border-radius: 999px; text-decoration: none; color: var(--muted); }
.pestanas a.activa { background: #fff; color: var(--deep); box-shadow: 0 2px 8px rgba(106, 79, 196, 0.15); }
.aviso {
  width: 100%;
  padding: 10px 14px;
  border-radius: 16px;
  background: #ffe3ec;
  color: #a8325c;
  font-weight: 700;
  text-align: left;
}
.aviso p { margin: 0; }
.aviso p + p { margin-top: 4px; }
.formulario { width: 100%; display: flex; flex-direction: column; gap: 6px; text-align: left; }
.formulario label { font-weight: 800; font-size: 0.9rem; color: var(--muted); margin-top: 6px; }
.formulario input:not([type="radio"]) {
  width: 100%;
  padding: 12px 14px;
  border-radius: 16px;
  border: 2px solid rgba(106, 79, 196, 0.18);
  background: #fff;
  color: var(--ink);
  font-weight: 700;
  font-size: 1rem;
}
.formulario .boton.principal { margin-top: 14px; align-self: stretch; }
.avatares { margin: 8px 0 0; padding: 0; border: none; display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
.avatares legend { padding: 0; margin-bottom: 6px; font-weight: 800; font-size: 0.9rem; color: var(--muted); }
.avatar-opcion { position: relative; margin: 0 !important; }
.avatar-opcion input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.avatar-opcion span {
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  border-radius: 14px;
  background: #fff;
  border: 2px solid rgba(106, 79, 196, 0.12);
  font-size: 1.5rem;
}
.avatar-opcion input:checked + span { border-color: var(--deep); background: #f1e9ff; box-shadow: 0 0 0 3px rgba(106, 79, 196, 0.18); }
.avatar-opcion input:focus-visible + span { outline: 3px solid var(--deep); outline-offset: 2px; }
.nota { margin: 0; color: var(--muted); font-weight: 700; font-size: 0.92rem; }

/* ---------- Galería ---------- */
.barra {
  position: sticky;
  top: 0;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  background: rgba(255, 255, 255, 0.55);
  border-bottom: 2px solid var(--edge);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
.marca { display: flex; align-items: center; gap: 10px; text-decoration: none; font-family: var(--font-display); font-weight: 400; font-size: 1.25rem; color: var(--deep); }
.yo { display: flex; align-items: center; gap: 8px; font-weight: 800; min-width: 0; }
.avatar { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 50%; background: #fff; border: 2px solid var(--edge); font-size: 1.3rem; flex: none; }
.yo-nombre { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.contenido { position: relative; z-index: 1; width: min(1100px, 100%); margin: 0 auto; padding: 24px 16px 40px; }
.saludo h1 { margin: 0; font-family: var(--font-display); font-weight: 400; font-size: clamp(1.8rem, 6vw, 2.5rem); color: var(--deep); text-wrap: balance; }
.saludo p { margin: 6px 0 0; color: var(--muted); font-weight: 700; }
.filtros { display: flex; flex-wrap: wrap; gap: 8px; margin: 16px 0 20px; }
.filtro { padding: 8px 16px; border-radius: 999px; border: 2px solid var(--edge); background: var(--glass); color: var(--ink); font-weight: 800; cursor: pointer; }
.filtro.activo { background: var(--deep); border-color: var(--deep); color: #fff; }
.juegos { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 18px; }
.tarjeta {
  display: flex;
  flex-direction: column;
  border-radius: 28px;
  background: var(--glass);
  border: 2px solid var(--edge);
  box-shadow: var(--shadow);
  overflow: hidden;
  text-decoration: none;
  color: var(--ink);
  font-weight: 500;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.tarjeta:hover { transform: translateY(-5px); box-shadow: 0 16px 36px rgba(106, 79, 196, 0.24); }
.joya {
  position: relative;
  height: 140px;
  display: grid;
  place-items: center;
  background:
    linear-gradient(120deg, transparent 30%, rgba(255, 255, 255, 0.45) 31%, transparent 44%),
    linear-gradient(60deg, transparent 58%, rgba(255, 255, 255, 0.3) 59%, transparent 70%),
    linear-gradient(135deg, var(--c1), var(--c2));
}
.joya::after {
  content: '';
  position: absolute;
  inset: 14px;
  clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%);
  background: rgba(255, 255, 255, 0.22);
}
.joya .emoji { position: relative; z-index: 1; font-size: 64px; line-height: 1; filter: drop-shadow(0 6px 6px rgba(0, 0, 0, 0.18)); transition: transform 0.2s ease; }
.tarjeta:hover .emoji { transform: scale(1.12) rotate(-6deg); }
.info { display: flex; flex-direction: column; gap: 6px; padding: 14px 16px 16px; flex: 1; }
.info h2 { margin: 0; font-family: var(--font-display); font-weight: 400; font-size: 1.12rem; color: var(--deep); }
.info p { margin: 0; font-size: 0.92rem; color: var(--muted); font-weight: 700; flex: 1; }
.meta { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px; margin-top: 4px; }
.chip { padding: 3px 10px; border-radius: 999px; background: #fff; font-size: 0.78rem; font-weight: 800; color: var(--deep); }
.cuando { font-size: 0.78rem; font-weight: 800; color: var(--muted); }
.cuando.nuevo { color: var(--pink-deep); }
.pie { position: relative; z-index: 1; padding: 0 16px 28px; text-align: center; color: var(--muted); font-weight: 700; font-size: 0.9rem; }

/* ---------- Jugando ---------- */
body.jugando { height: 100vh; height: 100dvh; display: grid; grid-template-rows: auto 1fr; overflow: hidden; }
.barra-juego {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  background: linear-gradient(90deg, var(--c1), var(--c2));
  color: #fff;
  min-width: 0;
}
.barra-juego .boton.suave { background: rgba(255, 255, 255, 0.85); border-color: transparent; padding: 7px 14px; }
.titulo-juego { flex: 1; min-width: 0; font-family: var(--font-display); font-size: 1rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-shadow: 0 2px 0 rgba(0, 0, 0, 0.15); }
.estado { flex: none; padding: 4px 10px; border-radius: 999px; background: rgba(255, 255, 255, 0.85); color: var(--muted); font-size: 0.78rem; font-weight: 800; }
.estado.ok { color: #2f8f5b; }
.estado.mal { color: #c2405f; }
.barra-juego .avatar { width: 34px; height: 34px; font-size: 1.1rem; }
.marco { position: relative; min-height: 0; }
.marco iframe { display: block; width: 100%; height: 100%; border: 0; background: #fff; }
.cargando {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 16px;
  background: linear-gradient(135deg, #f1e6ff 0%, #def6fa 48%, #ffe6f2 100%);
  text-align: center;
  font-weight: 800;
  color: var(--muted);
}
.cargando p { margin: 0; max-width: 34ch; }

/* Instalar app */
.boton.instalar {
  border: none;
  background: linear-gradient(135deg, var(--pink), #b98bff);
  color: #fff;
  box-shadow: 0 3px 0 rgba(106, 79, 196, 0.35);
}
.icono-app { width: 72px; height: 72px; border-radius: 18px; box-shadow: 0 6px 16px rgba(106, 79, 196, 0.25); }
.pasos { margin: 0; padding: 0 0 0 1.4em; text-align: left; display: flex; flex-direction: column; gap: 8px; font-weight: 700; }
.pasos b { color: var(--deep); }
.icono-compartir { display: inline-grid; place-items: center; width: 1.6em; height: 1.6em; border-radius: 6px; background: #eaf3ff; color: #2f7be0; font-weight: 800; }

/* Botón Guardar y usuario */
.boton.guardar {
  border: none;
  padding: 8px 16px;
  background: #fff;
  color: var(--deep);
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.15);
}
.boton.guardar:active { transform: translateY(2px); box-shadow: 0 1px 0 rgba(0, 0, 0, 0.15); }
.usuario-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.85);
  color: var(--ink);
  font-weight: 800;
  font-size: 0.85rem;
  white-space: nowrap;
}
.usuario-chip a { font-size: 0.78rem; }
.boton.chico { padding: 10px 18px; font-size: 0.95rem; }
.fila { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }

/* Aviso de partida guardada y mensajes */
.banner {
  position: absolute;
  left: 50%;
  top: 12px;
  transform: translateX(-50%);
  width: min(460px, calc(100% - 32px));
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px 16px;
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.95);
  border: 2px solid #fff;
  box-shadow: var(--shadow);
  text-align: center;
  font-weight: 800;
  z-index: 4;
}
.banner p { margin: 0; }
.toast {
  position: absolute;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  width: max-content;
  max-width: calc(100% - 32px);
  padding: 12px 18px;
  border-radius: 18px;
  background: var(--deep);
  color: #fff;
  font-weight: 800;
  text-align: center;
  box-shadow: 0 10px 26px rgba(106, 79, 196, 0.35);
  z-index: 4;
}

/* Ventana de usuario + PIN */
.modal {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  padding: 16px;
  overflow-y: auto;
  background: rgba(59, 42, 90, 0.4);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.tarjeta-modal {
  position: relative;
  margin: auto;
  width: min(420px, 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 26px 22px 24px;
  border-radius: 30px;
  background: #fffbff;
  border: 2px solid #fff;
  box-shadow: 0 20px 50px rgba(59, 42, 90, 0.3);
  text-align: center;
}
.tarjeta-modal h2 { margin: 0; font-family: var(--font-display); font-weight: 400; font-size: 1.5rem; color: var(--deep); }
.tarjeta-modal .gema-logo.grande { width: 64px; height: 56px; }
.cerrar {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: none;
  background: #f1e9ff;
  color: var(--deep);
  font-weight: 800;
  cursor: pointer;
}
.pestanas button {
  padding: 8px 14px;
  border: none;
  border-radius: 999px;
  background: none;
  color: var(--muted);
  font-weight: 800;
  cursor: pointer;
}
.pestanas button.activa { background: #fff; color: var(--deep); box-shadow: 0 2px 8px rgba(106, 79, 196, 0.15); }
.m-ayuda { margin: 0; color: var(--muted); font-weight: 700; font-size: 0.92rem; }
#mPin { letter-spacing: 0.5em; font-size: 1.3rem; text-align: center; }
.conflicto { display: flex; flex-direction: column; gap: 12px; font-weight: 700; }
.conflicto p { margin: 0; }

@media (max-width: 560px) {
  .marca span:last-child { font-size: 1.05rem; }
  .yo-nombre { display: none; }
  .estado { display: none; }
  .barra { flex-wrap: wrap; }
  .yo { flex-wrap: wrap; justify-content: flex-end; }
  .barra-juego { gap: 6px; padding-inline: 12px; }
  .barra-juego .usuario-chip a { display: none; }
  .titulo-juego { font-size: 0.9rem; }
  .avatares { grid-template-columns: repeat(4, 1fr); }
  .juegos { grid-template-columns: 1fr; }
  .joya { height: 120px; }
}
@media (prefers-reduced-motion: reduce) {
  .cristal, .gema-logo.girando { animation: none; }
  .tarjeta, .joya .emoji { transition: none; }
}
