/* ===================================================================
   style.css — Simulador da Copa 2026
   Paleta escura premium, destaque amarelo/dourado + azul vibrante
   =================================================================== */

:root {
  /* Fundos */
  --bg-primary:    #0F0F0F;
  --bg-secondary:  #111418;
  --bg-card:       #1A1A1A;
  --bg-elevated:   #1F1F25;
  --bg-overlay:    rgba(10, 10, 15, 0.85);

  /* Amarelo / dourado */
  --yellow:        #FFCC00;
  --yellow-2:      #FACC15;
  --yellow-3:      #EAB308;
  --gold:          #F5C542;

  /* Azul / ciano */
  --blue:          #0081C9;
  --blue-2:        #0284C7;
  --sky:           #0EA5E9;
  --blue-dark:     #0369A1;
  --cyan:          #00AEEF;

  /* Texto */
  --text:          #FFFFFF;
  --text-2:        #CBD5E1;
  --text-3:        #94A3B8;
  --text-muted:    #6B7280;

  /* Estados */
  --state-real:        var(--gold);
  --state-prediction:   var(--blue);
  --state-pending:      #3F3F46;
  --state-eliminated:   rgba(255, 255, 255, 0.3);
  --state-final:        var(--cyan);

  /* Bordas */
  --border:        #2A2A2E;
  --border-strong: #3F3F46;
  --border-gold:   rgba(255, 204, 0, 0.5);

  /* Tipografia */
  --font:          'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono:     'JetBrains Mono', monospace;

  /* Conectores */
  --connector:     #EAB308;
  --connector-w:   2px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--font);
  background: var(--bg-primary);
  background-image:
    radial-gradient(circle at 20% 0%, rgba(255, 204, 0, 0.04), transparent 40%),
    radial-gradient(circle at 80% 100%, rgba(0, 174, 239, 0.04), transparent 40%),
    linear-gradient(180deg, var(--bg-primary), var(--bg-secondary));
  background-attachment: fixed;
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--cyan); text-decoration: none; }
a:hover { opacity: 0.85; }

.container {
  max-width: 1500px;
  margin: 0 auto;
  padding: 24px 20px 80px;
}

/* ====================================================================
   HEADER
   ==================================================================== */
.sim-header {
  text-align: center;
  padding: 32px 20px 24px;
  border-bottom: 2px solid var(--border-gold);
  margin-bottom: 32px;
  position: relative;
}

.sim-header h1 {
  font-size: clamp(1.6rem, 3.5vw, 2.8rem);
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text);
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.5);
}
.sim-header h1 .accent { color: var(--yellow); }
.sim-header p.subtitle {
  color: var(--text-2);
  font-size: clamp(0.9rem, 1.4vw, 1.05rem);
  margin-top: 8px;
}

/* ====================================================================
   MODE TOGGLE
   ==================================================================== */
.mode-toggle {
  display: flex;
  gap: 12px;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  margin: 24px 0 32px;
}
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: 8px;
  font-weight: 700;
  font-size: 0.92rem;
  cursor: pointer;
  border: 1px solid var(--border-strong);
  background: var(--bg-card);
  color: var(--text-2);
  transition: all 0.18s ease;
  font-family: var(--font);
}
.btn:hover { transform: translateY(-1px); border-color: var(--border-gold); }
.btn-primary {
  background: var(--yellow);
  color: #1a1a2e;
  border-color: var(--yellow);
  box-shadow: 0 0 16px rgba(255, 204, 0, 0.3);
}
.btn-primary:hover { background: var(--yellow-2); }
.btn-secondary {
  background: var(--blue-2);
  color: #fff;
  border-color: var(--blue-2);
  box-shadow: 0 0 16px rgba(2, 132, 199, 0.3);
}
.btn-ghost {
  background: transparent;
  color: var(--text-2);
  border-color: var(--border);
}

.mode-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.mode-badge.real      { background: rgba(245, 197, 66, 0.15); color: var(--gold); border: 1px solid rgba(245, 197, 66, 0.4); }
.mode-badge.prediction{ background: rgba(14, 165, 233, 0.15); color: var(--sky);  border: 1px solid rgba(14, 165, 233, 0.4); }

/* ====================================================================
   SECTION TITLES
   ==================================================================== */
.section-title {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 40px 0 20px;
  font-size: clamp(1.1rem, 2vw, 1.5rem);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.section-title::before {
  content: "";
  width: 4px;
  height: 24px;
  background: linear-gradient(180deg, var(--yellow), var(--gold));
  border-radius: 2px;
}

/* ====================================================================
   GROUPS GRID
   ==================================================================== */
.groups-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  gap: 20px;
}
.group-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  transition: border-color 0.18s;
}
.group-card:hover { border-color: var(--border-gold); }
.group-card h3 {
  font-size: 1.1rem;
  font-weight: 800;
  margin-bottom: 12px;
  color: var(--yellow);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Tabela de classificação */
.standings-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  margin-bottom: 14px;
}
.standings-table th, .standings-table td {
  padding: 6px 4px;
  text-align: center;
  border-bottom: 1px solid var(--border);
}
.standings-table th {
  font-size: 0.7rem;
  color: var(--text-3);
  text-transform: uppercase;
  font-weight: 600;
}
.standings-table td.team-name {
  text-align: left;
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
  color: var(--text);
}
.standings-table .flag { width: 18px; height: 12px; object-fit: cover; border-radius: 1px; }
.standings-table tr.qualified td.team-name { color: var(--yellow); }
.standings-table tr.qualified { background: rgba(255, 204, 0, 0.05); }

/* Jogos do grupo */
.group-matches { display: flex; flex-direction: column; gap: 8px; }

/* ====================================================================
   MATCH CARD
   ==================================================================== */
.match-card {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 0.82rem;
  transition: all 0.18s;
  cursor: default;
  position: relative;
  overflow: hidden;
}
.match-card.editable { cursor: pointer; }
.match-card.editable:hover { border-color: var(--blue); background: rgba(2, 132, 199, 0.06); }

.match-card.status-finished { border-left: 3px solid var(--gold); }
.match-card.status-pending   { border-left: 3px solid var(--state-pending); }
.match-card .team {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}
.match-card .team.team-b { justify-content: flex-end; text-align: right; flex-direction: row-reverse; }
.match-card .team .name {
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 0.82rem;
}
.match-card .team .flag { width: 18px; height: 12px; object-fit: cover; border-radius: 1px; flex-shrink: 0; }

.match-card .score-area {
  display: flex;
  gap: 4px;
  align-items: center;
  font-weight: 800;
  font-size: 1rem;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  min-width: 50px;
  justify-content: center;
}
.match-card .score-area input {
  width: 26px;
  height: 24px;
  background: var(--bg-primary);
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  color: var(--text);
  text-align: center;
  font-weight: 800;
  font-size: 0.92rem;
  font-family: var(--font);
  padding: 0;
  -moz-appearance: textfield;
}
.match-card .score-area input::-webkit-outer-spin-button,
.match-card .score-area input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.match-card .score-area input:focus { outline: 2px solid var(--sky); border-color: var(--sky); }
.match-card .score-area input:disabled { color: var(--text-2); cursor: not-allowed; opacity: 1; }
.match-card .score-area .vs { color: var(--text-3); font-size: 0.7rem; padding: 0 2px; }

.match-card .team.winner .name { color: var(--yellow); font-weight: 800; }
.match-card .team.winner::after {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--gold);
}

.match-card.status-pending .team.winner::after { display: none; }
.match-card .meta {
  position: absolute;
  bottom: 2px;
  right: 6px;
  font-size: 0.62rem;
  color: var(--text-3);
  letter-spacing: 0.04em;
}
.match-card.editable::before {
  content: "SIMULAR";
  position: absolute;
  top: 2px;
  right: 4px;
  font-size: 0.55rem;
  font-weight: 800;
  color: var(--sky);
  letter-spacing: 0.06em;
  opacity: 0;
  transition: opacity 0.15s;
}
.match-card.editable:hover::before { opacity: 1; }
.match-card.status-finished.editable::before { content: "REAL"; color: var(--gold); opacity: 0.6; }
.match-card.status-finished.editable:hover::before { opacity: 1; }

.match-card.empty .team .name { color: var(--text-muted); font-style: italic; font-weight: 500; }

/* ====================================================================
   KNOCKOUT BRACKET
   ==================================================================== */
.bracket-wrapper {
  background: var(--bg-card);
  border: 2px solid var(--border-gold);
  border-radius: 12px;
  padding: 24px 16px;
  margin: 24px 0;
  overflow-x: auto;
  position: relative;
}
.bracket {
  display: grid;
  grid-template-columns: repeat(5, 1fr) 1.4fr;
  gap: 12px;
  min-width: 1100px;
  align-items: stretch;
}
.bracket-round {
  display: flex;
  flex-direction: column;
  justify-content: space-around;
  gap: 12px;
  position: relative;
}
.bracket-round .round-label {
  position: absolute;
  top: -16px;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 0.7rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-3);
}
.bracket-side { display: contents; }

/* Match card dentro do bracket (compacto) */
.bracket .match-card {
  font-size: 0.78rem;
  padding: 6px 8px;
  background: var(--bg-elevated);
  border-radius: 4px;
  min-height: 44px;
}
.bracket .match-card .team .name { font-size: 0.78rem; }
.bracket .match-card .team .flag { width: 16px; height: 11px; }
.bracket .match-card .score-area input { width: 22px; height: 22px; font-size: 0.85rem; }

/* LINHAS CONECTORAS via SVG overlay */
.bracket-svg {
  position: absolute;
  inset: 0;
  pointer-events: none;
  width: 100%;
  height: 100%;
}
.bracket-svg path {
  fill: none;
  stroke: var(--connector);
  stroke-width: var(--connector-w);
  stroke-linecap: round;
  opacity: 0.7;
}

/* ====================================================================
   FINAL CARD (centro)
   ==================================================================== */
.bracket-final-col {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  position: relative;
}
.final-banner {
  background: linear-gradient(135deg, var(--cyan), var(--blue-2));
  color: #fff;
  font-weight: 900;
  font-size: clamp(1.6rem, 2.4vw, 2.2rem);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 12px 24px;
  transform: skewX(-8deg);
  margin-bottom: 14px;
  box-shadow: 0 0 28px rgba(0, 174, 239, 0.4);
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}
.final-banner > span { display: inline-block; transform: skewX(8deg); }

.final-card {
  background: var(--bg-elevated);
  border: 2px solid var(--cyan);
  border-radius: 10px;
  padding: 16px 18px;
  width: 100%;
  max-width: 240px;
  box-shadow: 0 0 32px rgba(0, 174, 239, 0.25);
  position: relative;
}
.final-card .match-card { background: transparent; border: none; padding: 0; }
.final-card .match-card .team .name { font-size: 0.95rem; }
.final-card .match-card .team .flag { width: 22px; height: 15px; }
.final-card .match-card .score-area input { font-size: 1.1rem; width: 32px; height: 30px; }

.champion-card {
  margin-top: 16px;
  text-align: center;
  padding: 14px 18px;
  background: linear-gradient(135deg, rgba(255, 204, 0, 0.15), rgba(255, 204, 0, 0.05));
  border: 2px solid var(--gold);
  border-radius: 10px;
  display: none;
}
.champion-card.show { display: block; animation: championReveal 0.6s ease; }
.champion-card .trophy { font-size: 1.8rem; }
.champion-card .label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--gold);
  font-weight: 800;
  margin: 4px 0 2px;
}
.champion-card .name {
  font-size: 1.05rem;
  font-weight: 900;
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.champion-card .name .flag { width: 22px; height: 15px; object-fit: cover; border-radius: 2px; }
@keyframes championReveal {
  from { transform: scale(0.6); opacity: 0; }
  to   { transform: scale(1);   opacity: 1; }
}

/* ====================================================================
   EMPTY SLOTS
   ==================================================================== */
.match-card.empty .score-area input { display: none; }
.match-card.empty .score-area .vs { color: var(--text-muted); }

/* ====================================================================
   MOBILE
   ==================================================================== */
@media (max-width: 1100px) {
  .bracket-wrapper { overflow-x: auto; }
  .bracket { min-width: 1100px; }
}

@media (max-width: 768px) {
  .container { padding: 16px 12px 60px; }
  .sim-header { padding: 20px 12px 16px; }
  .groups-grid { grid-template-columns: 1fr; }
  .mode-toggle { flex-direction: column; gap: 8px; }
  .btn { width: 100%; justify-content: center; }
  .bracket-wrapper { padding: 16px 8px; }

  /* Mobile bracket: cada fase como bloco vertical, com tabs no topo */
  .mobile-tabs { display: flex; gap: 6px; margin-bottom: 16px; overflow-x: auto; }
  .mobile-tabs .tab {
    padding: 8px 12px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-2);
    font-size: 0.78rem;
    font-weight: 700;
    cursor: pointer;
    white-space: nowrap;
  }
  .mobile-tabs .tab.active { background: var(--yellow); color: #1a1a2e; border-color: var(--yellow); }
  .bracket { display: none; }
  .bracket.active { display: grid; grid-template-columns: 1fr; min-width: 0; }
  .bracket-round { min-height: 200px; }
  .bracket-final-col { order: -1; }
  .final-banner { font-size: 1.4rem; padding: 8px 16px; }
}

@media (min-width: 769px) {
  .mobile-tabs { display: none; }
}

/* ====================================================================
   SHARE / FOOTER
   ==================================================================== */
.sim-footer {
  text-align: center;
  margin-top: 48px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
  font-size: 0.78rem;
  color: var(--text-3);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.sim-footer .accent { color: var(--yellow); font-weight: 800; }
.sim-footer a { color: var(--cyan); }

/* Toast/share feedback */
.toast {
  position: fixed;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--bg-elevated);
  color: var(--text);
  padding: 12px 20px;
  border-radius: 8px;
  border: 1px solid var(--border-gold);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
  font-size: 0.9rem;
  opacity: 0;
  pointer-events: none;
  transition: all 0.25s ease;
  z-index: 999;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.error { border-color: var(--red, #ff5252); }
