:root {
  --bg: #0e1020;
  --panel: #171a2e;
  --panel-2: #1f2344;
  --line: #2b3157;
  --text: #e9ebfa;
  --muted: #8e95bf;
  --accent: #7c5cff;
  --ok: #35d6a5;
  --warn: #ffb454;
  --bad: #ff6b7a;
  --radius: 14px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
h1, h2, p { margin: 0; }
h2 { font-size: .8rem; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin-bottom: 10px; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }

/* ---------- Boutons & champs ---------- */
.btn {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  font: inherit;
  padding: 10px 16px;
  border-radius: 10px;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: border-color .15s, background .15s, transform .05s;
}
.btn:hover { border-color: var(--accent); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn.primary:hover { filter: brightness(1.1); }
.btn.small { padding: 5px 10px; font-size: .85rem; }

label { font-size: .85rem; color: var(--muted); }
input {
  width: 100%;
  font: inherit;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
}
input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
#code, #nameInput { letter-spacing: .15em; }
#code { text-transform: uppercase; font-family: ui-monospace, monospace; }
#nameInput { letter-spacing: normal; }

.alert {
  background: rgba(255, 180, 84, .12);
  border: 1px solid var(--warn);
  color: var(--warn);
  padding: 10px 14px;
  border-radius: 10px;
  font-size: .9rem;
}
.alert code { background: rgba(0, 0, 0, .3); padding: 1px 5px; border-radius: 4px; }
.error { color: var(--bad); min-height: 1.4em; font-size: .9rem; }

/* ---------- Accueil ---------- */
body.home { display: grid; place-items: center; padding: 20px; }
.card {
  width: min(440px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 28px;
  display: grid;
  gap: 12px;
}
.card h1 { font-size: 1.7rem; }
.row { display: flex; gap: 8px; }
.sep { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: .85rem; margin: 6px 0; }
.sep::before, .sep::after { content: ""; flex: 1; height: 1px; background: var(--line); }

/* ---------- Salon ---------- */
body.room { display: flex; flex-direction: column; height: 100dvh; }
.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}
.roomcode { display: flex; align-items: center; gap: 10px; margin: 0 auto; }
.roomcode strong { font-family: ui-monospace, monospace; letter-spacing: .2em; font-size: 1.1rem; }
.status { font-size: .85rem; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; }
.status::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--warn); }
.status[data-state="ok"]::before { background: var(--ok); }
.status[data-state="error"]::before { background: var(--bad); }

#configError { margin: 12px 16px 0; }

.layout { flex: 1; min-height: 0; display: grid; grid-template-columns: 300px 1fr; }
.side {
  overflow: auto;
  padding: 16px;
  border-right: 1px solid var(--line);
  display: grid;
  gap: 24px;
  align-content: start;
}
.pill {
  background: var(--panel-2);
  border-radius: 99px;
  padding: 0 8px;
  margin-left: 4px;
  color: var(--text);
  letter-spacing: 0;
}

.players { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.players li { display: flex; align-items: center; gap: 8px; padding: 8px 10px; background: var(--panel); border-radius: 10px; }
.players .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); flex: none; }
.players .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tag { font-size: .7rem; padding: 1px 7px; border-radius: 99px; background: var(--panel-2); color: var(--muted); flex: none; }
.tag.host { color: var(--accent); }

.games { display: grid; gap: 8px; }
.game {
  display: flex;
  gap: 12px;
  align-items: center;
  text-align: left;
  width: 100%;
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  font: inherit;
  cursor: pointer;
}
.game:hover { border-color: var(--accent); }
.game.active { border-color: var(--accent); background: var(--panel-2); }
.game .ico { font-size: 1.6rem; flex: none; }
.game .t { display: block; font-weight: 600; }
.game .d { display: block; font-size: .8rem; color: var(--muted); }
.game[data-warn] .d { color: var(--warn); }

.stage { min-width: 0; display: flex; flex-direction: column; gap: 8px; padding: 12px; }
.stagebar { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.stagebar strong { font-size: .95rem; }
.stagebar span:last-child { display: flex; gap: 6px; }
#game { flex: 1; width: 100%; border: 0; border-radius: var(--radius); background: #0b0d18; }
.placeholder {
  flex: 1;
  display: grid;
  place-items: center;
  color: var(--muted);
  border: 2px dashed var(--line);
  border-radius: var(--radius);
  text-align: center;
  padding: 20px;
}

dialog {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 24px;
  width: min(380px, calc(100% - 32px));
}
dialog::backdrop { background: rgba(5, 6, 15, .75); }
dialog form { display: grid; gap: 12px; }

@media (max-width: 800px) {
  .layout { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .side { border-right: 0; border-bottom: 1px solid var(--line); max-height: 42vh; }
  .roomcode { margin: 0; }
  .topbar { flex-wrap: wrap; }
}
