:root {
  --bg: #1d2333;
  --bg2: #262e44;
  --ink: #f4f1e8;
  --muted: #9aa3bd;
  --line: #0e111a;
  --gold: #ffd23f;
  --green: #5fd068;
  --red: #ff5d5d;
  --blue: #4f8fe6;
  --pixel: "Press Start 2P", monospace;
  --body: "VT323", monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--body);
  font-size: 20px;
  line-height: 1.15;
}

/* ---------- barre du haut ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
  padding: 10px 16px;
  background: var(--bg2);
  border-bottom: 4px solid var(--line);
}
.logo { display: flex; align-items: center; gap: 10px; margin-right: auto; }
.logo-icon {
  width: 32px; height: 32px;
  background:
    linear-gradient(#f2c79a 0 0) 8px 4px / 16px 12px no-repeat,
    linear-gradient(var(--gold) 0 0) 8px 16px / 16px 12px no-repeat,
    var(--blue);
  box-shadow: 0 0 0 3px var(--line);
}
.logo h1 { font-family: var(--pixel); font-size: 14px; margin: 0; letter-spacing: 1px; }
.logo h1 span { color: var(--gold); }
.logo p { margin: 3px 0 0; color: var(--muted); font-size: 18px; }

.clients { display: flex; gap: 8px; }
.client-btn {
  display: flex; align-items: center; gap: 8px;
  padding: 4px 10px 4px 4px;
  font-family: var(--pixel); font-size: 10px;
  color: var(--ink); background: #33405f;
  border: 3px solid var(--line);
  box-shadow: inset -3px -3px 0 #232c43, inset 3px 3px 0 #4b5b84;
  cursor: pointer;
}
.client-btn canvas { width: 28px; height: 42px; image-rendering: pixelated; }
.client-btn small { display: block; font-family: var(--body); font-size: 16px; color: var(--muted); margin-top: 3px; }
.client-btn.active { background: #3f6b3f; box-shadow: inset -3px -3px 0 #2c4d2c, inset 3px 3px 0 #5b965b; }

.controls { display: flex; gap: 8px; }
.btn {
  font-family: var(--pixel); font-size: 10px;
  padding: 10px 12px;
  color: var(--ink); background: #4a5a86;
  border: 3px solid var(--line);
  box-shadow: inset -3px -3px 0 #333f61, inset 3px 3px 0 #6b7db0;
  cursor: pointer;
}
.btn:active { box-shadow: inset 3px 3px 0 #333f61; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-gold { background: #b8901c; box-shadow: inset -3px -3px 0 #7d6110, inset 3px 3px 0 #e2b93a; color: #1d1600; }

/* ---------- scène ---------- */
.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 14px;
  padding: 14px 16px 0;
}
@media (max-width: 1100px) { .layout { grid-template-columns: 1fr; } }

.stage-wrap {
  background: #11151f;
  border: 4px solid var(--line);
  box-shadow: inset 0 0 0 3px #2c3550;
  padding: 10px;
  display: flex; flex-direction: column; align-items: center;
  min-height: 300px;
}
.stage { position: relative; }
#canvas {
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  cursor: default;
}
.overlay { position: absolute; inset: 0; pointer-events: none; }
.hint { color: var(--muted); font-size: 18px; margin-top: 8px; text-align: center; }

/* bulles de dialogue façon hôtel pixel */
.bubble {
  position: absolute;
  transform: translate(-50%, -100%);
  max-width: 240px;
  min-width: 90px;
  padding: 5px 8px 6px;
  background: #fff;
  color: #151515;
  font-size: 17px;
  line-height: 1;
  border: 2px solid var(--line);
  border-radius: 6px;
  box-shadow: 0 3px 0 rgba(0,0,0,.35);
  animation: pop .18s steps(3);
  z-index: 5;
}
.bubble::after {
  content: ""; position: absolute; left: 50%; bottom: -8px;
  width: 10px; height: 8px; margin-left: -5px;
  background: #fff;
  clip-path: polygon(0 0, 100% 0, 50% 100%);
}
.bubble b { font-family: var(--pixel); font-size: 8px; display: block; margin-bottom: 3px; }
.bubble .tag { margin-left: 4px; }
.bubble.below { transform: translate(-50%, 0); }
.bubble.below::after { top: -8px; bottom: auto; clip-path: polygon(50% 0, 100% 100%, 0 100%); }
@keyframes pop { from { transform: translate(-50%, -100%) scale(.6); } }

.tag {
  font-style: normal;
  font-family: var(--pixel); font-size: 8px;
  padding: 2px 4px;
  border: 2px solid var(--line);
  background: var(--gold); color: #1d1600;
  white-space: nowrap;
}
.tag-ia { background: #b48cff; }
.tag-code { background: #7fd1ff; }
.tag-client { background: #ffb36b; }

.nametag {
  position: absolute;
  transform: translate(-50%, 0);
  font-family: var(--pixel); font-size: 8px;
  color: #fff; background: rgba(14,17,26,.85);
  padding: 3px 5px; white-space: nowrap;
  z-index: 4;
}

.sign {
  position: absolute;
  transform: translate(-50%, -50%);
  font-family: var(--pixel); font-size: 7px;
  color: #1a1a1a;
  padding: 4px 6px;
  border: 2px solid var(--line);
  box-shadow: 0 3px 0 rgba(0,0,0,.4);
  pointer-events: auto;
  cursor: pointer;
  white-space: nowrap;
  z-index: 3;
}
.sign:hover { filter: brightness(1.12); transform: translate(-50%, -55%); }

.stamp {
  position: absolute;
  transform: translate(-50%, -50%) rotate(-12deg);
  font-family: var(--pixel); font-size: 12px;
  padding: 6px 8px;
  border: 3px solid currentColor;
  background: rgba(255,255,255,.85);
  animation: stamp .35s steps(4);
  z-index: 6;
}
.stamp.ok { color: #1f8a2d; }
.stamp.ko { color: #c21f1f; }
@keyframes stamp { from { transform: translate(-50%, -50%) rotate(-12deg) scale(2.4); opacity: 0; } }

/* ---------- fiche agent ---------- */
.panel {
  background: var(--bg2);
  border: 4px solid var(--line);
  box-shadow: inset 0 0 0 3px #36415f;
  max-height: calc(100vh - 140px);
  overflow: auto;
}
.panel-inner { padding: 14px; }
.card-head { display: flex; gap: 12px; align-items: center; margin-bottom: 10px; }
.card-head canvas {
  width: 64px; height: 96px; image-rendering: pixelated;
  background: #3a4566; border: 3px solid var(--line);
}
.card-head h2 { font-family: var(--pixel); font-size: 13px; margin: 0 0 6px; }
.card-head .role { color: var(--gold); font-size: 20px; }
.card h3 {
  font-family: var(--pixel); font-size: 9px; color: var(--muted);
  margin: 14px 0 6px; text-transform: uppercase;
}
.card p { margin: 0 0 6px; }
.card ul { margin: 0; padding-left: 18px; }
.card li { margin-bottom: 3px; }
.card code { font-family: var(--body); color: #9fe0ff; font-size: 19px; }
.status {
  padding: 6px 8px; background: #11151f; border: 2px solid var(--line);
  color: var(--green); min-height: 32px;
}
.did { max-height: 180px; overflow: auto; font-size: 18px; }
.did li::marker { color: var(--gold); }
.rules td, .rules th { font-size: 17px; padding: 2px 4px; text-align: left; border-bottom: 1px solid #36415f; }
.rules { border-collapse: collapse; width: 100%; }
.ok { color: var(--green); }
.ko { color: var(--red); }

/* ---------- journal ---------- */
.journal {
  margin: 14px 16px 0;
  background: #11151f;
  border: 4px solid var(--line);
  padding: 10px 14px;
}
.journal-head { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px; }
.journal h2 { font-family: var(--pixel); font-size: 11px; margin: 0; }
.legend { color: var(--muted); font-size: 17px; }
#log { list-style: none; margin: 8px 0 0; padding: 0; max-height: 170px; overflow: auto; font-size: 18px; }
#log li { padding: 3px 0; border-bottom: 1px dashed #2a3249; }
#log li .who { font-family: var(--pixel); font-size: 8px; margin-right: 6px; }
#log li .tag { margin-right: 6px; }

.foot { color: var(--muted); font-size: 16px; padding: 12px 16px 20px; text-align: center; }

/* ---------- modale dossier ---------- */
.modal { position: fixed; inset: 0; background: rgba(5,7,12,.72); display: grid; place-items: center; z-index: 20; }
.modal[hidden] { display: none; }
.modal-box {
  position: relative;
  width: min(820px, 94vw); max-height: 88vh; overflow: auto;
  background: #f6efd9; color: #1d1a12;
  border: 4px solid var(--line);
  box-shadow: 8px 8px 0 rgba(0,0,0,.45);
  padding: 20px 22px;
}
.modal-box h2 { font-family: var(--pixel); font-size: 14px; margin: 0 0 6px; }
.modal-box h3 { font-family: var(--pixel); font-size: 10px; margin: 16px 0 6px; color: #5a4a1f; }
.modal-close {
  position: absolute; top: 8px; right: 8px;
  font-family: var(--pixel); font-size: 12px;
  background: #c94a4a; color: #fff; border: 3px solid var(--line); cursor: pointer; padding: 4px 8px;
}
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.kpi { background: #fff; border: 3px solid var(--line); padding: 6px 8px; }
.kpi b { display: block; font-family: var(--pixel); font-size: 12px; margin-top: 4px; }
.alloc { width: 100%; border-collapse: collapse; }
.alloc td { padding: 2px 4px; font-size: 18px; vertical-align: top; }
.bar { height: 12px; background: #3b6fb6; border: 2px solid var(--line); }
.verdict { padding: 8px 10px; border: 3px solid var(--line); background: #fff; }
.verdict.refuse { background: #ffd9d9; }
.verdict.réduit { background: #fff1c2; }
.verdict.accepte { background: #d9ffd9; }
.disclaimer { font-size: 17px; color: #6a5b33; margin-top: 12px; }

/* ---------- verdicts ---------- */
.verdicts { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 10px 0; }
.verdict small { display: block; font-size: 17px; margin-bottom: 4px; }
.verdict b { font-family: var(--pixel); font-size: 10px; line-height: 1.5; }
.verdict.rouge { background: #ffd2cc; }
.verdict.orange { background: #ffe2bf; }
.verdict.jaune { background: #fff3bf; }
.verdict.vert { background: #d6f5d6; }
.verdict.gris { background: #e6e6e6; }
.card p.rouge { color: #ff8a80; }
.card p.orange { color: #ffbe6b; }
.card p.jaune { color: #ffe27a; }
.card p.vert { color: var(--green); }
blockquote.post {
  margin: 0; padding: 8px 12px; background: #fff; border: 3px solid var(--line);
  border-left: 8px solid #e0533d; font-size: 19px;
}
.modal-box a { color: #1f5fbf; }
@media (max-width: 700px) { .verdicts { grid-template-columns: 1fr; } }

/* =====================================================================
   ÉCRAN D'ACCUEIL (style jeu vidéo)
   ===================================================================== */
body.intro-active { overflow: hidden; }
.intro {
  position: fixed; inset: 0; z-index: 40;
  display: flex; align-items: center; justify-content: center;
  background: #0d1020; overflow: auto;
}
.intro[hidden] { display: none; }
.intro-sky {
  position: absolute; inset: 0; pointer-events: none;
  background:
    radial-gradient(2px 2px at 12% 18%, #fff 50%, transparent 51%),
    radial-gradient(2px 2px at 78% 12%, #ffd23f 50%, transparent 51%),
    radial-gradient(2px 2px at 35% 72%, #7fd1ff 50%, transparent 51%),
    radial-gradient(2px 2px at 88% 64%, #fff 50%, transparent 51%),
    radial-gradient(2px 2px at 58% 30%, #b48cff 50%, transparent 51%),
    radial-gradient(2px 2px at 20% 88%, #fff 50%, transparent 51%),
    linear-gradient(rgba(255,255,255,.035) 1px, transparent 1px) 0 0 / 100% 4px,
    linear-gradient(#141a35, #0d1020 60%, #1a1430);
  animation: twinkle 2.4s steps(2) infinite;
}
@keyframes twinkle { 50% { filter: brightness(1.25); } }
.intro-inner { position: relative; text-align: center; padding: 28px 20px 24px; max-width: 1180px; width: 100%; }
.intro-kicker { color: var(--muted); font-size: 20px; margin: 0 0 8px; letter-spacing: 1px; }
.intro-title {
  font-family: var(--pixel); font-size: clamp(30px, 6vw, 64px); margin: 0;
  color: #fff; letter-spacing: 4px;
  text-shadow: 4px 4px 0 #3b6fb6, 8px 8px 0 #141822;
  animation: title-in .9s steps(6) both;
}
.intro-title span { color: var(--gold); text-shadow: 4px 4px 0 #b8901c, 8px 8px 0 #141822; }
@keyframes title-in { from { transform: translateY(-40px); opacity: 0; } }
.intro-question { font-size: clamp(20px, 2.4vw, 28px); color: #e8ecf8; margin: 18px 0 22px; }
.intro-h2 { font-family: var(--pixel); font-size: 12px; color: var(--gold); margin: 0 0 14px; }
.intro-team { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 1000px) { .intro-team { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 560px) { .intro-team { grid-template-columns: 1fr; } }
.agent-card {
  position: relative;
  background: #232b45; border: 4px solid var(--line);
  box-shadow: inset 0 0 0 3px #36415f, 0 6px 0 rgba(0,0,0,.45);
  padding: 12px 10px 14px; text-align: center;
  animation: card-in .5s steps(5) both;
  transition: transform .15s steps(3);
}
.agent-card:hover { transform: translateY(-6px); }
@keyframes card-in { from { transform: translateY(30px); opacity: 0; } }
.agent-card .pedestal {
  height: 112px; display: flex; align-items: flex-end; justify-content: center;
  background: linear-gradient(transparent 70%, rgba(0,0,0,.25) 70%);
}
.agent-card canvas {
  width: 64px; height: 96px; image-rendering: pixelated;
  animation: bob 1.2s steps(2) infinite;
}
@keyframes bob { 50% { transform: translateY(-4px); } }
.agent-card h3 { font-family: var(--pixel); font-size: 11px; margin: 10px 0 4px; }
.agent-card .role { color: var(--gold); font-size: 19px; }
.agent-card .tache { font-size: 18px; color: #dfe4f3; margin: 8px 0 0; min-height: 60px; }
.agent-card .num {
  position: absolute; top: 6px; left: 8px;
  font-family: var(--pixel); font-size: 9px; color: var(--muted);
}
.agent-card .tag { position: absolute; top: 6px; right: 6px; }
.intro-flow { margin: 16px 0 0; font-size: 20px; color: var(--muted); }
.intro-flow b { color: #fff; font-weight: normal; }
.start-btn {
  margin-top: 22px;
  font-family: var(--pixel); font-size: 22px; letter-spacing: 4px;
  padding: 18px 46px;
  color: #1d1600; background: var(--gold);
  border: 4px solid var(--line);
  box-shadow: inset -5px -5px 0 #b8901c, inset 5px 5px 0 #fff2a8, 0 6px 0 #141822;
  cursor: pointer;
  animation: pulse 1s steps(2) infinite;
}
.start-btn:hover { filter: brightness(1.08); }
.start-btn:active { transform: translateY(4px); box-shadow: inset 5px 5px 0 #b8901c, 0 2px 0 #141822; }
@keyframes pulse { 50% { box-shadow: inset -5px -5px 0 #b8901c, inset 5px 5px 0 #fff2a8, 0 6px 0 #141822, 0 0 0 6px rgba(255,210,63,.35); } }
.intro-press { font-size: 18px; color: var(--muted); margin: 12px 0 0; animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: .2; } }
.intro-legal { font-size: 16px; color: #6f7894; margin: 18px 0 0; }

/* sortie de l'accueil */
.intro.leaving .intro-inner { animation: leave .45s steps(5) forwards; }
@keyframes leave { to { transform: scale(1.08); opacity: 0; } }

/* transition en pixels */
.wipe {
  position: fixed; inset: 0; z-index: 60; pointer-events: none;
  display: grid; grid-template-columns: repeat(16, 1fr); grid-auto-rows: 1fr;
}
.wipe i {
  background: #0d1020; transform: scale(0);
  transition: transform .22s steps(4);
}
.wipe.on i { transform: scale(1.02); }

/* entrée de l'open space */
.app.entering .topbar { animation: drop .5s steps(5) both; }
.app.entering .panel-left { animation: slide-l .55s steps(6) .1s both; }
.app.entering .panel:not(.panel-left) { animation: slide-r .55s steps(6) .1s both; }
.app.entering .centre { animation: fade .6s steps(6) .15s both; }
@keyframes drop { from { transform: translateY(-100%); } }
@keyframes slide-l { from { transform: translateX(-110%); } }
@keyframes slide-r { from { transform: translateX(110%); } }
@keyframes fade { from { opacity: 0; transform: scale(.97); } }

/* =====================================================================
   OPEN SPACE : 3 colonnes (utilisateur | scène | agent)
   ===================================================================== */
.layout { grid-template-columns: 300px minmax(0, 1fr) 330px; }
@media (max-width: 1250px) { .layout { grid-template-columns: 1fr; } .panel { max-height: none; } }
.centre { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.panel-left { display: flex; flex-direction: column; }
.mini-label {
  font-family: var(--pixel); font-size: 8px; color: var(--muted);
  text-transform: uppercase; letter-spacing: 1px;
}
.clients-wrap { display: flex; flex-direction: column; gap: 4px; }

/* barre de question */
.question-bar {
  background: var(--bg2); border: 4px solid var(--line);
  box-shadow: inset 0 0 0 3px #36415f;
  padding: 10px 12px; margin: 0;
}
.qb-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.qb-row .mini-label { width: 150px; flex: none; }
.question-bar select, .question-bar input, .question-bar textarea {
  flex: 1 1 260px; min-width: 0;
  font-family: var(--body); font-size: 19px; line-height: 1.1;
  color: #151515; background: #f6efd9;
  border: 3px solid var(--line); padding: 5px 8px;
}
.question-bar textarea { resize: vertical; min-height: 46px; }
.question-bar select:focus, .question-bar input:focus, .question-bar textarea:focus { outline: 3px solid var(--gold); }
.qb-note { margin: 0; font-size: 17px; color: var(--muted); }
.qb-note.warn { color: #ffbe6b; }

/* barre d'étapes */
.step-bar {
  display: flex; align-items: center; gap: 14px;
  background: #11151f; border: 4px solid var(--line); padding: 8px 12px;
}
.step-info { display: flex; flex-direction: column; gap: 3px; min-width: 260px; }
#step-label { font-size: 20px; }
.step-pips { display: flex; gap: 5px; flex: 1; }
.step-pips i { flex: 1; height: 10px; background: #2a3249; border: 2px solid var(--line); }
.step-pips i.done { background: var(--green); }
.step-pips i.now { background: var(--gold); animation: blink 0.8s steps(2) infinite; }
.btn-skip { background: #c94a4a; box-shadow: inset -3px -3px 0 #8f2f2f, inset 3px 3px 0 #e88080; }
.btn-skip:not(:disabled) { animation: pulse-skip 1.2s steps(2) infinite; }
@keyframes pulse-skip { 50% { filter: brightness(1.2); } }
.stage-wrap { min-height: 0; }

/* fiche utilisateur */
.profil-head { display: flex; gap: 12px; align-items: center; margin-bottom: 8px; }
.profil-head canvas {
  width: 64px; height: 96px; image-rendering: pixelated;
  background: #4a3a2a; border: 3px solid var(--line);
}
.profil-head h2 { font-family: var(--pixel); font-size: 13px; margin: 0 0 5px; }
.type-badge {
  display: inline-block; margin: 6px 0 2px; padding: 4px 8px;
  font-family: var(--pixel); font-size: 9px; color: #1d1600;
  border: 3px solid var(--line);
}
.type-badge.audacieuse, .type-badge.audacieux { background: #ff9a6b; }
.type-badge.equilibre { background: #7fd1ff; }
.type-badge.prudent { background: #9be59f; }
.kv { display: grid; grid-template-columns: 96px 1fr; gap: 3px 8px; font-size: 18px; margin: 8px 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.profil-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.profil-actions .btn { font-size: 8px; padding: 8px 9px; }
.details { margin-top: 10px; font-size: 18px; animation: fade .3s steps(3); }
.details[hidden] { display: none; }
.details ul { margin: 0 0 6px; padding-left: 18px; }
.panel-left.flash { animation: flash .6s steps(3) 2; }
@keyframes flash { 50% { box-shadow: inset 0 0 0 3px var(--gold); } }

/* rapport résumé */
.rapport { border-top: 4px solid var(--line); }
.rapport .vide { color: var(--muted); font-size: 18px; }
.rapport.pret { animation: fade .5s steps(5); }
.rapport h3 { font-family: var(--pixel); font-size: 9px; color: var(--gold); margin: 0 0 8px; text-transform: uppercase; }
.mini-verdict { border: 3px solid var(--line); padding: 6px 8px; margin-bottom: 6px; color: #151515; }
.mini-verdict small { display: block; font-size: 16px; }
.mini-verdict b { font-family: var(--pixel); font-size: 8px; line-height: 1.6; }
.mini-verdict.rouge { background: #ffd2cc; }
.mini-verdict.orange { background: #ffe2bf; }
.mini-verdict.jaune { background: #fff3bf; }
.mini-verdict.vert { background: #d6f5d6; }
.mini-verdict.gris { background: #e6e6e6; }
.rapport ul { margin: 6px 0; padding-left: 18px; font-size: 18px; }
.rapport li { margin-bottom: 4px; }
.rapport .niveau { font-size: 16px; color: var(--muted); margin: 0 0 6px; }
.rapport .retenir { font-size: 18px; background: #11151f; border-left: 4px solid var(--gold); padding: 6px 8px; margin: 8px 0; }
.rapport .btn { width: 100%; margin-top: 4px; }

/* message temporaire */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 70;
  max-width: min(640px, 92vw);
  background: #f6efd9; color: #1d1a12; font-size: 19px;
  border: 4px solid var(--line); box-shadow: 6px 6px 0 rgba(0,0,0,.45);
  padding: 10px 14px; animation: fade .25s steps(3);
}
.toast[hidden] { display: none; }

/* corrections d'affichage */
.rapport .btn, .profil-actions .btn { white-space: normal; line-height: 1.6; }
.qb-row .mini-label { line-height: 1.7; }
