/* ---------- Thème ---------- */
:root {
  --bg: #0e0b1a; --bg2: #171230; --line: #2c2450; --text: #f3f0ff; --muted: #9a92c0;
  --violet: #8b5cf6; --violet2: #c4b5fd;
  --commune: #9ca3af; --rare: #38bdf8; --epique: #a855f7; --legendaire: #f59e0b; --mythique: #f43f5e;
}
* { box-sizing: border-box; margin: 0; }
body { font-family: 'Space Grotesk', system-ui, sans-serif; background: radial-gradient(circle at 50% -20%, #2a1d5c, var(--bg) 60%) fixed; color: var(--text); min-height: 100vh; }
button, input, select { font: inherit; color: inherit; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.center { text-align: center; }
.error { color: #f87171; min-height: 1.2em; font-size: .9rem; }

/* ---------- Boutons ---------- */
.btn { border: 1px solid var(--line); background: var(--bg2); padding: .55rem 1rem; border-radius: 10px; cursor: pointer; transition: .15s; }
.btn:hover { border-color: var(--violet); }
.btn.primary { background: var(--violet); border-color: var(--violet); font-weight: 700; }
.btn.ghost { background: transparent; }
.btn:disabled { opacity: .4; cursor: not-allowed; }

/* ---------- Auth ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 1rem; }
.auth-box { width: min(380px, 100%); background: var(--bg2); border: 1px solid var(--line); border-radius: 18px; padding: 2rem; display: grid; gap: 1rem; text-align: center; }
.auth-box form { display: grid; gap: .7rem; }
.auth-box input { background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: .7rem .9rem; }
.tabs-mini { display: flex; gap: .3rem; background: var(--bg); padding: .25rem; border-radius: 10px; }
.tabs-mini button { flex: 1; border: 0; background: transparent; padding: .5rem; border-radius: 8px; cursor: pointer; }
.tabs-mini .active { background: var(--violet); }
.logo { font-size: 2.2rem; letter-spacing: -.03em; }
.logo span { color: var(--violet2); }
.logo.small { font-size: 1.3rem; }

/* ---------- Barre du haut ---------- */
.topbar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 1rem; padding: .8rem 1.5rem; background: #0e0b1acc; backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.tabs { display: flex; gap: .3rem; flex: 1; }
.tabs button { border: 0; background: transparent; padding: .5rem .9rem; border-radius: 8px; cursor: pointer; color: var(--muted); }
.tabs .active { color: var(--text); background: var(--bg2); }
.wallet { display: flex; align-items: center; gap: .6rem; }
.coins { background: var(--bg2); border: 1px solid var(--line); padding: .45rem .8rem; border-radius: 10px; }
main { max-width: 1200px; margin: 0 auto; padding: 1.5rem; }
.section-title { margin: 2.5rem 0 1rem; color: var(--muted); font-weight: 500; }

/* ---------- Booster ---------- */
.shop { display: grid; justify-items: center; gap: 1rem; padding: 1rem 0; }
.booster-pack { position: relative; overflow: hidden; width: 200px; height: 290px; border-radius: 16px; cursor: pointer; display: grid; place-content: center; text-align: center; gap: .4rem;
  background: linear-gradient(160deg, #6d28d9, #1e1145 70%); border: 2px solid var(--violet2); box-shadow: 0 20px 60px #8b5cf655; transition: transform .2s; }
.booster-pack:hover { transform: translateY(-6px) rotate(-2deg); }
.booster-pack.shake { animation: shake .5s; }
.pack-title { font-size: 1.8rem; font-weight: 700; }
.pack-sub { font-size: .8rem; color: var(--violet2); }
.pack-price { margin-top: 1rem; font-weight: 700; background: #0006; padding: .3rem .8rem; border-radius: 99px; justify-self: center; }
.pack-shine { position: absolute; inset: 0; background: linear-gradient(115deg, transparent 40%, #fff4 50%, transparent 60%); animation: shine 3s infinite; }
@keyframes shine { from { transform: translateX(-100%); } to { transform: translateX(100%); } }
@keyframes shake { 25% { transform: rotate(-6deg); } 50% { transform: rotate(6deg); } 75% { transform: rotate(-3deg); } }

.reveal { display: flex; justify-content: center; gap: 1rem; flex-wrap: wrap; margin-top: 1rem; perspective: 1200px; }
.flip { width: 190px; aspect-ratio: 5 / 7; cursor: pointer; animation: deal .4s backwards; }
.flip-inner { position: relative; width: 100%; height: 100%; transition: transform .6s; transform-style: preserve-3d; }
.flip.open .flip-inner { transform: rotateY(180deg); }
.flip-back, .flip-front { position: absolute; inset: 0; backface-visibility: hidden; }
.flip-front { transform: rotateY(180deg); }
.flip-back { border-radius: 12px; background: repeating-linear-gradient(45deg, #2a1d5c 0 10px, #1e1145 10px 20px); border: 2px solid var(--violet2); display: grid; place-items: center; font-size: 2rem; }
@keyframes deal { from { opacity: 0; transform: translateY(40px) scale(.8); } }

/* ---------- Carte ---------- */
.card { --rc: var(--commune); position: relative; width: 100%; aspect-ratio: 5 / 7; border-radius: 12px; overflow: hidden; background: linear-gradient(170deg, #241b47, #120d26);
  border: 3px solid var(--rc); display: flex; flex-direction: column; transition: transform .15s; transform: perspective(700px) rotateX(var(--rx, 0)) rotateY(var(--ry, 0)); cursor: pointer; }
.card.rare { --rc: var(--rare); }
.card.epique { --rc: var(--epique); box-shadow: 0 0 18px #a855f766; }
.card.legendaire { --rc: var(--legendaire); box-shadow: 0 0 26px #f59e0b88; }
.card.mythique { --rc: var(--mythique); border-color: transparent; box-shadow: 0 0 30px #f43f5e88;
  background: linear-gradient(170deg, #3b0d24, #120d26) padding-box, conic-gradient(from var(--a, 0deg), #f43f5e, #f59e0b, #a855f7, #38bdf8, #f43f5e) border-box;
  animation: spin-border 4s linear infinite; }
.card.mythique .card-type { background: linear-gradient(90deg, #f43f5e, #f59e0b); }
@property --a { syntax: '<angle>'; inherits: false; initial-value: 0deg; }
@keyframes spin-border { to { --a: 360deg; } }
.feed .r-mythique { color: var(--mythique); font-weight: 700; }
.card-top { display: flex; justify-content: space-between; align-items: center; padding: .35rem .5rem; font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.card-type { background: var(--rc); color: #0e0b1a; padding: .1rem .45rem; border-radius: 99px; }
.card-photo { margin: 0 .5rem; border-radius: 8px; flex: 1; min-height: 0; background: #0b0816 center 25% / cover no-repeat; border: 1px solid #ffffff22; }
.card-photo.none { display: grid; place-items: center; font-size: 3rem; color: var(--muted); }
.card-body { padding: .45rem .55rem .5rem; }
.card-name { font-weight: 700; font-size: .92rem; line-height: 1.1; }
.card-meta span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-right: .3rem; }
.card-meta { display: flex; justify-content: space-between; font-size: .66rem; color: var(--muted); margin-top: .25rem; }
.card-rarity { color: var(--rc); font-weight: 700; }
.badge-qty { position: absolute; top: 2rem; right: .6rem; background: #000a; border-radius: 99px; padding: .05rem .45rem; font-size: .7rem; font-weight: 700; }
.badge-role { position: absolute; top: 2rem; left: .6rem; font-size: .9rem; filter: drop-shadow(0 1px 2px #000); }

/* Holo : reflet arc-en-ciel qui suit la souris (--mx/--my mis à jour en JS) */
.card.holo::after { content: ''; position: absolute; inset: 0; pointer-events: none; mix-blend-mode: color-dodge; opacity: .55;
  background:
    radial-gradient(circle at var(--mx, 50%) var(--my, 50%), #fff8, transparent 45%),
    linear-gradient(115deg, #ff008855 10%, #ffd70055 30%, #00ffcc55 50%, #00aaff55 70%, #cc00ff55 90%);
  background-size: 100% 100%, 250% 250%; background-position: center, var(--mx, 50%) var(--my, 50%); }
.card.holo .card-top::after { content: ' ✦ HOLO'; color: #fff; }

/* Carte non possédée */
.card.locked { filter: grayscale(1) brightness(.45); cursor: default; }
.card.locked .card-photo { filter: blur(10px); }

/* ---------- Collection ---------- */
.filters { display: flex; gap: .8rem; flex-wrap: wrap; align-items: center; margin-bottom: 1rem; }
.filters select { background: var(--bg2); border: 1px solid var(--line); border-radius: 10px; padding: .5rem .7rem; }
.check { display: flex; gap: .4rem; align-items: center; color: var(--muted); }
.sets { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: .5rem; margin-bottom: 1.5rem; }
.set { background: var(--bg2); border: 1px solid var(--line); border-radius: 10px; padding: .5rem .7rem; font-size: .8rem; cursor: pointer; }
.set.done { border-color: var(--legendaire); }
.bar { height: 5px; background: var(--bg); border-radius: 99px; margin-top: .35rem; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--violet); }
.set.done .bar > i { background: var(--legendaire); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 1rem; }

/* ---------- Fil & classement ---------- */
.feed { list-style: none; padding: 0; display: grid; gap: .4rem; }
.feed li { background: var(--bg2); border: 1px solid var(--line); border-radius: 10px; padding: .5rem .8rem; font-size: .9rem; }
.feed .r-rare { color: var(--rare); } .feed .r-epique { color: var(--epique); } .feed .r-legendaire { color: var(--legendaire); }
.ranking { width: 100%; border-collapse: collapse; }
.ranking th, .ranking td { padding: .7rem; text-align: left; border-bottom: 1px solid var(--line); }
.ranking th { color: var(--muted); font-weight: 500; }

/* ---------- Modale & toast ---------- */
.modal { position: fixed; inset: 0; background: #000c; display: grid; place-items: center; z-index: 50; padding: 1rem; }
.modal-body { width: min(320px, 90vw); display: grid; gap: 1rem; }
.toast { position: fixed; bottom: 1.5rem; left: 50%; transform: translate(-50%, 150%); background: var(--bg2); border: 1px solid var(--violet); padding: .7rem 1.2rem; border-radius: 12px; transition: .3s; z-index: 60; }
.toast.show { transform: translate(-50%, 0); }

@media (max-width: 640px) {
  .flip { width: 44vw; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
  .topbar { padding: .6rem 1rem; }
}
