:root{
  /* thème clair */
  --bg:#f6f7fb;
  --panel:#ffffff;
  --panel2:#fafbff;
  --text:#0f172a;
  --muted:#6b7280;
  --border:#e6e9f2;
  --accent:#7c3aed;
  --accent2:#a78bfa;

  --chip-bg:linear-gradient(90deg,#f3f4ff 0,#f8f3ff 100%);
  --shadow:0 10px 22px rgba(15,23,42,.06);
  --radius:14px;

  --match-bg:#ffffff;
  --match-shadow:0 8px 16px rgba(15,23,42,.05);
  --line-bg:#f7f8fc;
  --win-bg:#ede9fe;
  --win-border:#c4b5fd;
  --win-text:#2e1065;
}

/* layout de base */
*{box-sizing:border-box}
html{scroll-behavior:smooth}
body{
  margin:0; background:var(--bg); color:var(--text);
  font-family:ui-sans-serif,system-ui,-apple-system,Segoe UI,Roboto,Arial;
}
.wrap{max-width:1320px;margin:28px auto;padding:0 18px}
h1{margin:0 0 10px; letter-spacing:.2px}
.muted{color:var(--muted)}

/* nav */
.topnav{
  position:sticky; top:0; z-index:30;
  background:rgba(246,247,251,.92); backdrop-filter:blur(6px);
  padding:12px 18px; margin:16px -18px 18px; border-bottom:1px solid var(--border);
}
.topnav .btns{display:flex;gap:12px;flex-wrap:wrap}
.btn{
  text-decoration:none; color:#fff; font-weight:800; letter-spacing:.2px;
  padding:10px 16px; border-radius:999px;
  background:linear-gradient(90deg,var(--accent),var(--accent2));
  box-shadow:var(--shadow); transition:transform .12s ease;
}
.btn:hover{transform:translateY(-1px)}

/* section */
.board{
  background:var(--panel);
  border:1px solid var(--border);
  border-radius:var(--radius);
  box-shadow:var(--shadow);
  padding:18px; margin:22px 0;
}
.board h2{
  margin:0 0 14px; padding:12px 14px;
  border:1px solid var(--border);
  background:var(--chip-bg);
  border-radius:12px;
}
.match-grid{
  display:grid; gap:10px;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
}
/* grille des tours */
.rounds{
  display:grid;                /* 1 grille globale */
  gap:16px;
  grid-template-columns: 1fr;  /* chaque round = pleine largeur */
}
@media(max-width:1100px){ .rounds{grid-template-columns:repeat(2,minmax(270px,1fr))} }
@media(max-width:620px){ .rounds{grid-template-columns:1fr} }

.round{
  border:1px solid var(--border);
  border-radius:12px;
  background:var(--panel2);
  box-shadow:var(--shadow);
  padding:10px 12px;
}

/* titre de colonne (Huitièmes / Quarts / …) façon chip */
.round h3{
  margin:0;
  font-size:13px; text-transform:uppercase; letter-spacing:.5px;
  color:#111827;
  background:var(--chip-bg);
  border:1px solid var(--border);
  border-radius:999px;
  padding:7px 12px;
  width:max-content;
  box-shadow:inset 0 1px 0 rgba(255,255,255,.6);
}

.sub{
  font-size:12px; font-weight:700; color:var(--muted);
  margin:2px 0 6px 2px;
}
.scope-chip{
  display:inline-block;
  padding:6px 10px; border-radius:999px; font-weight:800; font-size:12px;
  background:linear-gradient(90deg, var(--accent), var(--accent2));
  color:#fff; border:1px solid rgba(124,58,237,.35);
  box-shadow:0 4px 10px rgba(124,58,237,.15) inset;
}
/* carte match */
.match{
  position:relative;
  border:1px solid var(--border);
  background:var(--match-bg);
  border-radius:12px;
  box-shadow:var(--match-shadow);
  padding:10px;               /* carte extérieure */
}
/* gagnant en évidence */
.mrow.win{
  background:var(--win-bg);
  border-color:var(--win-border);
}
/* petit filet violet à gauche quand il y a un gagnant */
.match:has(.mrow.win)::before{
  content:""; position:absolute; inset:0 auto 0 0; width:4px;
  background:var(--accent); border-radius:12px 0 0 12px;
}
.mrow.win .pname{ color:var(--win-text) }
.mrow.win .score{ background:#c7bffd; color:#1b123f; border-color:#b9a8ff }
.mrows{ display:grid; gap:8px; }
.mrow{
  display:flex; align-items:center; gap:8px;
  background:var(--line-bg);
  border:1px solid #eef1f6;
  border-radius:10px;
  padding:8px 10px;
}
/* Titre pleine largeur */
.round-title{
  display:flex; align-items:center; justify-content:flex-start;
  gap:10px;
  margin:0 0 10px 0;
  padding:10px 12px;
  border-radius:10px;
  background:linear-gradient(90deg, rgba(124,58,237,.12), rgba(167,139,250,.10));
  border:1px solid var(--border);
  font-weight:900; letter-spacing:.3px; text-transform:uppercase;
}
/* petite barre d’accent à gauche (devient violette si gagnant sur la ligne) */
.match::before{
  content:""; position:absolute; left:0; top:0; bottom:0; width:4px;
  background:transparent;
}
.line.win ~ .line.win, .line.win{ /* si une ligne win existe, colorer la barre */
  /* hack léger : on forcera via JS la classe sur les 2 lignes mais une seule sera win */
}
.match .line.win:first-of-type ~ .line,
.match .line.win:first-of-type{
  /* rien, juste laisser la barre colorée via pseudo élément ci-dessous */
}
.match .line.win:first-of-type::before{ content:""; }

.match:has(.line.win)::before{ background:var(--accent); }

/* ligne joueur */
.line{
  display:flex; align-items:center; gap:10px;
  padding:8px 10px; border-radius:10px; background:var(--line-bg);
  border:1px solid #eef1f6;
}
.line + .line{ margin-top:8px; }

.pname{
  flex:1 1 auto;
  font-weight:700;
  white-space:normal; word-break:break-word; overflow:hidden;
}
.line{
  display:flex;
  justify-content:space-between;
  gap:10px;
  padding:8px 10px;
  border-radius:10px;
  background:var(--line-bg);
  border:1px solid #eef1f6;
  align-items:center;        /* verticalement centré */
}
.score{
  flex-shrink:0;
  min-width:34px; text-align:center;
  font-weight:900; letter-spacing:.2px;
  background:#eef1ff; color:#1f2a63;
  border:1px solid #dee6ff;
  padding:4px 10px; border-radius:999px;
}

/* score en pastille */
.score{
  min-width:34px; text-align:center;
  font-weight:900; letter-spacing:.2px;
  background:#eef1ff; color:#1f2a63;
  border:1px solid #dee6ff;
  padding:4px 10px; border-radius:999px;
}

/* état gagnant : plus de contraste, texte plus dense */
.line.win{
  background:var(--win-bg);
  border-color:var(--win-border);
}
.line.win .pname{font-weight:900; color:var(--win-text)}
.line.win .score{
  background:#c7bffd; color:#1b123f; border-color:#b9a8ff;
}

/* message vide */
.empty{
  color:var(--muted); padding:10px 12px;
  border:1px dashed var(--border); border-radius:12px;
  background:#fafbff;
}


/* ===== ULTRA COMPACT ===== */
body.ultra .board{padding:8px;margin:10px 0;border-radius:10px;box-shadow:0 3px 10px rgba(0,0,0,.10)}
body.ultra .board h2{padding:6px 8px;margin:0 0 8px;font-size:18px}

body.ultra .rounds{
  gap:10px;
  grid-template-columns:repeat(4,minmax(200px,1fr));
}
@media(max-width:1100px){ body.ultra .rounds{grid-template-columns:repeat(2,minmax(190px,1fr))} }
@media(max-width:640px){  body.ultra .rounds{grid-template-columns:1fr} }
body.ultra .scope-chip{padding:4px 8px;font-size:11.5px}
body.ultra .round{padding:8px}
body.ultra .match-grid{gap:8px}
body.ultra .round h3{font-size:12px;padding:4px 8px;border-radius:7px;margin:0 0 2px}
body.ultra .sub      {font-size:11px;margin:4px 0 4px 2px;color:#7a87a5}
body.ultra .round-title{padding:8px 10px;margin-bottom:6px}
body.ultra .match{padding:8px}
body.ultra .line {padding:6px 7px;border-radius:8px;gap:6px}
body.ultra .pname{font-size:13.5px}
body.ultra .score{font-size:12.5px}
body.ultra .mrow{padding:6px 8px}

/* small header chips inside a column */
.group-chip{
  display:inline-block;margin:4px 0 2px 2px;padding:3px 7px;border-radius:999px;
  font-size:11px;font-weight:800;letter-spacing:.2px;color:#4b4f60;
  background:rgba(124,58,237,.08);border:1px solid rgba(124,58,237,.18);
}
.group-block{ margin-top:8px }

/* --- chips de groupe : toujours compactes --- */
.group-chip{
  display:inline-flex !important;      /* au cas où un style hérité mettrait block */
  align-items:center;
  gap:6px;
  width:auto !important;               /* jamais 100% */
  max-width:100%;
  padding:4px 9px;
  margin:6px 0 4px 0;                  /* un peu d’air au-dessus, moins en dessous */
  border-radius:999px;
  font-size:11.5px;
  font-weight:800;
  letter-spacing:.2px;
  color:#4b4f60;
  background:rgba(124,58,237,.08);
  border:1px solid rgba(124,58,237,.18);
  box-shadow:inset 0 1px 0 rgba(255,255,255,.6);
}

/* Si jamais d’anciennes .sub traînent encore, on les compacte aussi */
.sub{ display:inline-flex; width:auto; padding:4px 8px; border-radius:999px; background:transparent }

/* --- colonne / grille encore plus serrées --- */
.rounds{ gap:12px }
.round{ gap:8px }
.round h3{ margin-bottom:4px }

/* --- carte match + lignes : resserré, bordure plus discrète --- */
.match{
  padding:8px 10px;
  border-radius:10px;
  border:1px solid var(--border);
  box-shadow:var(--match-shadow);
}
.line{
  padding:7px 9px;
  gap:8px;
  border-radius:8px;
  background:var(--line-bg);
  border:1px solid #eef1f6;
}

/* pastille de score : taille fixe + centrage stable */
.score{
  min-width:28px;
  height:26px;
  line-height:26px;
  padding:0 8px;
  border-radius:999px;
  display:inline-block;
  text-align:center;
  font-weight:900;
  background:#eef1ff;
  color:#1f2a63;
  border:1px solid #dee6ff;
}

/* gagnant : un peu moins “criard” tout en restant lisible */
.line.win{
  background:var(--win-bg);
  border-color:var(--win-border);
}
.line.win .pname{ font-weight:800; color:var(--win-text) }
.line.win .score{
  background:#dcd4ff; color:#20165a; border-color:#cfc2ff;
}

/* Empêche n’importe quel style de forcer 100% de largeur sur les chips */
.round > .group-chip { width:auto !important; }

.meta{display:flex;gap:8px;align-items:center;margin-top:8px}
.chip{
  display:inline-block; padding:4px 8px; border-radius:999px; font-weight:800; font-size:12px;
  background:#F7F8FC; color:#000;
  border:1px solid rgba(0, 0, 0, 0.644);
}
.topbar{
  position: sticky; top: 0; z-index: 1000;
  display: flex; align-items: center;
  padding: 10px 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
  backdrop-filter: blur(6px);
}
.homebtn{
  display: inline-flex; align-items: center; gap: 10px;
  padding: 8px 12px;
  border-radius: var(--radius);
  color: var(--text); text-decoration: none;
  border: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(255,255,255,.5), rgba(255,255,255,.0));
  transition: transform .15s ease, border-color .15s ease, background .2s ease;
}
.homebtn:hover{ transform: translateY(-1px); border-color: var(--accent2); }
.homebtn:focus{ outline: 3px solid #94a3b8; outline-offset: 2px; }
.homebtn svg{ opacity: .9; }
