:root {
  --bg: #0d0d14; --panel: #171722; --line: #2a2a3a; --text: #f1f0f7; --muted: #9795ab;
  --accent: #7c5cff; --gold: #ffc83d;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 system-ui, sans-serif; }
h1, h2, h3 { line-height: 1.2; }
.muted { color: var(--muted); }

header { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 24px; padding: 12px 24px; background: #0d0d14ee; border-bottom: 1px solid var(--line); }
.logo { color: var(--text); font-weight: 900; font-size: 20px; text-decoration: none; }
.seal { display: inline-grid; place-items: center; width: 1.45em; height: 1.45em; margin-right: 4px; vertical-align: middle; border-radius: .3em; background: #ff4d38; color: #17120f; font-weight: 900; letter-spacing: 0; text-shadow: none; box-shadow: inset 0 0 0 2px #17120f55; }
nav { display: flex; gap: 4px; flex: 1; }
nav a { display: flex; gap: 6px; padding: 8px 12px; border-radius: 99px; color: var(--muted); text-decoration: none; }
nav a.on { background: var(--panel); color: var(--text); }
.wallet { display: flex; align-items: center; gap: 12px; font-weight: 700; white-space: nowrap; }
main { max-width: 1100px; margin: auto; padding: 24px 16px 100px; }

button { font: inherit; cursor: pointer; }
button:disabled { opacity: .4; cursor: not-allowed; }
.btn { padding: 9px 16px; border: 0; border-radius: 99px; background: var(--accent); color: #fff; font-weight: 700; }
.btn.alt { background: var(--line); }
.btn.big { padding: 13px 24px; font-size: 16px; }
.ghost, .link { background: none; border: 0; color: var(--muted); }
.link { text-decoration: underline; }
input, select { font: inherit; padding: 9px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel); color: var(--text); min-width: 0; }
.row { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.row.center { justify-content: center; }

.auth { max-width: 360px; margin: 8vh auto; display: flex; flex-direction: column; gap: 12px; text-align: center; }

.hero { padding: 32px; border-radius: 22px; border: 1px solid #5a4a1c; background: radial-gradient(circle at 85% 30%, #6b4d0c, transparent 55%), var(--panel); }
.hero small { color: var(--gold); font-weight: 800; letter-spacing: .1em; }
.hero h1 { font-size: 38px; margin: 6px 0; }
.hero .btn { background: var(--gold); color: #17120a; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin: 12px 0 32px; }
.stat { display: flex; flex-direction: column; align-items: center; padding: 12px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; }
.stat b { font-size: 22px; }
.stat small { color: var(--muted); }

.packs { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 14px; margin-bottom: 32px; }
.pack { display: flex; flex-direction: column; gap: 8px; text-align: center; padding: 14px; background: var(--panel); border: 1px solid var(--line); border-radius: 16px; }
.pack h3 { margin: 0; }
.pack-art { width: 100%; aspect-ratio: 2 / 3; object-fit: contain; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; margin: 12px 0 28px; }
.r-C { --rc: #8b8b99; } .r-U { --rc: #3ecf8e; } .r-R { --rc: #4a9dff; }
.r-E { --rc: #b36bff; } .r-L { --rc: #ffc83d; } .r-M { --rc: #ff4d6d; }
.card { position: relative; display: block; width: 100%; aspect-ratio: 5 / 7; padding: 0; overflow: hidden; border: 3px solid var(--rc); border-radius: 14px; color: #fff; background: linear-gradient(160deg, hsl(var(--h) 55% 38%), hsl(calc(var(--h) + 50) 60% 12%)); transition: transform .15s; }
.card:hover { transform: translateY(-3px); }
/* L'image est toujours entière, dans l'espace libre entre le nom et le jeu. */
.card img { position: absolute; left: 3%; top: 14%; width: 94%; height: 76%; object-fit: contain; }
/* Images cadrées : perso détouré entre les titres, illustration sur toute la carte. */
.card .pic { position: absolute; left: 3%; top: 14%; width: 94%; height: 76%; }
.card .pic.fill { left: 0; top: 0; width: 100%; height: 100%; }
/* La pièce Geemu, à la taille du texte qui l'entoure */
img.piece { display: inline-block; width: 1.3em; height: 1.3em; margin: 0 .12em; vertical-align: -.3em; }
.art { position: absolute; inset: 0; display: grid; place-items: center; font-size: 52px; font-weight: 900; color: #ffffffd0; text-shadow: 0 4px 18px #0009; }
.c-name { position: absolute; top: 0; left: 0; right: 0; padding: 8px 34px 18px 8px; text-align: left; font-weight: 800; font-size: 13px; line-height: 1.2; background: linear-gradient(#000c, transparent); }
.c-rar { position: absolute; top: 6px; right: 6px; width: 24px; height: 24px; display: grid; place-items: center; border-radius: 50%; background: var(--rc); color: #111; font-weight: 900; font-size: 12px; }
.c-foot { position: absolute; bottom: 0; left: 0; right: 0; display: flex; justify-content: space-between; align-items: end; gap: 6px; padding: 20px 8px 7px; font-size: 11px; text-align: left; background: linear-gradient(transparent, #000d); }
.c-foot em { font-style: normal; }
.c-count, .c-new { position: absolute; right: 6px; top: 36px; padding: 1px 7px; border-radius: 99px; background: #000c; font-size: 11px; font-weight: 800; }
.c-new { top: auto; bottom: 38px; right: auto; left: 8px; background: var(--gold); color: #111; }
.card.r-E, .card.r-L { box-shadow: 0 0 14px -3px var(--rc); }
.card.r-M { box-shadow: 0 0 22px var(--rc); }
.card.r-M::after, .card.r-L::after { content: ''; position: absolute; inset: 0; pointer-events: none; background: linear-gradient(115deg, transparent 35%, #ffffff40 50%, transparent 65%) 0 0 / 300% 100%; }
/* Le reflet ne bouge que sur la carte survolée ou affichée en grand : des centaines d'animations feraient ramer. */
.card.r-M:hover::after, .card.r-L:hover::after, #overlay .card.r-M::after, #overlay .card.r-L::after { animation: holo 3.5s linear infinite; }
@keyframes holo { from { background-position: 150% 0; } to { background-position: -50% 0; } }
.card.locked { filter: grayscale(1) brightness(.45); }

.ad { display: flex; flex-direction: column; gap: 6px; text-align: center; }
.feed { display: grid; grid-auto-flow: column; grid-auto-columns: 140px; gap: 12px; overflow-x: auto; padding: 8px 4px; }
.feed figure { margin: 0; text-align: center; }
progress { width: 100%; accent-color: var(--accent); }
table { width: 100%; border-collapse: collapse; background: var(--panel); border-radius: 14px; overflow: hidden; }
th, td { padding: 11px 8px; text-align: left; border-bottom: 1px solid var(--line); }
tr.self { background: #7c5cff2b; }

#overlay { position: fixed; inset: 0; z-index: 10; display: grid; place-items: center; padding: 16px; background: #000c; overflow-y: auto; }
.modal { position: relative; width: min(900px, 100%); max-height: calc(100vh - 32px); overflow-y: auto; padding: 24px; text-align: center; background: var(--panel); border: 1px solid var(--line); border-radius: 20px; }
.close { position: absolute; top: 10px; right: 12px; font-size: 18px; }
.detail { display: grid; grid-template-columns: 220px 1fr; gap: 24px; text-align: left; align-items: center; }
.reveal { align-self: stretch; display: flex;flex-wrap: wrap; justify-content: center; gap: 12px; margin: 20px 0; }
.slot { width: 150px; }
.back { width: 100%; aspect-ratio: 5 / 7; padding: 0; border-radius: 14px; border: 3px solid var(--line); background: url('/art/dos.jpg') center / cover; }
.back.emerald { background-image: url('/art/dos-emeraude.jpg'); border-color: #2ee88a; }
.back:hover { border-color: var(--accent); }
/* Révélation carte par carte */
.single { width: min(250px, 66vw); margin: 6px 0; border-radius: 14px; }
.single .c-name { font-size: 17px; }

.flipped { animation: flip .35s ease-out; }
.flipped.r-L, .flipped.r-M { animation: flip .35s ease-out, pop .6s .35s; }
@keyframes flip { from { transform: rotateY(90deg); } }
@keyframes pop { 50% { transform: scale(1.12); } }
.emerald:is(h2) { color: #2ee88a; }

#toast { position: fixed; left: 50%; bottom: 90px; z-index: 20; transform: translateX(-50%); padding: 10px 18px; border-radius: 99px; background: #fff; color: #111; font-weight: 700; opacity: 0; pointer-events: none; transition: opacity .2s; }
#toast.show { opacity: 1; }

.logo { white-space: nowrap; }

@media (max-width: 900px) {
  header { gap: 8px; padding: 10px 14px; justify-content: space-between; }
  nav { position: fixed; bottom: 0; left: 0; right: 0; justify-content: space-around; padding: 8px; background: #12121b; border-top: 1px solid var(--line); }
  nav a { flex-direction: column; align-items: center; gap: 0; padding: 4px 8px; }
  nav b { font-size: 11px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; }
  .slot { width: 30%; }
  .detail { grid-template-columns: 1fr; text-align: center; }
  .detail > .card { max-width: 200px; margin: auto; }
  .detail .row { justify-content: center; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
