:root {
  --gold: #c9a45c;
  --gold-hi: #f0d38c;
  --radiant: #66bb3c;
  --dire: #d0432f;
  --purple: #9a7aff;
  --ink: #ece6d8;
  --muted: #9aa3b0;
  --panel: rgba(12, 15, 20, 0.86);
  --line: rgba(201, 164, 92, 0.35);
  --title: "Cinzel", Georgia, serif;
  --text: "Barlow", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #07090c; color: var(--ink); font: 16px/1.4 var(--text); }
#stage, #stage canvas { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
button { font: inherit; color: inherit; cursor: pointer; }
kbd { font: 600 0.7rem var(--text); padding: 0.05rem 0.35rem; border: 1px solid var(--line); border-radius: 3px; color: var(--gold-hi); background: #0008; }

/* --- Écran d'accueil --- */

#start {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 24px 16px;
  text-align: center;
  background: radial-gradient(ellipse at center, rgba(40, 8, 5, 0.55), rgba(7, 9, 12, 0.92) 70%);
  transition: opacity 0.9s, transform 0.9s;
}
#start.out { opacity: 0; transform: scale(1.15); pointer-events: none; }
.start-kicker { font: 600 0.85rem var(--title); letter-spacing: 0.5em; text-transform: uppercase; color: var(--dire); margin: 0; }
#start h1 {
  font: 900 clamp(2.6rem, 10vw, 6rem)/0.95 var(--title);
  margin: 0.3em 0;
  text-transform: uppercase;
  color: var(--gold-hi);
  text-shadow: 0 0 30px #d0432faa, 0 4px 0 #3a0c08, 0 8px 30px #000;
  animation: breathe 4s ease-in-out infinite;
}
@keyframes breathe { 50% { text-shadow: 0 0 60px #ff3b24, 0 4px 0 #3a0c08, 0 8px 30px #000; } }
.start-tag { color: var(--muted); max-width: 560px; margin: 0 auto 1.6rem; }
#enter {
  font: 800 1.1rem var(--title);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 1rem 2.2rem;
  border: 1px solid #ff8a6a;
  border-radius: 4px;
  background: linear-gradient(180deg, #d4513b, #7e1e14);
  color: #fff;
  box-shadow: 0 0 30px #d0432f88;
}
#enter:disabled { filter: grayscale(0.8); cursor: wait; }
#enter:not(:disabled):hover { filter: brightness(1.15); }
#start-note { color: #ff9a85; min-height: 1.4em; }
.keys { display: flex; flex-wrap: wrap; gap: 0.6rem 1.2rem; justify-content: center; list-style: none; padding: 0; margin: 1.5rem 0 0; color: var(--muted); font-size: 0.9rem; }
.keys em { color: var(--gold); font-style: normal; font-size: 0.8em; }

/* --- Plaque de l'audience --- */

#top {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10;
  display: flex;
  justify-content: center;
  padding: 12px 16px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 1s 1.5s;
}
.playing #top, .playing #actions { opacity: 1; }
#plaque {
  max-width: min(720px, 100%);
  text-align: center;
  padding: 0.55rem 1.4rem 0.65rem;
  background: linear-gradient(180deg, rgba(26, 20, 12, 0.92), rgba(12, 10, 8, 0.85));
  border: 1px solid var(--gold);
  border-top: 3px solid var(--gold);
  clip-path: polygon(0 0, 100% 0, 97% 100%, 3% 100%);
}
#plaque-title { font: 800 clamp(0.85rem, 2.4vw, 1.1rem) var(--title); color: var(--gold-hi); letter-spacing: 0.04em; }
#plaque-sub { color: var(--muted); font-size: 0.85rem; font-style: italic; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.phase { display: inline-block; margin-top: 0.3rem; font: 700 0.68rem var(--title); letter-spacing: 0.14em; text-transform: uppercase; color: var(--gold); }
.phase:empty { display: none; }
.phase-vote { color: var(--purple); }
.phase-coupable { color: var(--dire); }
.phase-acquitte { color: var(--radiant); }
#presence { position: fixed; top: 14px; right: 16px; font-weight: 700; color: var(--muted); }

/* --- Barre d'actions --- */

#actions {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  background: linear-gradient(0deg, rgba(7, 9, 12, 0.92), transparent);
  opacity: 0;
  transition: opacity 1s 1.5s;
}
.act {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 0.75rem;
  border: 1px solid #ffffff22;
  border-radius: 4px;
  background: rgba(20, 24, 30, 0.88);
  font-weight: 600;
  font-size: 0.88rem;
  transition: transform 0.1s, filter 0.1s;
}
.act:hover:not(:disabled) { filter: brightness(1.3); transform: translateY(-2px); }
.act:active:not(:disabled) { transform: translateY(1px) scale(0.97); }
.act:disabled { opacity: 0.4; cursor: not-allowed; }
.act-icon { font-size: 1.1rem; }
.act.gold { border-color: var(--gold); color: var(--gold-hi); background: linear-gradient(180deg, #3a2c12, #1a140a); }
.act.red { border-color: #ff7a5f; background: linear-gradient(180deg, #8e2418, #4a120c); }
.act.green { border-color: var(--radiant); background: linear-gradient(180deg, #2f6b25, #163410); }
.act.purple { border-color: var(--purple); background: linear-gradient(180deg, #45307a, #22183e); }
.act.big { font: 800 1rem var(--title); padding: 0.7rem 1.4rem; animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 24px #ff3b24; } }
@media (max-width: 640px) {
  .act { padding: 0.45rem 0.55rem; }
  .act-label { display: none; }
  .act.gold .act-label, .act.red .act-label, .act.green .act-label, .act.purple .act-label { display: inline; }
  .act kbd { display: none; }
}

/* --- Les gros titres dramatiques --- */

#big { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; pointer-events: none; padding: 16px; }
.big {
  font: 900 clamp(2.4rem, 11vw, 8rem)/1 var(--title);
  text-align: center;
  text-transform: uppercase;
  color: var(--gold-hi);
  text-shadow: 0 0 40px #000, 0 6px 0 #2a1a0c;
  animation: slam 0.35s cubic-bezier(0.2, 2, 0.4, 1) both;
  transition: opacity 0.6s, transform 0.6s;
}
.big.out { opacity: 0; transform: scale(1.3); }
.big-sub { font-size: 0.32em; letter-spacing: 0.12em; margin-top: 0.4em; color: var(--ink); text-transform: none; }
@keyframes slam { from { transform: scale(3); opacity: 0; } to { transform: none; opacity: 1; } }

.big-silence { animation: none; letter-spacing: -0.02em; font-size: clamp(2.2rem, 8.5vw, 8.5rem); white-space: nowrap; color: #fff; text-shadow: 0 0 30px #ffd27a, 0 0 80px #ff8a3a, 0 8px 0 #3a2410; }
.big-silence span { display: inline-block; animation: letter 0.5s cubic-bezier(0.2, 2.2, 0.4, 1) both, tremble 0.08s 0.5s infinite; }
@keyframes letter { from { transform: translateY(-120px) scale(2.5); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes tremble { 25% { transform: translate(2px, -2px); } 50% { transform: translate(-2px, 1px); } 75% { transform: translate(1px, 2px); } }

.big-barre { color: #fff2d6; text-shadow: 0 0 30px #fff2d6, 0 0 60px #c9a45c; }
.big-objection {
  color: #fff;
  font-style: italic;
  transform: rotate(-8deg);
  -webkit-text-stroke: 3px #7a1e14;
  text-shadow: 0 0 0 transparent, 8px 8px 0 #d0432f, 0 0 60px #ff3b24;
  animation: objection 0.3s cubic-bezier(0.2, 2.5, 0.4, 1) both;
}
@keyframes objection { from { transform: rotate(-8deg) translateX(-120vw) skewX(30deg); } to { transform: rotate(-8deg); } }
.big-delib { color: #d9caff; text-shadow: 0 0 40px var(--purple); font-size: clamp(2rem, 8vw, 5rem); }
.big-suspense { font-size: clamp(1.8rem, 6vw, 4rem); color: var(--ink); letter-spacing: 0.3em; animation: fadein 0.8s both; }
@keyframes fadein { from { opacity: 0; letter-spacing: 1em; } }
.big-coupable { -webkit-text-stroke: 2px #2a0604; color: #ff6b55; text-shadow: 0 0 50px #ff3b24, 0 0 100px #d0432f, 0 8px 0 #3a0c08; font-size: clamp(3rem, 15vw, 11rem); }
.big-acquitte { -webkit-text-stroke: 2px #0d2408; color: #b7ff8a; text-shadow: 0 0 50px #66bb3c, 0 8px 0 #163410; font-size: clamp(3rem, 14vw, 10rem); }
.big-roue, .big-peine { -webkit-text-stroke: 2px #2a1a0c; color: var(--gold-hi); text-shadow: 0 0 40px #ffb347, 0 6px 0 #3a2410; font-size: clamp(2rem, 8vw, 5.5rem); }
.big-titre { font-size: clamp(2rem, 8vw, 5rem); }
.big-classe { color: var(--muted); font-size: clamp(2rem, 8vw, 5rem); }

#flash { position: fixed; inset: 0; z-index: 15; pointer-events: none; opacity: 0; }
.flash-silence { background: #fff; animation: flash 0.5s ease-out; }
.flash-objection { background: repeating-conic-gradient(from 0deg at 50% 50%, #d0432f55 0 4deg, transparent 4deg 12deg); animation: flash 0.9s ease-out; }
.flash-coupable { background: radial-gradient(circle, transparent 20%, #d0432fcc); animation: flash 1.6s ease-out; }
.flash-acquitte { background: radial-gradient(circle, transparent 20%, #66bb3ccc); animation: flash 1.6s ease-out; }
@keyframes flash { from { opacity: 1; } to { opacity: 0; } }

/* --- Panneaux --- */

.panel, #jury, #sentence {
  position: fixed;
  z-index: 30;
  background: var(--panel);
  border: 1px solid var(--gold);
  box-shadow: 0 10px 50px #000, 0 0 30px #c9a45c22;
  backdrop-filter: blur(6px);
}
.panel { left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(560px, calc(100% - 32px)); max-height: calc(100% - 140px); overflow: auto; padding: 1.2rem; text-align: center; }
.panel h2 { font: 800 1.2rem var(--title); color: var(--gold-hi); margin: 0 0 1rem; text-transform: uppercase; letter-spacing: 0.06em; }
.panel .ghost { margin-top: 1rem; background: none; border: 1px solid var(--line); padding: 0.5rem 1.2rem; border-radius: 4px; }
.hint { color: var(--muted); font-size: 0.85rem; }
.picker-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
.pick { display: flex; flex-direction: column; align-items: center; gap: 0.3rem; padding: 0.7rem; background: #ffffff0a; border: 1px solid #ffffff1a; border-radius: 4px; }
.pick:hover { border-color: var(--gold); background: #c9a45c22; }
.pick img { width: 54px; height: 54px; border-radius: 50%; border: 2px solid var(--gold); }
.pick small { color: var(--muted); }
.docket-row { display: grid; grid-template-columns: auto 1fr auto; gap: 0.8rem; width: 100%; text-align: left; padding: 0.6rem 0.8rem; margin-bottom: 6px; background: #ffffff08; border: 1px solid #ffffff14; border-radius: 4px; }
.docket-row:hover { border-color: var(--gold); }
.docket-row b { color: var(--gold); }
.docket-row em { font-style: normal; font-size: 0.8rem; color: var(--muted); }
.docket-row.s-vote em { color: var(--purple); }
.docket-row.s-coupable em { color: var(--dire); }
.docket-row.s-acquitte em { color: var(--radiant); }

#jury { right: 16px; top: 120px; width: min(280px, calc(100% - 32px)); padding: 0.9rem; animation: slidein 0.5s both; }
#jury h3 { font: 800 0.9rem var(--title); margin: 0 0 0.6rem; color: var(--gold-hi); text-transform: uppercase; }
.juror { display: grid; grid-template-columns: 32px 1fr auto; align-items: center; gap: 0.5rem; padding: 0.25rem 0; }
.juror img { width: 32px; height: 32px; border-radius: 50%; }
.juror.g b { color: #ff7b6b; }
.juror.i b { color: #9be37a; }
@keyframes slidein { from { transform: translateX(120%); } }

#sentence { left: 16px; top: 120px; width: min(300px, calc(100% - 32px)); padding: 0.9rem 1rem; border-color: var(--dire); animation: slidein-left 0.5s both; }
#sentence small { font: 700 0.7rem var(--title); letter-spacing: 0.2em; text-transform: uppercase; color: var(--dire); }
#sentence strong { display: block; font: 800 1.15rem var(--title); color: var(--gold-hi); margin: 0.2rem 0; }
#sentence p { margin: 0; color: var(--muted); font-size: 0.9rem; }
@keyframes slidein-left { from { transform: translateX(-120%); } }
@media (max-width: 640px) { #jury, #sentence { top: auto; bottom: 90px; } #sentence { display: none; } }

#toasts { position: fixed; z-index: 40; left: 50%; bottom: 90px; transform: translateX(-50%); display: flex; flex-direction: column; gap: 6px; align-items: center; width: min(560px, calc(100% - 32px)); }
.toast { display: flex; gap: 0.8rem; align-items: center; padding: 0.6rem 1rem; background: var(--panel); border: 1px solid var(--line); border-radius: 4px; animation: up 0.3s both; transition: opacity 0.5s; }
.toast.out { opacity: 0; }
.toast button { border: 1px solid var(--gold); background: #c9a45c22; padding: 0.3rem 0.8rem; border-radius: 3px; color: var(--gold-hi); }
@keyframes up { from { transform: translateY(20px); opacity: 0; } }

#speak { position: fixed; z-index: 35; left: 50%; bottom: 90px; transform: translateX(-50%); width: min(600px, calc(100% - 32px)); }
#speak-input { width: 100%; font: 600 1.05rem var(--text); padding: 0.85rem 1rem; color: var(--ink); background: var(--panel); border: 1px solid var(--gold); border-radius: 4px; outline: none; box-shadow: 0 0 30px #c9a45c33; }

@media (prefers-reduced-motion: reduce) {
  .big, .big span, #start h1 { animation: none !important; }
}

/* --- Distribution des rôles --- */

#roles { width: min(620px, calc(100% - 32px)); text-align: left; }
#roles h2 { text-align: center; }
.roles-list { display: flex; flex-direction: column; gap: 6px; max-height: 42vh; overflow: auto; }
.role-row { display: grid; grid-template-columns: 36px 1fr auto; align-items: center; gap: 0.7rem; padding: 0.35rem 0.6rem; background: #ffffff08; border: 1px solid #ffffff14; border-radius: 4px; }
.role-row img { width: 36px; height: 36px; border-radius: 50%; border: 2px solid var(--gold); }
.role-select { font: 600 0.9rem var(--text); color: var(--ink); background: #0e1116; border: 1px solid var(--line); border-radius: 4px; padding: 0.35rem 0.5rem; }
.roles-dice { width: 100%; margin: 0.8rem 0; padding: 0.6rem; font: 700 0.95rem var(--title); color: var(--gold-hi); background: #c9a45c18; border: 1px dashed var(--gold); border-radius: 4px; }
.roles-dice:hover { background: #c9a45c30; }
.roles-crime { display: flex; gap: 6px; }
.roles-reason { flex: 1; font: 600 0.95rem var(--text); color: var(--ink); background: #0e1116; border: 1px solid var(--line); border-radius: 4px; padding: 0.6rem 0.8rem; }
.roles-crime .ghost { margin: 0; }
.roles-error { color: #ff9a85; min-height: 1.2em; margin: 0.5rem 0; }
.roles-actions { display: flex; justify-content: flex-end; gap: 8px; }
.roles-actions .ghost { margin: 0; }
.roles-open { font: 800 1rem var(--title); text-transform: uppercase; padding: 0.7rem 1.5rem; border: 1px solid #ff8a6a; border-radius: 4px; background: linear-gradient(180deg, #d4513b, #7e1e14); color: #fff; }

/* --- Pièces à conviction --- */

.evidence-preview { display: grid; place-items: center; margin-bottom: 0.8rem; background: #000; border: 1px solid var(--line); }
.evidence-preview img, .evidence-preview video { max-width: 100%; max-height: 40vh; display: block; }
#evidence-prompt { text-align: left; }
#evidence-prompt h2 { text-align: center; }
#evidence-prompt .roles-reason { width: 100%; margin-bottom: 0.8rem; }

#lightbox { position: fixed; inset: 0; z-index: 45; display: grid; place-items: center; padding: 16px; background: rgba(4, 5, 7, 0.88); backdrop-filter: blur(4px); animation: fadein-box 0.3s both; }
#lightbox[hidden] { display: none; }
@keyframes fadein-box { from { opacity: 0; } }
.lightbox-inner { display: flex; flex-direction: column; align-items: center; gap: 0.7rem; max-width: min(1100px, 100%); }
.lightbox-inner img, .lightbox-inner video { max-width: 100%; max-height: 70vh; border: 3px solid var(--gold); box-shadow: 0 0 60px #c9a45c44; background: #000; }
.lightbox-title { font: 800 clamp(1.1rem, 3vw, 1.6rem) var(--title); color: var(--gold-hi); text-transform: uppercase; letter-spacing: 0.08em; }
.lightbox-caption { margin: 0; color: var(--ink); text-align: center; font-size: 1.05rem; }
.lightbox-inner .ghost { background: none; border: 1px solid var(--line); padding: 0.5rem 1.2rem; border-radius: 4px; }

.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
.gallery-item { display: flex; flex-direction: column; gap: 0.3rem; padding: 0.4rem; background: #ffffff0a; border: 1px solid #ffffff1a; border-radius: 4px; text-align: left; }
.gallery-item:hover { border-color: var(--gold); }
.gallery-item img, .gallery-video { width: 100%; aspect-ratio: 16 / 10; object-fit: cover; background: #000; }
.gallery-video { display: grid; place-items: center; font-size: 2rem; color: var(--gold-hi); }
.gallery-item b { color: var(--gold); }
.gallery-item small { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.big-preuve { color: #fff2d6; text-shadow: 0 0 40px #fff2d6, 0 0 80px #c9a45c, 0 6px 0 #2a1a0c; -webkit-text-stroke: 2px #2a1a0c; font-size: clamp(2rem, 7vw, 5rem); }

/* --- Tours de parole --- */

#floor {
  position: fixed;
  z-index: 12;
  top: 108px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 0.8rem;
  width: min(420px, calc(100% - 32px));
  padding: 0.55rem 0.9rem;
  background: var(--panel);
  border: 1px solid var(--gold);
  border-radius: 4px;
  box-shadow: 0 0 30px #fff2d633;
  animation: up 0.3s both;
}
#floor[hidden] { display: none; }
#floor img { width: 42px; height: 42px; border-radius: 50%; border: 2px solid var(--gold); }
.floor-text { flex: 1; min-width: 0; }
.floor-kind { font: 700 0.68rem var(--title); letter-spacing: 0.16em; text-transform: uppercase; color: var(--gold); }
.floor-name { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.floor-bar { height: 4px; margin-top: 0.3rem; background: #ffffff1a; border-radius: 2px; overflow: hidden; }
.floor-bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--radiant), var(--gold)); transition: width 0.25s linear; }
.floor-time { font: 800 1.6rem var(--title); color: var(--gold-hi); font-variant-numeric: tabular-nums; }
#floor.hurry { border-color: var(--dire); }
#floor.hurry .floor-time { color: #ff6b55; animation: tremble 0.12s infinite; }
#floor.hurry .floor-bar i { background: var(--dire); }
#floor.defense .floor-kind { color: #ff7b6b; }
#floor.accusation .floor-kind { color: #9be37a; }
