/* ==========================================================================
   OWTracked — feuille de style principale
   ========================================================================== */

:root {
  color-scheme: dark;

  --bg: #0a0e16;
  --bg-glow: #142036;
  --surface: #111827;
  --surface-2: #182234;
  --surface-3: #212d44;
  --border: #27334b;
  --border-strong: #3a4865;
  --text: #e9edf4;
  --muted: #9ba7bc;

  --accent: #f99e1a;
  --accent-strong: #ffb547;
  --accent-ink: #1d1203;
  --focus: #8cc8ff;

  --good: #3dd68c;
  --bad: #ff6b6b;

  --tank: #5b9bff;
  --damage: #ff6b6b;
  --support: #3dd68c;
  --open: #c58bff;

  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 10px 30px rgb(0 0 0 / 0.35);

  --font-body: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-display: "Rajdhani", "Inter", system-ui, sans-serif;
}

/* ---- Base ---- */

/* L'attribut hidden doit toujours gagner, même sur un élément stylé en flex/grid (.btn…) */
[hidden] {
  display: none !important;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(1200px 500px at 50% -150px, var(--bg-glow), transparent 70%),
    var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.55;
}

main {
  flex: 1;
}

h1,
h2,
h3 {
  font-family: var(--font-display);
  line-height: 1.15;
  margin: 0 0 0.5em;
  letter-spacing: 0.01em;
}

h1 { font-size: clamp(2rem, 5vw, 3.2rem); }
h2 { font-size: 1.6rem; }
h3 { font-size: 1.2rem; }

p { margin: 0 0 1em; }

a {
  color: var(--accent);
}

a:hover {
  color: var(--accent-strong);
}

img {
  max-width: 100%;
  display: block;
}

code {
  font-size: 0.9em;
  background: var(--surface-3);
  padding: 0.1em 0.35em;
  border-radius: 4px;
}

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  border: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.skip-link {
  position: absolute;
  left: 1rem;
  top: -100px;
  z-index: 100;
  padding: 0.6rem 1rem;
  background: var(--accent);
  color: var(--accent-ink);
  border-radius: var(--radius-sm);
  font-weight: 700;
}

.skip-link:focus {
  top: 1rem;
}

.muted { color: var(--muted); }
.accent { color: var(--accent); }
.is-good { color: var(--good); }
.is-bad { color: var(--bad); }

.container {
  width: 100%;
  max-width: 1160px;
  margin-inline: auto;
  padding-inline: 16px;
}

@media (min-width: 640px) {
  .container { padding-inline: 24px; }
}

.container.narrow {
  max-width: 760px;
}

.section {
  margin-block: 3rem;
}

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.section-head h2 {
  margin: 0;
}

.page {
  padding-block: 2rem 3rem;
}

.page-head {
  margin-bottom: 1.5rem;
}

.page-head h1 {
  font-size: clamp(1.8rem, 4vw, 2.6rem);
  overflow-wrap: anywhere;
}

/* ---- Rôles : chaque composant lit --role ---- */

.role-tank { --role: var(--tank); }
.role-damage { --role: var(--damage); }
.role-support { --role: var(--support); }
.role-open { --role: var(--open); }
.role-none { --role: var(--muted); }

.role-dot {
  display: inline-block;
  width: 0.7rem;
  height: 0.7rem;
  border-radius: 50%;
  background: var(--role, var(--muted));
  flex-shrink: 0;
}

/* ---- Header ---- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgb(10 14 22 / 0.85);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  display: flex;
  align-items: center;
  gap: 1rem;
  min-height: 64px;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  color: var(--text);
  text-decoration: none;
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.brand:hover { color: var(--text); }
.brand strong { color: var(--accent); }

.main-nav {
  margin-left: auto;
}

.main-nav ul {
  display: flex;
  gap: 0.25rem;
  list-style: none;
  margin: 0;
  padding: 0;
}

.main-nav a,
.nav-soon {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  min-height: 44px;
  padding: 0 0.8rem;
  border-radius: var(--radius-sm);
  color: var(--muted);
  text-decoration: none;
  font-weight: 600;
}

.main-nav a:hover {
  color: var(--text);
  background: var(--surface-2);
}

.main-nav a[aria-current="page"] {
  color: var(--text);
  box-shadow: inset 0 -2px 0 var(--accent);
  border-radius: 0;
}

.nav-soon {
  cursor: not-allowed;
  opacity: 0.6;
}

.nav-soon small {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

@media (max-width: 560px) {
  .nav-soon { display: none; }
}

.header-search {
  display: flex;
  gap: 0.4rem;
  flex: 1 1 260px;
  max-width: 420px;
  order: 3;
}

@media (min-width: 760px) {
  .header-search { order: 0; margin-left: 1rem; }
}

@media (max-width: 759px) {
  .header-search { max-width: none; flex-basis: 100%; padding-bottom: 0.75rem; }
}

/* ---- Formulaires ---- */

input[type="search"],
input[type="text"] {
  width: 100%;
  min-height: 48px;
  padding: 0.7rem 0.9rem;
  font: inherit;
  font-size: 1rem;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
}

input::placeholder {
  color: #6f7c93;
}

input:focus-visible {
  border-color: var(--focus);
}

.field label {
  display: block;
  margin-bottom: 0.35rem;
  font-weight: 600;
}

.hint {
  margin: 0.5rem 0 0;
  font-size: 0.9rem;
  color: var(--muted);
}

.search-row {
  display: flex;
  gap: 0.5rem;
}

@media (max-width: 480px) {
  .search-row { flex-direction: column; }
}

/* Contrôle segmenté construit sur de vrais boutons radio */
.segmented {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 4px;
  margin: 0;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
}

.segmented input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  pointer-events: none;
}

.segmented label {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  min-height: 40px;
  padding: 0 1rem;
  border-radius: 999px;
  color: var(--muted);
  font-weight: 600;
  cursor: pointer;
  user-select: none;
  transition: background-color 0.15s, color 0.15s;
}

.segmented label:hover {
  color: var(--text);
}

.segmented input:checked + label {
  background: var(--accent);
  color: var(--accent-ink);
}

.segmented input:focus-visible + label {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

/* ---- Boutons ---- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 48px;
  padding: 0 1.25rem;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font: inherit;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 0.15s, border-color 0.15s, transform 0.1s;
}

.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.6; cursor: progress; }

.btn-primary {
  background: var(--accent);
  color: var(--accent-ink);
}

.btn-primary:hover {
  background: var(--accent-strong);
  color: var(--accent-ink);
}

.btn-ghost {
  background: transparent;
  color: var(--text);
  border-color: var(--border-strong);
}

.btn-ghost:hover {
  background: var(--surface-2);
  color: var(--text);
}

.btn-sm {
  min-height: 40px;
  padding: 0 0.9rem;
  font-size: 0.9rem;
}

.btn-icon {
  padding: 0;
  width: 48px;
  flex-shrink: 0;
}

/* ---- Accueil ---- */

.hero-search {
  padding-block: clamp(3rem, 9vw, 6rem) 2rem;
  text-align: center;
}

.eyebrow {
  margin-bottom: 0.75rem;
  color: var(--accent);
  font-weight: 700;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

.lead {
  max-width: 560px;
  margin-inline: auto;
  color: var(--muted);
  font-size: 1.1rem;
}

.search-card {
  margin-top: 2rem;
  padding: 1.25rem;
  display: grid;
  gap: 1rem;
  justify-items: center;
  text-align: left;
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) + 4px);
  box-shadow: var(--shadow);
}

.search-card .field {
  width: 100%;
}

.search-card input[type="search"] {
  min-height: 54px;
  font-size: 1.1rem;
}

.search-card .btn {
  min-height: 54px;
}

.demo-line {
  margin-top: 1.25rem;
  color: var(--muted);
}

.recent-list,
.feature-grid,
.result-list,
.hero-grid,
.rank-grid,
.top-heroes,
.legend,
.profile-meta {
  list-style: none;
  margin: 0;
  padding: 0;
}

.recent-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 0.75rem;
}

.recent-card,
.result-card {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  padding: 0.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  text-decoration: none;
  transition: border-color 0.15s, background-color 0.15s;
}

.recent-card:hover,
.result-card:hover {
  border-color: var(--accent);
  background: var(--surface-2);
  color: var(--text);
}

.recent-card img,
.recent-card .avatar-fallback {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
}

.recent-text,
.result-text {
  display: grid;
  min-width: 0;
  flex: 1;
}

.recent-text strong,
.result-text strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.recent-text small,
.result-text small,
.recent-time {
  color: var(--muted);
}

.recent-time {
  align-self: flex-start;
  font-size: 0.75rem;
  white-space: nowrap;
}

.avatar-fallback,
.hero-fallback {
  display: inline-grid;
  place-items: center;
  flex-shrink: 0;
  font-family: var(--font-display);
  font-weight: 700;
  color: var(--text);
  background: var(--surface-3);
}

.avatar-fallback {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--accent), #b0570a);
  color: var(--accent-ink);
}

.hero-fallback {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 2px solid var(--role, var(--border-strong));
  background: color-mix(in srgb, var(--role, var(--surface-3)) 20%, var(--surface-2));
  font-size: 0.95rem;
}

.hero-fallback-lg {
  width: 96px;
  height: 96px;
  font-size: 2rem;
}

.feature-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 1rem;
}

.feature-card {
  padding: 1.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.feature-card p {
  margin: 0;
  color: var(--muted);
}

.feature-card.is-soon {
  border-style: dashed;
}

.feature-icon {
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  margin-bottom: 0.75rem;
  font-size: 1.4rem;
  background: var(--surface-3);
  border-radius: var(--radius-sm);
}

.badge {
  display: inline-block;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  font-family: var(--font-body);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  vertical-align: middle;
  background: color-mix(in srgb, var(--accent) 18%, transparent);
  color: var(--accent);
}

.badge-ok {
  background: color-mix(in srgb, var(--good) 15%, transparent);
  color: var(--good);
}

.badge-muted {
  background: var(--surface-3);
  color: var(--muted);
}

.faq {
  display: grid;
  gap: 0.6rem;
}

.faq details {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.faq summary {
  padding: 1rem 1.25rem;
  font-weight: 600;
  cursor: pointer;
}

.faq details[open] summary {
  border-bottom: 1px solid var(--border);
}

.faq details p {
  margin: 0;
  padding: 1rem 1.25rem;
  color: var(--muted);
}

/* ---- Footer ---- */

.site-footer {
  margin-top: 3rem;
  padding-block: 2rem;
  border-top: 1px solid var(--border);
  font-size: 0.9rem;
}

.site-footer p { margin: 0.25rem 0; }

/* ---- Barre d'outils / notices ---- */

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  margin-block: 1.5rem;
}

.field-inline {
  flex: 1 1 220px;
  max-width: 340px;
}

.notice {
  padding: 0.8rem 1rem;
  border: 1px solid color-mix(in srgb, var(--accent) 50%, transparent);
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  border-radius: var(--radius-sm);
}

.result-count {
  margin-bottom: 0.75rem;
  font-size: 0.9rem;
}

/* ---- Résultats de recherche ---- */

.result-list {
  display: grid;
  gap: 0.6rem;
}

.result-card .avatar {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-sm);
}

.result-card.is-loading {
  min-height: 82px;
}

/* ---- Squelettes de chargement ---- */

.skeleton-block {
  display: grid;
  gap: 0.6rem;
  width: 100%;
}

.skeleton {
  display: block;
  height: 0.9rem;
  border-radius: 6px;
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 50%, var(--surface-2) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s ease-in-out infinite;
}

@keyframes shimmer {
  from { background-position: 200% 0; }
  to { background-position: -200% 0; }
}

@media (prefers-reduced-motion: reduce) {
  .skeleton { animation: none; }
  * { transition: none !important; }
}

/* ---- Liste des héros ---- */

.hero-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.75rem;
}

.hero-card {
  display: grid;
  justify-items: center;
  gap: 0.4rem;
  padding: 1rem 0.75rem;
  text-align: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-bottom: 3px solid var(--role, var(--border));
  border-radius: var(--radius);
  color: var(--text);
  text-decoration: none;
  transition: transform 0.15s, background-color 0.15s;
}

a.hero-card:hover {
  transform: translateY(-2px);
  background: var(--surface-2);
  color: var(--text);
}

.hero-card img {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--surface-3);
}

.hero-card.is-loading {
  min-height: 170px;
  align-content: end;
}

.hero-role {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.hero-grid .empty {
  grid-column: 1 / -1;
}

/* ---- Profil : bannière ---- */

.profile-banner {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  padding: clamp(1.25rem, 4vw, 2rem);
  min-height: 180px;
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) + 4px);
  background:
    linear-gradient(90deg, rgb(10 14 22 / 0.92) 25%, rgb(10 14 22 / 0.55)),
    var(--namecard, linear-gradient(120deg, #1d2a44, #3a2a14)) center / cover no-repeat;
  overflow: hidden;
}

.profile-id {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  min-width: 0;
  flex: 1 1 280px;
}

.profile-avatar {
  width: 96px;
  height: 96px;
  border-radius: var(--radius);
  border: 2px solid var(--accent);
  flex-shrink: 0;
  font-size: 2.2rem;
}

.profile-banner.is-loading .profile-avatar {
  border-color: var(--border);
}

.profile-name {
  margin: 0;
  font-size: clamp(1.8rem, 5vw, 2.6rem);
  overflow-wrap: anywhere;
}

.profile-name .tag {
  margin-left: 0.3rem;
  font-size: 0.55em;
  color: var(--muted);
}

.profile-title {
  margin: 0.15rem 0 0.4rem;
  color: var(--accent);
  font-weight: 600;
}

.profile-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1.25rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.profile-meta li {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.endorse {
  display: inline-grid;
  place-items: center;
  width: 1.6rem;
  height: 1.6rem;
  border-radius: 50%;
  background: conic-gradient(var(--good) 0 33%, var(--tank) 0 66%, var(--accent) 0);
  color: var(--bg);
  font-weight: 800;
  font-size: 0.8rem;
}

.profile-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.profile-actions .btn {
  background: rgb(10 14 22 / 0.6);
}

/* ---- Rangs ---- */

.rank-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 150px), 1fr));
  gap: 0.75rem;
}

.rank-card {
  display: grid;
  justify-items: center;
  gap: 0.5rem;
  padding: 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: 3px solid var(--role, var(--border));
  border-radius: var(--radius);
  text-align: center;
}

.rank-card.is-loading {
  min-height: 150px;
  align-content: center;
}

.rank-role {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-weight: 600;
  color: var(--muted);
}

.rank-icon {
  width: 64px;
  height: 64px;
}

.rank-placeholder {
  display: block;
  border-radius: 50%;
  border: 3px solid var(--div-color, var(--border-strong));
  background: radial-gradient(circle at 35% 30%, color-mix(in srgb, var(--div-color, var(--surface-3)) 55%, white 10%), var(--surface-2) 70%);
}

.div-bronze { --div-color: #b0703c; }
.div-silver { --div-color: #b9c2cf; }
.div-gold { --div-color: #f1c24b; }
.div-platinum { --div-color: #6fd3d6; }
.div-diamond { --div-color: #7aa9ff; }
.div-master { --div-color: #3fd0a0; }
.div-grandmaster { --div-color: #c48bff; }
.div-champion,
.div-ultimate { --div-color: #ff7a59; }

.rank-label {
  font-family: var(--font-display);
  font-size: 1.25rem;
}

.rank-card.is-unranked .rank-label {
  color: var(--muted);
  font-weight: 600;
}

/* ---- Onglets ---- */

.tabs {
  display: flex;
  gap: 0.25rem;
  margin-bottom: 1.5rem;
  /* Trait de séparation dessiné à l'intérieur : rien ne dépasse, donc pas de barre de défilement verticale */
  box-shadow: inset 0 -1px 0 var(--border);
  /* Défilement horizontal au doigt sur petit écran, sans barre visible */
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
}

@supports not (scrollbar-width: none) {
  .tabs::-webkit-scrollbar {
    display: none;
  }
}

.tabs [role="tab"] {
  min-height: 48px;
  padding: 0 1.25rem;
  border: 0;
  background: none;
  color: var(--muted);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  border-bottom: 3px solid transparent;
  flex-shrink: 0;
  white-space: nowrap;
}

.tabs [role="tab"]:hover {
  color: var(--text);
}

.tabs [role="tab"][aria-selected="true"] {
  color: var(--text);
  border-bottom-color: var(--accent);
}

.tabpanel:focus-visible {
  outline-offset: 6px;
  border-radius: var(--radius-sm);
}

/* ---- Tuiles de stats ---- */

.tile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 0.75rem;
}

.tile-grid-5 {
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}

.tile {
  display: grid;
  gap: 0.2rem;
  align-content: start;
  padding: 1rem 1.1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.tile.is-loading {
  min-height: 96px;
  align-content: center;
}

.tile-label {
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 600;
}

.tile-value {
  font-family: var(--font-display);
  font-size: 2rem;
  line-height: 1.1;
}

.tile-sub {
  color: var(--muted);
  font-size: 0.8rem;
}

.winrate-meter {
  width: 100%;
  height: 8px;
  margin-top: 0.35rem;
}

.block-title {
  margin: 2rem 0 0.75rem;
  font-size: 1.15rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.card .block-title {
  margin-top: 0;
}

.two-cols {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr));
  gap: 1rem;
  margin-top: 2rem;
}

.card {
  padding: 1.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

/* Top héros */
.top-heroes {
  display: grid;
  gap: 0.85rem;
  margin-bottom: 1rem;
}

.top-heroes li {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.hero-portrait {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--surface-3);
}

.top-hero-body {
  flex: 1;
  min-width: 0;
}

.top-hero-line {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  font-size: 0.92rem;
  margin-bottom: 0.3rem;
}

.top-hero-wr {
  width: 4.5rem;
  text-align: right;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.bar {
  height: 6px;
  background: var(--surface-3);
  border-radius: 999px;
  overflow: hidden;
}

.bar-fill {
  display: block;
  height: 100%;
  background: var(--role, var(--accent));
  border-radius: inherit;
}

/* Répartition par rôle */
.stacked-bar {
  display: flex;
  height: 14px;
  border-radius: 999px;
  overflow: hidden;
  background: var(--surface-3);
  gap: 2px;
  margin-bottom: 1rem;
}

.stacked-bar span {
  background: var(--role);
}

.legend {
  display: grid;
  gap: 0.6rem;
}

.legend li {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  align-items: center;
  gap: 0.6rem;
}

.legend .muted {
  font-size: 0.85rem;
  min-width: 6rem;
  text-align: right;
}

/* ---- Tableau par héros ---- */

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.stats-table {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.stats-table th,
.stats-table td {
  padding: 0.65rem 0.9rem;
  text-align: right;
  border-bottom: 1px solid var(--border);
}

.stats-table thead th {
  position: sticky;
  top: 0;
  background: var(--surface-2);
  padding: 0;
}

.stats-table th:first-child {
  text-align: left;
}

.stats-table tbody tr:last-child > * {
  border-bottom: 0;
}

.stats-table tbody tr:hover {
  background: var(--surface-2);
}

.stats-table tbody th {
  font-weight: 600;
  position: sticky;
  left: 0;
  background: var(--surface);
}

.stats-table tbody tr:hover th {
  background: var(--surface-2);
}

.sort-btn {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.35rem;
  width: 100%;
  min-height: 44px;
  padding: 0 0.9rem;
  border: 0;
  background: none;
  color: var(--muted);
  font: inherit;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
}

th:first-child .sort-btn {
  justify-content: flex-start;
}

th[aria-sort] .sort-btn,
.sort-btn:hover {
  color: var(--text);
}

.sort-arrow {
  font-size: 0.7rem;
  opacity: 0.7;
}

.hero-cell {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
}

.hero-cell .hero-portrait,
.hero-cell .hero-fallback {
  width: 32px;
  height: 32px;
  font-size: 0.8rem;
}

/* ---- Rôles ---- */

.role-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr));
  gap: 1rem;
}

.role-card {
  border-top: 3px solid var(--role);
}

.role-card h3 {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.role-card.is-empty {
  opacity: 0.6;
}

.role-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem 1rem;
  margin: 0;
}

.role-stats dt {
  color: var(--muted);
  font-size: 0.8rem;
}

.role-stats dd {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 700;
}

/* ---- Messages ---- */

.message-box {
  max-width: 620px;
  margin: 2rem auto;
  padding: 2rem;
  text-align: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.message-box.is-error {
  border-color: color-mix(in srgb, var(--bad) 55%, transparent);
}

.message-actions {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-top: 1.25rem;
}

/* Bouton de retour vers capridia.com (site parent) */
.back-capridia {
  gap: 0.3rem;
  padding-inline: 0.7rem 0.9rem;
}

@media (max-width: 420px) {
  .main-nav a { padding-inline: 0.6rem; }
}

/* ---- Historique ---- */

.small {
  font-size: 0.85rem;
}

.history-help {
  margin-bottom: 0.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.history-help summary {
  padding: 0.8rem 1.1rem;
  font-weight: 600;
  cursor: pointer;
}

.history-help p {
  margin: 0;
  padding: 0 1.1rem 0.8rem;
  color: var(--muted);
}

.history-empty p:last-child {
  margin-bottom: 0;
}

.session-list {
  display: grid;
  gap: 0.6rem;
  margin: 0 0 1rem;
  padding: 0;
  list-style: none;
}

.session-card {
  --outcome: var(--border-strong);
  display: grid;
  grid-template-columns: 7.5rem 1fr auto;
  align-items: center;
  gap: 1rem;
  padding: 0.85rem 1.1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--outcome);
  border-radius: var(--radius);
}

.session-card.is-win { --outcome: var(--good); }
.session-card.is-loss { --outcome: var(--bad); }

.session-result {
  display: grid;
}

.session-result strong {
  font-family: var(--font-display);
  font-size: 1.25rem;
  color: var(--outcome);
}

.session-card.is-even .session-result strong {
  color: var(--text);
}

.session-result small {
  color: var(--muted);
}

.session-body {
  display: grid;
  gap: 0.35rem;
  min-width: 0;
}

.session-heroes {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1rem;
  margin: 0;
  padding: 0;
  list-style: none;
  font-weight: 600;
}

.session-heroes li {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.session-heroes .hero-portrait,
.session-heroes .hero-fallback {
  width: 28px;
  height: 28px;
  font-size: 0.7rem;
}

.session-meta {
  margin: 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.rank-changes {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 0.85rem;
  font-weight: 600;
}

.rank-changes li {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.15rem 0.6rem;
  border-radius: 999px;
  background: var(--surface-3);
}

.session-wr {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

@media (max-width: 560px) {
  .session-card {
    grid-template-columns: 1fr auto;
  }

  .session-body {
    grid-column: 1 / -1;
    grid-row: 2;
  }
}

.seasons-table td,
.seasons-table th {
  text-align: left;
}

.seasons-table thead th {
  padding: 0.65rem 0.9rem;
  color: var(--muted);
  font-size: 0.85rem;
}

.seasons-table .badge {
  margin-left: 0.5rem;
}

.season-rank {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
}

.rank-dot {
  width: 0.8rem;
  height: 0.8rem;
  border-radius: 50%;
  background: var(--div-color, var(--muted));
}

.history-clear {
  margin-top: 1.5rem;
}

/* ---- Suggestions de joueurs (recherche en direct) ---- */

.suggest-wrap {
  position: relative;
  flex: 1;
  min-width: 0;
}

.suggest-panel {
  position: absolute;
  z-index: 20;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  min-width: min(100%, 300px);
  max-height: min(60vh, 420px);
  overflow-y: auto;
  padding: 0.35rem;
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  text-align: left;
}

.suggest-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.suggest-option {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  min-height: 48px;
  padding: 0.4rem 0.6rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.suggest-option[aria-selected="true"],
.suggest-option:hover {
  background: var(--surface-3);
}

.suggest-option img,
.suggest-option .avatar-fallback {
  width: 36px;
  height: 36px;
  border-radius: 6px;
  font-size: 0.9rem;
}

.suggest-option .result-text small {
  font-size: 0.8rem;
}

.suggest-status {
  margin: 0;
  padding: 0.5rem 0.6rem;
  color: var(--muted);
  font-size: 0.85rem;
}

.suggest-status:empty {
  display: none;
}

@media (max-width: 480px) {
  .tabs [role="tab"] {
    padding-inline: 0.75rem;
  }
}

.table-wrap + .small {
  margin-top: 0.6rem;
}

/* ---- Listes déroulantes ---- */

select {
  width: 100%;
  min-height: 48px;
  padding: 0.6rem 2.4rem 0.6rem 0.9rem;
  font: inherit;
  font-size: 1rem;
  color: var(--text);
  background-color: var(--surface);
  /* Flèche personnalisée : appearance:none garde l'élément natif (clavier, lecteurs d'écran) */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='none' stroke='%239ba7bc' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round' d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  background-size: 1.1rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  appearance: none;
  cursor: pointer;
}

select:focus-visible {
  border-color: var(--focus);
}

select:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

select option,
select optgroup {
  background: var(--surface);
  color: var(--text);
}

/* ---- Classement méta : filtres ---- */

.meta-filters {
  display: grid;
  gap: 1rem;
  margin-block: 1.5rem;
  padding: 1.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.meta-filters > .filter-group {
  display: inline-grid;
}

@media (min-width: 900px) {
  .meta-filters {
    grid-template-columns: auto auto 1fr;
    align-items: end;
  }

  .filter-selects {
    grid-column: 1 / -1;
  }
}

.filter-group {
  gap: 0.35rem;
  margin: 0;
  padding: 0;
  border: 0;
  min-width: 0;
}

.filter-group legend,
.filter-selects label {
  margin-bottom: 0.35rem;
  padding: 0;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--muted);
}

.filter-group .segmented {
  justify-self: start;
}

.filter-selects {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 190px), 1fr));
  gap: 0.75rem 1rem;
}

/* ---- Classement méta : tier list (style TierMaker) ---- */

.tierlist {
  display: grid;
  gap: 2px;
  padding: 2px;
  background: #0f0f0d;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.tier-row {
  --tier: #7f7f7f;
  display: grid;
  grid-template-columns: 5.5rem 1fr;
  min-height: 104px;
  background: #1b1c18;
}

.tier-S { --tier: #ff7f7f; }
.tier-A { --tier: #ffbf7f; }
.tier-B { --tier: #ffdf7f; }
.tier-C { --tier: #ffff7f; }
.tier-D { --tier: #bfff7f; }

.tier-label {
  display: grid;
  place-items: center;
  background: var(--tier);
  color: #1a1a1a;
  font-family: var(--font-display);
  font-size: 2.2rem;
  font-weight: 700;
}

.tier-heroes {
  display: flex;
  flex-wrap: wrap;
  align-content: flex-start;
  gap: 4px;
  margin: 0;
  padding: 4px;
  list-style: none;
}

.tier-hero {
  position: relative;
  display: grid;
  justify-items: center;
  align-content: start;
  gap: 2px;
  width: 84px;
  padding: 6px 4px 5px;
  background: var(--surface-2);
  border-radius: 6px;
  border-bottom: 3px solid var(--role, var(--border));
  text-align: center;
}

.tier-hero img,
.tier-hero .tier-fallback {
  width: 64px;
  height: 64px;
  border-radius: 6px;
  object-fit: cover;
  background: var(--surface-3);
}

.tier-hero .tier-fallback {
  border-radius: 6px;
  font-size: 1.3rem;
}

.tier-hero.skeleton {
  height: 96px;
  border-bottom: 0;
}

.tier-hero-name {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.78rem;
  font-weight: 700;
}

.tier-hero-stat {
  font-size: 0.72rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.tier-empty {
  align-self: center;
  padding-left: 0.75rem;
}

@media (max-width: 560px) {
  .tier-row {
    grid-template-columns: 3rem 1fr;
  }

  .tier-label {
    font-size: 1.6rem;
  }

  .tier-hero {
    width: 68px;
  }

  .tier-hero img,
  .tier-hero .tier-fallback {
    width: 52px;
    height: 52px;
  }
}

.meta-help {
  margin-top: 1rem;
}

/* ---- Classement méta : tableau ---- */

.meta-table td {
  min-width: 9rem;
}

.meta-table .hero-cell > span {
  display: grid;
  text-align: left;
}

.hero-role-line {
  font-size: 0.75rem;
  font-weight: 500;
}

.tier-chip {
  display: inline-grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  border-radius: 6px;
  background: var(--tier);
  color: #1a1a1a;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.1rem;
}

.rate {
  display: grid;
  gap: 0.3rem;
  justify-items: end;
}

.rate-bar {
  display: block;
  width: 100%;
  max-width: 11rem;
  height: 6px;
  background: var(--surface-3);
  border-radius: 999px;
  overflow: hidden;
}

.rate-bar > span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--muted);
}

.rate-bar.is-pick > span { background: var(--accent); }
.rate-bar.is-win > span { background: var(--tank); }
.rate-bar.is-ban > span { background: var(--bad); }

/* Nouvelle division compétitive */
.div-emerald { --div-color: #2fcf7a; }
.div-master { --div-color: #e3a95b; }

/* En-tête mobile : logo + bouton Capridia sur une ligne, menu en dessous.
   Non collant : sur trois lignes, il masquerait près d'un quart de l'écran. */
@media (max-width: 640px) {
  .site-header {
    position: static;
  }

  .back-capridia {
    order: 1;
    margin-left: auto;
  }

  .main-nav {
    order: 2;
    flex-basis: 100%;
    margin-left: 0;
  }

  .main-nav ul {
    justify-content: space-between;
  }

  .header-search {
    order: 3;
  }
}

/* ---- Mode admin ---- */

.admin-dialog {
  width: min(100% - 32px, 380px);
  padding: 1.5rem;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

/* Empêche le défilement de la page derrière la boîte ouverte */
.admin-dialog:modal {
  overscroll-behavior: contain;
}

.admin-dialog::backdrop {
  background: rgb(5 8 14 / 0.7);
  overflow: hidden;
  overscroll-behavior: contain;
}

.admin-dialog h2 {
  margin-bottom: 1rem;
}

.admin-dialog label {
  display: block;
  margin-bottom: 0.35rem;
  font-weight: 600;
}

.admin-dialog input {
  width: 100%;
  min-height: 48px;
  padding: 0.7rem 0.9rem;
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
}

.admin-error {
  min-height: 1.4em;
  margin: 0.5rem 0 0;
  color: var(--bad);
  font-size: 0.9rem;
}

.admin-dialog .message-actions {
  justify-content: flex-start;
  margin-top: 0.75rem;
}

.admin-bar {
  position: fixed;
  z-index: 30;
  right: 16px;
  bottom: 16px;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.4rem 0.5rem 0.4rem 1rem;
  background: var(--surface-2);
  border: 1px solid var(--accent);
  border-radius: 999px;
  box-shadow: var(--shadow);
  font-weight: 700;
  font-size: 0.9rem;
}
