/* Une colonne calme ; le tableau blanc est le seul élément coloré et fort de l'écran. */
:root {
  --bg: #eef0f5;
  --surface: #ffffff;
  --ink: #161925;
  --muted: #676c7d;
  --line: #dde0e8;
  --accent: #2f5bea;
  --accent-ink: #ffffff;
  --accent-soft: #e6ecfd;
  --danger: #d93a43;
  --good: #0f9568;
  --paper: #ffffff;
  --display: 'Bricolage Grotesque', 'Avenir Next', system-ui, sans-serif;
  --body: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(22, 25, 37, .06), 0 6px 20px rgba(22, 25, 37, .06);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #11131a; --surface: #1a1d27; --ink: #eceef4; --muted: #9a9fb1; --line: #2a2e3b;
    --accent: #6f8cff; --accent-ink: #0d1020; --accent-soft: #1f2641; --danger: #ff6b72; --good: #3ccf98;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #11131a; --surface: #1a1d27; --ink: #eceef4; --muted: #9a9fb1; --line: #2a2e3b;
  --accent: #6f8cff; --accent-ink: #0d1020; --accent-soft: #1f2641; --danger: #ff6b72; --good: #3ccf98;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3); color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 500 16px/1.5 var(--body);
  -webkit-tap-highlight-color: transparent;
}
[hidden] { display: none !important; }
button { font-family: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

#app {
  padding-block: 20px max(32px, env(safe-area-inset-bottom));
  padding-left: max(16px, env(safe-area-inset-left));
  padding-right: max(16px, env(safe-area-inset-right));
}
.screen { margin: 0 auto; display: flex; flex-direction: column; gap: 16px; }
.narrow { max-width: 440px; }
.wide { max-width: 980px; }

/* Barre du haut */
.topbar {
  display: flex; align-items: center; gap: 12px;
  max-width: 1012px; margin: 0 auto;
  padding: max(12px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 0 max(16px, env(safe-area-inset-left));
}
.brand { font: 800 1.05rem var(--display); letter-spacing: -.01em; }
.room { margin-left: auto; font: 600 .85rem var(--body); color: var(--muted); letter-spacing: .14em; font-variant-numeric: tabular-nums; }
.icon-btn {
  width: 36px; height: 36px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--surface);
  display: grid; place-items: center; cursor: pointer; padding: 0; color: var(--muted);
}
.icon-btn svg { width: 18px; height: 18px; }

/* Typo */
h1, h2 { margin: 0; text-wrap: balance; }
h2, .title { font: 700 1.25rem/1.2 var(--display); letter-spacing: -.01em; margin: 0; }
.label { margin: 0; font-size: .75rem; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.muted { color: var(--muted); }
.hint { margin: 0; text-align: center; color: var(--muted); font-size: .92rem; }

/* Surfaces */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  display: flex; flex-direction: column; gap: 14px;
}

/* Champs et boutons */
input {
  font: 500 1rem var(--body);
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
  color: var(--ink);
  width: 100%; min-width: 0;
}
input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.btn {
  font: 600 .95rem var(--body);
  padding: 11px 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s, transform .08s;
}
.btn:hover:not(:disabled) { background: var(--bg); }
.btn:active:not(:disabled) { transform: scale(.98); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover:not(:disabled) { background: var(--accent); filter: brightness(1.08); }
.btn.block { width: 100%; padding: 13px 16px; font-size: 1rem; }
.btn.small { padding: 7px 12px; font-size: .85rem; }
.btn.link { border: 0; background: none; color: var(--muted); padding: 6px; align-self: center; }
.row { display: flex; gap: 8px; }

/* Accueil */
.home-head { text-align: center; padding: 6vh 0 4px; }
.logo { font: 800 clamp(2.6rem, 12vw, 3.4rem)/1 var(--display); letter-spacing: -.035em; }
.tagline { margin: 10px 0 0; color: var(--muted); }

.identity { display: flex; gap: 14px; align-items: center; }
.avatar-btn {
  position: relative; flex: none;
  width: 76px; height: 76px; border-radius: 50%;
  border: 1px solid var(--line); background: var(--bg);
  padding: 6px; cursor: pointer;
}
.avatar-btn .av { width: 100%; height: 100%; display: block; }
.avatar-btn .reroll {
  position: absolute; right: -2px; bottom: -2px;
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--surface); border: 1px solid var(--line);
  display: grid; place-items: center; font-size: .9rem; color: var(--muted);
}
.identity-fields { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 10px; }
.swatches { display: flex; flex-wrap: wrap; gap: 4px; }
.swatch { width: 17px; height: 17px; border-radius: 50%; border: 0; padding: 0; cursor: pointer; }
.swatch[aria-checked="true"] { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--ink); }
.join { display: flex; gap: 8px; }
.join input { text-transform: uppercase; letter-spacing: .3em; text-align: center; font-weight: 600; }
.join input::placeholder { letter-spacing: normal; text-transform: none; }
.or { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: .8rem; }
.or::before, .or::after { content: ''; flex: 1; height: 1px; background: var(--line); }

.rules { color: var(--muted); font-size: .92rem; padding: 0 4px; }
.rules summary { cursor: pointer; font-weight: 600; color: var(--ink); text-align: center; list-style: none; }
.rules summary::-webkit-details-marker { display: none; }
.rules ol { margin: 12px 0 0; padding-left: 20px; display: grid; gap: 6px; }

/* Salon */
.lobby-code { text-align: center; display: flex; flex-direction: column; gap: 8px; padding-top: 4vh; }
.code { font: 800 3.6rem/1 var(--display); letter-spacing: .12em; padding-left: .12em; font-variant-numeric: tabular-nums; }
.share-row { display: flex; gap: 8px; margin-top: 8px; }
.share-row input { font-size: .85rem; color: var(--muted); }
.card-head { display: flex; align-items: baseline; justify-content: space-between; }
.people { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.people li { display: flex; align-items: center; gap: 12px; padding: 8px 0; border-top: 1px solid var(--line); }
.people li:first-child { border-top: 0; }
.people .av { width: 36px; height: 36px; flex: none; }
.people .nm { font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.people li.off { opacity: .45; }
.people li.waiting { color: var(--muted); font-size: .92rem; }
.tag { margin-left: auto; font-size: .75rem; font-weight: 600; color: var(--muted); }
.tag + .tag { margin-left: 8px; }

/* Partie */
.game-layout { display: grid; gap: 16px; }
@media (min-width: 860px) { .game-layout { grid-template-columns: 200px 1fr; align-items: start; } }

.roster { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; margin: 0 -4px; padding: 2px 4px; }
.roster::-webkit-scrollbar { display: none; }
@media (min-width: 860px) { .roster { flex-direction: column; overflow: visible; margin: 0; padding: 0; gap: 2px; } }
.rp {
  flex: none; display: flex; align-items: center; gap: 8px;
  padding: 4px 10px 4px 4px; border-radius: 99px;
  font-size: .88rem;
}
@media (min-width: 860px) { .rp { border-radius: 10px; padding: 6px 8px; } }
.rp .av { width: 30px; height: 30px; flex: none; border-radius: 50%; }
.rp .nm { font-weight: 600; white-space: nowrap; max-width: 120px; overflow: hidden; text-overflow: ellipsis; }
.rp .sc { color: var(--muted); font-size: .8rem; margin-left: auto; padding-left: 6px; font-variant-numeric: tabular-nums; }
.rp.now { background: var(--accent-soft); }
.rp.now .av { box-shadow: 0 0 0 2px var(--accent); }
.rp.off { opacity: .4; }
.rp .ok { color: var(--good); font-weight: 700; }

.stage { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.stage-top { display: flex; align-items: center; gap: 10px; min-height: 36px; }
.status { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--muted); }
.status b { color: var(--ink); font-weight: 700; }
.status .me { color: var(--accent); }

.clock { position: relative; width: 36px; height: 36px; flex: none; }
.clock svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.clock circle { fill: none; stroke-width: 3; }
.clock .track { stroke: var(--line); }
.clock .arc { stroke: var(--accent); stroke-linecap: round; stroke-dasharray: 113.1; }
.clock.low .arc { stroke: var(--danger); }
.clock span { position: absolute; inset: 0; display: grid; place-items: center; font: 600 .8rem var(--body); font-variant-numeric: tabular-nums; }
.clock.low span { color: var(--danger); }

.board {
  align-self: center;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--line);
  overflow: hidden;
  max-width: 100%;
  transition: box-shadow .2s;
}
#board { display: block; background: var(--paper); touch-action: none; }
.board.my-turn { box-shadow: 0 0 0 3px var(--accent), var(--shadow); border-color: var(--accent); }
.board.my-turn #board { cursor: crosshair; }

.panel { display: flex; flex-direction: column; gap: 14px; }
.say { margin: 0; text-align: center; color: var(--muted); }
.say b { color: var(--ink); }

.choices { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
.choice {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px 8px 8px;
  border: 1px solid var(--line); border-radius: 12px;
  background: var(--surface); cursor: pointer;
  font: 600 .95rem var(--body); text-align: left; min-width: 0;
}
.choice .av { width: 34px; height: 34px; flex: none; }
.choice span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.choice:hover { border-color: var(--muted); }
.choice.picked { border-color: var(--accent); background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent); }

.verdict { text-align: center; }
.verdict .title { font-size: 1.8rem; }
.verdict.imposter .title { color: var(--danger); }
.verdict.artists .title { color: var(--good); }
.verdict p { margin: 6px 0 0; color: var(--muted); }

.facts { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.facts > div { background: var(--surface); padding: 14px; display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; min-width: 0; }
.facts strong { font: 700 1.25rem/1.2 var(--display); word-break: break-word; }
.facts .av { width: 44px; height: 44px; }
.facts > div { justify-content: center; }
.facts .word { font-size: 1.6rem; }

.table { list-style: none; margin: 0; padding: 0; }
.table li { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-top: 1px solid var(--line); font-size: .95rem; }
.table li:first-child { border-top: 0; }
.table .av { width: 26px; height: 26px; flex: none; }
.table .end { margin-left: auto; color: var(--muted); font-variant-numeric: tabular-nums; }
.table .hit { color: var(--good); font-weight: 600; }
.table .lead { font-weight: 700; }
.table .lead .end { color: var(--ink); }

/* Carte secrète */
.overlay {
  position: fixed; inset: 0; z-index: 10;
  background: rgba(10, 12, 20, .6);
  display: grid; place-items: center;
  padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  perspective: 1200px;
  animation: fade .2s;
}
@keyframes fade { from { opacity: 0; } }
.flip { width: min(320px, 100%); aspect-ratio: 3 / 4; max-width: 100%; cursor: pointer; animation: rise .35s cubic-bezier(.2, 1.2, .4, 1); }
@keyframes rise { from { transform: translateY(30px); opacity: 0; } }
.flip-inner { position: relative; width: 100%; height: 100%; transition: transform .55s cubic-bezier(.3, 1.2, .5, 1); transform-style: preserve-3d; }
.flip.flipped .flip-inner { transform: rotateY(180deg); }
.face {
  position: absolute; inset: 0;
  backface-visibility: hidden; -webkit-backface-visibility: hidden;
  border-radius: 20px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  padding: 24px; text-align: center;
}
.face.front { background: var(--ink); color: var(--bg); }
.face.front .q { font: 800 6rem/1 var(--display); }
.face.front p { margin: 0; opacity: .75; font-size: .92rem; }
.face.back { background: var(--surface); transform: rotateY(180deg); }
.face.back.imposter { background: var(--danger); color: #fff; }
.face .cat { font-size: .75rem; font-weight: 600; text-transform: uppercase; letter-spacing: .1em; opacity: .7; }
.face .word { font: 800 2.6rem/1.05 var(--display); letter-spacing: -.02em; word-break: break-word; }
.face p { margin: 0; font-size: .92rem; opacity: .8; }
.face .tap { font-size: .8rem; opacity: .55; }

/* Confettis (seulement pour le camp gagnant) */
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 30; overflow: hidden; }
.confetti i { position: absolute; top: -20px; width: 8px; height: 12px; border-radius: 2px; animation: fall linear forwards; }
@keyframes fall { to { transform: translate(var(--dx), 110vh) rotate(var(--rot)); } }

.toast {
  position: fixed; left: 50%; bottom: max(20px, env(safe-area-inset-bottom));
  transform: translate(-50%, 160%); visibility: hidden;
  background: var(--ink); color: var(--bg);
  padding: 10px 16px; border-radius: 10px; font-weight: 600; font-size: .92rem;
  transition: transform .25s, visibility .25s;
  z-index: 40; max-width: calc(100% - 32px); text-align: center;
}
.toast.show { transform: translate(-50%, 0); visibility: visible; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
