:root {
  --ink: #16130f;
  --paper: #fff8ec;
  --muted: #6b6257;
  --yellow: #ffd84d;
  --pink: #ff9dbb;
  --blue: #9fd3ff;
  --green: #a6eba9;
  --purple: #cdb0ff;
  --red: #ff7a6b;
  --r0: #eeeeee;
  --r1: #e2f1ff;
  --r2: #d7f8d2;
  --r3: #ecdcff;
  --r4: #ffe991;
  --radius: 16px;
  --shadow: 4px 4px 0 var(--ink);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  background-image: radial-gradient(#eadbc2 1.3px, transparent 1.3px);
  background-size: 22px 22px;
  color: var(--ink);
  font-family: 'DM Sans', system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  min-height: 100vh;
}
h1, h2, h3, .logo, .display { font-family: 'Bagel Fat One', system-ui, sans-serif; font-weight: 400; letter-spacing: .3px; margin: 0; }
h1 { font-size: clamp(32px, 5vw, 52px); line-height: 1.05; }
h2 { font-size: 28px; }
h3 { font-size: 20px; }
a { color: inherit; }
p { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.center { text-align: center; }

/* ---------- Layout ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: #fff; border-bottom: 3px solid var(--ink);
}
.topbar-in {
  max-width: 1240px; margin: 0 auto; padding: 10px 20px;
  display: flex; align-items: center; gap: 18px; flex-wrap: wrap;
}
.logo { font-size: 28px; display: flex; align-items: center; gap: 10px; text-decoration: none; }
.logo-card {
  width: 30px; height: 40px; border: 3px solid var(--ink); border-radius: 7px; background: var(--yellow);
  position: relative; transform: rotate(-8deg); transition: transform .3s;
}
.logo-card::after {
  content: ''; position: absolute; top: -9px; right: -9px; width: 20px; height: 20px;
  border-radius: 50%; background: #fff; border-left: 3px solid var(--ink); border-bottom: 3px solid var(--ink);
}
.logo:hover .logo-card { transform: rotate(10deg) scale(1.08); }
nav.main { display: flex; gap: 6px; flex-wrap: wrap; flex: 1; }
nav.main a {
  text-decoration: none; font-weight: 800; font-size: 15px; padding: 7px 12px; border-radius: 999px;
  border: 2.5px solid transparent; position: relative; white-space: nowrap;
}
nav.main a:hover { border-color: var(--ink); transform: rotate(-2deg); }
nav.main a.active { background: var(--ink); color: #fff; }
.badge {
  display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 5px;
  border-radius: 999px; background: var(--pink); color: var(--ink); border: 2px solid var(--ink);
  font-size: 11px; font-weight: 800; margin-left: 4px; vertical-align: 1px;
}
.me { display: flex; align-items: center; gap: 10px; }
.coin-pill {
  display: inline-flex; align-items: center; gap: 7px; font-weight: 800;
  padding: 5px 12px 5px 6px; border: 2.5px solid var(--ink); border-radius: 999px; background: var(--yellow);
  box-shadow: 2px 2px 0 var(--ink);
}
.coin {
  width: 22px; height: 22px; border-radius: 50%; background: #ffbf2e; border: 2.5px solid var(--ink);
  display: inline-grid; place-items: center; font-size: 11px; font-weight: 800; flex: none;
}
main { max-width: 1240px; margin: 0 auto; padding: 32px 20px 80px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 26px; }
.page-head p { margin-top: 6px; }
.stack { display: flex; flex-direction: column; gap: 18px; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 22px; }
.section { margin-top: 40px; }
.section > h2 { margin-bottom: 16px; }

/* ---------- Composants ---------- */
.panel {
  background: #fff; border: 2.5px solid var(--ink); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 22px;
}
.panel.tilt-l { transform: rotate(-.6deg); }
.panel.tilt-r { transform: rotate(.6deg); }
.btn {
  font: inherit; font-weight: 800; font-size: 15px; color: var(--ink);
  border: 2.5px solid var(--ink); border-radius: 12px; background: var(--yellow);
  box-shadow: 3px 3px 0 var(--ink); padding: 10px 18px; cursor: pointer;
  transition: transform .12s, box-shadow .12s; display: inline-flex; align-items: center; gap: 8px;
  text-decoration: none; min-height: 44px;
}
.btn:hover { transform: translate(-1px, -1px) rotate(-1.5deg); box-shadow: 5px 5px 0 var(--ink); }
.btn:active { transform: translate(3px, 3px); box-shadow: 0 0 0 var(--ink); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; box-shadow: 3px 3px 0 var(--ink); }
.btn.pink { background: var(--pink); }
.btn.blue { background: var(--blue); }
.btn.green { background: var(--green); }
.btn.white { background: #fff; }
.btn.red { background: var(--red); }
.btn.sm { padding: 6px 12px; font-size: 14px; min-height: 36px; border-radius: 10px; box-shadow: 2px 2px 0 var(--ink); }
.btn.big { font-size: 20px; padding: 14px 28px; border-radius: 16px; }

label.field { display: flex; flex-direction: column; gap: 6px; font-weight: 800; font-size: 14px; }
label.field .hint { font-weight: 400; color: var(--muted); }
input, select, textarea {
  font: inherit; font-size: 16px; color: var(--ink); background: #fff;
  border: 2.5px solid var(--ink); border-radius: 12px; padding: 10px 12px; min-height: 44px; width: 100%;
}
textarea { min-height: 110px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; box-shadow: 3px 3px 0 var(--pink); }
input[type=checkbox] { width: 22px; height: 22px; min-height: 0; accent-color: var(--ink); }
.check { display: flex; gap: 10px; align-items: center; font-weight: 600; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; }

.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  font: inherit; font-weight: 800; font-size: 14px; padding: 6px 14px; border-radius: 999px;
  border: 2.5px solid var(--ink); background: #fff; cursor: pointer; min-height: 36px;
}
.chip.on { background: var(--ink); color: #fff; }
.chip.r1.on { background: var(--r1); color: var(--ink); }
.chip.r2.on { background: var(--r2); color: var(--ink); }
.chip.r3.on { background: var(--r3); color: var(--ink); }
.chip.r4.on { background: var(--r4); color: var(--ink); }

.tabs { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 24px; }

.stickers { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 18px; }
.sticker {
  border: 2.5px solid var(--ink); border-radius: 18px; padding: 18px; box-shadow: var(--shadow);
  background: #fff; text-decoration: none; display: block; transition: transform .15s;
}
.sticker:nth-child(1) { background: var(--yellow); transform: rotate(-1.2deg); }
.sticker:nth-child(2) { background: var(--blue); transform: rotate(.8deg); }
.sticker:nth-child(3) { background: var(--green); transform: rotate(-.5deg); }
.sticker:nth-child(4) { background: var(--pink); transform: rotate(1.1deg); }
.sticker:nth-child(5) { background: var(--purple); transform: rotate(-.9deg); }
.sticker:hover { transform: rotate(0) scale(1.03); }
.sticker .big { font-family: 'Bagel Fat One', system-ui; font-size: 44px; line-height: 1; }
.sticker .lbl { font-weight: 800; margin-top: 6px; }

.empty {
  border: 2.5px dashed var(--ink); border-radius: var(--radius); padding: 36px 20px; text-align: center;
  background: rgba(255, 255, 255, .6);
}
.empty .display { font-size: 24px; margin-bottom: 6px; }

table.simple { width: 100%; border-collapse: collapse; }
table.simple td, table.simple th { padding: 10px 8px; border-bottom: 2px dashed #d9ccb6; text-align: left; vertical-align: middle; }
table.simple th { font-size: 13px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); }
.plus { color: #18803a; font-weight: 800; }
.minus { color: #c0392b; font-weight: 800; }
.scroll-x { overflow-x: auto; }

/* ---------- Cartes ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(176px, 1fr)); gap: 26px 22px; }
.cards.mini { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 14px; }
.tcg {
  --tilt: 0deg;
  position: relative; aspect-ratio: 5 / 7; border: 3px solid var(--ink); border-radius: 16px;
  background: var(--r0); box-shadow: var(--shadow); padding: 10px; display: flex; flex-direction: column; gap: 7px;
  transform: rotate(var(--tilt)); transition: transform .18s, box-shadow .18s; overflow: hidden; cursor: default;
  font: inherit; color: inherit; text-align: left; width: 100%;
}
button.tcg { cursor: pointer; }
button.tcg:hover, .tcg.hoverable:hover { transform: rotate(0) translateY(-6px) scale(1.03); box-shadow: 7px 9px 0 var(--ink); z-index: 2; }
.tcg.r1 { background: var(--r1); }
.tcg.r2 { background: var(--r2); }
.tcg.r3 { background: var(--r3); }
.tcg.r4 { background: var(--r4); }
.tcg.r4::after {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(110deg, transparent 30%, rgba(255, 255, 255, .75) 45%, transparent 60%);
  background-size: 250% 100%; animation: shimmer 2.8s infinite linear;
}
.tcg.r3 { background-image: radial-gradient(rgba(255,255,255,.6) 1.5px, transparent 1.5px); background-size: 12px 12px; }
@keyframes shimmer { from { background-position: 150% 0; } to { background-position: -100% 0; } }
.tcg-top { display: flex; justify-content: space-between; align-items: center; gap: 6px; }
.rpill {
  font-size: 10.5px; font-weight: 800; text-transform: uppercase; letter-spacing: .6px;
  background: var(--ink); color: #fff; padding: 3px 8px; border-radius: 999px; white-space: nowrap;
}
.tcg-type { font-size: 11px; font-weight: 800; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tcg-art {
  flex: 1 1 auto; min-height: 0; border: 2.5px solid var(--ink); border-radius: 10px; overflow: hidden;
  background: repeating-linear-gradient(45deg, rgba(255,255,255,.7) 0 8px, rgba(255,255,255,.25) 8px 16px);
  display: grid; place-items: center;
}
.tcg-art img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tcg-letter { font-family: 'Bagel Fat One', system-ui; font-size: 58px; line-height: 1; transform: rotate(-6deg); }
.tcg-title { font-family: 'Bagel Fat One', system-ui; font-size: 16.5px; line-height: 1.1; overflow-wrap: anywhere; }
.tcg-desc { font-size: 12px; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.tcg-foot { font-size: 11px; font-weight: 600; color: #4a433b; margin-top: auto; }
.tcg-count {
  position: absolute; top: -2px; right: -2px; z-index: 3; background: var(--pink); border: 2.5px solid var(--ink);
  border-radius: 0 13px 0 12px; padding: 2px 9px; font-weight: 800; font-size: 14px;
}
.tcg-lock {
  position: absolute; bottom: 10px; right: -30px; transform: rotate(-35deg); background: var(--red);
  border: 2px solid var(--ink); font-size: 10px; font-weight: 800; padding: 2px 34px; text-transform: uppercase; z-index: 3;
}
.tcg.small { padding: 7px; gap: 5px; border-radius: 12px; box-shadow: 3px 3px 0 var(--ink); }
.tcg.small .tcg-title { font-size: 13px; }
.tcg.small .tcg-letter { font-size: 38px; }
.tcg.small .rpill { font-size: 9px; padding: 2px 6px; }
.tcg.small .tcg-type, .tcg.small .tcg-foot { display: none; }
.tcg.selected { outline: 4px solid var(--ink); outline-offset: 3px; transform: rotate(0) scale(.96); }
.tcg.selected::before {
  content: '✓'; position: absolute; top: 6px; left: 6px; z-index: 4; width: 26px; height: 26px; border-radius: 50%;
  background: var(--green); border: 2.5px solid var(--ink); display: grid; place-items: center; font-weight: 800;
}
.tcg.missing { opacity: .5; }
.card-wrap { display: flex; flex-direction: column; gap: 10px; }

/* ---------- Booster ---------- */
.booster-zone { display: grid; place-items: center; padding: 30px 0 10px; gap: 22px; }
.pack {
  width: 220px; height: 300px; border: 3px solid var(--ink); border-radius: 18px; cursor: pointer;
  background:
    repeating-linear-gradient(-45deg, var(--pink) 0 18px, #ffb3c9 18px 36px);
  box-shadow: 6px 6px 0 var(--ink); position: relative; display: grid; place-items: center;
  animation: wobble 2.4s ease-in-out infinite; font: inherit; color: var(--ink);
}
.pack::before, .pack::after {
  content: ''; position: absolute; left: -3px; right: -3px; height: 16px; background:
    linear-gradient(135deg, transparent 50%, var(--ink) 50% 62%, transparent 62%) 0 0 / 16px 16px repeat-x;
}
.pack::before { top: 12px; }
.pack::after { bottom: 12px; transform: scaleY(-1); }
.pack .pack-label {
  background: #fff; border: 3px solid var(--ink); border-radius: 12px; padding: 10px 16px; transform: rotate(-6deg);
  font-family: 'Bagel Fat One', system-ui; font-size: 26px; box-shadow: 3px 3px 0 var(--ink); text-align: center; line-height: 1.05;
}
.pack .pack-label small { display: block; font-family: 'DM Sans', system-ui; font-weight: 800; font-size: 12px; margin-top: 4px; }
.pack:hover { animation-duration: .5s; }
.pack:disabled { animation: none; filter: grayscale(1); opacity: .5; cursor: not-allowed; }
.pack.shaking { animation: shake .55s ease-in-out; }
@keyframes wobble { 0%, 100% { transform: rotate(-3deg); } 50% { transform: rotate(3deg) translateY(-6px); } }
@keyframes shake {
  0%, 100% { transform: translateX(0) rotate(0); }
  20% { transform: translateX(-10px) rotate(-6deg); } 40% { transform: translateX(10px) rotate(6deg); }
  60% { transform: translateX(-8px) rotate(-4deg); } 80% { transform: translateX(8px) rotate(4deg); }
}
.reveal { width: 230px; perspective: 1000px; }
.reveal .flip { position: relative; transform-style: preserve-3d; animation: flipin .8s cubic-bezier(.2, 1.4, .4, 1) forwards; }
@keyframes flipin { from { transform: rotateY(180deg) scale(.6); } to { transform: rotateY(0) scale(1); } }
.new-tag {
  position: absolute; top: -14px; left: -14px; z-index: 5; background: var(--green); border: 2.5px solid var(--ink);
  border-radius: 999px; padding: 4px 12px; font-weight: 800; transform: rotate(-12deg); font-size: 14px;
}
.confetti { position: fixed; top: -20px; width: 12px; height: 18px; z-index: 100; border: 2px solid var(--ink); pointer-events: none; animation: fall linear forwards; }
@keyframes fall { to { transform: translateY(110vh) rotate(720deg); } }

/* ---------- Joueurs ---------- */
.players { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 22px; }
.player { display: flex; flex-direction: column; gap: 14px; }
.avatar {
  width: 56px; height: 56px; border-radius: 50%; border: 3px solid var(--ink); display: grid; place-items: center;
  font-family: 'Bagel Fat One', system-ui; font-size: 26px; flex: none; box-shadow: 2px 2px 0 var(--ink);
}
.avatar.lg { width: 84px; height: 84px; font-size: 40px; }
.bar { height: 14px; border: 2.5px solid var(--ink); border-radius: 999px; background: #fff; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--green); border-right: 2.5px solid var(--ink); }
.crown { display: inline-flex; vertical-align: -3px; margin-left: 6px; }

/* ---------- Échanges / Marché ---------- */
.trade { display: flex; flex-direction: column; gap: 16px; }
.trade-cols { display: grid; grid-template-columns: 1fr auto 1fr; gap: 16px; align-items: start; }
.trade-arrow { font-family: 'Bagel Fat One', system-ui; font-size: 30px; align-self: center; }
.status {
  display: inline-block; font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: .5px;
  border: 2px solid var(--ink); border-radius: 999px; padding: 2px 10px; background: #fff;
}
.status.pending { background: var(--yellow); }
.status.accepted, .status.sold { background: var(--green); }
.status.declined, .status.cancelled, .status.expired { background: #e5e0d8; }
.auction-meta { display: flex; flex-direction: column; gap: 8px; }
.price { font-family: 'Bagel Fat One', system-ui; font-size: 24px; display: flex; align-items: center; gap: 8px; }

/* ---------- Auth ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 30px 16px; }
.auth-box { width: 100%; max-width: 440px; }
.auth-title { text-align: center; margin-bottom: 26px; }
.auth-title .logo { justify-content: center; font-size: 52px; }
.auth-title .logo-card { width: 46px; height: 62px; }
.auth-title p { margin-top: 10px; font-weight: 600; }
.float-cards { position: fixed; inset: 0; pointer-events: none; z-index: -1; overflow: hidden; }
.float-cards span {
  position: absolute; width: 90px; height: 126px; border: 3px solid var(--ink); border-radius: 12px;
  box-shadow: 4px 4px 0 var(--ink); animation: drift 9s ease-in-out infinite;
}
@keyframes drift { 0%, 100% { transform: translateY(0) rotate(var(--r)); } 50% { transform: translateY(-22px) rotate(calc(var(--r) * -1)); } }

/* ---------- Toasts / Modal ---------- */
#toasts { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 10px; z-index: 200; max-width: min(380px, calc(100vw - 36px)); }
.toast {
  background: #fff; border: 2.5px solid var(--ink); border-radius: 14px; box-shadow: var(--shadow);
  padding: 12px 16px; font-weight: 600; animation: pop .25s cubic-bezier(.2, 1.6, .4, 1);
}
.toast.err { background: #ffd9d4; }
.toast.ok { background: #ddf7d9; }
@keyframes pop { from { transform: scale(.6) rotate(-6deg); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.modal-bg {
  position: fixed; inset: 0; background: rgba(22, 19, 15, .45); z-index: 150; display: grid; place-items: center; padding: 18px;
  animation: fade .15s;
}
@keyframes fade { from { opacity: 0; } }
.modal {
  background: var(--paper); border: 3px solid var(--ink); border-radius: 20px; box-shadow: 7px 7px 0 var(--ink);
  width: 100%; max-width: 640px; max-height: calc(100vh - 36px); overflow: auto; padding: 24px; animation: pop .25s cubic-bezier(.2, 1.4, .4, 1);
}
.modal-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 18px; }
.x-btn {
  width: 44px; height: 44px; border-radius: 50%; border: 2.5px solid var(--ink); background: #fff; cursor: pointer;
  font-size: 22px; font-weight: 800; display: grid; place-items: center; flex: none;
}
.modal-card { display: grid; grid-template-columns: 200px 1fr; gap: 22px; align-items: start; }
.modal-card.create-grid { grid-template-columns: 1fr 220px; }

.loading { padding: 60px 0; text-align: center; font-family: 'Bagel Fat One', system-ui; font-size: 26px; animation: wobble 1.2s infinite; }

@media (max-width: 720px) {
  .topbar-in { gap: 10px; padding: 10px 14px; }
  nav.main { order: 3; flex-basis: 100%; overflow-x: auto; flex-wrap: nowrap; padding-bottom: 4px; }
  .me { margin-left: auto; }
  main { padding: 22px 14px 70px; }
  .cards { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 18px 14px; }
  .trade-cols { grid-template-columns: 1fr; }
  .trade-arrow { transform: rotate(90deg); justify-self: center; }
  .modal-card, .modal-card.create-grid { grid-template-columns: 1fr; }
  .modal-card > .tcg { max-width: 220px; margin: 0 auto; }
}
