@font-face { font-family: 'Cinzel'; font-weight: 600; font-display: swap; src: url(/fonts/cinzel-latin-600-normal.woff2) format('woff2'); }
@font-face { font-family: 'Cinzel'; font-weight: 800; font-display: swap; src: url(/fonts/cinzel-latin-800-normal.woff2) format('woff2'); }
@font-face { font-family: 'Inter'; font-weight: 400; font-display: swap; src: url(/fonts/inter-latin-400-normal.woff2) format('woff2'); }
@font-face { font-family: 'Inter'; font-weight: 600; font-display: swap; src: url(/fonts/inter-latin-600-normal.woff2) format('woff2'); }
@font-face { font-family: 'Inter'; font-weight: 700; font-display: swap; src: url(/fonts/inter-latin-700-normal.woff2) format('woff2'); }

:root {
  --night-0: #06061a;
  --night-1: #0d0b2b;
  --night-2: #1a1446;
  --ink: #ece6ff;
  --muted: #9c95c4;
  --faint: #5f5891;
  --gold: #f1c76b;
  --gold-soft: rgba(241, 199, 107, .14);
  --violet: #8b6cff;
  --violet-soft: rgba(139, 108, 255, .16);
  --rose: #ff6f91;
  --mint: #6fe3c1;
  --card: rgba(255, 255, 255, .055);
  --card-strong: rgba(255, 255, 255, .09);
  --line: rgba(236, 230, 255, .12);
  --radius: 18px;
  --display: 'Cinzel', 'Times New Roman', serif;
  --body: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; min-height: 100%; }
body {
  background: var(--night-0);
  background-image:
    radial-gradient(ellipse 120% 70% at 50% -10%, #2a1d6b 0%, transparent 60%),
    radial-gradient(ellipse 80% 50% at 100% 100%, #1b0f3d 0%, transparent 70%),
    linear-gradient(180deg, var(--night-1), var(--night-0));
  background-attachment: fixed;
  color: var(--ink);
  font-family: var(--body);
  font-size: 16px;
  line-height: 1.45;
  overscroll-behavior: none;
  -webkit-font-smoothing: antialiased;
}

/* ---- ciel étoilé ---- */
.sky { position: fixed; inset: 0; pointer-events: none; z-index: 0; overflow: hidden; }
.sky i {
  position: absolute; width: 2px; height: 2px; border-radius: 50%; background: #fff;
  opacity: .5; animation: twinkle 4s ease-in-out infinite;
}
.sky .moon {
  position: absolute; top: -40px; right: -40px; width: 180px; height: 180px; border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #fff6dc, #f1c76b 45%, #b3873a 75%);
  box-shadow: 0 0 80px 20px rgba(241, 199, 107, .22), 0 0 200px 60px rgba(139, 108, 255, .12);
  opacity: .9;
}
.sky .moon::after {
  content: ''; position: absolute; inset: 0; border-radius: 50%;
  background: var(--night-1); transform: translate(-34%, 18%);
  box-shadow: inset 8px -4px 30px rgba(0,0,0,.4);
}
.sky .fog {
  position: absolute; left: -20%; right: -20%; bottom: -60px; height: 220px;
  background: radial-gradient(ellipse at center, rgba(139,108,255,.18), transparent 70%);
  filter: blur(20px); animation: drift 18s ease-in-out infinite alternate;
}
@keyframes twinkle { 0%, 100% { opacity: .15; } 50% { opacity: .9; } }
@keyframes drift { from { transform: translateX(-6%); } to { transform: translateX(6%); } }

/* ---- mise en page ---- */
#app {
  position: relative; z-index: 1; max-width: 520px; margin: 0 auto;
  min-height: 100dvh; padding: max(20px, env(safe-area-inset-top)) 16px max(24px, env(safe-area-inset-bottom));
  display: flex; flex-direction: column;
}
.screen { display: flex; flex-direction: column; gap: 16px; flex: 1; animation: rise .35s ease both; }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.grow { flex: 1; }
.center { text-align: center; }
.row { display: flex; gap: 10px; align-items: center; }
.row > * { flex: 1; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.spacer { height: 8px; }

header.bar { display: flex; align-items: center; gap: 10px; min-height: 44px; }
header.bar h2 { flex: 1; margin: 0; font-family: var(--display); font-size: 1.15rem; letter-spacing: .06em; }
.icon-btn {
  width: 44px; height: 44px; border-radius: 14px; border: 1px solid var(--line); background: var(--card);
  color: var(--ink); font-size: 20px; display: grid; place-items: center; cursor: pointer;
}

h1.logo {
  font-family: var(--display); font-weight: 800; font-size: clamp(3rem, 16vw, 4.4rem); letter-spacing: .12em;
  margin: 0; text-align: center; line-height: 1;
  background: linear-gradient(180deg, #fff8e6 10%, var(--gold) 60%, #a4772d);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  text-shadow: 0 0 40px rgba(241, 199, 107, .25);
}
.tagline { text-align: center; color: var(--muted); margin: 6px 0 0; font-style: italic; }
h3 { font-family: var(--display); font-weight: 600; letter-spacing: .05em; margin: 0 0 4px; font-size: 1rem; color: var(--gold); }
p { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.big { font-size: 1.25rem; }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px;
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}
.card.glow { box-shadow: 0 0 0 1px rgba(241,199,107,.25), 0 10px 40px rgba(139,108,255,.18); }

/* ---- boutons ---- */
.btn {
  appearance: none; border: 0; border-radius: 16px; padding: 16px 18px; min-height: 54px;
  font: 600 1rem var(--body); color: var(--night-0); cursor: pointer; width: 100%;
  background: linear-gradient(180deg, #ffe3a1, var(--gold)); box-shadow: 0 8px 24px rgba(241,199,107,.25);
  transition: transform .08s ease, opacity .2s;
  display: inline-flex; align-items: center; justify-content: center; gap: 10px; text-decoration: none;
}
.btn:active { transform: scale(.98); }
.btn[disabled] { opacity: .4; pointer-events: none; }
.btn.ghost { background: var(--card); color: var(--ink); border: 1px solid var(--line); box-shadow: none; }
.btn.violet { background: linear-gradient(180deg, #a891ff, var(--violet)); color: #fff; box-shadow: 0 8px 24px rgba(139,108,255,.3); }
.btn.danger { background: rgba(255,111,145,.14); color: var(--rose); border: 1px solid rgba(255,111,145,.35); box-shadow: none; }
.btn.small { min-height: 40px; padding: 8px 12px; font-size: .9rem; border-radius: 12px; width: auto; }
.btn .sub { display: block; font-weight: 400; font-size: .8rem; opacity: .75; }
.mode-btn { flex-direction: column; gap: 2px; padding: 18px; min-height: 84px; }
.mode-btn .t { font-family: var(--display); font-size: 1.15rem; letter-spacing: .06em; }

/* ---- formulaires ---- */
label.field { display: flex; flex-direction: column; gap: 6px; font-size: .85rem; color: var(--muted); }
input[type=text] {
  width: 100%; padding: 15px 16px; border-radius: 14px; border: 1px solid var(--line); background: rgba(0,0,0,.25);
  color: var(--ink); font: 500 1.05rem var(--body); outline: none;
}
input[type=text]:focus { border-color: var(--gold); box-shadow: 0 0 0 3px var(--gold-soft); }
input.code-input { text-transform: uppercase; letter-spacing: .5em; text-align: center; font-family: var(--display); font-size: 1.6rem; font-weight: 800; }

.stepper { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; }
.stepper + .stepper { border-top: 1px solid var(--line); }
.stepper .lbl { flex: 1; }
.stepper .lbl b { display: block; font-weight: 600; }
.stepper .ctrl { display: flex; align-items: center; gap: 6px; }
.stepper .ctrl button {
  width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--line); background: var(--card-strong);
  color: var(--ink); font-size: 1.3rem; cursor: pointer;
}
.stepper .ctrl button[disabled] { opacity: .3; }
.stepper .ctrl output { min-width: 28px; text-align: center; font: 700 1.2rem var(--display); }

.switch { position: relative; width: 52px; height: 30px; flex: 0 0 auto; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch span { position: absolute; inset: 0; border-radius: 30px; background: var(--card-strong); border: 1px solid var(--line); transition: .2s; }
.switch span::after { content: ''; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: var(--muted); transition: .2s; }
.switch input:checked + span { background: var(--violet-soft); border-color: var(--violet); }
.switch input:checked + span::after { transform: translateX(22px); background: var(--violet); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 1px solid var(--line); background: var(--card); color: var(--muted); border-radius: 999px;
  padding: 8px 12px; font: 500 .85rem var(--body); cursor: pointer;
}
.chip.on { background: var(--violet-soft); color: var(--ink); border-color: var(--violet); }
details.themes summary { cursor: pointer; list-style: none; display: flex; justify-content: space-between; align-items: center; }
details.themes summary::-webkit-details-marker { display: none; }
details.themes summary::after { content: '▾'; color: var(--muted); }
details.themes[open] summary::after { content: '▴'; }
details.themes .chips { margin-top: 12px; }

/* ---- joueurs ---- */
.players { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.players li {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 14px;
  background: var(--card); border: 1px solid var(--line);
}
.players li .name { flex: 1; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.players li.dead { opacity: .5; }
.players li.dead .name { text-decoration: line-through; text-decoration-color: var(--rose); }
.players li.me { border-color: rgba(241,199,107,.45); }
.players li.selected { border-color: var(--gold); background: var(--gold-soft); }
.players li.tap { cursor: pointer; }
.avatar {
  width: 36px; height: 36px; border-radius: 50%; flex: 0 0 auto; display: grid; place-items: center;
  font: 800 .95rem var(--display); color: var(--night-0);
}
.badge { font-size: .72rem; padding: 3px 8px; border-radius: 999px; background: var(--card-strong); color: var(--muted); white-space: nowrap; }
.badge.gold { background: var(--gold-soft); color: var(--gold); }
.badge.rose { background: rgba(255,111,145,.15); color: var(--rose); }
.badge.mint { background: rgba(111,227,193,.13); color: var(--mint); }
.badge.violet { background: var(--violet-soft); color: #c2b3ff; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--mint); flex: 0 0 auto; }
.dot.off { background: var(--faint); }
.x-btn { background: none; border: 0; color: var(--faint); font-size: 1.2rem; cursor: pointer; padding: 4px 6px; }
.order-num { font: 800 .9rem var(--display); color: var(--gold); width: 22px; text-align: center; }

/* ---- carte secrète ---- */
.secret-card {
  position: relative; border-radius: 24px; min-height: 280px; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 10px; text-align: center; padding: 28px 20px;
  background:
    radial-gradient(circle at 50% 0%, rgba(241,199,107,.18), transparent 60%),
    linear-gradient(160deg, #241a5c, #120d33);
  border: 1px solid rgba(241,199,107,.3);
  box-shadow: 0 20px 60px rgba(0,0,0,.45), inset 0 0 60px rgba(139,108,255,.15);
  user-select: none; -webkit-user-select: none; cursor: pointer; touch-action: manipulation;
  overflow: hidden;
}
.secret-card::before {
  content: ''; position: absolute; inset: 10px; border-radius: 18px; border: 1px dashed rgba(241,199,107,.22); pointer-events: none;
}
.secret-card .eye { font-size: 2.6rem; filter: drop-shadow(0 0 16px rgba(241,199,107,.5)); }
.secret-card .hint { color: var(--muted); font-size: .9rem; }
.secret-card .word {
  font-family: var(--display); font-weight: 800; font-size: clamp(2rem, 10vw, 2.8rem); letter-spacing: .04em;
  color: #fff8e6; text-shadow: 0 0 24px rgba(241,199,107,.45); word-break: break-word; line-height: 1.1;
}
.secret-card .role-white { font-family: var(--display); font-weight: 800; font-size: 2rem; color: #fff; text-shadow: 0 0 30px rgba(255,255,255,.6); }
.secret-card.revealed { animation: flip .35s ease; }
@keyframes flip { from { transform: rotateY(80deg); opacity: .3; } to { transform: none; opacity: 1; } }

.mini-word {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 14px;
  border-radius: 14px; background: var(--card); border: 1px solid var(--line); cursor: pointer; user-select: none;
}
.mini-word b { font-family: var(--display); letter-spacing: .04em; color: var(--gold); }

/* ---- QR / code ---- */
.invite { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.qr { width: min(64vw, 240px); aspect-ratio: 1; border-radius: 16px; background: #f4ecd8; padding: 8px; box-shadow: 0 0 40px rgba(241,199,107,.2); }
.qr img { width: 100%; height: 100%; display: block; image-rendering: pixelated; }
.room-code { font: 800 2.4rem var(--display); letter-spacing: .35em; color: var(--gold); padding-left: .35em; }

/* ---- résultats ---- */
.banner { text-align: center; padding: 24px 16px; }
.banner .emoji { font-size: 3.2rem; }
.banner h2 { font-family: var(--display); font-size: 1.8rem; margin: 8px 0 4px; letter-spacing: .06em; }
.banner.civils h2 { color: var(--mint); }
.banner.impostors h2 { color: var(--rose); }
.banner.mrwhite h2 { color: #fff; text-shadow: 0 0 24px rgba(255,255,255,.5); }
.words-reveal { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.words-reveal > div { text-align: center; padding: 14px 8px; border-radius: 14px; background: var(--card); border: 1px solid var(--line); }
.words-reveal small { display: block; color: var(--muted); font-size: .75rem; text-transform: uppercase; letter-spacing: .1em; }
.words-reveal b { font-family: var(--display); font-size: 1.2rem; }

.notice { padding: 12px 14px; border-radius: 14px; background: var(--violet-soft); border: 1px solid rgba(139,108,255,.4); color: #d8ceff; font-size: .92rem; }
.toast {
  position: fixed; left: 50%; bottom: max(20px, env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: #2a1d5c; color: var(--ink); border: 1px solid var(--line); padding: 12px 18px; border-radius: 14px;
  z-index: 10; box-shadow: 0 10px 30px rgba(0,0,0,.4); max-width: calc(100% - 32px); animation: rise .2s ease;
}
.conn { position: fixed; top: max(8px, env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); z-index: 9; }
.rules li { margin-bottom: 8px; }
.rules { padding-left: 20px; margin: 0; color: var(--muted); }
.rules b { color: var(--ink); }
footer.foot { text-align: center; color: var(--faint); font-size: .75rem; margin-top: 16px; }
footer.foot a { color: var(--muted); }
.hidden { display: none !important; }
.screen.still { animation: none; }
