@media (min-width: 720px) {
  .app-shell { padding-inline: 8px; }
  .group-carousel { grid-auto-columns: calc((100% - 56px) / 3); padding-inline: 14px; scroll-padding-inline: 14px; }
  .group-navigation { justify-content: center; }
  .home-news { grid-template-columns: repeat(2, 1fr); }
}

@media (min-width: 1120px) {
  .group-carousel { grid-auto-columns: calc((100% - 88px) / 5); }
  .team-list, .match-list { grid-template-columns: 1fr; }
  .home-news { grid-template-columns: 1fr; }
}

@media (max-height: 700px) {
  .app-shell { min-height: 520px; }
  .status-message { margin-top: 4px; margin-bottom: 2px; }
  .group-card__inner { padding: 11px; }
  .team-row { min-height: 29px; padding-block: 5px; }
  .standings th, .standings td { padding-block: 3px; }
  .match-row { padding: 0; gap: 0; }
  .group-dot { width: 30px; height: 30px; font-size: 0.70rem; }
}

/* Ajustes para celulares menores, como iPhone SE */
@media (max-width: 430px) {
  body {
    height: 100dvh;
    min-height: 0;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
  }

  .app-header {
    padding: max(6px, env(safe-area-inset-top)) 8px 6px;
  }

  .app-header-inner {
    width: 100%;
    gap: 8px;
    padding: 6px 0;
    justify-content: center;
  }

  .app-title {
    font-size: 0.9rem;
  }

  .tab-button {
    padding: 6px 10px;
    font-size: 0.66rem;
  }

  .status-message {
    max-width: 190px;
    font-size: 0.52rem;
    line-height: 1.15;
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
  }

  .status-message__line {
    display: block;
  }

  .refresh-button {
    padding: 8px 11px;
    font-size: 0.78rem;
  }

  .app-shell {
    height: auto;
    min-height: 0;
    padding-bottom: max(5px, env(safe-area-inset-bottom));
  }

  .group-carousel {
    grid-auto-columns: calc(100% - 48px);
    gap: 12px;
    padding: 15px 24px 5px;
    scroll-padding-inline: 24px;
  }

  .group-navigation {
    gap: 8px;
    padding: 6px 16px 4px;
  }

  .group-dot {
    width: 28px;
    height: 28px;
    font-size: 0.72rem;
  }

  .group-card__inner {
    padding: 10px;
    grid-template-rows: auto auto auto auto auto 1fr;
  }

  .group-card__top {
    margin-bottom: 5px;
  }

  .group-card__label {
    font-size: 0.52rem;
  }

  .group-card__title {
    font-size: 1.35rem;
  }

  .group-card__badge {
    width: 40px;
    height: 40px;
    border-radius: 13px;
    font-size: 1.28rem;
  }

  .team-list {
    gap: 5px;
    margin-bottom: 5px;
  }

  .team-row {
    min-height: 27px;
    padding: 5px 7px;
    gap: 6px;
    border-radius: 12px;
  }

  .team-flag {
    width: 21px;
    height: 15px;
    font-size: 0.95rem;
  }

  .team-code {
    min-width: 31px;
    padding: 3px 5px;
    font-size: 0.56rem;
  }

  .team-name {
    font-size: 0.68rem;
  }

  .section-title {
    margin: 7px 0 4px;
    font-size: 0.58rem;
  }

  .standings {
    font-size: 0.58rem;
  }

  .standings th,
  .standings td {
    padding: 3px 2px;
  }

  .standings th:first-child,
  .standings td:first-child {
    width: 44%;
  }

  .standings th {
    font-size: 0.5rem;
  }

  .match-list {
    gap: 5px;
  }

  .match-row {
    min-height: 25px;
    padding: 0;
    gap: 0;
    font-size: 0.57rem;
    border-radius: 12px;
  }

  .match-versus {
    font-size: 0.6rem;
  }
}

@media (max-width: 380px) and (max-height: 700px) {
  .app-header {
    width: 100%;
    padding-inline: 7px;
  }

  .app-title { font-size: 0.82rem; }

  .status-message {
    max-width: 175px;
    font-size: 0.49rem;
  }

  .refresh-button {
    padding: 7px 9px;
    font-size: 0.72rem;
  }

  .group-carousel {
    grid-auto-columns: calc(100% - 56px);
    padding-inline: 28px;
    scroll-padding-inline: 28px;
  }

  .group-card__inner { padding: 9px; }
  .group-card__title { font-size: 1.25rem; }
  .group-card__badge { width: 38px; height: 38px; }
  .team-row { min-height: 25px; padding-block: 4px; }
  .section-title { margin-top: 6px; }
  .standings th, .standings td { padding-block: 2px; }
  .match-row { min-height: 23px; padding: 0; gap: 0; }
  .group-dot { width: 26px; height: 26px; }
}


.app-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 4px 14px max(4px, env(safe-area-inset-bottom));
  font-size: 0.5rem;
}

.footer-update-link {
  border: 0;
  background: none;
  padding: 0;
  color: var(--muted);
  font-size: 0.5rem;
  font-family: inherit;
  cursor: pointer;
  text-align: left;
  text-decoration: underline;
  text-decoration-color: rgba(255,255,255,0.35);
}

.footer-update-link:hover { color: #fff; }

.footer-version {
  margin: 0;
  text-align: right;
  white-space: nowrap;
}

/* Abaixo de 720px a navegação principal vira uma barra fixa embaixo (estilo
   app), em vez da fileira de abas no topo - a fileira do topo e o rodapé de
   status saem de cena pra abrir espaço. Precisa vir DEPOIS da regra
   incondicional de .app-footer acima, senão ela vence por ordem no arquivo
   (mesma especificidade) e o rodapé nunca esconde de verdade no mobile. */
@media (max-width: 720px) {
  .tab-nav { display: none; }
  .app-footer { display: none; }
  .bottom-nav { display: flex; }
  .app-header {
    background: linear-gradient(180deg, rgba(2, 15, 20, 0.85) 0%, rgba(2, 15, 20, 0.85) 100%), url('../img/primeira-fase.webp') center / cover no-repeat;
    box-shadow: none;
  }
}