/* Ajustes para teléfonos, comunes a todos los juegos.
   Usa la altura visible real (dvh: el iPhone cuenta mal "vh" porque incluye las barras del navegador),
   compacta las tarjetas en pantallas bajitas y deja deslizar lo que no quepa. */

.tarjeta { max-height: 96vh; max-height: 96dvh; overflow: auto; -webkit-overflow-scrolling: touch; }
#inicio, #cartel { overflow: auto; touch-action: pan-y; }
#menuPausa { touch-action: pan-y; }

/* ---------- Pantallas bajitas (teléfono acostado) ---------- */
@media (max-height: 560px) {
  #inicio, #cartel {
    padding: 8px calc(8px + env(safe-area-inset-right, 0px)) 8px calc(8px + env(safe-area-inset-left, 0px));
  }
  .tarjeta { padding: 10px 20px 14px !important; gap: 6px !important; border-radius: 24px; box-shadow: 0 6px 0 rgba(13, 58, 95, .28) !important; }
  .tarjeta h1, #inicio h1 { font-size: clamp(20px, 4vw, 28px) !important; line-height: 1.1; }
  .tarjeta p, #inicio p { font-size: clamp(13px, 2.2vw, 16px) !important; line-height: 1.4; }
  .tarjeta img { height: min(30dvh, 110px) !important; }
  .grande, #jugar, #seguir { font-size: clamp(18px, 3.4vw, 24px) !important; padding: 6px 26px !important; box-shadow: 0 5px 0 rgba(0, 0, 0, .35) !important; }
  .suave, .volver { font-size: clamp(14px, 2.4vw, 18px) !important; padding: 5px 18px !important; box-shadow: 0 3px 0 #0d3a5f !important; }
  .equipo { min-width: 86px !important; padding: 4px 10px !important; font-size: 13px !important; }
  .equipo b { font-size: 28px !important; }
  .vs i { font-size: 20px !important; }
  .pista { font-size: 18px !important; }
  .ayuda { font-size: 12px !important; padding: 4px 10px !important; }
  .cat { padding: 6px 12px !important; font-size: clamp(13px, 2.2vw, 17px) !important; min-width: 0 !important; box-shadow: 0 4px 0 #0d3a5f !important; }
  .cats { gap: 6px !important; }
  .fila { gap: 8px !important; }
  #cartel .tarjeta img { height: min(22dvh, 80px) !important; }

  /* botones flotantes más chicos */
  #pausa { width: 46px !important; height: 46px !important; font-size: 20px !important; top: 8px !important; box-shadow: 0 3px 0 #0d3a5f !important; }
  #centrar { width: 46px !important; height: 46px !important; font-size: 20px !important; top: 8px !important; right: calc(66px + env(safe-area-inset-right, 0px)) !important; box-shadow: 0 3px 0 #0d3a5f !important; }
  #btnMusica { width: 42px !important; height: 42px !important; font-size: 20px !important; bottom: calc(8px + env(safe-area-inset-bottom, 0px)) !important; box-shadow: 0 3px 0 #0d3a5f !important; }
}

/* Zombis y Aventura: imagen a la izquierda, texto y botones a la derecha */
@media (max-height: 560px) and (orientation: landscape) {
  #inicio .tarjeta:has(#jugar) {
    display: grid; grid-template-columns: auto 1fr;
    grid-template-areas: "img h" "img p" "img b" "img l";
    column-gap: 18px; row-gap: 4px; align-items: center; justify-items: center; text-align: center;
  }
  #inicio .tarjeta:has(#jugar) h1 { grid-area: h; }
  #inicio .tarjeta:has(#jugar) img { grid-area: img; height: min(62dvh, 190px) !important; }
  #inicio .tarjeta:has(#jugar) p { grid-area: p; }
  #inicio .tarjeta:has(#jugar) #jugar { grid-area: b; }
  #inicio .tarjeta:has(#jugar) .volver { grid-area: l; }
  /* Acertijos: tarjeta de inicio compacta */
  #inicio .tarjeta:not(:has(#jugar)) img { height: min(18dvh, 70px) !important; }
}

/* Acertijos: pantalla de juego en teléfono acostado */
@media (max-height: 560px) and (min-width: 641px) {
  .pantalla { padding: 6px 12px !important; }
  #top { gap: 6px; }
  .ic { width: 44px !important; height: 44px !important; font-size: 20px !important; box-shadow: 0 3px 0 #0d3a5f !important; }
  #prog { padding: 4px 10px !important; font-size: 16px !important; }
  #stage img { height: min(26dvh, 90px) !important; }
  #burbuja { font-size: clamp(15px, 2.6vw, 22px) !important; padding: 8px 14px !important; }
  #big { font-size: clamp(28px, 6dvh, 44px) !important; margin-top: 2px !important; }
  .opt { width: min(22vw, 30dvh, 110px) !important; height: min(22vw, 30dvh, 110px) !important; font-size: min(8dvh, 52px) !important; border-width: 4px !important; border-radius: 20px !important; box-shadow: 0 5px 0 #0d3a5f !important; }
  #opts { padding-bottom: 8px !important; gap: 10px !important; }
}

/* Menú de juegos: tarjetas en una fila que se desliza hacia los lados */
@media (max-height: 560px) {
  main { min-height: 100dvh !important; padding: 10px 12px 64px !important; gap: 10px !important; justify-content: flex-start !important; }
  main > h1 { font-size: clamp(20px, 4vw, 30px) !important; }
  .juegos { gap: 14px !important; flex-wrap: nowrap !important; overflow-x: auto; max-width: 100%; padding: 24px 10px 12px !important; -webkit-overflow-scrolling: touch; }
  a.juego { flex: 0 0 auto; width: clamp(130px, 21vw, 200px) !important; padding: 12px 8px 10px !important; }
  a.juego img { height: min(26dvh, 90px) !important; }
  a.juego b { font-size: 15px !important; }
  a.juego span { font-size: 11px !important; }
}

/* ---------- Accesibilidad y tacto (guía ui-ux-pro-max) ---------- */
/* Foco visible para quien use teclado */
button:focus-visible, a:focus-visible {
  outline: 4px solid #0d3a5f !important; outline-offset: 3px !important; box-shadow: 0 0 0 4px #ffd43b !important;
}
/* Respetar la preferencia de menos movimiento del sistema */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}
/* Objetivos táctiles de al menos 44 px y 8 px de separación, también en pantallas bajitas */
@media (max-height: 560px) {
  .grande, #jugar, #seguir, .suave, .volver, .cat, .opcion, #menuPausa button, #menuPausa a {
    min-height: 44px; display: inline-flex; align-items: center; justify-content: center; box-sizing: border-box;
  }
  #btnMusica { width: 44px !important; height: 44px !important; }
  .cats { gap: 8px !important; }
  .tarjeta p, #inicio p { font-size: clamp(14px, 2.4vw, 17px) !important; }
  #cartel .tarjeta img { height: min(18dvh, 64px) !important; }
}
