/* Tournoi de belote — habillage : salle d'attente et table de jeu. Zéro image : cartes et tapis dessinés en CSS/SVG. */
:root {
  --tapis: #2E6B43;
  --tapis-fonce: #235236;
  --bois: #5b3f25;
  --creme: #FBF7EF;
  --or: #F6C945;
  --rouge: #C0392B;
  --texte: #203028;
  --carte-l: 66px;
  --carte-h: 92px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--texte); background: #153D28; -webkit-user-select: none; user-select: none; }
#app { min-height: 100%; display: flex; flex-direction: column; }
.entete { display: flex; justify-content: space-between; align-items: center; padding: 8px 16px; background: var(--bois); color: var(--creme); }
.titre { font-weight: 800; font-size: 18px; }
.etat { font-size: 13px; opacity: .9; }
.etat.alerte { color: #ffb4a8; }
main { flex: 1; padding: 12px; display: flex; flex-direction: column; }

/* ---------- Salle d'attente ---------- */
.salle { max-width: 720px; width: 100%; margin: 0 auto; background: var(--creme); border-radius: 12px; padding: 20px; }
.salle h1 { margin: 0 0 6px; font-size: 22px; text-transform: uppercase; letter-spacing: .04em; }
.soustitre { margin: 0 0 14px; color: #555; }
.compteur { font-weight: 700; margin: 0 0 12px; }
.matchs { display: grid; gap: 10px; }
.match { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 10px; background: #fff; border: 1px solid #e3dccb; border-radius: 10px; padding: 10px 12px; }
.equipe { padding: 6px 8px; border-radius: 8px; }
.equipe.moi { background: #fff5d6; outline: 2px solid var(--or); }
.equipe.gagnant .nom-equipe::after { content: " ✔"; color: var(--tapis); }
.nom-equipe { font-weight: 700; }
.joueurs { font-size: 14px; color: #444; }
.vs { font-size: 12px; font-weight: 700; color: #777; text-transform: uppercase; }
.pages { display: flex; gap: 6px; margin-top: 12px; }
.page { border: 1px solid #ccc; background: #fff; border-radius: 6px; padding: 4px 10px; cursor: pointer; }
.page.active { background: var(--tapis); color: #fff; border-color: var(--tapis); }
.victoire { text-align: center; }
.victoire h1 { color: var(--tapis); }
.victoire .coupe { font-size: 56px; line-height: 1; margin-bottom: 8px; }
.victoire .gagnants { font-size: 18px; font-weight: 700; }

/* ---------- Boutons, popins, toasts ---------- */
.btn { border: 0; border-radius: 8px; padding: 10px 18px; font-weight: 700; cursor: pointer; background: var(--tapis); color: #fff; font-size: 15px; font-family: inherit; }
.btn:hover { filter: brightness(1.08); }
.btn.secondaire { background: #d9d2c0; color: var(--texte); }
.btn.mini { padding: 4px 10px; font-size: 13px; background: rgba(255,255,255,.15); }
.btn.petit { padding: 5px 12px; font-size: 13px; }
.vs .regarder { display: block; margin: 6px auto 0; text-transform: none; }
.btn.couleur { font-size: 28px; padding: 6px 16px; background: #fff; color: var(--texte); border: 2px solid #ccc; }
.btn.couleur.rouge { color: var(--rouge); }
.boutons { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin: 10px 0 0; }
.voile { position: fixed; inset: 0; background: rgba(0,0,0,.55); display: flex; align-items: center; justify-content: center; z-index: 50; animation: apparait .18s ease-out; }
.popin { background: var(--creme); border-radius: 14px; padding: 22px 28px; text-align: center; min-width: 280px; max-width: 92vw; box-shadow: 0 18px 50px rgba(0,0,0,.4); animation: surgit .22s ease-out; }
.popin h2 { margin: 0 0 8px; font-size: 20px; }
.popin p { margin: 6px 0; }
.gros { font-size: 48px; font-weight: 800; margin: 0; color: var(--tapis); }
.duel { display: flex; justify-content: center; gap: 24px; font-size: 18px; }
.duel b { font-size: 26px; }
.total { color: #555; font-size: 14px; }
.ret-carte { display: flex; justify-content: center; margin: 8px 0; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: #222; color: #fff; padding: 10px 16px; border-radius: 8px; font-size: 14px; z-index: 60; max-width: 90vw; animation: apparait .2s ease-out; }
@keyframes apparait { from { opacity: 0; } to { opacity: 1; } }
@keyframes surgit { from { transform: scale(.92); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- Table de jeu ---------- */
.plateau { flex: 1; display: flex; flex-direction: column; max-width: 980px; width: 100%; margin: 0 auto; }
.bandeau { display: flex; align-items: center; gap: 10px; color: var(--creme); padding: 4px 6px 8px; font-size: 14px; flex-wrap: wrap; }
.bandeau b { font-size: 18px; }
.sc.obj { opacity: .7; }
.sc.atout { font-weight: 700; background: rgba(255,255,255,.12); padding: 2px 8px; border-radius: 6px; }
.sc.atout.rouge { color: #ffb4a8; }
.sc.spect { font-style: italic; opacity: .8; }
.bandeau .btn { margin-left: auto; }

/* Tapis : feutre émeraude avec léger tissage, lumière douce en haut, liseré doré (repris du prototype enjeu-phr) */
.tapis {
  position: relative; flex: 1; min-height: 540px; border-radius: 26px;
  background:
    repeating-linear-gradient(45deg, rgba(255,255,255,.02) 0 2px, rgba(0,0,0,0) 2px 7px),
    radial-gradient(ellipse at 50% 28%, rgba(255,255,255,.09) 0%, rgba(255,255,255,0) 55%),
    radial-gradient(ellipse at 50% 46%, #35805A 0%, var(--tapis) 45%, var(--tapis-fonce) 78%, #153D28 100%);
  box-shadow: inset 0 0 0 1.5px rgba(246,201,69,.45), inset 0 0 0 6px rgba(0,0,0,.16), inset 0 0 90px rgba(0,0,0,.26), 0 12px 30px rgba(16,22,28,.3);
}
.tapis::before {
  content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 160 160'%3E%3Cg fill='none' stroke='%23FFFFFF' stroke-opacity='.07' stroke-width='3'%3E%3Ccircle cx='80' cy='80' r='74'/%3E%3Ccircle cx='80' cy='80' r='66' stroke-opacity='.045'/%3E%3Ccircle cx='80' cy='57' r='18'/%3E%3Ccircle cx='62' cy='82' r='18'/%3E%3Ccircle cx='98' cy='82' r='18'/%3E%3Cpath d='M80 78 Q77 102 66 112 L94 112 Q83 102 80 78 Z'/%3E%3C/g%3E%3C/svg%3E") center 46% / 220px auto no-repeat;
}
.attente { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: var(--creme); font-size: 18px; }

.siege { position: absolute; display: flex; flex-direction: column; align-items: center; gap: 5px; }
.siege-sud { left: 50%; bottom: 8px; transform: translateX(-50%); width: 100%; }
.siege-nord { left: 50%; top: 12px; transform: translateX(-50%); }
.siege-est { right: 14px; top: 50%; transform: translateY(-60%); }
.siege-ouest { left: 14px; top: 50%; transform: translateY(-60%); }
.identite { position: relative; display: flex; align-items: center; gap: 6px; background: #FFFDF7; color: var(--texte); padding: 4px 10px 4px 5px; border-radius: 20px; font-size: 13px; white-space: nowrap; box-shadow: 0 2px 6px rgba(0,0,0,.3); transition: box-shadow .2s; }
.siege.tour .identite { box-shadow: 0 0 0 2px var(--or), 0 0 14px var(--or); }
.siege.remporte .identite { background: var(--or); }
.siege-est .identite { background: #FDE9C8; }
.siege-nord .identite { background: #DCEDFA; }
.siege-ouest .identite { background: #E1F3DC; }
.avatar { width: 22px; height: 22px; border-radius: 50%; background: radial-gradient(circle at 35% 35%, #ffe08a, #c9972a); display: inline-block; flex: none; box-shadow: inset 0 0 0 1px rgba(0,0,0,.15); }
.pseudo { font-weight: 700; }
.pts { background: rgba(0,0,0,.12); border-radius: 10px; font-size: 11px; padding: 1px 7px; font-weight: 700; }
.badge { background: var(--or); color: #5A4300; border-radius: 10px; padding: 0 6px; font-size: 11px; font-weight: 700; }
.badge.atout { background: #fff; font-size: 14px; color: #26303B; box-shadow: 0 1px 3px rgba(0,0,0,.3); }
.badge.atout.rouge { color: var(--rouge); }
.chrono { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: conic-gradient(var(--or) var(--pct), rgba(0,0,0,.12) 0); color: #111; font-weight: 800; font-size: 11px; }
.bulle { background: #fff; color: var(--texte); padding: 4px 10px; border-radius: 12px; font-size: 13px; font-weight: 700; box-shadow: 0 2px 8px rgba(0,0,0,.3); animation: surgit .2s ease-out; max-width: 220px; white-space: normal; text-align: center; }
.bulle.emoji { font-size: 26px; padding: 2px 10px; }

/* Dos des cartes adverses : nord = rangée debout ; est/ouest = cartes couchées, empilées */
.dos-main { display: flex; }
.dos-main span { width: 34px; height: 48px; border-radius: 5px; margin-left: -22px; border: 1.5px solid #fff;
  background: repeating-linear-gradient(45deg, rgba(255,255,255,.3) 0 1.5px, transparent 1.5px 7px), repeating-linear-gradient(-45deg, rgba(255,255,255,.3) 0 1.5px, transparent 1.5px 7px), linear-gradient(165deg, #4376C4, #2C5390);
  box-shadow: 0 1px 4px rgba(0,0,0,.35); }
.dos-main span:first-child { margin-left: 0; }
.siege-est .dos-main, .siege-ouest .dos-main { flex-direction: column; }
.siege-est .dos-main span, .siege-ouest .dos-main span { margin-left: 0; margin-top: -32px; width: 48px; height: 34px; }
.siege-est .dos-main span:first-child, .siege-ouest .dos-main span:first-child { margin-top: 0; }

.centre { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); display: flex; flex-direction: column; align-items: center; gap: 8px; }
.retourne { background: rgba(0,0,0,.3); border-radius: 12px; padding: 8px 14px; text-align: center; color: var(--creme); animation: surgit .25s ease-out; }
.ret-titre { font-weight: 800; margin-bottom: 4px; }
.pli { position: relative; width: 230px; height: 170px; }
.pli .posee { position: absolute; left: 50%; top: 50%; margin-left: calc(var(--carte-l) / -2); margin-top: calc(var(--carte-h) / -2); transition: transform .45s ease-in, opacity .45s ease-in; }
.pli .pos-sud { transform: translateY(22%) rotate(3deg); }
.pli .pos-nord { transform: translateY(-26%) rotate(-5deg); }
.pli .pos-est { transform: translateX(55%) rotate(9deg); }
.pli .pos-ouest { transform: translateX(-55%) rotate(-8deg); }
/* arrivée d'une carte depuis le siège du joueur */
.pli .arrive-sud { animation: arrive-sud .32s ease-out; }
.pli .arrive-nord { animation: arrive-nord .32s ease-out; }
.pli .arrive-est { animation: arrive-est .32s ease-out; }
.pli .arrive-ouest { animation: arrive-ouest .32s ease-out; }
@keyframes arrive-sud { from { transform: translateY(260px) scale(.9); } to { transform: translateY(22%) rotate(3deg); } }
@keyframes arrive-nord { from { transform: translateY(-240px) scale(.8); } to { transform: translateY(-26%) rotate(-5deg); } }
@keyframes arrive-est { from { transform: translateX(320px) scale(.8); } to { transform: translateX(55%) rotate(9deg); } }
@keyframes arrive-ouest { from { transform: translateX(-320px) scale(.8); } to { transform: translateX(-55%) rotate(-8deg); } }
/* ramassage du pli : les cartes glissent vers le gagnant */
.pli .vers-sud { transform: translateY(260px) scale(.7); opacity: 0; }
.pli .vers-nord { transform: translateY(-240px) scale(.7); opacity: 0; }
.pli .vers-est { transform: translateX(320px) scale(.7); opacity: 0; }
.pli .vers-ouest { transform: translateX(-320px) scale(.7); opacity: 0; }

/* hauteur fixe : la barre de chat ne bouge pas quand la main est vide entre deux donnes */
.main { display: flex; justify-content: center; gap: 6px; padding: 6px 0 2px; flex-wrap: nowrap; min-height: calc(var(--carte-h) + 8px); }

/* Cartes */
.carte { position: relative; width: var(--carte-l); height: var(--carte-h); border-radius: 7px; background: #fff; border: 1px solid #c9c2b2; box-shadow: 0 2px 6px rgba(0,0,0,.35); user-select: none; flex: 0 0 auto; }
.carte svg { display: block; width: 100%; height: 100%; }
.carte.rouge { color: var(--rouge); }
.carte.noire { color: #26303B; }
.carte.est-atout { box-shadow: 0 0 0 2px var(--or), 0 2px 6px rgba(0,0,0,.35); }
.carte.jouable { cursor: pointer; transition: transform .12s; }
/* soulèvement au survol : seulement avec une souris (au doigt, la carte resterait levée) */
@media (hover: hover) { .carte.jouable:hover { transform: translateY(-12px); } }
.carte.inerte { opacity: .45; }
.carte.dos { border: 2px solid #fff; background: repeating-linear-gradient(45deg, rgba(255,255,255,.3) 0 1.5px, transparent 1.5px 7px), repeating-linear-gradient(-45deg, rgba(255,255,255,.3) 0 1.5px, transparent 1.5px 7px), linear-gradient(165deg, #4376C4, #2C5390); }
.carte.distribuee { animation: distribuee .35s ease-out both; }
@keyframes distribuee { from { transform: translateY(-140px) rotate(-12deg); opacity: 0; } to { transform: none; opacity: 1; } }

/* Chat : émojis + message court */
.chat { display: flex; align-items: center; gap: 6px; padding: 8px 4px 0; flex-wrap: wrap; }
.chat .emoji { border: 0; background: rgba(255,255,255,.12); border-radius: 50%; width: 36px; height: 36px; font-size: 20px; cursor: pointer; }
.chat .emoji:hover { background: rgba(255,255,255,.25); }
#form-chat { display: flex; gap: 6px; flex: 1; min-width: 200px; }
#champ-chat { flex: 1; border: 0; border-radius: 8px; padding: 6px 10px; font: inherit; font-size: 14px; }

@media (max-width: 640px) {
  :root { --carte-l: 50px; --carte-h: 70px; }
  .match { grid-template-columns: 1fr; }
  .vs { text-align: center; }
  .tapis { min-height: 520px; border-radius: 18px; }
  .siege-est { right: 6px; top: 22%; transform: none; align-items: flex-end; max-width: 46%; }
  .siege-ouest { left: 6px; top: 22%; transform: none; align-items: flex-start; max-width: 46%; }
  .siege-est .identite, .siege-ouest .identite { font-size: 12px; padding: 3px 8px 3px 4px; }
  .siege-est .pseudo, .siege-ouest .pseudo { max-width: 64px; overflow: hidden; text-overflow: ellipsis; }
  .siege-est .pts, .siege-ouest .pts { display: none; }
  .siege-est .dos-main, .siege-ouest .dos-main { flex-direction: row; }
  .siege-est .dos-main span, .siege-ouest .dos-main span { width: 20px; height: 30px; margin: 0 0 0 -9px; }
  .siege-est .dos-main span:first-child, .siege-ouest .dos-main span:first-child { margin-left: 0; }
  .centre { top: 56%; }
  .siege-nord { top: 8px; }
  .pli { width: 180px; height: 130px; }
  .main { padding: 6px 4px 2px; gap: 0; }
  .main .carte + .carte { margin-left: -14px; }
  .main .carte.jouable:hover { z-index: 2; }
  .bandeau { gap: 8px; font-size: 13px; }
  .chat .emoji { width: 32px; height: 32px; font-size: 18px; }
}
