/* Thème « Soirée » : fond prune, accents dorés. */
:root {
  --bg: #16131f;
  --card: #231e31;
  --card2: #2e2742;
  --text: #f3effa;
  --muted: #a79fbb;
  --accent: #f5b83d;
  --on-accent: #1b1405;
  --blue: #2f6fc0;
  --red: #c83a36;
  --green: #4cc38a;
  --on-green: #082417;
  --night: #101a3a;
  --night-text: #eef0ff;
  --night-muted: #b8beda;
  --radius: 18px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'Outfit', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  font-size: 17px;
  -webkit-tap-highlight-color: transparent;
  transition: background .6s;
}

body.night { background: var(--night); color: var(--night-text); }
body.night { --card: rgba(255, 255, 255, .08); --card2: rgba(255, 255, 255, .12); --muted: var(--night-muted); --text: var(--night-text); }

main {
  max-width: 520px;
  margin: 0 auto;
  padding: calc(20px + env(safe-area-inset-top)) 20px calc(28px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 100vh;
}

h1, h2, h3, p { margin: 0; }
p { line-height: 1.45; }
.muted { color: var(--muted); }
.center { text-align: center; }
.small { font-size: 14px; }
.section { font-size: 15px; font-weight: 700; color: var(--muted); margin-top: 4px; }

.wordmark { font-size: 46px; font-weight: 800; line-height: 1; letter-spacing: -.5px; margin-top: 36px; }
.title { font-size: 26px; font-weight: 800; }
.heading { font-size: 24px; font-weight: 800; }

.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

label { font-size: 14px; font-weight: 600; color: var(--muted); }

input, select {
  width: 100%;
  font: inherit;
  padding: 14px;
  border-radius: 12px;
  border: 2px solid var(--card2);
  background: var(--bg);
  color: var(--text);
  outline: none;
}
input:focus, select:focus { border-color: var(--accent); }
input.code {
  text-transform: uppercase;
  letter-spacing: 10px;
  text-align: center;
  font-size: 26px;
  font-weight: 800;
  padding: 12px;
  border-color: var(--accent);
}

button {
  font: inherit;
  font-weight: 700;
  width: 100%;
  padding: 15px;
  border: 0;
  border-radius: 12px;
  background: var(--accent);
  color: var(--on-accent);
  cursor: pointer;
}
button.big { font-size: 18px; font-weight: 800; padding: 16px; }
button.secondary { background: var(--card2); color: var(--text); }
button.ghost { background: transparent; color: var(--muted); text-decoration: underline; font-weight: 600; padding: 10px; }
button:disabled { opacity: .45; cursor: default; }
.ghost-link { display: block; text-align: center; color: var(--accent); font-weight: 600; padding: 10px; }
button.inline { width: auto; padding: 10px 14px; font-size: 15px; font-weight: 600; }
.bottom { margin-top: auto; display: flex; flex-direction: column; gap: 8px; }

.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { padding: 6px 12px; border-radius: 999px; background: var(--card2); font-size: 14px; font-weight: 600; }

.as-bar { display: flex; flex-direction: column; gap: 6px; padding: 10px 12px; border-radius: 12px; border: 1px dashed var(--accent); }
.as-bar .chip { width: auto; padding: 6px 12px; color: var(--text); }
.as-bar .chip.on { background: var(--accent); color: var(--on-accent); }

.divider { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 14px; }
.divider::before, .divider::after { content: ''; flex: 1; height: 1px; background: var(--card2); }

.topbar { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.topbar .right { display: flex; align-items: center; gap: 10px; }
.roomcode { font-weight: 800; letter-spacing: 3px; color: var(--accent); }
body.night .roomcode { color: var(--night-muted); }

.codecard { flex-direction: row; align-items: center; justify-content: space-between; }
.codecard .bigcode { font-size: 34px; font-weight: 800; letter-spacing: 8px; color: var(--accent); }
.codecard button { width: auto; padding: 12px 14px; font-size: 15px; }

/* Joueurs */
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.person { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 12px; background: var(--card); min-width: 0; }
.person .who { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; flex: 1; }
.person .who b { font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.person .who span { font-size: 12px; color: var(--muted); }
.person .kick { width: 32px; height: 32px; padding: 0; background: transparent; color: var(--muted); font-size: 18px; }
.avatar { width: 32px; height: 32px; flex: none; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 15px; color: #fff; }

.list { display: flex; flex-direction: column; gap: 8px; }
.item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 13px 16px;
  min-height: 50px;
  border-radius: 12px;
  background: var(--card);
  color: var(--text);
  text-align: left;
  font-weight: 400;
}
.item b { font-size: 17px; }
.item .note { font-size: 13px; font-weight: 700; }
.item.selected { background: var(--accent); color: var(--on-accent); }
.item.dead { opacity: .55; }
.item.dead b { text-decoration: line-through; }
.item.me { box-shadow: inset 0 0 0 2px var(--accent); }
button.item:disabled { opacity: .55; }
.rank { width: 28px; height: 28px; flex: none; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-weight: 800; font-size: 14px; background: var(--accent); color: var(--on-accent); margin-right: 12px; }
.badge { font-size: 13px; font-weight: 800; padding: 3px 8px; border-radius: 6px; background: var(--card2); color: var(--text); white-space: nowrap; }
.badge.red { background: var(--red); color: #fff; }
.badge.blue { background: var(--blue); color: #fff; }
.badge.light { background: var(--text); color: var(--bg); }
.badge.accent { background: var(--accent); color: var(--on-accent); }

/* Choix du jeu */
.game { padding: 12px 14px; border-radius: 12px; background: var(--card); border: 2px solid transparent; display: flex; justify-content: space-between; align-items: center; gap: 10px; text-align: left; color: var(--text); font-weight: 400; }
.game.active { border-color: var(--accent); }
.game b { display: block; font-size: 17px; }
.game span { font-size: 13px; color: var(--muted); }
div.game { cursor: default; }

.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; text-align: center; }
.stats > div { padding: 10px 4px; border-radius: 12px; background: var(--card2); }
.stats b { display: block; font-size: 22px; }
.stats span { font-size: 12px; color: var(--muted); }
.stats select { margin-top: 4px; padding: 6px; text-align: center; font-weight: 700; }
.toggles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.toggle { padding: 10px 6px; border-radius: 12px; background: var(--card2); color: var(--text); font-size: 14px; font-weight: 700; border: 2px solid transparent; }
.toggle.on { border-color: var(--accent); }
div.toggle { text-align: center; }

/* Cartes secrètes */
.secret {
  border-radius: var(--radius);
  padding: 22px 16px;
  text-align: center;
  background: var(--card2);
  color: var(--text);
  cursor: pointer;
  user-select: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.secret .label { font-size: 14px; opacity: .85; }
.secret .value { font-size: 38px; font-weight: 800; line-height: 1.1; }
.secret .hint { font-size: 13px; opacity: .85; }
.secret.hidden { flex-direction: row; justify-content: space-between; align-items: center; padding: 16px; }
.secret.hidden .value { font-size: 15px; letter-spacing: 3px; }
.secret.blue { background: var(--blue); color: #fff; }
.secret.red { background: var(--red); color: #fff; }
.tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.tiles .secret { padding: 14px; text-align: left; gap: 2px; }
.tiles .secret .value { font-size: 22px; }
.tiles .secret.hidden { flex-direction: column; align-items: flex-start; }

.banner { border-radius: var(--radius); padding: 14px 16px; background: var(--card); font-weight: 600; line-height: 1.4; }
.banner.accent { background: var(--accent); color: var(--on-accent); display: flex; gap: 10px; align-items: center; }
.banner.row { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-weight: 400; }
.banner.win, .banner.lose { text-align: center; padding: 26px 16px; display: flex; flex-direction: column; gap: 6px; }
.banner.win { background: var(--green); color: var(--on-green); }
.banner.lose { background: var(--red); color: #fff; }
.banner.win big, .banner.lose big { font-size: 30px; font-weight: 800; line-height: 1.1; }

.phase { display: flex; align-items: center; gap: 12px; }
.phase .heading { display: block; }
.phase svg { flex: none; }

.progress { display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--muted); }
.progress .bar { flex: 1; height: 8px; border-radius: 4px; background: var(--card2); overflow: hidden; }
.progress .bar div { height: 8px; background: var(--accent); }

.pips { display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }
.pips i { width: 14px; height: 20px; border-radius: 3px; background: var(--muted); }

.log { display: flex; flex-direction: column; gap: 6px; font-size: 14px; line-height: 1.35; }
.log div { padding-bottom: 6px; border-bottom: 1px solid var(--card2); }
.log div:last-child { border-bottom: 0; }

.note-box { border-radius: 12px; padding: 12px 14px; background: var(--card); font-size: 13px; color: var(--muted); line-height: 1.4; }

#toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: var(--red);
  color: #fff;
  padding: 12px 18px;
  border-radius: 12px;
  width: max-content;
  max-width: calc(100% - 32px);
  font-weight: 600;
  z-index: 10;
}

/* Time Bomb en 3D : la scène plein écran, l'interface flotte par-dessus. */
#tb3d { position: fixed; inset: 0; z-index: 0; background: #070a1f; touch-action: none; user-select: none; -webkit-user-select: none; }
#tb3d[hidden] { display: none; }
#tb3d canvas { width: 100%; height: 100%; display: block; }
body.tb3d { overflow: hidden; background: #070a1f; }
body.tb3d main {
  position: fixed;
  inset: 0;
  z-index: 1;
  max-width: none;
  min-height: 0;
  padding: calc(10px + env(safe-area-inset-top)) 12px calc(14px + env(safe-area-inset-bottom));
  gap: 8px;
  pointer-events: none;
}
body.tb3d main button, body.tb3d .tb-panel, body.tb3d .as-bar { pointer-events: auto; }
.tb-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.tb-stats { display: flex; gap: 12px; }
.tb-stats span { display: inline-flex; flex-direction: column; align-items: center; line-height: 1.1; font-size: 11px; }
.tb-stats, .tb-btn {
  background: rgba(22, 19, 31, .78);
  border: 1px solid rgba(245, 184, 61, .35);
  border-radius: 999px;
  padding: 6px 11px;
  font-size: 13px;
  color: var(--muted);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.tb-stats b { color: var(--accent); font-size: 15px; }
.tb-tools { display: flex; gap: 6px; flex: none; }
.tb-btn { width: auto; min-width: 38px; height: 34px; display: inline-flex; align-items: center; justify-content: center; color: var(--text); font-weight: 700; }
body.tb3d .as-bar { background: rgba(22, 19, 31, .78); align-self: flex-start; }
.tb-panel {
  margin-top: auto;
  align-self: center;
  width: 100%;
  max-width: 520px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--radius);
  background: rgba(22, 19, 31, .84);
  border: 1px solid rgba(245, 184, 61, .3);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.tb-panel .chip { width: auto; padding: 8px 14px; color: var(--text); font-size: 15px; }
.tb-panel .chip.on { background: var(--accent); color: var(--on-accent); }
.tb-panel button.big { display: flex; align-items: center; justify-content: center; gap: 8px; }
.tb-panel .banner { padding: 16px; }
.tb-roles .chip.blue { background: var(--blue); color: #fff; }
.tb-roles .chip.red { background: var(--red); color: #fff; }
.tb3d-flash { position: absolute; inset: 0; background: #fff6dc; opacity: 0; pointer-events: none; }
.tb3d-caption {
  position: absolute;
  left: 50%;
  bottom: 22%;
  transform: translate(-50%, 12px);
  opacity: 0;
  transition: opacity .25s, transform .25s;
  pointer-events: none;
  text-align: center;
  padding: 10px 20px;
  border-radius: 16px;
  max-width: calc(100% - 32px);
  width: max-content;
  background: rgba(22, 19, 31, .85);
  color: var(--text);
  box-shadow: 0 8px 30px rgba(0, 0, 0, .4);
}
.tb3d-caption.show { opacity: 1; transform: translate(-50%, 0); }
.tb3d-caption b { display: block; font-size: 26px; font-weight: 800; line-height: 1.15; }
.tb3d-caption span { display: block; font-size: 14px; opacity: .85; margin-top: 2px; }
.tb3d-caption.soft b { font-size: 18px; font-weight: 700; }
.tb3d-caption.blue { background: rgba(47, 111, 192, .92); color: #fff; }
.tb3d-caption.red { background: rgba(200, 58, 54, .94); color: #fff; }
.tb3d-caption.green { background: rgba(76, 195, 138, .94); color: var(--on-green); }
.tb3d-caption.gold { background: rgba(245, 184, 61, .94); color: var(--on-accent); }
.tb-panel .banner big { font-size: 24px; }
.tb-panel .banner { padding: 12px; gap: 2px; }
