/* Moteur commun des jeux (/games/_shared/js/party.js) : réglages, salle d'attente, bandeau, fenêtres, résultats.
   Pensé d'abord pour le téléphone, tenu à la verticale. Chaque jeu ajoute sa propre feuille pour sa « scène »
   (.stage) et son encre (--accent). Couleurs, polices, boutons, timbre et frise viennent de /_shared/css/mval.css. */

.btn-big { width: 100%; min-height: 3.2rem; font-size: 1.1rem; }

/* ---------- Réglages ---------- */
.setup { display: grid; gap: 1.6rem; max-width: 34rem; }
.choice { margin: 0; padding: 0; border: 0; min-width: 0; }
.choice legend { margin-bottom: 0.6rem; padding: 0; font-family: var(--title); font-weight: 800; font-size: 1.15rem; }

.chips { display: flex; flex-wrap: wrap; gap: 0.6rem; }
.chips-col { flex-direction: column; }
.chips-num .chip { flex: 1; }
.chips-level { display: grid; grid-template-columns: 1fr 1fr; }
.chip { position: relative; display: flex; }
.chip input { position: absolute; opacity: 0; pointer-events: none; }
.chip > span {
  display: grid;
  gap: 0.1rem;
  width: 100%;
  min-height: 2.9rem;
  align-content: center;
  padding: 0.6rem 0.9rem;
  border: 2px solid var(--ink);
  border-radius: 8px;
  background: var(--paper);
  cursor: pointer;
  box-shadow: 2px 2px 0 var(--ink);
}
.chip small { color: var(--soft); font-size: 0.85rem; }
.chip-sm > span { justify-items: center; padding: 0.5rem 0.85rem; font-weight: 700; }
.chips-num .chip-sm > span { padding-inline: 0.3rem; font-family: var(--data); white-space: nowrap; }
.chip input:checked + span { background: var(--accent); color: #ffffff; box-shadow: 2px 2px 0 var(--ink); }
.chip input:checked + span small { color: #ffffffcc; }
.chip input:focus-visible + span { outline: 3px solid var(--ink); outline-offset: 3px; }
.chip:hover input:not(:checked) + span { background: var(--hover); }

.text-input {
  width: 100%;
  border: 0;
  border-bottom: 2px solid var(--ink);
  background: transparent;
  padding: 0.45rem 0;
  font-size: 1.1rem; /* 16 px minimum : iOS ne zoome pas sur le champ */
}
.text-input:focus { outline: none; border-bottom-color: var(--accent); }
.names { display: grid; gap: 0.5rem; margin: 0 0 0.9rem; padding: 0; list-style: none; }
.names li { display: flex; gap: 1rem; align-items: baseline; }

.online-actions { margin-top: 1.2rem; }
.join label { display: block; font-size: 0.85rem; color: var(--soft); }
.join-row { display: flex; gap: 0.8rem; align-items: end; }
.code-input { width: 7rem; font-family: var(--data); font-weight: 700; letter-spacing: 0.25em; text-transform: uppercase; }
.or { margin: 1rem 0 0; color: var(--soft); font-size: 0.9rem; }

.rules { max-width: 34rem; margin-top: 3rem; padding-top: 1.5rem; border-top: 1.5px solid var(--rule); }
.rules h2 { font-size: 1.15rem; margin-bottom: 0.6rem; }
.rules ul { margin: 0; padding-left: 1.2rem; display: grid; gap: 0.45rem; }

/* ---------- Salle d'attente ---------- */
.lobby { display: grid; gap: 1.2rem; max-width: 30rem; padding-top: 2rem; }
.lobby-panel { justify-items: center; text-align: center; gap: 0.6rem; }
.lobby-label { margin: 0; color: var(--soft); font-size: 0.9rem; }
.room-code { margin: 0; font-family: var(--data); font-weight: 700; font-size: 3.2rem; letter-spacing: 0.3em; padding-left: 0.3em; line-height: 1.1; }
.lobby-settings { margin: 0 0 0.6rem; font-family: var(--data); }
.lobby-title { font-size: 1.2rem; }
.lobby-title span { font-family: var(--data); font-weight: 400; color: var(--soft); }
.lobby-players { display: grid; gap: 0.5rem; margin: 0; padding: 0; list-style: none; }
.lobby-players li { display: flex; justify-content: space-between; align-items: baseline; padding: 0.6rem 0.9rem; background: var(--paper); border: 1.5px solid var(--ink); border-radius: 8px; font-weight: 700; }
.lobby-players li.is-me { border-width: 2px; border-color: var(--accent); }
.lobby-players small { font-weight: 400; color: var(--soft); }
.lobby-wait { margin: 0; text-align: center; color: var(--soft); }
.lobby .btn-text { justify-self: center; }

/* ---------- Le jeu : plein écran ---------- */
body.is-playing { overflow: hidden; overscroll-behavior: none; }
.game {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  height: 100dvh;
  background: var(--ground);
  padding-bottom: env(safe-area-inset-bottom);
}
.game[hidden] { display: none; }

/* Bandeau du jeu : une ligne pour la question, une pour le reste. Tout ce qui est gagné en hauteur va à la scène. */
.hud {
  padding: calc(0.35rem + env(safe-area-inset-top)) 0.6rem 0.45rem;
  background: var(--paper);
  border-bottom: 2px solid var(--ink);
}
.hud p { margin: 0; }
.hud-top { display: flex; align-items: center; gap: 0.6rem; }
.hud .icon-btn { width: 2.2rem; height: 2.2rem; font-size: 1rem; }
.game-progress, .game-score { flex: none; font-family: var(--data); font-size: 0.9rem; }
.game-player { max-width: 6.5rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 700; font-size: 0.9rem; }
.game-player:empty { display: none; }

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 2.6rem;
  height: 2.6rem;
  border: 2px solid var(--ink);
  border-radius: 8px;
  background: var(--paper);
  font-size: 1.15rem;
  font-weight: 700;
  line-height: 1;
  box-shadow: 2px 2px 0 var(--ink);
}
.icon-btn:active { transform: translate(2px, 2px); box-shadow: none; }

.q-name { flex: 1; min-width: 0; font-family: var(--title); font-weight: 800; font-size: clamp(1.3rem, 6vw, 1.9rem); line-height: 1.1; overflow-wrap: anywhere; }
.q-meta { display: flex; align-items: center; gap: 0.6rem; margin-top: 0.35rem; }

.tries { display: flex; gap: 0.3rem; margin: 0; padding: 0; list-style: none; }
.tries li { width: 0.95rem; height: 0.95rem; border: 2px solid var(--ink); border-radius: 50%; background: var(--paper); }
.tries li.is-bad { background: var(--cinabre); }
.tries li.is-good { background: var(--accent); }

/* Le temps : une piste pointillée qui se vide de son motif de vagues */
.timer { flex: 1; height: 14px; border: 1.5px solid var(--ink); border-radius: 999px; overflow: hidden; background-color: var(--paper); background-image: var(--dots); background-size: 8px 8px; }
.timer-bar { height: 100%; transform-origin: left; transform: scaleX(var(--left, 1)); background: var(--motif) 0 0 / 12px 6px, var(--paper); border-right: 1.5px solid var(--ink); }
.timer.is-hurry .timer-bar { background: var(--cinabre); }
.timer-num { flex: none; width: 1.6rem; text-align: right; font-family: var(--data); font-weight: 700; }

/* La scène : propre à chaque jeu (la carte, le drapeau et ses réponses…), elle prend toute la place restante */
.stage { position: relative; flex: 1; min-height: 0; }

.feedback {
  margin: 0;
  padding: 0.6rem 0.85rem;
  background: var(--paper);
  border: 2px solid var(--ink);
  border-radius: 8px;
  font-weight: 700;
  box-shadow: 3px 3px 0 var(--ink);
}
.feedback.is-bad { border-color: var(--cinabre); color: var(--error-ink); box-shadow: 3px 3px 0 var(--cinabre); }
.feedback.is-good { border-color: var(--accent); color: var(--accent); box-shadow: 3px 3px 0 var(--accent); }

.game-foot { padding: 0.6rem 0.75rem 0.75rem; border-top: 1.5px solid var(--ink); background: var(--ground); }

/* Fenêtre par-dessus la scène */
.overlay {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: grid;
  place-items: center;
  padding: 1rem;
  background: #f7f7f4e6;
  background-image: var(--dots);
  background-size: 22px 22px;
}
.overlay.is-late { animation: over-late 2.4s both; }
@keyframes over-late { 0%, 55% { opacity: 0; } 100% { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .overlay.is-late { animation: none; } }
.card-over {
  display: grid;
  gap: 0.8rem;
  width: min(100%, 24rem);
  padding: 1.4rem 1.3rem 1.3rem;
  background: var(--paper);
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  box-shadow: 4px 4px 0 var(--ink);
  text-align: center;
}
.over-kicker { margin: 0; font-family: var(--data); font-size: 0.85rem; color: var(--soft); }
.over-title { font-size: 1.8rem; line-height: 1.1; overflow-wrap: anywhere; }

.standings { display: grid; gap: 0.35rem; margin: 0; padding: 0; list-style: none; counter-reset: st; text-align: left; }
.standings li { display: flex; gap: 0.6rem; align-items: baseline; padding: 0.4rem 0.6rem; border-bottom: 1.5px solid var(--rule); counter-increment: st; }
.standings li::before { content: counter(st); width: 1.2rem; font-family: var(--data); color: var(--soft); }
.standings li.is-me { background: var(--hover); border-radius: 6px; }
.st-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 700; }
.st-extra { font-family: var(--data); font-size: 0.85rem; color: var(--soft); }
.st-pts { font-family: var(--data); font-weight: 700; }

/* ---------- Résultats ---------- */
.end { display: grid; gap: 1.2rem; max-width: 34rem; padding-top: 2.5rem; }
.end-title { font-size: clamp(2rem, 8vw, 2.8rem); line-height: 1.05; }
.end-sub { font-size: 1.15rem; margin-top: 1rem; }
.podium { display: grid; gap: 0.6rem; margin: 0; padding: 0; list-style: none; }
.podium li {
  display: grid;
  grid-template-columns: 2.2rem 1fr auto;
  grid-template-areas: "rank name pts" "rank detail pts";
  align-items: center;
  column-gap: 0.8rem;
  padding: 0.7rem 0.9rem;
  background: var(--paper);
  border: 2px solid var(--ink);
  border-radius: 8px;
  box-shadow: 3px 3px 0 var(--ink);
}
.podium li.is-top { background: var(--accent); color: #ffffff; }
.podium li.is-top .pod-detail { color: #ffffffcc; }
.podium li.is-me:not(.is-top) { border-color: var(--accent); }
.pod-rank { grid-area: rank; font-family: var(--data); font-weight: 700; font-size: 1.5rem; }
.pod-name { grid-area: name; font-weight: 700; font-size: 1.1rem; overflow-wrap: anywhere; }
.pod-detail { grid-area: detail; font-size: 0.85rem; color: var(--soft); }
.pod-pts { grid-area: pts; font-family: var(--data); font-weight: 700; font-size: 1.2rem; }

.recap-wrap { overflow-x: auto; border: 1.5px solid var(--ink); border-radius: 8px; background: var(--paper); }
.recap { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
.recap th, .recap td { padding: 0.4rem 0.6rem; border-bottom: 1px solid var(--rule); text-align: left; }
.recap thead th { font-size: 0.8rem; color: var(--soft); white-space: nowrap; }
.recap tbody th { font-weight: 400; }
.recap .recap-q { display: block; margin-bottom: 0.15rem; color: var(--soft); font-size: 0.82rem; line-height: 1.3; }
.recap td { width: 4.5rem; text-align: center; font-family: var(--data); font-weight: 700; }
.recap td.pts-3, .recap td.pts-4 { color: var(--accent); }
.recap td.pts-0 { color: var(--cinabre); }
.recap td .duel { font-size: 0.75rem; color: var(--accent); }
.recap-note { margin: -0.4rem 0 0; font-size: 0.85rem; color: var(--soft); }
.end-actions { display: grid; gap: 0.9rem; margin-top: 0.6rem; }

/* Grand écran : la carte garde de l'air autour */
@media (min-width: 900px) {
  .hud-top, .q-meta { width: min(100%, 44rem); margin-inline: auto; }
  .game-foot { display: flex; justify-content: center; }
  .game-foot .btn-big { width: 24rem; }
}
