/* ============================================================
   CS Cards — tokens + composants
   Direction : graphite tactique, accent ambre, cartes à foil discret
   ============================================================ */

:root,
[data-theme='light'] {
  /* Échelle typographique */
  --text-xs: clamp(0.75rem, 0.7rem + 0.25vw, 0.875rem);
  --text-sm: clamp(0.875rem, 0.8rem + 0.35vw, 1rem);
  --text-base: clamp(1rem, 0.95rem + 0.25vw, 1.125rem);
  --text-lg: clamp(1.125rem, 1rem + 0.75vw, 1.5rem);
  --text-xl: clamp(1.5rem, 1.2rem + 1.25vw, 2.25rem);
  --text-2xl: clamp(2rem, 1.2rem + 2.5vw, 3.5rem);

  /* Espacements 4px */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;
  --space-16: 4rem;
  --space-20: 5rem;
  --space-24: 6rem;

  /* Surfaces claires */
  --color-bg: #f4f3f0;
  --color-surface: #fbfaf8;
  --color-surface-2: #ffffff;
  --color-surface-offset: #ecebe6;
  --color-surface-dynamic: #e2e0da;
  --color-divider: oklch(0 0 0 / 0.08);
  --color-border: oklch(0 0 0 / 0.14);

  --color-text: #1a1b1d;
  --color-text-muted: #64666b;
  --color-text-faint: #9b9da1;
  --color-text-inverse: #f7f6f3;

  --color-primary: #9c4409;
  --color-primary-hover: #7c3406;
  --color-primary-soft: oklch(0.55 0.13 55 / 0.12);

  /* Raretés */
  --r-commune: #5a6067;
  --r-rare: #245f80;
  --r-epique: #6c3f9b;
  --r-legendaire: #96690b;
  --r-icone: #a8302a;

  --radius-sm: 0.375rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.75rem;
  --radius-xl: 1rem;
  --radius-full: 9999px;

  --transition-interactive: 180ms cubic-bezier(0.16, 1, 0.3, 1);
  --ease-sortie: cubic-bezier(0.16, 1, 0.3, 1);

  --shadow-sm: 0 1px 2px oklch(0.2 0.01 260 / 0.07);
  --shadow-md: 0 6px 16px oklch(0.2 0.01 260 / 0.1);
  --shadow-lg: 0 18px 44px oklch(0.2 0.01 260 / 0.16);

  --content-wide: 1200px;

  --font-display: 'Clash Display', 'Georgia', serif;
  --font-body: 'Satoshi', 'Helvetica Neue', sans-serif;
  --font-mono: 'JetBrains Mono', 'Menlo', monospace;

  --grain: oklch(0 0 0 / 0.04);
}

[data-theme='dark'] {
  --color-bg: #111214;
  --color-surface: #191a1d;
  --color-surface-2: #1f2125;
  --color-surface-offset: #15161a;
  --color-surface-dynamic: #282a2f;
  --color-divider: oklch(1 0 0 / 0.07);
  --color-border: oklch(1 0 0 / 0.13);

  --color-text: #e7e6e3;
  --color-text-muted: #9a9c9f;
  --color-text-faint: #6a6c70;
  --color-text-inverse: #16171a;

  --color-primary: #e8843a;
  --color-primary-hover: #f39c58;
  --color-primary-soft: oklch(0.72 0.13 55 / 0.16);

  --r-commune: #9aa1a9;
  --r-rare: #56a5cd;
  --r-epique: #a97fd8;
  --r-legendaire: #e0ac36;
  --r-icone: #e8615a;

  --shadow-sm: 0 1px 2px oklch(0 0 0 / 0.3);
  --shadow-md: 0 6px 16px oklch(0 0 0 / 0.4);
  --shadow-lg: 0 20px 48px oklch(0 0 0 / 0.55);

  --grain: oklch(1 0 0 / 0.035);
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme]) {
    color-scheme: light;
  }
}

/* ---------- utilitaires ---------- */
[hidden] {
  display: none !important;
}

.skip {
  position: absolute;
  left: var(--space-4);
  top: calc(-1 * var(--space-16));
  z-index: 50;
  background: var(--color-surface-2);
  color: var(--color-text);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  font-size: var(--text-sm);
}
.skip:focus {
  top: var(--space-4);
}

/* ---------- en-tête ---------- */
.entete {
  position: sticky;
  top: 0;
  z-index: 30;
  background: color-mix(in oklab, var(--color-bg) 88%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--color-divider);
}
.entete-inner {
  max-width: var(--content-wide);
  margin-inline: auto;
  padding: var(--space-3) var(--space-5);
  display: flex;
  flex-wrap: wrap;
  row-gap: var(--space-2);
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
}
.marque {
  display: inline-flex;
  align-items: center;
  gap: var(--space-3);
  color: var(--color-text);
  text-decoration: none;
}
.logo {
  color: var(--color-primary);
  flex: none;
}
.marque-nom {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.entete-actions {
  display: flex;
  align-items: center;
  gap: var(--space-4);
}
.compte-conteneur {
  position: relative;
}
.menu-compte {
  position: absolute;
  z-index: 40;
  top: calc(100% + 0.5rem);
  right: 0;
  min-width: 11rem;
  display: grid;
  padding: var(--space-2);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 0.75rem;
  box-shadow: var(--shadow-lg);
}
.menu-compte a {
  display: block;
  padding: 0.55rem 0.75rem;
  border-radius: 0.5rem;
  color: var(--color-text);
  text-decoration: none;
  font-size: var(--text-sm);
}
.menu-compte a:hover {
  background: var(--color-surface-2);
}
.compteur-entete {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  display: flex;
  align-items: baseline;
  gap: 0.15em;
  margin: 0;
}
.compteur-entete #entete-possedees {
  color: var(--color-text);
  font-weight: 600;
}
.compteur-sep {
  color: var(--color-text-faint);
}
.compteur-label {
  margin-left: var(--space-2);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.btn-icone {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: var(--radius-md);
  color: var(--color-text-muted);
  border: 1px solid transparent;
}
.btn-icone:hover {
  color: var(--color-text);
  background: var(--color-surface-offset);
  border-color: var(--color-divider);
}

/* ---------- boutons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: var(--space-3) var(--space-6);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}
.btn-primaire {
  background: var(--color-primary);
  color: #fff;
}
[data-theme='dark'] .btn-primaire {
  color: #1a1207;
}
.btn-primaire:hover {
  background: var(--color-primary-hover);
}
.btn-primaire:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.btn-fantome {
  border: 1px solid var(--color-border);
  color: var(--color-text);
}
.btn-fantome:hover {
  background: var(--color-surface-offset);
  border-color: var(--color-text-faint);
}

/* ============================================================
   SCÈNE D'OUVERTURE
   ============================================================ */
.scene {
  max-width: var(--content-wide);
  margin-inline: auto;
  padding: clamp(var(--space-10), 5vw, var(--space-16)) var(--space-5) var(--space-12);
  display: grid;
  gap: clamp(var(--space-8), 4vw, var(--space-12));
}
.scene-texte {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
  gap: var(--space-8) clamp(var(--space-8), 6vw, var(--space-16));
  align-items: end;
}
.scene-texte > .surtitre,
.scene-texte > h1,
.scene-texte > .accroche {
  grid-column: 1;
}
.scene-boutons,
.chiffres {
  grid-column: 2;
}
.surtitre {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--color-primary);
  margin-bottom: var(--space-4);
}
.scene .surtitre {
  margin-bottom: 0;
}
.scene h1 {
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  font-weight: 700;
  letter-spacing: -0.015em;
  margin-bottom: var(--space-4);
}
.accroche {
  color: var(--color-text-muted);
  max-width: 46ch;
}
.scene-boutons {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  grid-row: 2;
}
.chiffres {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-8);
  grid-row: 3;
  padding-top: var(--space-5);
  border-top: 1px solid var(--color-divider);
}
.chiffres dt {
  font-size: var(--text-xs);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--color-text-faint);
}
.chiffres dd {
  font-family: var(--font-mono);
  font-size: var(--text-lg);
  font-weight: 600;
  margin-top: var(--space-1);
}

/* plateau */
.scene-plateau {
  position: relative;
  min-height: 440px;
  display: grid;
  place-items: center;
  padding-block: var(--space-4) var(--space-10);
  border-top: 1px solid var(--color-divider);
}

/* ---------- pack scellé ---------- */
.pack {
  width: 232px;
  aspect-ratio: 5 / 7;
  border-radius: var(--radius-lg);
  background:
    repeating-linear-gradient(
      -45deg,
      var(--grain) 0 2px,
      transparent 2px 9px
    ),
    linear-gradient(165deg, var(--color-surface-2), var(--color-surface-offset));
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-lg);
  display: grid;
  place-items: center;
  cursor: pointer;
  font: inherit;
  color: inherit;
  transition:
    transform 520ms var(--ease-sortie),
    opacity 320ms linear;
}
.pack:hover {
  transform: translateY(-4px);
}
.pack-corps {
  text-align: center;
  padding: var(--space-5);
}
.pack-titre {
  display: block;
  font-family: var(--font-display);
  font-size: 2.25rem;
  font-weight: 700;
  line-height: 0.95;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--color-text);
}
.pack-titre::after {
  content: '';
  display: block;
  width: 40px;
  height: 3px;
  margin: var(--space-4) auto 0;
  background: var(--color-primary);
}
.pack-serie {
  display: block;
  margin-top: var(--space-4);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--color-text-faint);
}
.pack.secoue {
  animation: secousse 620ms ease-in-out;
}
.pack.parti {
  transform: translateY(-14px) scale(0.94);
  opacity: 0;
  pointer-events: none;
}
@keyframes secousse {
  0%,
  100% {
    transform: rotate(0) translateY(0);
  }
  20% {
    transform: rotate(-1.6deg) translateY(-4px);
  }
  45% {
    transform: rotate(1.8deg) translateY(2px);
  }
  70% {
    transform: rotate(-1.1deg) translateY(-2px);
  }
}

/* ---------- tirage (5 cartes) ---------- */
.tirage {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.tirage-aide {
  position: absolute;
  bottom: -6px;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-text-faint);
}

.emplacement {
  perspective: 1200px;
  flex: none;
  margin-inline: var(--space-2);
  animation: entree 460ms var(--ease-sortie) backwards;
}
.emplacement:nth-child(1) {
  animation-delay: 0ms;
  transform: rotate(-7deg) translateY(6px);
}
.emplacement:nth-child(2) {
  animation-delay: 70ms;
  transform: rotate(-3.5deg);
}
.emplacement:nth-child(3) {
  animation-delay: 140ms;
  transform: translateY(-10px);
  z-index: 3;
}
.emplacement:nth-child(4) {
  animation-delay: 210ms;
  transform: rotate(3.5deg);
}
.emplacement:nth-child(5) {
  animation-delay: 280ms;
  transform: rotate(7deg) translateY(6px);
}
@keyframes entree {
  from {
    opacity: 0;
    transform: translateY(26px) scale(0.92);
  }
}

/* ============================================================
   CARTE
   ============================================================ */
.carte {
  width: 178px;
  aspect-ratio: 5 / 7;
  position: relative;
  transform-style: preserve-3d;
  transition: transform 560ms var(--ease-sortie);
  border-radius: var(--radius-lg);
  display: block;
  padding: 0;
}
.carte.retournee {
  transform: rotateY(180deg);
}
.carte-face,
.carte-dos {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-md);
}
.carte-dos {
  background:
    repeating-linear-gradient(45deg, var(--grain) 0 2px, transparent 2px 8px),
    linear-gradient(150deg, var(--color-surface-2), var(--color-surface-offset));
  display: grid;
  place-items: center;
}
.carte-dos span {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.5rem;
  letter-spacing: 0.06em;
  color: var(--color-text-faint);
}
.carte-face {
  transform: rotateY(180deg);
  background: var(--color-surface);
  display: flex;
  flex-direction: column;
}
.emplacement .carte:hover:not(.retournee) {
  transform: translateY(-8px) scale(1.02);
}

/* variantes de rareté */
.carte-face {
  --teinte: var(--r-commune);
}
.carte[data-rarete='rare'] .carte-face {
  --teinte: var(--r-rare);
}
.carte[data-rarete='epique'] .carte-face {
  --teinte: var(--r-epique);
}
.carte[data-rarete='legendaire'] .carte-face {
  --teinte: var(--r-legendaire);
}
.carte[data-rarete='icone'] .carte-face {
  --teinte: var(--r-icone);
}
.carte-face {
  border-color: color-mix(in oklab, var(--teinte) 45%, transparent);
}
.carte[data-rarete='legendaire'] .carte-face,
.carte[data-rarete='icone'] .carte-face {
  box-shadow:
    var(--shadow-md),
    0 0 0 1px color-mix(in oklab, var(--teinte) 55%, transparent),
    0 0 30px color-mix(in oklab, var(--teinte) 26%, transparent);
}

/* portrait / monogramme */
.carte-visuel {
  position: relative;
  height: 41%;
  display: grid;
  place-items: center;
  background:
    repeating-linear-gradient(
      var(--angle, 115deg),
      color-mix(in oklab, var(--teinte) 13%, transparent) 0 1px,
      transparent 1px 7px
    ),
    linear-gradient(
      168deg,
      color-mix(in oklab, var(--teinte) 24%, var(--color-surface-2)),
      var(--color-surface)
    );
  border-bottom: 1px solid color-mix(in oklab, var(--teinte) 30%, transparent);
}
.monogramme {
  font-family: var(--font-display);
  font-size: 2.125rem;
  font-weight: 700;
  line-height: 1;
  color: color-mix(in oklab, var(--teinte) 72%, var(--color-text));
  letter-spacing: -0.02em;
}
.note {
  position: absolute;
  top: var(--space-2);
  left: var(--space-2);
  font-family: var(--font-mono);
  font-size: 1rem;
  font-weight: 600;
  line-height: 1;
  color: var(--color-text);
}
.pays {
  position: absolute;
  top: var(--space-2);
  right: var(--space-2);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.06em;
  padding: 2px var(--space-2);
  border-radius: var(--radius-sm);
  background: color-mix(in oklab, var(--color-surface-2) 82%, transparent);
  border: 1px solid var(--color-divider);
  color: var(--color-text-muted);
}
.ruban {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 3px var(--space-3);
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--color-text-inverse);
  background: var(--teinte);
}

.carte-infos {
  padding: var(--space-2) var(--space-3) var(--space-3);
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  text-align: center;
}
.carte-pseudo {
  font-family: var(--font-display);
  font-size: 1.0625rem;
  font-weight: 600;
  line-height: 1.15;
  overflow-wrap: anywhere;
}
.carte-nom {
  font-size: 0.6875rem;
  color: var(--color-text-muted);
  line-height: 1.3;
  margin-top: 1px;
  overflow-wrap: anywhere;
}
.carte-equipe {
  margin-top: auto;
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--color-text);
  padding-top: var(--space-2);
  border-top: 1px solid var(--color-divider);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.jauges {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2px var(--space-3);
  margin-top: var(--space-2);
}
.jauge {
  font-family: var(--font-mono);
  font-size: 0.625rem;
  letter-spacing: 0.04em;
  color: var(--color-text-muted);
  display: flex;
  justify-content: space-between;
  gap: var(--space-1);
}
.jauge b {
  color: var(--color-text);
  font-weight: 600;
}

/* ============================================================
   COLLECTION
   ============================================================ */
.collection {
  max-width: var(--content-wide);
  margin-inline: auto;
  padding: clamp(var(--space-8), 4vw, var(--space-12)) var(--space-5) var(--space-20);
  border-top: 1px solid var(--color-divider);
}
.collection-entete {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-5);
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: var(--space-8);
}
.collection h2 {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: 600;
}
.collection-sous-titre {
  color: var(--color-text-muted);
  font-size: var(--text-sm);
  margin-top: var(--space-1);
}
.filtres {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
}
.champ input,
.champ select {
  min-height: 44px;
  padding: 0 var(--space-4);
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  font-size: var(--text-sm);
}
.champ input {
  min-width: 240px;
}
.champ input::placeholder {
  color: var(--color-text-faint);
}
.champ input:hover,
.champ select:hover {
  border-color: var(--color-text-faint);
}

.grille {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(178px, 1fr));
  gap: var(--space-5);
}
.grille li {
  max-width: none;
  position: relative;
}
.grille .carte {
  width: 100%;
}
.doublon {
  position: absolute;
  z-index: 4;
  top: calc(-1 * var(--space-2));
  right: calc(-1 * var(--space-2));
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  font-weight: 600;
  padding: 2px var(--space-2);
  border-radius: var(--radius-full);
  background: var(--color-primary);
  color: var(--color-text-inverse);
  box-shadow: var(--shadow-sm);
}
[data-theme='light'] .doublon {
  color: #fff;
}

/* état vide */
.vide {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: var(--space-16) var(--space-6);
  color: var(--color-text-muted);
}
.vide svg {
  color: var(--color-text-faint);
  margin-bottom: var(--space-5);
  animation: flotte 3.4s ease-in-out infinite;
}
@keyframes flotte {
  50% {
    transform: translateY(-7px);
  }
}
.vide h3 {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  color: var(--color-text);
  margin-bottom: var(--space-2);
}
.vide p {
  max-width: 42ch;
  margin-bottom: var(--space-6);
}

/* pied de page */
.pied {
  border-top: 1px solid var(--color-divider);
  padding: var(--space-8) var(--space-5);
}
.pied p {
  max-width: var(--content-wide);
  margin-inline: auto;
  font-size: var(--text-xs);
  color: var(--color-text-faint);
}
.pied a {
  color: var(--color-text-muted);
}
.pied a:hover {
  color: var(--color-primary);
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 900px) {
  .scene-texte {
    grid-template-columns: 1fr;
    align-items: start;
  }
  .scene-boutons,
  .chiffres {
    grid-column: 1;
    grid-row: auto;
  }
  .accroche {
    max-width: none;
  }
  .scene-plateau {
    min-height: 380px;
  }
}

@media (max-width: 720px) {
  .emplacement {
    margin-inline: 0;
  }
  .tirage {
    position: static;
    width: 100%;
    justify-self: stretch;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--space-4);
    padding: var(--space-2);
    place-items: center;
  }
  .emplacement,
  .emplacement:nth-child(n) {
    transform: none;
    width: 100%;
  }
  .emplacement:nth-child(3) {
    grid-column: span 2;
    max-width: 176px;
  }
  .carte {
    width: 100%;
  }
  .scene-plateau {
    min-height: 0;
  }
  .tirage-aide {
    position: static;
    margin-top: var(--space-4);
    text-align: center;
  }
  .chiffres {
    gap: var(--space-6);
  }
  .champ input {
    min-width: 0;
    width: 100%;
  }
  .filtres {
    width: 100%;
  }
  .champ {
    flex: 1 1 140px;
  }
  .compteur-label {
    display: none;
  }
}

/* ---------- squelettes de chargement ---------- */
@keyframes shimmer {
  0% {
    background-position: -200% 0;
  }
  100% {
    background-position: 200% 0;
  }
}
.skeleton-carte {
  aspect-ratio: 5 / 7;
  border-radius: var(--radius-lg);
  border: 1px solid var(--color-divider);
  background: linear-gradient(
    90deg,
    var(--color-surface-offset) 25%,
    var(--color-surface-dynamic) 50%,
    var(--color-surface-offset) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s ease-in-out infinite;
}

/* la carte de collection reste face visible au survol : on ne touche qu'à
   l'élément déjà retourné, jamais à sa contre-rotation interne */
.grille .carte.retournee {
  transform: rotateY(180deg);
}
.grille .carte.retournee:hover {
  transform: rotateY(180deg) translateY(-6px);
}
.grille .carte.retournee:hover .carte-face {
  box-shadow: var(--shadow-lg);
}

/* ============================================================
   Ajouts : Pack Élite, fragments, célébration, fiche joueur
   ============================================================ */

.note-elite {
  grid-column: 2;
  max-width: 44ch;
  margin-top: var(--space-3);
  font-size: var(--text-xs);
  line-height: 1.55;
  color: var(--color-text-muted);
}

#btn-elite span {
  margin-left: 0.15em;
  color: var(--color-primary);
}

#btn-elite[disabled] {
  opacity: 0.45;
  cursor: not-allowed;
}

.pack.pack-elite .pack-corps {
  border-color: var(--r-legendaire);
  box-shadow: 0 0 0 1px var(--r-legendaire) inset, 0 18px 50px -24px var(--r-legendaire);
}

/* ---------- ouverture plein écran, carte par carte ---------- */
.voile-ouverture {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: grid;
  place-items: center;
  background: rgb(4 4 6 / 0.9);
  backdrop-filter: blur(4px);
  opacity: 0;
  transition: opacity 240ms ease;
}
.voile-ouverture.ouvert {
  opacity: 1;
}
.ouverture-scene {
  display: grid;
  justify-items: center;
  gap: var(--space-5);
  padding: var(--space-5);
}
.ouverture-compteur {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--color-text-faint);
}
.carte-overlay {
  width: min(78vw, 280px);
  cursor: pointer;
  background: none;
  border: 0;
  padding: 0;
}
.ouverture-aide {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}
.ouverture-scene #btn-continuer[disabled] {
  opacity: 0.35;
  cursor: not-allowed;
}

/* fragment gagné sur un doublon */
.fondu {
  position: absolute;
  z-index: 3;
  top: -6px;
  left: 50%;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--color-primary);
  pointer-events: none;
  animation: monte 1.4s ease-out forwards;
}

@keyframes monte {
  0% {
    opacity: 0;
    transform: translate(-50%, 6px);
  }
  22% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -34px);
  }
}

/* grosse trouvaille */
.carte.eclat {
  animation: eclat 1.1s ease-out;
}

@keyframes eclat {
  0% {
    box-shadow: 0 0 0 0 rgb(255 255 255 / 0.55);
  }
  100% {
    box-shadow: 0 0 0 26px rgb(255 255 255 / 0);
  }
}

/* la collection devient cliquable */
.grille .carte {
  width: 100%;
  cursor: pointer;
  background: none;
  border: 0;
  padding: 0;
  font: inherit;
  color: inherit;
}

.grille .carte:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 4px;
  border-radius: var(--radius-lg);
}

/* ---------- fiche joueur ---------- */
.voile {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: var(--space-4);
  background: color-mix(in srgb, var(--color-bg) 78%, transparent);
  backdrop-filter: blur(6px);
  opacity: 0;
  transition: opacity 180ms ease;
}

.voile.ouvert {
  opacity: 1;
}

.fiche {
  position: relative;
  width: min(100%, 26rem);
  max-height: 86vh;
  overflow-y: auto;
  padding: var(--space-6);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  transform: translateY(10px) scale(0.98);
  transition: transform 220ms cubic-bezier(0.22, 1, 0.36, 1);
}

.voile.ouvert .fiche {
  transform: none;
}

.fiche-fermer {
  position: absolute;
  top: var(--space-3);
  right: var(--space-3);
  display: grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  color: var(--color-text-muted);
  background: none;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: color 140ms ease, border-color 140ms ease;
}

.fiche-fermer:hover {
  color: var(--color-text);
  border-color: var(--color-text-muted);
}

.fiche-rarete {
  display: inline-block;
  margin-bottom: var(--space-2);
  padding: 0.2rem 0.6rem;
  font-family: var(--font-mono);
  font-size: 0.66rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--color-text-inverse);
  background: var(--r-commune);
  border-radius: var(--radius-sm);
}

.fiche-rarete[data-rarete='rare'] {
  background: var(--r-rare);
}
.fiche-rarete[data-rarete='epique'] {
  background: var(--r-epique);
}
.fiche-rarete[data-rarete='legendaire'] {
  background: var(--r-legendaire);
}
.fiche-rarete[data-rarete='icone'] {
  background: var(--r-icone);
}

.fiche h3 {
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  line-height: 1.05;
  letter-spacing: -0.02em;
}

.fiche-nom {
  margin-top: 0.15rem;
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}

.fiche-meta {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-3);
  margin: var(--space-5) 0;
  padding: var(--space-4) 0;
  border-top: 1px solid var(--color-border);
  border-bottom: 1px solid var(--color-border);
}

.fiche-meta dt {
  font-family: var(--font-mono);
  font-size: 0.62rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--color-text-muted);
}

.fiche-meta dd {
  margin-top: 0.2rem;
  font-size: var(--text-sm);
  font-weight: 500;
}

.fiche-stats {
  display: grid;
  gap: var(--space-3);
}

.fiche-stat {
  display: grid;
  grid-template-columns: 7.5rem 1fr 2rem;
  align-items: center;
  gap: var(--space-3);
  font-size: var(--text-sm);
}

.fiche-stat b {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  text-align: right;
}

.fiche-barre {
  height: 5px;
  overflow: hidden;
  background: color-mix(in srgb, var(--color-text) 12%, transparent);
  border-radius: var(--radius-full);
}

.fiche-barre i {
  display: block;
  height: 100%;
  background: var(--color-primary);
  border-radius: inherit;
}

.fiche-lien {
  width: 100%;
  text-decoration: none;
  margin-top: var(--space-5);
  justify-content: center;
}

.fiche-avis {
  margin-top: var(--space-4);
  font-size: var(--text-xs);
  line-height: 1.5;
  color: var(--color-text-muted);
}

@media (max-width: 900px) {
  .note-elite {
    grid-column: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  .fondu,
  .carte.eclat {
    animation: none;
  }
  .voile,
  .fiche {
    transition: none;
  }
}

/* ============================================================
   Comptes : barre d'entête, formulaires, profil, vitrine
   ============================================================ */

.btn-compact {
  padding: 0.44rem 0.8rem;
  font-size: 0.7rem;
}

/* pastille de compte dans l'entête */
.jeton-compte {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: 0.28rem 0.7rem 0.28rem 0.3rem;
  font: inherit;
  color: var(--color-text);
  background: var(--color-surface-offset);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: border-color 140ms ease;
}

.jeton-compte:hover {
  border-color: var(--color-text-muted);
}

.jeton-pseudo {
  max-width: 9rem;
  overflow: hidden;
  font-size: var(--text-xs);
  font-weight: 500;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.pastille,
.avatar {
  display: grid;
  place-items: center;
  overflow: hidden;
  font-family: var(--font-display);
  color: var(--color-text-inverse);
  background-color: var(--teinte-compte, var(--color-primary));
  background-position: center;
  background-size: cover;
  border-radius: var(--radius-full);
  flex: none;
}

.pastille {
  width: 1.65rem;
  height: 1.65rem;
  font-size: 0.72rem;
}

.avatar {
  width: 5rem;
  height: 5rem;
  font-size: 1.85rem;
  border: 2px solid var(--color-border);
}

/* champs de formulaire */
.champ {
  display: grid;
  align-content: start;
  gap: 0.35rem;
}

.champ label {
  font-family: var(--font-mono);
  font-size: 0.62rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--color-text-muted);
}

.saisie {
  width: 100%;
  padding: 0.6rem 0.75rem;
  font: inherit;
  font-size: var(--text-sm);
  color: var(--color-text);
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  transition: border-color 140ms ease, box-shadow 140ms ease;
}

.saisie:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-soft);
}

.champ-aide {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}

.couleur-ligne {
  display: grid;
  gap: 0.4rem;
  justify-items: start;
}

.champ .saisie-couleur {
  width: 3.25rem;
  height: 2.25rem;
  padding: 2px;
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  cursor: pointer;
}

.lien-discret {
  padding: 0;
  font: inherit;
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  text-decoration: underline;
  text-underline-offset: 3px;
  background: none;
  border: 0;
  cursor: pointer;
  transition: color 140ms ease;
}

.lien-discret:hover {
  color: var(--color-text);
}

/* boîte de connexion */
.fiche-auth h3 {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  letter-spacing: -0.015em;
}

.auth-intro {
  margin-top: var(--space-2);
  font-size: var(--text-sm);
  line-height: 1.55;
  color: var(--color-text-muted);
}

.onglets {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2px;
  margin: var(--space-5) 0;
  padding: 3px;
  background: var(--color-surface-offset);
  border-radius: var(--radius-md);
}

.onglet {
  padding: 0.5rem;
  font-family: var(--font-mono);
  font-size: 0.66rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-text-muted);
  background: none;
  border: 0;
  border-radius: calc(var(--radius-md) - 2px);
  cursor: pointer;
  transition: background 140ms ease, color 140ms ease;
}

.onglet.actif {
  color: var(--color-text);
  background: var(--color-surface-2);
  box-shadow: var(--shadow-sm);
}

.form-auth {
  display: grid;
  gap: var(--space-4);
}

.form-auth .btn {
  justify-content: center;
  width: 100%;
  margin-top: var(--space-1);
}

.auth-erreur {
  padding: 0.6rem 0.75rem;
  font-size: var(--text-xs);
  line-height: 1.5;
  color: var(--r-icone);
  background: color-mix(in srgb, var(--r-icone) 12%, transparent);
  border-radius: var(--radius-md);
}

/* ---------- section profil ---------- */
.profil {
  max-width: var(--content-wide);
  margin-inline: auto;
  padding: clamp(var(--space-8), 4vw, var(--space-12)) var(--space-5) 0;
  border-top: 1px solid var(--color-divider);
}

.profil-entete {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-5);
  align-items: flex-start;
  justify-content: space-between;
  padding-bottom: var(--space-8);
  border-bottom: 1px solid var(--color-divider);
}

.profil-identite {
  display: flex;
  gap: var(--space-5);
  align-items: center;
}

.avatar-bloc {
  display: grid;
  gap: var(--space-2);
  justify-items: center;
}

.avatar-actions {
  display: grid;
  gap: 0.35rem;
  justify-items: center;
}

.profil h2 {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  line-height: 1.05;
  letter-spacing: -0.02em;
}

.profil-resume {
  margin-top: var(--space-2);
  max-width: 52ch;
  font-size: var(--text-xs);
  line-height: 1.6;
  color: var(--color-text-muted);
}

.profil-grille {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr));
  gap: var(--space-5);
  padding: var(--space-8) 0;
}

.profil-etat {
  grid-column: 1 / -1;
  min-height: 1.1rem;
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}

.profil-etat.erreur {
  color: var(--r-icone);
}

/* ---------- vitrine ---------- */
.vitrine-bloc {
  padding-bottom: var(--space-4);
}

.vitrine-entete h3 {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  letter-spacing: -0.015em;
}

.vitrine-entete p {
  margin-top: var(--space-2);
  max-width: 58ch;
  font-size: var(--text-sm);
  line-height: 1.6;
  color: var(--color-text-muted);
}

.vitrine {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(10rem, 14rem));
  gap: var(--space-5);
  margin-top: var(--space-6);
  list-style: none;
}

.vitrine-case {
  display: grid;
  gap: var(--space-3);
  justify-items: center;
  width: 100%;
  max-width: 14rem;
}

.vitrine-case.pleine .carte {
  width: 100%;
}

.vide-case {
  display: grid;
  place-content: center;
  gap: var(--space-2);
  aspect-ratio: 5 / 7;
  padding: var(--space-4);
  text-align: center;
  background: var(--color-surface);
  border: 1px dashed var(--color-border);
  border-radius: var(--radius-lg);
}

.vide-case p {
  font-size: var(--text-xs);
  color: var(--color-text-faint);
}

.vitrine-numero {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  color: var(--color-text-faint);
  opacity: 0.45;
}

.fiche-vitrine {
  justify-content: center;
  width: 100%;
  margin-top: var(--space-5);
}

.fiche-vitrine:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

@media (max-width: 620px) {
  /* l'entête doit rester sur une ligne malgré le bouton de compte */
  .marque-nom {
    display: none;
  }
  .compteur-label {
    display: none;
  }
  .jeton-pseudo {
    max-width: 5.5rem;
  }
}

@media (max-width: 640px) {
  .profil {
    padding-inline: var(--space-4);
  }
  .profil-identite {
    flex-direction: column;
    align-items: flex-start;
  }
  .avatar-bloc {
    justify-items: start;
  }
}

/* ---------------------- administration ---------------------- */
.profil-liens {
  display: grid;
  gap: 0.35rem;
  justify-items: end;
  text-align: right;
}

.lien-discret.danger {
  color: var(--r-icone);
}

.admin-bloc {
  display: grid;
  gap: var(--space-5);
  margin-top: var(--space-8);
  padding-top: var(--space-7);
  border-top: 1px solid var(--color-border);
  scroll-margin-top: 5.5rem;
}

.admin-barre {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
}

.table-enveloppe {
  overflow-x: auto;
  border: 1px solid var(--color-border);
  border-radius: 0.75rem;
}

.table-admin {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}

.table-admin th,
.table-admin td {
  padding: 0.7rem var(--space-4);
  text-align: left;
  vertical-align: middle;
}

/* la séparation est portée par la ligne : sinon elle se décale sous la
   cellule du pseudo, qui est plus haute */
.table-admin tr + tr {
  border-top: 1px solid var(--color-border);
}

.table-admin thead th {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-text-muted);
  background: var(--color-surface-2);
}

.table-admin tbody th {
  display: grid;
  gap: 0.15rem;
  justify-items: start;
  font-weight: 600;
  color: var(--color-text);
}

.admin-nom {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.table-admin td {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  color: var(--color-text);
}

.admin-date {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 400;
  color: var(--color-text-muted);
}

.etiquette-admin {
  display: inline-block;
  padding: 0.1rem 0.4rem;
  border-radius: 0.3rem;
  background: color-mix(in srgb, var(--color-primary) 22%, transparent);
  color: var(--color-primary);
  font-family: var(--font-mono);
  font-size: 0.62rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.admin-actions {
  display: flex;
  gap: var(--space-4);
  white-space: nowrap;
}

/* ---------- amis ---------- */
.recherche-amis {
  position: relative;
  max-width: 26rem;
}
.recherche-resultats {
  position: absolute;
  z-index: 5;
  top: calc(100% + 0.4rem);
  left: 0;
  right: 0;
  display: grid;
  gap: 0.25rem;
  padding: var(--space-2);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 0.75rem;
  box-shadow: var(--shadow-lg);
}
.recherche-resultats:empty {
  display: none;
}
.resultat-compte {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: 0.4rem 0.6rem;
  border-radius: 0.5rem;
}
.resultat-compte:hover {
  background: var(--color-surface-2);
}
.mini-cartes-amis {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: var(--space-4);
  margin-top: var(--space-4);
}
.mini-cartes-amis .carte {
  width: 100%;
  pointer-events: none;
}


@media (max-width: 620px) {
  .profil-liens {
    justify-items: start;
    text-align: left;
  }
}
