:root {
  --bg: #07060b;
  --ink: #f4ecdf;
  --muted: #a99fb8;
  --panel: #1b1626;
  --panel-2: #2a2238;
  --line: #f4ecdf;
  --accent: #ffcc4d;
  --good: #5fd47a;
  --bad: #ff4d5e;
  --blue: #4f8cff;
  --pixel: "Press Start 2P", monospace;
  --text: "VT323", monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); overflow: hidden; font-family: var(--text); }
[hidden] { display: none !important; }
button { font-family: var(--text); cursor: pointer; }

#stage { position: absolute; width: 672px; height: 900px; transform-origin: 0 0; overflow: hidden; background: #000; user-select: none; }
#game { position: absolute; inset: 0; width: 672px; height: 900px; image-rendering: pixelated; }

/* ---------- HUD ---------- */
#hud { position: absolute; top: 0; left: 0; right: 0; height: 52px; display: flex; align-items: center; justify-content: space-between; padding: 0 40px; font-size: 26px; pointer-events: none; }
#hud-room { font-family: var(--pixel); font-size: 12px; color: var(--muted); letter-spacing: 1px; }
.hud-btns { display: flex; gap: 8px; pointer-events: auto; }
.hud-btns button { background: var(--panel); color: var(--ink); border: 2px solid var(--panel-2); padding: 4px 10px; font-size: 20px; border-radius: 4px; }
.hud-btns button:hover { border-color: var(--accent); }

/* ---------- Dialogue ---------- */
#dialog { position: absolute; left: 18px; right: 18px; bottom: 14px; min-height: 150px; background: rgba(18, 14, 28, .96); border: 4px solid var(--line); border-radius: 8px; box-shadow: 0 0 0 4px #000, 0 8px 0 4px rgba(0,0,0,.4); padding: 20px 24px 18px; font-size: 30px; line-height: 1.12; cursor: pointer; z-index: 20; }
#dialog.narr { font-style: italic; color: #e4dcf0; }
#dialog-name { position: absolute; top: -22px; left: 18px; background: var(--accent); color: #1a1220; font-family: var(--pixel); font-size: 12px; padding: 8px 12px; border: 3px solid #000; border-radius: 4px; font-style: normal; }
#dialog-more { position: absolute; right: 16px; bottom: 8px; font-size: 22px; color: var(--accent); animation: bob .6s infinite alternate; }
#choices { display: flex; flex-direction: column; gap: 6px; margin-top: 12px; }
#choices button { text-align: left; background: transparent; color: var(--ink); border: 2px solid transparent; font-size: 28px; padding: 2px 10px; border-radius: 4px; }
#choices button.sel, #choices button:hover { border-color: var(--accent); color: var(--accent); }
#choices button.sel::before { content: "▶ "; }
@keyframes bob { to { transform: translateY(4px); } }

/* ---------- Lineup (intro) ---------- */
#lineup { position: absolute; left: 0; right: 0; top: 300px; display: flex; justify-content: center; gap: 10px; z-index: 15; }
#lineup .lu { background: rgba(18,14,28,.92); border: 3px solid var(--panel-2); border-radius: 6px; padding: 6px; text-align: center; font-size: 20px; width: 118px; opacity: .45; transition: .2s; }
#lineup .lu.on { opacity: 1; border-color: var(--accent); transform: translateY(-8px) scale(1.05); }
#lineup canvas { display: block; margin: 0 auto 4px; image-rendering: pixelated; }

/* ---------- Toasts ---------- */
#toasts { position: absolute; top: 60px; right: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 40; align-items: flex-end; }
.toast { background: var(--panel); border: 3px solid var(--accent); border-radius: 6px; padding: 8px 14px; font-size: 22px; max-width: 360px; animation: slidein .25s ease-out; transition: opacity .4s, transform .4s; }
.toast.clue { border-color: var(--blue); }
.toast.out { opacity: 0; transform: translateX(40px); }
.toast.teams { background: #fff; color: #242424; border: none; border-left: 6px solid #5b5fc7; font-family: system-ui, sans-serif; font-size: 15px; width: 360px; padding: 12px 14px; box-shadow: 0 6px 24px rgba(0,0,0,.5); }
.teams-head { display: flex; align-items: center; gap: 8px; font-weight: 600; margin-bottom: 6px; }
.teams-logo { width: 26px; height: 26px; background: #5b5fc7; color: #fff; border-radius: 5px; display: grid; place-items: center; font-weight: 700; }
.teams-file { margin-top: 8px; display: flex; align-items: center; gap: 8px; background: #f3f2f1; padding: 8px; border-radius: 4px; }
.teams-file b { color: #c4314b; }
@keyframes slidein { from { transform: translateX(60px); opacity: 0; } }

#flash { position: absolute; inset: 0; opacity: 0; pointer-events: none; z-index: 60; }
#flash.on { background: var(--bad); animation: flash .45s; }
@keyframes flash { 0%, 60% { opacity: .45; } 30% { opacity: .15; } 100% { opacity: 0; } }
#fade { position: absolute; inset: 0; background: #000; opacity: 0; pointer-events: none; transition: opacity .22s; z-index: 70; }

/* ---------- Overlays ---------- */
.overlay { position: absolute; inset: 0; background: rgba(5, 4, 10, .82); display: flex; align-items: center; justify-content: center; z-index: 50; }
.panel { background: var(--panel); border: 4px solid var(--line); box-shadow: 0 0 0 4px #000; border-radius: 8px; padding: 22px 26px; width: 600px; max-height: 840px; overflow: auto; font-size: 26px; }
.panel h2 { font-family: var(--pixel); font-size: 16px; margin: 0 0 16px; color: var(--accent); }
.panel button, .big { display: block; width: 100%; background: var(--panel-2); color: var(--ink); border: 3px solid #000; border-radius: 6px; padding: 8px 12px; font-size: 26px; margin: 8px 0; text-align: center; }
.panel button:hover, .big:hover, .panel button.sel { background: var(--accent); color: #1a1220; }
.panel button.danger:hover { background: var(--bad); }
.panel button:disabled { opacity: .35; cursor: default; background: var(--panel-2); color: var(--ink); }
.row { display: flex; gap: 10px; }
.row button { flex: 1; }

#card { background: #000; flex-direction: column; z-index: 65; }
.card-t { font-family: var(--pixel); font-size: 26px; color: var(--accent); margin-bottom: 18px; animation: slidein .5s; }
.card-s { font-size: 40px; animation: slidein .7s; }

#title { z-index: 80; overflow: hidden; background:
  radial-gradient(ellipse at 50% 45%, rgba(10,8,20,.35), rgba(0,0,0,.92) 70%),
  url("assets/salles/entree.jpg") center / cover; }
#title::after { content: ""; position: absolute; inset: 0; background: #000; opacity: 0; pointer-events: none; animation: flicker 6s infinite; }
@keyframes flicker { 0%, 91%, 95%, 100% { opacity: 0; } 92% { opacity: .5; } 93% { opacity: .1; } 94% { opacity: .45; } }
.title-box { position: relative; z-index: 2; text-align: center; padding: 20px 30px; width: 620px; }
.title-tag { display: inline-block; font-family: var(--pixel); font-size: 9px; letter-spacing: 1px; color: #c0202c; border: 2px solid #c0202c; padding: 6px 10px; transform: rotate(-3deg); background: rgba(0,0,0,.5); }
#title h1 { font-family: var(--pixel); color: var(--accent); margin: 22px 0 10px; line-height: 1.35; text-shadow: 3px 3px 0 #000, 6px 6px 0 #7a1020; }
#title h1 .l1 { display: block; font-size: 22px; color: var(--ink); }
#title h1 .l2 { display: block; font-size: 30px; margin-top: 10px; }
#title p { font-size: 28px; color: var(--muted); margin: 0; }
.title-scene { position: relative; height: 215px; margin: 10px auto 6px; width: 300px; }
.title-detective { position: absolute; left: 40px; bottom: 0; width: 115px; height: 204px; background: url("assets/persos/detective.png") 0 0 / 460.8px 612px; image-rendering: pixelated; filter: drop-shadow(0 6px 4px rgba(0,0,0,.7)); }
.title-victim { position: absolute; right: 30px; bottom: 6px; font-size: 64px; transform: rotate(-12deg); filter: grayscale(.3) drop-shadow(0 4px 3px rgba(0,0,0,.8)); }
.title-victim span { position: absolute; right: -16px; top: -18px; font-size: 26px; color: #c0202c; transform: rotate(12deg); }
.title-victim::before { content: ""; position: absolute; inset: -14px -24px; border: 3px dashed rgba(255,255,255,.55); border-radius: 50% 40% 50% 45%; }
.title-btns { width: 380px; margin: 0 auto; }
.title-btns .big { background: rgba(27,22,38,.92); border: 3px solid var(--line); font-size: 28px; }
.title-btns .big:hover { background: var(--accent); color: #1a1220; }
.title-btns .big.small { font-size: 22px; padding: 4px; border-width: 2px; opacity: .85; }
#title .title-help { font-size: 21px; margin-top: 18px; text-shadow: 0 2px 0 #000; }
.tape { position: absolute; left: -100px; right: -100px; height: 40px; background: #ffcc4d; border-top: 3px solid #1a1220; border-bottom: 3px solid #1a1220; display: flex; align-items: center; overflow: hidden; z-index: 1; box-shadow: 0 6px 12px rgba(0,0,0,.6); }
.tape span { white-space: nowrap; font-family: var(--pixel); font-size: 13px; color: #1a1220; animation: tape 18s linear infinite; }
.tape-1 { top: 70px; transform: rotate(-8deg); }
.tape-2 { bottom: 60px; transform: rotate(6deg); }
.tape-2 span { animation-direction: reverse; }
@keyframes tape { to { transform: translateX(-50%); } }
.hud-btns .music-btn { padding: 4px 8px; }

.menu-jump { margin: 14px 0; }
.menu-jump p { margin: 0 0 4px; color: var(--muted); font-size: 22px; }
.menu-jump button { display: inline-block; width: auto; padding: 4px 10px; margin: 3px; font-size: 22px; }

/* Carnet */
.carnet-panel h3 { font-family: var(--pixel); font-size: 12px; color: var(--muted); margin: 18px 0 6px; }
.carnet-panel ul { margin: 0; padding-left: 22px; }
.carnet-panel li { margin: 4px 0; font-size: 24px; }
.carnet-panel .empty { color: var(--muted); font-style: italic; font-size: 22px; }

/* Accusation */
.accuse-panel { width: 640px; text-align: center; }
.suspects { display: flex; justify-content: center; gap: 8px; margin: 16px 0; flex-wrap: wrap; }
.sus { position: relative; width: 112px; background: var(--panel-2); border: 3px solid #000; border-radius: 6px; padding: 8px 4px; cursor: pointer; font-size: 19px; }
.sus:hover, .sus.sel { border-color: var(--accent); transform: translateY(-4px); }
.sus canvas { display: block; margin: 0 auto 4px; image-rendering: pixelated; }
.sus.off { opacity: .55; }
.sus .stamp { position: absolute; top: 40px; left: 50%; transform: translateX(-50%) rotate(-14deg); font-family: var(--pixel); font-size: 9px; color: var(--good); border: 2px solid var(--good); padding: 3px; background: rgba(0,0,0,.6); }

/* Mini-jeux */
.mg-panel { width: 640px; text-align: center; }
.mg-panel .rule { color: var(--muted); font-size: 24px; margin: 0 0 12px; }
.mg-area { min-height: 200px; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.mg-canvas { background: #000; border: 3px solid #000; border-radius: 4px; max-width: 100%; touch-action: none; }
.mg-big { font-size: 44px; margin: 10px 0; }
.mg-info { font-size: 26px; margin: 8px 0; }

.cfm-arena { display: flex; align-items: center; justify-content: center; gap: 30px; font-size: 80px; margin: 10px 0; }
.cfm-arena span { font-family: var(--pixel); font-size: 16px; color: var(--muted); }
.cfm-btns { display: flex; gap: 10px; }
.cfm-btns button { font-size: 40px; width: 110px; padding: 8px; }

.bdf { width: 100%; }
.bdf-names { display: flex; justify-content: space-between; font-size: 24px; }
.bdf-bar { position: relative; height: 34px; background: linear-gradient(90deg, var(--good) 0 50%, var(--bad) 50% 100%); border: 3px solid #000; border-radius: 6px; margin: 8px 0 16px; }
.bdf-knot { position: absolute; top: -12px; width: 18px; height: 52px; background: var(--ink); border: 3px solid #000; border-radius: 4px; transform: translateX(-50%); left: 50%; }
.bdf-btn { font-size: 30px !important; padding: 18px !important; }
.bdf-btn:active { transform: scale(.97); }

.cook { width: 100%; }
.cook-card { background: #f3e6c8; color: #3a2a1a; border-radius: 6px; padding: 12px 16px; text-align: left; border: 3px solid #000; }
.cook-n { font-family: var(--pixel); font-size: 10px; color: #8a5a2a; }
.cook-card p { margin: 6px 0 0; font-size: 28px; }
.cook-opts { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-top: 10px; }
.cook-opts button { margin: 0; }
.cook-opts button.wrong { background: var(--bad) !important; opacity: .6; }
.cook-opts button.right { background: var(--good) !important; color: #000; }
.cook-note { min-height: 30px; font-size: 24px; color: var(--accent); }

/* Labo */
#labo { z-index: 55; }
.labo-machine { width: 600px; background: #b9bcc4; border: 4px solid #000; border-radius: 12px; padding: 14px; box-shadow: inset 0 -10px 0 #8d9099; }
.labo-title { font-family: var(--pixel); font-size: 11px; color: #2a2d36; text-align: center; margin-bottom: 10px; }
.labo-screen { background: #0b1a10; color: #6dff8f; border: 4px solid #2a2d36; border-radius: 6px; padding: 16px; min-height: 360px; font-size: 26px; text-shadow: 0 0 6px rgba(109,255,143,.5); transition: background .15s; }
.labo-screen.err { background: #3a0b10; color: #ff8a95; }
.lab-head { font-family: var(--pixel); font-size: 10px; opacity: .7; margin-bottom: 10px; }
.lab-q { margin: 0 0 14px; }
.labo-screen button { display: block; width: 100%; text-align: left; background: transparent; color: inherit; border: 2px solid currentColor; border-radius: 4px; padding: 8px 12px; font-size: 24px; margin: 8px 0; }
.labo-screen button:hover:not(:disabled) { background: rgba(109,255,143,.15); }
.labo-screen button:disabled { opacity: .35; text-decoration: line-through; }
.labo-screen button.ok { border-color: #6dff8f; background: rgba(109,255,143,.2); text-decoration: none; opacity: 1; }
.lab-msg { min-height: 60px; margin: 10px 0 0; }
.lab-msg.bad { color: #ff8a95; }
.labo-screen .next { text-align: center; border-style: dashed; }

#dbg { position: absolute; left: 8px; top: 56px; background: rgba(0,0,0,.8); color: #6dff8f; padding: 4px 8px; font-size: 20px; z-index: 30; pointer-events: none; }

/* ---------- Fiche police ---------- */
#fiche { position: fixed; inset: 0; background: rgba(0,0,0,.88); overflow: auto; z-index: 100; padding: 30px 16px; font-family: "Courier New", monospace; }
.paper { position: relative; max-width: 780px; margin: 0 auto; background: #f2ead8; color: #222; padding: 34px 40px; border-radius: 4px; box-shadow: 0 10px 40px rgba(0,0,0,.6); }
.paper header { display: flex; justify-content: space-between; border-bottom: 3px double #222; padding-bottom: 10px; font-weight: bold; letter-spacing: 1px; font-size: 14px; }
.paper-top { display: flex; gap: 26px; margin: 22px 0; }
.photo { width: 170px; height: 210px; border: 3px solid #222; background: #d9d0bd; display: grid; place-items: center; overflow: hidden; flex: none; }
.photo img { width: 100%; height: 100%; object-fit: cover; }
.photo canvas { image-rendering: pixelated; }
.ident { flex: 1; font-size: 16px; }
.ident p { margin: 6px 0; }
.ident b { display: inline-block; min-width: 150px; }
.stamp-big { display: inline-block; margin-top: 14px; font-family: var(--pixel); font-size: 26px; color: #c0202c; border: 5px solid #c0202c; padding: 10px 14px; transform: rotate(-8deg); opacity: .85; }
.paper h3 { background: #222; color: #f2ead8; padding: 4px 10px; font-size: 15px; letter-spacing: 1px; margin: 22px 0 8px; }
.paper ul { margin: 0; padding-left: 22px; font-size: 16px; line-height: 1.45; }
.paper-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; max-width: 780px; margin: 18px auto 0; }
.paper-actions button, .paper-actions a { font-family: var(--text); font-size: 24px; background: var(--panel); color: var(--ink); border: 3px solid var(--line); border-radius: 6px; padding: 6px 16px; text-decoration: none; cursor: pointer; }
.paper-actions button:hover, .paper-actions a:hover { background: var(--accent); color: #1a1220; }

@media print {
  body { background: #fff; overflow: visible; }
  #stage, .paper-actions { display: none !important; }
  #fiche { position: static; background: none; padding: 0; overflow: visible; }
  .paper { box-shadow: none; max-width: none; }
}

/* ---------- Éditeur de collisions ---------- */
#editor { position: absolute; left: 0; right: 0; bottom: 0; background: rgba(10, 8, 16, .94); border-top: 3px solid var(--accent); padding: 6px 12px 8px; z-index: 18; font-size: 19px; line-height: 1.1; }
.ed-help b { color: var(--accent); font-weight: normal; }
.ed-btns { display: flex; gap: 6px; margin-top: 6px; }
.ed-btns button { flex: 1; background: var(--panel-2); color: var(--ink); border: 2px solid #000; border-radius: 4px; font-size: 19px; padding: 3px; }
.ed-btns button:hover { background: var(--accent); color: #1a1220; }
#ed-export { background: #2f6b3f; }
#ed-count { color: var(--muted); font-size: 17px; margin-top: 4px; }
