/* PALABRE : la nuit indigo sous l'arbre à palabres, la terre de latérite, la lumière curcuma des ampoules du maquis.
   Un seul monde visuel (le jeu est nocturne par choix). Trois familles : rouge kola, vert feuille, bleu pagne. */

:root {
  color-scheme: dark;
  --nuit: #16114A;
  --nuit-2: #0B0830;
  --indigo: #2B2490;
  --indigo-clair: #4B43C9;
  --laterite: #C4502A;
  --laterite-f: #8E3418;
  --curcuma: #FFC23D;
  --curcuma-f: #E2900B;
  --papier: #FFF6E3;
  --encre: #1B1036;
  --texte: #FFF6E3;
  --texte-2: #CFC9F5;
  --costaud: #E8412F;
  --malin: #1FB36B;
  --tchatcheur: #2E8FFF;
  --or: #F7C948;
  --rayon: 22px;
  --ombre-bouton: 0 6px 0 rgba(0, 0, 0, .35);
  --haut: env(safe-area-inset-top, 0px);
  --bas: env(safe-area-inset-bottom, 0px);
  --f-titre: "Lilita One", "Arial Rounded MT Bold", "Trebuchet MS", sans-serif;
  --f-meme: "Anton", Impact, "Arial Narrow", sans-serif;
  --f-texte: "Nunito", "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--nuit-2);
  color: var(--texte);
  font-family: var(--f-texte);
  font-weight: 700;
  font-size: 16px;
  line-height: 1.4;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; padding: 0; }
input, textarea { font: inherit; user-select: text; -webkit-user-select: text; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--curcuma); outline-offset: 3px; border-radius: 8px; }
.ico { width: 1.2em; height: 1.2em; display: inline-block; vertical-align: middle; flex: none; }

/* ───────── Le décor : nuit, étoiles, arbre, terre ───────── */
#decor {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background:
    radial-gradient(120% 70% at 50% -10%, rgba(255, 194, 61, .20), transparent 60%),
    radial-gradient(90% 60% at 50% 110%, rgba(196, 80, 42, .55), transparent 70%),
    linear-gradient(180deg, var(--nuit) 0%, #1D1660 55%, #2A1648 100%);
}
#decor::before { /* le motif de pagne, à peine visible */
  content: ""; position: absolute; inset: 0; opacity: .07;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='64' height='64'%3E%3Cg fill='none' stroke='%23FFF6E3' stroke-width='2'%3E%3Ccircle cx='32' cy='32' r='14'/%3E%3Ccircle cx='32' cy='32' r='6'/%3E%3Cpath d='M0 0l12 12M64 0L52 12M0 64l12-12M64 64L52 52'/%3E%3C/g%3E%3C/svg%3E");
}

#app {
  position: relative; z-index: 1;
  height: 100%;
  max-width: 520px;
  margin: 0 auto;
  display: flex; flex-direction: column;
}
@media (min-width: 900px) {
  #app { box-shadow: 0 0 0 1px rgba(255, 255, 255, .06), 0 30px 120px rgba(0, 0, 0, .55); background: rgba(11, 8, 48, .35); }
}

.ecran { position: absolute; inset: 0; display: flex; flex-direction: column; padding: calc(var(--haut) + 10px) 16px calc(var(--bas) + 12px); overflow: hidden; }
.ecran.defile { overflow-y: auto; overscroll-behavior: contain; }
.ecran.defile > * { flex-shrink: 0; }
.ecran-entree { animation: entree .32s cubic-bezier(.22, 1, .36, 1) both; }
@keyframes entree { from { opacity: 0; transform: translateY(14px) scale(.98); } }

/* ───────── Boutons « à la Clash » : épais, avec une tranche ───────── */
.btn {
  --c: var(--curcuma); --c-f: var(--curcuma-f); --t: var(--encre);
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: .5em;
  min-height: 52px; padding: .55em 1.3em .7em;
  font-family: var(--f-titre); font-size: 1.2rem; letter-spacing: .01em; color: var(--t);
  background: linear-gradient(180deg, color-mix(in srgb, var(--c) 82%, #fff) 0%, var(--c) 46%, var(--c-f) 100%);
  border: 3px solid var(--encre); border-radius: 18px;
  box-shadow: 0 5px 0 var(--encre), inset 0 2px 0 rgba(255, 255, 255, .55);
  transition: transform .08s, box-shadow .08s;
  text-shadow: 0 1px 0 rgba(255, 255, 255, .45); text-decoration: none;
}
.btn:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--encre), inset 0 2px 0 rgba(255, 255, 255, .55); }
.btn.indigo { --c: #5A51E0; --c-f: #332AA8; --t: var(--papier); text-shadow: 0 2px 0 rgba(0, 0, 0, .35); }
.btn.vert { --c: #2FD07F; --c-f: #13894E; }
.btn.rouge { --c: #FF6B57; --c-f: #C22B1B; --t: var(--papier); text-shadow: 0 2px 0 rgba(0, 0, 0, .3); }
.btn.papier { --c: var(--papier); --c-f: #E6D6B3; }
.btn.petit { min-height: 42px; font-size: 1rem; padding: .35em .9em .5em; border-radius: 14px; }
.btn.plein { width: 100%; }
.btn[disabled] { filter: grayscale(.8) brightness(.8); pointer-events: none; }

.pastille {
  display: inline-flex; align-items: center; gap: .35em; padding: .25em .7em .25em .35em;
  background: rgba(11, 8, 48, .72); border: 2px solid rgba(255, 255, 255, .14); border-radius: 999px;
  font-family: var(--f-titre); font-size: 1.05rem; font-variant-numeric: tabular-nums;
}
.pastille .ico { width: 1.5em; height: 1.5em; }

/* ───────── En-tête de l'accueil ───────── */
.entete { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.joueur-puce { display: flex; align-items: center; gap: 10px; min-width: 0; }
.avatar {
  width: 46px; height: 46px; border-radius: 14px; flex: none;
  display: grid; place-items: center; font-family: var(--f-titre); font-size: 1.3rem; color: var(--encre);
  background: linear-gradient(160deg, var(--curcuma), var(--laterite)); border: 3px solid var(--encre);
  box-shadow: 0 3px 0 var(--encre);
}
.joueur-puce .qui { min-width: 0; line-height: 1.15; }
.joueur-puce .nom { font-family: var(--f-titre); font-size: 1.05rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.joueur-puce .titre { font-size: .8rem; color: var(--texte-2); white-space: nowrap; }
.jauge-xp { height: 7px; width: 120px; max-width: 100%; border-radius: 9px; background: rgba(255, 255, 255, .14); overflow: hidden; margin-top: 4px; }
.jauge-xp i { display: block; height: 100%; background: linear-gradient(90deg, var(--malin), #9BF0C4); border-radius: inherit; }

/* ───────── Le logo ───────── */
.logo {
  font-family: var(--f-titre); text-align: center; line-height: .9; margin: 10px 0 0;
  font-size: clamp(3.4rem, 17vw, 5.2rem); letter-spacing: .01em;
  color: var(--curcuma);
  -webkit-text-stroke: 3px var(--encre);
  paint-order: stroke fill;
  text-shadow: 0 5px 0 var(--encre), 0 8px 0 var(--laterite-f), 0 14px 26px rgba(0, 0, 0, .5);
  transform: rotate(-3deg);
}
.logo small { display: block; font-family: var(--f-texte); font-weight: 800; font-size: .95rem; letter-spacing: .02em; color: var(--texte-2); -webkit-text-stroke: 0; text-shadow: none; transform: rotate(3deg); margin-top: .7em; }

/* ───────── L'arbre à palabres ───────── */
.arbre { position: relative; width: 100%; max-width: 380px; margin: 0 auto; aspect-ratio: 380 / 210; }
.arbre svg { width: 100%; height: 100%; display: block; overflow: visible; }
.ampoule { animation: scintille 3.2s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
@keyframes scintille { 0%, 100% { opacity: 1; } 50% { opacity: .55; } }

/* ───────── Accueil ───────── */
.accueil-centre { flex: 1; display: flex; flex-direction: column; justify-content: center; gap: 14px; min-height: 0; }
.gros-palabre {
  flex-direction: column; gap: 2px; line-height: 1;
  font-size: clamp(1.8rem, 9vw, 2.4rem); min-height: 84px; border-radius: 26px; border-width: 4px;
  box-shadow: 0 7px 0 var(--encre), inset 0 3px 0 rgba(255, 255, 255, .6), 0 18px 40px rgba(255, 194, 61, .28);
}
.gros-palabre .sous { display: block; margin-top: 4px; font-family: var(--f-texte); font-weight: 800; font-size: .82rem; opacity: .8; letter-spacing: 0; }
.gros-palabre:active { transform: translateY(5px); box-shadow: 0 2px 0 var(--encre), inset 0 3px 0 rgba(255, 255, 255, .6); }
.modes { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.mode {
  display: flex; flex-direction: column; align-items: flex-start; justify-content: flex-end; gap: 2px;
  min-height: 96px; padding: 12px 14px; border-radius: 20px; text-align: left;
  border: 3px solid var(--encre); box-shadow: 0 5px 0 var(--encre);
  background: linear-gradient(160deg, var(--m1), var(--m2)); position: relative; overflow: hidden;
}
.mode:active { transform: translateY(3px); box-shadow: 0 2px 0 var(--encre); }
.mode .ico { position: absolute; top: 10px; right: 10px; width: 34px; height: 34px; opacity: .9; }
.mode b { font-family: var(--f-titre); font-weight: 400; font-size: 1.15rem; line-height: 1.05; }
.mode span { font-size: .78rem; opacity: .85; line-height: 1.2; }
.mode.large { grid-column: 1 / -1; min-height: 84px; }
.m-ami { --m1: #5A51E0; --m2: #2A228F; }
.m-soiree { --m1: #FF6B57; --m2: #A3261A; }
.m-tour { --m1: #1FB36B; --m2: #0C6B3E; }
.m-ia { --m1: #3A3478; --m2: #221D57; }

/* ───────── Barre du bas ───────── */
.barre { display: flex; gap: 8px; padding-top: 10px; }
.barre button {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 4px;
  border-radius: 16px; font-size: .78rem; color: var(--texte-2); background: rgba(11, 8, 48, .5);
}
.barre button .ico { width: 26px; height: 26px; }
.barre button[aria-current="page"] { color: var(--encre); background: var(--curcuma); box-shadow: 0 3px 0 var(--encre); }

/* ═════════ LA CARTE ═════════ */
.carte {
  --w: 120px; --fc: var(--costaud);
  width: var(--w); aspect-ratio: 63 / 88; font-size: calc(var(--w) / 10);
  position: relative; flex: none; transform-style: preserve-3d;
  transition: transform .5s cubic-bezier(.3, 1.3, .5, 1);
}
.carte.f-costaud { --fc: var(--costaud); --fc-c: #FF8A76; --fc-f: #9E1D10; }
.carte.f-malin { --fc: var(--malin); --fc-c: #7EEBB5; --fc-f: #0A6B3B; }
.carte.f-tchatcheur { --fc: var(--tchatcheur); --fc-c: #8CC4FF; --fc-f: #0F4FB3; }
.carte .face, .carte .dos {
  position: absolute; inset: 0; border-radius: .9em; backface-visibility: hidden; -webkit-backface-visibility: hidden; overflow: hidden;
  border: .22em solid var(--encre);
  box-shadow: 0 .35em 0 rgba(0, 0, 0, .35), 0 .7em 1.6em rgba(0, 0, 0, .35);
}
.carte .dos { transform: rotateY(180deg); }
.carte.cachee { transform: rotateY(180deg); }

.face {
  display: flex; flex-direction: column; padding: .32em;
  background: linear-gradient(165deg, var(--fc-c) 0%, var(--fc) 38%, var(--fc-f) 100%);
}
.face .ill {
  position: relative; flex: 1 1 auto; min-height: 0; border-radius: .55em; overflow: hidden;
  border: .16em solid var(--encre);
  background:
    repeating-conic-gradient(from 0deg at 50% 62%, rgba(255, 255, 255, .16) 0 10deg, transparent 10deg 20deg),
    radial-gradient(circle at 50% 60%, var(--fc-c), var(--fc) 70%);
}
.face .ill svg { position: absolute; left: 0; right: 0; bottom: 0; width: 100%; height: 100%; }
.face .num {
  position: absolute; top: .1em; left: .1em; z-index: 3;
  width: 2.3em; height: 2.3em; border-radius: 50%; display: grid; place-items: center;
  font-family: var(--f-titre); font-size: 1.05em; line-height: 1; color: var(--encre);
  background: radial-gradient(circle at 35% 30%, #FFF2C4, var(--curcuma) 55%, var(--curcuma-f));
  border: .14em solid var(--encre); box-shadow: 0 .12em 0 var(--encre);
}
.face .num b { font-weight: 400; font-size: 1.45em; }
.face .num.monte { background: radial-gradient(circle at 35% 30%, #DFFFEF, #3CE08F 55%, #12894E); }
.face .fam {
  position: absolute; top: .22em; right: .22em; z-index: 3; width: 1.9em; height: 1.9em; border-radius: .55em;
  display: grid; place-items: center; color: #fff; background: var(--fc-f); border: .13em solid var(--encre);
}
.face .fam .ico { width: 1.25em; height: 1.25em; }
.face .nom {
  flex: none; margin-top: .28em; padding: .22em .3em .26em; border-radius: .45em;
  font-family: var(--f-titre); font-size: .78em; line-height: 1.05; text-align: center; color: var(--papier);
  background: var(--encre); text-wrap: balance;
}
.face .phrase {
  flex: none; margin-top: .26em; padding: .28em .35em; border-radius: .45em; min-height: 2.6em;
  display: grid; place-items: center; text-align: center;
  font-family: var(--f-meme); text-transform: uppercase; font-size: .62em; line-height: 1.12; letter-spacing: .01em;
  color: #fff; -webkit-text-stroke: .14em #000; paint-order: stroke fill;
  background: rgba(0, 0, 0, .28); text-wrap: balance;
}
.face .pouvoir {
  flex: none; margin-top: .26em; padding: .3em .4em; border-radius: .45em; display: flex; gap: .3em; align-items: flex-start;
  font-family: var(--f-texte); font-weight: 800; font-size: .5em; line-height: 1.2; color: var(--encre); background: var(--papier);
}
.face .pouvoir .ico { width: 1.4em; height: 1.4em; color: var(--curcuma-f); }
.face .niv { position: absolute; bottom: .25em; left: 50%; transform: translateX(-50%); z-index: 3; display: flex; gap: .12em; }
.face .niv i { width: .55em; height: .55em; border-radius: 50%; background: var(--curcuma); border: .08em solid var(--encre); }

/* Les tailles : en main on ne garde que l'essentiel */
.carte.mini .phrase, .carte.mini .pouvoir, .carte.moyenne .pouvoir { display: none; }
.carte.mini .nom { font-size: 1.02em; padding: .18em .2em .22em; }
.carte.mini .num { font-size: 1.3em; }
.carte.mini .fam { font-size: 1.15em; }

/* Les raretés */
.carte.r-rare .face { box-shadow: inset 0 0 0 .14em #E8EEF6, 0 .35em 0 rgba(0, 0, 0, .35), 0 .7em 1.6em rgba(0, 0, 0, .35); }
.carte.r-epique .face, .carte.r-legendaire .face { box-shadow: inset 0 0 0 .16em var(--or), 0 .35em 0 rgba(0, 0, 0, .35), 0 0 1.6em rgba(247, 201, 72, .45); }
.carte.r-legendaire .face .nom { background: linear-gradient(90deg, #6B4A00, #2B1B00, #6B4A00); color: #FFE7A3; }
/* L'éclat : une bande de lumière qui balaie la carte (épique : arc-en-ciel, légendaire : or). Jamais un voile sur toute la carte. */
.carte .reflet {
  position: absolute; inset: 0; z-index: 4; pointer-events: none; border-radius: .7em; opacity: 0; mix-blend-mode: screen;
  background: linear-gradient(105deg, transparent 38%, rgba(255, 140, 220, .32) 44%, rgba(140, 230, 255, .42) 50%, rgba(255, 250, 170, .32) 56%, transparent 62%);
  background-size: 320% 100%; background-repeat: no-repeat; background-position: var(--px, 130%) 0;
}
.carte.r-legendaire .reflet { background-image: linear-gradient(105deg, transparent 40%, rgba(255, 236, 160, .25) 45%, rgba(255, 255, 255, .6) 50%, rgba(255, 236, 160, .25) 55%, transparent 60%); }
.carte.r-epique .reflet, .carte.r-legendaire .reflet { opacity: 1; animation: eclat 3.6s ease-in-out infinite; }
.carte.r-legendaire .reflet { animation-duration: 2.8s; }
.carte.zoom .reflet { animation: none; }
@keyframes eclat { 0%, 55% { background-position: 130% 0; } 100% { background-position: -30% 0; } }

/* Le dos de carte : le motif de pagne et le sceau PALABRE */
.dos {
  display: grid; place-items: center;
  background:
    radial-gradient(circle at 50% 50%, transparent 0 28%, rgba(0, 0, 0, .25) 29% 30%, transparent 31%),
    repeating-conic-gradient(from 45deg at 50% 50%, #3B33B8 0 15deg, #2A238F 15deg 30deg);
}
.dos::before {
  content: ""; position: absolute; inset: .4em; border-radius: .6em; border: .14em dashed rgba(255, 194, 61, .55);
}
.dos .sceau {
  width: 52%; aspect-ratio: 1; border-radius: 50%; display: grid; place-items: center;
  background: radial-gradient(circle at 35% 30%, #FFE7A3, var(--curcuma) 50%, var(--curcuma-f));
  border: .18em solid var(--encre); box-shadow: 0 .18em 0 var(--encre);
  font-family: var(--f-titre); color: var(--encre); font-size: 1.9em; line-height: 1;
}

/* ═════════ LE DUEL ═════════ */
.duel { gap: 6px; padding-left: 12px; padding-right: 12px; }
.duel-haut, .duel-bas { display: flex; align-items: center; gap: 10px; }
.duel-haut .qui, .duel-bas .qui { flex: 1; min-width: 0; }
.duel .nom-j { font-family: var(--f-titre); font-size: 1.05rem; line-height: 1.1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.duel .sous-j { font-size: .75rem; color: var(--texte-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.score { display: flex; gap: 6px; }
.score i {
  width: 22px; height: 22px; border-radius: 50%; border: 3px solid var(--encre); background: rgba(255, 255, 255, .14);
  box-shadow: 0 2px 0 var(--encre);
}
.score i.on { background: radial-gradient(circle at 35% 30%, #FFF2C4, var(--curcuma) 60%); animation: pop .5s cubic-bezier(.3, 1.8, .5, 1); }
@keyframes pop { 0% { transform: scale(.3); } 60% { transform: scale(1.35); } }

.main-adverse { display: flex; justify-content: center; height: 46px; }
.main-adverse .carte { --w: 40px; margin: 0 -6px; }
.main-adverse .carte:nth-child(odd) { transform: rotateY(180deg) rotate(-4deg); }
.main-adverse .carte:nth-child(even) { transform: rotateY(180deg) rotate(3deg); }

.arene {
  position: relative; flex: 1; min-height: 0; border-radius: 26px; overflow: hidden;
  display: grid; grid-template-rows: 1fr auto 1fr; align-items: center; justify-items: center;
  background:
    radial-gradient(60% 45% at 50% 50%, rgba(255, 194, 61, .22), transparent 70%),
    linear-gradient(180deg, rgba(43, 36, 144, .55), rgba(196, 80, 42, .55));
  border: 3px solid rgba(0, 0, 0, .35);
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .06), inset 0 -30px 60px rgba(142, 52, 24, .5);
}
.arene::before { /* le sol de latérite, en bas */
  content: ""; position: absolute; left: -10%; right: -10%; bottom: -30%; height: 60%; border-radius: 50%;
  background: radial-gradient(ellipse at 50% 30%, rgba(214, 104, 60, .7), rgba(142, 52, 24, .2) 60%, transparent 70%);
}
.emplacement {
  --w: clamp(92px, 27vw, 128px);
  position: relative; width: var(--w); aspect-ratio: 63 / 88; border-radius: 14px;
  border: 3px dashed rgba(255, 246, 227, .25); display: grid; place-items: center;
}
.emplacement > .carte { position: absolute; left: -3px; top: -3px; }
.emplacement .attente { font-size: .75rem; color: var(--texte-2); text-align: center; padding: 0 8px; }
.milieu { position: relative; z-index: 2; display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 4px 12px; max-width: 100%; }
.manche-n { font-family: var(--f-titre); font-size: .95rem; color: var(--texte-2); }
.raison {
  font-family: var(--f-titre); font-size: clamp(1.05rem, 5vw, 1.35rem); text-align: center; line-height: 1.1; min-height: 1.3em;
  color: var(--papier); -webkit-text-stroke: 2px var(--encre); paint-order: stroke fill; text-shadow: 0 3px 0 var(--encre); padding: 0 10px;
}
.chrono {
  position: absolute; right: 10px; top: 10px; z-index: 3;
  width: 54px; height: 54px; border-radius: 50%; display: grid; place-items: center;
  font-family: var(--f-titre); font-size: 1.4rem; color: var(--encre);
  background: conic-gradient(var(--curcuma) calc(var(--p, 1) * 360deg), rgba(255, 255, 255, .15) 0);
  border: 3px solid var(--encre); box-shadow: 0 3px 0 var(--encre);
}
.chrono b { width: 38px; height: 38px; border-radius: 50%; background: var(--papier); display: grid; place-items: center; font-weight: 400; }
.chrono.urgent { animation: tremble .3s linear infinite; }
.chrono.urgent b { background: #FFD3CC; }
@keyframes tremble { 25% { transform: rotate(-6deg); } 75% { transform: rotate(6deg); } }
.triangle-mini { position: absolute; left: 10px; top: 10px; z-index: 3; width: 58px; height: 58px; }

.ma-main { display: flex; justify-content: center; align-items: flex-end; height: clamp(128px, 33vw, 162px); padding-bottom: 2px; }
.ma-main .carte {
  --w: clamp(76px, 22vw, 106px); margin: 0 -11px; cursor: pointer;
  transform: translateY(var(--ty, 0)) rotate(var(--rot, 0deg));
  transition: transform .25s cubic-bezier(.3, 1.4, .5, 1), opacity .2s;
}
.ma-main .carte:hover, .ma-main .carte:focus-visible { --ty: -14px; z-index: 5; }
.ma-main .carte.choisie { --ty: -26px; z-index: 6; }
.ma-main .carte.choisie .face { box-shadow: 0 0 0 .2em var(--curcuma), 0 .6em 1.4em rgba(255, 194, 61, .6); }
.ma-main.bloquee .carte { opacity: .55; pointer-events: none; }
.ma-main .carte.nouvelle { animation: piocher .45s cubic-bezier(.3, 1.4, .5, 1) both; }
@keyframes piocher { from { transform: translateY(80px) rotate(10deg); opacity: 0; } }

.actions-duel { display: flex; gap: 8px; align-items: center; }
.btn-rond {
  width: 48px; height: 48px; border-radius: 16px; display: grid; place-items: center; flex: none;
  background: rgba(11, 8, 48, .7); border: 2px solid rgba(255, 255, 255, .16); color: var(--papier);
}
.btn-rond .ico { width: 26px; height: 26px; }

/* La révélation */
.carte.revele { animation: retourne .55s cubic-bezier(.3, 1.3, .5, 1) both; }
@keyframes retourne { from { transform: rotateY(180deg) scale(.9); } to { transform: rotateY(0) scale(1); } }
.carte.gagne { animation: frappe .6s cubic-bezier(.2, 1.6, .4, 1) both; z-index: 5; }
@keyframes frappe { 0% { transform: scale(1); } 35% { transform: scale(1.22) rotate(-3deg); } 60% { transform: scale(.96); } 100% { transform: scale(1.08); } }
.carte.perd { animation: chute .9s cubic-bezier(.5, 0, .7, .4) both; }
@keyframes chute { 0% { transform: none; filter: none; } 30% { transform: rotate(8deg) translateY(4px); } 100% { transform: rotate(-14deg) translateY(10px) scale(.9); filter: grayscale(.85) brightness(.7); } }
.carte.nul { animation: nul .5s ease both; }
@keyframes nul { 30% { transform: translateX(-6px); } 60% { transform: translateX(6px); } }
.bulle-meme {
  position: absolute; z-index: 8; left: 50%; transform: translateX(-50%); width: max-content; max-width: 92%;
  padding: .45em .8em; border-radius: 16px; text-align: center;
  font-family: var(--f-meme); text-transform: uppercase; font-size: clamp(1rem, 5.2vw, 1.35rem); line-height: 1.05;
  color: #fff; -webkit-text-stroke: 3px #000; paint-order: stroke fill; background: transparent;
  animation: bulle 2.2s cubic-bezier(.2, 1.4, .4, 1) both; pointer-events: none;
}
@keyframes bulle { 0% { opacity: 0; transform: translateX(-50%) scale(.4) rotate(-6deg); } 12% { opacity: 1; transform: translateX(-50%) scale(1.08) rotate(-3deg); } 22% { transform: translateX(-50%) scale(1) rotate(-3deg); } 85% { opacity: 1; } 100% { opacity: 0; transform: translateX(-50%) translateY(-10px) rotate(-3deg); } }
.secousse { animation: secousse .35s linear; }
@keyframes secousse { 20% { transform: translate(-4px, 2px); } 40% { transform: translate(4px, -2px); } 60% { transform: translate(-3px, -1px); } 80% { transform: translate(3px, 1px); } }

/* Les réactions */
.reactions {
  position: absolute; left: 12px; right: 12px; bottom: calc(var(--bas) + 70px); z-index: 20;
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 12px; border-radius: 20px;
  background: rgba(11, 8, 48, .94); border: 2px solid rgba(255, 255, 255, .14); box-shadow: 0 20px 50px rgba(0, 0, 0, .5);
  animation: entree .2s ease both;
}
.reactions button { padding: 10px 8px; border-radius: 14px; background: rgba(255, 255, 255, .08); font-family: var(--f-titre); font-size: 1rem; }
.reactions button:active { background: var(--curcuma); color: var(--encre); }
.reaction-vol {
  position: absolute; z-index: 25; padding: 8px 14px; border-radius: 18px; font-family: var(--f-titre); font-size: 1.15rem;
  background: var(--papier); color: var(--encre); border: 3px solid var(--encre); box-shadow: 0 4px 0 var(--encre);
  animation: reaction 2.4s cubic-bezier(.2, 1.4, .4, 1) both; pointer-events: none; white-space: nowrap;
}
.reaction-vol::after { content: ""; position: absolute; left: 22px; width: 14px; height: 14px; background: var(--papier); border: 3px solid var(--encre); border-top: 0; border-left: 0; }
.reaction-vol.de-haut::after { top: -9px; transform: rotate(-135deg); }
.reaction-vol.de-bas::after { bottom: -9px; transform: rotate(45deg); }
@keyframes reaction { 0% { opacity: 0; transform: scale(.3); } 10% { opacity: 1; transform: scale(1.1); } 18% { transform: scale(1); } 85% { opacity: 1; } 100% { opacity: 0; transform: translateY(-8px); } }

/* ═════════ Surcouches (verdict, calebasse, zoom, feuilles) ═════════ */
.voile {
  position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center;
  padding: calc(var(--haut) + 16px) 16px calc(var(--bas) + 16px);
  background: rgba(8, 5, 36, .82); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
  animation: fondu .25s ease both;
}
@keyframes fondu { from { opacity: 0; } }
.feuille {
  width: 100%; max-width: 440px; max-height: 100%; overflow-y: auto; border-radius: 26px; padding: 20px 18px;
  background: linear-gradient(180deg, #2A2390, #1A145E); border: 3px solid var(--encre); box-shadow: 0 8px 0 var(--encre), 0 30px 80px rgba(0, 0, 0, .55);
  animation: entree .3s cubic-bezier(.22, 1, .36, 1) both;
}
.feuille h2 { font-family: var(--f-titre); font-weight: 400; font-size: 1.6rem; margin: 0 0 4px; line-height: 1.1; text-wrap: balance; }
.feuille p { margin: 0 0 12px; color: var(--texte-2); font-weight: 700; }
.feuille .choix { display: grid; gap: 10px; margin-top: 12px; }
.feuille .choix .btn { justify-content: flex-start; text-align: left; font-size: 1.1rem; }
.feuille .choix .btn small { display: block; font-family: var(--f-texte); font-size: .75rem; font-weight: 800; opacity: .75; }
.fermer { position: absolute; top: calc(var(--haut) + 14px); right: 14px; z-index: 60; }

.champ { display: grid; gap: 6px; margin: 10px 0; }
.champ label { font-size: .85rem; color: var(--texte-2); }
.champ input, .champ select {
  width: 100%; min-height: 50px; padding: 10px 14px; border-radius: 14px; font-weight: 800; font-size: 1.05rem;
  color: var(--encre); background: var(--papier); border: 3px solid var(--encre);
}
.puces { display: flex; flex-wrap: wrap; gap: 6px; }
.puces button { padding: 7px 11px; border-radius: 999px; font-size: .82rem; background: rgba(255, 255, 255, .1); border: 2px solid rgba(255, 255, 255, .14); }
.puces button[aria-pressed="true"] { background: var(--curcuma); color: var(--encre); border-color: var(--encre); }

/* Le verdict */
.verdict { text-align: center; position: relative; }
.verdict .liste-joueurs { text-align: left; }
.tampon {
  display: inline-block; margin: 6px auto 10px; padding: 6px 18px; border: 5px solid var(--costaud); border-radius: 12px;
  font-family: var(--f-titre); font-size: 2.6rem; line-height: 1; color: var(--costaud); letter-spacing: .04em;
  transform: rotate(-8deg); animation: tampon .5s cubic-bezier(.2, 1.8, .4, 1) .15s both;
  background: rgba(232, 65, 47, .08);
}
.tampon.vert { border-color: var(--malin); color: var(--malin); background: rgba(31, 179, 107, .08); }
@keyframes tampon { from { transform: rotate(-8deg) scale(2.4); opacity: 0; } }
.verdict .enjeu { font-family: var(--f-titre); font-size: 1.35rem; line-height: 1.15; color: var(--papier); margin: 4px 0 10px; text-wrap: balance; }
.verdict .score-final { font-family: var(--f-titre); font-size: 2.2rem; color: var(--curcuma); -webkit-text-stroke: 2px var(--encre); paint-order: stroke fill; }
.gains { display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; margin: 10px 0 14px; }
.verdict .actions { display: grid; gap: 10px; }
.verdict .actions .ligne { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.verdict .actions .ligne .btn { font-size: 1.02rem; line-height: 1.1; padding: .5em .6em .62em; }
.verdict .actions .ligne .btn .ico { display: none; }

/* La calebasse */
.calebasse-scene { display: flex; flex-direction: column; align-items: center; gap: 16px; text-align: center; }
.calebasse-scene .cal { width: 170px; height: 150px; animation: secoue 1s ease-in-out infinite; cursor: pointer; }
@keyframes secoue { 0%, 100% { transform: rotate(0); } 20% { transform: rotate(-7deg); } 40% { transform: rotate(6deg); } 60% { transform: rotate(-4deg); } }
.tirage { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.tirage .carte { --w: 132px; animation: sortie .6s cubic-bezier(.2, 1.5, .4, 1) both; }
.tirage .carte:nth-child(2) { animation-delay: .25s; }
@keyframes sortie { from { transform: translateY(80px) scale(.3) rotate(-20deg); opacity: 0; } }
.etiquette { font-family: var(--f-titre); font-size: .95rem; margin-top: 6px; }
.etiquette.nouveau { color: var(--malin); }

/* L'invocation (légendaire) */
.invocation { position: fixed; inset: 0; z-index: 70; display: grid; place-items: center; overflow: hidden; background: rgba(8, 5, 36, .9); animation: fondu .2s both; }
.invocation .rayons {
  position: absolute; width: 220vmax; height: 220vmax; border-radius: 50%;
  background: repeating-conic-gradient(rgba(255, 194, 61, .5) 0 8deg, transparent 8deg 18deg);
  animation: tourne 6s linear infinite; mask: radial-gradient(circle, #000 10%, transparent 55%); -webkit-mask: radial-gradient(circle, #000 10%, transparent 55%);
}
@keyframes tourne { to { transform: rotate(360deg); } }
.invocation .carte { --w: min(62vw, 260px); animation: invoque 1.1s cubic-bezier(.2, 1.4, .4, 1) both; }
@keyframes invoque { 0% { transform: scale(.1) rotate(-30deg); filter: brightness(4); } 60% { transform: scale(1.12) rotate(3deg); filter: brightness(1.4); } 100% { transform: none; filter: none; } }
.invocation .cri { position: absolute; bottom: calc(var(--bas) + 12%); font-family: var(--f-titre); font-size: clamp(1.6rem, 8vw, 2.4rem); color: var(--curcuma); -webkit-text-stroke: 3px var(--encre); paint-order: stroke fill; text-align: center; padding: 0 16px; animation: entree .5s .5s both; }

/* ═════════ Collection, profil, tour ═════════ */
.titre-ecran { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.titre-ecran h1 { font-family: var(--f-titre); font-weight: 400; font-size: 1.7rem; margin: 0; line-height: 1; }
.titre-ecran .esp { flex: 1; }
.filtres { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.grille-cartes { display: grid; grid-template-columns: repeat(auto-fill, minmax(106px, 1fr)); gap: 14px 10px; padding-bottom: 20px; justify-items: center; }
.grille-cartes .case { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.grille-cartes .carte { --w: 106px; cursor: pointer; }
.grille-cartes .verrou { width: 106px; aspect-ratio: 63 / 88; border-radius: 12px; display: grid; place-items: center; text-align: center; padding: 8px; font-size: .72rem; color: var(--texte-2); background: rgba(255, 255, 255, .05); border: 3px dashed rgba(255, 255, 255, .15); }
.grille-cartes .verrou .ico { width: 28px; height: 28px; opacity: .5; }
.compte { font-size: .72rem; color: var(--texte-2); }
.zoom-scene { display: flex; flex-direction: column; align-items: center; gap: 14px; max-width: 360px; width: 100%; }
.zoom-scene .carte { --w: min(74vw, 290px); }
.zoom-scene .ref { font-size: .92rem; color: var(--texte-2); text-align: center; line-height: 1.4; }
.zoom-scene .ref b { color: var(--papier); }

.stat-grille { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 12px 0; }
.stat { padding: 10px 6px; border-radius: 16px; text-align: center; background: rgba(255, 255, 255, .07); }
.stat b { display: block; font-family: var(--f-titre); font-weight: 400; font-size: 1.5rem; color: var(--curcuma); font-variant-numeric: tabular-nums; }
.stat span { font-size: .72rem; color: var(--texte-2); }
.echelle { display: grid; gap: 6px; margin-top: 8px; }
.echelle div { display: flex; justify-content: space-between; padding: 9px 12px; border-radius: 12px; background: rgba(255, 255, 255, .05); font-size: .9rem; }
.echelle div.atteint { background: rgba(31, 179, 107, .18); }
.echelle div.actuel { background: var(--curcuma); color: var(--encre); }

.route { position: relative; display: grid; gap: 14px; padding: 6px 0 24px; }
.etape {
  display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: 20px;
  background: rgba(255, 255, 255, .07); border: 3px solid transparent; text-align: left; width: 100%;
}
.etape .tampon-ville {
  width: 58px; height: 58px; border-radius: 50%; flex: none; display: grid; place-items: center; text-align: center;
  font-family: var(--f-titre); font-size: .62rem; line-height: 1; border: 3px dashed rgba(255, 255, 255, .3); color: var(--texte-2); transform: rotate(-8deg);
}
.etape .tampon-ville b { font-size: 1.6rem; font-weight: 400; }
.etape .tampon-ville .ico { width: 22px; height: 22px; }
.etape.faite .tampon-ville { border: 3px solid var(--malin); color: var(--malin); background: rgba(31, 179, 107, .12); }
.etape.ouverte { border-color: var(--curcuma); background: rgba(255, 194, 61, .1); }
.etape.fermee { opacity: .5; }
.etape .info { flex: 1; min-width: 0; }
.etape .info b { display: block; font-family: var(--f-titre); font-weight: 400; font-size: 1.15rem; }
.etape .info span { font-size: .8rem; color: var(--texte-2); }

/* Salle (ami, soirée) */
.code-salle {
  font-family: var(--f-titre); font-size: 3rem; letter-spacing: .12em; text-align: center; color: var(--curcuma);
  -webkit-text-stroke: 2px var(--encre); paint-order: stroke fill; text-shadow: 0 4px 0 var(--encre); margin: 6px 0;
}
.qr { width: 168px; height: 168px; margin: 6px auto; padding: 8px; border-radius: 16px; background: #fff; border: 3px solid var(--encre); }
.qr svg, .qr img { width: 100%; height: 100%; display: block; }
.liste-joueurs { display: grid; gap: 8px; margin: 10px 0; }
.liste-joueurs div { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: 14px; background: rgba(255, 255, 255, .07); }
.liste-joueurs .avatar { width: 34px; height: 34px; font-size: 1rem; border-radius: 10px; }
.attente-point::after { content: "…"; animation: points 1.2s steps(4) infinite; display: inline-block; width: 1.2em; overflow: hidden; vertical-align: bottom; }
@keyframes points { from { width: 0; } }

/* La soirée : le Tribunal des mèmes */
.situation {
  padding: 16px; border-radius: 20px; text-align: center; background: var(--papier); color: var(--encre); border: 3px solid var(--encre);
  box-shadow: 0 5px 0 var(--encre); font-family: var(--f-titre); font-size: clamp(1.2rem, 5.5vw, 1.5rem); line-height: 1.15; text-wrap: balance;
}
.situation small { display: block; font-family: var(--f-texte); font-size: .75rem; opacity: .6; margin-bottom: 4px; }
.cartes-meme { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.carte-meme {
  position: relative; display: flex; flex-direction: column; border-radius: 16px; overflow: hidden; text-align: center; min-height: 150px;
  border: 3px solid var(--encre); box-shadow: 0 4px 0 var(--encre); background: var(--fc, #3A3478);
}
.carte-meme .im { height: 92px; position: relative; background: radial-gradient(circle at 50% 70%, rgba(255, 255, 255, .35), transparent 70%); }
.carte-meme .im svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.carte-meme .txt {
  flex: 1; display: grid; place-items: center; padding: 6px 8px 8px;
  font-family: var(--f-meme); text-transform: uppercase; font-size: 1rem; line-height: 1.08; color: #fff; -webkit-text-stroke: 2.5px #000; paint-order: stroke fill;
}
.carte-meme[aria-pressed="true"] { outline: 4px solid var(--curcuma); outline-offset: 2px; transform: translateY(-3px); }
.carte-meme .votes { position: absolute; top: 6px; right: 6px; min-width: 30px; height: 30px; padding: 0 6px; border-radius: 99px; display: grid; place-items: center; background: var(--curcuma); color: var(--encre); font-family: var(--f-titre); border: 2px solid var(--encre); }
.carte-meme .auteur { font-size: .72rem; padding: 4px; background: rgba(0, 0, 0, .35); }

/* Les confettis et éclats */
#effets { position: fixed; inset: 0; z-index: 80; pointer-events: none; }

.note-bas { font-size: .75rem; color: var(--texte-2); text-align: center; margin-top: 8px; }
.toast {
  position: fixed; left: 50%; bottom: calc(var(--bas) + 90px); z-index: 90; transform: translateX(-50%);
  padding: 10px 16px; border-radius: 14px; background: var(--papier); color: var(--encre); border: 3px solid var(--encre);
  font-weight: 800; box-shadow: 0 4px 0 var(--encre); animation: entree .25s both; max-width: 90vw; text-align: center;
}

@media (max-height: 700px) {
  .arbre { max-width: 300px; }
  .ma-main { height: 112px; }
  .ma-main .carte { --w: 66px; }
  .emplacement { --w: 88px; }
  .main-adverse { height: 36px; }
  .main-adverse .carte { --w: 32px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
