/* ===============================
   COPA 10 STYLE (COMPLETO)
   - Mobile first
   - Anti-overflow (não estoura pros lados)
   - Bracket: logo menor em cima, nome embaixo
   - Ranking: estilo “tabela Brasileirão”
================================ */

/* ========== RESET / BASE ========== */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }

html { scroll-behavior: smooth; }
body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: #eaf1f7;

  /* fundo copa10 */
  background:
    radial-gradient(1200px 700px at 20% -10%, rgba(36, 194, 255, 0.18), transparent 60%),
    radial-gradient(900px 600px at 110% 0%, rgba(34, 197, 94, 0.15), transparent 55%),
    radial-gradient(900px 600px at 50% 120%, rgba(59, 130, 246, 0.12), transparent 55%),
    linear-gradient(180deg, #06121b 0%, #04070f 100%);

  /* evita “estourar” pro lado */
  overflow-x: hidden;
}

/* utilitários */
.hidden { display: none !important; }
.muted { color: rgba(234, 241, 247, 0.68); }
.label { display: block; font-weight: 700; font-size: 13px; opacity: .82; margin-bottom: 8px; }

/* quebra textos longos sem vazar */
h1,h2,h3,h4,p,span,div,button,label {
  overflow-wrap: anywhere;
  word-break: break-word;
}

/* ========== CONTAINER / CARDS ========== */
.container {
  width: 100%;
  max-width: 920px;
  margin: 0 auto 42px;
  padding: 14px;
  overflow-x: hidden; /* anti-vazamento */
}

.card {
  position: relative;
  border-radius: 22px;
  padding: 18px;
  margin-bottom: 16px;

  /* “glass” */
  background: linear-gradient(160deg, rgba(13, 44, 60, 0.72), rgba(7, 20, 31, 0.72));
  border: 1px solid rgba(255,255,255,0.10);
  box-shadow:
    0 18px 60px rgba(0,0,0,0.55),
    inset 0 1px 0 rgba(255,255,255,0.05);

  backdrop-filter: blur(10px);
}

/* ========== HEADER ========== */
.header.card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

/* em telas pequenas, evita header estourar */
@media (max-width: 520px) {
  .header.card {
    flex-direction: column;
    align-items: stretch;
  }
  .top-actions { justify-content: center !important; }
}

/* ========== INPUTS / SELECTS ========== */
.input, input, select, textarea {
  width: 100%;
  padding: 14px 14px;
  border-radius: 16px;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(0,0,0,0.22);
  color: #eaf1f7;
  font-size: 16px;
  outline: none;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.06);
}

input::placeholder { color: rgba(234,241,247,0.42); }

/* deixa select mais “copa10” */
select {
  appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, rgba(255,255,255,.55) 50%),
    linear-gradient(135deg, rgba(255,255,255,.55) 50%, transparent 50%);
  background-position:
    calc(100% - 18px) calc(50% - 3px),
    calc(100% - 12px) calc(50% - 3px);
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
  padding-right: 34px;
}

/* ========== BOTÕES ========== */
.btn {
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 999px;
  padding: 12px 16px;
  font-weight: 900;
  letter-spacing: .2px;
  cursor: pointer;
  color: #eaf1f7;
  background: rgba(255,255,255,0.08);
  box-shadow: 0 10px 30px rgba(0,0,0,0.25), inset 0 1px 0 rgba(255,255,255,0.05);
  backdrop-filter: blur(8px);
  transition: transform .08s ease, filter .15s ease;
}

.btn:active { transform: scale(0.98); }
.btn-full { width: 100%; }

.btn-ghost {
  background: rgba(255,255,255,0.06);
}

.btn-success {
  border: 1px solid rgba(34, 197, 94, 0.35);
  background: linear-gradient(180deg, rgba(34,197,94,0.95), rgba(22,163,74,0.88));
  color: #04110a;
}

.btn-danger {
  border: 1px solid rgba(239, 68, 68, 0.35);
  background: linear-gradient(180deg, rgba(239,68,68,0.92), rgba(185,28,28,0.90));
  color: #100204;
}

/* botões topo */
.top-actions { display: flex; gap: 10px; align-items: center; justify-content: flex-end; }
.top-actions .btn { min-width: 128px; }
.top-actions .active {
  border: 1px solid rgba(34,197,94,0.38);
  background: linear-gradient(180deg, rgba(34,197,94,0.95), rgba(22,163,74,0.88));
  color: #04110a;
}

/* ========== TABS (ADMIN) ========== */
.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.tab {
  border: 1px solid rgba(255,255,255,0.10);
  border-radius: 999px;
  padding: 10px 14px;
  background: rgba(255,255,255,0.06);
  color: rgba(234,241,247,0.92);
  font-weight: 900;
}

.tab.active {
  background: linear-gradient(180deg, rgba(59,130,246,0.90), rgba(29,78,216,0.84));
  border: 1px solid rgba(59,130,246,0.35);
  color: #07101a;
}

.tab-panel { overflow-x: hidden; }

/* ========== MODAL ADMIN (garante clique + sem travar scroll) ========== */
#modalAdmin { position: fixed; inset: 0; z-index: 9999; }
#modalAdmin.hidden { display: none !important; }

#modalAdminBackdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(6px);
}

#modalAdminCard {
  position: relative;
  z-index: 10000;
  width: min(520px, calc(100% - 28px));
  margin: 12vh auto 0;
  border-radius: 22px;
  border: 1px solid rgba(255,255,255,0.12);
  background: linear-gradient(160deg, rgba(13, 44, 60, 0.92), rgba(7, 20, 31, 0.92));
  padding: 16px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.45);
}

/* ========== CHAVEAMENTO (Copa10) ========== */
/* anti-estouro geral dentro das áreas do bracket */
#bracketAdminArea, #publicBracket, #publicInfo, #timesArea, #participantesArea, #rankingArea {
  overflow-x: hidden;
}

/* imagens no chaveamento: menores */
#bracketAdminArea img,
#publicBracket img,
.match img,
.team img {
  width: auto !important;
  max-width: 92px !important;
  max-height: 92px !important;
  height: auto !important;
  display: block;
  margin: 0 auto 8px;
  filter: drop-shadow(0 10px 24px rgba(0,0,0,.45));
}

/* confronto: sempre frente a frente, estilo Copa10 */
.match {
  display: grid;
  grid-template-columns: 1fr 50px 1fr;
  align-items: center;
  gap: 10px;
  margin: 12px 0;
  padding: 12px;
  border-radius: 20px;
  border: 1px solid rgba(255,255,255,0.10);
  background: rgba(0,0,0,0.18);
}

/* time card (logo em cima, nome embaixo) */
.team {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;

  padding: 12px 10px;
  border-radius: 18px;
  border: 1px solid rgba(255,255,255,0.10);
  background: rgba(255,255,255,0.05);
  min-width: 0; /* evita estourar */
  text-align: center;
}

/* caso o app.js renderize nome do jogador em spans/divs */
.team .name,
.team .player,
.team .jogador,
.team .nome,
.team span,
.team div {
  max-width: 100%;
  font-weight: 900;
  font-size: 14px;
  line-height: 1.15;
  opacity: .95;
  text-align: center;

  /* impede vazar */
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* o “X” do confronto */
.match .vs, .match .x, .match .mid, .match > :nth-child(2) {
  text-align: center;
  font-weight: 1000;
  opacity: .9;
}

/* inputs de placar (se existirem) */
.score, .placar, input[type="number"] {
  max-width: 78px;
  text-align: center;
}

/* vencedor */
.team.winner {
  outline: 2px solid rgba(34,197,94,0.75);
  background: rgba(34,197,94,0.14);
}

/* telas bem pequenas */
@media (max-width: 380px) {
  .match { grid-template-columns: 1fr 38px 1fr; padding: 10px; }
  #bracketAdminArea img, #publicBracket img, .match img, .team img {
    max-width: 78px !important;
    max-height: 78px !important;
  }
  .team .name, .team span, .team div { font-size: 13px; }
}

/* ========== RANKING (tabela estilo Brasileirão) ========== */
/* 1) remove a caixa de limpar ranking (você vai limpar no Firebase) */
#abaRanking .dangerBox { display: none !important; }

/* 2) blocos do ranking */
#rankingArea h1, #rankingArea h2, #rankingArea h3 {
  margin: 0 0 10px;
}
#rankingArea .rankingTitle,
#rankingArea .title {
  font-weight: 1000;
  font-size: 18px;
}

/* 3) tenta transformar listas em “tabela” */
#rankingArea ol, #rankingArea ul {
  list-style: none;
  padding: 0;
  margin: 12px 0 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* se o app.js usar <li> */
#rankingArea li {
  display: grid;
  grid-template-columns: 56px 1fr 110px;
  align-items: center;
  gap: 10px;

  padding: 14px 14px;
  border-radius: 18px;
  border: 1px solid rgba(255,255,255,0.10);
  background: rgba(255,255,255,0.06);
}

#rankingArea li strong { font-weight: 1000; }
#rankingArea li .pos,
#rankingArea li .rank,
#rankingArea li .num {
  font-weight: 1000;
  opacity: .95;
}

#rankingArea li .nome,
#rankingArea li .name,
#rankingArea li .player {
  font-weight: 900;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#rankingArea li .pontos,
#rankingArea li .gols,
#rankingArea li .value {
  text-align: right;
  font-weight: 1000;
  opacity: .95;
}

/* caso o ranking venha como texto solto com <br>, deixa mais “tabela” pelo menos */
#rankingArea {
  font-size: 16px;
  line-height: 1.35;
}
#rankingArea b { font-weight: 1000; }

/* ========== CHECKBOX (auto repair) ========== */
input[type="checkbox"] {
  width: 18px;
  height: 18px;
}

/* ========== TOAST AREA ========== */
#toastArea { pointer-events: none; }
#toastArea * { pointer-events: auto; }