/* — Réviseur TLMVP : sobre, responsive, clair/sombre — */
:root {
  --bg: #f4f6fb; --card: #ffffff; --ink: #1c2333; --muted: #66708a;
  --accent: #2456d6; --accent-ink: #ffffff; --accent-soft: #e5ecff;
  --ok: #1a8a4a; --ok-soft: #e3f6ec; --bad: #c23a3a; --bad-soft: #fdeaea;
  --line: #dfe4f0; --shadow: 0 1px 3px rgba(20, 30, 70, .08), 0 8px 24px rgba(20, 30, 70, .06);
  --radius: 14px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #10131c; --card: #1a1f2e; --ink: #e7eaf3; --muted: #97a0bb;
    --accent: #6d93ff; --accent-ink: #0d1220; --accent-soft: #232c4a;
    --ok: #4fc98a; --ok-soft: #173226; --bad: #ff8080; --bad-soft: #3a1d1d;
    --line: #2a3148; --shadow: 0 1px 3px rgba(0, 0, 0, .4);
  }
}
:root[data-theme="dark"] {
  --bg: #10131c; --card: #1a1f2e; --ink: #e7eaf3; --muted: #97a0bb;
  --accent: #6d93ff; --accent-ink: #0d1220; --accent-soft: #232c4a;
  --ok: #4fc98a; --ok-soft: #173226; --bad: #ff8080; --bad-soft: #3a1d1d;
  --line: #2a3148; --shadow: 0 1px 3px rgba(0, 0, 0, .4);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
.app { max-width: 760px; margin: 0 auto; padding: 0 14px 48px; }

.topbar {
  position: sticky; top: 0; z-index: 10; display: flex; align-items: center;
  justify-content: space-between; padding: 12px 2px; background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; letter-spacing: .4px; }
.brand-full { font-weight: 400; color: var(--muted); font-size: .8em; margin-left: 6px; }
.conn { font-size: 18px; color: var(--muted); }
.conn.on { color: var(--ok); } .conn.off { color: var(--bad); }

.theme-select {
  appearance: none; border: 1px solid var(--line); background: var(--card); color: var(--ink);
  border-radius: 8px; padding: 4px 8px; font: inherit; font-size: .8rem; cursor: pointer;
}
.theme-select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 20px; margin: 14px 0;
}
h1 { font-size: 1.35rem; margin: 0 0 8px; }
h2 { font-size: 1.05rem; margin: 0 0 12px; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.error { color: var(--bad); }

.btn {
  appearance: none; border: 1px solid var(--line); background: var(--card); color: var(--ink);
  border-radius: 10px; padding: 10px 16px; font: inherit; font-weight: 600;
  cursor: pointer; transition: transform .05s, background .15s, border-color .15s;
}
.btn:hover { border-color: var(--accent); }
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.big { padding: 16px 22px; font-size: 1.05rem; }
.btn.subtle { color: var(--muted); }
.btn:disabled { opacity: .5; cursor: default; }
.home-head { display: flex; align-items: baseline; flex-wrap: wrap; gap: 8px; }
.linklike {
  background: none; border: none; color: var(--muted); cursor: pointer; font: inherit;
  font-size: .8rem; padding: 0; opacity: .8; text-decoration: none; line-height: 1.2;
}
.linklike:hover { text-decoration: underline; }

input[type="text"], input[type="number"] {
  width: 100%; padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--bg); color: var(--ink); font: inherit;
}
input[type="text"]:focus, input[type="number"]:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
label { display: block; margin: 12px 0 6px; font-weight: 600; }
form .btn { margin-top: 14px; }
.row { display: flex; gap: 10px; align-items: center; }
.row input { flex: 1; }
.row.wrap { flex-wrap: wrap; }
.row .btn { margin-top: 0; }

.home-actions { display: grid; gap: 12px; grid-template-columns: 1fr 1fr; margin: 18px 0 6px; }
@media (max-width: 560px) { .home-actions { grid-template-columns: 1fr; } }
.join-box { margin-top: 12px; }
.join-box summary { cursor: pointer; color: var(--muted); }
.join-box .row { margin-top: 10px; align-items: stretch; }
.join-box .row .btn { padding-top: 12px; padding-bottom: 12px; }

.themes { list-style: none; margin: 0; padding: 0; }
.themes li { padding: 10px 0; border-bottom: 1px solid var(--line); }
.themes li:last-child { border-bottom: none; }
.themes .t-nom { font-weight: 700; }
.themes .t-nb { float: right; color: var(--muted); font-size: .85rem; }
.themes .t-desc { color: var(--muted); font-size: .85rem; margin: 4px 0 8px; }
.progress { height: 6px; border-radius: 4px; background: var(--line); overflow: hidden; }
.progress > div { height: 100%; background: var(--accent); border-radius: 4px; }

.players { list-style: none; margin: 0 0 12px; padding: 0; }
.players li {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: 10px; margin-bottom: 8px;
}
.players li.me { border-color: var(--accent); background: var(--accent-soft); }
.players .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); flex: none; }
.players .dot.on { background: var(--ok); }
.players .p-name { flex: 1; font-weight: 600; overflow-wrap: anywhere; }
.players .p-meta { color: var(--muted); font-size: .85rem; }
.players .badge {
  font-size: .75rem; font-weight: 700; padding: 2px 8px; border-radius: 999px;
  background: var(--line); color: var(--ink);
}
.players .badge.ready { background: var(--ok-soft); color: var(--ok); }
.players .badge.host { background: var(--accent-soft); color: var(--accent); }

.share label { font-weight: 600; }

.game-head { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; }
.tag {
  font-size: .75rem; font-weight: 700; letter-spacing: .4px; text-transform: uppercase;
  background: var(--accent-soft); color: var(--accent); padding: 3px 10px; border-radius: 999px;
}
.timer { position: relative; height: 12px; border-radius: 8px; background: var(--line); overflow: hidden; margin: 6px 0 14px; }
.timer-bar { height: 100%; width: 100%; background: var(--accent); border-radius: 8px; }
.timer.warn .timer-bar { background: var(--bad); }
.timer-text { position: absolute; right: 6px; top: -2px; font-size: .7rem; font-weight: 700; color: var(--ink); }
.question { font-size: 1.15rem; line-height: 1.45; margin: 6px 0 16px; }

.choices { display: grid; gap: 10px; grid-template-columns: 1fr 1fr; }
@media (max-width: 560px) { .choices { grid-template-columns: 1fr; } }
.choice {
  display: flex; align-items: center; gap: 12px; text-align: left;
  border: 1px solid var(--line); background: var(--card); color: var(--ink);
  border-radius: 12px; padding: 13px 15px; font: inherit; cursor: pointer;
}
.choice:hover:not(:disabled) { border-color: var(--accent); }
.choice:disabled { cursor: default; opacity: .75; }
.choice .letter {
  flex: none; width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent); font-weight: 800; font-size: .9rem;
}
.choice.correct { border-color: var(--ok); background: var(--ok-soft); opacity: 1; }
.choice.correct .letter { background: var(--ok); color: #fff; }
.choice.wrong { border-color: var(--bad); background: var(--bad-soft); opacity: 1; }
.choice.wrong .letter { background: var(--bad); color: #fff; }
.choice.chosen { outline: 2px solid var(--accent); outline-offset: 1px; }

.reveal { margin-top: 14px; }
.reveal #reveal-verdict { font-weight: 800; margin: 0 0 6px; }
.reveal #reveal-verdict.ok { color: var(--ok); }
.reveal #reveal-verdict.ko { color: var(--bad); }

.countdown {
  margin-top: 16px; padding: 14px; display: flex; align-items: center; gap: 12px;
  justify-content: center; border-radius: var(--radius); background: var(--accent-soft);
}
.countdown-number {
  font-size: 2rem; font-weight: 800; color: var(--accent); min-width: 1.4em; text-align: center;
  animation: countdown-pulse .5s ease-out;
}
.countdown-label { font-weight: 600; color: var(--muted); }
@keyframes countdown-pulse {
  0% { transform: scale(1.6); opacity: 0; }
  60% { transform: scale(1); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}

.results { list-style: none; margin: 0 0 16px; padding: 0; counter-reset: rk; }
.results li {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px;
  border: 1px solid var(--line); border-radius: 12px; margin-bottom: 8px;
}
.results li.me { border-color: var(--accent); background: var(--accent-soft); }
.results .rank { font-size: 1.3rem; font-weight: 800; width: 34px; text-align: center; }
.results li:nth-child(1) .rank { color: #d4a017; }
.results li:nth-child(2) .rank { color: #8a8f9c; }
.results li:nth-child(3) .rank { color: #b06f3b; }
.results .r-name { flex: 1; font-weight: 600; }
.results .r-score { font-weight: 800; }

.footnote { text-align: center; margin-top: 18px; }

/* Bandeau d'alerte (permissions serveur, etc.) */
.banner {
  border: 1px solid var(--bad); background: var(--bad-soft); color: var(--bad);
  border-radius: 10px; padding: 10px 14px; margin: 12px 0; font-weight: 600; font-size: .9rem;
}

/* Formulaire de configuration de partie */
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
@media (max-width: 560px) { .grid2 { grid-template-columns: 1fr; } }
.themes-box {
  display: grid; grid-template-columns: 1fr 1fr; gap: 4px 18px;
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; background: var(--bg);
}
@media (max-width: 560px) { .themes-box { grid-template-columns: 1fr; } }
.themes-box label { display: flex; align-items: center; gap: 10px; font-weight: 500; margin: 2px 0; cursor: pointer; }
.themes-box input[type="checkbox"] { accent-color: var(--accent); width: 16px; height: 16px; flex: none; }
.themes-box span { overflow-wrap: anywhere; }
.toast {
  position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%);
  background: var(--ink); color: var(--bg); border-radius: 10px;
  padding: 10px 18px; font-weight: 600; box-shadow: var(--shadow);
  max-width: min(92vw, 480px); z-index: 50;
}
[hidden] { display: none !important; }
