/* competition.css — shared styling for the World Cup 2026 bracket competition.
 * Mobile-first (most traffic is phones). Per-page accent set via a theme class
 * on <body>: .theme-purple (Greg), .theme-dark (Dad), .theme-analysis (AI). */

:root {
  --bg: #0e1116;
  --panel: #171b22;
  --panel-2: #1f242d;
  --line: #2b313b;
  --text: #e8eaed;
  --muted: #9aa3af;
  --accent: #2c8a85;          /* default; overridden by theme */
  --accent-2: #5fc7c1;
  --hit: #2faf63;
  --hit-bg: rgba(47, 175, 99, 0.16);
  --miss: #d05a52;
  --miss-bg: rgba(208, 90, 82, 0.14);
  --pending: #6b7686;
  --gold: #e8b84b;
  --radius: 14px;
  --shadow: 0 6px 24px rgba(0, 0, 0, 0.35);
}

body.theme-purple { --accent: #7c4dff; --accent-2: #b39dff; }
body.theme-dark { --accent: #3a4a63; --accent-2: #7d93b8; }
body.theme-analysis { --accent: #2c8a85; --accent-2: #5fc7c1; }
body.theme-open { --accent: #d8732f; --accent-2: #f0a868; }

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: radial-gradient(1200px 600px at 50% -10%, #1b2230 0%, var(--bg) 55%);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

a { color: var(--accent-2); text-decoration: none; }
a:hover { text-decoration: underline; }

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

/* ---- header / nav ---- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 6px 0 16px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  letter-spacing: 0.2px;
  font-size: 1.05rem;
}
.brand .ball { font-size: 1.4rem; }
.nav { display: flex; gap: 6px; flex-wrap: wrap; }
.nav a {
  padding: 7px 12px;
  border-radius: 999px;
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--text);
  font-size: 0.85rem;
  font-weight: 600;
}
.nav a.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.nav a:hover { text-decoration: none; border-color: var(--accent-2); }

/* ---- page title ---- */
.page-head { margin: 8px 0 18px; }
.page-head h1 {
  margin: 0 0 4px;
  font-size: clamp(1.6rem, 4vw, 2.4rem);
  line-height: 1.05;
}
.page-head .accent-bar {
  height: 4px; width: 64px; border-radius: 4px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  margin: 10px 0 12px;
}
.page-head p { color: var(--muted); margin: 0; max-width: 60ch; }

/* ---- status banner ---- */
.status-banner {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; border-radius: 10px;
  background: var(--panel); border: 1px solid var(--line);
  font-size: 0.85rem; color: var(--muted); margin-bottom: 18px;
}
.status-banner .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--hit); flex: none; }
.status-banner.stale { border-color: var(--miss); color: #f2c4c0; }
.status-banner.stale .dot { background: var(--miss); }

/* ---- score pill ---- */
.score-pill {
  display: inline-flex; align-items: baseline; gap: 6px;
  background: var(--panel-2); border: 1px solid var(--line);
  padding: 6px 14px; border-radius: 999px; font-weight: 700;
}
.score-pill .big { font-size: 1.5rem; color: var(--accent-2); }
.score-pill .max { color: var(--muted); font-weight: 500; font-size: 0.85rem; }

/* ---- generic panel / cards ---- */
.panel {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow);
}
.grid-cards { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.card-link {
  display: block; padding: 18px; border-radius: var(--radius);
  background: var(--panel); border: 1px solid var(--line); color: var(--text);
  transition: transform 0.12s ease, border-color 0.12s ease;
}
.card-link:hover { transform: translateY(-2px); border-color: var(--accent-2); text-decoration: none; }
.card-link h3 { margin: 0 0 6px; font-size: 1.1rem; }
.card-link p { margin: 0; color: var(--muted); font-size: 0.88rem; }
.card-link .emoji { font-size: 1.6rem; }

/* ---- bracket ---- */
.bracket {
  display: grid; gap: 14px;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  align-items: start;
}
.round-col { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; }
.round-col h4 {
  margin: 0 0 4px; font-size: 0.78rem; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--muted);
}
.round-col .round-pts { font-size: 0.72rem; color: var(--accent-2); margin-bottom: 10px; }
.team-chip {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px; padding: 8px 10px; margin-bottom: 7px; border-radius: 9px;
  background: var(--panel-2); border: 1px solid var(--line);
  font-size: 0.9rem; font-weight: 600;
}
.team-chip .pts { font-size: 0.72rem; color: var(--muted); font-weight: 700; }
.team-chip.hit { background: var(--hit-bg); border-color: var(--hit); }
.team-chip.hit .pts { color: var(--hit); }
.team-chip.miss { background: var(--miss-bg); border-color: var(--miss); color: #f0b8b4; }
.team-chip.miss .name { text-decoration: line-through; opacity: 0.8; }
.team-chip.pending { opacity: 0.92; }
.team-chip.champion { border-color: var(--gold); background: rgba(232, 184, 75, 0.12); }
.team-chip.champion .pts { color: var(--gold); }

.legend { display: flex; gap: 14px; flex-wrap: wrap; margin: 12px 0 0; font-size: 0.78rem; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.swatch { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.swatch.hit { background: var(--hit); }
.swatch.miss { background: var(--miss); }
.swatch.pending { background: var(--pending); }

/* ---- leaderboard table ---- */
.lb { width: 100%; border-collapse: collapse; }
.lb th, .lb td { padding: 12px 10px; text-align: left; border-bottom: 1px solid var(--line); }
.lb th { font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
.lb td.num, .lb th.num { text-align: right; font-variant-numeric: tabular-nums; }
.lb tr.rank-1 td { background: rgba(232, 184, 75, 0.07); }
.lb .rankbadge {
  display: inline-flex; align-items: center; justify-content: center;
  width: 26px; height: 26px; border-radius: 50%; font-weight: 800; font-size: 0.85rem;
  background: var(--panel-2); border: 1px solid var(--line);
}
.lb tr.rank-1 .rankbadge { background: var(--gold); color: #2a2308; border-color: var(--gold); }
.lb .playercell { display: flex; align-items: center; gap: 10px; font-weight: 700; }
.lb .total { font-size: 1.15rem; font-weight: 800; color: var(--accent-2); }
.progress { height: 6px; border-radius: 4px; background: var(--panel-2); overflow: hidden; margin-top: 6px; }
.progress > i { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-2)); }

/* ---- head to head ---- */
.h2h-row {
  display: grid; grid-template-columns: 1fr auto 1fr; gap: 10px; align-items: center;
  padding: 10px 0; border-bottom: 1px solid var(--line);
}
.h2h-row .mid { font-size: 0.72rem; color: var(--muted); text-transform: uppercase; text-align: center; }
.h2h-side { display: flex; flex-wrap: wrap; gap: 6px; }
.h2h-side.right { justify-content: flex-end; }
.mini-chip { padding: 4px 9px; border-radius: 7px; font-size: 0.82rem; background: var(--panel-2); border: 1px solid var(--line); }
.mini-chip.hit { background: var(--hit-bg); border-color: var(--hit); }
.mini-chip.miss { background: var(--miss-bg); border-color: var(--miss); }
.mini-chip.agree { box-shadow: inset 0 0 0 1px var(--accent-2); }
.h2h-tally { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 18px; }
.h2h-tally .who { text-align: center; }
.h2h-tally .who .nm { font-weight: 800; font-size: 1.05rem; }
.h2h-tally .who .sc { font-size: 2rem; font-weight: 900; color: var(--accent-2); }
.h2h-tally .vs { color: var(--muted); font-weight: 700; }
.h2h-tally .lead { font-size: 0.8rem; color: var(--gold); }

/* rationale (analysis page) */
.rationale { margin-top: 22px; }
.rationale h3 { margin: 0 0 10px; }
.rationale dl { display: grid; gap: 12px; margin: 0; }
.rationale dt { font-weight: 700; color: var(--accent-2); margin-bottom: 2px; }
.rationale dd { margin: 0 0 4px; color: var(--text); opacity: 0.92; line-height: 1.5; }

.footer { margin-top: 40px; color: var(--muted); font-size: 0.78rem; text-align: center; }
.placeholder-flag {
  margin-top: 14px; padding: 10px 14px; border-radius: 10px; font-size: 0.82rem;
  background: rgba(232, 184, 75, 0.1); border: 1px solid var(--gold); color: #f0d896;
}

/* ---- pick editor ---- */
.edit-controls { display: flex; align-items: center; gap: 12px; margin-top: 14px; flex-wrap: wrap; }
.editor-toggle {
  padding: 9px 16px; border-radius: 999px; cursor: pointer; font-weight: 700; font-size: 0.9rem;
  background: var(--accent); color: #fff; border: 1px solid var(--accent);
}
.editor-toggle:hover { filter: brightness(1.08); }
.locknote { font-size: 0.85rem; color: var(--gold); }

.editor-host { margin: 0 0 8px; }
.editor-host[data-open="1"] { margin-bottom: 22px; }
.editor-panel {
  background: var(--panel); border: 1px solid var(--accent); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow);
}
.editor-intro { margin: 0 0 14px; color: var(--muted); font-size: 0.88rem; }
.editor-section { padding: 12px 0; border-top: 1px solid var(--line); }
.editor-section:first-of-type { border-top: none; padding-top: 0; }
.editor-section-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 10px; }
.editor-section-head h4 { margin: 0; font-size: 0.95rem; }
.editor-count { font-size: 0.8rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.editor-count.has { color: var(--accent-2); font-weight: 700; }
.editor-grid { display: flex; flex-wrap: wrap; gap: 7px; }
.editor-team {
  padding: 6px 11px; border-radius: 8px; cursor: pointer; font-size: 0.85rem; font-weight: 600;
  background: var(--panel-2); border: 1px solid var(--line); color: var(--text);
}
.editor-team:hover { border-color: var(--accent-2); }
.editor-team.on { background: var(--accent); border-color: var(--accent); color: #fff; }

.editor-footer { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); }
.editor-pin { display: flex; align-items: center; gap: 8px; font-size: 0.82rem; color: var(--muted); }
.editor-pin input {
  padding: 8px 10px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--bg); color: var(--text); font-size: 0.9rem; width: 140px;
}
.editor-save {
  padding: 9px 18px; border-radius: 999px; cursor: pointer; font-weight: 800; font-size: 0.9rem;
  background: var(--hit); color: #06210f; border: 1px solid var(--hit);
}
.editor-save:disabled { opacity: 0.6; cursor: default; }
.editor-cancel {
  padding: 9px 14px; border-radius: 999px; cursor: pointer; font-weight: 600; font-size: 0.88rem;
  background: transparent; color: var(--muted); border: 1px solid var(--line);
}
.editor-status { font-size: 0.85rem; }
.editor-status.ok { color: var(--hit); }
.editor-status.err { color: var(--miss); }
.editor-status.warn { color: var(--gold); }

/* ---- traditional bracket tree ---- */
.editor-toggle.ghost { background: var(--panel); color: var(--text); border-color: var(--line); }
.editor-toggle.ghost:hover { border-color: var(--accent-2); }

.tree {
  display: flex; align-items: stretch; gap: 10px;
  overflow-x: auto; padding: 6px 2px 14px;
}
.tree-col { display: flex; flex-direction: column; justify-content: space-around; gap: 8px; min-width: 132px; }
.tree-col.tree-final { justify-content: center; min-width: 150px; }
.tree-col-head {
  font-size: 0.66rem; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--muted); text-align: center; margin-bottom: 4px;
}
.tree-col-head.gold { color: var(--gold); }

.tn {
  background: var(--panel); border: 1px solid var(--line); border-radius: 9px;
  overflow: hidden; flex: none;
}
.tn.round-final { border-color: var(--gold); }
.tn-slot {
  display: flex; align-items: center; gap: 6px; padding: 6px 8px;
  font-size: 0.82rem; font-weight: 600; border-top: 1px solid var(--line);
}
.tn-slot:first-child { border-top: none; }
.tn-flag { flex: none; font-size: 0.95rem; min-width: 1.1em; }
.tn-name { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tn-slot.tbd { color: var(--muted); font-weight: 500; font-style: italic; }
.tn-slot.picked { background: rgba(124, 77, 255, 0.16); }
body.theme-dark .tn-slot.picked { background: rgba(125, 147, 184, 0.18); }
body.theme-analysis .tn-slot.picked { background: rgba(95, 199, 193, 0.16); }
body.theme-open .tn-slot.picked { background: rgba(216, 115, 47, 0.18); }
.tn-slot.won { background: var(--hit-bg); }
.tn-slot.won .tn-name { color: var(--hit); }
.tn-slot.lost { background: var(--miss-bg); }
.tn-slot.lost .tn-name { text-decoration: line-through; opacity: 0.75; }
.tn-slot.selectable { cursor: pointer; }
.tn-slot.selectable:hover { background: rgba(255, 255, 255, 0.06); }
.tn-pts { font-size: 0.68rem; font-weight: 800; color: var(--accent-2); flex: none; }
.tn-slot.won .tn-pts { color: var(--hit); }
.tn-slot.lost .tn-pts { color: var(--miss); }

.tree-champion {
  margin-top: 10px; text-align: center; font-weight: 800;
  padding: 10px 8px; border-radius: 10px; border: 1px solid var(--gold);
  background: rgba(232, 184, 75, 0.12); color: var(--gold);
  display: flex; align-items: center; justify-content: center; gap: 6px;
}
.tree-msg { color: var(--muted); }

.tree-savebar {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  background: var(--panel); border: 1px solid var(--accent); border-radius: var(--radius);
  padding: 12px 14px; margin-bottom: 8px;
}
.tree-savehint { font-size: 0.82rem; color: var(--muted); flex: 1 1 220px; }

/* head-to-head: two trees */
.h2h-tree { margin-bottom: 18px; border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; background: var(--panel); }
.h2h-tree-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 8px; font-weight: 800; }
.h2h-tree-score { color: var(--accent-2); font-size: 0.9rem; }

/* mobile round-by-round */
.round-picker { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.round-btn {
  padding: 7px 13px; border-radius: 999px; cursor: pointer; font-weight: 700; font-size: 0.82rem;
  background: var(--panel); border: 1px solid var(--line); color: var(--text);
}
.round-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.round-list { display: flex; flex-direction: column; gap: 10px; }
.round-list .tn { max-width: 420px; }

@media (max-width: 560px) {
  .bracket { grid-template-columns: 1fr 1fr; }
  .h2h-row { grid-template-columns: 1fr; }
  .h2h-side.right { justify-content: flex-start; }
}
