:root {
  --bg: #0b132b;
  --panel: #1c2541;
  --panel-2: #243156;
  --line: #2f3e63;
  --text: #e8ecf5;
  --muted: #9aa7c7;
  --brazil: #009c3b;
  --brazil-2: #ffdf00;
  --accent: #3a86ff;
  --win: #2ecc71;
  --radius: 14px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: radial-gradient(1200px 600px at 70% -10%, #15224a 0%, var(--bg) 60%);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}

header.hero {
  padding: 28px 20px 18px;
  text-align: center;
  background: linear-gradient(90deg, var(--brazil) 0%, var(--brazil-2) 100%);
  color: #0b132b;
}
header.hero h1 { margin: 0; font-size: clamp(1.4rem, 4vw, 2.2rem); letter-spacing: -0.5px; }
header.hero p { margin: 6px 0 0; font-weight: 600; opacity: 0.85; }

.wrap { max-width: 1000px; margin: 0 auto; padding: 18px 16px 60px; }

.tabs { display: flex; flex-wrap: wrap; gap: 8px; margin: 18px 0 22px; }
.tab {
  background: var(--panel); color: var(--muted); border: 1px solid var(--line);
  padding: 9px 16px; border-radius: 999px; cursor: pointer; font-weight: 600;
  font-size: 0.92rem; transition: all 0.15s;
}
.tab:hover { color: var(--text); }
.tab.active { background: var(--accent); color: #fff; border-color: var(--accent); }

.panel {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 18px; margin-bottom: 18px;
}
.panel h2 { margin: 0 0 4px; font-size: 1.15rem; }
.panel .sub { color: var(--muted); font-size: 0.85rem; margin: 0 0 14px; }
.view { display: none; }
.view.active { display: block; }

table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th, td { padding: 9px 8px; text-align: center; }
th { color: var(--muted); font-weight: 600; border-bottom: 1px solid var(--line); font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em; }
td.team-cell { text-align: left; font-weight: 600; white-space: nowrap; }
tbody tr { border-bottom: 1px solid var(--line); }
tbody tr:last-child { border-bottom: none; }
tr.qualify-1 td:first-child { box-shadow: inset 3px 0 0 var(--win); }
tr.qualify-2 td:first-child { box-shadow: inset 3px 0 0 var(--accent); }
tr.is-focus { background: rgba(0, 156, 59, 0.12); }
.pts { font-weight: 700; }
.flag { margin-right: 8px; }

.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 0.78rem; color: var(--muted); margin-top: 12px; }
.legend span::before { content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: middle; }
.legend .l1::before { background: var(--win); }
.legend .l2::before { background: var(--accent); }

.result-row, .fixture-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; padding: 10px 4px; border-bottom: 1px solid var(--line); font-size: 0.9rem;
}
.result-row:last-child, .fixture-row:last-child { border: none; }
.match-teams { display: flex; align-items: center; gap: 10px; flex: 1; }
.score { font-weight: 800; background: var(--panel-2); padding: 2px 10px; border-radius: 8px; min-width: 54px; text-align: center; }
.match-meta { color: var(--muted); font-size: 0.76rem; text-align: right; min-width: 120px; }
.badge { font-size: 0.68rem; background: var(--panel-2); color: var(--muted); padding: 2px 8px; border-radius: 999px; }

.scenario { border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; background: var(--panel-2); }
.scenario h3 { margin: 0 0 4px; font-size: 1.02rem; }
.scenario .opp-now { color: var(--brazil-2); font-weight: 700; }
.path { list-style: none; padding: 0; margin: 12px 0 0; }
.path li { display: flex; gap: 12px; padding: 10px 0; border-bottom: 1px dashed var(--line); }
.path li:last-child { border: none; }
.path .round { font-weight: 700; min-width: 110px; }
.path .detail { color: var(--muted); font-size: 0.85rem; }
.path .detail b { color: var(--text); }

.bracket-row { display: flex; align-items: center; gap: 10px; padding: 9px 4px; border-bottom: 1px solid var(--line); font-size: 0.88rem; }
.bracket-row:last-child { border: none; }
.bracket-row.brazil { background: rgba(255, 223, 0, 0.08); border-radius: 8px; }
.bracket-row .mnum { color: var(--muted); min-width: 42px; font-size: 0.78rem; }
.bracket-row .teams { flex: 1; font-weight: 600; }
.bracket-row .where { color: var(--muted); font-size: 0.76rem; text-align: right; min-width: 150px; }

.note { font-size: 0.82rem; color: var(--muted); background: var(--panel-2); border-left: 3px solid var(--accent); padding: 10px 12px; border-radius: 8px; margin-top: 12px; }
.sources a { color: var(--accent); text-decoration: none; }
.sources a:hover { text-decoration: underline; }
.sources li { margin: 4px 0; font-size: 0.85rem; }
footer { text-align: center; color: var(--muted); font-size: 0.78rem; padding: 20px; }

/* ---- shared bits ---- */
h3.sec { margin: 20px 0 10px; font-size: 0.82rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); border-bottom: 1px solid var(--line); padding-bottom: 6px; }
h3.sec .sec-date { float: right; text-transform: none; letter-spacing: 0; color: var(--accent); font-weight: 600; }
.btn { background: var(--panel-2); color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 8px 14px; cursor: pointer; font-weight: 600; font-size: 0.85rem; }
.btn:hover { border-color: var(--accent); }
.btn.back { margin-bottom: 14px; }
.search { width: 100%; padding: 10px 14px; margin: 4px 0 16px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; color: var(--text); font-size: 0.9rem; }
.search:focus { outline: none; border-color: var(--accent); }

/* ---- team grid ---- */
.team-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin-bottom: 8px; }
.team-card { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; cursor: pointer; color: var(--text); text-align: left; position: relative; transition: transform 0.1s, border-color 0.15s; }
.team-card:hover { transform: translateY(-2px); border-color: var(--accent); }
.tc-flag { font-size: 1.8rem; line-height: 1; }
.tc-name { font-weight: 700; font-size: 0.95rem; }
.tc-form { color: var(--muted); font-size: 0.8rem; font-variant-numeric: tabular-nums; }
.tc-rank { position: absolute; top: 10px; right: 12px; font-size: 0.72rem; color: var(--brazil-2); font-weight: 700; }

/* ---- team detail ---- */
.team-head { display: flex; align-items: center; gap: 16px; margin-bottom: 6px; }
.th-flag { font-size: 3rem; line-height: 1; }
.team-head h2 { margin: 0; }
.team-detail-grid { display: grid; grid-template-columns: minmax(220px, 360px) 1fr; gap: 22px; align-items: start; }
@media (max-width: 680px) { .team-detail-grid { grid-template-columns: 1fr; } }
.tactics-style { font-size: 0.95rem; }
.pitch-cap { color: var(--muted); font-size: 0.78rem; margin: 8px 0 0; }
.sw { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 10px; }
@media (max-width: 460px) { .sw { grid-template-columns: 1fr; } }
.sw h4 { margin: 0 0 8px; font-size: 0.82rem; color: var(--muted); }
ul.chips { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; }
ul.chips li { font-size: 0.83rem; padding: 6px 10px; border-radius: 8px; line-height: 1.35; }
ul.chips li.good { background: rgba(46, 204, 113, 0.12); border-left: 3px solid var(--win); }
ul.chips li.bad { background: rgba(231, 76, 60, 0.12); border-left: 3px solid #e74c3c; }

/* ---- players table ---- */
table.players td { text-align: left; }
.pos-badge { width: 48px; }
.pos-badge span { display: inline-block; min-width: 38px; text-align: center; font-size: 0.72rem; font-weight: 700; background: var(--accent); color: #fff; border-radius: 6px; padding: 2px 6px; }
.note-cell { color: var(--muted); font-size: 0.82rem; }
table.players tr.star { background: rgba(255, 223, 0, 0.08); }

/* ---- formation pitch (SVG) ---- */
svg.pitch { width: 100%; max-width: 360px; border-radius: 12px; display: block; box-shadow: 0 6px 20px rgba(0,0,0,0.35); }
.pdot circle { fill: var(--brazil-2); stroke: #0b3d1a; stroke-width: 0.5; }
.pdot.empty circle { fill: rgba(255,255,255,0.35); }
.pdot text { text-anchor: middle; fill: #fff; paint-order: stroke; stroke: rgba(0,0,0,0.65); stroke-width: 0.5; }
.pdot .pcode { font-size: 2.6px; font-weight: 700; fill: var(--brazil-2); }
.pdot.empty .pcode { fill: #cfe; }
.pdot .pname { font-size: 2.9px; font-weight: 700; }

/* ---- matchup ---- */
.match-pickers { display: flex; align-items: center; gap: 10px; margin: 6px 0 18px; }
.match-pickers .pick { margin: 0; flex: 1; }
.match-pickers .vs { color: var(--muted); font-weight: 700; }
.vs-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 12px; padding: 12px 16px; }
.vs-team { display: flex; align-items: center; gap: 12px; flex: 1; }
.vs-team.right { justify-content: flex-end; text-align: right; }
.vs-flag { font-size: 2.4rem; line-height: 1; }
.vs-mid { text-align: center; padding: 0 6px; }
.matchup-pitches { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin: 18px 0; justify-items: center; }
.matchup-pitches svg.pitch { max-width: 300px; }
.cmp-table { width: 100%; border-collapse: collapse; margin-top: 6px; }
.cmp-table td { padding: 9px 10px; border-bottom: 1px solid var(--line); font-size: 0.9rem; vertical-align: top; }
.cmp-table .cmp-a { text-align: right; width: 40%; }
.cmp-table .cmp-b { text-align: left; width: 40%; }
.cmp-table .cmp-label { text-align: center; color: var(--muted); font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.04em; white-space: nowrap; }
.cmp-table .win { color: var(--brazil-2); font-weight: 800; }
@media (max-width: 560px) { .matchup-pitches svg.pitch { max-width: 100%; } .vs-flag { font-size: 1.8rem; } }

@media (max-width: 560px) {
  .match-meta { display: none; }
  .bracket-row .where { display: none; }
  th.hide-sm, td.hide-sm { display: none; }
}
