/* =================================================================
   SOCLE COMMUN À TOUS LES JEUX
   -----------------------------------------------------------------
   Chaque jeu définit ses jetons dans son thème (theme-*.css), sous
   html[data-jeu="…"]. Les composants partagés ci-dessous n'utilisent
   que ces jetons : boutons, champs, code du salon, classement, bandeau.
   Les valeurs par défaut = Photomany (mur photo).
   ================================================================= */
:root {
    --fond: #F2F2F2;
    --fond-motif: none;
    --surface: #FFFFFF;
    --surface-encre: #000000;
    --encre: #000000;
    --encre-douce: #555555;
    --trait: #000000;
    --trait-epaisseur: 3px;
    --accent: #000000;
    --accent-encre: #FFFFFF;
    --accent-2: #FFFFFF;
    --accent-2-encre: #000000;
    --succes: #12823B;
    --alerte: #D7261E;
    --rayon: 0px;
    --ombre: none;
    --ombre-bouton: none;
    --police-titre: 'Archivo', system-ui, sans-serif;
    --police-texte: 'Archivo', system-ui, sans-serif;
    --police-chiffres: 'Archivo', system-ui, sans-serif;
    --casse-titre: none;
    --graisse-titre: 900;
    --chasse-titre: 100%;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
    min-height: 100vh;
    min-height: 100dvh;
    background-color: var(--fond);
    background-image: var(--fond-motif);
    color: var(--encre);
    font-family: var(--police-texte);
    font-size: 17px;
    line-height: 1.4;
    -webkit-tap-highlight-color: transparent;
    overflow-x: hidden;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
img, svg { display: block; max-width: 100%; }

.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* ---------- Titres ---------- */
.titre {
    font-family: var(--police-titre);
    font-weight: var(--graisse-titre);
    font-stretch: var(--chasse-titre);
    text-transform: var(--casse-titre);
    line-height: .95;
}

/* ---------- Boutons ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: .5em;
    padding: .8em 1.4em;
    min-height: 52px;
    border: var(--trait-epaisseur) solid var(--trait);
    border-radius: var(--rayon);
    background: var(--accent);
    color: var(--accent-encre);
    font-family: var(--police-titre);
    font-weight: var(--graisse-titre);
    font-stretch: var(--chasse-titre);
    text-transform: var(--casse-titre);
    font-size: 1.1rem;
    line-height: 1.05;
    text-decoration: none;
    text-align: center;
    box-shadow: var(--ombre-bouton);
    transition: transform .08s ease, box-shadow .08s ease;
    touch-action: manipulation;
    user-select: none;
}
.btn:active { transform: translateY(3px); box-shadow: none; }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.btn-sec { background: transparent; color: var(--encre); }
.btn-2 { background: var(--accent-2); color: var(--accent-2-encre); }
.btn-plein { width: 100%; }
.btn-grand { font-size: 1.35rem; min-height: 64px; }
.btn-petit { font-size: .95rem; min-height: 40px; padding: .45em .9em; }

/* ---------- Champs ---------- */
.champ {
    width: 100%;
    padding: .8em 1em;
    min-height: 54px;
    border: var(--trait-epaisseur) solid var(--trait);
    border-radius: var(--rayon);
    background: var(--surface);
    color: var(--surface-encre);
    font-size: 1.15rem;
    outline: none;
}
.champ::placeholder { color: color-mix(in srgb, var(--surface-encre) 45%, transparent); }
.champ:focus { outline: 3px solid var(--accent); outline-offset: 2px; }
textarea.champ { min-height: 110px; resize: vertical; line-height: 1.4; }
select.champ { appearance: none; background-image: linear-gradient(45deg, transparent 50%, currentColor 50%), linear-gradient(135deg, currentColor 50%, transparent 50%); background-position: calc(100% - 22px) 52%, calc(100% - 16px) 52%; background-size: 6px 6px; background-repeat: no-repeat; padding-right: 2.4em; }
select.champ option { color: #000; background: #fff; }
input[type="number"]::-webkit-outer-spin-button, input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
input[type="number"] { -moz-appearance: textfield; appearance: textfield; }

/* ---------- Bandeau réseau (créé en JS) ---------- */
.bandeau-reseau {
    position: fixed; top: 0; left: 0; right: 0; z-index: 99999;
    padding: 10px 16px; text-align: center;
    font-family: var(--police-texte); font-weight: 700; font-size: .95rem;
    background: var(--alerte); color: #fff;
}

/* =================================================================
   PROJECTEUR — cadre commun
   ================================================================= */
.projecteur-body { padding: 0; }
.barre-projo {
    position: fixed; top: 0; left: 0; right: 0; z-index: 5000;
    display: flex; justify-content: space-between; align-items: center;
    padding: 14px 24px; pointer-events: none;
}
.barre-projo > * { pointer-events: auto; }
.lien-menu {
    font-family: var(--police-texte); font-weight: 700; font-size: .95rem;
    color: var(--encre); text-decoration: none; opacity: .55;
    padding: 6px 10px; border-radius: var(--rayon);
}
.lien-menu:hover { opacity: 1; }
.code-salon-coin {
    display: flex; align-items: center; gap: 10px;
    font-family: var(--police-texte); font-weight: 700; font-size: 1rem;
}
.code-salon-coin b {
    font-family: var(--police-chiffres); font-size: 1.9rem; letter-spacing: 2px;
    padding: 2px 12px; border-radius: var(--rayon);
    background: var(--accent); color: var(--accent-encre);
}

.projecteur-layout {
    display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 28px;
    width: 100%; min-height: 100vh; padding: 70px 34px 30px;
}
.main-game-area { min-width: 0; display: flex; flex-direction: column; justify-content: center; overflow-y: auto; scrollbar-width: none; }
.main-game-area::-webkit-scrollbar { display: none; }

/* ---------- Salle d'attente (commune, habillée par chaque thème) ---------- */
.lobby { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 34px; align-items: start; }
.lobby-titre { font-size: clamp(3rem, 6vw, 5.6rem); margin-bottom: 18px; }
.lobby-consigne { font-size: 1.25rem; max-width: 34em; margin-bottom: 22px; }
.lobby-consigne strong { font-weight: 800; }
.lobby-code { display: inline-flex; flex-direction: column; gap: 4px; margin-bottom: 26px; }
.lobby-code span { font-weight: 700; font-size: 1.05rem; }
.lobby-code b {
    font-family: var(--police-chiffres); font-size: clamp(4rem, 9vw, 7.5rem); line-height: 1; letter-spacing: 6px;
    padding: 8px 26px; background: var(--accent); color: var(--accent-encre);
    border: var(--trait-epaisseur) solid var(--trait); border-radius: var(--rayon); box-shadow: var(--ombre);
}
.lobby-joueurs { background: var(--surface); color: var(--surface-encre); border: var(--trait-epaisseur) solid var(--trait); border-radius: var(--rayon); box-shadow: var(--ombre); padding: 20px 22px; }
.lobby-joueurs h3 { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 14px; font-size: 1.6rem; }
.lobby-joueurs h3 .nb { font-family: var(--police-chiffres); font-size: 1.6rem; }
.liste-pseudos { list-style: none; display: flex; flex-wrap: wrap; gap: 8px; min-height: 48px; }
.liste-pseudos li { padding: 6px 14px; border: 2px solid currentColor; border-radius: var(--rayon); font-weight: 700; font-size: 1.1rem; }
.liste-pseudos li.hors-ligne { opacity: .4; border-style: dashed; }
.liste-pseudos li.pret { background: var(--surface-encre); color: var(--surface); border-color: var(--surface-encre); }
.liste-pseudos:empty::after { content: "Personne pour l'instant. Partagez le code !"; opacity: .6; font-size: 1rem; align-self: center; }
.lobby-reglages { margin-top: 18px; display: flex; flex-direction: column; gap: 14px; }
.reglage { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; }
.reglage label, .reglage > span { font-weight: 700; font-size: 1.1rem; }
.stepper { display: inline-flex; align-items: center; border: var(--trait-epaisseur) solid var(--trait); border-radius: var(--rayon); overflow: hidden; background: var(--surface); color: var(--surface-encre); }
.stepper button { width: 46px; height: 44px; border: 0; background: transparent; font-size: 1.5rem; font-weight: 800; }
.stepper button:active { background: color-mix(in srgb, var(--surface-encre) 12%, transparent); }
.stepper output { min-width: 52px; text-align: center; font-family: var(--police-chiffres); font-size: 1.5rem; }
.lobby .btn-lancer { margin-top: 22px; }

/* ---------- Classement latéral (Quizz / Anecdotes) ---------- */
.classement { display: flex; flex-direction: column; min-height: 0; background: var(--surface); color: var(--surface-encre); border: var(--trait-epaisseur) solid var(--trait); border-radius: var(--rayon); box-shadow: var(--ombre); padding: 18px; overflow-y: auto; align-self: start; max-height: calc(100vh - 100px); }
.classement h3 { font-size: 1.7rem; margin-bottom: 12px; }
#leaderboard-list { list-style: none; display: flex; flex-direction: column; gap: 6px; }
#leaderboard-list li { position: relative; display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--rayon); font-weight: 700; font-size: 1.15rem; }
#leaderboard-list .rank { font-family: var(--police-chiffres); min-width: 2.2em; font-size: 1.1rem; }
#leaderboard-list .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#leaderboard-list .score { font-family: var(--police-chiffres); }
#leaderboard-list li.top-1 { background: var(--accent); color: var(--accent-encre); }
#leaderboard-list li.top-2, #leaderboard-list li.top-3 { background: color-mix(in srgb, var(--surface-encre) 10%, transparent); }
#leaderboard-list li.overtake-flash { outline: 3px solid var(--accent); }

/* ---------- Podium de fin (Quizz / Anecdotes) ---------- */
.podium { list-style: none; display: flex; flex-direction: column; gap: 8px; max-width: 640px; width: 100%; margin: 0 auto; }
.podium li { display: grid; grid-template-columns: 3.2em 1fr auto; align-items: center; gap: 12px; padding: 10px 16px; font-size: 1.45rem; font-weight: 700; background: var(--surface); color: var(--surface-encre); border: var(--trait-epaisseur) solid var(--trait); border-radius: var(--rayon); }
.podium li .rg { font-family: var(--police-chiffres); font-size: 1.5rem; }
.podium li .pts { font-family: var(--police-chiffres); }
.podium li:first-child { font-size: 2rem; background: var(--accent); color: var(--accent-encre); box-shadow: var(--ombre); }

/* ---------- Trophées (Anecdotes / Infecto) ---------- */
.trophees { display: flex; flex-wrap: wrap; gap: 14px; justify-content: center; }
.trophee { min-width: 190px; max-width: 240px; padding: 14px 16px; background: var(--surface); color: var(--surface-encre); border: var(--trait-epaisseur) solid var(--trait); border-radius: var(--rayon); text-align: center; }
.trophee .t-emoji { font-size: 2rem; line-height: 1.2; }
.trophee .t-titre { font-weight: 800; font-size: 1.05rem; }
.trophee .t-pseudo { font-family: var(--police-titre); font-weight: var(--graisse-titre); font-stretch: var(--chasse-titre); text-transform: var(--casse-titre); font-size: 1.6rem; line-height: 1.1; margin: 4px 0; }
.trophee .t-detail { font-size: .92rem; opacity: .75; }

/* =================================================================
   TÉLÉPHONE — cadre commun
   ================================================================= */
.joueur-body { display: flex; justify-content: center; }
.tel-app { width: 100%; max-width: 480px; min-height: 100dvh; display: flex; flex-direction: column; padding: 18px 16px 110px; }
.ecran { display: flex; flex-direction: column; gap: 14px; }
.tel-app > .ecran { flex: 1; }
.entete-jeu { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 4px; }
.entete-jeu .marque { font-family: var(--police-titre); font-weight: var(--graisse-titre); font-stretch: var(--chasse-titre); text-transform: var(--casse-titre); font-size: 1.5rem; line-height: 1; }
.entete-jeu .qui { font-weight: 700; font-size: .95rem; text-align: right; }
.carte { background: var(--surface); color: var(--surface-encre); border: var(--trait-epaisseur) solid var(--trait); border-radius: var(--rayon); box-shadow: var(--ombre); padding: 18px; }
.carte h2, .carte h3 { margin-bottom: 10px; }
.texte-doux { opacity: .78; }
.texte-ok { font-weight: 700; color: var(--succes); }
.gros-titre { font-size: 2.6rem; }
.pile { display: flex; flex-direction: column; gap: 12px; }

.deux-boutons { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.texte-erreur { font-weight: 700; color: var(--alerte); }
.rang-final { font-family: var(--police-titre); font-weight: var(--graisse-titre); font-stretch: var(--chasse-titre); text-transform: var(--casse-titre); font-size: 2rem; line-height: 1.05; margin: 8px 0; }
.message-texte { white-space: pre-line; font-size: 1.05rem; line-height: 1.5; margin-bottom: 14px; }
.btn-danger { background: var(--alerte); color: #fff; }
.ecran-plein { position: fixed; inset: 0; z-index: 2500; overflow-y: auto; padding: 28px 18px; display: flex; flex-direction: column; gap: 14px; background: var(--fond); color: var(--encre); }

/* Popup maison (remplace alert()) */
.popup { position: fixed; inset: 0; z-index: 4000; display: flex; align-items: center; justify-content: center; padding: 20px; background: rgba(0,0,0,.72); }
.popup .carte { width: 100%; max-width: 380px; }

/* =================================================================
   PHOTOMANY — mur photo (identité de l'accueil : blanc, noir, Archivo)
   ================================================================= */
html[data-jeu="photowall"] body { background: #F2F2F2; }
.photowall-entete { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; padding: 10px 0 20px; border-bottom: 3px solid #000; margin-bottom: 30px; }
.photowall-entete h1 { font-family: 'Archivo'; font-weight: 900; font-stretch: 62%; text-transform: uppercase; font-size: clamp(3rem, 7vw, 6rem); line-height: .85; letter-spacing: -1px; }
.photowall-entete p { font-family: 'Archivo'; font-weight: 600; font-size: 1.2rem; text-align: right; max-width: 22em; }
.projecteur-layout.photowall-mode { grid-template-columns: 1fr; padding-top: 60px; }
.projecteur-layout.photowall-mode .main-game-area { justify-content: flex-start; padding-bottom: 80px; height: calc(100vh - 90px); overflow-anchor: none; }
.masonry-wall { column-count: 4; column-gap: 28px; padding: 10px 0; width: 100%; }
.masonry-wall:empty { column-count: 1; padding: 12vh 0; }
.masonry-wall:empty::before { content: 'Le mur est vide. Première photo publiée, première affichée.'; display: block; font-family: 'Archivo'; font-weight: 800; font-stretch: 75%; font-size: clamp(1.4rem, 3vw, 2.4rem); color: rgba(0,0,0,.35); text-align: center; }
.masonry-item {
    position: relative; break-inside: avoid; margin-bottom: 32px;
    padding: 12px 12px 0; background: #fff; border: 1px solid #d9d9d9;
    box-shadow: 0 1px 0 #cfcfcf, 0 12px 20px -14px rgba(0,0,0,.45);
    transform: translateY(var(--random-y, 0)) rotate(var(--random-rot, 0deg));
    animation: popPhoto .5s cubic-bezier(.3, 1.4, .6, 1);
    transition: transform .25s ease;
}
.masonry-item:hover { z-index: 50; transform: scale(1.06) rotate(0deg); }
.masonry-item img { width: 100%; display: block; object-fit: cover; }
.photo-caption { padding: 10px 2px 2px; font-family: 'Archivo'; font-weight: 800; font-size: 1.25rem; line-height: 1.15; color: #000; text-align: left; word-wrap: break-word; }
.photo-auteur { padding: 4px 2px 12px; font-family: 'Archivo'; font-weight: 600; font-size: .9rem; color: #666; }
.like-btn-container { position: absolute; top: 20px; right: 20px; z-index: 20; display: flex; align-items: center; gap: 6px; padding: 5px 11px; background: #000; color: #fff; border-radius: 30px; cursor: pointer; font-family: 'Archivo'; font-weight: 800; }
.like-btn-container:active { transform: scale(.88); }
.like-icon { width: 18px; height: 18px; pointer-events: none; }
.like-counter { pointer-events: none; }
.floating-heart { position: absolute; z-index: 100; font-size: 2.2rem; pointer-events: none; animation: flyUpHeart 1.4s ease-out forwards; }
@keyframes flyUpHeart { 0% { transform: translate(0,0) scale(.5); opacity: 1; } 80% { opacity: 1; } 100% { transform: translate(var(--drift-x), var(--drift-y)) scale(1.4); opacity: 0; } }
.delete-photo-btn, .download-photo-btn { position: absolute; z-index: 20; width: 38px; height: 38px; display: grid; place-items: center; border: 2px solid #000; border-radius: 50%; background: #fff; color: #000; font-weight: 900; opacity: 0; transition: opacity .2s; }
.delete-photo-btn { top: 20px; left: 20px; }
.download-photo-btn { bottom: 56px; right: 20px; }
.masonry-item:hover .delete-photo-btn, .masonry-item:hover .download-photo-btn { opacity: 1; }
@media (hover: none) { .download-photo-btn { opacity: 1; } }
@keyframes popPhoto { 0% { transform: scale(.4) translateY(80px) rotate(-18deg); opacity: 0; } 100% { transform: translateY(var(--random-y, 0)) rotate(var(--random-rot, 0deg)); opacity: 1; } }

/* Téléphone : envoi de photo */
.photowall-tel h1 { font-family: 'Archivo'; font-weight: 900; font-stretch: 62%; text-transform: uppercase; font-size: 3.2rem; line-height: .9; margin-bottom: 6px; }
.photowall-tel .apercu { width: 100%; max-height: 260px; object-fit: contain; background: #fff; border: 3px solid #000; }

/* =================================================================
   Responsive commun
   ================================================================= */
@media (max-width: 1200px) {
    .projecteur-layout { grid-template-columns: 1fr; }
    .classement { max-height: none; }
    .masonry-wall { column-count: 3; }
}
@media (max-width: 900px) {
    .lobby { grid-template-columns: 1fr; }
    .projecteur-layout { padding: 64px 16px 24px; }
}
@media (max-width: 768px) {
    .masonry-wall { column-count: 2; padding: 10px 16px; }
    .photowall-entete { padding: 10px 16px 16px; flex-direction: column; align-items: flex-start; }
    .photowall-entete p { text-align: left; }
}
@media (max-width: 480px) {
    .masonry-wall { column-count: 1; }
    .masonry-item { --random-rot: 0deg; --random-y: 0px; }
}

/* Utilitaire encore utilisé par les pages Démineuromany */
.text-center { text-align: center; }
