:root {
  --bg: #120E20;
  --bg-2: #1A1430;
  --card: #201A3A;
  --card-2: #281F49;
  --line: #352A57;
  --ink: #ECE7FA;
  --muted: #9A90BE;
  --mystery: #8E6BE6;      /* violet mystère */
  --mystery-2: #B79BFF;
  --spot: #E8A63C;         /* ambre projecteur */
  --spot-soft: #3a2c14;
  --good: #52C48C;
  --danger: #F0674C;
  --radius: 16px;
  --shadow: 0 20px 50px -24px rgba(0,0,0,.7);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  background:
    radial-gradient(1000px 500px at 80% -8%, rgba(142,107,230,.16), transparent 60%),
    radial-gradient(800px 500px at 0% 110%, rgba(232,166,60,.10), transparent 55%),
    var(--bg);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
.app {
  min-height: 100%;
  max-width: 560px;
  margin: 0 auto;
  padding: 24px 18px calc(28px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
}
.loader { margin: auto; color: var(--muted); }

/* ---- Brand ---- */
.brand { text-align: center; margin: 8px 0 26px; }
.brand .logo {
  font-size: 1.9rem; font-weight: 800; letter-spacing: -.02em;
  background: linear-gradient(100deg, var(--mystery-2), var(--spot));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.brand .tag { color: var(--muted); font-size: .9rem; margin-top: 2px; }

/* ---- Cards / layout ---- */
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow);
}
.stack { display: flex; flex-direction: column; gap: 14px; }
.stack-sm { display: flex; flex-direction: column; gap: 8px; }
h2 { margin: 0 0 4px; font-size: 1.35rem; letter-spacing: -.01em; }
h3 { margin: 0; font-size: 1rem; }
.muted { color: var(--muted); font-size: .92rem; margin: 0; }
.eyebrow { font-size: .72rem; letter-spacing: .16em; text-transform: uppercase; color: var(--mystery-2); font-weight: 700; }
.center { text-align: center; }

/* ---- Inputs ---- */
label { font-size: .82rem; color: var(--muted); display: block; margin-bottom: 6px; }
input[type=text], select {
  width: 100%; font-size: 1.05rem; padding: 14px 16px;
  background: var(--bg-2); border: 1px solid var(--line); border-radius: 12px;
  color: var(--ink); outline: none;
}
input[type=text]:focus, select:focus { border-color: var(--mystery); box-shadow: 0 0 0 3px rgba(142,107,230,.25); }
input.code { text-transform: uppercase; letter-spacing: .3em; font-weight: 700; text-align: center; font-size: 1.5rem; }

/* ---- Buttons ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; font-size: 1.05rem; font-weight: 650; padding: 15px 18px;
  border: none; border-radius: 12px; cursor: pointer; color: #170f28;
  background: linear-gradient(100deg, var(--mystery-2), var(--mystery));
  transition: transform .06s ease, filter .15s ease;
}
.btn:active { transform: translateY(1px) scale(.995); }
.btn:disabled { filter: grayscale(.6) brightness(.7); cursor: not-allowed; }
.btn.spot { background: linear-gradient(100deg, var(--spot), #d98f26); }
.btn.ghost { background: transparent; border: 1px solid var(--line); color: var(--ink); }
.btn.danger { background: linear-gradient(100deg, #f4795f, var(--danger)); color: #2a0f0a; }
.btn.sm { font-size: .92rem; padding: 11px 14px; width: auto; }

.row { display: flex; gap: 10px; }
.row > * { flex: 1; }

.err { color: var(--danger); font-size: .9rem; margin: 4px 2px 0; min-height: 1em; }
.divider { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: .8rem; margin: 4px 0; }
.divider::before, .divider::after { content: ""; height: 1px; background: var(--line); flex: 1; }

/* ---- Game list ---- */
.game-card {
  display: flex; gap: 14px; align-items: center; text-align: left;
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  padding: 16px; width: 100%; cursor: pointer; color: var(--ink);
}
.game-card:active { border-color: var(--mystery); }
.game-card .mask { font-size: 1.8rem; }
.game-card .info h3 { margin-bottom: 2px; }
.game-card .info p { margin: 0; color: var(--muted); font-size: .85rem; }
.game-card .cnt { margin-left: auto; color: var(--muted); font-size: .8rem; white-space: nowrap; }

/* ---- Lobby ---- */
.codebox { text-align: center; padding: 22px; }
.codebox .code {
  font-size: 3rem; font-weight: 800; letter-spacing: .35em; padding-left: .35em;
  color: var(--spot);
}
.players { display: flex; flex-direction: column; gap: 8px; }
.player {
  display: flex; align-items: center; gap: 12px;
  background: var(--bg-2); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px;
}
.player .av {
  width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center;
  font-weight: 800; color: #170f28; background: linear-gradient(120deg, var(--mystery-2), var(--spot));
}
.player .nm { font-weight: 600; }
.player .role-badges { margin-left: auto; display: flex; gap: 6px; }
.badge { font-size: .68rem; padding: 3px 9px; border-radius: 100px; font-weight: 700; letter-spacing: .04em; }
.badge.host { background: var(--spot-soft); color: var(--spot); }
.badge.off { background: rgba(240,103,76,.15); color: var(--danger); }
.badge.voted { background: rgba(82,196,140,.15); color: var(--good); }
.badge.dead { background: rgba(240,103,76,.15); color: var(--danger); }

.opt { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); }
.opt:first-child { border-top: none; }
.opt .lab { font-size: .95rem; }
.opt .lab small { display: block; color: var(--muted); font-size: .8rem; }
.toggle { width: 52px; height: 30px; border-radius: 100px; background: var(--line); position: relative; border: none; cursor: pointer; flex: 0 0 auto; }
.toggle.on { background: var(--mystery); }
.toggle::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; transition: left .15s ease; }
.toggle.on::after { left: 25px; }
.stepper { display: flex; align-items: center; gap: 12px; }
.stepper button { width: 34px; height: 34px; border-radius: 9px; border: 1px solid var(--line); background: var(--bg-2); color: var(--ink); font-size: 1.2rem; cursor: pointer; }
.stepper .val { min-width: 20px; text-align: center; font-weight: 700; }

/* ---- Game: word reveal ---- */
.wordcard {
  text-align: center; padding: 30px 20px;
  background: linear-gradient(160deg, var(--card-2), var(--card));
  border: 1px solid var(--mystery); border-radius: 20px;
  box-shadow: 0 0 0 1px rgba(142,107,230,.2), var(--shadow);
}
.wordcard .lab { font-size: .74rem; letter-spacing: .18em; text-transform: uppercase; color: var(--mystery-2); font-weight: 700; }
.wordcard .word { font-size: 2.6rem; font-weight: 800; margin: 10px 0 2px; letter-spacing: -.01em; }
.wordcard .word.white { color: var(--spot); font-size: 2rem; }
.wordcard .hint { color: var(--muted); font-size: .88rem; margin-top: 6px; }

.turnlist { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.turnlist .t { background: var(--bg-2); border: 1px solid var(--line); border-radius: 100px; padding: 7px 14px; font-size: .9rem; }
.turnlist .t .n { color: var(--muted); margin-right: 6px; font-variant-numeric: tabular-nums; }

/* ---- Voting ---- */
.votegrid { display: flex; flex-direction: column; gap: 8px; }
.votebtn {
  display: flex; align-items: center; gap: 12px; text-align: left;
  background: var(--bg-2); border: 1px solid var(--line); border-radius: 12px;
  padding: 13px 15px; color: var(--ink); font-size: 1rem; cursor: pointer; width: 100%;
}
.votebtn:active { border-color: var(--mystery); }
.votebtn.picked { border-color: var(--mystery); background: rgba(142,107,230,.15); }
.votebtn.dead { opacity: .4; }

/* ---- Result / reveal ---- */
.reveal-role { display: inline-block; padding: 6px 14px; border-radius: 100px; font-weight: 700; font-size: .9rem; }
.reveal-role.civil { background: rgba(142,107,230,.18); color: var(--mystery-2); }
.reveal-role.infiltre { background: var(--spot-soft); color: var(--spot); }
.reveal-role.mrwhite { background: rgba(255,255,255,.1); color: #fff; }

.result-banner { text-align: center; padding: 26px 18px; border-radius: 18px; }
.result-banner.civils { background: linear-gradient(160deg, rgba(142,107,230,.22), transparent); border: 1px solid var(--mystery); }
.result-banner.imposteurs, .result-banner.mrwhite { background: linear-gradient(160deg, rgba(232,166,60,.22), transparent); border: 1px solid var(--spot); }
.result-banner .big { font-size: 1.6rem; font-weight: 800; margin: 6px 0; }

.reveal-list { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.reveal-row { display: flex; align-items: center; gap: 10px; padding: 10px 12px; background: var(--bg-2); border-radius: 10px; }
.reveal-row .nm { font-weight: 600; }
.reveal-row .wd { margin-left: auto; color: var(--muted); font-size: .85rem; }

.card.invited { border-color: var(--spot); box-shadow: 0 0 0 1px rgba(232,166,60,.25), var(--shadow); }

#toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom));
  transform: translateX(-50%) translateY(16px);
  background: var(--card-2); border: 1px solid var(--mystery); color: var(--ink);
  padding: 12px 18px; border-radius: 12px; font-size: .92rem; text-align: center;
  max-width: 88vw; box-shadow: var(--shadow); z-index: 50;
  opacity: 0; pointer-events: none; transition: opacity .2s ease, transform .2s ease;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.waiting { text-align: center; color: var(--muted); padding: 18px; }
.foot { margin-top: auto; padding-top: 22px; text-align: center; color: var(--muted); font-size: .78rem; }
.spacer { flex: 1; }
