:root {
  --fond: #1a120c;
  --carte: #2c1f14;
  --texte: #fff4e4;
  --muet: #d2b896;
  --accent: #f0a01a;
  --feuille: #3ea35c;
  --ciel: #4eb6d4;
  --renard: #e07028;
  --ligne: #4a3424;
  --commun: #5dce6e;
  --rare: #4ec4ea;
  --epique: #c889ee;
  --legendaire: #ffd24a;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  font-family: "Trebuchet MS", "Segoe UI", system-ui, sans-serif;
  background:
    radial-gradient(ellipse at 10% 0%, #e0702840, transparent 42%),
    radial-gradient(ellipse at 90% 8%, #4eb6d433, transparent 38%),
    radial-gradient(ellipse at 50% 100%, #3ea35c33, transparent 45%),
    linear-gradient(165deg, #2a1810 0%, #1a120c 45%, #122018 100%);
  color: var(--texte);
  padding-bottom: env(safe-area-inset-bottom);
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.barre {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.7rem;
  padding: 0.75rem 1.2rem;
  padding-top: calc(0.75rem + env(safe-area-inset-top));
  border-bottom: 1px solid var(--ligne);
  background: linear-gradient(90deg, #3a2418, #1e281c 55%, #1a2830);
  position: sticky;
  top: 0;
  z-index: 20;
}
.logo {
  font-weight: 800;
  letter-spacing: 0.04em;
  color: var(--texte);
  font-size: 1.25rem;
}
.logo span { color: var(--accent); }
.langue { margin: 0; }
.langue select {
  min-height: 40px;
  max-width: 8.5rem;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 700;
  background: #241810;
  color: var(--texte);
  border: 1px solid var(--ligne);
  border-radius: 999px;
  padding: 0.3rem 0.5rem;
}
.btn-install {
  border: 0;
  background: var(--accent);
  color: #2a1604;
  font: inherit;
  font-weight: 800;
  font-size: 0.82rem;
  padding: 0.45rem 0.7rem;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
  min-height: 40px;
}
.btn-install[hidden] { display: none !important; }
.dialog-install {
  border: 0;
  border-radius: 16px;
  padding: 1.1rem 1.2rem;
  max-width: 360px;
  background: var(--carte);
  color: var(--texte);
  box-shadow: 0 20px 50px #0008;
}
.dialog-install::backdrop { background: #120a0688; }
.dialog-install h2 { margin: 0 0 0.5rem; }
.dialog-install ol { padding-left: 1.2rem; color: var(--muet); }
.icone-partage {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.7rem;
  height: 1.7rem;
  margin: 0 0.2rem;
  vertical-align: -0.35rem;
  border-radius: 0.4rem;
  background: #e8f0ff;
  color: #007aff;
}
.icone-partage svg {
  width: 1.15rem;
  height: 1.15rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.1;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.nav-haut { display: flex; align-items: center; gap: 0.9rem; flex-wrap: wrap; }
nav a { color: var(--texte); }
.cta.haut { margin-top: 0; padding: 0.45rem 0.8rem; }
.lien-btn {
  background: none;
  border: 0;
  color: var(--texte);
  font: inherit;
  cursor: pointer;
  padding: 0;
}
.lien-btn:hover { text-decoration: underline; }
.inline { display: inline; margin: 0; }

main { max-width: 1100px; margin: 0 auto; padding: 1.5rem 1.2rem 4rem; }

.intro h1 { margin: 0 0 0.4rem; font-size: 2rem; }
.intro p, .vide { color: var(--muet); }

.filtres {
  display: flex;
  gap: 0.5rem;
  list-style: none;
  padding: 0;
  flex-wrap: wrap;
}
.filtres a {
  display: inline-block;
  padding: 0.35rem 0.75rem;
  border: 1px solid var(--ligne);
  border-radius: 999px;
  color: var(--texte);
}
.filtres a.actif { background: var(--carte); border-color: var(--accent); }

.recherche-dex {
  display: flex;
  gap: 0.5rem;
  margin: 0 0 1rem;
}
.recherche-dex input {
  flex: 1;
  min-width: 0;
  min-height: 44px;
  border-radius: 12px;
  border: 1px solid var(--ligne);
  background: #241810;
  color: var(--texte);
  font: inherit;
  padding: 0.45rem 0.8rem;
}
.recherche-dex .cta { margin: 0; min-height: 44px; }

.grille {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 0.85rem;
}
.carte, .fiche, .panneau, .pub {
  background: linear-gradient(180deg, #352418 0%, #241810 100%);
  border: 1px solid var(--ligne);
  border-radius: 14px;
}
.carte.commun { border-color: color-mix(in srgb, var(--commun) 55%, var(--ligne)); }
.carte.rare { border-color: color-mix(in srgb, var(--rare) 55%, var(--ligne)); }
.carte.epique { border-color: color-mix(in srgb, var(--epique) 55%, var(--ligne)); }
.carte.legendaire { border-color: color-mix(in srgb, var(--legendaire) 70%, var(--ligne)); }
.carte {
  padding: 0.9rem;
  color: var(--texte);
  display: block;
}
.carte:hover { text-decoration: none; border-color: var(--accent); }
.carte h2 { margin: 0.6rem 0 0.15rem; font-size: 1.1rem; }
.latin { font-style: italic; color: var(--muet); margin: 0; font-size: 0.9rem; }
.visuel {
  aspect-ratio: 4/3;
  border-radius: 10px;
  background: #0d120c;
  display: grid;
  place-items: center;
  overflow: hidden;
}
.visuel img, .carte img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.placeholder { font-size: 2.4rem; color: var(--muet); }
.meta { display: flex; gap: 0.5rem; flex-wrap: wrap; font-size: 0.85rem; color: var(--muet); }
.badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 700;
}
.badge.commun { background: color-mix(in srgb, var(--commun) 25%, transparent); color: var(--commun); }
.badge.rare { background: color-mix(in srgb, var(--rare) 25%, transparent); color: var(--rare); }
.badge.epique { background: color-mix(in srgb, var(--epique) 25%, transparent); color: var(--epique); }
.badge.legendaire { background: color-mix(in srgb, var(--legendaire) 25%, transparent); color: var(--legendaire); }
.badge.premium { background: #3a2e10; color: var(--accent); }

.fiche {
  display: grid;
  grid-template-columns: minmax(220px, 340px) 1fr;
  gap: 1.4rem;
  padding: 1.2rem;
  margin-bottom: 1.5rem;
}
.visuel.grand { min-height: 240px; }
.cta {
  display: inline-block;
  margin-top: 0.8rem;
  background: var(--accent);
  color: #1a1404;
  font-weight: 700;
  padding: 0.75rem 1rem;
  border-radius: 12px;
  border: 0;
  cursor: pointer;
  font: inherit;
  text-align: center;
  min-height: 44px;
}
.cta.secondaire {
  background: transparent;
  color: var(--texte);
  border: 1px solid var(--ligne);
}
.cta.large { width: 100%; margin-top: 1rem; }
.cta:hover { text-decoration: none; filter: brightness(1.05); }

.panneau { padding: 1.2rem; max-width: 480px; }
.champ, form p input, form p select, form p textarea {
  width: 100%;
  padding: 0.7rem 0.75rem;
  border-radius: 8px;
  border: 1px solid var(--ligne);
  background: #0d120c;
  color: var(--texte);
  font-size: 16px;
}
.visuellement-cache {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}
.suggestions { display: grid; gap: 0.45rem; margin: 0 0 1rem; }
.suggestion {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  width: 100%;
  text-align: left;
  background: #0d120c;
  color: var(--texte);
  border: 1px solid var(--ligne);
  border-radius: 10px;
  padding: 0.4rem 0.55rem;
  cursor: pointer;
  font: inherit;
}
.suggestion img {
  width: 52px;
  height: 52px;
  object-fit: cover;
  border-radius: 8px;
}
.suggestion.meilleure { border-color: var(--accent); }
.actions-photo .cta { margin-top: 0; width: 100%; }
.nom-fichier, .libelle-photo { display: block; color: var(--muet); font-size: 0.9rem; margin: 0.35rem 0; }
form p { margin: 0 0 0.8rem; position: relative; }
.helptext, .errorlist { color: var(--muet); font-size: 0.85rem; }
.errorlist { color: #e07a7a; }
.xp { font-size: 2rem; font-weight: 800; color: var(--accent); margin: 0.3rem 0 0; }

.photos figure { margin: 0; }
.photos figcaption { font-size: 0.8rem; color: var(--muet); padding: 0.4rem 0 0; }
.photo-perso {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  min-width: 0;
}
.photo-perso .carte { color: inherit; }
.form-supprimer { margin: 0; }
.btn-supprimer {
  width: 100%;
  min-height: 40px;
  border: 1px solid #8a4040;
  background: #3a1c18;
  color: #f0b4a8;
  font: inherit;
  font-weight: 700;
  border-radius: 10px;
  cursor: pointer;
}
.btn-supprimer:hover { background: #4a2420; }

.flash { list-style: none; max-width: 1100px; margin: 0.8rem auto 0; padding: 0 1.2rem; }
.flash li {
  background: #24351d;
  border: 1px solid var(--commun);
  padding: 0.6rem 0.8rem;
  border-radius: 8px;
}

.pub {
  max-width: 1100px;
  margin: 0 auto 1rem;
  padding: 1rem;
  text-align: center;
  color: var(--muet);
  font-size: 0.9rem;
}
.pub:empty { display: none; }
.pied {
  max-width: 1100px;
  margin: 0 auto 1.5rem;
  padding: 0 1.2rem 0.5rem;
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  font-size: 0.85rem;
  color: var(--muet);
}

.nav-bas { display: none; }

.visuel { position: relative; }
.gotcha {
  position: absolute;
  left: 0.4rem;
  top: 0.4rem;
  background: #3a2e10;
  color: var(--accent);
  font-size: 0.75rem;
  font-weight: 800;
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
}
.carte.capturee { border-color: var(--accent); }
.bandeau-defi {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  background: var(--carte);
  border: 1px solid var(--legendaire);
  border-radius: 14px;
  padding: 0.9rem 1rem;
  margin: 0 0 1rem;
  color: var(--texte);
}
.bandeau-defi:hover { text-decoration: none; }
.jauge-bloc { margin: 0 0 1rem; }
.jauge {
  height: 8px;
  background: #0d120c;
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid var(--ligne);
}
.jauge span {
  display: block;
  height: 100%;
  background: var(--accent);
}
.rang { font-weight: 800; letter-spacing: 0.04em; margin: 0.4rem 0 0; color: var(--accent); }
.panneau.large { max-width: 640px; }
.succes { list-style: none; padding: 0; display: grid; gap: 0.5rem; }
.succes li {
  background: var(--carte);
  border: 1px solid var(--ligne);
  border-radius: 12px;
  padding: 0.7rem 0.9rem;
  display: flex;
  flex-direction: column;
  color: var(--muet);
}
.succes li.ok { border-color: var(--accent); color: var(--texte); }
.classement { list-style: none; padding: 0; }
.classement li {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.8rem;
  background: var(--carte);
  border: 1px solid var(--ligne);
  border-radius: 12px;
  padding: 0.75rem 0.9rem;
  margin: 0 0 0.5rem;
}
.rang-n { font-weight: 800; color: var(--accent); min-width: 1.5rem; }
.xp-mini { margin-left: auto; font-weight: 700; }
.avantages { padding-left: 1.1rem; }
.avantages li { margin: 0.4rem 0; }
.nav-bas a { font-size: 0.8rem; padding: 0.5rem 0.45rem; }

@media (max-width: 720px) {
  .fiche { grid-template-columns: 1fr; }
  .nav-haut { display: none; }
  .barre { justify-content: space-between; gap: 0.5rem; }
  main { padding: 1rem 0.9rem 6.5rem; }
  .flash { padding: 0.8rem 0.9rem 0; }
  .intro h1 { font-size: 1.55rem; }
  .filtres {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 0.4rem;
  }
  .filtres a { flex: 0 0 auto; min-height: 40px; display: inline-flex; align-items: center; }
  .cta { width: 100%; }
  .pub { margin-bottom: 5.5rem; }
  .nav-bas {
    display: flex;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 30;
    background: #12180f;
    border-top: 1px solid var(--ligne);
    justify-content: space-around;
    align-items: center;
    padding: 0.35rem 0.4rem calc(0.4rem + env(safe-area-inset-bottom));
  }
  .nav-bas a {
    color: var(--texte);
    text-decoration: none;
    font-weight: 700;
    font-size: 0.85rem;
    padding: 0.55rem 0.8rem;
    min-height: 44px;
    display: flex;
    align-items: center;
  }
  .nav-bas a.principal {
    background: var(--accent);
    color: #1a1404;
    border-radius: 999px;
  }
}

@media (min-width: 721px) {
  .grille { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
  .actions-photo { flex-direction: row; }
  .actions-photo .cta { width: auto; flex: 1; }
}

.actions-photo { display: flex; flex-direction: column; gap: 0.6rem; }

.logo { animation: lueur 4s ease-in-out infinite; }
@keyframes lueur {
  0%, 100% { filter: drop-shadow(0 0 0 transparent); }
  50% { filter: drop-shadow(0 0 10px color-mix(in srgb, var(--accent) 55%, transparent)); }
}

.grille .carte.entre {
  animation: monte 0.45s ease both;
}
@keyframes monte {
  from { opacity: 0; transform: translateY(14px) scale(0.98); }
  to { opacity: 1; transform: none; }
}
.carte { transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease; }
.carte:hover { transform: translateY(-4px); box-shadow: 0 10px 24px #0006; }

.bandeau-defi {
  animation: pulse-bord 2.4s ease-in-out infinite;
}
@keyframes pulse-bord {
  0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--legendaire) 35%, transparent); }
  50% { box-shadow: 0 0 22px 2px color-mix(in srgb, var(--legendaire) 35%, transparent); }
}

.gotcha { animation: pop 0.45s cubic-bezier(.2,1.4,.3,1); }
@keyframes pop {
  from { transform: scale(0.4); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.flash li { animation: glisse 0.4s ease; }
@keyframes glisse {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: none; }
}

.cta { transition: transform 0.15s ease, filter 0.15s ease; }
.cta.presse, .cta:active { transform: scale(0.97); }
.nav-bas a.principal { animation: bounce-doux 2.8s ease-in-out infinite; }
@keyframes bounce-doux {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-3px); }
}

.jauge span { animation: jauge 0.8s ease; transform-origin: left; }
@keyframes jauge { from { transform: scaleX(0); } to { transform: scaleX(1); } }

.apercu-photo {
  display: block;
  width: 100%;
  max-height: 220px;
  object-fit: cover;
  border-radius: 12px;
  margin-top: 0.6rem;
  border: 1px solid var(--ligne);
}
.scanneur { text-align: center; padding: 0.4rem 0 0.8rem; }
.scanneur-cadre {
  position: relative;
  width: min(100%, 220px);
  aspect-ratio: 1;
  margin: 0 auto 0.7rem;
  border-radius: 16px;
  overflow: hidden;
  background: #0d120c;
}
.scanneur-cadre span {
  position: absolute;
  width: 18px;
  height: 18px;
  border: 2px solid var(--accent);
}
.scanneur-cadre span:nth-child(1) { top: 8px; left: 8px; border-right: 0; border-bottom: 0; }
.scanneur-cadre span:nth-child(2) { top: 8px; right: 8px; border-left: 0; border-bottom: 0; }
.scanneur-cadre span:nth-child(3) { bottom: 8px; left: 8px; border-right: 0; border-top: 0; }
.scanneur-cadre span:nth-child(4) { bottom: 8px; right: 8px; border-left: 0; border-top: 0; }
.scan-ligne {
  position: absolute;
  left: 10%;
  right: 10%;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  animation: scan 1.2s linear infinite;
  box-shadow: 0 0 12px var(--accent);
}
@keyframes scan {
  from { top: 12%; }
  to { top: 82%; }
}

.suggestion {
  animation: monte 0.35s ease both;
  position: relative;
}
.suggestion small { display: block; color: var(--muet); font-size: 0.8rem; }
.jauge-mini {
  position: absolute;
  right: 0.6rem;
  bottom: 0.45rem;
  width: 72px;
  height: 5px;
  background: #1a2218;
  border-radius: 99px;
  overflow: hidden;
}
.jauge-mini i {
  display: block;
  height: 100%;
  background: var(--accent);
}
.suggestion.meilleure { animation: pulse-bord 1.8s ease-in-out infinite; }
.suggestion.verrouillee { cursor: default; }
.suggestion.refusee { opacity: 0.45; }
.suggestion:disabled { cursor: default; }
.alerte-attendu {
  background: #3a1818;
  border: 1px solid #e07a7a;
  color: #f0c0c0;
  padding: 0.75rem 0.9rem;
  border-radius: 10px;
  margin: 0 0 0.7rem;
  font-weight: 600;
}
.alerte-attendu.ok {
  background: #183018;
  border-color: var(--commun);
  color: #c8f0c8;
}
.cta:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

body.celebration::after {
  content: "";
  pointer-events: none;
  position: fixed;
  inset: 0;
  background:
    radial-gradient(circle at 20% 20%, #d4a01755, transparent 25%),
    radial-gradient(circle at 80% 30%, #9b6bdb44, transparent 22%),
    radial-gradient(circle at 50% 80%, #7aa36a44, transparent 28%);
  animation: festif 1.6s ease forwards;
  z-index: 40;
}
@keyframes festif {
  from { opacity: 0; }
  30% { opacity: 1; }
  to { opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
  }
}
