:root{
  --bg:#0f1115;
  --panel:#141820;
  --row:#11151c;
  --row2:#0f131a;
  --text:#e8edf5;
  --muted:#aab3c2;
  --line:#222a36;

  --lib:#4aa3ff;
  --pre:#46d6ff;
  --sul:#2ecc71;
  --reb:#ff4d4d;

  --shadow: 0 10px 30px rgba(0,0,0,.35);
  --radius:14px;
}

*{ box-sizing:border-box; }
html,body{ height:100%; }

body{
  margin:0;
  background:linear-gradient(180deg, #0b0d12 0%, #0f1115 40%, #0f1115 100%);
  color:var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial;
}

.app{ max-width:1180px; margin:0 auto; padding:18px; }

.topbar{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:16px;
  padding: 14px 14px;
  background: rgba(20,24,32,.75);
  border:1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
}

.brand{ display:flex; align-items:center; gap:12px; }
.dot{
  width:12px; height:12px; border-radius:999px;
  background: linear-gradient(135deg, var(--lib), var(--sul));
  box-shadow: 0 0 0 4px rgba(74,163,255,.12);
}
.brand-title{ font-weight:800; letter-spacing:.12em; font-size:12px; color: var(--muted); }
.brand-sub{ font-weight:700; font-size:14px; margin-top:2px; }

.controls{ display:flex; align-items:center; gap:10px; flex-wrap:wrap; justify-content:flex-end; }

.seedbox{
  display:flex; align-items:center; gap:8px;
  padding:8px;
  border:1px solid var(--line);
  border-radius:12px;
  background: rgba(255,255,255,.02);
}
.seedlabel{ color: var(--muted); font-weight:800; font-size:12px; letter-spacing:.08em; }
.seedinput{
  width: 160px;
  border:1px solid rgba(255,255,255,.08);
  background: rgba(0,0,0,.18);
  color: var(--text);
  border-radius:10px;
  padding:8px 10px;
  outline:none;
}
.seedinput::placeholder{ color: rgba(170,179,194,.65); }

.btn{
  border:1px solid var(--line);
  background: transparent;
  color: var(--text);
  padding: 10px 12px;
  border-radius: 12px;
  font-weight: 800;
  cursor:pointer;
  transition: transform .08s ease, background .2s ease, border-color .2s ease, opacity .2s ease;
  user-select:none;
}
.btn:active{ transform: translateY(1px); }
.btn:disabled{ opacity:.55; cursor:not-allowed; }

.btn-primary{
  background: linear-gradient(135deg, rgba(74,163,255,.18), rgba(46,204,113,.14));
  border-color: rgba(74,163,255,.35);
}
.btn-primary:hover{ background: linear-gradient(135deg, rgba(74,163,255,.24), rgba(46,204,113,.18)); }
.btn-ghost:hover{ background: rgba(255,255,255,.03); }

.grid{ margin-top: 14px; display:grid; grid-template-columns: 1.1fr 1fr; gap: 14px; }

.panel{
  background: rgba(20,24,32,.75);
  border:1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow:hidden;
}

.panel-head{ padding: 14px 14px 10px 14px; border-bottom:1px solid var(--line); }
.panel-head-split{ display:flex; align-items:flex-start; justify-content:space-between; gap:12px; }

.panel-title{ margin:0; font-size: 14px; letter-spacing:.08em; }
.panel-sub{ margin-top:4px; color: var(--muted); font-size: 12px; letter-spacing:.08em; }

.table-wrap{ padding: 10px 10px 6px 10px; }

.standings{ width:100%; border-collapse: collapse; font-size: 13px; }

.standings thead th{
  text-align:left;
  font-size: 12px;
  color: var(--muted);
  font-weight:900;
  padding: 10px 10px;
  border-bottom:1px solid var(--line);
}
.standings tbody td{
  padding: 10px 10px;
  border-bottom:1px solid rgba(34,42,54,.6);
}
.standings tbody tr:nth-child(odd){ background: rgba(17,21,28,.55); }

.col-pos{ width:34px; color: var(--muted); font-weight:900; }
.col-team{ width: 100%; }
.col-num{ width:56px; text-align:right; }
.col-num.strong{ font-weight:900; }

.teamcell{ display:flex; align-items:baseline; justify-content:space-between; gap:10px; }
.teamname{ font-weight:900; }
.teamslug{ color: var(--muted); font-weight:900; letter-spacing:.08em; font-size: 11px; }

.legend{
  display:flex; flex-wrap:wrap; gap:10px 14px;
  padding: 10px 14px 14px 14px;
  color: var(--muted);
  font-size: 12px;
  border-top:1px solid var(--line);
}
.legend-item{ display:flex; align-items:center; gap:8px; }
.pill{ width:10px; height:10px; border-radius:999px; display:inline-block; }
.p-lib{ background: var(--lib); }
.p-pre{ background: var(--pre); }
.p-sul{ background: var(--sul); }
.p-reb{ background: var(--reb); }

.round-kicker{ font-weight:900; letter-spacing:.10em; font-size: 14px; }
.round-sub{ margin-top:4px; color: var(--muted); font-size: 12px; }

.round-nav{ display:flex; align-items:center; gap:10px; margin-top: 2px; }
.icon-btn{
  width:34px; height:34px; border-radius: 12px;
  border:1px solid var(--line);
  background: rgba(255,255,255,.02);
  color: var(--text);
  font-size: 18px;
  cursor:pointer;
}
.round-num{ min-width: 26px; text-align:center; font-weight:900; color: var(--muted); }

.matches{ padding: 12px; display:grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.matches-col{ display:flex; flex-direction:column; gap: 10px; }

.match{
  border:1px solid rgba(34,42,54,.85);
  border-radius: 14px;
  background: rgba(15,19,26,.55);
  overflow:hidden;
}
.match-meta{
  display:flex; align-items:center; justify-content:space-between; gap:10px;
  padding: 10px 12px;
  color: var(--muted);
  font-size: 11px;
  border-bottom:1px solid rgba(34,42,54,.7);
  letter-spacing:.03em;
}
.meta-date{ font-weight:900; }
.meta-venue{ opacity:.9; text-align:center; flex:1; }
.meta-time{ font-weight:900; }

.match-row{
  display:flex; align-items:center; justify-content:space-between;
  padding: 12px 12px;
}

.side{ display:flex; align-items:center; gap:10px; min-width: 110px; }
.side.right{ justify-content:flex-end; text-align:right; }

.crest{
  width:34px; height:34px; border-radius: 12px;
  border:1px solid rgba(255,255,255,.08);
  background: rgba(255,255,255,.04);
  display:flex; align-items:center; justify-content:center;
  font-weight:900; letter-spacing:.08em;
  font-size: 11px; color: var(--muted);
}
.abbr{ font-weight:900; letter-spacing:.10em; }

.score{
  display:flex; align-items:center; gap:10px;
  font-weight:900;
}
.score .g{ width: 18px; text-align:center; font-size: 18px; }
.score .x{ color: var(--muted); font-weight:900; font-size: 14px; }

.footer-note{ padding: 0 14px 14px 14px; color: var(--muted); font-size: 12px; }
.muted{ color: var(--muted); }

@media (max-width: 980px){
  .grid{ grid-template-columns: 1fr; }
  .matches{ grid-template-columns: 1fr; }
  .seedinput{ width: 140px; }
}
@media (max-width: 520px){
  .topbar{ flex-direction:column; align-items:flex-start; }
  .controls{ width:100%; justify-content:flex-start; }
  .seedbox{ width:100%; }
  .seedinput{ flex:1; width:auto; }
}

/* =========================================================
   ZONAS DA CLASSIFICAÇÃO (cores como na imagem)
   1-4  Libertadores   (azul)
   5-6  Pré-libertadores (ciano)
   7-12 Sul-americana  (verde)
   17-20 Rebaixados    (vermelho)
   ========================================================= */

/* garante que a cor de fundo/linha funcione bem */
.standings tbody tr{
  position: relative;
}

/* barra lateral colorida (igual ao visual de apps esportivos) */
.standings tbody tr.z-lib::before,
.standings tbody tr.z-pre::before,
.standings tbody tr.z-sul::before,
.standings tbody tr.z-reb::before{
  content:"";
  position:absolute;
  left:0;
  top:0;
  bottom:0;
  width:4px;
  border-radius: 0;
}

/* número da posição (coluna #) com cor */
.standings tbody tr.z-lib td.col-pos{ color: var(--lib); }
.standings tbody tr.z-pre td.col-pos{ color: var(--pre); }
.standings tbody tr.z-sul td.col-pos{ color: var(--sul); }
.standings tbody tr.z-reb td.col-pos{ color: var(--reb); }

/* barra colorida */
.standings tbody tr.z-lib::before{ background: var(--lib); }
.standings tbody tr.z-pre::before{ background: var(--pre); }
.standings tbody tr.z-sul::before{ background: var(--sul); }
.standings tbody tr.z-reb::before{ background: var(--reb); }

/* leve “tinta” no fundo da linha para destacar a zona (bem sutil) */
.standings tbody tr.z-lib{
  background: linear-gradient(90deg, rgba(74,163,255,.14), rgba(0,0,0,0)) !important;
}
.standings tbody tr.z-pre{
  background: linear-gradient(90deg, rgba(70,214,255,.12), rgba(0,0,0,0)) !important;
}
.standings tbody tr.z-sul{
  background: linear-gradient(90deg, rgba(46,204,113,.12), rgba(0,0,0,0)) !important;
}
.standings tbody tr.z-reb{
  background: linear-gradient(90deg, rgba(255,77,77,.13), rgba(0,0,0,0)) !important;
}

/* mantém hover bonito sem “matar” as cores */
.standings tbody tr:hover{
  filter: brightness(1.06);
}

/* legenda com as mesmas cores */
.p-lib{ background: var(--lib); }
.p-pre{ background: var(--pre); }
.p-sul{ background: var(--sul); }
.p-reb{ background: var(--reb); }

/* Neutro (13-16) */
:root{
  --neu:#7f8c8d; /* cinza neutro */
}

.standings tbody tr.z-neu::before{
  content:"";
  position:absolute;
  left:0;
  top:0;
  bottom:0;
  width:4px;
  background: var(--neu);
}

.standings tbody tr.z-neu td.col-pos{
  color: var(--neu);
}

/* degradê neutro sutil (proporcional às demais zonas) */
.standings tbody tr.z-neu{
  background: linear-gradient(90deg, rgba(127,140,141,.10), rgba(0,0,0,0)) !important;
}

/* =========================
   USER TEAM HIGHLIGHT
   ========================= */
.standings tbody tr.user-team {
  box-shadow: inset 0 0 0 2px #ffd700, 0 0 12px rgba(255, 215, 0, 0.3);
  position: relative;
  z-index: 1;
}

.standings tbody tr.user-team td.col-team .teamname {
  color: #ffd700;
}

.standings tbody tr.user-team::after {
  content: "★";
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  color: #ffd700;
  font-size: 14px;
}

.user-team-display {
  display: flex;
  align-items: center;
  margin-left: 12px;
}

.user-team-badge {
  background: linear-gradient(135deg, #ffd700, #ffaa00);
  color: #000;
  font-weight: 900;
  padding: 6px 12px;
  border-radius: 10px;
  font-size: 12px;
  letter-spacing: 0.08em;
}

/* =========================
   MODAL STYLES
   ========================= */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(4px);
}

.modal-content {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 28px;
  max-width: 420px;
  width: 90%;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  animation: modalIn 0.25s ease-out;
}

.modal-large {
  max-width: 700px;
}

@keyframes modalIn {
  from {
    opacity: 0;
    transform: scale(0.95) translateY(10px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.modal-title {
  font-size: 22px;
  font-weight: 900;
  margin: 0 0 8px 0;
  color: var(--text);
}

.modal-subtitle {
  color: var(--muted);
  font-size: 14px;
  margin: 0 0 20px 0;
}

.modal-result-title {
  font-size: 28px;
  font-weight: 900;
  margin: 0 0 12px 0;
}

.result-champion { color: #ffd700; }
.result-libertadores { color: var(--lib); }
.result-pre-libertadores { color: var(--pre); }
.result-sul-americana { color: var(--sul); }
.result-relegated { color: var(--reb); }
.result-neutral { color: var(--muted); }

.modal-position {
  font-size: 42px;
  font-weight: 900;
  margin: 16px 0;
  color: var(--text);
}

.modal-message {
  font-size: 16px;
  color: var(--text);
  margin: 0 0 24px 0;
}

.modal-btn {
  min-width: 140px;
  padding: 12px 24px;
}

/* =========================
   TEAM SELECTION GRID
   ========================= */
.team-selection-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  max-height: 400px;
  overflow-y: auto;
  padding: 8px;
}

.team-select-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 16px 8px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line);
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
  color: var(--text);
}

.team-select-btn:hover {
  background: rgba(74, 163, 255, 0.15);
  border-color: var(--lib);
  transform: translateY(-2px);
}

.team-select-short {
  font-size: 18px;
  font-weight: 900;
  letter-spacing: 0.1em;
  margin-bottom: 6px;
}

.team-select-name {
  font-size: 11px;
  color: var(--muted);
  text-align: center;
}

/* =========================
   ACHIEVEMENTS
   ========================= */
.achievements-header {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 20px;
}

.achievements-header h3 {
  margin: 0;
  font-size: 20px;
  font-weight: 900;
}

.serie-b-badge {
  background: var(--reb);
  color: #fff;
  font-size: 11px;
  font-weight: 900;
  padding: 4px 10px;
  border-radius: 6px;
}

.achievements-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 12px;
}

.achievement-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 16px 8px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line);
  border-radius: 12px;
}

.achievement-icon {
  font-size: 28px;
  margin-bottom: 8px;
}

.achievement-count {
  font-size: 24px;
  font-weight: 900;
  color: var(--text);
}

.achievement-label {
  font-size: 10px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 4px;
}

.achievement-negative {
  border-color: rgba(255, 77, 77, 0.3);
  background: rgba(255, 77, 77, 0.08);
}

@media (max-width: 600px) {
  .team-selection-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .achievements-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}
