/* Classeur TCG : couleurs du dégradé de l'icône (sarcelle → or), par-dessus le kit du playground. */
:root {
  --pg-bg: #f3f6f6;
  --pg-surface: #ffffff;
  --pg-surface-2: #e9efef;
  --pg-text: #142022;
  --pg-muted: #56676a;
  --pg-line: #dce5e5;
  --pg-dot: rgba(20, 32, 34, 0.08);
  --pg-accent: #0e8a95;
  --pg-accent-2: #c98a1c;
  --card-ink: #0b2a2e;
  --danger: #c43c3c;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --pg-bg: #0d1214;
    --pg-surface: #151c1f;
    --pg-surface-2: #1d2629;
    --pg-text: #edf3f3;
    --pg-muted: #9db0b3;
    --pg-line: #243034;
    --pg-dot: rgba(237, 243, 243, 0.06);
    --pg-accent: #39c6d1;
    --pg-accent-2: #f0b54a;
    --danger: #ff7b7b;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
body { -webkit-tap-highlight-color: transparent; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
.muted { color: var(--pg-muted); }
.small { font-size: 14px; }
.ic { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
:focus-visible { outline: 2px solid var(--pg-accent); outline-offset: 2px; }

/* ---------------------------------------------------------------- en-tête */
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 22px 0 6px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 14px; min-width: 0; }
.logo { width: 48px; height: 48px; flex: none; }
.brand > div { min-width: 0; }
.brand h1 { margin: 0; font-size: clamp(24px, 5vw, 32px); line-height: 1.1; letter-spacing: -0.02em; }
.sub { margin: 2px 0 0; font: 500 12.5px/1.4 var(--pg-mono); color: var(--pg-muted); }
.top-actions { display: flex; gap: 8px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 42px; padding: 0 14px; border-radius: 12px;
  border: 1px solid var(--pg-line); background: var(--pg-surface); color: var(--pg-text);
  font-weight: 600; font-size: 15px; white-space: nowrap; text-decoration: none;
  transition: border-color .15s, background .15s, transform .1s;
}
.btn:hover { border-color: color-mix(in srgb, var(--pg-accent) 50%, var(--pg-line)); }
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--pg-grad); border-color: transparent; color: #fff; }
.btn.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 35%, var(--pg-line)); }
.link { background: none; border: 0; padding: 8px 4px; color: var(--pg-accent); font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }

/* ---------------------------------------------------------------- progression */
.progress {
  margin: 14px 0 12px; padding: 14px 16px; border-radius: var(--pg-radius);
  background: var(--pg-surface); border: 1px solid var(--pg-line); box-shadow: var(--pg-shadow);
}
.progress-txt { display: flex; align-items: baseline; gap: 6px; font-size: 15px; color: var(--pg-muted); }
.progress-txt b { font-size: 26px; color: var(--pg-text); font-variant-numeric: tabular-nums; }
.progress-pct { margin-left: auto; font: 600 15px var(--pg-mono); color: var(--pg-text); }
.bar { height: 8px; margin-top: 8px; border-radius: 99px; background: var(--pg-surface-2); overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; border-radius: inherit; background: var(--pg-grad); transition: width .35s ease; }
.progress-scope { margin: 6px 0 0; font: 12px var(--pg-mono); color: var(--pg-muted); }

/* ---------------------------------------------------------------- filtres */
.filters {
  position: sticky; top: 0; z-index: 10;
  margin: 0 -16px 14px; padding: 10px 16px;
  background: color-mix(in srgb, var(--pg-bg) 86%, transparent);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  border-bottom: 1px solid transparent;
}
.filters-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.search {
  flex: 1 1 220px; display: flex; align-items: center; gap: 8px; min-height: 42px; padding: 0 12px;
  border-radius: 12px; border: 1px solid var(--pg-line); background: var(--pg-surface); color: var(--pg-muted);
}
.search:focus-within { border-color: var(--pg-accent); }
.search input { flex: 1; min-width: 0; border: 0; outline: 0; background: none; font-size: 16px; color: var(--pg-text); }
.seg { display: inline-flex; padding: 3px; border-radius: 12px; background: var(--pg-surface-2); border: 1px solid var(--pg-line); }
.seg button {
  border: 0; background: none; min-height: 34px; padding: 0 12px; border-radius: 9px;
  font-size: 14px; font-weight: 600; color: var(--pg-muted);
}
.seg button[aria-checked="true"] { background: var(--pg-surface); color: var(--pg-text); box-shadow: var(--pg-shadow); }
.btn-filters b {
  min-width: 20px; height: 20px; padding: 0 6px; border-radius: 99px; background: var(--pg-grad); color: #fff;
  font: 600 12px/20px var(--pg-mono); text-align: center;
}
.filters-more { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-end; margin-top: 10px; }
.filters-more label, .form label { display: flex; flex-direction: column; gap: 4px; }
.filters-more label { flex: 1 1 150px; }
.filters-more label > span, .form label > span, .form legend { font: 500 11.5px var(--pg-mono); color: var(--pg-muted); text-transform: uppercase; letter-spacing: .03em; }
select, .form input:not([type="checkbox"]) {
  min-height: 42px; padding: 0 10px; border-radius: 12px; border: 1px solid var(--pg-line);
  background: var(--pg-surface); font-size: 16px; width: 100%;
}
select:focus, .form input:focus { outline: 0; border-color: var(--pg-accent); }

/* Filtres en icônes et en avatars : une rangée de boutons ronds, celui qui est actif cerclé de la couleur du projet */
.pick { display: flex; flex-direction: column; gap: 6px; flex: 1 1 300px; min-width: 0; }
.pick-wide { flex-basis: 100%; }
.pick > span { font: 500 11.5px var(--pg-mono); color: var(--pg-muted); text-transform: uppercase; letter-spacing: .03em; }
.pick > span b { font-weight: 500; color: var(--pg-text); text-transform: none; }
.pick-row { display: flex; flex-wrap: wrap; gap: 6px; }
.pick-row.avatars { flex-wrap: nowrap; overflow-x: auto; padding: 2px 2px 6px; scrollbar-width: thin; scroll-snap-type: x proximity; }
.pick-b {
  flex: none; display: grid; place-items: center; width: 40px; height: 40px; padding: 0; border-radius: 50%;
  border: 1px solid var(--pg-line); background: var(--pg-surface); color: var(--pg-muted); cursor: pointer;
  transition: border-color .15s, color .15s, box-shadow .15s, opacity .15s; scroll-snap-align: start;
}
.pick-b:hover { color: var(--pg-text); border-color: var(--pg-muted); }
.pick-b[aria-pressed="true"] { color: var(--pg-accent); border-color: var(--pg-accent); box-shadow: 0 0 0 2px var(--pg-accent); }
.pick-b:focus-visible { outline: 2px solid var(--pg-accent); outline-offset: 2px; }
.avatars .pick-b { width: 44px; height: 44px; overflow: hidden; }
.avatars .pick-b img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
.avatars:has([aria-pressed="true"]) .pick-b:not([aria-pressed="true"]) { opacity: .55; }
/* Icônes officielles (monochromes) posées en masque : elles prennent la couleur du texte, en clair comme en sombre */
.ico {
  display: inline-block; width: 22px; height: 22px; flex: none; background: currentColor;
  -webkit-mask: var(--ico) center / contain no-repeat; mask: var(--ico) center / contain no-repeat;
}
#d-tags .pg-chip { display: inline-flex; align-items: center; gap: 6px; }
#d-tags .ico { width: 16px; height: 16px; }
#d-tags .av { width: 20px; height: 20px; margin-left: -4px; border-radius: 50%; object-fit: cover; }

@media (min-width: 900px) {
  .btn-filters { display: none; }
}
@media (max-width: 899px) {
  .filters-more { display: none; }
  .filters-open .filters-more { display: flex; }
  .filters-more label { flex-basis: calc(50% - 4px); }
}
.search, .search input { min-width: 0; }
@media (max-width: 560px) {
  .seg { order: 3; flex: 1 1 100%; }
  .seg button { flex: 1; }
  .search { flex: 1 1 0; }
  .top { flex-wrap: nowrap; padding-top: 16px; }
  .brand { flex: 1; gap: 10px; }
  .logo { width: 40px; height: 40px; }
  .brand h1 { font-size: 22px; white-space: nowrap; }
  .sub { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .top-actions .btn span { display: none; }
  .top-actions .btn { padding: 0 11px; }
}
@media (min-width: 900px) { .filters { position: static; } }

/* ---------------------------------------------------------------- grille */
.empty { text-align: center; color: var(--pg-muted); padding: 40px 0; }
.grid {
  list-style: none; margin: 0; padding: 0 0 40px;
  display: grid; gap: 14px;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
}
@media (max-width: 560px) { .grid { gap: 10px; grid-template-columns: repeat(3, minmax(0, 1fr)); } }

.tile { position: relative; content-visibility: auto; contain-intrinsic-size: auto 220px; }
.tile-open { display: block; width: 100%; padding: 0; border: 0; background: none; border-radius: 6%; perspective: 800px; }
.tile:not(.owned) .cf { filter: grayscale(1) contrast(.85); opacity: .42; }
.tile:not(.owned) .tile-open { outline: 1.5px dashed color-mix(in srgb, var(--pg-muted) 55%, transparent); outline-offset: 3px; }
.tile-open:hover .cf { opacity: .75; }
.tile.owned .tile-open:hover .cf { opacity: 1; }

.tile-check {
  position: absolute; top: -6px; right: -6px; z-index: 3;
  width: 32px; height: 32px; padding: 0; border-radius: 50%;
  border: 2px solid var(--pg-line); background: var(--pg-surface); box-shadow: var(--pg-shadow);
  display: grid; place-items: center; transition: background .15s, border-color .15s, transform .15s;
}
.tile-check::before { content: ""; position: absolute; inset: -8px; } /* zone de toucher de 48 px */
.tile-check svg { width: 18px; height: 18px; fill: none; stroke: var(--pg-surface); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; opacity: 0; }
.tile-check:hover { border-color: var(--pg-accent); }
.tile.owned .tile-check { background: var(--pg-accent); border-color: var(--pg-accent); }
.tile.owned .tile-check svg { opacity: 1; }
.tile.pop .tile-check { animation: pop .35s ease; }
.tile.pop .cf { animation: shine .7s ease; }
@keyframes pop { 40% { transform: scale(1.25); } }
@keyframes shine { 0% { filter: brightness(1.6); } }

/* Variables de lumière déclarées pour pouvoir être animées : la carte suit le doigt et revient en douceur. */
@property --mx { syntax: '<percentage>'; inherits: true; initial-value: 50%; }
@property --my { syntax: '<percentage>'; inherits: true; initial-value: 40%; }
@property --bgx { syntax: '<percentage>'; inherits: true; initial-value: 50%; }
@property --bgy { syntax: '<percentage>'; inherits: true; initial-value: 50%; }
@property --rx { syntax: '<angle>'; inherits: true; initial-value: 0deg; }
@property --ry { syntax: '<angle>'; inherits: true; initial-value: 0deg; }
@property --hyp { syntax: '<number>'; inherits: true; initial-value: 0; }

/* ---------------------------------------------------------------- face d'une carte */
.cf {
  --mx: 50%; --my: 40%; --rx: 0deg; --ry: 0deg; --hyp: .3; --bgx: 50%; --bgy: 50%;
  position: relative; aspect-ratio: 63 / 88; width: 100%;
  border-radius: 5.5% / 4%; overflow: hidden; isolation: isolate;
  transform: rotateX(var(--rx)) rotateY(var(--ry));
  /* à plat (en preserve-3d, overflow ne rogne pas toujours ce qui touche un bord) */
  transform-style: flat;
  transition: --rx .7s cubic-bezier(.2, .8, .3, 1), --ry .7s cubic-bezier(.2, .8, .3, 1), --mx .7s ease, --my .7s ease, --bgx .7s ease, --bgy .7s ease, --hyp .7s ease, box-shadow .3s, filter .3s, opacity .3s;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .18), 0 6px 16px -8px rgba(0, 0, 0, .35);
  container-type: inline-size;
  text-align: left; color: #fff;
}
.cf.active { transition: --rx .12s linear, --ry .12s linear, --mx .12s linear, --my .12s linear, --bgx .12s linear, --bgy .12s linear, --hyp .12s linear, box-shadow .3s; box-shadow: 0 2px 4px rgba(0, 0, 0, .2), 0 18px 36px -14px rgba(0, 0, 0, .55); }
.cf-frame {
  position: absolute; inset: 0; padding: 5.5%;
  display: flex; flex-direction: column; gap: 4%;
  background:
    radial-gradient(120% 70% at 50% 18%, color-mix(in srgb, var(--pg-accent) 75%, #fff) 0%, transparent 60%),
    linear-gradient(160deg, color-mix(in srgb, var(--pg-accent) 85%, #000) 0%, #0b2a2e 55%, color-mix(in srgb, var(--pg-accent-2) 70%, #000) 100%);
  border-radius: inherit;
  box-shadow: inset 0 0 0 max(2px, 1.6cqi) rgba(255, 255, 255, .14);
}
.t-action .cf-frame {
  background:
    radial-gradient(120% 70% at 50% 18%, color-mix(in srgb, var(--pg-accent-2) 65%, #fff) 0%, transparent 60%),
    linear-gradient(160deg, color-mix(in srgb, var(--pg-accent-2) 75%, #000) 0%, #2a1d07 55%, color-mix(in srgb, var(--pg-accent) 60%, #000) 100%);
}
.t-jeton .cf-frame {
  background:
    radial-gradient(120% 70% at 50% 18%, rgba(255, 255, 255, .45) 0%, transparent 60%),
    linear-gradient(160deg, #3c4a4d 0%, #182124 60%, #2c3538 100%);
}
.cf-art {
  position: relative; flex: 1; min-height: 0; border-radius: 4cqi;
  display: grid; place-items: center;
  background: radial-gradient(circle at 50% 45%, rgba(255, 255, 255, .18), rgba(0, 0, 0, .25) 75%);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .18);
  overflow: hidden;
}
.cf-glyph { width: 52%; height: auto; fill: none; stroke: #fff; stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round; filter: drop-shadow(0 0 3cqi rgba(255, 255, 255, .45)); position: relative; z-index: 1; }
.cf-ini {
  position: absolute; inset: auto 0 -8% 0; text-align: center;
  font: 800 34cqi/1 var(--pg-font); letter-spacing: -0.04em; color: rgba(255, 255, 255, .1);
}
.cf-txt { display: flex; flex-direction: column; gap: 1cqi; }
.cf-name {
  font: 700 9.4cqi/1.1 var(--pg-font); letter-spacing: -0.01em;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  text-shadow: 0 1px 2px rgba(0, 0, 0, .5);
}
.cf-meta { font: 500 6.4cqi/1.2 var(--pg-mono); color: rgba(255, 255, 255, .72); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cf-foot { display: flex; justify-content: space-between; align-items: center; gap: 2cqi; font: 500 5.6cqi/1 var(--pg-mono); color: rgba(255, 255, 255, .7); }
.cf-foot span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cf-foot b { flex: none; padding: 1.2cqi 2.6cqi; border-radius: 99px; background: rgba(0, 0, 0, .35); color: #fff; font-weight: 700; }

/* Calques de brillance */
.holo, .glare { position: absolute; inset: 0; border-radius: inherit; pointer-events: none; z-index: 2; }
.holo { opacity: 0; transition: opacity .3s; mix-blend-mode: color-dodge; background-size: 260% 260%; background-position: var(--bgx) var(--bgy); }
.glare {
  opacity: 0; transition: opacity .3s; mix-blend-mode: overlay;
  background: radial-gradient(farthest-corner circle at var(--mx) var(--my), rgba(255, 255, 255, .85) 8%, rgba(255, 255, 255, .25) 30%, rgba(0, 0, 0, .35) 90%);
}
.cf.active .glare { opacity: .8; }
.tile:not(.owned) .holo, .tile:not(.owned) .glare { display: none; }

/* Ta photo remplace le dessin ; la brillance de la rareté passe par-dessus. */
.wip {
  position: absolute; left: 50%; bottom: 1.2%; z-index: 5; transform: translateX(-50%); pointer-events: none;
  padding: .9cqi 2.4cqi; border-radius: 99px; white-space: nowrap;
  font: 700 3.8cqi/1 var(--pg-mono); letter-spacing: .04em; text-transform: uppercase;
  color: rgba(255, 255, 255, .85); background: rgba(0, 0, 0, .42); opacity: .8;
}
.cf-photo { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; user-select: none; -webkit-user-drag: none; }
.cf-lv {
  position: absolute; right: 5%; bottom: 3.5%; z-index: 3; padding: 1.2cqi 2.6cqi; border-radius: 99px;
  background: rgba(0, 0, 0, .6); color: #fff; font: 700 5.6cqi/1 var(--pg-mono);
}

/* Lv1 (et, pour le moment, Lv3 et Lv4) : pelliculage holo « verre irisé » (玻璃幻彩镭射) : arc-en-ciel + facettes de verre */
:is(.g1, .g3, .g4) .holo {
  opacity: .4;
  background-image:
    repeating-linear-gradient(60deg, rgba(255, 255, 255, .18) 0 1px, transparent 1px 11px),
    repeating-linear-gradient(-60deg, rgba(255, 255, 255, .18) 0 1px, transparent 1px 11px),
    repeating-linear-gradient(115deg,
      hsl(0 90% 65%) 0%, hsl(45 95% 62%) 4%, hsl(120 80% 60%) 8%, hsl(190 90% 62%) 12%, hsl(260 85% 68%) 16%, hsl(320 85% 65%) 20%, hsl(360 90% 65%) 24%);
  background-size: auto, auto, 260% 260%;
  filter: brightness(.75) contrast(1.4) saturate(.9);
}
:is(.g1, .g3, .g4).active .holo { opacity: .8; }

/* Lv2 : paillettes fines (细闪) */
.g2 .holo, .gSP .holo {
  opacity: .55;
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='1.3' numOctaves='1' seed='4'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 14 -9.6'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)'/%3E%3C/svg%3E"),
    linear-gradient(115deg, hsl(0 90% 60%), hsl(60 95% 60%), hsl(140 80% 55%), hsl(200 90% 60%), hsl(270 85% 65%), hsl(330 85% 62%), hsl(0 90% 60%));
  background-size: 160px 160px, 260% 260%;
  background-position: calc(var(--bgx) * -1) calc(var(--bgy) * -1), var(--bgx) var(--bgy);
  background-blend-mode: multiply;
}
.g2.active .holo { opacity: 1; }

/* SP : illustration alternative, texture prismatique (异画) */
.gSP .cf-frame { box-shadow: inset 0 0 0 max(2px, 2cqi) #f3f0ff, inset 0 0 0 max(3px, 2.8cqi) rgba(0, 0, 0, .3); }
.gSP .cf-art::after {
  content: ""; position: absolute; inset: 0; mix-blend-mode: color-dodge; opacity: .55;
  background: conic-gradient(from 0deg at var(--mx) var(--my), hsl(0 90% 60%), hsl(60 95% 60%), hsl(140 80% 55%), hsl(200 90% 60%), hsl(270 85% 65%), hsl(330 85% 62%), hsl(360 90% 60%));
}
/* Texture réfractive (折光纹理) : anneaux concentriques qui suivent la lumière, or et argent entrelacés */
.gSP .holo {
  opacity: .7;
  background-image:
    repeating-radial-gradient(circle at var(--mx) var(--my), rgba(255, 255, 255, .35) 0 2px, transparent 2px 9px),
    linear-gradient(115deg, rgba(246, 210, 122, .9), rgba(230, 236, 248, .9) 30%, hsl(200 90% 60%) 45%, hsl(300 80% 65%) 60%, rgba(246, 210, 122, .9) 80%);
  background-size: auto, 260% 260%;
  background-position: 0 0, var(--bgx) var(--bgy);
  background-blend-mode: overlay;
}
.gSP.has-photo .cf-art::after { display: none; }
.gSP.active .holo { opacity: 1; }

/* ---------------------------------------------------------------- brillance sur les vraies cartes (images)
   Calée sur des photos de vraies cartes (annonces eBay en lumière directe) et la fiche des finitions de Shining Soul.
   Le personnage n'est jamais couvert par une texture, à aucune rareté (il continue sous le cadre du texte).
   R1 pelliculage holo « verre irisé » (玻璃幻彩镭射) : arc-en-ciel très discret, hors du personnage
   R2 grain scintillant fin et argenté (细闪) sur le fond : des points fixes sur la carte, qui s'allument là où tombe
       la lumière ; le trait doré du cadre, les étoiles des coins et le bord de la carte sont irisés
   R3 / R4 : pour le moment le même effet que les R1 (leurs propres effets seront refaits sur une base propre)
   Tout suit le dessin de chaque carte : masques calculés par tools/masques.py (--fm fond, --fc cadre des R2). Comme
   une vraie carte : presque rien à plat, l'effet s'allume quand on l'incline (--hyp = inclinaison, 0 à 1). Les points
   du grain des R2 restent fixes sur la carte : seule la lumière, et donc ceux qui brillent, change. */
.cf.has-photo {
  --hyp: .12;
  --spark: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='97' height='97'%3E%3Cfilter id='n' x='0' y='0' width='1' height='1' color-interpolation-filters='sRGB'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.62' numOctaves='1' seed='5' stitchTiles='stitch'/%3E%3CfeColorMatrix values='26 0 0 0 -16.6 26 0 0 0 -16.6 26 0 0 0 -16.6 0 0 0 0 1'/%3E%3CfeGaussianBlur stdDeviation='.4'/%3E%3C/filter%3E%3Crect width='97' height='97' filter='url(%23n)'/%3E%3C/svg%3E");
  --rainbow: repeating-linear-gradient(115deg, hsl(0 88% 52%) 0%, hsl(45 90% 50%) 5%, hsl(120 78% 44%) 10%, hsl(190 88% 50%) 15%, hsl(260 84% 57%) 20%, hsl(320 84% 52%) 25%, hsl(360 88% 52%) 30%);
  /* La lumière : forte au point visé, s'éteint en s'éloignant (les points ne brillent que là). */
  --light: radial-gradient(farthest-corner circle at var(--mx) var(--my), #fff 0%, #9a9a9a 22%, #3a3a3a 55%, #161616 100%);
}
.cf.has-photo :is(.holo, .rim, .foil) {
  position: absolute; inset: 0; border-radius: inherit; pointer-events: none; z-index: 2;
  transition: none; filter: none;
}
.cf.has-photo .glare {
  opacity: calc(var(--hyp) * .55); transition: none;
  background: radial-gradient(farthest-corner circle at var(--mx) var(--my), rgba(255, 255, 255, .6) 4%, rgba(255, 255, 255, .14) 28%, rgba(0, 0, 0, .16) 95%);
}
.foil, .rim { opacity: 0; }
.tile:not(.owned) :is(.foil, .rim) { display: none; }
/* Masque du fond : partout sauf le personnage (sans masque : toute la carte) */
.cf.has-photo .holo {
  -webkit-mask: var(--fm, linear-gradient(#000, #000)) center / 100% 100% no-repeat;
  mask: var(--fm, linear-gradient(#000, #000)) center / 100% 100% no-repeat;
}

/* R1 (et R3 / R4 pour le moment) : bandes arc-en-ciel fines et facettes de verre, à peine visibles */
.cf.has-photo:is(.g1, .g3, .g4) .holo {
  opacity: calc(.02 + var(--hyp) * .24); mix-blend-mode: color-dodge;
  background-image:
    repeating-linear-gradient(62deg, rgba(255, 255, 255, .35) 0 1px, transparent 1px 7%),
    repeating-linear-gradient(-58deg, rgba(255, 255, 255, .28) 0 1px, transparent 1px 9%),
    repeating-linear-gradient(110deg, hsl(0 85% 62%) 0%, hsl(50 90% 60%) 3%, hsl(130 75% 55%) 6%, hsl(195 85% 60%) 9%, hsl(265 80% 66%) 12%, hsl(330 80% 62%) 15%, hsl(360 85% 62%) 18%);
  background-size: 140% 140%, 160% 160%, 300% 300%;
  background-position: var(--bgx) var(--bgy), calc(100% - var(--bgx)) var(--bgy), var(--bgx) var(--bgy);
}

/* R2 : grain scintillant. Des points fins et clairsemés, fixes sur la carte, éclairés par la lumière (--light) :
   quand on incline, la lumière se déplace et allume d'autres points ; teinte argentée, à peine irisée. */
.cf.has-photo.g2 .holo {
  opacity: calc(.05 + var(--hyp) * .75); mix-blend-mode: color-dodge;
  background-image: var(--spark), var(--light),
    linear-gradient(115deg, #b9c2d0 0%, #ffffff 18%, #ffe1ee 32%, #dff6ff 46%, #fffbe2 60%, #eadcff 74%, #ffffff 86%, #b9c2d0 100%);
  background-size: 97px 97px, 100% 100%, 300% 300%;
  background-position: 0 0, 0 0, var(--bgx) var(--bgy);
  background-blend-mode: multiply;
}
/* R2 : le bord de la carte, le trait doré du cadre et les étoiles des coins (--fc, le même gabarit pour toutes
   les R2) sont irisés : paillettes arc-en-ciel fixes sur un arc-en-ciel léger (::before), toujours un peu visibles. */
.cf.has-photo.g2 :is(.rim, .foil) {
  opacity: calc(.45 + var(--hyp) * .55); mix-blend-mode: color-dodge;
  background-image: var(--spark), var(--rainbow);
  background-size: 97px 97px, 220% 220%;
  background-position: 0 0, var(--bgx) var(--bgy);
  background-blend-mode: multiply;
}
.cf.has-photo.g2 :is(.rim, .foil)::before {
  content: ""; position: absolute; inset: 0; opacity: .45;
  background: var(--rainbow) var(--bgx) var(--bgy) / 220% 220%;
}
.cf.has-photo.g2 .rim {
  padding: 2.4cqi;
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0);
}
.cf.has-photo.g2 .foil {
  opacity: calc(.6 + var(--hyp) * .4);
  -webkit-mask: var(--fc, linear-gradient(transparent, transparent)) center / 100% 100% no-repeat;
  mask: var(--fc, linear-gradient(transparent, transparent)) center / 100% 100% no-repeat;
}

/* Carte en grand ; tant qu'on ne la touche pas, elle « respire » comme si on la tenait à la main */
.cf.big { border-radius: 4.5% / 3.2%; }
@media (hover: hover) and (pointer: fine) { .cf.big { cursor: grab; } }
.cf.big.has-photo:not(.active) { animation: sway 7s ease-in-out infinite alternate; }
@keyframes sway {
  0% { --bgx: 38%; --bgy: 42%; --mx: 30%; --my: 25%; --hyp: .35; --rx: 3deg; --ry: -4deg; }
  50% { --bgx: 52%; --bgy: 50%; --mx: 55%; --my: 40%; --hyp: .15; --rx: 0deg; --ry: 1deg; }
  100% { --bgx: 64%; --bgy: 58%; --mx: 75%; --my: 55%; --hyp: .4; --rx: -3deg; --ry: 5deg; }
}
.cf.big:not(.has-photo):not(.active) .holo { animation: drift 6s ease-in-out infinite alternate; }
@keyframes drift { from { background-position: 20% 30%; } to { background-position: 80% 70%; } }
@media (prefers-reduced-motion: reduce) {
  .cf, .cf.active { transition: none; transform: none; }
  .cf.big .holo, .cf.big { animation: none !important; }
}

/* ---------------------------------------------------------------- fenêtres */
/* Fenêtre ouverte : la page derrière ne défile plus (ni sa barre de défilement par-dessus le fond) */
html:has(dialog[open]) { overflow: hidden; }
dialog.sheet {
  width: min(880px, 100% - 24px); max-height: min(90vh, 960px); max-height: min(92dvh, 960px);
  padding: 0; border: 1px solid var(--pg-line); border-radius: var(--pg-radius-lg);
  background: var(--pg-surface); color: var(--pg-text); box-shadow: 0 30px 80px -20px rgba(0, 0, 0, .5);
  overscroll-behavior: contain;
}
dialog.sheet::backdrop { background: rgba(5, 10, 12, .55); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); }
/* Ouverture et fermeture : fondu sur grand écran, glissement depuis le bas sur mobile (voir plus bas).
   La fermeture passe par closeDialog() (js/app.js), qui pose .closing puis ferme à la fin de l'animation. */
dialog.sheet[open] { animation: sheet-in .24s cubic-bezier(.2, .8, .3, 1); }
dialog.sheet[open]::backdrop { animation: fade-in .24s ease; }
dialog.sheet.closing { animation: sheet-out .18s ease-in forwards; }
dialog.sheet.closing::backdrop { animation: fade-out .18s ease-in forwards; }
@keyframes sheet-in { from { opacity: 0; transform: scale(.97); } }
@keyframes sheet-out { to { opacity: 0; transform: scale(.97); } }
@keyframes fade-in { from { opacity: 0; } }
@keyframes fade-out { to { opacity: 0; } }
#dlg-save, #dlg-edit { width: min(560px, 100% - 24px); }
.small-sheet { width: min(480px, 100% - 24px) !important; }
.sheet-in { position: relative; padding: 22px; }
.sheet h2 { margin: 0 0 10px; font-size: 24px; letter-spacing: -0.02em; line-height: 1.15; padding-right: 40px; }
.sheet h3 { margin: 18px 0 8px; font: 500 11.5px var(--pg-mono); color: var(--pg-muted); text-transform: uppercase; letter-spacing: .04em; }
.sheet p { margin: 0 0 12px; }
.x {
  position: absolute; top: 12px; right: 12px; z-index: 2; width: 40px; height: 40px; border-radius: 50%;
  border: 0; background: var(--pg-surface-2); display: grid; place-items: center;
}

@media (max-width: 640px) {
  dialog.sheet, #dlg-save, #dlg-edit, .small-sheet {
    width: 100% !important; max-width: 100%; margin: auto 0 0; max-height: 92vh; max-height: 94dvh;
    border-radius: var(--pg-radius-lg) var(--pg-radius-lg) 0 0; border-bottom: 0;
    /* Marge sous le contenu : la barre du navigateur ou du téléphone ne cache pas le bas de la fiche */
    padding-bottom: max(18px, env(safe-area-inset-bottom));
  }
  @keyframes sheet-in { from { transform: translateY(100%); } }
  @keyframes sheet-out { to { transform: translateY(100%); } }
}
@media (prefers-reduced-motion: reduce) {
  dialog.sheet[open], dialog.sheet.closing, dialog.sheet[open]::backdrop, dialog.sheet.closing::backdrop { animation-duration: 1ms; }
}

/* Carte en grand : ouverte directement depuis le classeur, aussi grande que l'écran le permet. À gauche, les raretés
   et la coche « je l'ai » ; flèches sur les côtés (souris) pour la carte suivante ou précédente. */
dialog.zoom {
  width: 100%; height: 100%; max-width: none; max-height: none; margin: 0; padding: 0; border: 0;
  background: none; overflow: hidden; overscroll-behavior: contain; --side: 84px; --edge: 24px;
  /* La carte se place entre la barre du haut (Retourner, nom, fermer) et le bas de l'écran, jamais dessous */
  box-sizing: border-box; padding: calc(64px + env(safe-area-inset-top)) 0 calc(16px + env(safe-area-inset-bottom));
  --free: calc(100dvh - 80px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
}
dialog.zoom[open] { display: grid; place-items: center; animation: zoom-in .26s cubic-bezier(.2, .8, .3, 1); }
dialog.zoom::backdrop { background: rgba(5, 10, 12, .86); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }
dialog.zoom[open]::backdrop { animation: fade-in .26s ease; }
dialog.zoom.closing { animation: zoom-out .18s ease-in forwards; }
dialog.zoom.closing::backdrop { animation: fade-out .18s ease-in forwards; }
@keyframes zoom-in { from { opacity: 0; transform: scale(.9); } }
@keyframes zoom-out { to { opacity: 0; transform: scale(.94); } }
@media (hover: hover) and (pointer: fine) { dialog.zoom { --side: 200px; --edge: 144px; } } /* (place des flèches) */
.z-main { display: flex; align-items: center; gap: 12px; margin-left: calc(-1 * (52px + 12px)); }
.zoom-card {
  display: grid; width: min(calc(100vw - var(--side)), calc((var(--free) - 12px) * 63 / 88));
  perspective: 1400px; overflow: clip; overflow-clip-margin: 40px;
}
/* Mobile : les raretés et la coche sur une ligne, sous la carte */
@media (max-width: 640px) {
  .z-main { flex-direction: column; gap: 14px; margin-left: 0; }
  .z-main > .z-side { order: 1; }
  /* La carte qui glisse (changement de rareté ou de carte) reste dans son cadre : elle ne passe pas sur les boutons */
  .zoom-card { overflow-clip-margin: 6px; }
  .zoom-card { width: min(calc(100vw - var(--edge)), calc((var(--free) - 14px - 44px - 12px) * 63 / 88)); }
  dialog.zoom .z-side, dialog.zoom .z-grades { flex-direction: row; width: auto; }
  dialog.zoom .z-own { margin: 0 0 0 6px; }
}

/* Changement de carte : les deux cartes se superposent le temps du fondu ou du glissement. --dir : 1, la nouvelle
   arrive par la droite (carte suivante) ou, avec .vert, par le bas (rareté suivante) ; -1 de l'autre côté. */
.zoom-card > * { grid-area: 1 / 1; }
.zoom-card > .cf { transition-property: --rx, --ry, --mx, --my, --bgx, --bgy, --hyp, box-shadow, filter, opacity, translate, scale; cursor: zoom-out; touch-action: none; }
.zoom-card > .cf:is(.enter, .leave) { opacity: 0; scale: .96; pointer-events: none; }
.zoom-card > .cf.enter { translate: calc(var(--dir, 0) * 28%) 0; transition-duration: 0s; }
.zoom-card > .cf.leave { translate: calc(var(--dir, 0) * 28%) 0; z-index: -1; transition-duration: .4s; transition-timing-function: ease-in; }
.zoom-card > .cf.vert:is(.enter, .leave) { translate: 0 calc(var(--dir, 0) * 20%); }
.zoom-card > .cf:not(.enter, .leave) { transition-duration: .7s, .7s, .7s, .7s, .7s, .7s, .7s, .3s, .3s, .42s, .42s, .42s; transition-timing-function: cubic-bezier(.2, .8, .3, 1); }
.zoom-card > .cf.active:not(.enter, .leave) { transition-duration: .12s, .12s, .12s, .12s, .12s, .12s, .12s, .3s, .3s, .42s, .42s, .42s; }
/* Image encore en route : une carte vide aux couleurs du projet, parcourue d'un reflet */
.zoom-card::before {
  content: ""; grid-area: 1 / 1; align-self: start; aspect-ratio: 63 / 88; border-radius: 4.5% / 3.2%;
  background:
    linear-gradient(105deg, transparent 35%, color-mix(in srgb, var(--pg-accent-2) 40%, transparent) 48%, color-mix(in srgb, var(--pg-accent) 45%, transparent) 54%, transparent 66%) 0 0 / 260% 100%,
    linear-gradient(160deg, color-mix(in srgb, var(--pg-accent) 22%, var(--pg-surface-2)), var(--pg-surface-2) 60%, color-mix(in srgb, var(--pg-accent-2) 18%, var(--pg-surface-2)));
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .12);
  opacity: 0; transition: opacity .25s; pointer-events: none;
}
.zoom-card.loading::before { opacity: 1; animation: wait 1.3s linear infinite; }
.zoom-card > .cf.leave ~ .cf.enter { z-index: 1; }
@keyframes wait { from { background-position: 100% 0, 0 0; } to { background-position: -60% 0, 0 0; } }
@media (prefers-reduced-motion: reduce) {
  .zoom-card > .cf { transition-duration: 0s !important; }
  .zoom-card.loading::before { animation: none; }
}

/* Raretés, l'une sous l'autre, et la coche « je l'ai » de celle qu'on regarde */
.z-side { position: relative; z-index: 2; display: flex; flex-direction: column; gap: 8px; width: 52px; flex: none; }
.z-grades { display: flex; flex-direction: column; gap: 8px; }
.zg, .z-own {
  position: relative; display: grid; place-items: center; width: 52px; min-height: 44px; padding: 0; border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, .22); background: rgba(255, 255, 255, .08); color: rgba(255, 255, 255, .75);
  font: 600 13px var(--pg-mono); transition: background .2s, color .2s, border-color .2s;
}
.zg[aria-pressed="true"] { background: var(--pg-grad); border-color: transparent; color: #fff; }
.zg i, .z-own i { display: grid; place-items: center; border-radius: 50%; }
.zg i { position: absolute; top: -5px; right: -5px; width: 17px; height: 17px; background: var(--pg-accent); opacity: 0; transition: opacity .2s; }
.zg.has i { opacity: 1; }
.zg svg, .z-own svg { width: 11px; height: 11px; fill: none; stroke: #fff; stroke-width: 3.4; stroke-linecap: round; stroke-linejoin: round; }
.z-own { margin-top: 10px; gap: 3px; padding: 7px 0 6px; font: 600 10.5px var(--pg-font); }
.z-own i { width: 20px; height: 20px; border: 2px solid rgba(255, 255, 255, .5); transition: background .2s, border-color .2s; }
.z-own svg { opacity: 0; }
.z-own[aria-checked="true"] { border-color: color-mix(in srgb, var(--pg-accent) 60%, transparent); color: #fff; }
.z-own[aria-checked="true"] i { background: var(--pg-accent); border-color: var(--pg-accent); }
.z-own[aria-checked="true"] svg { opacity: 1; }
@media (hover: hover) { .zg:hover, .z-own:hover { border-color: rgba(255, 255, 255, .5); } }

/* En haut : retourner la carte, son nom, fermer. Sur les côtés : carte précédente et suivante. */
dialog.zoom .x { position: fixed; top: max(12px, env(safe-area-inset-top)); right: 12px; background: rgba(255, 255, 255, .14); color: #fff; }
.z-title {
  position: fixed; top: max(12px, env(safe-area-inset-top)); left: 50%; translate: -50% 0; max-width: calc(100% - 280px);
  height: 40px; margin: 0; display: flex; align-items: center; gap: 8px; white-space: nowrap; overflow: hidden;
  color: #fff; font-weight: 600; font-size: 15px; pointer-events: none; z-index: 2;
}
.z-title > * { overflow: hidden; text-overflow: ellipsis; }
.z-num { flex: none; font: 500 12px var(--pg-mono); color: rgba(255, 255, 255, .6); }
.z-nav {
  position: fixed; top: 50%; translate: 0 -50%; width: 48px; height: 48px; display: grid; place-items: center;
  border: 0; border-radius: 50%; background: rgba(255, 255, 255, .12); color: #fff; transition: background .2s, opacity .2s;
}
.z-nav.prev { left: 16px; }
.z-nav.next { right: 16px; }
.z-nav:hover { background: rgba(255, 255, 255, .24); }
.z-nav:disabled { opacity: .25; pointer-events: none; }
@media (hover: none), (pointer: coarse) { .z-nav { display: none; } }
@media (max-width: 480px) {
  dialog.zoom .z-flip { padding: 0 10px; }
  dialog.zoom .z-flip span { display: none; }
  .z-title { max-width: calc(100% - 140px); }
}
/* Retourner la carte : la face tourne jusqu'à la tranche, puis l'autre face arrive de l'autre côté. Le dos (js/dos.js,
   tools/dos.py) : sans effet ni calque pour le moment. */
.z-flip {
  position: fixed; z-index: 2; top: max(12px, env(safe-area-inset-top)); left: 12px; height: 40px; padding: 0 14px 0 11px;
  display: flex; align-items: center; gap: 7px; border: 0; border-radius: 99px;
  background: rgba(255, 255, 255, .14); color: #fff; font: 600 13px var(--pg-font);
}
.z-flip[aria-pressed="true"] { background: var(--pg-grad); }
/* Retourner : l'ancienne face tourne jusqu'à être de profil puis disparaît ; la nouvelle (cachée tant que ses images
   arrivent) apparaît de profil de l'autre côté et finit de tourner. Aucune face ne reste visible de profil. */
.zoom-card > .cf.flip.enter { opacity: 0; scale: 1; translate: 0 0; rotate: y -90deg; transition: none; }
.zoom-card > .cf.flip.leave { opacity: 0; scale: 1; translate: 0 0; rotate: y 90deg; transition: rotate .2s cubic-bezier(.5, 0, .9, .4), opacity 0s linear .2s; }
.zoom-card > .cf.flip:not(.enter, .leave) { opacity: 1; rotate: y 0deg; transition: rotate .24s cubic-bezier(.1, .6, .5, 1) .2s, opacity 0s linear .2s; }
.cf.dos { cursor: zoom-out; }
@media (prefers-reduced-motion: reduce) {
  dialog.zoom[open], dialog.zoom.closing, dialog.zoom[open]::backdrop, dialog.zoom.closing::backdrop { animation-duration: 1ms; }
}

/* Boutons des fenêtres */
.form-actions { display: flex; gap: 8px; margin-top: 20px; flex-wrap: wrap; }
.grow { flex: 1; }

/* Sauvegarde */
.save-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 16px 0 10px; }
.save-actions label { cursor: pointer; }
.danger-zone { margin-top: 18px; border-top: 1px solid var(--pg-line); padding-top: 12px; }
.danger-zone summary { cursor: pointer; color: var(--danger); font-weight: 600; padding: 6px 0; }
.danger-zone p { margin-top: 8px; }

/* Pied de page */
.foot { padding: 20px 0 calc(30px + env(safe-area-inset-bottom)); border-top: 1px solid var(--pg-line); text-align: center; }
.foot p { margin: 0 auto 12px; max-width: 640px; font-size: 13px; color: var(--pg-muted); }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); z-index: 100;
  transform: translate(-50%, 20px); opacity: 0; transition: transform .25s, opacity .25s;
  max-width: calc(100% - 32px); padding: 11px 18px; border-radius: 12px;
  background: var(--pg-text); color: var(--pg-bg); font-weight: 600; font-size: 14.5px; box-shadow: 0 10px 30px -10px rgba(0, 0, 0, .5);
}
.toast.show { transform: translate(-50%, 0); opacity: 1; }

/* Images des cartes */
.nudge {
  margin: 0 0 14px; padding: 12px 14px; border-radius: var(--pg-radius-sm);
  border: 1px dashed color-mix(in srgb, var(--pg-accent) 45%, var(--pg-line)); font-size: 14.5px; color: var(--pg-muted);
}
.nudge .link { padding: 0; }
.import-progress { margin: 6px 0 12px; }
.import-progress .bar { margin: 0 0 6px; }
.import-progress .btn { min-height: 36px; font-size: 14px; }
.sheet code { font: 500 13px var(--pg-mono); padding: 1px 5px; border-radius: 6px; background: var(--pg-surface-2); }
.more { height: 1px; }
