:root{
  --boy:#3b82f6; /* bleu */
  --girl:#ec4899; /* rose */
  --bg:#0b0b0f;
  --card:#15151c;
  --text:#f7f7fb;
  --muted:#b8b8c5;
  --ring: rgba(255,255,255,.08);
}

*{ box-sizing:border-box; }
html,body{ margin:0; padding:0; background:var(--bg); color:var(--text);
  font-family:system-ui,-apple-system,Segoe UI,Roboto,Ubuntu,Cantarell,Noto Sans,Arial; }

.hero{
  text-align:center; padding:48px 16px;
}
.hero h1{ margin:0 0 8px; font-size: clamp(28px, 4vw, 44px); }
.hero p{ color:var(--muted); margin:0; }

.container{ width:min(1000px, 92%); margin:0 auto; padding-bottom:40px; }

.vote-grid{ display:grid; grid-template-columns: 1fr 1fr; gap:16px; }
@media (max-width:700px){ .vote-grid{ grid-template-columns: 1fr; } }

.col{
  background:var(--card); padding:24px; border-radius:18px; box-shadow: 0 0 0 1px var(--ring) inset;
  display:flex; justify-content:center; align-items:center; min-height:140px;
}
.col-vertical { flex-direction: column; gap: 16px; }
.col-vertical img { display:block; margin:0 auto; max-width:240px; width:100%; border-radius:12px; }

.btn{
  appearance:none; border:0; border-radius:999px; padding:18px 32px; font-size:18px; cursor:pointer;
  color:#fff; transition: transform .06s ease, filter .2s ease, box-shadow .2s ease;
  box-shadow: 0 10px 24px rgba(0,0,0,.35);
}
.btn:hover{ transform: translateY(-1px); filter:brightness(1.05); }
.btn:active{ transform: translateY(0); }
.btn-boy{ background:var(--boy); }
.btn-girl{ background:var(--girl); }

.results{ display:grid; grid-template-columns: 360px 1fr; gap:24px; margin-top:24px; }
@media (max-width:900px){ .results{ grid-template-columns: 1fr; } }

.stats{ background:var(--card); padding:20px; border-radius:18px; box-shadow: 0 0 0 1px var(--ring) inset; }
.stat{ display:flex; align-items:center; justify-content:space-between; padding:10px 0; }
.stat .label{ color:var(--muted); }
.stat .value{ font-weight:700; font-size:24px; }
.total{ margin-top:8px; color:var(--muted); }
.notice{ margin-top:12px; background:#1f2937; color:#e5e7eb; padding:10px 12px; border-radius:10px; font-size:14px; }

.chart-wrap{
  background:var(--card); padding:20px; border-radius:18px; box-shadow: 0 0 0 1px var(--ring) inset;
  display:flex; align-items:center; justify-content:center;
}

.footer{ text-align:center; color:var(--muted); padding:24px 12px 40px; }

/* --- Modal --- */
.modal.hidden { display:none; }
.modal { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.55); }
.modal-dialog {
  position: relative; z-index: 1; width: min(520px, 92%);
  background: var(--card); color: var(--text); border-radius: 16px; padding: 20px;
  box-shadow: 0 0 0 1px var(--ring) inset, 0 20px 60px rgba(0,0,0,.45);
}
.modal-close {
  position: absolute; top: 10px; right: 12px; font-size: 24px; line-height: 1;
  background: transparent; color: var(--muted); border: 0; cursor: pointer;
}
.modal-sub { color: var(--muted); margin-top: 4px; }
.form-row { display: grid; gap: 6px; margin: 14px 0; }
.form-row label { font-size: 14px; color: var(--muted); }
.form-row input {
  background: #0f0f14; border: 1px solid var(--ring); color: var(--text);
  padding: 12px 14px; border-radius: 12px; outline: none;
}
.form-row input:focus { border-color: #6b7280; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 10px; }
.btn-light{
  background:#1f2937; color:#e5e7eb; border-radius:999px; padding:12px 18px; border:0; cursor:pointer;
}
.btn-primary{
  background: linear-gradient(90deg, var(--boy), var(--girl));
  color:#fff; border-radius:999px; padding:12px 18px; border:0; cursor:pointer;
  box-shadow: 0 8px 20px rgba(0,0,0,.3);
}
.btn-primary:hover{ filter:brightness(1.05); }

.fieldset { border: 1px solid var(--ring); border-radius: 14px; padding: 14px; margin: 14px 0; }
.legend { padding: 0 8px; font-weight: 600; color: var(--muted); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 520px){ .grid-2{ grid-template-columns: 1fr; } }

.segmented { display: inline-flex; gap: 6px; background: #0f0f14; padding: 6px; border-radius: 999px; border: 1px solid var(--ring); }
.seg-item { display:flex; align-items:center; gap:6px; padding: 6px 10px; border-radius: 999px; color: var(--text); opacity: .7; }
.seg-item input { accent-color: var(--boy); }
#sex_boy:checked ~ span, #sex_girl:checked ~ span { font-weight: 600; opacity: 1; }

/* Toast simple (succès/erreur) */
.toast-wrap{
  position: fixed; top: 16px; right: 16px; z-index: 9999;
  display: grid; gap: 8px;
}
.toast{
  background:#111827; color:#e5e7eb; border:1px solid rgba(255,255,255,.08);
  border-radius:12px; padding:10px 12px; min-width: 220px; box-shadow:0 10px 30px rgba(0,0,0,.35);
  animation: toast-in .2s ease-out, toast-out .2s ease-in 4.5s forwards;
}
.toast.ok{ border-color: rgba(16,185,129,.4); }
.toast.err{ border-color: rgba(239,68,68,.4); }
@keyframes toast-in{ from{ transform: translateY(-8px); opacity:0;} to{ transform: translateY(0); opacity:1;} }
@keyframes toast-out{ to{ transform: translateY(-8px); opacity:0;} }
/* ====== Responsive stats + chart ====== */

/* Grille principale de la section résultats: 2 colonnes sur grand écran, 1 colonne sur mobile */
.results{
  display:grid;
  grid-template-columns: 380px 1fr;   /* colonne gauche (stats) + droite (graph) */
  gap:24px;
  margin-top:24px;
}

/* Sous 1024px : colonnes plus étroites */
@media (max-width: 1024px){
  .results{
    grid-template-columns: 320px 1fr;
  }
}

/* Sous 860px : on empile en 1 colonne */
@media (max-width: 860px){
  .results{
    grid-template-columns: 1fr;
  }
}

/* Carte des stats : passe en flex wrap pour que les éléments s’organisent bien */
.stats{
  flex-wrap:wrap;
  align-items:flex-start;
  gap:12px;
}

/* Chaque bloc stat prend une largeur mini et s’adapte */
.stat{
  background: transparent; /* on garde l'aspect existant */
  padding:10px 0;
  display:flex;
  justify-content:space-between;
  align-items:center;
  flex:1 1 160px;          /* s'étire / se replie selon l'espace */
  min-width: 160px;
}

/* La ligne "Total" prend toute la ligne si besoin */
.total,
.notice{
  flex: 1 1 100%;
}

/* Boîte du graphique: centrée et fluide */
.chart-wrap{
  background:var(--card);
  padding:20px;
  border-radius:18px;
  box-shadow: 0 0 0 1px var(--ring) inset;
  display:flex;
  align-items:center;
  justify-content:center;
}

/* Canvas Chart.js 100% fluide (ignore les width/height HTML) */
.chart-wrap canvas{
  width: 100% !important;
  height: auto !important;
  max-width: 520px;      /* taille max confortable sur desktop */
  aspect-ratio: 1 / 1;   /* carré, évite les déformations */
}

/* Petits écrans: on réduit un peu les textes */
@media (max-width: 480px){
  .stat .value{ font-size:20px; }
  .hero h1{ font-size: clamp(26px, 7vw, 36px); }
}


/* Empêche le scroll de la page quand la modale est ouverte */
html.modal-open, body.modal-open{
  overflow: hidden;
  height: 100%;
  touch-action: none;
  overscroll-behavior: none;
}

/* La modale elle-même peut scroller si contenu long */
.modal{
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  overflow: auto;                 /* permet de scroller DANS la modale */
  overscroll-behavior: contain;   /* évite le “pull-to-refresh” iOS dans la page */
}

.modal-backdrop{ position:absolute; inset:0; background: rgba(0,0,0,.55); }

.modal-dialog{
  position: relative;
  z-index: 1;
  width: min(520px, 92%);
  max-height: calc(100dvh - 32px); /* plein écran - marges */
  overflow: auto;                   /* scroll interne de la fenêtre */
  -webkit-overflow-scrolling: touch;/* inertie iOS */
  margin: 16px;                     /* garde un petit espace autour sur mobile */
}


