:root {
  --bg: #0b0d10;
  --bg-2: #14181d;
  --panel: rgba(20, 24, 29, 0.82);
  --ink: #e8e2d6;
  --ink-dim: #9a9285;
  --amber: #f0a84a;
  --amber-2: #ffcf7a;
  --teal: #1f4f5a;
  --danger: #d9534f;
  --ok: #7ccf8a;
  --serif: "Special Elite", "Courier New", monospace;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: radial-gradient(1200px 700px at 30% 10%, #1b2027 0%, var(--bg) 60%);
  color: var(--ink);
  font-family: var(--sans);
  overflow: hidden;
}

.grain {
  pointer-events: none;
  position: fixed; inset: 0; z-index: 50;
  opacity: 0.08;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/></filter><rect width='100%' height='100%' filter='url(%23n)' opacity='0.9'/></svg>");
  mix-blend-mode: overlay;
}

.screen { display: none; min-height: 100vh; }
.screen.active { display: flex; flex-direction: column; }

/* ---------- Titre ---------- */
#screen-title { position: relative; align-items: center; justify-content: center; padding: 24px; overflow: hidden; }
.bg-video {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; z-index: 0;
  opacity: 0.55; filter: saturate(.8);
  -webkit-mask-image: radial-gradient(70% 70% at 50% 45%, #000 40%, transparent 100%);
  mask-image: radial-gradient(70% 70% at 50% 45%, #000 40%, transparent 100%);
}
.title-card { position: relative; z-index: 1; }

/* ---------- Intro ---------- */
#screen-intro { position: relative; background: #000; align-items: center; justify-content: center; }
.intro-video { width: 100%; height: 100vh; object-fit: contain; background: #000; }
.skip { position: absolute; right: 22px; bottom: 22px; z-index: 2; opacity: .75; }
.skip:hover { opacity: 1; }
.title-card {
  max-width: 640px; width: 100%;
  padding: 44px 48px;
  background: var(--panel);
  border: 1px solid rgba(240, 168, 74, 0.18);
  box-shadow: 0 30px 80px rgba(0,0,0,0.6), inset 0 0 0 1px rgba(255,255,255,0.02);
  backdrop-filter: none;
}
.kicker {
  margin: 0 0 6px; font-family: var(--serif); letter-spacing: 0.18em; text-transform: uppercase;
  font-size: 12px; color: var(--amber);
}
h1 {
  margin: 0 0 18px; font-family: var(--serif); font-weight: 400;
  font-size: clamp(44px, 7vw, 72px); line-height: 0.95; letter-spacing: 0.01em;
  text-shadow: 0 0 24px rgba(240,168,74,0.15);
}
.lede { font-size: 16px; line-height: 1.55; color: var(--ink); margin: 0 0 18px; }
.lede strong { color: var(--amber-2); }
.howto { list-style: none; padding: 0; margin: 0 0 26px; color: var(--ink-dim); font-size: 14px; line-height: 1.6; }
.howto li { padding-left: 18px; position: relative; }
.howto li::before { content: "·"; position: absolute; left: 4px; color: var(--amber); }
.howto em { color: var(--ink); font-style: normal; font-weight: 600; }
.key {
  display: inline-block; padding: 1px 8px; border: 1px solid var(--ink-dim); border-bottom-width: 3px;
  border-radius: 4px; font-family: var(--serif); font-size: 12px; color: var(--ink);
}
.title-error { margin: 12px 0 0; font-size: 13px; color: var(--danger); text-align: center; }
.notice { margin: 16px 0 0; font-size: 12px; color: var(--ink-dim); text-align: center; }

.btn-primary, .btn-ghost {
  font-family: var(--sans); font-weight: 600; font-size: 15px; cursor: pointer;
  border-radius: 6px; padding: 14px 22px; transition: transform .08s ease, background .2s ease, box-shadow .2s;
}
.btn-primary {
  width: 100%; border: 0; color: #1a1207;
  background: linear-gradient(180deg, var(--amber-2), var(--amber));
  box-shadow: 0 10px 30px rgba(240,168,74,0.25);
}
.btn-primary:hover { transform: translateY(-1px); }
.btn-primary:disabled { opacity: .5; cursor: default; transform: none; }
.btn-ghost {
  background: transparent; color: var(--ink); border: 1px solid rgba(232,226,214,0.25);
}
.btn-ghost:hover { border-color: var(--amber); color: var(--amber-2); }

/* ---------- Briefing ---------- */
#screen-briefing { align-items: center; justify-content: center; padding: 24px; overflow-y: auto; }
.briefing {
  max-width: 900px; width: 100%; padding: 28px 40px; background: var(--panel);
  border: 1px solid rgba(240,168,74,0.18); box-shadow: 0 30px 80px rgba(0,0,0,0.6);
  animation: rise .5s ease both;
}
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
.briefing-head h2 { font-family: var(--serif); font-weight: 400; font-size: 30px; margin: 0 0 14px; }
.briefing-grid { display: grid; grid-template-columns: 236px 1fr; gap: 26px; margin-bottom: 18px; align-items: start; }
.briefing-video-wrap { display: grid; gap: 10px; }
.briefing-video {
  width: 236px; aspect-ratio: 9 / 16; object-fit: cover; border-radius: 10px; background: #000; display: block;
  border: 1px solid rgba(240,168,74,0.35); box-shadow: 0 18px 40px rgba(0,0,0,.55);
}
.briefing-story p { margin: 0 0 12px; font-size: 16px; line-height: 1.5; }
.briefing-story .time {
  display: inline-block; min-width: 118px; font-family: var(--serif); color: var(--amber); font-size: 14px; letter-spacing: .04em;
}
.briefing-warn { font-family: var(--serif); font-size: 22px; color: var(--amber-2); margin: 0; text-align: center; }
.briefing-suspects .briefing-warn-row { display: block; background: none; border: 0; padding: 10px 0 0; }
.briefing-suspects { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.briefing-suspects li { display: grid; grid-template-columns: 54px 1fr; gap: 12px; align-items: center; padding: 8px 10px; background: rgba(0,0,0,.25); border: 1px solid rgba(255,255,255,.06); border-radius: 8px; }
.briefing-suspects img { width: 54px; height: 66px; object-fit: cover; border-radius: 4px; }
.briefing-suspects b { font-family: var(--serif); font-weight: 400; font-size: 15px; display: block; }
.briefing-suspects small { display: block; color: var(--ink-dim); font-size: 12px; margin: 1px 0 3px; }
.briefing-suspects em { font-style: italic; color: var(--ink); font-size: 13px; }
.briefing-rules { list-style: none; margin: 0 0 24px; padding: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.briefing-rules li { display: grid; grid-template-columns: 34px 1fr; gap: 10px; font-size: 14px; line-height: 1.5; color: var(--ink-dim); }
.briefing-rules b { color: var(--ink); display: block; }
.briefing-rules .num { width: 30px; height: 30px; border-radius: 50%; border: 1px solid var(--amber); color: var(--amber); font-family: var(--serif); display: flex; align-items: center; justify-content: center; font-size: 15px; }
.briefing-actions { display: flex; gap: 12px; align-items: center; }
.briefing-actions .btn-primary { flex: 1; }
@media (max-width: 760px) {
  .briefing { padding: 26px 22px; }
  .briefing-grid, .briefing-rules { grid-template-columns: 1fr; }
  .briefing-video { width: 100%; max-width: 300px; margin: 0 auto; }
  .briefing-actions { flex-direction: column; }
}

/* ---------- Jeu ---------- */
#screen-game { height: 100vh; }
.topbar {
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  padding: 14px 22px; border-bottom: 1px solid rgba(255,255,255,0.06);
}
.brand { font-family: var(--serif); letter-spacing: 0.08em; color: var(--ink-dim); font-size: 14px; }
.timer {
  font-family: var(--serif); font-size: 30px; color: var(--amber-2); letter-spacing: 0.06em;
  text-align: center; font-variant-numeric: tabular-nums;
}
.timer.low { color: var(--danger); animation: blink 1s steps(2, start) infinite; }
@keyframes blink { to { visibility: hidden; } }
.topbar .btn-ghost { justify-self: end; padding: 10px 16px; }

.board {
  flex: 1; display: grid; grid-template-columns: 240px 1fr 280px; gap: 18px;
  padding: 18px 22px; min-height: 0;
}

.suspects { display: flex; flex-direction: column; gap: 12px; }
.suspect {
  display: grid; grid-template-columns: 56px 1fr; gap: 12px; align-items: center;
  padding: 10px; background: var(--panel); border: 1px solid rgba(255,255,255,0.06);
  border-radius: 8px; cursor: pointer; transition: border-color .2s, transform .1s;
  text-align: left; color: var(--ink); font: inherit;
}
.suspect:hover { border-color: rgba(240,168,74,0.5); transform: translateX(2px); }
.suspect.active { border-color: var(--amber); box-shadow: 0 0 0 1px rgba(240,168,74,0.35), 0 12px 30px rgba(0,0,0,0.4); }
.suspect img { width: 56px; height: 70px; object-fit: cover; border-radius: 4px; filter: grayscale(.3) contrast(1.05); }
.suspect.active img { filter: none; }
.suspect .n { font-family: var(--serif); font-size: 15px; }
.suspect .r { font-size: 12px; color: var(--ink-dim); }
.suspect .mood { font-size: 11px; color: var(--amber); margin-top: 2px; min-height: 13px; }

.room {
  position: relative; display: grid; grid-template-rows: 1fr auto auto; gap: 12px; min-height: 0;
  background: var(--panel); border: 1px solid rgba(255,255,255,0.06); border-radius: 10px; padding: 16px;
}
.portrait-wrap { position: relative; min-height: 0; display: flex; align-items: center; justify-content: center; overflow: hidden; border-radius: 6px; background: #000; }
.portrait { height: 100%; max-height: 100%; width: auto; max-width: 100%; object-fit: contain; display: block; opacity: 0; transition: opacity .35s ease, filter .3s; }
.portrait.show { opacity: 1; }
.portrait.shaken { filter: saturate(.7) contrast(1.15); }
.portrait.broken { filter: saturate(.4) brightness(.85); }
.lamp {
  position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(60% 70% at 25% 30%, rgba(240,168,74,0.10), transparent 70%);
}
.blinds {
  position: absolute; inset: 0; pointer-events: none; opacity: .18;
  background: repeating-linear-gradient(175deg, transparent 0 22px, rgba(0,0,0,0.55) 22px 34px);
}
.speaking-ring {
  position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%);
  width: 140px; height: 26px; display: flex; gap: 4px; align-items: flex-end; justify-content: center; opacity: 0; transition: opacity .2s;
}
.speaking-ring.on { opacity: 1; }
.speaking-ring i {
  display: block; width: 4px; height: 6px; background: var(--amber-2); border-radius: 2px;
  animation: bar .6s ease-in-out infinite alternate;
}
.speaking-ring i:nth-child(2n) { animation-delay: .12s; }
.speaking-ring i:nth-child(3n) { animation-delay: .24s; }
@keyframes bar { to { height: 24px; } }

.dialog { display: grid; gap: 6px; }
.name-tag { display: flex; align-items: baseline; gap: 10px; font-family: var(--serif); font-size: 18px; color: var(--amber-2); }
.name-tag small { font-family: var(--sans); font-size: 12px; color: var(--ink-dim); }
.line { min-height: 22px; font-size: 16px; line-height: 1.5; }
.line.user { color: var(--ink-dim); font-style: italic; }
.line.user::before { content: "Vous · "; font-style: normal; font-size: 12px; letter-spacing: .08em; text-transform: uppercase; }
.line.npc { color: var(--ink); font-size: 18px; }
.status { font-size: 12px; color: var(--ink-dim); min-height: 16px; }
.status.err { color: var(--danger); }

.controls { display: flex; justify-content: center; align-items: center; gap: 14px; padding-top: 4px; flex-wrap: wrap; }
.type-form { display: flex; gap: 8px; align-items: center; }
.type-form input {
  width: 300px; max-width: 50vw; padding: 11px 14px; border-radius: 999px; border: 1px solid rgba(232,226,214,0.18);
  background: rgba(0,0,0,0.35); color: var(--ink); font: 14px var(--sans); outline: none;
}
.type-form input:focus { border-color: var(--amber); }
.btn-ghost.small { padding: 10px 14px; font-size: 13px; }
.btn-talk {
  display: flex; align-items: center; gap: 12px; border: 1px solid rgba(240,168,74,0.5);
  background: rgba(240,168,74,0.08); color: var(--amber-2); border-radius: 999px; padding: 12px 22px 12px 14px;
  font: 600 14px var(--sans); cursor: pointer; user-select: none; -webkit-user-select: none; touch-action: none;
  transition: background .15s, transform .08s, box-shadow .15s;
}
.btn-talk .mic { width: 22px; height: 22px; border-radius: 50%; background: var(--amber); box-shadow: 0 0 0 0 rgba(240,168,74,.5); }
.btn-talk.rec { background: rgba(217,83,79,0.15); border-color: var(--danger); color: #ffb3b0; }
.btn-talk.rec .mic { background: var(--danger); animation: pulse 1s infinite; }
.btn-talk.busy { opacity: .55; cursor: wait; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(217,83,79,.55); } 100% { box-shadow: 0 0 0 16px rgba(217,83,79,0); } }

.notebook {
  background: var(--panel); border: 1px solid rgba(255,255,255,0.06); border-radius: 10px; padding: 16px;
  background-image: repeating-linear-gradient(180deg, transparent 0 27px, rgba(255,255,255,0.035) 27px 28px);
}
.notebook h2 { margin: 0 0 12px; font-family: var(--serif); font-weight: 400; font-size: 20px; color: var(--amber-2); }
.notebook ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.clue {
  display: grid; grid-template-columns: 22px 1fr; gap: 10px; align-items: start;
  font-size: 14px; line-height: 1.45; color: var(--ink-dim);
}
.clue .box { width: 18px; height: 18px; border: 1px solid var(--ink-dim); border-radius: 3px; margin-top: 2px; }
.clue.found { color: var(--ink); }
.clue.found .box { background: var(--amber); border-color: var(--amber); position: relative; }
.clue.found .box::after { content: ""; position: absolute; left: 5px; top: 1px; width: 5px; height: 10px; border: solid #1a1207; border-width: 0 2px 2px 0; transform: rotate(45deg); }
.clue.found { animation: pop .35s ease; }
@keyframes pop { from { transform: scale(.96); } to { transform: none; } }
.hint { font-size: 12px; color: var(--ink-dim); margin: 14px 0 0; line-height: 1.5; }

.footbar { display: flex; justify-content: space-between; padding: 10px 22px; font-size: 11px; color: var(--ink-dim); border-top: 1px solid rgba(255,255,255,0.06); }

/* ---------- Accusation ---------- */
#screen-accuse, #screen-end { align-items: center; justify-content: center; padding: 24px; }
.accuse-card, .end-card { max-width: 760px; width: 100%; padding: 36px 40px; background: var(--panel); border: 1px solid rgba(240,168,74,0.18); box-shadow: 0 30px 80px rgba(0,0,0,0.6); text-align: center; }
.accuse-card h2, .end-card h2 { font-family: var(--serif); font-weight: 400; font-size: 36px; margin: 0 0 22px; }
.accuse-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-bottom: 20px; }
.accuse-btn { background: var(--bg-2); border: 1px solid rgba(255,255,255,0.08); border-radius: 8px; padding: 12px; cursor: pointer; color: var(--ink); font: inherit; transition: border-color .2s, transform .1s; }
.accuse-btn:hover { border-color: var(--danger); transform: translateY(-2px); }
.accuse-btn img { width: 100%; aspect-ratio: 4/5; object-fit: cover; border-radius: 4px; margin-bottom: 8px; }
.accuse-btn .n { font-family: var(--serif); font-size: 16px; }
.accuse-btn .r { font-size: 12px; color: var(--ink-dim); }

/* ---------- Fin ---------- */
.end-portrait { width: 200px; aspect-ratio: 4/5; object-fit: cover; border-radius: 6px; margin: 0 auto 18px; display: block; box-shadow: 0 20px 50px rgba(0,0,0,.6); }
.end-text { font-size: 17px; line-height: 1.6; margin: 0 auto 22px; max-width: 600px; }
.end-actions { display: flex; justify-content: center; gap: 12px; }
.end-card.win h2 { color: var(--ok); }
.end-card.lose h2 { color: var(--danger); }

@media (max-width: 980px) {
  body { overflow: auto; }
  #screen-game { height: auto; min-height: 100vh; }
  .board { grid-template-columns: 1fr; }
  .suspects { flex-direction: row; overflow-x: auto; }
  .suspect { min-width: 200px; }
  .portrait-wrap { height: 46vh; }
  .accuse-grid { grid-template-columns: 1fr; }
}
