/* Le Merdeux — thème sombre par défaut (ambiance LoL), clair si le système le demande
   ou si l'utilisateur le choisit avec le bouton (attribut data-theme sur <html>) */
:root {
  color-scheme: dark;
  --bg: #0e1116;
  --panel: #161b22;
  --panel-2: #1c232d;
  --line: #2a3340;
  --text: #e6edf3;
  --muted: #8b98a8;
  --accent: #c8aa6e;          /* or LoL */
  --accent-2: #0ac8b9;        /* hextech */
  --win: #3fb27f;
  --loss: #e5534b;
  --note-great: #2ea043;
  --note-good: #7bc96f;
  --note-mid: #d4a72c;
  --note-low: #e08a3c;
  --note-bad: #e5534b;
  --radius: 10px;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    color-scheme: light;
    --bg: #f5f6f8;
    --panel: #ffffff;
    --panel-2: #f0f2f5;
    --line: #dde1e7;
    --text: #1c2128;
    --muted: #5e6b7a;
    --accent: #9a7b3c;
    --accent-2: #087f75;
  }
}
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f5f6f8;
  --panel: #ffffff;
  --panel-2: #f0f2f5;
  --line: #dde1e7;
  --text: #1c2128;
  --muted: #5e6b7a;
  --accent: #9a7b3c;
  --accent-2: #087f75;
}
.theme-toggle {
  background: var(--panel-2); border: 1px solid var(--line); color: var(--text);
  border-radius: 6px; width: 34px; height: 32px; cursor: pointer; font-size: 16px; line-height: 1;
}
.theme-toggle:hover { border-color: var(--muted); }

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 Inter, system-ui, sans-serif;
}
a { color: inherit; text-decoration: none; }
a:hover { color: var(--accent); }
h1 { font-size: 22px; margin: 24px 0 4px; }
h2 { font-size: 16px; margin: 0 0 12px; color: var(--accent); font-weight: 600; }
.sub { color: var(--muted); margin: 0 0 20px; }
.wrap { max-width: 1200px; margin: 0 auto; padding: 0 16px; }

/* Barre du haut */
.topbar { background: var(--panel); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.topbar-inner { display: flex; align-items: center; gap: 16px; min-height: 56px; flex-wrap: wrap; }
.brand { font-weight: 700; font-size: 17px; color: var(--accent); white-space: nowrap; }
.nav { display: flex; gap: 4px; flex: 1; overflow-x: auto; }
.nav a { padding: 6px 10px; border-radius: 6px; color: var(--muted); white-space: nowrap; }
.nav a.active, .nav a:hover { background: var(--panel-2); color: var(--text); }
.period select, select {
  background: var(--panel-2); color: var(--text); border: 1px solid var(--line);
  border-radius: 6px; padding: 6px 8px; font: inherit;
}

/* Cartes et grilles */
.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); margin-bottom: 16px; }
.grid-5 { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); margin-bottom: 16px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; min-width: 0; }
.card.tight { padding: 12px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.kpi .label { color: var(--muted); font-size: 12px; }
.kpi .value { font-size: 22px; font-weight: 700; }

/* Tableaux */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th, td { padding: 8px 10px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: var(--muted); font-weight: 500; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; }
td.num, th.num { text-align: right; }
tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--panel-2); }
tr.provisional td { opacity: .55; }
td.small { white-space: normal; min-width: 90px; }

/* Éléments */
.note { display: inline-block; min-width: 42px; text-align: center; padding: 2px 8px; border-radius: 6px; font-weight: 700; color: #fff; }
.note-great { background: var(--note-great); }
.note-good { background: var(--note-good); color: #0e1116; }
.note-mid { background: var(--note-mid); color: #0e1116; }
.note-low { background: var(--note-low); color: #0e1116; }
.note-bad { background: var(--note-bad); }
.note-none { background: var(--panel-2); color: var(--muted); }
.wr-high { color: var(--win); font-weight: 600; }
.wr-low { color: var(--loss); font-weight: 600; }
.pos { color: var(--win); } .neg { color: var(--loss); }
.champ { display: inline-flex; align-items: center; gap: 6px; }
.champ img { width: 24px; height: 24px; border-radius: 4px; }
.champ.lg img { width: 40px; height: 40px; border-radius: 6px; }
.tag { display: inline-block; padding: 1px 7px; border-radius: 4px; font-size: 11px; font-weight: 600; background: var(--panel-2); color: var(--muted); }
.tag.win { background: color-mix(in srgb, var(--win) 20%, transparent); color: var(--win); }
.tag.loss { background: color-mix(in srgb, var(--loss) 20%, transparent); color: var(--loss); }
.tag.mvp { background: color-mix(in srgb, var(--accent) 25%, transparent); color: var(--accent); }
.tag.role { min-width: 38px; text-align: center; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.player-link { font-weight: 600; }

/* Partie (historique) */
.game { display: grid; grid-template-columns: 110px 1fr; gap: 12px; padding: 12px; border-left: 4px solid var(--line); }
.game.win { border-left-color: var(--win); }
.game.loss { border-left-color: var(--loss); }
.game-players { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; }
.gp { background: var(--panel-2); border-radius: 8px; padding: 8px; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.gp .name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.lineup { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; }
.lineup .slot { background: var(--panel-2); border-radius: 8px; padding: 10px; text-align: center; }

.chart-box { position: relative; height: 320px; }
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.btn-ghost { background: none; border: 1px solid var(--line); color: var(--muted); border-radius: 6px; padding: 6px 10px; cursor: pointer; font: inherit; }
.btn-ghost:hover { color: var(--text); border-color: var(--muted); }
.footer { display: flex; justify-content: space-between; align-items: center; color: var(--muted); padding: 24px 16px 40px; flex-wrap: wrap; gap: 8px; }
.empty { color: var(--muted); padding: 12px 0; }

@media (max-width: 720px) {
  .topbar-inner { gap: 8px; padding-top: 8px; }
  .brand { flex: 1; }
  .nav { order: 3; flex-basis: 100%; padding-bottom: 8px; }
  .game { grid-template-columns: 1fr; }
  .game-players, .lineup { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid { grid-template-columns: 1fr; }
  h1 { font-size: 19px; }
}

/* --- Recherche, comptes, clans ------------------------------------------- */
input:not([type=hidden]) {
  background: var(--panel-2); color: var(--text); border: 1px solid var(--line);
  border-radius: 6px; padding: 7px 10px; font: inherit; min-width: 0;
}
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.search { display: flex; gap: 6px; }
.search input { width: 170px; }
.search-lg { justify-content: center; margin: 16px 0 8px; }
.search-lg input { width: min(340px, 60vw); font-size: 16px; padding: 10px 12px; }
.btn {
  display: inline-block; background: var(--accent); color: #111; border: none; border-radius: 6px;
  padding: 8px 14px; font: inherit; font-weight: 600; cursor: pointer; text-align: center;
}
.btn:hover { filter: brightness(1.08); color: #111; }
.btn-small { padding: 5px 10px; font-size: 13px; }
.btn-google { background: #fff; color: #1f1f1f; border: 1px solid var(--line); }
.btn-discord { background: #5865f2; color: #fff; }
.btn-discord:hover { color: #fff; }
.account-link { font-weight: 600; white-space: nowrap; }
.badge { background: var(--loss); color: #fff; border-radius: 10px; padding: 0 6px; font-size: 11px; }
.subbar { border-top: 1px solid var(--line); background: var(--panel-2); }
.subbar-inner { display: flex; align-items: center; gap: 12px; min-height: 42px; flex-wrap: wrap; }
.narrow { max-width: 560px; margin: 0 auto; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.flash { border-color: var(--accent); }
.verify-icon { margin: 8px 0 8px 24px; }
.verify-icon img { border-radius: 10px; border: 2px solid var(--accent); }
.hero { text-align: center; padding: 28px 0 12px; }
.hero h1 { font-size: 28px; }
.profile-head { display: flex; gap: 16px; align-items: center; margin: 20px 0 12px; }
.profile-icon { border-radius: 14px; border: 2px solid var(--accent); }
.profile-head h1 { margin: 0; }
.rank-card .value { font-size: 20px; font-weight: 700; }
.chip { padding: 5px 12px; border-radius: 16px; border: 1px solid var(--line); color: var(--muted); font-size: 13px; }
.chip.active, .chip:hover { background: var(--panel-2); color: var(--text); border-color: var(--muted); }
.bar-row { display: grid; grid-template-columns: 50px 1fr 50px; gap: 8px; align-items: center; margin-bottom: 8px; }
.bar { background: var(--panel-2); border-radius: 4px; height: 10px; overflow: hidden; }
.bar div { background: var(--accent); height: 100%; }
.game-line { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding: 6px 8px; border-left: 3px solid var(--line); margin-bottom: 6px; }
.game-line.win { border-left-color: var(--win); }
.game-line.loss { border-left-color: var(--loss); }
.award { background: var(--panel-2); border-radius: 8px; padding: 12px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.award-title { width: 100%; font-weight: 600; }
.award.mvp { border-left: 4px solid var(--accent); }
.award.merdeux { border-left: 4px solid #8b5a2b; }
code { background: var(--panel-2); padding: 1px 5px; border-radius: 4px; }

@media (max-width: 720px) {
  .search { order: 4; flex-basis: 100%; }
  .search input { flex: 1; width: auto; }
  .subbar-inner { gap: 6px; padding: 6px 0; }
}

.member-row { padding: 4px 0; }
.push-right { margin-left: auto; }
.vote-row { padding: 8px 0; border-bottom: 1px solid var(--line); }

/* Suggestions de recherche */
.suggest {
  position: absolute; top: calc(100% + 4px); left: 0; z-index: 30; min-width: 300px; max-width: 92vw;
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 4px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .35);
}
.suggest-item { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: 6px; }
.suggest-item img { border-radius: 6px; background: var(--panel-2); flex: none; }
.suggest-item .suggest-name { flex: 1; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.suggest-item.active, .suggest-item:hover { background: var(--panel-2); color: var(--text); }
.search-lg .suggest { left: 50%; transform: translateX(-50%); width: min(460px, 92vw); text-align: left; }

.legal { flex-basis: 100%; font-size: 11px; color: var(--muted); margin: 8px 0 0; }

.prose p, .prose li { line-height: 1.65; }
.prose h2 { margin-top: 24px; }
.legal a { text-decoration: underline; }
.danger { color: var(--loss); border-color: var(--loss); }
