/* Reste frais ! — design system */
:root {
  --bg: #490085;
  --bg-2: #0b1020;
  --panel: rgba(18, 25, 44, 0.72);
  --panel-solid: #111a2e;
  --line: rgba(140, 165, 220, 0.14);
  --line-strong: rgba(140, 165, 220, 0.28);
  --txt: #e8edf7;
  --muted: #8b9bb8;
  --gold: #c8aa6e;
  --gold-2: #f0e6d2;
  --teal: #0ac8b9;
  --blue: #4f9cf9;
  --red: #e2555b;
  --red-2: #640707;
  --red-3: #aa6060;
  --green: #4ad991;
  --radius: 14px;
  --shadow: 0 18px 40px -24px rgba(0, 0, 0, 0.9);
  --font: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background:
    radial-gradient(1200px 600px at 15% -10%, rgba(10, 200, 185, 0.13), transparent 60%),
    radial-gradient(900px 500px at 90% 0%, rgba(200, 170, 110, 0.10), transparent 55%),
    var(--bg);
  color: var(--txt);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button, input, select { font-family: inherit; font-size: 14px; }

/* ---- top bar ---- */
.topbar {
  display: flex; align-items: center; gap: 22px;
  padding: 14px 26px; border-bottom: 1px solid var(--line);
  background: #070a12c7; backdrop-filter: blur(14px);
  position: sticky; top: 0; z-index: 40;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; letter-spacing: .5px; }
/* logo du site : remplacez public/icon.svg (128x128, fond transparent conseille) */
.brand .logo { width: 50px; height: 50px; border-radius: 8px; display: block; }
.brand b { font-size: 17px; color: var(--gold-2); }
.brand small { color: var(--muted); font-weight: 500; letter-spacing: 1px; font-size: 10px; text-transform: uppercase; }
.nav { display: flex; gap: 4px; margin-left: 12px; flex-wrap: wrap; }
.nav a {
  padding: 8px 13px; border-radius: 9px; color: var(--muted); font-weight: 600; font-size: 13.5px;
  transition: .15s;
}
.nav a:hover { color: var(--txt); background: rgba(255,255,255,.04); }
.nav a.active { color: var(--gold-2); background: rgba(200,170,110,.12); box-shadow: inset 0 0 0 1px rgba(200,170,110,.25); }
.spacer { flex: 1; }
.pill {
  display: inline-flex; align-items: center; gap: 7px; padding: 5px 11px; border-radius: 999px;
  font-size: 11.5px; font-weight: 700; letter-spacing: .4px; border: 1px solid var(--line-strong);
  color: var(--muted); background: rgba(255,255,255,.02);
}
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); }
.dot.live { background: var(--green); box-shadow: 0 0 10px var(--green); }
.dot.demo { background: var(--gold); box-shadow: 0 0 10px var(--gold); }
.dot.err { background: var(--red); box-shadow: 0 0 10px var(--red); }

/* ---- dashboard compact : equipe active et piscine cote a cote ---- */
/* encart "Run terminé" : le bouton Nouveau run est dans l'encart, pas en bas */
/* encart "Run terminee" : il doit se detacher de la grille qui suit */
.ended { border-color: rgba(226,85,91,.45); margin-bottom: 18px; }
.ended-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.ended-row a.btn { text-decoration: none; display: inline-flex; align-items: center; }

/* lien discret (mot de passe oublie sur son profil) */
.quiet-link {
  display: inline-block; margin-top: 10px; font-size: 11px; color: var(--muted);
  text-decoration: none; border-bottom: 1px dotted rgba(255,255,255,.25);
}
.quiet-link:hover { color: var(--gold); border-bottom-color: var(--gold); }
.ended-row .grow { flex: 1; min-width: 220px; }
/* le journal defile avec la MEME barre que les encarts de champions */
.card .journal {
  max-height: 420px; overflow-y: auto; overscroll-behavior: contain;
  padding-right: 4px;
  scrollbar-width: thin; scrollbar-color: rgba(200,170,90,.55) transparent;
}
.card .journal::-webkit-scrollbar { width: 8px; }
.card .journal::-webkit-scrollbar-track { background: transparent; }
.card .journal::-webkit-scrollbar-thumb { background: rgba(200,170,90,.5); border-radius: 8px; }

/* ---- tableau de bord : grille a zones nommees ------------------------------
   Ligne 1 : Equipe active (gauche, plus large) | Piscine + Cimetiere (droite)
   Ligne 2 : Journal des parties (gauche)        | Le run en cours (droite)
   Chaque carte est placee par SA ZONE, jamais par son ordre dans le HTML. */
.dash-grid {
  display: grid;
  grid-template-columns: 1.12fr .88fr;
  grid-template-areas:
    "col-gauche col-droite";
  align-items: start;
  gap: 18px;
}
.dash-grid > .dash-slot { min-width: 0; }
/* Le tableau de bord est DEUX COLONNES independantes (deux vrais conteneurs
   .dash-col), et non quatre zones sur deux rangees : ainsi le Journal reste
   colle sous l'Equipe active (18px) meme quand la Piscine + Cimetiere devient
   tres haute, et le trou geant entre les deux n'existe plus. */
.dash-col { display: flex; flex-direction: column; gap: 18px; min-width: 0; }
.col-gauche { grid-area: col-gauche; }
/* la Piscine + Cimetiere fait TOUJOURS la meme hauteur que
   "Equipe active + pioche" + "Journal des parties" : une hauteur FIXE, posee
   par ajusterDefilement() en pixels. Le contenu qui depasse defile a
   l'interieur des zones. */
.col-droite { grid-area: col-droite; min-height: 0; }
.col-droite > .dash-slot { min-height: 0; display: flex; }
.col-droite > .dash-slot > .card { flex: 1 1 auto; }
.dash-col > .dash-slot > .card { margin: 0; }
/* la carte "Le run en cours" est sous la grille, sur toute la largeur */
.dash-slot.pleine-largeur { margin-top: 18px; }
.dash-slot.pleine-largeur > .card { margin: 0; }
@media (max-width: 1020px) {
  .dash-grid { grid-template-columns: 1fr; grid-template-areas: "col-gauche" "col-droite"; grid-auto-rows: auto; }
}

/* barre de titre du run */
.dash-head { display: flex; align-items: flex-start; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.dash-head .grow { flex: 1; min-width: 260px; }
.dash-head h1 { margin: 0 0 6px; font-size: 28px; letter-spacing: -.5px; }
.dash-meta { color: var(--muted); font-size: 13px; }
.dash-meta .ok { color: var(--green); }
.dash-meta .ko { color: var(--red); }
.dash-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.dash-actions select { width: auto; }
.dash-stats { margin-bottom: 18px; }
.dash-stats .stat .s { color: var(--muted); font-size: 11.5px; }
.dash-h3 { margin: 0 0 6px; font-size: 14px; }
.red { color: #e2555b; }
.item .s.gold, .s.gold { color: var(--gold); }
.item img.mini { width: 34px; height: 34px; border-radius: 8px; object-fit: cover; flex: none; }

/* ---- zones qui defilent quand la colonne de droite devient trop haute ------
   Une fois que la carte Piscine + Cimetiere depasse la colonne du Journal,
   l'equipe en jeu ajoute la classe "dash-scroll" a .dash-grid : la pioche,
   la piscine et le cimetiere passent alors en defilement interne (classe
   "scroll-zone"), et la page ne s'allonge plus. */
.scroll-zone { min-height: 0; }
/* la carte de droite : 75 % piscine, 25 % cimetiere, hauteur fixe */
.card-droite {
  display: flex; flex-direction: column; min-height: 0; overflow: hidden;
}
.card-droite > .zone { display: flex; flex-direction: column; min-height: 0; }
.card-droite > .zone-piscine { flex: 1 1 0; }
.card-droite > .zone-cimetiere { flex: 1 1 0; margin-top: 12px; }
/* dans la carte de droite, les zones de champions prennent la place restante
   et defilent des que leur contenu ne tient plus */
.card-droite .scroll-zone {
  flex: 1 1 auto; min-height: 0; overflow-y: auto;
  overscroll-behavior: contain; padding-right: 4px;
  scrollbar-width: thin; scrollbar-color: rgba(200,170,90,.55) transparent;
  grid-auto-rows: min-content;
}
.card-droite .scroll-zone::-webkit-scrollbar { width: 8px; }
.card-droite .scroll-zone::-webkit-scrollbar-track { background: transparent; }
.card-droite .scroll-zone::-webkit-scrollbar-thumb { background: rgba(200,170,90,.5); border-radius: 8px; }
/* les rangées de la grille gardent leur hauteur naturelle : sans ça, la grille
   écrase les vignettes pour tenir dans max-height et rien ne défile jamais.
   min-content = une vignette entière, jamais moins. */
.dash-grid.dash-scroll .scroll-zone { grid-auto-rows: min-content; }
.dash-grid.dash-scroll .scroll-zone {
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-right: 4px;
  scrollbar-width: thin;
  scrollbar-color: rgba(200,170,90,.55) transparent;
}
.dash-grid.dash-scroll .scroll-zone::-webkit-scrollbar { width: 8px; }
.dash-grid.dash-scroll .scroll-zone::-webkit-scrollbar-track { background: transparent; }
.dash-grid.dash-scroll .scroll-zone::-webkit-scrollbar-thumb {
  background: rgba(200,170,90,.5); border-radius: 8px;
}

.pool-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); gap: 7px; }
.pool-grid .token { padding: 7px 5px 7px; border-radius: 10px; }
.pool-grid .token .nm { font-size: 10.5px; margin-top: 4px; }
.pool-grid .token .lvl { font-size: 9.5px; }
.pool-grid .token .restwrap { margin-top: 4px; }
.pool-grid .token .restwrap .restbtn,
.pool-grid .token .restwrap .restok { font-size: 9px; padding: 4px 3px; }

/* ---- layout ---- */
.wrap { max-width: 1180px; margin: 0 auto; padding: 28px 26px 80px; }
.grid { display: grid; gap: 18px; }
.g2 { grid-template-columns: 1, 1; }
/* encart pleine largeur (accueil : "Comment ça marche") */
.g1 { grid-template-columns: 1fr; }
.g3 { grid-template-columns: repeat(3, 1fr); }
.g4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 900px) { .g2, .g3, .g4 { grid-template-columns: 1fr; } .nav { display: none; } }

.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px; box-shadow: var(--shadow); backdrop-filter: blur(6px); }
.card h2, .card h3 { margin: 0 0 4px; font-size: 15px; letter-spacing: .3px; }
.card .sub { color: var(--muted); font-size: 12.5px; margin-bottom: 14px; }
.section-title { font-size: 13px; text-transform: uppercase; letter-spacing: 1.6px; color: var(--gold); margin: 0 0 12px; }

/* ---- hero ---- */
.hero { padding: 34px 0 10px; }
.hero h1 { font-size: 42px; line-height: 1.06; margin: 0 0 12px; letter-spacing: -1px; }
.hero h1 em { font-style: normal; color: var(--gold); }
.hero p { color: var(--muted); font-size: 15.5px; max-width: 620px; line-height: 1.6; margin: 0 0 20px; }

/* ---- stats ---- */
.stat { display: flex; flex-direction: column; gap: 4px; }
.stat .k { color: var(--muted); font-size: 11.5px; text-transform: uppercase; letter-spacing: 1.2px; }
.stat .v { font-size: 26px; font-weight: 800; letter-spacing: -.5px; }
.stat .v.gold { color: var(--gold); }
.stat .v.green { color: var(--green); }
.stat .v.red { color: var(--red); }

/* ---- forms & buttons ---- */
label { display: block; font-size: 12px; color: var(--muted); margin: 0 0 5px; letter-spacing: .4px; }
input, select {
  width: 100%; padding: 10px 12px; border-radius: 10px; color: var(--txt);
  background: rgba(6, 10, 20, .7); border: 1px solid var(--line-strong); outline: none;
  transition: .15s;
}
input:focus, select:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(200,170,110,.12); }
.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row > * { flex: 1; min-width: 150px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 18px; border-radius: 10px; border: 1px solid var(--gold);
  background: linear-gradient(180deg, rgba(200,170,110,.22), rgba(200,170,110,.10));
  color: var(--gold-2); font-weight: 700; cursor: pointer; transition: .15s; letter-spacing: .3px;
}
.btn:hover { background: linear-gradient(180deg, rgba(200,170,110,.35), rgba(200,170,110,.18)); transform: translateY(-1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.btn.risk { border-color: rgba(209,68,63,.7); background: linear-gradient(180deg, rgba(209,68,63,.28), rgba(209,68,63,.14)); color: #ffd9d7; font-weight: 800; }
.btn.risk:hover { border-color: #d1443f; background: linear-gradient(180deg, rgba(209,68,63,.42), rgba(209,68,63,.2)); }
.btn.ghost { border-color: var(--line-strong); background: rgba(255,255,255,.03); color: var(--txt); }
.btn.ghost:hover { border-color: var(--gold); color: var(--gold-2); }
.btn.sm { padding: 5px 11px; font-size: 11.5px; }

/* pied de la carte starter : compteur de champions + relance du tirage */
.starter-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.starter-foot span { font-size: 11.5px; color: var(--muted); }
.btn.teal { border-color: var(--teal); background: linear-gradient(180deg, rgba(10,200,185,.22), rgba(10,200,185,.08)); color: #b8fff8; }
.btn.danger { border-color: var(--red); background: rgba(226,85,91,.14); color: #ffd9db; }
.btn.sm { padding: 7px 12px; font-size: 12.5px; }
.mt { margin-top: 14px; }

/* ---- champion tokens ---- */
.team-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; }
@media (max-width: 700px) { .team-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
/* la grille de l'equipe ne doit jamais etre etiree : tokens vides a la meme taille que les autres */
.team-grid { align-items: stretch; }
.team-grid > .token { min-width: 0; max-width: 100%; align-self: stretch; }
.team-grid > .token .champ { max-width: 100%; }
.token {
  position: relative; border: 1px solid var(--line-strong); border-radius: 12px;
  padding: 10px 8px 10px; text-align: center; background: rgba(9, 14, 26, .8); transition: .15s;
  display: flex; flex-direction: column; gap: 2px;
}
.token:hover { border-color: var(--gold); }
.token .champ img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; border-radius: 9px; }
.token .champ span.lbl { position: relative; z-index: 1; }
.token .champ { position: relative; overflow: hidden; width: 100%; aspect-ratio: 1; border-radius: 9px; display: grid; place-items: center;
  font-weight: 800; font-size: 13px; color: var(--gold-2); background: radial-gradient(circle at 30% 20%, #1d2b4a, #0a1120);
  border: 1px solid var(--line); overflow: hidden; }
.token .nm { font-size: 11.5px; margin-top: 6px; color: var(--txt); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.token .lvl { font-size: 10px; color: var(--muted); }
.token.dead { opacity: .55; border-color: rgba(226,85,91,.45); }
.token.dead .nm { text-decoration: line-through; color: var(--red); }
.token.empty { border-style: dashed; opacity: .5; align-self: stretch; }
/* un emplacement libre ne doit pas etre plus grand que les autres : on cale sa hauteur sur le contenu */
.token.empty .champ { aspect-ratio: 1; height: auto; }
/* champion en repos : visible mais grise, avec le nombre de parties restantes */
.token.waiting { outline: 2px solid var(--gold); outline-offset: 1px; cursor: pointer; }
/* le petit bouton ↩ se decale pour ne pas passer sous le bouton Reposer */
.token .x.withrest { position: absolute; top: 4px; right: 4px; width: 18px; height: 18px; border-radius: 50%;
  border: none; background: rgba(226,85,91,.85); color: #fff; cursor: pointer; font-size: 11px; line-height: 1; display: none; z-index: 5;}
.token.rest { opacity: .62; border-color: rgba(200,170,90,.35); }
.token.rest .champ { filter: grayscale(.85) brightness(.75); }
.token.rest .lvl { color: var(--gold); font-weight: 600; }
.token .x { position: absolute; top: 4px; right: 4px; width: 18px; height: 18px; border-radius: 50%;
  border: none; background: rgba(226,85,91,.85); color: #fff; cursor: pointer; font-size: 11px; line-height: 1; display: none; z-index: 5;}
.token:hover .x { display: block; }
/* ---- cartes de champion (equipe, piscine, cimetiere) ----
   Meme carte partout : le bouton "Reposer" est dans le flux, SOUS le nom et le nombre
   de repos, donc il ne peut plus passer devant le texte quelle que soit la largeur. */
.token .restwrap {
  display: flex; justify-content: center; gap: 4px; margin-top: 6px;
}
.token .restwrap .restbtn, .token .restwrap .restok {
  flex: 0 1 auto; min-width: 0; padding: 5px 10px; border-radius: 8px; border: 1px solid rgba(200,170,90,.7);
  background: rgba(200,170,90,.94); color: #000000; font-size: 10.5px; font-weight: 800;
  letter-spacing: .3px; cursor: pointer; line-height: 1.15; text-align: center;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.token .restwrap .restbtn:hover { background: var(--gold); border-color: var(--gold); }
.token .restwrap .restbtn.off { background: rgba(120,120,130,.55); border-color: rgba(150,150,160,.5); color: #0d0e11; cursor: pointer; opacity: .75; }
.token .restwrap .restbtn.waiting { background: rgba(200,170,90,.5); border-color: rgba(200,170,90,.5); color: #22242a; cursor: default; }
/* la confirmation n'apparait qu'apres le premier clic, a cote du bouton */
.token .restwrap .restok { display: none; background: #3fbf6f; border-color: #3fbf6f; color: #0b120d; font-size: 10px; padding: 5px 5px; }
.token .restwrap .restok.no { background: #d1443f; border-color: #d1443f; color: #fff; }
/* 1er clic sur "Reposer" : le bouton de base s'efface, seul le bouton vert
   de confirmation (avec le prix) reste affiche */
.token .restwrap.confirm .restbtn { display: none; }
.token .restwrap.confirm .restok { display: block; flex: 1 1 auto; }
.token .restwrap .restok:hover { filter: brightness(1.12); }

/* ---- list / table ---- */
.list { display: flex; flex-direction: column; gap: 8px; }
.item {
  display: flex; align-items: center; gap: 12px; padding: 11px 14px; border-radius: 11px;
  border: 1px solid var(--line); background: rgba(10, 16, 30, .6);
}
.item:hover { border-color: var(--line-strong); }
.item .grow { flex: 1; min-width: 0; }
.item .t { font-weight: 650; font-size: 13.5px; }
.item .s { color: var(--muted); font-size: 11.5px; margin-top: 2px; }
.rank { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; font-weight: 800;
  font-size: 13px; background: rgba(255,255,255,.05); color: var(--muted); flex: none; }
.rank.p1 { background: linear-gradient(180deg, #f0d99b, #b8934b); color: #241a06; }
.rank.p2 { background: linear-gradient(180deg, #d9e0ea, #96a1b3); color: #1a1e25; }
.rank.p3 { background: linear-gradient(180deg, #d8a578, #a06f42); color: #2a1808; }
.tag { font-size: 10.5px; padding: 3px 8px; border-radius: 999px; border: 1px solid var(--line-strong); color: var(--muted); }
.tag.win { color: var(--green); border-color: rgba(74,217,145,.35); background: rgba(74,217,145,.08); }
.tag.loss { color: var(--red); border-color: rgba(226,85,91,.35); background: rgba(226,85,91,.08); }
.tag.gold { color: var(--gold); border-color: rgba(200,170,110,.35); background: rgba(200,170,110,.08); }

/* ---- misc ---- */
.empty { text-align: center; color: var(--muted); padding: 30px 10px; font-size: 13.5px; }
.err { color: var(--red); font-size: 13px; margin-top: 10px; }
.ok { color: var(--green); font-size: 13px; margin-top: 10px; }
.bar { height: 7px; border-radius: 999px; background: rgba(255,255,255,.07); overflow: hidden; }
.bar > i { display: block; height: 100%; background: linear-gradient(90deg, var(--teal), var(--gold)); }
.avatar { width: 54px; height: 54px; border-radius: 14px; display: grid; place-items: center; flex: 0 0 auto;
  font-weight: 800; font-size: 20px; color: #0a1020; background: linear-gradient(135deg, var(--gold), var(--teal));
  overflow: hidden; border: 1px solid rgba(200,170,110,.45); }
.avatar.hasicon { background: #0d0f13; }
.avatar.hasicon img { width: 100%; height: 100%; object-fit: cover; display: block; }
.mono { font-family: ui-monospace, 'SF Mono', Menlo, monospace; font-size: 12px; }
.hr { height: 1px; background: var(--line); margin: 16px 0; }
.toast {
  position: fixed; top: 50%; left: 50%; transform: translate(-50%, -46%);
  padding: 14px 26px; border-radius: 13px; background: var(--panel-solid); border: 1px solid var(--gold);
  color: var(--gold-2); font-size: 14.5px; font-weight: 600; max-width: min(560px, 88vw); text-align: center;
  opacity: 0; pointer-events: none; transition: .22s; z-index: 200; box-shadow: 0 18px 60px rgba(0,0,0,.55);
}
.toast.show { opacity: 1; transform: translate(-50%, -50%); }
.hide { display: none !important; }

/* ---- vignette de champion : hauteur identique pour toutes -------------------
   La rangee "⚡ Reposer" n'existe que pour un champion au repos. On lui reserve
   TOUJOURS la place (hauteur mini), sinon les vignettes pretes sont plus courtes.
   Le bouton ↩ est en position absolue : il ne prend plus de place dans le flux. */
/* place reservee a la rangee "Reposer" (bouton 24px + 6px de marge) : les vignettes
   pretes gardent la meme hauteur, sans l'allonger inutilement */
/* Hauteur COMMUNE a toutes les vignettes, calculee sur la place qu'elles ont
   vraiment (l'image carree fait la largeur de la cellule). Ainsi les vignettes
   ne changent plus de taille quand l'equipe se remplit ou se vide.
   La place du bouton "Reposer" est toujours reservee. */
.token { min-height: calc((100% - 4 * 10px) / 5 + 62px); }
.token .x { position: absolute; top: 4px; right: 4px; }
