/* =====================================================================
 * PilcheroManager - mobile.css v2
 * PWA ONLINE-ONLY + mejoras mobile-first (spec del usuario).
 * IMPORTANTE: el Service Worker (sw.js) NO cachea nada (online-only) —
 * el juego siempre necesita internet para que los anuncios carguen.
 *
 * ADAPTACIONES sobre el CSS original del paste (para no romper el
 * diseño existente, que usa utilidades Tailwind cargadas por CDN):
 *  - #app SIN padding ni max-width forzados: cada pantalla maneja su
 *    propio espaciado y la pantalla del partido necesita ancho full
 *    (el paste pedía padding 8/16/24px y max-width 1200px).
 *  - Botones: min-height 44px SOLO en .btn (chips y btn-xs/btn-sm
 *    conservan su tamaño compacto); sin min-width global ni font-size
 *    forzado (rompían chips, topbar y tablas).
 *  - Scrollbar: se oculta SOLO en mobile; en desktop se conserva el
 *    diseño propio del juego (9px crema).
 *  - p/span/div con clamp: las utilidades Tailwind y los estilos
 *    inline de JS ganan por especificidad, así que solo afecta texto
 *    sin clase propia.
 *  - Las clases .match-live/.scoreboard/.mobile-nav/etc. no existen en
 *    el juego todavía: se dejan listas por si se usan más adelante.
 * ===================================================================== */

/* ===== LAUNCHER (pantalla de inicio) ===== */
@media (max-width: 600px) {
  /* orbes del launcher: el blur(64px) + animación infinita en pantallas
     chicas cuesta caro (re-pinta un área enorme en cada frame). En móvil
     se quedan quietos y con blur mínimo: el degradado se ve igual, el
     lag desaparece. */
  .lm-orb { filter: blur(0) !important; animation: none !important; }
  /* barra superior: una sola fila compacta, sin que el brand se envuelva */
  .landing > div:first-child { flex-wrap: nowrap; padding: 10px 12px; }
  .landing > div:first-child .l-brand { font-size: 14px; white-space: nowrap; }
  /* ocultar el subtítulo del brand ("· Carrera · Versus · Subasta") en
     pantallas chicas: deja el ⚽ Pilchero en una sola línea */
  .landing > div:first-child .l-brand span { display: none; }
  /* aire arriba del hero para que el título no quede debajo de la barra */
  .landing > .relative.z-10 > .text-center:first-child { padding-top: 60px; }
  /* tarjetas de modo más compactas en vertical */
  .lm-card { padding: 14px; }
  .lm-card-desc { font-size: 12.5px; }
  .lm-go { padding-top: 14px; }
}

/* ===== MOBILE FIRST ===== */
* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  overflow-x: hidden;
  width: 100%;
  touch-action: manipulation;
}

/* Contenedor principal (sin padding forzado: cada pantalla lo maneja) */
#app {
  width: 100%;
  min-height: 100vh;
}

/* =====================================================================
 * TIPOGRAFÍA RESPONSIVE — escala fluida para móvil
 * Clamp garantisza tamaño mínimo legible + crecimiento proporcional.
 * h1/h2 usan vw para ser fluidos; el max-width evita que crezcan
 * demasiado en tablets grandes.
 * ===================================================================== */
h1 {
  font-size: clamp(1.35rem, 5.5vw, 2.2rem);
  line-height: 1.15;
  letter-spacing: -0.025em;
  font-weight: 800;
}
h2 {
  font-size: clamp(1.15rem, 4.2vw, 1.75rem);
  line-height: 1.2;
  letter-spacing: -0.02em;
  font-weight: 700;
}
h3 {
  font-size: clamp(1rem, 3.5vw, 1.4rem);
  line-height: 1.25;
  font-weight: 700;
}
p {
  font-size: clamp(0.875rem, 3vw, 0.95rem);
  line-height: 1.55;
}
span, label, li {
  font-size: clamp(0.8rem, 2.8vw, 0.9rem);
  line-height: 1.45;
}
small, .text-xs {
  font-size: clamp(0.7rem, 2.2vw, 0.8rem) !important;
  line-height: 1.4;
}

/* Botones: área táctil mínima en los principales, chips compactos intactos */
.btn { min-height: 44px; }
.btn-xs, .btn-sm { min-height: auto; }

/* Inputs 16px: evita el zoom automático de iOS al enfocar */
input, select, textarea {
  font-size: 16px;
  padding: 12px;
  border-radius: 8px;
}

/* Tabla de posiciones scrollable */
.table-container {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* Escudos y logos */
.team-logo, .player-avatar {
  width: clamp(32px, 8vw, 64px);
  height: clamp(32px, 8vw, 64px);
}

/* Barra de navegación inferior (tipo app) */
.mobile-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 60px;
  display: flex;
  justify-content: space-around;
  align-items: center;
  background: var(--bg-dark);
  border-top: 1px solid var(--border);
  z-index: 1000;
  padding-bottom: env(safe-area-inset-bottom);
}
.mobile-nav button {
  flex: 1;
  background: none;
  border: none;
  color: var(--text);
  font-size: 0.75rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

/* ===== PARTIDO EN VIVO (mobile) ===== */
.match-live { display: flex; flex-direction: column; gap: 12px; }
.scoreboard { display: flex; justify-content: space-between; align-items: center; padding: 16px; }
.team-side { display: flex; flex-direction: column; align-items: center; gap: 8px; flex: 1; }
.vs-center { font-size: 1.5rem; font-weight: bold; padding: 0 16px; }

/* Narración scrollable */
.narration-box {
  max-height: 40vh;
  overflow-y: auto;
  padding: 12px;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 12px;
}

/* Stats en grid de 2 columnas */
.stats-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.stat-item { text-align: center; padding: 8px; background: rgba(255, 255, 255, 0.05); border-radius: 8px; }

/* Decisiones en stack vertical */
.decisions-container { display: flex; flex-direction: column; gap: 8px; }
.decision-btn { width: 100%; text-align: left; padding: 16px; }

/* ===== TOUCH-FRIENDLY ===== */
/* Swipe para navegar */
.swipe-container { touch-action: pan-y; user-select: none; }

/* Prevenir zoom en doble tap */
* { touch-action: manipulation; }

/* Scrollbar oculta SOLO en mobile (en desktop se conserva el diseño propio) */
@media (max-width: 600px) {
  ::-webkit-scrollbar { width: 0; height: 0; }
}

/* =====================================================================
 * MÓVIL: MEJORAS DE TIPOGRAFÍA Y ESPACIADO
 * Ajustes específicos para pantallas ≤600px.
 * ===================================================================== */
@media (max-width: 600px) {
  /* --- TÍTULOS: más compactos, mejor legibilidad --- */
  h1 {
    font-size: clamp(1.3rem, 6vw, 1.65rem);
    line-height: 1.12;
    letter-spacing: -0.03em;
    margin-bottom: 0.5em;
  }
  h2 {
    font-size: clamp(1.1rem, 5vw, 1.4rem);
    line-height: 1.18;
    letter-spacing: -0.02em;
  }
  h3 {
    font-size: clamp(0.95rem, 4.2vw, 1.15rem);
    line-height: 1.22;
  }
  p {
    font-size: 0.875rem;
    line-height: 1.6;
  }
  span, label, li {
    font-size: 0.82rem;
    line-height: 1.45;
  }
  small, .text-xs {
    font-size: 0.72rem !important;
  }
  /* --- FUENTES DISPLAY (títulos de pantalla, scores, etc.) --- */
  .font-display {
    letter-spacing: -0.03em;
    font-weight: 800;
  }
  /* --- BOTONES: más grandes para dedos --- */
  .btn {
    min-height: 44px;
    padding: 0.65rem 1.2rem;
    font-size: 0.85rem;
    font-weight: 800;
    border-radius: 0.75rem;
  }
  .btn-sm {
    min-height: 38px;
    padding: 0.5rem 1rem;
    font-size: 0.8rem;
  }
  .btn-xs {
    min-height: 34px;
    padding: 0.4rem 0.8rem;
    font-size: 0.75rem;
  }
  /* --- TARJETAS: más aire interior --- */
  .stat-pill, .mode-card {
    padding: 0.85rem;
    border-radius: 0.9rem;
  }
  /* --- TOASTS: más legibles --- */
  .toast {
    font-size: 0.82rem;
    padding: 0.8rem 1.1rem;
    border-radius: 0.85rem;
    max-width: 92vw;
    min-width: 200px;
  }
  /* --- INPUTS: más altos para tocar --- */
  .input {
    padding: 0.7rem 0.95rem;
    font-size: 0.9rem;
    border-radius: 0.7rem;
    min-height: 44px;
  }
  /* --- TABLAS: texto más compacto pero legible --- */
  table {
    font-size: 0.78rem;
  }
  th {
    font-size: 0.72rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.06em;
  }
  td {
    padding: 0.5rem 0.4rem;
  }
  /* --- FEED DEL PARTIDO: más compacto --- */
  #match-feed {
    font-size: 0.8rem;
    line-height: 1.5;
  }
  /* --- NAV ITEMS: más grandes para tocar --- */
  .nav-item {
    padding: 0.7rem 0.9rem;
    font-size: 0.85rem;
    font-weight: 600;
  }
  /* --- SUBASTA: botones de puja más grandes --- */
  .sa-bid-btn {
    min-height: 42px;
    font-size: 0.82rem;
    font-weight: 800;
    border-radius: 0.7rem;
  }
  .sa-inc-chip {
    min-height: 36px;
    font-size: 0.75rem;
    font-weight: 700;
    padding: 0.35rem 0.7rem;
  }
  /* --- CARRERA DE JUGADOR --- */
  .pc-shirt-text {
    font-size: clamp(1.2rem, 5vw, 1.8rem);
  }
  /* --- LANDING: títulos y stats más legibles --- */
  .l-title {
    font-size: clamp(1.8rem, 8vw, 2.5rem);
    line-height: 1.08;
    letter-spacing: -0.04em;
  }
  .l-sub {
    font-size: 0.85rem;
    line-height: 1.5;
  }
  .l-stat-n {
    font-size: clamp(1.1rem, 4vw, 1.4rem);
  }
  .l-stat-l {
    font-size: 0.65rem;
  }
  .l-chip {
    font-size: 0.72rem;
    padding: 0.3rem 0.55rem;
  }
  /* --- MODE CARDS: mejor legibilidad --- */
  .mode-card {
    padding: 0.9rem;
  }
  /* --- SCROLL HORIZONTAL SMOOTH --- */
  .table-container {
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x proximity;
  }
  .table-container > * {
    scroll-snap-align: start;
  }
  /* --- MEJOR ESPACIADO ENTRE SECCIONES --- */
  .space-y-2 > * + *, .space-y-3 > * + *, .space-y-4 > * + * {
    margin-top: 0.6rem;
  }
  /* --- MODALES: más grande en móvil para legibilidad --- */
  .rounded-2xl {
    border-radius: 1rem !important;
    margin: 0.5rem;
    max-height: 92vh;
    overflow-y: auto;
  }
}

/* =====================================================================
 * TAP TARGETS EN MÓVIL — mínimos táctiles
 * En pantallas táctiles los botones por debajo de ~40px son difíciles
 * de tocar: se suben los mínimos SOLO en mobile (desktop no cambia).
 * ===================================================================== */
@media (max-width: 600px) {
  .btn-sm { min-height: 38px; }
  .btn-xs { min-height: 34px; }
  .lm-back { min-height: 44px; }
  .lang-seg-btn { min-height: 30px; }
  .fb-btn { min-height: 40px; }
  .fb-lang-btn { min-height: 30px; }
  .cp-picker-row { min-height: 40px; }
  .topbar-burger { min-height: 40px; }
  .sa-bid-btn { min-height: 38px; }
  .sa-inc-chip { min-height: 34px; }
  .sa-skip-global { min-height: 34px; }
  /* --- TEXTOS PEQUEÑOS: subir tamaño mínimo para legibilidad --- */
  .text-\[8px\] { font-size: 11px !important; }
  .text-\[9px\] { font-size: 12px !important; }
}

/* =====================================================================
 * TABLET (601–900px): escalado intermedio
 * ===================================================================== */
@media (min-width: 601px) and (max-width: 900px) {
  h1 { font-size: clamp(1.5rem, 4.5vw, 2rem); }
  h2 { font-size: clamp(1.2rem, 3.8vw, 1.6rem); }
  .card { padding: 16px; }
}

/* =====================================================================
 * TÁCTICAS / ALINEACIÓN — mobile
 * ===================================================================== */
@media (max-width: 600px) {
  /* pitch: ancho completo, aspect ratio más compacto */
  .pitch {
    max-width: 100% !important;
    border-radius: 0.75rem;
    aspect-ratio: 4 / 5 !important;
  }
  /* avatares en cancha: más chicos en móvil pero inicial grande */
  .pitch-avatar {
    width: 40px !important;
    height: 40px !important;
    font-size: 18px !important;
    border-width: 2px !important;
  }
  /* badges de posición: más chicos */
  .pitch-pos-badge {
    font-size: 7px !important;
    padding: 1px 4px !important;
    top: -7px !important;
  }
  /* badge de rating: más chico */
  .pitch-ov-badge {
    width: 18px !important;
    height: 18px !important;
    font-size: 8px !important;
    border-width: 1.5px !important;
    bottom: -2px !important;
    right: -2px !important;
  }
  /* nombre del jugador: más chico */
  .pitch-name {
    font-size: 8px !important;
    max-width: 56px !important;
    margin-top: 1px !important;
  }
  /* indicadores capitán/penalización */
  .pitch-chip .absolute { font-size: 9px !important; }
  /* filas del banco: más compactas */
  .bench-row {
    padding: 5px 8px !important;
    gap: 8px !important;
    border-radius: 8px !important;
  }
  /* botón info del banco: área táctil mínima */
  .bench-row button {
    min-width: 32px;
    min-height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  /* botones de formación/estilo: scroll horizontal */
  #screen .flex-wrap {
    overflow-x: auto;
    flex-wrap: nowrap !important;
    -webkit-overflow-scrolling: touch;
    gap: 6px !important;
    padding-bottom: 4px;
  }
  #screen .flex-wrap > span {
    white-space: nowrap;
    flex-shrink: 0;
  }
  #screen .btn-xs {
    font-size: 11px !important;
    padding: 4px 8px !important;
    min-height: 30px !important;
    flex-shrink: 0;
  }
  /* hint: más compacto */
  #screen .text-\[10px\] {
    font-size: 10px !important;
    line-height: 1.4 !important;
  }
  /* grid: gap más compacto en móvil */
  #screen .grid {
    gap: 10px !important;
  }
}

/* =====================================================================
 * DESKTOP (901px+)
 * ===================================================================== */
@media (min-width: 901px) {
  .card { padding: 24px; }
}

/* =====================================================================
 * ANIMACIONES MEJORADAS MOBILE
 * ===================================================================== */
@media (max-width: 600px) {
  /* feed: entradas más rápidas en mobile */
  #match-feed > div { animation-duration: .2s; }
  
  /* botones: área táctil más grande */
  .btn { min-height: 44px; }
  
  /* transiciones más suaves para touch */
  * { -webkit-tap-highlight-color: transparent; }
  
  /* scroll horizontal suave para chips de formación */
  .flex.gap-2 {
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x mandatory;
  }
  .flex.gap-2 > * { scroll-snap-align: start; }
}


/* =====================================================================
 * v6 - MOBILE UI POLISH
 * Mejores transiciones, mejoras de touch, mejor contraste dark mode.
 * ===================================================================== */

@media (max-width: 600px) {
  /* --- Transiciones mas suaves en touch --- */
  .btn { transition: all .18s cubic-bezier(.4,0,.2,1); }
  .btn:active { transform: scale(.96); }

  /* --- Cards: mas aire y mejor sombra --- */
  .stat-pill {
    padding: 0.8rem 0.9rem;
    border-radius: 0.85rem;
    box-shadow: 0 2px 8px rgba(15,23,42,.06);
  }
  .stat-pill:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 14px rgba(15,23,42,.08);
  }

  /* --- Modales: mejor espaciado --- */
  .rounded-2xl {
    border-radius: 1rem !important;
    margin: 0.4rem;
    max-height: 94vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* --- Feed: lineas mas compactas --- */
  #match-feed > div {
    padding: 0.3rem 0.5rem;
    margin: 0.1rem 0;
    font-size: 0.78rem;
    line-height: 1.4;
  }

  /* --- Scoreboard: mas compacto --- */
  .score-pulse {
    animation-duration: 0.5s;
  }

  /* --- Botones de decision: mejor touch --- */
  .btn-decision {
    padding: 0.7rem 0.85rem;
    min-height: 44px;
  }

  /* --- Inputs: padding generoso --- */
  .input {
    min-height: 44px;
    padding: 0.65rem 0.9rem;
    font-size: 0.88rem;
  }

  /* --- Pitch: avatar mas grande en movil --- */
  .pitch-avatar {
    box-shadow: 0 2px 8px rgba(0,0,0,.5);
  }

  /* --- Sidebar items: mas grandes para tocar --- */
  .sb-nav-item {
    padding: 0.65rem 0.8rem;
    min-height: 42px;
  }

  /* --- Toast: mas legible --- */
  .toast {
    font-size: 0.8rem;
    padding: 0.7rem 1rem;
    max-width: 90vw;
  }

  /* --- Dark mode: mejor contraste en movil --- */
  body.dark-mode .stat-pill {
    background: linear-gradient(160deg, rgba(30,41,59,.92), rgba(15,23,42,.82));
    border-color: rgba(51,65,85,.4);
  }
  body.dark-mode #fm-modal .rounded-2xl {
    box-shadow: 0 20px 50px -10px rgba(0,0,0,.7);
  }

  /* --- Scroll horizontal para chips --- */
  .flex-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x proximity;
    padding-bottom: 2px;
  }
  .flex-wrap > * { scroll-snap-align: start; flex-shrink: 0; }

  /* --- Landing: mejor header compacto --- */
  .l-title {
    line-height: 1.08;
    letter-spacing: -0.04em;
  }
  .l-stat {
    padding: 0.6rem 0.7rem;
  }

  /* --- Reduced motion --- */
  @media (prefers-reduced-motion: reduce) {
    .btn, .stat-pill, .rounded-2xl {
      transition-duration: 0.01ms !important;
    }
  }
}

/* =====================================================================
 * COPA PEPA VERSUS — MOBILE
 * Mejoras específicas para el modo Versus en pantallas ≤600px.
 * ===================================================================== */
@media (max-width: 600px) {
  /* --- SETUP: formación grid 2 cols, más compacto --- */
  #app .grid-cols-3 { grid-template-columns: repeat(2, 1fr) !important; }
  #app .grid-cols-4 { grid-template-columns: repeat(2, 1fr) !important; }
  #app .sm\:grid-cols-4 { grid-template-columns: repeat(2, 1fr) !important; }

  /* --- DRAFT: cancha más chica, candidatos apilados --- */
  .cp-pitch-stretch {
    min-height: 280px !important;
    max-height: 45vh !important;
  }
  .cp-pitch {
    border-radius: 1rem !important;
    max-height: 50vh !important;
  }
  /* candidatos: cards más compactas */
  #app .flex.flex-col.gap-2 > button,
  #app .flex.flex-col.gap-3 > button {
    padding: 8px 10px !important;
    gap: 8px !important;
  }
  /* OVR badge más chico */
  #app .w-10.h-10.rounded-full {
    width: 34px !important;
    height: 34px !important;
    font-size: 13px !important;
  }
  /* timer más chico */
  #app .w-16.h-16 {
    width: 52px !important;
    height: 52px !important;
  }
  /* header del draft: más compacto */
  #app .font-display.text-xl {
    font-size: 1.1rem !important;
  }
  /*--- aviso turno --- */
  #app .text-sm.font-black.text-center {
    font-size: 0.78rem !important;
    padding: 8px 12px !important;
  }

  /* --- LIVE MATCH: feed y layout --- */
  #vs-feed {
    max-height: 200px !important;
    font-size: 0.78rem !important;
  }
  #vs-live-score {
    font-size: 2rem !important;
  }
  /* controles de velocidad */
  #app .btn.btn-xs {
    min-height: 32px !important;
    font-size: 11px !important;
    padding: 4px 10px !important;
  }

  /* --- RESULT: más compacto --- */
  #app .text-5xl { font-size: 2.5rem !important; }
  #app .text-4xl { font-size: 2rem !important; }
  #app .text-3xl { font-size: 1.5rem !important; }

  /* --- TEAMS BAR: vertical en móvil --- */
  #app .sm\:flex-row { flex-direction: column !important; }

  /* --- GRID draft: cancha arriba, candidatos abajo --- */
  #app .lg\:grid-cols-\[1\.15fr_1fr\] {
    grid-template-columns: 1fr !important;
  }
}

/* =====================================================================
 * VERSUS EN TABLET (601–900px)
 * ===================================================================== */
@media (min-width: 601px) and (max-width: 900px) {
  .cp-pitch-stretch {
    min-height: 400px !important;
    max-height: 60vh !important;
  }
  #vs-feed {
    max-height: 260px !important;
  }
}

/* =====================================================================
 * VERSUS: MOBILE POLISH — fluidez y animaciones
 * ===================================================================== */
@media (max-width: 600px) {
  /* scroll suave en todo el versus */
  #app { -webkit-overflow-scrolling: touch; }

  /* score: transición suave al cambiar */
  #vs-live-score {
    transition: transform .3s cubic-bezier(.22,1,.36,1), filter .35s ease;
    will-change: transform;
  }

  /* feed: transición suave */
  #vs-feed > div {
    animation-duration: .22s !important;
  }

  /* candidate cards: feedback táctil mejorado */
  #app button[style*="border-2"] {
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
  }

  /* head y bottom bar: backdrop blur para profundidad */
  .sticky {
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
  }

  /* formación grid: animación stagger */
  #app .grid-cols-3 button,
  #app .grid-cols-4 button,
  #app .sm\:grid-cols-4 button {
    animation: cardIn .35s cubic-bezier(.22,1,.36,1) both;
  }

  /* resultado: entrada suave */
  #app .max-w-2xl {
    animation: screenIn .3s ease-out both;
  }

  /* pitch: sombra sutil para profundidad */
  .cp-pitch-stretch {
    box-shadow: 0 8px 32px rgba(0,0,0,.3);
    border-radius: 1rem;
  }

  /* live match grid: layout optimizado */
  #app .grid-cols-1.md\:grid-cols-\[1\.1fr_1fr\] {
    gap: 12px !important;
  }

  /* btn speed/skip: más grandes para tocar */
  #app .btn.btn-xs {
    border-radius: 0.6rem;
    letter-spacing: 0;
  }
}
