:root {
  --fond: #0e1116;
  --fond-2: #161b22;
  --fond-3: #1f2630;
  --bord: #2c3440;
  --texte: #e6e9ee;
  --discret: #8b95a3;
  --accent: #f5b301;
  --accent-texte: #1a1300;
  --bleu: #4ea1ff;
  --vert: #3fb950;
  --rouge: #f85149;
  --orange: #ff9f43;
  --rayon: 8px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--fond);
  color: var(--texte);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--bleu); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0 0 .6em; line-height: 1.25; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }
h4 { font-size: .85rem; text-transform: uppercase; letter-spacing: .04em; color: var(--discret); }
p { margin: 0 0 .8em; }
.discret { color: var(--discret); }
.petit { font-size: .85rem; }
pre, code { font-family: ui-monospace, Consolas, monospace; }

/* ---- navigation ---- */
#nav {
  display: flex; flex-wrap: wrap; align-items: center; gap: .3rem 1rem;
  padding: .6rem 1rem; background: var(--fond-2); border-bottom: 1px solid var(--bord);
  position: sticky; top: 0; z-index: 10;
}
#nav .marque { font-weight: 700; color: var(--accent); font-size: 1.1rem; margin-right: .5rem; }
#nav .liens { display: flex; flex-wrap: wrap; gap: .2rem; flex: 1; }
#nav .liens a, #nav .compte a { color: var(--texte); padding: .3rem .6rem; border-radius: 6px; }
#nav .liens a:hover, #nav .compte a:hover { background: var(--fond-3); text-decoration: none; }
#nav .liens a.actif { background: var(--fond-3); color: var(--accent); }
#nav .compte { display: flex; gap: .3rem; align-items: center; }
#bandeau:empty { display: none; }
#bandeau { background: #3a2c00; color: #ffd76a; padding: .5rem 1rem; text-align: center; }

main { max-width: 1280px; margin: 0 auto; padding: 1.2rem 1rem 3rem; }

/* ---- blocs ---- */
.carte {
  background: var(--fond-2); border: 1px solid var(--bord); border-radius: var(--rayon);
  padding: 1rem; margin-bottom: 1rem; min-width: 0;
}
.carte.erreur { border-color: var(--rouge); color: var(--rouge); }
.grille { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.deux-colonnes { display: grid; gap: 1rem; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
@media (max-width: 860px) { .deux-colonnes { grid-template-columns: 1fr; } }
.entete { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem 1rem; margin-bottom: 1rem; }
.entete h1 { margin: 0; flex: 1; min-width: 200px; }
.barre { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; }
.infos { display: flex; flex-wrap: wrap; gap: .3rem .9rem; color: var(--discret); margin-bottom: .8rem; }
.infos b { color: var(--texte); font-weight: 600; }
.vide { color: var(--discret); font-style: italic; }

/* ---- boutons et formulaires ---- */
button, .bouton {
  font: inherit; cursor: pointer; border: 1px solid transparent; border-radius: 6px;
  padding: .4rem .85rem; background: var(--accent); color: var(--accent-texte); font-weight: 600;
  display: inline-flex; align-items: center; gap: .35rem; white-space: nowrap;
}
.bouton:hover { text-decoration: none; }
button:hover, .bouton:hover { filter: brightness(1.1); }
button:disabled { opacity: .5; cursor: default; filter: none; }
button.secondaire, .bouton.secondaire { background: var(--fond-3); color: var(--texte); border-color: var(--bord); }
button.danger { background: transparent; color: var(--rouge); border-color: var(--rouge); }
button.petit { padding: .15rem .5rem; font-size: .85rem; }
input, select, textarea {
  font: inherit; color: var(--texte); background: var(--fond); border: 1px solid var(--bord);
  border-radius: 6px; padding: .4rem .55rem; width: 100%; min-width: 0;
}
input:focus, select:focus, textarea:focus, button:focus-visible { outline: 2px solid var(--bleu); outline-offset: 1px; }
input[type=checkbox] { width: auto; }
textarea { resize: vertical; }
.champ { display: flex; flex-direction: column; gap: .25rem; margin-bottom: .75rem; }
.champ > span { font-size: .85rem; color: var(--discret); }
.champ small { color: var(--discret); font-size: .8rem; }
.case { display: flex; gap: .5rem; align-items: center; margin-bottom: .6rem; cursor: pointer; }
.champs-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 .8rem; }
@media (max-width: 560px) { .champs-2 { grid-template-columns: 1fr; } }
.formulaire { max-width: 420px; margin: 2rem auto; }

dialog.fenetre {
  background: var(--fond-2); color: var(--texte); border: 1px solid var(--bord); border-radius: var(--rayon);
  padding: 1.2rem; width: min(640px, calc(100vw - 32px)); max-height: calc(100vh - 32px);
}
dialog::backdrop { background: rgb(0 0 0 / .6); }
.actions { display: flex; justify-content: flex-end; gap: .5rem; margin-top: 1rem; }

/* ---- tableaux ---- */
.defile { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: .45rem .6rem; text-align: left; border-bottom: 1px solid var(--bord); vertical-align: middle; }
th { font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; color: var(--discret); font-weight: 600; }
td.nombre, th.nombre { text-align: right; font-variant-numeric: tabular-nums; }
tr.qualifie td:first-child { box-shadow: inset 3px 0 var(--vert); }
table.compact th, table.compact td { padding: .35rem .3rem; }
table.compact th:nth-child(2), table.compact td:nth-child(2) { width: 100%; }

/* ---- badges ---- */
.badge {
  display: inline-block; padding: .05rem .5rem; border-radius: 999px; font-size: .78rem; font-weight: 600;
  background: var(--fond-3); color: var(--discret); border: 1px solid var(--bord); white-space: nowrap;
}
.badge.vert { color: var(--vert); border-color: color-mix(in srgb, var(--vert) 50%, transparent); }
.badge.bleu { color: var(--bleu); border-color: color-mix(in srgb, var(--bleu) 50%, transparent); }
.badge.orange { color: var(--orange); border-color: color-mix(in srgb, var(--orange) 50%, transparent); }
.badge.rouge { color: var(--rouge); border-color: color-mix(in srgb, var(--rouge) 50%, transparent); }
.badge.or { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 50%, transparent); }

/* ---- onglets ---- */
.onglets { display: flex; gap: .2rem; border-bottom: 1px solid var(--bord); margin-bottom: 1rem; overflow-x: auto; }
.onglets button {
  background: none; color: var(--discret); border-radius: 0; border-bottom: 2px solid transparent; padding: .5rem .9rem;
}
.onglets button.actif { color: var(--texte); border-bottom-color: var(--accent); }

/* ---- cartes de tournois ---- */
.tournoi-carte { display: block; color: inherit; }
.tournoi-carte:hover { text-decoration: none; border-color: var(--accent); }
.tournoi-carte h3 { color: var(--texte); }

/* ---- arbres ---- */
.arbre { display: flex; gap: 1.6rem; overflow-x: auto; padding-bottom: .5rem; }
.tour { display: flex; flex-direction: column; min-width: 190px; }
.tour-matchs { display: flex; flex-direction: column; justify-content: space-around; flex: 1; gap: .6rem; }
.match {
  display: block; background: var(--fond-3); border: 1px solid var(--bord); border-radius: 6px;
  color: var(--texte); overflow: hidden; position: relative;
}
.match:hover { border-color: var(--bleu); text-decoration: none; }
.match .ligne { display: flex; justify-content: space-between; gap: .5rem; padding: .25rem .55rem; }
.match .ligne + .ligne { border-top: 1px solid var(--bord); }
.match .nom { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.match .score { font-variant-numeric: tabular-nums; font-weight: 700; min-width: 1.5em; text-align: right; }
.match .gagnant { color: var(--accent); font-weight: 600; }
.match .perdant { color: var(--discret); }
.match.exempt { opacity: .45; }
.match.fantome { visibility: hidden; }
.match.statut-en_cours { border-color: var(--vert); box-shadow: 0 0 0 1px var(--vert); }
.match.statut-a_valider { border-color: var(--orange); }
.match.statut-litige { border-color: var(--rouge); }
.section-arbre + .section-arbre { margin-top: 1.5rem; }

.podium { display: flex; gap: 1rem; flex-wrap: wrap; align-items: flex-end; }
.podium > div { text-align: center; background: var(--fond-3); border-radius: var(--rayon); padding: .6rem 1.2rem; min-width: 120px; }
.podium .rang { font-size: 1.6rem; }
.podium .p1 { border: 1px solid var(--accent); padding-top: 1.2rem; }

/* ---- matchs ---- */
.face-a-face { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 1rem; text-align: center; }
.face-a-face .equipe { font-size: 1.4rem; font-weight: 700; overflow-wrap: anywhere; }
.face-a-face .gagnant { color: var(--accent); }
.face-a-face .resultat { font-size: 2.4rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.liste-matchs { display: flex; flex-direction: column; gap: .4rem; }
.ligne-match {
  display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr) auto; gap: .6rem; align-items: center;
  padding: .45rem .6rem; background: var(--fond-3); border-radius: 6px; color: var(--texte);
}
.ligne-match:hover { text-decoration: none; outline: 1px solid var(--bleu); }
.ligne-match .a { text-align: right; }
.ligne-match .sc { font-weight: 700; font-variant-numeric: tabular-nums; min-width: 3.2em; text-align: center; }
.ligne-match .meta { grid-column: 1 / -1; font-size: .8rem; color: var(--discret); }
.manches td input { width: 5.5em; }

/* ---- shoutbox ---- */
.shoutbox .messages { max-height: 340px; overflow-y: auto; display: flex; flex-direction: column; gap: .3rem; margin-bottom: .6rem; }
.shoutbox .msg { overflow-wrap: anywhere; }
.shoutbox .msg b { color: var(--accent); }
.shoutbox form { display: flex; gap: .4rem; }

/* ---- plan de salle ---- */
.salle { display: grid; gap: 4px; overflow-x: auto; padding: .5rem 0; }
.salle .case-salle {
  aspect-ratio: 1; min-width: 46px; border-radius: 6px; border: 1px dashed transparent;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-size: .72rem; line-height: 1.15; text-align: center; padding: 2px; overflow: hidden;
  background: none; color: var(--discret); font-weight: 400;
}
.salle .case-salle.place { background: var(--fond-3); border: 1px solid var(--bord); color: var(--texte); cursor: pointer; }
.salle .case-salle.place.prise { background: color-mix(in srgb, var(--bleu) 22%, var(--fond-3)); border-color: var(--bleu); }
.salle .case-salle.place.moi { background: color-mix(in srgb, var(--accent) 28%, var(--fond-3)); border-color: var(--accent); }
.salle .case-salle .lib { font-weight: 700; }
.salle .case-salle .qui { overflow: hidden; text-overflow: ellipsis; max-width: 100%; white-space: nowrap; }
.salle.edition .case-salle { border-color: var(--bord); cursor: pointer; }
.legende { display: flex; gap: 1rem; flex-wrap: wrap; font-size: .85rem; color: var(--discret); }
.legende span::before { content: ""; display: inline-block; width: .8em; height: .8em; border-radius: 3px; margin-right: .35em; vertical-align: -1px; }
.legende .l-libre::before { background: var(--fond-3); border: 1px solid var(--bord); }
.legende .l-prise::before { background: var(--bleu); }
.legende .l-moi::before { background: var(--accent); }

/* ---- serveurs ---- */
.console {
  background: #05070a; color: #c9d1d9; border: 1px solid var(--bord); border-radius: 6px; padding: .6rem;
  height: 460px; overflow-y: auto; white-space: pre-wrap; overflow-wrap: anywhere; font-size: .82rem; margin: 0 0 .6rem;
}
.commande { display: flex; gap: .4rem; }
.commande select { width: auto; }
.point { display: inline-block; width: .6em; height: .6em; border-radius: 50%; background: var(--discret); margin-right: .35em; }
.point.en_marche { background: var(--vert); box-shadow: 0 0 6px var(--vert); }
.point.installation, .point.arret { background: var(--orange); }

/* ---- toasts ---- */
#toasts { position: fixed; bottom: 1rem; right: 1rem; display: flex; flex-direction: column; gap: .5rem; z-index: 100; max-width: calc(100vw - 2rem); }
.toast {
  background: var(--fond-3); border: 1px solid var(--bord); border-left: 4px solid var(--vert); border-radius: 6px;
  padding: .6rem .9rem; box-shadow: 0 6px 20px rgb(0 0 0 / .4); white-space: pre-line; max-width: 420px;
}
.toast.erreur { border-left-color: var(--rouge); }

/* ---- news ---- */
.news .contenu { white-space: pre-line; overflow-wrap: anywhere; }
.news + .news { margin-top: 0; }

/* ---- vidéoprojecteur ---- */
body.projecteur #nav, body.projecteur #bandeau { display: none; }
body.projecteur main { max-width: none; padding: 1.5rem 2rem; }
.projo { font-size: 1.35rem; min-height: calc(100vh - 3rem); display: flex; flex-direction: column; }
.projo .haut { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 1rem; }
.projo .haut h1 { font-size: 2.4rem; color: var(--accent); }
.projo .horloge { font-size: 2rem; font-variant-numeric: tabular-nums; color: var(--discret); }
.projo .quitter { position: fixed; top: .4rem; right: .6rem; font-size: .8rem; opacity: .3; }
.projo .ligne-match { font-size: 1.4rem; padding: .7rem 1rem; }
.projo .match { font-size: 1.05rem; }
.projo .tour { min-width: 230px; }
