/* ---------- Thème ---------- */

:root {
  color-scheme: light;
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-solid: #ffffff;
  --surface-2: #f0f2f5;
  --border: #e3e6eb;
  --border-strong: #cfd4dc;
  --text: #111827;
  --muted: #667085;
  --accent: #2557d6;
  --accent-soft: rgb(37 87 214 / 0.1);
  --grad: linear-gradient(180deg, #2f64e0 0%, #2150c4 100%);
  --up: #15803d;
  --up-bg: rgb(22 163 74 / 0.1);
  --down: #c62828;
  --down-bg: rgb(220 38 38 / 0.08);
  --gold: #d99a00;
  --silver: #98a2b3;
  --bronze: #c2763a;
  --tier-bronze: #b4692f;
  --tier-argent: #7c8798;
  --tier-or: #c58f00;
  --tier-platine: #0f9d8e;
  --tier-diamant: #2563eb;
  --tier-master: #7c3aed;
  --shadow: 0 1px 2px rgb(16 24 40 / 0.05);
  --shadow-lg: 0 16px 48px rgb(16 24 40 / 0.18);
  --radius: 12px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);

  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  color: var(--text);
  background: var(--bg);
}

/* Le thème est posé sur <html data-theme> par le script en tête de index.html. */
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0e1116;
  --surface: #151a21;
  --surface-solid: #151a21;
  --surface-2: #1d232c;
  --border: #272e39;
  --border-strong: #38414f;
  --text: #e8ecf2;
  --muted: #8b95a7;
  --accent: #5b8def;
  --accent-soft: rgb(91 141 239 / 0.14);
  --grad: linear-gradient(180deg, #4f83ec 0%, #3f70d8 100%);
  --up: #4ade80;
  --up-bg: rgb(74 222 128 / 0.12);
  --down: #f87171;
  --down-bg: rgb(248 113 113 / 0.12);
  --gold: #f0b429;
  --tier-bronze: #cf8a4d;
  --tier-argent: #9aa6b8;
  --tier-or: #e5ac1b;
  --tier-platine: #2dd4bf;
  --tier-diamant: #60a5fa;
  --tier-master: #a78bfa;
  --shadow: none;
  --shadow-lg: 0 20px 60px rgb(0 0 0 / 0.6);
}

:root.theme-transition,
:root.theme-transition *,
:root.theme-transition *::before,
:root.theme-transition *::after {
  transition:
    background-color 0.3s ease,
    border-color 0.3s ease,
    color 0.3s ease !important;
}

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

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  margin: 0 auto;
  max-width: 720px;
  min-height: 100dvh;
  padding: 0 max(1rem, env(safe-area-inset-left)) calc(6.5rem + var(--safe-bottom))
    max(1rem, env(safe-area-inset-right));
  -webkit-tap-highlight-color: transparent;
}

body:has(dialog[open]) {
  overflow: hidden;
}

h1,
h2,
p {
  margin: 0;
}

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
  border: 0;
  background: none;
  touch-action: manipulation;
}

:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent) 60%, transparent);
  outline-offset: 2px;
}

[hidden] {
  display: none !important;
}

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

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 40px;
  padding: 0.55rem 1rem;
  border-radius: 10px;
  font-weight: 600;
  transition:
    transform 0.15s ease,
    box-shadow 0.2s ease,
    opacity 0.2s ease;
}

.btn:active {
  transform: scale(0.97);
}

.btn-gitlab {
  background: #292961;
  color: #fff;
}

.btn-gitlab svg {
  color: #fc6d26;
}

.btn-lg {
  min-height: 44px;
  padding-inline: 1.2rem;
}

.btn-primary {
  background: var(--grad);
  color: #fff;
  box-shadow: 0 1px 2px rgb(16 24 40 / 0.2);
}

.btn-primary:disabled {
  opacity: 0.4;
  box-shadow: none;
  cursor: not-allowed;
}

.btn-primary.loading {
  opacity: 0.8;
  cursor: wait;
  background-size: 200% 100%;
  animation: shimmer 1.2s linear infinite;
}

.btn-block {
  width: 100%;
  min-height: 48px;
  font-size: 1rem;
}

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--border);
  transition:
    color 0.15s,
    transform 0.15s;
}

.icon-btn:hover {
  color: var(--text);
}

.icon-btn:active {
  transform: scale(0.94);
}

.icon-btn.spinning svg {
  animation: spin 0.8s linear infinite;
}

.pill {
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 600;
}

/* ---------- En-tête ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin: 0 -1rem;
  padding: calc(0.7rem + env(safe-area-inset-top)) 1rem 0.7rem;
  backdrop-filter: saturate(1.4) blur(12px);
  -webkit-backdrop-filter: saturate(1.4) blur(12px);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  border-bottom: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  color: inherit;
  text-decoration: none;
  border-radius: 12px;
}

.brand img {
  border-radius: 10px;
}

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

.brand h1 {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.1;
}

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

#auth,
.header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

#theme-toggle svg {
  transition: transform 0.4s cubic-bezier(0.2, 0.9, 0.3, 1.3);
}

#theme-toggle:active svg {
  transform: rotate(-30deg) scale(0.9);
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.25rem 0.75rem 0.25rem 0.25rem;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: inherit;
  font-weight: 600;
  text-decoration: none;
}

/* ---------- Bandeaux ---------- */

main,
.view {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

main {
  padding-top: 0.75rem;
}

#banner {
  padding: 0.8rem 1rem;
  border-radius: 10px;
  background: var(--down-bg);
  color: var(--down);
  font-weight: 600;
}

.cta {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.1rem 1.2rem;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  overflow: hidden;
  animation: rise 0.4s ease both;
}

.cta::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  background: var(--grad);
}

.cta p {
  color: var(--muted);
  font-size: 0.92rem;
  margin-top: 0.15rem;
}

.cta-mascot {
  flex-shrink: 0;
  animation: bob 3s ease-in-out infinite;
}

.cta-text {
  flex: 1;
}

.empty-mascot {
  display: block;
  margin: 0 auto 0.8rem;
  animation: bob 3s ease-in-out infinite;
}

/* ---------- Classement ---------- */

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.9rem;
}

.section-title h2 {
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.count {
  margin-left: 0.4rem;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0;
}

.avatar {
  flex-shrink: 0;
  display: inline-grid;
  place-items: center;
  border-radius: 50%;
  object-fit: cover;
  background: var(--surface-2);
}

.avatar.initials {
  color: #fff;
  font-weight: 800;
  background: linear-gradient(135deg, hsl(var(--h) 75% 58%), hsl(calc(var(--h) + 40) 70% 48%));
}

.empty-avatar {
  color: var(--muted);
  font-weight: 800;
  font-size: 1.2rem;
  border: 2px dashed var(--border);
  background: transparent;
}

.chip {
  display: inline-flex;
  align-items: center;
  padding: 0.12rem 0.5rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  background: var(--surface-2);
  color: var(--muted);
  white-space: nowrap;
}

.chip.up {
  background: var(--up-bg);
  color: var(--up);
}

.chip.down {
  background: var(--down-bg);
  color: var(--down);
}

/* Podium : cartes « métal » avec reflet */

.podium {
  display: grid;
  grid-template-columns: 1fr 1.14fr 1fr;
  align-items: end;
  gap: 0.7rem;
  margin: 1.8rem 0 1.1rem;
}

.podium-spot {
  --m1: #fff;
  --m2: #ddd;
  --m3: #aaa;
  --ink: #1c1608;
  --text: var(--ink);
  --muted: rgb(28 22 8 / 0.62);
  --up: #166534;
  --down: #b91c1c;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  min-width: 0;
  padding: 1.5rem 0.5rem 1rem;
  border-radius: 16px;
  border: 1px solid rgb(255 255 255 / 0.55);
  background: linear-gradient(160deg, var(--m1) 0%, var(--m2) 48%, var(--m3) 100%);
  box-shadow:
    inset 0 1px 0 rgb(255 255 255 / 0.8),
    inset 0 -12px 24px rgb(0 0 0 / 0.08),
    0 12px 28px var(--glow, rgb(0 0 0 / 0.2));
  color: var(--ink);
  text-align: center;
  text-decoration: none;
  transform: perspective(800px) rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg));
  transition: transform 0.12s ease-out;
  animation: rise 0.45s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.podium-spot.place-1 {
  --m1: #fff4bd;
  --m2: #f5c842;
  --m3: #cf8f00;
  --glow: rgb(245 184 0 / 0.45);
  order: 2;
  padding-top: 2.1rem;
  padding-bottom: 1.3rem;
}

.podium-spot.place-2 {
  --m1: #fbfcfe;
  --m2: #cdd5df;
  --m3: #8e9aac;
  --glow: rgb(120 135 160 / 0.4);
  order: 1;
  animation-delay: 0.08s;
}

.podium-spot.place-3 {
  --m1: #ffe6cf;
  --m2: #e3a26d;
  --m3: #a05c2a;
  --glow: rgb(190 110 50 / 0.4);
  order: 3;
  animation-delay: 0.16s;
}

/* Calque de brillance : balayage lumineux, reflet qui suit la souris, grand numéro en filigrane. */
.shine {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  overflow: hidden;
  pointer-events: none;
}

.shine::before {
  content: attr(data-place);
  position: absolute;
  right: 0.35rem;
  bottom: -0.55rem;
  color: rgb(255 255 255 / 0.3);
  font-size: 5.2rem;
  font-weight: 900;
  line-height: 1;
}

.shine::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at var(--mx, 50%) var(--my, 0%), rgb(255 255 255 / 0.6), transparent 55%);
  opacity: 0;
  transition: opacity 0.2s;
}

.podium-spot:hover .shine::after {
  opacity: 1;
}

.sweep {
  position: absolute;
  inset: -20% 0;
  background: linear-gradient(105deg, transparent 35%, rgb(255 255 255 / 0.7) 50%, transparent 65%);
  transform: translateX(-130%);
  animation: sweep 5s ease-in-out 0.8s infinite;
}

.place-2 .sweep {
  animation-delay: 1.6s;
}

.place-3 .sweep {
  animation-delay: 2.4s;
}

.spark {
  position: absolute;
  left: var(--x);
  top: var(--y);
  width: 12px;
  height: 12px;
  background: #fff;
  clip-path: polygon(50% 0, 62% 38%, 100% 50%, 62% 62%, 50% 100%, 38% 62%, 0 50%, 38% 38%);
  animation: twinkle 2.4s ease-in-out var(--d, 0s) infinite;
}

.podium-spot > :not(.shine) {
  position: relative;
}

.podium-crown {
  position: absolute !important;
  top: -1.55rem;
  display: grid;
  color: #f5b800;
  filter: drop-shadow(0 3px 4px rgb(120 80 0 / 0.45));
  animation: bob 3s ease-in-out infinite;
}

.podium-crown svg {
  fill: #ffd84d;
}

.podium-spot .avatar {
  margin-bottom: 0.35rem;
  box-shadow:
    0 0 0 3px rgb(255 255 255 / 0.9),
    0 0 0 5px rgb(0 0 0 / 0.12),
    0 8px 18px rgb(0 0 0 / 0.25);
}

.medal {
  position: absolute !important;
  top: -0.8rem;
  display: grid;
  place-items: center;
  width: 1.7rem;
  height: 1.7rem;
  border-radius: 50%;
  background: linear-gradient(135deg, #fff 0%, var(--m2) 70%);
  border: 2px solid #fff;
  color: var(--ink);
  font-size: 0.85rem;
  font-weight: 900;
  box-shadow: 0 4px 10px rgb(0 0 0 / 0.25);
}

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

.podium-elo {
  font-size: 1.7rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
  text-shadow: 0 1px 0 rgb(255 255 255 / 0.5);
}

.place-1 .podium-elo {
  font-size: 2.1rem;
}

.podium-spot .tier {
  background: rgb(255 255 255 / 0.55);
  color: var(--ink);
}

.podium-spot .chip {
  background: rgb(255 255 255 / 0.6);
}

.podium-spot .holding.holding {
  color: var(--ink);
}

.podium-record {
  margin-bottom: 0.2rem;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
}

.podium-record b {
  color: var(--ink);
  font-weight: 800;
}

.podium-record span {
  margin-left: 0.2rem;
}

/* Liste */

.list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.row {
  display: grid;
  grid-template-columns: 1.6rem auto 1fr auto;
  align-items: center;
  gap: 0.75rem;
  min-height: 64px;
  padding: 0.7rem 0.9rem;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  color: inherit;
  text-decoration: none;
  animation: rise 0.35s ease both;
}

/* Historiques longs : les lignes hors écran ne sont mises en page qu'au besoin. */
.history > li {
  content-visibility: auto;
  contain-intrinsic-size: auto 64px;
}

.row.unplayed {
  opacity: 0.7;
  box-shadow: none;
}

.rank {
  color: var(--muted);
  font-weight: 800;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.who {
  min-width: 0;
}

.name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 700;
}

.sub {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
  font-size: 0.8rem;
  margin-top: 0.1rem;
}

.tag {
  display: inline-block;
  margin-left: 0.25rem;
  padding: 0.05rem 0.45rem;
  border-radius: 999px;
  background: var(--grad);
  color: #fff;
  font-size: 0.68rem;
  font-weight: 800;
  vertical-align: 0.1em;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.score {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.2rem;
}

.score .elo {
  font-size: 1.2rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
}

.row.me,
.podium-spot.me {
  border-color: color-mix(in srgb, var(--accent) 55%, transparent);
  box-shadow:
    0 0 0 1px color-mix(in srgb, var(--accent) 30%, transparent),
    var(--shadow);
}

.flash {
  animation: flash 1.6s ease both;
}

.list-label {
  margin: 0.9rem 0 0.1rem 0.25rem;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.skeleton {
  min-height: 64px;
  background: linear-gradient(90deg, var(--surface) 0%, var(--surface-2) 50%, var(--surface) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.3s linear infinite;
  box-shadow: none;
}

.empty {
  padding: 2rem 1rem;
  text-align: center;
  color: var(--muted);
  line-height: 1.6;
}

/* ---------- Fiche joueur ---------- */

.back-link {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  min-height: 40px;
  padding: 0 0.8rem 0 0.4rem;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--muted);
  font-weight: 700;
}

.profile-hero {
  --tier: var(--muted);
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: 1.4rem 1.4rem 1.2rem;
  border-radius: var(--radius);
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--tier) 20%, transparent), transparent 75%),
    var(--surface);
  border: 1px solid color-mix(in srgb, var(--tier) 40%, var(--border));
  box-shadow: var(--shadow);
  overflow: hidden;
  animation: rise 0.3s ease both;
}

.profile-hero::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 3px;
  background: var(--tier);
}

.profile-hero.me {
  border-color: color-mix(in srgb, var(--accent) 45%, var(--border));
}

.hero-top {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 1.1rem;
}

.hero-avatar .avatar {
  box-shadow:
    0 0 0 3px var(--surface-solid),
    0 0 0 5px color-mix(in srgb, var(--tier) 70%, transparent);
}

.hero-id {
  min-width: 0;
}

.hero-id h2 {
  overflow-wrap: anywhere;
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1.2;
}

.hero-id .sub {
  font-size: 0.9rem;
}

.hero-tags {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem 0.7rem;
  margin-top: 0.55rem;
}

.hero-tags:empty {
  display: none;
}

.hero-elo {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.1rem;
}

.hero-elo .elo {
  font-size: 2.6rem;
  font-weight: 700;
  letter-spacing: -0.04em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.elo-label {
  margin-bottom: 0.25rem;
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.12em;
}

.profile-hero.skeleton,
.panel.skeleton {
  min-height: 150px;
  border: 0;
}

.panel.skeleton {
  min-height: 240px;
}

/* Performance */

.perf-main {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 1.4rem;
}

.ring-chart {
  position: relative;
  width: 148px;
  height: 148px;
}

.ring-chart svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.ring-chart circle {
  fill: none;
  stroke-width: 3.6;
}

.ring-track {
  stroke: var(--surface-2);
}

.ring-loss {
  stroke: var(--down);
  opacity: 0.55;
}

.ring-win {
  stroke: var(--up);
  stroke-linecap: round;
  animation: ring-in 0.9s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.ring-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.ring-center strong {
  font-size: 2.3rem;
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.ring-center small {
  font-size: 1rem;
  font-weight: 700;
  color: var(--muted);
}

.ring-center span {
  margin-top: 0.2rem;
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.kpis {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
}

.kpi {
  --k: var(--accent);
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  padding: 0.75rem 0.9rem 0.7rem;
  border-radius: 12px;
  background: linear-gradient(135deg, color-mix(in srgb, var(--k) 12%, transparent), transparent 75%), var(--surface-2);
  overflow: hidden;
}

.kpi.blue { --k: var(--accent); }
.kpi.green { --k: var(--up); }
.kpi.red { --k: var(--down); }
.kpi.gold { --k: var(--gold); }

.kpi-icon {
  position: absolute;
  top: 0.65rem;
  right: 0.7rem;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: color-mix(in srgb, var(--k) 16%, transparent);
  color: var(--k);
}

.kpi-value {
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.035em;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.kpi-label {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.form {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  margin-top: 1.1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.form-label {
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.form-dots {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}

.dot {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 8px;
  font-size: 0.72rem;
  font-weight: 800;
}

.dot.win {
  background: var(--up);
  color: #fff;
}

.dot.loss {
  background: var(--down-bg);
  color: var(--down);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--down) 40%, transparent);
}

.pill-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.9rem;
}

.pill-stat {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.3rem 0.7rem;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 600;
}

.pill-stat b {
  color: var(--text);
}

.pill-stat.win {
  background: var(--up-bg);
  color: var(--up);
}

.pill-stat.loss {
  background: var(--down-bg);
  color: var(--down);
}

.pill-stat.win b,
.pill-stat.loss b {
  color: inherit;
}

/* Panneaux (badges, courbe, historique) */

.panel {
  padding: 1.1rem 1.2rem 1.2rem;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

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

.panel-head h3 {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.panel-meta {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.chart {
  margin: 0;
}

.chart-plot {
  position: relative;
  height: 180px;
}

.chart-plot svg {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.chart-line {
  fill: none;
  stroke: var(--accent);
  stroke-width: 2.5;
  stroke-linejoin: round;
  stroke-linecap: round;
  vector-effect: non-scaling-stroke;
}

.chart-base {
  stroke: var(--muted);
  stroke-width: 1;
  stroke-dasharray: 4 4;
  opacity: 0.5;
  vector-effect: non-scaling-stroke;
}

.chart-label {
  position: absolute;
  left: 0;
  z-index: 1;
  padding: 0 0.3rem;
  border-radius: 6px;
  background: color-mix(in srgb, var(--surface-solid) 80%, transparent);
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.chart-label.top {
  top: 0;
}

.chart-label.bottom {
  bottom: 0;
}

.chart-dot {
  position: absolute;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--surface-solid);
  box-shadow: 0 0 0 4px var(--accent-soft);
  transform: translate(-50%, -50%);
}

.chart-axis {
  display: flex;
  justify-content: space-between;
  margin-top: 0.4rem;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 600;
}

.history {
  display: flex;
  flex-direction: column;
  gap: 0;
  margin: 0;
  padding: 0;
  list-style: none;
}

.match {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 0.7rem;
  padding: 0.55rem 0;
  border-top: 1px solid var(--border);
}

.history > li:first-child .match {
  border-top: 0;
}

.result {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 7px;
  font-size: 0.78rem;
  font-weight: 800;
}

.match.win .result {
  background: var(--up-bg);
  color: var(--up);
}

.match.loss .result {
  background: var(--down-bg);
  color: var(--down);
}

.match-opponent {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-width: 0;
  color: inherit;
  text-decoration: none;
}

.match-opponent .who {
  display: flex;
  flex-direction: column;
}

.match-score {
  font-size: 1.1rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.match-elo {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.15rem;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

/* ---------- Pied de page ---------- */

.site-footer {
  display: flex;
  justify-content: center;
  margin-top: 2rem;
}

.site-footer a {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.8rem;
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 600;
  text-decoration: none;
}

/* ---------- Bouton flottant ---------- */

.fab {
  position: fixed;
  z-index: 20;
  right: max(1.25rem, env(safe-area-inset-right));
  bottom: calc(1.25rem + var(--safe-bottom));
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  min-height: 52px;
  padding: 0 1.3rem 0 1rem;
  border-radius: 12px;
  background: var(--grad);
  color: #fff;
  font-weight: 700;
  font-size: 1rem;
  box-shadow: 0 8px 24px rgb(16 24 40 / 0.28);
  transition: transform 0.15s ease;
  animation: pop 0.4s cubic-bezier(0.2, 1.4, 0.4, 1) both;
}

.fab:active {
  transform: scale(0.95);
}

.fab-icon {
  display: inline-grid;
}

/* ---------- Feuille « Nouveau match » ---------- */

dialog {
  width: min(520px, calc(100vw - 2rem));
  max-height: min(92dvh, 760px);
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface-solid);
  color: var(--text);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

dialog[open] {
  animation: zoom-in 0.25s cubic-bezier(0.2, 0.9, 0.3, 1);
}

dialog::backdrop {
  background: rgb(8 10 20 / 0.5);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.sheet {
  display: flex;
  flex-direction: column;
  max-height: inherit;
}

.sheet-header {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.1rem 1.1rem 0.6rem 1.3rem;
}

.sheet-header h2 {
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.grabber {
  display: none;
}

.sheet-body {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  padding: 0.4rem 1.3rem 1rem;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.sheet-footer {
  padding: 0.8rem 1.3rem calc(1rem + var(--safe-bottom));
  border-top: 1px solid var(--border);
  background: var(--surface-solid);
}

fieldset {
  margin: 0;
  padding: 0;
  border: 0;
  min-width: 0;
}

/* Contrôle segmenté (format) */

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  padding: 4px;
  border-radius: 10px;
  background: var(--surface-2);
}

.segmented input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.segmented span {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  min-height: 42px;
  border-radius: 11px;
  color: var(--muted);
  font-weight: 700;
  font-size: 0.92rem;
  cursor: pointer;
  transition:
    background 0.2s,
    color 0.2s,
    box-shadow 0.2s;
}

.segmented em {
  font-style: normal;
  font-size: 0.72rem;
  padding: 0.05rem 0.35rem;
  border-radius: 6px;
  background: var(--down-bg);
  color: var(--accent);
}

.segmented input:checked + span {
  background: var(--surface-solid);
  color: var(--text);
  box-shadow: 0 2px 8px rgb(15 23 42 / 0.12);
}

.segmented input:focus-visible + span {
  outline: 3px solid color-mix(in srgb, var(--accent) 60%, transparent);
  outline-offset: 2px;
}

/* Tableau des scores (joueurs à gauche, une colonne par set) */

.board {
  container: board / inline-size;
  --cell: 40px;
  padding: 0.3rem 0.6rem 0.2rem;
  border-radius: var(--radius);
  background: var(--surface-2);
}

.board-head,
.board-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.5rem;
}

.board-head {
  padding: 0.35rem 0 0.3rem 0.3rem;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.board-row {
  padding: 0.45rem 0;
  border-top: 1px solid var(--border);
}

.set-cells {
  display: flex;
  gap: 4px;
  user-select: none;
  -webkit-user-select: none;
}

.set-cells > * {
  flex: none;
  display: grid;
  place-items: center;
  width: var(--cell);
  font-variant-numeric: tabular-nums;
}

.board-row .set-cells > * {
  height: var(--cell);
}

.set-cell {
  border-radius: 11px;
  background: var(--surface-solid);
  border: 1px solid var(--border);
  font-size: 1.05rem;
  font-weight: 800;
  transition:
    transform 0.15s,
    background 0.2s,
    color 0.2s;
}

.set-cell:not(:disabled):active {
  transform: scale(0.92);
}

.set-cell:disabled {
  opacity: 0.35;
  cursor: default;
}

.set-cell.lost {
  color: var(--muted);
  font-weight: 600;
}

.set-cell.won {
  background: var(--grad);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 6px 16px rgb(37 87 214 / 0.25);
}

.set-cell.pop {
  animation: pop 0.25s ease;
}

.set-input {
  padding: 0;
  border: 2px solid var(--accent);
  border-radius: 11px;
  background: var(--surface-solid);
  color: var(--text);
  font: inherit;
  font-size: 16px;
  font-weight: 800;
  text-align: center;
}

.set-input:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent) 35%, transparent);
  outline-offset: 0;
}

.set-total {
  margin-left: 4px;
}

.board-row .set-total {
  font-size: 1.35rem;
  font-weight: 900;
  color: var(--muted);
}

.board-row.winner .set-total {
  color: var(--gold);
}

.board-hint {
  margin-top: -0.35rem;
  color: var(--muted);
  font-size: 0.78rem;
  text-align: center;
}

/* Cellule joueur */

.player-cell {
  container: player / inline-size;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-width: 0;
  min-height: 48px;
  padding: 0.2rem 0.3rem;
  border-radius: 12px;
  color: var(--muted);
  text-align: left;
  transition: background 0.2s;
}

.player-cell > svg {
  flex-shrink: 0;
  margin-left: auto;
}

.board-row.winner .player-cell {
  background: linear-gradient(90deg, color-mix(in srgb, var(--gold) 22%, transparent), transparent);
}

.pc-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.pc-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text);
  font-size: 1rem;
}

.pc-short {
  display: none;
}

.pc-sub {
  font-size: 0.8rem;
  font-variant-numeric: tabular-nums;
}

/* Colonne joueur étroite (mobile, 3 sets gagnants) : on passe aux initiales. */
@container player (max-width: 140px) {
  .pc-full:not(:only-child),
  .pc-sub,
  .player-cell > svg {
    display: none;
  }

  .pc-short {
    display: inline;
  }

  .player-cell .avatar {
    width: 30px !important;
    height: 30px !important;
    font-size: 12px !important;
  }
}

@container player (max-width: 64px) {
  .player-cell .avatar:not(.empty-avatar) {
    display: none;
  }

  .pc-full {
    display: none;
  }
}

@container board (max-width: 340px) {
  .set-cells {
    --cell: 34px;
    gap: 3px;
  }
}

@container board (max-width: 290px) {
  .set-cells {
    --cell: 30px;
  }

  .player-cell {
    padding-inline: 0.1rem;
  }
}

.board-head > span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Recherche de joueur */

.combo {
  position: relative;
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.board-row.searching > .player-cell,
.board-row.searching > .set-cells {
  display: none;
}

.combo-icon {
  position: absolute;
  top: 14px;
  left: 0.8rem;
  display: inline-grid;
  color: var(--muted);
  pointer-events: none;
}

.combo-input {
  width: 100%;
  min-height: 46px;
  padding: 0 0.9rem 0 2.5rem;
  border: 2px solid var(--accent);
  border-radius: 12px;
  background: var(--surface-solid);
  color: var(--text);
  font: inherit;
  font-size: 16px;
}

.combo-input:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent) 35%, transparent);
  outline-offset: 0;
}

.combo-list {
  position: relative;
  max-height: min(16rem, 40dvh);
  margin: 0;
  padding: 0.25rem;
  overflow-y: auto;
  overscroll-behavior: contain;
  list-style: none;
  border-radius: 12px;
  background: var(--surface-solid);
  border: 1px solid var(--border);
}

.combo-group {
  padding: 0.5rem 0.6rem 0.25rem;
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.combo-option {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.6rem;
  padding: 0.45rem 0.6rem;
  border-radius: 10px;
  cursor: pointer;
}

.combo-option[aria-selected="true"] {
  background: var(--surface-2);
}

.opt-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.opt-name,
.opt-sub {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.opt-name {
  font-weight: 700;
}

.opt-sub {
  color: var(--muted);
  font-size: 0.78rem;
}

.opt-elo {
  color: var(--muted);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.combo-empty {
  padding: 0.9rem;
  color: var(--muted);
  text-align: center;
}

/* Aperçu */

.preview {
  min-height: 4.5rem;
  padding: 0.9rem 1rem;
  border-radius: var(--radius);
  border: 1px dashed var(--border);
}

.preview-title {
  margin-bottom: 0.5rem;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.preview-line {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  align-items: center;
  gap: 0.6rem;
  padding: 0.35rem 0;
  animation: rise 0.25s ease both;
}

.preview-line + .preview-line {
  animation-delay: 0.05s;
}

.preview-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
}

.preview-elo {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.preview-elo strong {
  color: var(--text);
  font-size: 1.1rem;
}

.stakes {
  display: grid;
  gap: 0.4rem;
}

.stakes div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  font-weight: 600;
}

.hint {
  color: var(--muted);
  text-align: center;
  font-size: 0.92rem;
  padding-top: 0.6rem;
}

.warning {
  margin-bottom: 0.6rem;
  color: var(--down);
  font-weight: 600;
  font-size: 0.9rem;
}

/* ---------- Toast ---------- */

#toast {
  position: fixed;
  z-index: 50;
  left: 50%;
  bottom: calc(5.5rem + var(--safe-bottom));
  max-width: calc(100vw - 2rem);
  padding: 0.85rem 1.2rem;
  border-radius: 10px;
  background: #111827;
  color: #fff;
  font-size: 0.92rem;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  transform: translateX(-50%);
  animation: toast-in 0.3s cubic-bezier(0.2, 0.9, 0.3, 1.2) both;
}

#toast.error {
  background: #b91c1c;
}

/* ---------- Animations ---------- */

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}

@keyframes pop {
  from {
    opacity: 0;
    transform: scale(0.8);
  }
}

@keyframes zoom-in {
  from {
    opacity: 0;
    transform: scale(0.96);
  }
}

@keyframes slide-up {
  from {
    transform: translateY(100%);
  }
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translate(-50%, 12px);
  }
}

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

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes bob {
  50% {
    transform: translateY(-5px) rotate(-3deg);
  }
}

@keyframes flash {
  0%,
  40% {
    border-color: var(--accent);
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 30%, transparent);
  }
}

/* ---------- Mobile ---------- */

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

  .tagline {
    display: none;
  }

  .cta {
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 0.75rem;
  }

  .cta-action,
  .cta .btn {
    width: 100%;
  }

  .podium {
    gap: 0.45rem;
  }

  .podium-spot {
    padding-inline: 0.3rem;
  }

  .podium-elo {
    font-size: 1.25rem;
  }

  .place-1 .podium-elo {
    font-size: 1.5rem;
  }

  .row {
    gap: 0.6rem;
    padding: 0.65rem 0.75rem;
  }

  .profile-hero {
    padding: 1.1rem 1rem 1rem;
  }

  .hero-top {
    grid-template-columns: auto minmax(0, 1fr);
    gap: 0.8rem;
  }

  .hero-avatar .avatar {
    width: 60px !important;
    height: 60px !important;
  }

  .hero-id h2 {
    font-size: 1.25rem;
  }

  .hero-elo {
    grid-column: 1 / -1;
    flex-direction: row;
    align-items: baseline;
    gap: 0.5rem;
  }

  .hero-elo .elo {
    font-size: 2.2rem;
  }

  .elo-label {
    margin: 0;
  }

  .panel {
    padding: 1rem;
  }

  .match {
    gap: 0.55rem;
  }

  /* La feuille de saisie s'ouvre depuis le bas, comme une app native. */
  dialog {
    width: 100%;
    max-width: none;
    max-height: 94dvh;
    margin: auto 0 0;
    border-radius: 16px 16px 0 0;
    border-bottom: 0;
  }

  dialog[open] {
    animation: slide-up 0.32s cubic-bezier(0.2, 0.9, 0.3, 1);
  }

  .grabber {
    display: block;
    position: absolute;
    top: 0.45rem;
    left: 50%;
    width: 40px;
    height: 5px;
    border-radius: 999px;
    background: var(--border);
    transform: translateX(-50%);
  }

  .sheet-header {
    padding-top: 1.4rem;
  }

  .sheet-body {
    padding-inline: 1rem;
  }

  .sheet-footer {
    padding-inline: 1rem;
  }
}

@media (hover: hover) {
  .row {
    transition:
      transform 0.15s ease,
      box-shadow 0.15s ease;
  }

  .row:hover {
    transform: translateY(-1px);
  }

  .btn-gitlab:hover,
  .btn-primary:not(:disabled):hover {
    box-shadow: 0 12px 28px rgb(37 87 214 / 0.3);
  }

  .set-cell:not(:disabled):hover {
    border-color: var(--accent);
  }

  .player-cell:hover {
    background-color: var(--surface-solid);
  }

  .combo-option:hover {
    background-color: color-mix(in srgb, var(--surface-2) 55%, transparent);
  }

  .match-opponent {
    transition: transform 0.15s ease;
  }

  .podium-spot:hover {
    transform: perspective(800px) translateY(-3px) rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg));
  }

  .match-opponent:hover .name {
    text-decoration: underline;
  }

  .back-link:hover {
    color: var(--text);
  }

  .brand img {
    transition: transform 0.2s ease;
  }

  .brand:hover img {
    transform: rotate(-8deg) scale(1.05);
  }

  .user-chip {
    transition: border-color 0.15s ease;
  }

  .user-chip:hover {
    border-color: var(--accent);
  }

  .site-footer a:hover {
    color: var(--text);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Ligues */

.tier {
  --tier: var(--muted);
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.1rem 0.5rem 0.1rem 0.4rem;
  border-radius: 999px;
  background: color-mix(in srgb, var(--tier) 16%, transparent);
  color: color-mix(in srgb, var(--tier) 80%, var(--text));
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  white-space: nowrap;
}

.tier-bronze { --tier: var(--tier-bronze); }
.tier-argent { --tier: var(--tier-argent); }
.tier-or { --tier: var(--tier-or); }
.tier-platine { --tier: var(--tier-platine); }
.tier-diamant { --tier: var(--tier-diamant); }
.tier.tier-master {
  --tier: var(--tier-master);
  background: linear-gradient(135deg, color-mix(in srgb, #7c3aed 20%, transparent), color-mix(in srgb, #2563eb 20%, transparent));
}

.row-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.3rem 0.5rem;
  margin-top: 0.3rem;
}

.holding {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--muted);
  white-space: nowrap;
}

.holding.crown { color: var(--gold); }
.holding.last { color: var(--down); }
.holding.badge-count { color: var(--muted); }

.holding {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

.podium-holding {
  margin-top: 0.2rem;
  white-space: normal;
}

.tier-bar {
  flex: 1;
  height: 6px;
  min-width: 60px;
  border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
}

.tier-bar i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--grad);
}

/* ---------- Badges (succès) ---------- */

.meter {
  height: 6px;
  margin-bottom: 0.9rem;
  border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
}

.meter i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width 0.4s ease;
}

.panel-meta b {
  color: var(--text);
  font-size: 1.05rem;
}

.filters {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  border-radius: 10px;
  background: var(--surface-2);
}

.filter {
  padding: 0.35rem 0.8rem;
  border-radius: 8px;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 600;
}

.filter.active {
  background: var(--surface-solid);
  color: var(--text);
  box-shadow: 0 1px 3px rgb(16 24 40 / 0.14);
}

.badge-group {
  margin: 1.2rem 0 0.7rem;
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.bgrid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(88px, 1fr));
  gap: 1rem 0.4rem;
}

.bmedal {
  --b: var(--accent);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
  padding: 0.35rem 0.2rem;
  border-radius: 14px;
  text-align: center;
  transition: background 0.15s;
}

/* Pastille « autocollant » : carré arrondi, couleur franche, icône blanche */
.bmedal-tile,
.detail-medal {
  position: relative;
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  border-radius: 22px;
  transition: transform 0.2s cubic-bezier(0.2, 0.9, 0.3, 1.4);
}

.bmedal.earned .bmedal-tile,
.detail-medal.earned {
  background: linear-gradient(145deg, color-mix(in srgb, var(--b) 78%, #fff), var(--b));
  color: #fff;
  box-shadow:
    inset 0 1px 0 rgb(255 255 255 / 0.4),
    0 6px 14px color-mix(in srgb, var(--b) 32%, transparent);
}

/* À débloquer : même forme, teinte pâle, icône estompée */
.bmedal.locked .bmedal-tile,
.detail-medal.locked {
  background: color-mix(in srgb, var(--b) 9%, var(--surface-2));
  color: color-mix(in srgb, var(--b) 50%, var(--muted));
  box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--b) 18%, transparent);
}

.bmedal.locked .bmedal-tile svg,
.detail-medal.locked svg {
  opacity: 0.6;
}

.bmedal-lock,
.detail-lock {
  position: absolute;
  right: -5px;
  bottom: -5px;
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--surface-solid);
  color: var(--muted);
  box-shadow: 0 1px 4px rgb(0 0 0 / 0.25);
}

.bmedal-name {
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1.2;
}

.bmedal.locked .bmedal-name {
  color: var(--muted);
  font-weight: 600;
}

.bmedal-bar {
  width: 48px;
  height: 4px;
  border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
}

.bmedal-bar i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--b);
}

/* Fenêtre de détail d'un badge */

.badge-dialog {
  width: min(360px, calc(100vw - 2rem));
}

.badge-detail {
  --b: var(--accent);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  padding: 0 1.5rem 1.8rem;
  text-align: center;
}

.badge-dialog .sheet-header {
  justify-content: flex-end;
}

.detail-medal {
  width: 96px;
  height: 96px;
  margin-bottom: 0.8rem;
  border-radius: 32px;
  animation: pop 0.45s cubic-bezier(0.2, 1.4, 0.4, 1) both;
}

.detail-lock {
  right: -6px;
  bottom: -6px;
  width: 32px;
  height: 32px;
}

.badge-detail h2 {
  font-size: 1.3rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.detail-desc {
  color: var(--muted);
  line-height: 1.45;
}

.detail-status {
  margin-top: 0.3rem;
  padding: 0.3rem 0.8rem;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.detail-status.ok {
  background: color-mix(in srgb, var(--b) 15%, transparent);
  color: color-mix(in srgb, var(--b) 80%, var(--text));
}

.badge-detail .meter {
  width: 100%;
  margin: 0.3rem 0 0;
}

.detail-group {
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.tone-blue { --b: #2563eb; }
.tone-green { --b: #16a34a; }
.tone-orange { --b: #ea580c; }
.tone-red { --b: #dc2626; }
.tone-yellow { --b: #d19a00; }
.tone-violet { --b: #7c3aed; }
.tone-slate { --b: #64748b; }

:root[data-theme="dark"] .tone-blue { --b: #3b82f6; }
:root[data-theme="dark"] .tone-green { --b: #22c55e; }
:root[data-theme="dark"] .tone-orange { --b: #f97316; }
:root[data-theme="dark"] .tone-red { --b: #ef4444; }
:root[data-theme="dark"] .tone-yellow { --b: #eab308; }
:root[data-theme="dark"] .tone-violet { --b: #8b5cf6; }
:root[data-theme="dark"] .tone-slate { --b: #64748b; }

@media (hover: hover) {
  .bmedal:hover .bmedal-tile {
    transform: translateY(-3px) rotate(-4deg);
  }
}

@keyframes sweep {
  0%,
  55% {
    transform: translateX(-130%);
  }
  100% {
    transform: translateX(130%);
  }
}

@keyframes twinkle {
  0%,
  100% {
    opacity: 0;
    transform: scale(0.3);
  }
  50% {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes ring-in {
  from {
    stroke-dasharray: 0 100;
  }
}

@media (max-width: 560px) {
  .perf-main {
    grid-template-columns: 1fr;
    justify-items: center;
    gap: 1rem;
  }

  .kpis {
    width: 100%;
  }

  .ring-chart {
    width: 132px;
    height: 132px;
  }

  .form {
    flex-wrap: wrap;
  }

  .bgrid {
    grid-template-columns: repeat(3, 1fr);
  }

  .podium {
    gap: 0.45rem;
  }

  .podium-elo {
    font-size: 1.35rem;
  }

  .place-1 .podium-elo {
    font-size: 1.7rem;
  }

  .shine::before {
    font-size: 3.8rem;
  }
}

/* Rareté des badges et bonus d'ELO */

.rarity-common { --r: var(--muted); }
.rarity-rare { --r: #2563eb; }
.rarity-epic { --r: #7c3aed; }
.rarity-legendary { --r: #b7791f; }

:root[data-theme="dark"] .rarity-rare { --r: #60a5fa; }
:root[data-theme="dark"] .rarity-epic { --r: #a78bfa; }
:root[data-theme="dark"] .rarity-legendary { --r: #f0b429; }

.bmedal-pts {
  margin-top: -0.15rem;
  color: var(--r);
  font-size: 0.68rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.bmedal.locked .bmedal-pts {
  opacity: 0.85;
}

.detail-reward {
  padding: 0.25rem 0.8rem;
  border-radius: 999px;
  background: color-mix(in srgb, var(--r) 14%, transparent);
  color: var(--r);
  font-size: 0.82rem;
  font-weight: 600;
}

.elo-bonus {
  margin-top: 0.2rem;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 600;
}

.bonus-line {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  margin-top: 0.15rem;
  color: var(--accent);
  font-size: 0.75rem;
  font-weight: 700;
}

/* ---------- Ligues : écusson, carte de ligue, échelle ---------- */

.emblem {
  display: block;
  flex: none;
  filter: drop-shadow(0 2px 3px rgb(0 0 0 / 0.22));
}

.e-body {
  fill: var(--tier);
}

.tier-master .e-body {
  fill: url(#emb-master);
}

.e-rim {
  fill: none;
  stroke: color-mix(in srgb, var(--tier) 55%, #000);
  stroke-width: 1.3;
}

.e-gem {
  fill: #fff;
  opacity: 0.93;
}

.e-facet {
  fill: none;
  stroke: color-mix(in srgb, var(--tier) 65%, #000);
  stroke-width: 0.8;
  opacity: 0.45;
}

.tier-platine .emblem,
.tier-diamant .emblem {
  filter: drop-shadow(0 0 5px color-mix(in srgb, var(--tier) 65%, transparent));
}

.tier-master .emblem {
  animation: master-glow 2.6s ease-in-out infinite;
}

@keyframes master-glow {
  50% {
    filter: drop-shadow(0 0 9px rgb(236 72 153 / 0.75));
  }
}

.tier .emblem {
  filter: none;
  margin-block: -2px;
}

.tier {
  gap: 0.3rem;
  padding: 0.12rem 0.6rem 0.12rem 0.35rem;
  font-size: 0.74rem;
}

.league {
  padding-top: 1rem;
  border-top: 1px solid color-mix(in srgb, var(--tier) 28%, var(--border));
}

.league-head {
  display: grid;
  grid-template-columns: auto auto minmax(0, 1fr);
  align-items: center;
  gap: 0.9rem;
}

.league-title {
  display: flex;
  flex-direction: column;
  line-height: 1.05;
}

.league-kicker {
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.league-title strong {
  color: color-mix(in srgb, var(--tier) 80%, var(--text));
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.03em;
}

.league-pts {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  text-align: right;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
  line-height: 1.2;
}

.league-pts strong {
  color: var(--text);
  font-size: 1.9rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

/* Barre de progression : dégradé de la ligue actuelle vers la suivante, repère à la position de l'ELO */
.lprog {
  margin-top: 1.2rem;
}

.lprog-ends {
  display: flex;
  justify-content: space-between;
  margin-bottom: 0.5rem;
  font-size: 0.78rem;
  font-weight: 800;
}

.lprog-ends span:first-child {
  color: color-mix(in srgb, var(--tier) 80%, var(--text));
}

.lprog-ends span:last-child {
  color: color-mix(in srgb, var(--next) 80%, var(--text));
}

.lprog-ends small {
  margin-left: 0.15rem;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.lprog-track {
  position: relative;
  height: 14px;
  border-radius: 999px;
  background:
    repeating-linear-gradient(90deg, transparent 0 calc(25% - 1px), rgb(255 255 255 / 0.1) calc(25% - 1px) 25%),
    var(--surface-2);
  box-shadow: inset 0 1px 3px rgb(0 0 0 / 0.25);
}

.lprog-fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: var(--p);
  border-radius: inherit;
  background:
    linear-gradient(180deg, rgb(255 255 255 / 0.35), transparent 55%),
    linear-gradient(90deg, var(--tier), var(--next));
  box-shadow: 0 0 12px color-mix(in srgb, var(--tier) 45%, transparent);
  overflow: hidden;
  animation: lprog-grow 0.9s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

/* Reflet qui traverse la barre */
.lprog-fill::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(100deg, transparent 30%, rgb(255 255 255 / 0.55) 50%, transparent 70%);
  transform: translateX(-120%);
  animation: lprog-sheen 3.4s ease-in-out 1.2s infinite;
}

.lprog-knob {
  position: absolute;
  top: 50%;
  left: var(--p);
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--surface-solid);
  border: 3px solid color-mix(in srgb, var(--tier) 30%, var(--next));
  box-shadow: 0 2px 8px rgb(0 0 0 / 0.35);
  transform: translate(-50%, -50%);
  animation: lprog-knob 0.9s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

/* ELO actuel, en infobulle au-dessus du repère */
.lprog-knob b {
  position: absolute;
  bottom: calc(100% + 7px);
  left: 50%;
  padding: 0.1rem 0.45rem;
  border-radius: 6px;
  background: var(--text);
  color: var(--bg);
  font-size: 0.7rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  transform: translateX(-50%);
}

.lprog-knob b::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 50%;
  border: 4px solid transparent;
  border-top-color: var(--text);
  transform: translateX(-50%);
}

@keyframes lprog-grow {
  from {
    width: 0;
  }
}

@keyframes lprog-knob {
  from {
    left: 0;
  }
}

@keyframes lprog-sheen {
  0%,
  60% {
    transform: translateX(-120%);
  }
  100% {
    transform: translateX(120%);
  }
}

.ladder {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  align-items: end;
  gap: 0.2rem;
  margin: 1rem 0 0;
  padding: 0;
  list-style: none;
}

.ladder li {
  --tier: var(--muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
  text-align: center;
}

.ladder .tier-bronze { --tier: var(--tier-bronze); }
.ladder .tier-argent { --tier: var(--tier-argent); }
.ladder .tier-or { --tier: var(--tier-or); }
.ladder .tier-platine { --tier: var(--tier-platine); }
.ladder .tier-diamant { --tier: var(--tier-diamant); }
.ladder .tier-master { --tier: var(--tier-master); }

.ladder span {
  font-size: 0.7rem;
  font-weight: 700;
}

.ladder small {
  color: var(--muted);
  font-size: 0.62rem;
  font-variant-numeric: tabular-nums;
}

.ladder .todo {
  opacity: 0.4;
  filter: grayscale(0.7);
}

.ladder .current span {
  color: color-mix(in srgb, var(--tier) 80%, var(--text));
  font-size: 0.78rem;
  font-weight: 800;
}

.ladder .current .emblem {
  filter: drop-shadow(0 4px 8px color-mix(in srgb, var(--tier) 55%, transparent));
}

@media (max-width: 560px) {
  .league-head {
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 0.6rem;
  }

  .league-pts strong {
    font-size: 1.6rem;
  }

  .league-title strong {
    font-size: 1.7rem;
  }
}

.score-main {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.score-main .emblem {
  filter: drop-shadow(0 1px 2px rgb(0 0 0 / 0.25));
}

.rules {
  margin-top: 1.5rem;
  font-size: 0.9rem;
}

.rules ul {
  margin: 0 0 1rem;
  padding-left: 1.2rem;
  display: grid;
  gap: 0.4rem;
}

.scale {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
  font-variant-numeric: tabular-nums;
}

.scale th,
.scale td {
  padding: 0.35rem 0.5rem;
  text-align: center;
  border-bottom: 1px solid var(--border);
}

.scale th {
  color: var(--muted);
  font-weight: 600;
}

.scale td:first-child,
.scale th:first-child {
  text-align: left;
}

.scale-note {
  margin: 0.5rem 0 0;
  color: var(--muted);
  font-size: 0.78rem;
}
