/* ── Responsive — móvil, tablet, web app ── */

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
  padding-bottom: env(safe-area-inset-bottom);
}

.header-inner {
  min-height: 56px;
  height: auto;
  padding: 0.5rem 0;
  flex-wrap: nowrap;
  position: relative;
}

.logo-text { font-size: clamp(1rem, 4vw, 1.35rem); }

.menu-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 44px;
  height: 44px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  cursor: pointer;
  flex-shrink: 0;
}

.menu-toggle span {
  display: block;
  height: 2px;
  background: var(--text);
  border-radius: 1px;
  transition: var(--transition);
}

.menu-toggle.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.menu-toggle.open span:nth-child(2) { opacity: 0; }
.menu-toggle.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

.header-actions.is-mobile-panel {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: rgba(15, 12, 9, 0.98);
  border-bottom: 1px solid var(--border);
  padding: 0.75rem 1rem 1rem;
  flex-direction: column;
  align-items: stretch;
  gap: 0.5rem;
  box-shadow: var(--shadow);
  z-index: 50;
}

.header-actions.is-mobile-panel.open { display: flex; }

.header-actions.is-mobile-panel .btn {
  width: 100%;
  justify-content: center;
  min-height: 44px;
}

.main-content {
  padding: 1.25rem 1rem 3rem;
  padding-left: max(1rem, env(safe-area-inset-left));
  padding-right: max(1rem, env(safe-area-inset-right));
}

.btn, .tab, .group-tab { min-height: 44px; }
.btn-sm { min-height: 36px; }

.modal--wide { max-width: 640px; }
.modal--match { max-width: 620px; }
.login-logo-wrap { display: flex; justify-content: center; margin-bottom: 1rem; }

.login-submit { width: 100%; margin-top: 1rem; min-height: 44px; }

.form-hint { font-size: 0.78rem; grid-column: 1 / -1; }

@media (max-width: 768px) {
  .menu-toggle { display: flex; }
  .header-actions:not(.is-mobile-panel) { display: none !important; }

  .tabs {
    margin-bottom: 1.25rem;
    padding-bottom: 0.15rem;
    -webkit-overflow-scrolling: touch;
  }

  .header-actions-inline,
  .export-bar {
    width: 100%;
    flex-direction: column;
    align-items: stretch;
  }

  .header-actions-inline .btn,
  .export-bar .btn {
    width: 100%;
    justify-content: center;
  }

  .match-card-body {
    grid-template-columns: 1fr;
    gap: 0.75rem;
    text-align: center;
    padding: 1rem 0.875rem;
    justify-items: center;
  }

  .match-card-foot {
    padding: 0.6rem 0.875rem;
    font-size: 0.72rem;
  }

  .match-card-actions {
    grid-template-columns: 1fr;
    padding: 0.875rem;
    gap: 0.5rem;
  }

  .match-card-actions .btn-primary {
    grid-column: auto;
  }

  .match-side {
    flex-direction: row !important;
    justify-content: center;
    width: 100%;
  }
  .match-side-inner {
    justify-content: center !important;
  }
  .match-home { order: 2; }
  .match-away { order: 3; }
  .match-team-name { max-width: none; }
  .score-display {
    order: -1;
    justify-self: center;
    width: 100%;
    justify-content: center;
  }
  .score-num { font-size: 2rem; }

  .public-banner-pro { grid-template-columns: 1fr; padding: 1.15rem; }
  .stats-bar-pro { display: grid; grid-template-columns: repeat(2, 1fr); width: 100%; }
  .hero-section { padding: 1.5rem 0 1rem; }
  .tournament-grid-pro { grid-template-columns: 1fr; }
  .tab { padding: 0.65rem 0.85rem; font-size: 0.8rem; flex: 1; text-align: center; }
  .form-grid { grid-template-columns: 1fr !important; }

  .modal-overlay { align-items: flex-end; padding: 0; }
  .modal { max-height: 100dvh; border-radius: 12px 12px 0 0; margin-top: auto; align-self: flex-end; }

  .modal-footer {
    flex-direction: column;
    align-items: stretch;
    gap: 0.5rem;
    padding: 1rem;
  }

  .modal-footer .btn {
    width: 100%;
    justify-content: center;
    min-height: 44px;
  }

  .goal-entry { grid-template-columns: 1fr 70px 44px; }
  .page-header h1 { font-size: 1.45rem; }
  .live-ticker { height: 32px; }
  .login-page { margin: 1.5rem auto; padding: 0 0.5rem; }
  .admin-badge:not(.admin-badge-link) { display: none; }
  a.admin-badge-link { font-size: 0.58rem; padding: 0.35rem 0.5rem; }

  .toast-container {
    left: 1rem;
    right: 1rem;
    bottom: max(1rem, env(safe-area-inset-bottom));
  }
  .toast { width: 100%; }

  /* Tabla de posiciones — misma estructura que escritorio, sin GF/GC, compacta */
  .standings-table table {
    width: 100%;
    min-width: 0;
    table-layout: fixed;
    font-size: 0.73rem;
  }

  .standings-table thead {
    display: table-header-group;
  }

  .standings-table tbody tr {
    display: table-row;
  }

  .standings-table thead th,
  .standings-table tbody td {
    display: table-cell;
    padding: 0.48rem 0.22rem;
    text-align: center;
    vertical-align: middle;
  }

  .standings-table th.col-pos,
  .standings-table .pos-cell {
    width: 8%;
    padding-left: 0.2rem;
    padding-right: 0.2rem;
  }

  .standings-table th.col-team,
  .standings-table .team-col {
    width: 34%;
    min-width: 0;
    text-align: left;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    padding-left: 0.35rem;
  }

  .standings-table th.col-pts,
  .standings-table .pts-cell {
    width: 11%;
  }

  .standings-table th.stat-gf,
  .standings-table th.stat-gc,
  .standings-table .stat-gf,
  .standings-table .stat-gc {
    display: none;
  }

  .standings-table thead th {
    font-size: 0.58rem;
    letter-spacing: 0.2px;
    line-height: 1.2;
    white-space: nowrap;
  }

  .standings-table .pos-num {
    font-size: 0.82rem;
  }

  .standings-table .pts-badge {
    font-size: 0.78rem;
    min-width: 1.45rem;
    padding: 0.12rem 0.28rem;
  }

  .standings-table .team-logo-sm {
    width: 16px;
    height: 16px;
    margin-right: 3px;
  }

  .standings-table .standing-team-cell {
    display: inline-flex;
    align-items: center;
    min-width: 0;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .standings-table .table-legend {
    font-size: 0.62rem;
    padding: 0.4rem 0.65rem;
  }

  .mode-public .standings-table thead th,
  .mode-public .standings-table td {
    padding: 0.48rem 0.22rem;
    font-size: 0.73rem;
  }

  .mode-public .standings-table thead th {
    font-size: 0.58rem;
  }
}

@media (max-width: 480px) {
  .stats-bar { grid-template-columns: repeat(2, 1fr); }
  .matches-grid-pro { grid-template-columns: 1fr; gap: 1.125rem; }
  .logo-sub { display: none; }
  .round-header { align-items: flex-start; }
  .round-progress { font-size: 0.78rem; line-height: 1.4; }
}

@media (min-width: 481px) and (max-width: 900px) {
  .matches-grid-pro {
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr));
  }
}

@media (min-width: 769px) {
  .header-actions.is-mobile-panel { display: none !important; }
}

@media (min-width: 769px) and (max-width: 1024px) {
  .layout-pro { grid-template-columns: 1fr 280px; }
  .main-content { padding: 1.75rem 1.25rem 3.5rem; }
}

@media (prefers-reduced-motion: reduce) {
  .ticker-track, .live-pulse, .ticker-dot, .live-dot { animation: none !important; }
  .standings-animate tbody tr { animation: none !important; }
}

.lockout-notice {
  margin-top: 1rem;
  padding: 0.75rem;
  background: rgba(232, 69, 60, 0.1);
  border: 1px solid rgba(232, 69, 60, 0.3);
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  color: var(--danger);
  text-align: center;
}

.login-attempts {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-align: center;
  margin-top: 0.5rem;
}
