/* Soirée Miss France — mobile d'abord, thèmes clair et sombre selon l'appareil. */

:root {
  --fond: #f5f7fa;
  --surface: #ffffff;
  --surface-2: #edf1f6;
  --texte: #1a1e25;
  --texte-doux: #5f6773;
  --bord: #dce2ea;
  --accent: #1d5fc4;
  --accent-texte: #ffffff;
  --accent-doux: #e2ecfb;
  --or: #b8860b;
  --succes: #1d7a46;
  --succes-doux: #e2f4e9;
  --alerte: #a14d00;
  --alerte-doux: #fff1e0;
  --erreur: #b3261e;
  --erreur-doux: #fde7e6;
  --rayon: 14px;
  --ombre: 0 1px 3px rgba(0, 0, 0, .08), 0 4px 14px rgba(0, 0, 0, .05);
  --tactile: 48px;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --fond: #10141a;
    --surface: #1a1f27;
    --surface-2: #252c36;
    --texte: #eef2f7;
    --texte-doux: #a3adbb;
    --bord: #343d4a;
    --accent: #6ea8ff;
    --accent-texte: #0a1a33;
    --accent-doux: #1b2c47;
    --or: #e6b84a;
    --succes: #6fd49a;
    --succes-doux: #17301f;
    --alerte: #f3a65a;
    --alerte-doux: #33230f;
    --erreur: #ff8a80;
    --erreur-doux: #3a1816;
    --ombre: 0 1px 3px rgba(0, 0, 0, .4);
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--fond);
  color: var(--texte);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding-bottom: calc(72px + env(safe-area-inset-bottom));
}

main { max-width: 760px; margin: 0 auto; padding: 16px; padding-top: max(16px, env(safe-area-inset-top)); }

h1, h2, h3 { line-height: 1.2; margin: 0 0 .6em; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 .8em; }
a { color: var(--accent); }

/* En-tête */
.entete {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 16px; padding-top: calc(10px + env(safe-area-inset-top));
  background: var(--surface); border-bottom: 1px solid var(--bord);
}
.entete .titre { font-weight: 700; font-size: 1.05rem; }
.entete .titre span { color: var(--accent); }
.entete .qui { font-size: .9rem; color: var(--texte-doux); text-align: right; }

/* Navigation basse */
.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: flex; justify-content: space-around;
  background: var(--surface); border-top: 1px solid var(--bord);
  padding-bottom: env(safe-area-inset-bottom);
}
.nav a {
  flex: 1; min-height: 60px; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; color: var(--texte-doux); text-decoration: none; font-size: .75rem;
  text-align: center; line-height: 1.1;
}
.nav a .ico { font-size: 1.35rem; line-height: 1; }
.nav a[aria-current="page"] { color: var(--accent); font-weight: 600; }

/* Cartes */
.carte {
  background: var(--surface); border: 1px solid var(--bord); border-radius: var(--rayon);
  padding: 16px; margin-bottom: 16px; box-shadow: var(--ombre);
}

/* Boutons */
button, .bouton {
  font: inherit; min-height: var(--tactile); padding: 0 18px; border-radius: 12px;
  border: 1px solid var(--bord); background: var(--surface-2); color: var(--texte);
  cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  text-decoration: none; touch-action: manipulation;
}
button.principal, .bouton.principal { background: var(--accent); color: var(--accent-texte); border-color: var(--accent); font-weight: 600; }
button.danger { color: var(--erreur); }
button.lien { background: none; border: none; color: var(--accent); padding: 0 4px; min-height: 36px; text-decoration: underline; }
button:disabled { opacity: .45; cursor: not-allowed; }
button.large, .bouton.large { width: 100%; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }

/* Formulaires */
input[type="text"], input[type="number"], input[type="password"], select {
  font: inherit; width: 100%; min-height: var(--tactile); padding: 0 14px;
  border-radius: 12px; border: 1px solid var(--bord); background: var(--surface); color: var(--texte);
}
input:focus-visible, button:focus-visible, select:focus-visible, a:focus-visible {
  outline: 3px solid var(--accent); outline-offset: 2px;
}
label { display: block; font-weight: 600; margin: 12px 0 6px; }
.champ-ligne { display: flex; gap: 8px; }
.champ-ligne > * { flex: 1; }

/* Liste des prénoms */
.prenoms { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; }
.prenoms button { min-height: 56px; font-size: 1.05rem; font-weight: 600; }

/* Messages */
.message { border-radius: 12px; padding: 12px 14px; margin: 12px 0; }
.message.info { background: var(--accent-doux); }
.message.succes { background: var(--succes-doux); color: var(--succes); }
.message.alerte { background: var(--alerte-doux); color: var(--alerte); }
.message.erreur { background: var(--erreur-doux); color: var(--erreur); }
.doux { color: var(--texte-doux); }
.petit { font-size: .875rem; }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: calc(84px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  z-index: 50; max-width: calc(100% - 32px); padding: 12px 18px; border-radius: 12px;
  background: var(--texte); color: var(--fond); box-shadow: var(--ombre); font-weight: 500;
}

/* Pastilles d'état */
.etat { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: .8rem; font-weight: 600; }
.etat.a_venir { background: var(--surface-2); color: var(--texte-doux); }
.etat.ouverte { background: var(--succes-doux); color: var(--succes); }
.etat.fermee { background: var(--erreur-doux); color: var(--erreur); }

/* Avatar d'une candidate : photo ou initiales */
.avatar {
  --taille: 56px;
  width: var(--taille); height: var(--taille); border-radius: 50%; flex: none;
  object-fit: cover; object-position: center 20%;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: calc(var(--taille) * .36); color: #fff;
  background: hsl(var(--teinte, 215) 55% 42%);
}

.avatar-photo { position: relative; overflow: hidden; background: var(--surface-2); }
.avatar-photo img { position: absolute; max-width: none; height: auto; display: block; }

/* Lignes de liste (admin) */
.ligne { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--bord); }
.ligne:first-child { border-top: none; }
.ligne .corps { flex: 1; min-width: 0; }
.ligne .corps .nom { font-weight: 600; }

/* Grille de cases (qualifiées) */
.cases { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px; }
.case {
  display: flex; align-items: center; gap: 10px; min-height: var(--tactile); padding: 6px 10px;
  border: 1px solid var(--bord); border-radius: 12px; cursor: pointer; font-weight: 400; margin: 0;
}
.case input { width: 22px; height: 22px; accent-color: var(--accent); }
.case.choisie { border-color: var(--accent); background: var(--accent-doux); }

details > summary { cursor: pointer; min-height: var(--tactile); display: flex; align-items: center; font-weight: 600; }

.cache { display: none !important; }

/* --- Écran de vote (lot B) --------------------------------------------------- */

.podium h2 { display: flex; justify-content: space-between; align-items: center; }
.compteur { font-size: .9rem; color: var(--texte-doux); font-weight: 600; }

.places { list-style: none; margin: 0; padding: 0; }
.place {
  display: flex; align-items: center; gap: 6px; min-height: 64px; padding: 6px;
  margin-bottom: 6px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--bord);
}
.place.vide { border-style: dashed; background: transparent; gap: 12px; padding-left: 12px; }

/* Zone de prise : tout le côté gauche de la ligne. touch-action: none empêche le
   défilement de la page quand on commence à glisser au doigt. */
.prise {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px;
  cursor: grab; touch-action: none; user-select: none; -webkit-user-select: none;
  -webkit-touch-callout: none; padding: 4px 0;
}
.poignee { font-size: 1.4rem; color: var(--texte-doux); width: 22px; text-align: center; flex: none; }
.rang { display: flex; flex-direction: column; align-items: center; width: 64px; flex: none; line-height: 1.1; }
.rang b { font-size: 1.2rem; }
.rang small { font-size: .68rem; color: var(--texte-doux); text-align: center; }
.rang-1 b { color: var(--or); }
.place .corps { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.place .nom { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.place .petit { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.fleches { display: flex; flex-direction: column; gap: 2px; flex: none; }
.fleche, .retirer { min-height: 30px; width: 40px; padding: 0; font-size: .85rem; border-radius: 8px; }
.retirer { min-height: 44px; color: var(--texte-doux); flex: none; }

/* États pendant le glisser-déposer */
.place.fantome { opacity: .35; }
.place.choisie { border-color: var(--accent); }
.place.en-vol { box-shadow: 0 8px 24px rgba(0, 0, 0, .25); background: var(--surface); }
.sortable-fallback { opacity: .95 !important; }

/* Grille des candidates */
.grille-miss { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 10px; }
.miss {
  position: relative; display: flex; flex-direction: column; align-items: stretch; padding: 0;
  min-height: 0; border-radius: 12px; overflow: hidden; background: var(--surface);
  border: 2px solid var(--bord); text-align: left;
}
.miss .photo {
  width: 100%; aspect-ratio: 3 / 4; object-fit: cover; object-position: center 15%; display: block;
  background: var(--surface-2);
}
.miss .photo.initiales {
  display: flex; align-items: center; justify-content: center; color: #fff;
  font-size: 2rem; font-weight: 700; background: hsl(var(--teinte, 215) 55% 42%);
}
.miss .legende { display: flex; flex-direction: column; padding: 6px 8px 8px; line-height: 1.2; }
.miss .legende .region { font-weight: 700; font-size: .85rem; }
.miss .legende .nom { font-size: .75rem; color: var(--texte-doux); }
.miss.choisie { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
.badge-rang {
  position: absolute; top: 6px; right: 6px; width: 32px; height: 32px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; font-weight: 700;
  background: var(--accent); color: var(--accent-texte); box-shadow: var(--ombre);
}

/* Bouton Valider collé au-dessus de la navigation */
.barre-valider {
  position: sticky; bottom: calc(68px + env(safe-area-inset-bottom)); z-index: 5;
  margin: 16px -16px 0; padding: 10px 16px; background: linear-gradient(transparent, var(--fond) 30%);
}
.barre-valider button { min-height: 54px; font-size: 1.05rem; box-shadow: var(--ombre); }

/* --- Consultation (lot C) ---------------------------------------------------- */

.onglets {
  display: flex; gap: 6px; overflow-x: auto; margin: 0 -16px 8px; padding: 0 16px 4px;
  scrollbar-width: none;
}
.onglets::-webkit-scrollbar { display: none; }
.onglets button {
  flex: none; min-height: 44px; border-radius: 999px; padding: 0 14px; font-size: .9rem; white-space: nowrap;
}
.onglets button.actif { background: var(--accent); color: var(--accent-texte); border-color: var(--accent); font-weight: 600; }
.point-direct {
  display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--succes);
  box-shadow: 0 0 0 3px var(--succes-doux);
}
.onglets button.actif .point-direct { box-shadow: none; background: currentColor; }
.maj { margin-bottom: 12px; }

/* Détail des votes */
.vote { padding: 12px; }
.vote.moi { border-color: var(--accent); }
.vote-entete { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 8px; }
.mini-podium { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.mini-podium li { display: flex; flex-direction: column; align-items: center; text-align: center; min-width: 0; }
.mini-photo { position: relative; }
.mini-rang {
  position: absolute; bottom: -4px; right: -6px; width: 22px; height: 22px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; font-size: .75rem; font-weight: 700;
  background: var(--surface); border: 1px solid var(--bord);
}
.mini-rang.rang-1 { background: var(--or); color: #fff; border-color: var(--or); }
.mini-region {
  margin-top: 6px; font-size: .72rem; font-weight: 600; line-height: 1.15; width: 100%;
  overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}
.mini-nom { font-size: .65rem; color: var(--texte-doux); width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Favorites */
.favorites { list-style: none; padding: 4px 16px; }
.favorite { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--bord); }
.favorite:first-child { border-top: none; }
.fav-rang { width: 28px; text-align: center; font-weight: 700; font-size: 1.1rem; flex: none; color: var(--texte-doux); }
.fav-rang.rang-1 { color: var(--or); }
.fav-corps { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.fav-corps .nom { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.barre { display: block; height: 8px; border-radius: 4px; background: var(--surface-2); overflow: hidden; }
.barre span { display: block; height: 100%; border-radius: 4px; background: var(--accent); }

/* --- Classement (lot D) ------------------------------------------------------ */

.pronostiqueur { border-top: 1px solid var(--bord); }
.pronostiqueur:first-of-type { border-top: none; }
.pronostiqueur > summary { gap: 12px; padding: 4px 0; list-style: none; }
.pronostiqueur > summary::-webkit-details-marker { display: none; }
.pronostiqueur > summary .corps { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pronostiqueur > summary .points { font-size: 1.05rem; }
.pronostiqueur.moi > summary .corps { color: var(--accent); }
.detail-score { width: 100%; border-collapse: collapse; font-size: .8rem; margin: 4px 0 12px; }
.detail-score th, .detail-score td { padding: 6px 4px; text-align: center; border-bottom: 1px solid var(--bord); }
.detail-score thead th { font-weight: 600; color: var(--texte-doux); font-size: .72rem; }
.detail-score tbody th { text-align: left; font-weight: 400; color: var(--texte-doux); }
.detail-score tr.total th, .detail-score tr.total td { font-weight: 700; border-bottom: none; }
.mention-emoji { font-size: 1.6rem; line-height: 1; width: 36px; text-align: center; flex: none; }
.mention .petit { margin-top: 2px; }
.mention strong.moi { color: var(--accent); }
