/* 50/50 — feuille de style mobile-first (§5 : responsive, contrastes AA, cibles ≥ 44 px). */

:root {
  --bg: #161427;
  --bg-card: #211f3a;
  --bg-input: #2c2a4a;
  --fg: #f3f1ff;
  --muted: #a9a4cf;
  --primary: #7b5cff;
  --primary-press: #6a4bf0;
  --a: #ff5d73;
  --b: #36c5f0;
  --ok: #3cd28b;
  --radius: 16px;
  --gap: 16px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

#app {
  max-width: 560px;
  margin: 0 auto;
  padding: max(16px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom));
  min-height: 100vh;
}

/* ---- Écrans ---- */
.screen { display: none; flex-direction: column; gap: var(--gap); }
.screen.active { display: flex; }
.hidden { display: none !important; }

/* ---- Bandeau de connexion ---- */
.banner {
  position: fixed;
  top: 0; left: 0; right: 0;
  padding: 10px 16px;
  text-align: center;
  font-size: 0.9rem;
  font-weight: 600;
  z-index: 50;
  background: #b4452f;
  color: #fff;
}

/* ---- Hero ---- */
.hero { text-align: center; padding: 24px 0 8px; }
.logo {
  font-size: 4rem;
  font-weight: 900;
  margin: 0;
  letter-spacing: -2px;
  background: linear-gradient(120deg, var(--a), var(--primary), var(--b));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.logo span { opacity: 0.5; }
.tagline { color: var(--muted); margin: 8px 4px 0; line-height: 1.4; }

/* ---- Cartes & champs ---- */
.card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.card h2 { margin: 0 0 4px; font-size: 1.15rem; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-size: 0.85rem; color: var(--muted); font-weight: 600; }

input, select {
  width: 100%;
  padding: 14px;
  font-size: 1rem;
  border: 2px solid transparent;
  border-radius: 12px;
  background: var(--bg-input);
  color: var(--fg);
  min-height: 48px;
}
input:focus, select:focus { outline: none; border-color: var(--primary); }
#home-code { text-transform: uppercase; letter-spacing: 4px; font-weight: 700; text-align: center; }

/* ---- Boutons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 14px 20px;
  font-size: 1rem;
  font-weight: 700;
  border: none;
  border-radius: 12px;
  background: var(--bg-input);
  color: var(--fg);
  cursor: pointer;
  transition: transform 0.05s ease, background 0.15s ease;
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--primary); }
.btn-primary:active { background: var(--primary-press); }
.btn-block { width: 100%; }
.btn-small { min-height: 40px; padding: 8px 14px; font-size: 0.9rem; }
.btn-ghost { background: transparent; border: 2px solid var(--bg-input); align-self: flex-start; }

.divider { text-align: center; position: relative; color: var(--muted); font-size: 0.85rem; }
.divider::before, .divider::after {
  content: ''; position: absolute; top: 50%; width: 40%; height: 1px; background: var(--bg-input);
}
.divider::before { left: 0; }
.divider::after { right: 0; }

/* ---- Topbar (lobby) ---- */
.topbar { display: flex; align-items: center; justify-content: space-between; }
.room-code .label { display: block; font-size: 0.75rem; color: var(--muted); }
.room-code strong { font-size: 2rem; letter-spacing: 4px; }

/* ---- Listes de joueurs ---- */
.player-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.player-list li {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; background: var(--bg-input); border-radius: 12px;
}
.dot { width: 14px; height: 14px; border-radius: 50%; flex-shrink: 0; }
.player-list .name { flex: 1; font-weight: 600; }
.tag { font-size: 0.7rem; padding: 2px 8px; border-radius: 99px; background: var(--primary); font-weight: 700; }
.tag.off { background: #555; }
.kick { background: none; border: none; color: var(--a); font-size: 1.2rem; cursor: pointer; padding: 4px 8px; }

.muted { color: var(--muted); font-weight: 400; }
.hint { color: var(--muted); text-align: center; }
.center { text-align: center; }

/* Indicateur de manche */
.round-indicator {
  align-self: center;
  margin: 0 auto 4px;
  padding: 4px 14px;
  border-radius: 99px;
  background: var(--primary);
  color: #fff;
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0.5px;
}

/* ---- Phases de jeu ---- */
.phase-tag {
  align-self: center;
  background: var(--bg-input);
  color: var(--muted);
  padding: 6px 16px;
  border-radius: 99px;
  font-size: 0.85rem;
  font-weight: 700;
}
.prompt {
  font-size: 1.4rem;
  font-weight: 700;
  line-height: 1.35;
  text-align: center;
  padding: 8px 4px;
}

/* ---- Vote ---- */
.vote-options { display: flex; flex-direction: column; gap: 14px; }
.vote-btn {
  display: flex; align-items: center; gap: 14px;
  width: 100%; min-height: 80px; padding: 18px;
  border: 3px solid transparent; border-radius: var(--radius);
  background: var(--bg-card); color: var(--fg);
  font-size: 1.1rem; text-align: left; cursor: pointer;
  transition: transform 0.05s, border-color 0.15s;
}
.vote-btn:active { transform: scale(0.98); }
.vote-btn[data-choice="A"] .vote-letter { background: var(--a); }
.vote-btn[data-choice="B"] .vote-letter { background: var(--b); }
.vote-btn.selected { border-color: var(--fg); }
.vote-letter {
  display: flex; align-items: center; justify-content: center;
  width: 44px; height: 44px; border-radius: 12px;
  font-weight: 900; font-size: 1.3rem; flex-shrink: 0;
}
.vote-text { flex: 1; font-weight: 600; }
.status { text-align: center; color: var(--muted); min-height: 1.2em; }
.timer { text-align: center; font-size: 1.5rem; font-weight: 800; }

/* ---- Attente / spinner ---- */
#screen-wait { align-items: center; justify-content: center; padding-top: 80px; }
.spinner {
  width: 48px; height: 48px; border-radius: 50%;
  border: 5px solid var(--bg-input); border-top-color: var(--primary);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- Révélation : barres ---- */
.bars { display: flex; flex-direction: column; gap: 14px; }
.bar-row { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; align-items: center; }
.bar-label { font-weight: 600; font-size: 0.95rem; }
.bar-count { grid-row: span 2; align-self: center; font-weight: 800; font-size: 1.2rem; }
.bar-track { grid-column: 1; height: 16px; border-radius: 99px; background: var(--bg-input); overflow: hidden; }
.bar-fill { height: 100%; width: 0; border-radius: 99px; transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1); }
.bar-a { background: var(--a); }
.bar-b { background: var(--b); }

/* Qui a voté quoi (révélé après la manche) */
.voters { display: flex; flex-wrap: wrap; gap: 6px; margin: -4px 0 4px; }
.voter-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: 99px;
  background: var(--bg-input); font-size: 0.85rem; font-weight: 600;
}
.voter-chip .dot { width: 10px; height: 10px; }

.score-badge {
  text-align: center; font-size: 1.1rem; padding: 14px;
  background: var(--bg-card); border-radius: var(--radius);
}
.score-badge strong { font-size: 1.8rem; color: var(--ok); margin: 0 4px; }

/* ---- Classements ---- */
.standings { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.standings li {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px; background: var(--bg-card); border-radius: 12px;
}
.standings.mini li { padding: 8px 12px; background: var(--bg-input); }
.rank { font-weight: 800; width: 28px; text-align: center; color: var(--muted); }
.standings li.top-1 .rank { color: gold; }
.standings li.top-2 .rank { color: silver; }
.standings li.top-3 .rank { color: #cd7f32; }
.standings .name { flex: 1; font-weight: 600; }
.standings .pts { font-weight: 800; }

.host-only, .guest-only { display: none; }
body.is-host .host-only { display: flex; }
body.is-host .guest-only { display: none; }
body:not(.is-host) .guest-only { display: block; }
p.host-only, p.guest-only { display: none; }
body.is-host p.host-only { display: block; }
body:not(.is-host) p.guest-only { display: block; }

/* toasts d'erreur */
#toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: #b4452f; color: #fff; padding: 12px 20px; border-radius: 12px;
  font-weight: 600; z-index: 100; max-width: 90%; text-align: center;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}
