:root {
  --bg: #15102b;
  --bg2: #2a1d4f;
  --gold: #f2c14e;
  --gold-2: #e8a33d;
  --ink: #fdf8ef;
  --muted: #b8b0d4;
  --ok: #3fae6a;
  --ko: #e0525a;
  --paper: #fffdf8;
  --radius: 14px;
  --serif: "Playfair Display", "DejaVu Serif", Georgia, "Times New Roman", serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { margin: 0; height: 100%; }
body {
  font-family: var(--sans);
  color: var(--ink);
  background:
    radial-gradient(1200px 700px at 15% -10%, rgba(242, 193, 78, .18), transparent 60%),
    radial-gradient(900px 600px at 110% 110%, rgba(225, 85, 84, .16), transparent 60%),
    linear-gradient(160deg, var(--bg2), var(--bg) 60%);
  background-attachment: fixed;
}

.title { font-family: var(--serif); font-weight: 700; margin: 0; letter-spacing: .01em; }
.title em { color: var(--gold); font-style: italic; }
.title.small { font-size: 1.5rem; }
.title.big { font-size: clamp(3rem, 9vw, 7.5rem); line-height: 1; }
.kicker { text-transform: uppercase; letter-spacing: .35em; color: var(--gold); margin: 0 0 1rem; font-weight: 600; }
.lead { font-size: clamp(1.1rem, 2.2vw, 1.7rem); margin: 1.5rem 0 .5rem; }
.muted { color: var(--muted); }
.row { display: flex; gap: .75rem; align-items: center; justify-content: center; flex-wrap: wrap; }

/* ---------- Boutons ---------- */
.btn {
  font: inherit; font-weight: 600; border: 0; cursor: pointer; text-decoration: none;
  padding: .7rem 1.3rem; border-radius: 999px; color: var(--ink);
  transition: transform .15s, box-shadow .15s, background .15s, opacity .15s;
}
.btn:hover { transform: translateY(-1px); }
.btn:disabled { opacity: .4; cursor: not-allowed; transform: none; }
.btn.primary { background: linear-gradient(180deg, var(--gold), var(--gold-2)); color: #2b1d05; box-shadow: 0 6px 20px rgba(242, 193, 78, .3); }
.btn.ghost { background: rgba(255, 255, 255, .08); border: 1px solid rgba(255, 255, 255, .18); }
.btn.big { font-size: 1.35rem; padding: .9rem 2.2rem; }
.btn.pulse { animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 12px rgba(242, 193, 78, 0), 0 0 30px rgba(242, 193, 78, .7); transform: scale(1.04); } }

.icon-btn {
  font: inherit; font-size: 1.2rem; line-height: 1; cursor: pointer; text-decoration: none;
  width: 2.4rem; height: 2.4rem; display: inline-grid; place-items: center;
  border-radius: 50%; border: 1px solid rgba(255, 255, 255, .18);
  background: rgba(255, 255, 255, .06); color: var(--ink);
}
.icon-btn:hover { background: rgba(255, 255, 255, .14); }

input:not([type=checkbox]) {
  font: inherit; color: var(--ink); background: rgba(255, 255, 255, .07);
  border: 1px solid rgba(255, 255, 255, .2); border-radius: 10px; padding: .65rem .9rem;
}
input:focus { outline: 2px solid var(--gold); outline-offset: 1px; }

/* ---------- Barre du haut ---------- */
.bar {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: .9rem 1.5rem; height: 4.5rem;
}
.bar .status { display: flex; gap: 1.5rem; align-items: center; font-size: 1.25rem; font-weight: 600; }
.bar .tools { display: flex; gap: .5rem; align-items: center; }
.score { background: rgba(242, 193, 78, .15); color: var(--gold); padding: .3rem .9rem; border-radius: 999px; transition: transform .3s; }
.score::before { content: "★ "; }
.score.bump { transform: scale(1.35); }

/* ---------- Connexion ---------- */
.center-page { display: grid; place-items: center; min-height: 100vh; padding: 1rem; }
.login-box { display: grid; gap: 1rem; width: min(360px, 100%); text-align: center; }
.login-box .title { font-size: 2.6rem; margin-bottom: 1rem; }
.error { color: var(--ko); min-height: 1.2em; margin: 0; }

/* ---------- Jeu ---------- */
body.game { overflow: hidden; height: 100dvh; display: flex; flex-direction: column; user-select: none; -webkit-user-select: none; }
.screen { flex: 1; min-height: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 0 1.5rem 1.5rem; }
.hero { text-align: center; }
.hero .row { margin-top: 2.5rem; }

/* Plateau : prénoms et boutons gardent leur hauteur, les cartes prennent ce qui reste
   (taille calculée en JS d'après la place réellement disponible, cf. layoutCards). */
#screenBoard { justify-content: flex-start; gap: .8rem; }
#screenBoard > .tray, #screenBoard > .actions { flex: none; }

.cards {
  --gap: clamp(1rem, 2.5vw, 2.5rem);
  /* La carte (photo 3:4 + bandeau prénom) doit tenir en largeur ET en hauteur. */
  --cw: 200px;
  flex: 1; min-height: 0; width: 100%;
  display: flex; flex-wrap: wrap; gap: var(--gap); justify-content: center; align-content: center;
  perspective: 1600px;
}

.card {
  width: var(--cw); background: var(--paper); border-radius: var(--radius); padding: calc(var(--cw) * .045);
  box-shadow: 0 18px 40px rgba(0, 0, 0, .45); color: #2a2240; cursor: pointer;
  transform: rotate(calc((var(--i) - 1.5) * 1.2deg));
  animation: deal .6s cubic-bezier(.2, .9, .3, 1.2) both; animation-delay: calc(var(--i) * 90ms);
  transition: box-shadow .2s, transform .2s;
}
.card.over { transform: scale(1.04) rotate(0); box-shadow: 0 0 0 4px var(--gold), 0 18px 40px rgba(0, 0, 0, .45); }
@keyframes deal { from { opacity: 0; transform: translateY(40px) rotate(-6deg) scale(.9); } }

.flip { position: relative; aspect-ratio: 3 / 4; transform-style: preserve-3d; transition: transform .8s cubic-bezier(.4, .1, .2, 1); }
.card.revealed .flip { transform: rotateY(180deg); }
.face { position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden; border-radius: calc(var(--radius) * .6); overflow: hidden; background: #ddd; }
.face.back { transform: rotateY(180deg); }
.face img { width: 100%; height: 100%; object-fit: cover; display: block; pointer-events: none; }

.slot {
  height: calc(var(--cw) * .2); min-height: 3.2rem; margin-top: calc(var(--cw) * .04);
  border: 2px dashed #d6cfe6; border-radius: 10px;
  display: grid; place-items: center; transition: background .3s, border-color .3s;
}
.slot .placeholder { font-family: var(--serif); font-size: 1.8rem; color: #c9c0dc; }
.slot:has(.chip) { border-color: transparent; }
.card.revealed .slot { border: 0; color: #fff; }
.card.ok .slot { background: var(--ok); }
.card.ko .slot { background: var(--ko); }
.card.neutral .slot { background: linear-gradient(180deg, #ffe08f, var(--gold)); color: #2b1d05; }

/* Bandeau de réponse : tout doit tenir dans la hauteur fixe du bandeau, quelle que soit la
   taille de la carte (police proportionnelle à la carte, une ligne par élément, « … » si besoin). */
.answer {
  display: flex; align-items: center; justify-content: center; column-gap: .3em; flex-wrap: wrap;
  width: 100%; padding: 0 .35rem; text-align: center; line-height: 1.05;
  font-size: clamp(.75rem, calc(var(--cw) * .09), 2rem);
  animation: pop .45s cubic-bezier(.2, .9, .3, 1.4);
}
.answer .mark { font-size: 1.15em; font-weight: 800; flex: none; }
.answer .real { font-family: var(--serif); font-weight: 700; min-width: 0; max-width: calc(100% - 1.6em); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.answer .wrong { flex-basis: 100%; text-decoration: line-through; opacity: .85; font-size: .62em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.answer .wrong + .real { max-width: 100%; }
@keyframes pop { from { transform: scale(.4); opacity: 0; } }

.tray { min-height: 4.2rem; display: flex; flex-wrap: wrap; gap: .9rem; justify-content: center; align-items: center; padding: .5rem 1rem; border-radius: 999px; }
.tray .hint { margin: 0; font-size: 1.15rem; }

/* Tuile « photo adulte + prénom ». Dans la réserve : photo au-dessus du prénom ;
   posée sur une carte : pastille compacte miniature + prénom. */
.chip {
  --tile: clamp(70px, min(10vw, 15vh), 160px);
  font: 700 clamp(.95rem, 1.5vw, 1.35rem) var(--serif); cursor: grab; touch-action: none;
  display: inline-flex; flex-direction: column; align-items: center; gap: .3rem;
  padding: .35rem .35rem .4rem; border-radius: 12px; border: 0; color: #2b1d05;
  background: linear-gradient(180deg, #ffe08f, var(--gold)); box-shadow: 0 6px 16px rgba(0, 0, 0, .35);
  transition: transform .15s, box-shadow .15s, opacity .15s; white-space: nowrap;
}
.chip img { width: var(--tile); aspect-ratio: 3 / 4; object-fit: cover; border-radius: 8px; display: block; pointer-events: none; background: rgba(0, 0, 0, .15); }
.chip .nm { max-width: var(--tile); overflow: hidden; text-overflow: ellipsis; }
.chip:hover { transform: translateY(-2px); }
.chip.selected { box-shadow: 0 0 0 4px #fff, 0 0 24px var(--gold); transform: scale(1.08); }
.chip.dragging { opacity: .25; }
.chip.ghost { position: fixed; left: 0; top: 0; z-index: 50; pointer-events: none; cursor: grabbing; box-shadow: 0 14px 30px rgba(0, 0, 0, .5); }
.slot .chip {
  font-size: clamp(.9rem, calc(var(--cw) * .075), 1.5rem); max-width: 100%;
  flex-direction: row; gap: .45rem; padding: .2rem .8rem .2rem .2rem; border-radius: 999px;
}
.slot .chip img { width: auto; height: max(2.1rem, calc(var(--cw) * .2 - .7rem)); border-radius: 50%; aspect-ratio: 1; }
.slot .chip .nm { max-width: calc(var(--cw) * .55); }

.actions { display: flex; flex-wrap: wrap; gap: .8rem 1rem; align-items: center; justify-content: center; }

#confetti { position: fixed; inset: 0; width: 100vw; height: 100vh; pointer-events: none; z-index: 100; }

/* ---------- Admin ---------- */
.admin-main { max-width: 1200px; margin: 0 auto; padding: 0 1.5rem 3rem; }
.admin .bar { height: auto; flex-wrap: wrap; }
.panel { background: rgba(255, 255, 255, .05); border: 1px solid rgba(255, 255, 255, .1); border-radius: var(--radius); padding: 1.2rem; margin-bottom: 1.5rem; display: grid; gap: 1rem; }
.panel form { justify-content: flex-start; }
.panel form input { flex: 1; min-width: 200px; }
.dropzone { display: block; border: 2px dashed rgba(242, 193, 78, .5); border-radius: var(--radius); padding: 1.2rem; text-align: center; cursor: pointer; line-height: 1.6; }
.dropzone.over { background: rgba(242, 193, 78, .1); }
.dropzone.loading, .ph.loading { pointer-events: none; }
.ph.loading { opacity: .5; }
code { background: rgba(255, 255, 255, .1); padding: .1rem .4rem; border-radius: 6px; }
.report:empty { display: none; }
.report { font-size: .95rem; display: grid; gap: .8rem; }
.report .sum { margin: 0; font-weight: 600; font-size: 1.05rem; }
.report h3 { margin: 0; font-size: 1rem; }
.report details summary { cursor: pointer; color: var(--muted); }
.report .list { margin: .4rem 0 0; padding: 0; list-style: none; max-height: 14rem; overflow: auto; }
.report .ok { color: #8fe0a9; }
.report .ko { color: #ff9a9f; }
.pairs { border-collapse: collapse; width: 100%; max-width: 560px; }
.pairs th { text-align: left; color: var(--muted); font-weight: 500; padding: .3rem .5rem; }
.pairs td { padding: .3rem .5rem; border-top: 1px solid rgba(255, 255, 255, .08); color: var(--ink); }
.pairs tr.ko td:first-child { color: #ffcf7a; }
.pairs tr.ko td:first-child::before { content: "⚠ "; }
.pairs img { width: 42px; height: 56px; object-fit: cover; border-radius: 6px; display: block; }
.pairs .miss { color: #ff9a9f; font-size: .85rem; }
.progress { position: relative; height: 1.6rem; margin-top: .8rem; border-radius: 999px; background: rgba(255, 255, 255, .08); overflow: hidden; }
.progress div { position: absolute; inset: 0 auto 0 0; width: 0; background: linear-gradient(90deg, var(--gold-2), var(--gold)); transition: width .2s; }
.progress span { position: relative; font-size: .85rem; line-height: 1.6rem; color: #fff; text-shadow: 0 1px 2px #000; }
.dropzone.loading { opacity: 1; }
.dropzone.loading > :not(.progress) { opacity: .5; }

.guest-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1rem; }
.guest { background: rgba(255, 255, 255, .06); border: 1px solid rgba(255, 255, 255, .1); border-radius: var(--radius); padding: .8rem; }
.guest.incomplete { border-color: rgba(242, 193, 78, .55); }
.guest.disabled { opacity: .5; }
.guest-head { display: flex; gap: .5rem; align-items: center; margin-bottom: .7rem; }
.guest-head .name { flex: 1; min-width: 0; font-weight: 700; }
.toggle { font-size: .85rem; color: var(--muted); white-space: nowrap; display: flex; gap: .3rem; align-items: center; }
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; }
.ph { position: relative; aspect-ratio: 3 / 4; border-radius: 10px; overflow: hidden; cursor: pointer; border: 2px dashed rgba(255, 255, 255, .25); display: grid; place-items: center; }
.ph.over { border-color: var(--gold); }
.ph img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: none; }
.ph.has { border-style: solid; border-color: transparent; }
.ph.has img { display: block; }
.ph .lbl { font-size: .8rem; color: var(--muted); text-align: center; padding: .3rem; z-index: 1; }
.ph.has .lbl { position: absolute; bottom: 0; left: 0; right: 0; background: rgba(0, 0, 0, .55); color: #fff; }
.ph:not(.has) .lbl::after { content: "\A+ ajouter"; white-space: pre; color: var(--gold); }
.ph .rm { position: absolute; top: .3rem; right: .3rem; width: 1.8rem; height: 1.8rem; font-size: .8rem; background: rgba(0, 0, 0, .6); z-index: 2; }
.ph:not(.has) .rm, .ph:not(.has) .crop { display: none; }
.ph .crop { position: absolute; top: .3rem; left: .3rem; width: 1.8rem; height: 1.8rem; font-size: .85rem; background: rgba(0, 0, 0, .6); z-index: 2; }

/* Écran en portrait (téléphone, tablette) : en-tête et prénoms plus compacts. */
@media (max-aspect-ratio: 1 / 1) {
  .bar { padding: .6rem 1rem; }
  .bar .status { gap: .6rem; font-size: 1rem; white-space: nowrap; }
  .game .title.small { font-size: 1.15rem; white-space: nowrap; }
  .screen { padding: 0 .8rem .8rem; }
  .cards { --gap: .9rem; }
  .slot { min-height: 2.6rem; }
  .tray { gap: .5rem; padding: 0; }
  .tray .chip { --tile: min(calc((100vw - 4rem) / 4 - .7rem), 19vh, 140px); font-size: .9rem; padding: .25rem .25rem .3rem; }
  .btn.big { font-size: 1.15rem; padding: .75rem 1.6rem; }
}
@media (max-width: 480px) { .game .bar .title.small { display: none; } }

/* ---------- Recherche, doublons, fusion ---------- */
.toolbar { display: flex; gap: 1rem; align-items: center; margin-bottom: 1rem; flex-wrap: wrap; }
.toolbar input { flex: 1; min-width: 220px; max-width: 420px; }
.empty { text-align: center; padding: 2rem; }
.btn.small { padding: .4rem .9rem; font-size: .9rem; }
.dupes { border-color: rgba(242, 193, 78, .55); }
.dupes h2 { margin: 0; font-size: 1.05rem; color: var(--gold); }
.dupes ul { list-style: none; margin: 0; padding: 0; display: grid; gap: .5rem; }
.dupes li { display: flex; gap: 1rem; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.merge-banner {
  position: sticky; top: .5rem; z-index: 5; display: flex; gap: 1rem; align-items: center; justify-content: space-between;
  background: #3a2a10; border: 1px solid var(--gold); border-radius: var(--radius); padding: .6rem 1rem; margin-bottom: 1rem;
}
.guest { display: flex; flex-direction: column; gap: .6rem; }
.guest-head { margin-bottom: 0; }
.guest.merge-source { outline: 3px solid var(--gold); }
.guest .merge-here { width: 100%; }
.merge-dialog {
  width: min(560px, calc(100vw - 2rem)); color: var(--ink); background: #221a40;
  border: 1px solid rgba(255, 255, 255, .15); border-radius: var(--radius); padding: 1.4rem;
}
.merge-dialog::backdrop { background: rgba(5, 3, 15, .7); }
.merge-dialog h2 { margin: 0; font-family: var(--serif); }
.merge-dialog p { margin: .3rem 0 1rem; }
.merge-dialog fieldset { border: 0; padding: 0; margin: 0 0 1rem; }
.merge-dialog legend { font-weight: 600; margin-bottom: .4rem; }
.choices { display: flex; gap: .6rem; flex-wrap: wrap; }
.choice { display: flex; gap: .45rem; align-items: center; cursor: pointer; padding: .45rem .7rem; border-radius: 10px;
  background: rgba(255, 255, 255, .06); border: 1px solid rgba(255, 255, 255, .12); }
.choice:has(input:checked) { border-color: var(--gold); background: rgba(242, 193, 78, .12); }
.choice input[type=radio] { accent-color: var(--gold); }
.choice input:not([type=radio]) { padding: .3rem .5rem; width: 11rem; }
.thumb { display: grid; gap: .2rem; justify-items: center; }
.thumb img { width: 84px; height: 112px; object-fit: cover; border-radius: 8px; }
.thumb small { color: var(--muted); max-width: 90px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row.end { justify-content: flex-end; }

/* ---------- Multijoueur ---------- */
.pill { background: rgba(255, 255, 255, .08); padding: .3rem .9rem; border-radius: 999px; font-size: 1rem; }
.pill.warn { background: rgba(224, 82, 90, .25); color: #ffb3b7; }
.linkish { background: none; border: 0; color: var(--muted); text-decoration: underline; cursor: pointer; font: inherit; font-size: .9rem; }

.lobby { display: flex; gap: clamp(1.5rem, 5vw, 5rem); align-items: center; justify-content: center; width: 100%; flex-wrap: wrap; }
.join { text-align: center; display: grid; justify-items: center; gap: .4rem; }
.join .kicker { margin: 0; }
.qr { width: min(42vh, 80vw); aspect-ratio: 1; background: #fff; border-radius: 18px; padding: .6rem; box-shadow: 0 20px 50px rgba(0, 0, 0, .45); }
.join-url { font-size: clamp(1.1rem, 2.4vw, 1.8rem); font-weight: 700; margin: .6rem 0 0; color: var(--gold); word-break: break-all; }
.join p { margin: 0; }
.code { font-size: 1.3em; letter-spacing: .15em; color: var(--ink); }
.players-box { min-width: min(420px, 90vw); max-width: 640px; flex: 1; }
.players-box .title { font-size: clamp(2rem, 4vw, 3.2rem); }
.players-box .row { justify-content: flex-start; margin-top: 1.2rem; }
.players { list-style: none; padding: 0; margin: 1rem 0 0; display: flex; flex-wrap: wrap; gap: .5rem; max-height: 46vh; overflow: auto; }
.players li { display: flex; align-items: center; gap: .45rem; background: rgba(255, 255, 255, .08); border-radius: 999px; padding: .35rem .5rem .35rem .8rem; font-size: 1.1rem; animation: pop .35s ease-out; }
.players li.off { opacity: .5; }
.players .dot { width: .55rem; height: .55rem; border-radius: 50%; background: var(--ok); }
.players li.off .dot { background: #888; }
.players .kick { border: 0; background: none; color: var(--muted); cursor: pointer; font-size: 1.1rem; line-height: 1; padding: 0 .2rem; }
.players .kick:hover { color: var(--ko); }

.progress-line { flex: none; width: min(600px, 80%); height: .5rem; border-radius: 999px; background: rgba(255, 255, 255, .1); overflow: hidden; }
.progress-line div { height: 100%; width: 0; background: linear-gradient(90deg, var(--gold-2), var(--gold)); transition: width .4s; }
.answer .stat { flex-basis: 100%; font-size: clamp(.6rem, .45em, .85rem); opacity: .9; white-space: nowrap; }
.leader-strip { flex: none; list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: .6rem; justify-content: center; }
.leader-strip li { display: flex; gap: .45rem; align-items: baseline; background: rgba(255, 255, 255, .08); border-radius: 999px; padding: .4rem 1rem; font-size: 1.15rem; animation: pop .4s ease-out both; }
.leader-strip .who { font-weight: 700; }
.leader-strip .pts { color: var(--gold); }
.leader-strip .gain { color: #8fe0a9; font-size: .9rem; }
.mini-join { position: fixed; right: 1rem; bottom: 1rem; display: flex; align-items: center; gap: .6rem; background: rgba(0, 0, 0, .35); padding: .4rem .7rem .4rem .4rem; border-radius: 12px; font-size: .85rem; color: var(--muted); }
.mini-join img { width: 72px; height: 72px; background: #fff; border-radius: 8px; }

.final { width: min(900px, 100%); }
.podium { display: flex; gap: 1rem; justify-content: center; align-items: flex-end; margin: 1.5rem 0; }
.podium .step { display: grid; justify-items: center; gap: .4rem; width: min(220px, 30vw); animation: deal .7s cubic-bezier(.2, .9, .3, 1.2) both; }
.podium .s1 { animation-delay: .6s; } .podium .s2 { animation-delay: .3s; }
.podium .who { font-family: var(--serif); font-weight: 700; font-size: clamp(1.1rem, 2.6vw, 2rem); text-align: center; }
.podium .pts { color: var(--gold); font-weight: 600; }
.podium .block { width: 100%; display: grid; place-items: center; font-size: 2.4rem; border-radius: 14px 14px 0 0; background: linear-gradient(180deg, rgba(242, 193, 78, .35), rgba(242, 193, 78, .08)); }
.podium .s1 .block { height: 11rem; } .podium .s2 .block { height: 8rem; } .podium .s3 .block { height: 6rem; }
.ranking { list-style: none; padding: 0; margin: 0 auto 1.5rem; max-width: 520px; max-height: 32vh; overflow: auto; text-align: left; }
.ranking li { display: flex; gap: .8rem; padding: .45rem .8rem; border-bottom: 1px solid rgba(255, 255, 255, .08); }
.ranking li.me { background: rgba(242, 193, 78, .15); border-radius: 10px; }
.ranking .rank { width: 2.5rem; color: var(--muted); }
.ranking .who { flex: 1; }
.ranking .pts { color: var(--gold); }

.player .bar { height: auto; min-height: 3.6rem; }
.player .me { font-weight: 700; font-family: var(--serif); font-size: 1.15rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 40vw; }
.player .score::before { content: "★ "; }
.play-status { flex: none; margin: 0; text-align: center; color: var(--muted); min-height: 2.6em; padding: 0 .5rem; }
.play-status.done { color: #8fe0a9; font-weight: 600; }
.spinner { width: 2.2rem; height: 2.2rem; margin: 2rem auto 0; border-radius: 50%; border: 3px solid rgba(255, 255, 255, .15); border-top-color: var(--gold); animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.player #screenJoin { justify-content: center; }
@media (max-aspect-ratio: 1 / 1) {
  .host .mini-join { display: none; }
}
.chip.static { cursor: default; }
.chip.static:hover { transform: none; }

/* ---------- Recadrage ---------- */
.crop-dialog { width: min(640px, calc(100vw - 1rem)); }
.crop-stage {
  position: relative; height: min(62vh, 560px); margin: .5rem 0; overflow: hidden; border-radius: 12px;
  background: #0b0818; touch-action: none; cursor: grab; user-select: none;
}
.crop-stage:active { cursor: grabbing; }
.crop-stage img { position: absolute; left: 0; top: 0; max-width: none; transform-origin: 0 0; pointer-events: none; }
.crop-frame {
  position: absolute; pointer-events: none; border: 2px solid var(--gold); border-radius: 6px;
  box-shadow: 0 0 0 9999px rgba(11, 8, 24, .72);
}
/* Grille des tiers */
.crop-frame i { position: absolute; background: rgba(255, 255, 255, .35); }
.crop-frame i:nth-child(1), .crop-frame i:nth-child(2) { top: 0; bottom: 0; width: 1px; }
.crop-frame i:nth-child(1) { left: 33.33%; } .crop-frame i:nth-child(2) { left: 66.66%; }
.crop-frame i:nth-child(3), .crop-frame i:nth-child(4) { left: 0; right: 0; height: 1px; }
.crop-frame i:nth-child(3) { top: 33.33%; } .crop-frame i:nth-child(4) { top: 66.66%; }
.crop-tools { display: flex; gap: .8rem; align-items: center; margin-bottom: 1rem; }
.crop-tools input[type=range] { flex: 1; accent-color: var(--gold); }
.row .spacer { flex: 1; }
.crop-dialog { max-height: calc(100dvh - 1rem); overflow: auto; }
.crop-dialog .row.end { flex-wrap: nowrap; }
@media (max-width: 520px) {
  .crop-dialog { padding: 1rem; }
  .crop-dialog h2 { font-size: 1.15rem; }
  .crop-dialog > p { display: none; }
  .crop-stage { height: min(56dvh, 480px); }
  .crop-dialog .row.end { gap: .4rem; }
  .crop-dialog .row.end .btn { padding: .6rem .9rem; font-size: .95rem; }
}



/* Classement à la demande (écran animateur) */
.ranking-dialog {
  width: min(760px, calc(100vw - 2rem)); max-height: calc(100dvh - 3rem); color: var(--ink);
  background: #221a40; border: 1px solid rgba(242, 193, 78, .4); border-radius: 18px; padding: 1.4rem 1.6rem;
  display: none; flex-direction: column;
}
.ranking-dialog[open] { display: flex; animation: pop .3s ease-out; }
.ranking-dialog::backdrop { background: rgba(5, 3, 15, .75); }
.ranking-head { display: flex; align-items: baseline; gap: 1rem; margin-bottom: .8rem; }
.ranking-head .title { font-size: clamp(1.6rem, 3vw, 2.4rem); }
.ranking-head .muted { flex: 1; }
.ranking.big { max-height: none; overflow: auto; margin: 0; max-width: none; font-size: clamp(1.05rem, 1.8vw, 1.45rem); }
.ranking.big li { align-items: center; padding: .55rem .8rem; }
.ranking.big .rank { width: 3rem; }
.ranking.big .dot { width: .5rem; height: .5rem; border-radius: 50%; background: var(--ok); flex: none; }
.ranking.big .dot.off { background: #777; }
.ranking.big .who { font-weight: 600; }
.ranking.big .gain { color: #8fe0a9; font-size: .8em; width: 2.5rem; text-align: right; }
.ranking.big li.top1 { background: rgba(242, 193, 78, .18); border-radius: 10px; }
.ranking.big li.top2, .ranking.big li.top3 { background: rgba(255, 255, 255, .06); border-radius: 10px; }

/* En-tête de l'écran animateur : sur écran étroit (téléphone, tablette en portrait), les
   compteurs passent sur une 2e ligne pour que les boutons restent accessibles. */
.host .bar { height: auto; min-height: 4.5rem; flex-wrap: wrap; row-gap: .5rem; }
.host .bar .status { flex-wrap: wrap; justify-content: center; row-gap: .4rem; }
.host .bar .tools { margin-left: auto; }
.host .bar .btn { white-space: nowrap; }
@media (max-width: 1000px) {
  .host .bar { padding: .6rem .8rem; }
  .host .bar .status { order: 3; flex-basis: 100%; gap: .4rem; font-size: .95rem; }
  .host .pill { padding: .25rem .7rem; font-size: .9rem; }
}
@media (max-width: 560px) {
  .host #btnRanking .lbl { display: none; }
  .host .bar .tools { gap: .35rem; }
}
/* Salle d'attente et fin de l'écran animateur : défilement vertical si l'écran est trop petit
   (le contenu reste centré quand il tient). */
.host #screenLobby, .host #screenEnd { overflow-y: auto; justify-content: safe center; padding-top: .5rem; }
@media (max-aspect-ratio: 1 / 1), (max-height: 600px) {
  .host .qr { width: min(34vh, 70vw); }
  .host .players-box .title { font-size: 1.8rem; }
  .host .podium .block { height: auto !important; min-height: 3rem; }
}

/* ---------- Navigation admin ---------- */
.admin-nav { display: flex; gap: .4rem; justify-content: center; margin: 0 auto 1.2rem; padding: 0 1rem; flex-wrap: wrap; }
.admin-nav a { color: var(--muted); text-decoration: none; padding: .5rem 1rem; border-radius: 999px; border: 1px solid transparent; }
.admin-nav a:hover { color: var(--ink); background: rgba(255, 255, 255, .06); }
.admin-nav a[aria-current=page] { color: var(--ink); background: rgba(242, 193, 78, .15); border-color: rgba(242, 193, 78, .5); }
.row.start { justify-content: flex-start; }
.row.between { justify-content: space-between; }
.danger { color: #ffb3b7; }

/* ---------- Composition des manches ---------- */
.rounds-page .mode { margin: 0; font-size: 1.05rem; }
.rounds-page .help, .small-note { margin: 0; font-size: .9rem; }
.warnings { list-style: none; margin: 0; padding: 0; color: #ffcf7a; font-size: .95rem; display: grid; gap: .2rem; }
.pool-panel h2, .round-head h2 { margin: 0; font-size: 1.1rem; }
.round-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 1rem; }
.round-card { margin: 0; gap: .6rem; }
.round-head { display: flex; align-items: center; gap: .5rem; }
.round-head .spacer { flex: 1; }
.round-head .count { color: var(--muted); font-size: .9rem; }
.round-head .count.warn { color: #ffcf7a; }
.round-head .icon-btn:disabled { opacity: .3; cursor: default; }
.drop { display: flex; flex-wrap: wrap; gap: .6rem; min-height: 7.5rem; padding: .6rem; border-radius: 12px;
  border: 2px dashed rgba(255, 255, 255, .12); align-items: flex-start; transition: background .15s, border-color .15s; }
.drop.over { border-color: var(--gold); background: rgba(242, 193, 78, .08); }
.empty-drop { margin: auto; }
.pick { width: 92px; display: grid; justify-items: center; gap: .25rem; padding: .3rem; border-radius: 10px; cursor: grab;
  background: rgba(255, 255, 255, .06); touch-action: none; user-select: none; position: relative; font-size: .85rem; text-align: center; }
.pick img { width: 80px; aspect-ratio: 3 / 4; object-fit: cover; border-radius: 7px; pointer-events: none; background: #333; }
.pick span { max-width: 84px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pick small { color: #ffcf7a; font-size: .7rem; }
.pick.unplayable { opacity: .55; }
.pick.selected { outline: 3px solid var(--gold); background: rgba(242, 193, 78, .15); }
.pick.dragging { opacity: .25; }
.pick.ghost { position: fixed; left: 0; top: 0; z-index: 50; pointer-events: none; box-shadow: 0 14px 30px rgba(0, 0, 0, .5); background: #2c2150; }
.pick.insert-before::before { content: ""; position: absolute; left: -.45rem; top: .3rem; bottom: .3rem; width: 3px; border-radius: 2px; background: var(--gold); }

/* ---------- Liste des parties ---------- */
.section-title { font-size: 1.15rem; margin: 1rem 0 .6rem; }
.game-card { margin-bottom: .8rem; gap: .4rem; }
.game-head { display: flex; align-items: center; gap: .7rem; flex-wrap: wrap; }
.game-head .code { font-size: 1.3rem; letter-spacing: .12em; }
.game-head .spacer { flex: 1; }
.badge { font-size: .85rem; padding: .2rem .7rem; border-radius: 999px; background: rgba(255, 255, 255, .08); color: var(--muted); }
.badge.live { background: rgba(63, 174, 106, .25); color: #8fe0a9; }
.game-card .meta, .podium-line { margin: 0; }
.game-card details summary { cursor: pointer; color: var(--muted); }
.game-card .ranking { margin: .4rem 0 0; max-height: 40vh; }
.hero a, #planInfo a { color: var(--gold); }
