/* ------------------------------------------------------------- */
/* CSS PADRÃO (PARA DESKTOP E COMO BASE PARA MOBILE) */
/* ------------------------------------------------------------- */

:root {
  --header-gradient-start: #2e7d32;
  --header-gradient-end: #4caf50;
}

body {
  margin: 0;
  font-family: Arial, sans-serif;
  background-color: var(--background-light);
  color: var(--text-dark);
  transition: background-color 0.3s ease, color 0.3s ease;
}

header {
  width: 100%;
  background: linear-gradient(90deg, var(--header-gradient-start), var(--header-gradient-end));
  padding: 20px 0;
  color: white;
  text-align: center;
  font-size: 2em; /* Tamanho para desktop */
  font-weight: bold;
  box-sizing: border-box;
}

.container {
  display: flex;
  flex-wrap: wrap;
  padding: 20px;
  gap: 20px;
}

.tabela, .jogos {
  background-color: var(--container-bg);
  color: var(--text-dark);
  padding: 20px;
  border-radius: 8px;
  box-shadow: 0 2px 8px var(--shadow-subtle);
  transition: background-color 0.3s ease, color 0.3s ease;
}

.tabela {
  flex: 1.5;
  min-width: 300px;
}

.jogos {
  flex: 1;
  min-width: 280px;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th, td {
  padding: 10px; /* Padding para desktop */
  text-align: center;
  font-size: 1em; /* Tamanho da fonte para desktop */
  color: var(--text-dark);
}

th {
  background-color: var(--table-header-bg);
  font-weight: bold;
  color: var(--text-dark);
}

tr:nth-child(even) {
  background-color: var(--table-row-even);
}

.posicao {
  font-weight: bold;
}

.pos-1 { color: #4caf50; }
.pos-2, .pos-3 { color: #757575; }
.pos-4 { color: #e53935; }

.rodada-header {
  display: flex;
  justify-content: center;
  align-items: center;
  margin-bottom: 15px;
  gap: 10px;
  position: relative;
  z-index: 5;
}

/* Estilos globais para a seta (desktop) */
.seta {
  background-color: #2e7d32;
  color: white;
  border: none;
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 1.2em;
  cursor: pointer;
  transition: background-color 0.2s;
}

.seta:hover {
  background-color: #1b5e20;
}

.jogo-novo {
  background: var(--jogo-bg);
  color: var(--text-dark);
  border-radius: 12px;
  box-shadow: 0 1px 4px var(--shadow-subtle);
  margin-bottom: 15px;
  padding: 10px 15px;
  font-family: Arial, sans-serif;
  transition: background-color 0.3s ease, color 0.3s ease;
}

.jogo-cabecalho {
  font-size: 0.85em;
  color: var(--text-medium);
  margin-bottom: 8px;
  text-align: center;
}

.jogo-conteudo.alinhado {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  text-align: center;
  gap: 20px;
  width: 100%;
  max-width: 100%;
  overflow: hidden;
}

.jogo-conteudo.alinhado .time {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 4px;
  width: 100%;
}

.time {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  font-weight: bold;
  color: var(--text-dark);
}

.placeholder-time {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  width: 100%;
  box-sizing: border-box;
}

.placeholder-icon {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: #eee;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5em;
  color: #999;
  flex-shrink: 0;
}

.nome-time-placeholder {
  font-size: 0.95em;
  color: var(--text-dark);
  text-align: center;
  word-wrap: break-word;
  max-width: 100%;
  line-height: 1.2;
  white-space: normal;
  overflow-wrap: break-word;
}

.placar-preview {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.vs-text {
  font-size: 1.2em;
  font-weight: bold;
  color: var(--text-dark);
}

/* Ícones dos times nas rodadas - TAMANHO PARA DESKTOP */
.icone-time {
  width: 48px; /* Mantido em 48px (desktop) */
  height: 48px; /* Mantido em 48px (desktop) */
  border-radius: 50%;
  object-fit: contain;
  background: #eee;
}

.placar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 1.2em;
  font-weight: bold;
  color: var(--text-dark);
}

.nome-time {
  font-size: 0.95em; /* Tamanho para desktop */
  color: var(--text-dark);
  text-align: center;
  word-wrap: break-word;
  max-width: 100%;
  white-space: normal;
  overflow-wrap: break-word;
}

.tabela-time {
  display: flex;
  align-items: center;
  justify-content: start;
  gap: 6px;
}

/* ------------------------------------------------------------- */
/* CSS ESPECÍFICO PARA MOBILE (SOBRESCRITA) */
/* ------------------------------------------------------------- */
@media (max-width: 768px) {
  .container {
    flex-direction: column;
    padding: 8px;
    gap: 12px;
  }

  header {
    font-size: 1.6em; /* Apenas mobile */
    padding: 15px 0; /* Apenas mobile */
  }

  .tabela, .jogos {
    padding: 12px;
    margin: 0;
    width: 100%;
    box-sizing: border-box;
    overflow-x: hidden;
  }

  h2 {
    font-size: 1.25em;
    margin-bottom: 12px;
    color: var(--text-dark);
  }
  h3 {
    font-size: 1.1em;
    white-space: nowrap;
    color: var(--text-dark);
  }

  .rodada-header {
    flex-wrap: nowrap;
    justify-content: center;
    align-items: center;
    margin-bottom: 12px;
    gap: 6px;
    position: relative;
    z-index: 5;
  }

  .seta {
    background-color: #2e7d32;
    color: white;
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.8em;
    line-height: 1;
    cursor: pointer;
    transition: background-color 0.2s;
    flex-shrink: 0;
    position: relative;
    z-index: 10;
    background-image: none !important;
    content: normal !important;
  }
  .seta:hover {
    background-color: #1b5e20;
  }

  /* --- OTIMIZAÇÃO DA TABELA --- */
  .tabela table {
    width: 100%;
    table-layout: fixed;
    border-collapse: collapse;
  }

  .tabela th, .tabela td {
    padding: 4px 1px;
    font-size: 0.75em;
    text-align: center;
    vertical-align: middle;
    border-bottom: 1px solid var(--table-border);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--text-dark);
  }

  .tabela th {
    font-size: 0.7em;
    background-color: var(--table-header-bg);
    color: var(--text-dark);
  }

  /* Larguras das colunas - AJUSTADAS para comportar 3 dígitos */
  .tabela th:nth-child(1), .tabela td:nth-child(1) { width: 4%; } /* # */
  .tabela th:nth-child(2), .tabela td:nth-child(2) { width: 27%; text-align: left; } /* Time - REDUZIDO */
  .tabela th:nth-child(3), .tabela td:nth-child(3) { width: 7%; } /* PTS */
  .tabela th:nth-child(4), .tabela td:nth-child(4) { width: 5%; } /* J */
  .tabela th:nth-child(5), .tabela td:nth-child(5) { width: 5%; } /* V */
  .tabela th:nth-child(6), .tabela td:nth-child(6) { width: 5%; } /* E */
  .tabela th:nth-child(7), .tabela td:nth-child(7) { width: 5%; } /* D */
  .tabela th:nth-child(8), .tabela td:nth-child(8) { width: 8%; } /* GP - AUMENTADO para 3 dígitos */
  .tabela th:nth-child(9), .tabela td:nth-child(9) { width: 8%; } /* GC - AUMENTADO para 3 dígitos */
  .tabela th:nth-child(10), .tabela td:nth-child(10) { width: 8%; } /* SG - AUMENTADO para 3 dígitos */
  .tabela th:nth-child(11), .tabela td:nth-child(11) { /* % - AUMENTADO para 100% */
    width: 13%;
    font-size: 0.65em;
  }

  /* Ajuste para a coluna "Time" na tabela */
  .tabela-time {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 4px;
  }

  .tabela-time .icone-time {
    width: 20px; /* Mantido para a tabela */
    height: 20px; /* Mantido para a tabela */
    flex-shrink: 0;
  }

  .tabela .nome-time {
    font-size: 0.72em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--text-dark);
    font-weight: 500;
    max-width: 100%;
  }

  /* --- OTIMIZAÇÃO DOS JOGOS --- */
  .jogo-novo {
    padding: 10px;
    margin-bottom: 10px;
  }

  .jogo-cabecalho {
    font-size: 0.7em;
    margin-bottom: 4px;
    color: var(--text-medium);
  }

  .jogo-conteudo.alinhado {
    gap: 4px;
  }

  /* Ícones dos times nas rodadas - TAMANHO PARA MOBILE */
  .time .icone-time {
    width: 50px; /* AUMENTADO para 50px (mobile) */
    height: 50px; /* AUMENTADO para 50px (mobile) */
  }

  .time .nome-time {
    font-size: 0.75em;
    color: var(--text-dark);
  }
  
  .placeholder-icon {
    width: 50px;
    height: 50px;
    font-size: 1.5em;
  }
  
  .nome-time-placeholder {
    font-size: 0.75em;
  }

  .placar {
    font-size: 1em;
    color: var(--text-dark);
  }
}

/* ------------------------------------------------------------- */
/* BOTÃO VER PELADAS */
/* ------------------------------------------------------------- */
.botao-peladas-container {
  display: flex;
  justify-content: center;
  padding: 30px 20px;
  margin-top: 20px;
}

.botao-peladas {
  background: linear-gradient(90deg, var(--header-gradient-start), var(--header-gradient-end));
  color: white;
  border: none;
  padding: 15px 30px;
  border-radius: 8px;
  font-size: 1.2em;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 4px 15px rgba(46, 125, 50, 0.3);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.botao-peladas:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(46, 125, 50, 0.4);
}

.botao-peladas:active {
  transform: translateY(0);
  box-shadow: 0 2px 10px rgba(46, 125, 50, 0.3);
}

/* Responsividade para mobile */
@media (max-width: 768px) {
  .botao-peladas-container {
    padding: 20px 15px;
    margin-top: 15px;
  }
  
  .botao-peladas {
    padding: 12px 25px;
    font-size: 1.1em;
    width: 100%;
    max-width: 300px;
  }
}

/* ------------------------------------------------------------- */
/* CSS PARA TELAS MUITO PEQUENAS (< 400px) - Redmi Note 9 */
/* ------------------------------------------------------------- */
@media (max-width: 400px) {
  .tabela th, .tabela td {
    padding: 4px 1px;
    font-size: 0.7em;
  }
  
  .tabela th {
    font-size: 0.65em;
  }
  
  /* Larguras IGUAIS às telas 400px+ para manter proporção visual */
  .tabela th:nth-child(1), .tabela td:nth-child(1) { width: 4%; } /* # */
  .tabela th:nth-child(2), .tabela td:nth-child(2) { width: 27%; text-align: left; } /* Time */
  .tabela th:nth-child(3), .tabela td:nth-child(3) { width: 7%; } /* PTS */
  .tabela th:nth-child(4), .tabela td:nth-child(4) { width: 5%; } /* J */
  .tabela th:nth-child(5), .tabela td:nth-child(5) { width: 5%; } /* V */
  .tabela th:nth-child(6), .tabela td:nth-child(6) { width: 5%; } /* E */
  .tabela th:nth-child(7), .tabela td:nth-child(7) { width: 5%; } /* D */
  .tabela th:nth-child(8), .tabela td:nth-child(8) { width: 8%; } /* GP */
  .tabela th:nth-child(9), .tabela td:nth-child(9) { width: 8%; } /* GC */
  .tabela th:nth-child(10), .tabela td:nth-child(10) { width: 8%; } /* SG */
  .tabela th:nth-child(11), .tabela td:nth-child(11) { width: 13%; } /* % */
  
  .tabela .nome-time {
    font-size: 0.68em;
    font-weight: 600;
  }
  
  .tabela-time .icone-time {
    width: 18px;
    height: 18px;
  }
}

/* ------------------------------------------------------------- */
/* NAVEGAÇÃO DE FASES */
/* ------------------------------------------------------------- */
.navegacao-fases {
  background-color: var(--container-bg);
  padding: 15px;
  text-align: center;
  box-shadow: 0 2px 4px var(--shadow-subtle);
  transition: background-color 0.3s ease;
}

.navegacao-fases-conteudo {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 15px;
}

.btn-fase {
  background-color: #2e7d32;
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 1.1em;
  cursor: pointer;
  transition: background-color 0.2s;
}

.btn-fase:hover {
  background-color: #1b5e20;
}

.btn-fase:disabled {
  background-color: #ccc;
  cursor: not-allowed;
  opacity: 0.5;
}

.titulo-fase {
  font-size: 1.3em;
  font-weight: bold;
  color: var(--text-dark);
  min-width: 200px;
  transition: color 0.3s ease;
}

/* ------------------------------------------------------------- */
/* FINAL - CARD E PREVIEW */
/* ------------------------------------------------------------- */
.final-wrapper {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 40px 20px;
  min-height: 400px;
  width: 100%;
  box-sizing: border-box;
}

.jogo-final-preview {
  background: var(--container-bg);
  color: var(--text-dark);
  border-radius: 16px;
  box-shadow: 0 4px 12px var(--shadow-medium);
  padding: 30px;
  max-width: 600px;
  width: 100%;
  text-align: center;
  transition: background-color 0.3s ease, color 0.3s ease;
  box-sizing: border-box;
  margin: 0 auto;
  overflow: hidden;
}

.final-titulo {
  font-size: 2em;
  font-weight: bold;
  color: var(--text-dark);
  margin-bottom: 10px;
  transition: color 0.3s ease;
}

.final-subtitulo {
  font-size: 1em;
  color: var(--text-medium);
  margin-bottom: 30px;
  font-style: italic;
  transition: color 0.3s ease;
}

.final-confronto {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 20px;
  margin-bottom: 30px;
}

.final-time {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.final-icone {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: var(--table-row-even);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.5em;
  color: var(--text-medium);
  transition: background-color 0.3s ease, color 0.3s ease;
}

.final-icone img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: contain;
}

.final-nome {
  font-size: 1.1em;
  font-weight: bold;
  color: var(--text-dark);
  transition: color 0.3s ease;
}

.final-vs {
  font-size: 1.8em;
  font-weight: bold;
  color: var(--text-medium);
  transition: color 0.3s ease;
}

/* Responsividade para mobile */
@media (max-width: 768px) {
  .navegacao-fases {
    padding: 12px;
  }
  
  .navegacao-fases-conteudo {
    gap: 10px;
  }
  
  .btn-fase {
    padding: 6px 12px;
    font-size: 1em;
  }
  
  .titulo-fase {
    font-size: 1.1em;
    min-width: 150px;
  }
  
  .final-wrapper {
    padding: 20px 5px;
    min-height: 300px;
  }
  
  .jogo-final-preview {
    padding: 20px;
    max-width: 98%;
  }
  
  .final-titulo {
    font-size: 1.5em;
  }
  
  .final-subtitulo {
    font-size: 0.9em;
    margin-bottom: 20px;
  }
  
  .final-confronto {
    gap: 15px;
  }
  
  .final-icone {
    width: 60px;
    height: 60px;
    font-size: 2em;
  }
  
  .final-nome {
    font-size: 0.95em;
  }
  
  .final-vs {
    font-size: 1.5em;
  }
}
