:root {
  --bg: #1c1a17;
  --desk: #2a2621;
  --paper: #f4ecd8;
  --paper-2: #e9dfc6;
  --ink: #221d16;
  --muted: #7a6f5d;
  --red: #c8102e;
  --green: #1f8a4c;
  --amber: #d9961a;
  --string: #d7263d;
  --radius: 10px;
  --font-type: 'Special Elite', 'Courier New', monospace;
  --font-ui: 'Inter', system-ui, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: radial-gradient(ellipse at top, #332e27, var(--bg) 70%);
  color: var(--paper);
  font-family: var(--font-ui);
  line-height: 1.45;
}

main { flex: 1; width: 100%; max-width: 1080px; margin: 0 auto; padding: 16px; overflow-x: clip; }

button { font: inherit; cursor: pointer; }
button:disabled { cursor: default; }

/* ---------- HUD ---------- */
#hud {
  position: sticky; top: 0; z-index: 10;
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 8px 16px;
  background: #111;
}
#hud[hidden] { display: none; }
#hud > :not(#hud-progress) { position: relative; } /* au-dessus de la barre de temps */
#hud-progress {
  position: absolute; inset: 0 auto 0 0;
  background: linear-gradient(90deg, #1f5a3a, #2a7a4f);
  transition: width 1s linear, background .5s;
}
#hud-progress.mid { background: linear-gradient(90deg, #7a4f0e, #a86d14); }
#hud-progress.low { background: linear-gradient(90deg, #6e0a1a, #a50d25); animation: pulse .5s infinite alternate; }
.hud-brand { font-weight: 800; letter-spacing: .02em; }
.hud-brand span { color: var(--red); }
.hud-brand, .hud-item { text-shadow: 0 1px 3px rgba(0,0,0,.6); }
.hud-stats { display: flex; gap: 18px; align-items: center; }
.hud-item { display: flex; flex-direction: column; font-weight: 800; font-variant-numeric: tabular-nums; }
.hud-label { font-size: 10px; text-transform: uppercase; letter-spacing: .08em; color: #aaa; font-weight: 600; }
#hud-time.urgent { color: #ffd1d8; animation: pulse .5s infinite alternate; }
.bar { width: 110px; height: 10px; background: #333; border-radius: 5px; overflow: hidden; margin-top: 4px; }
#hud-cred-bar { height: 100%; width: 50%; background: var(--green); transition: width .4s, background .4s; }
#hud-cred-bar.mid { background: var(--amber); }
#hud-cred-bar.low { background: var(--red); }

@keyframes pulse { to { opacity: .4; } }

/* ---------- Boutons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 16px;
  border: 2px solid var(--paper);
  border-radius: var(--radius);
  background: transparent; color: var(--paper);
  font-weight: 600; text-decoration: none;
  transition: transform .1s, background .2s;
}
.btn:hover:not(:disabled) { transform: translateY(-1px); background: rgba(255,255,255,.06); }
.btn.primary { background: var(--red); border-color: var(--red); color: #fff; }
.btn.primary:hover:not(:disabled) { background: #a50d25; }
.btn.primary:disabled { opacity: .4; }
.btn.ghost { border-style: dashed; border-color: #8a7f6c; color: #d8cdb5; }
.btn.ghost:disabled { opacity: .8; border-style: solid; }
.btn.small { padding: 4px 10px; font-size: 12px; border-width: 1px; border-color: var(--ink); color: var(--ink); }
.btn.big { font-size: 18px; padding: 14px 24px; }

/* ---------- Écrans ---------- */
.screen { animation: fadein .35s ease; }
@keyframes fadein { from { opacity: 0; transform: translateY(8px); } }

.kicker { text-transform: uppercase; letter-spacing: .15em; font-size: 12px; margin: 0 0 6px; }
.lead { font-size: 18px; max-width: 640px; }
.lead.small { font-size: 16px; }

.intro { text-align: center; padding-top: 24px; }
.intro h1 { font-family: var(--font-type); font-size: clamp(40px, 9vw, 76px); margin: 0 0 12px; line-height: 1; }
.intro .lead { margin: 0 auto 24px; }
.intro q { font-family: var(--font-type); color: #ffb3bd; }
.strike { color: var(--red); }

.roles { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; max-width: 640px; margin: 0 auto 24px; }
.role {
  display: flex; flex-direction: column; gap: 6px; align-items: center;
  padding: 20px; border-radius: var(--radius);
  background: var(--paper); color: var(--ink);
  border: 3px solid transparent;
  box-shadow: 0 8px 24px rgba(0,0,0,.4);
  transition: transform .15s, border-color .15s;
}
.role:hover:not(:disabled) { transform: translateY(-3px) rotate(-.5deg); border-color: var(--red); }
.role-icon { font-size: 40px; }
.role small { color: var(--muted); }
.role.locked { opacity: .45; filter: grayscale(1); }

.howto { text-align: left; max-width: 560px; margin: 0 auto; color: #d8cdb5; }
.howto li { margin-bottom: 6px; }

/* ---------- Phase 1 ---------- */
.phase-head { margin-bottom: 14px; }
.phase-head p { margin: 6px 0 0; color: #d8cdb5; max-width: 780px; }
.phase-tag {
  display: inline-block; padding: 3px 10px; border-radius: 4px;
  background: var(--red); color: #fff; font-weight: 800; font-size: 12px; letter-spacing: .06em; text-transform: uppercase;
}

.board {
  position: relative;
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px;
  padding: 16px;
  background: #6b4f33 repeating-linear-gradient(45deg, rgba(0,0,0,.05) 0 2px, transparent 2px 6px);
  border-radius: var(--radius);
  box-shadow: inset 0 0 40px rgba(0,0,0,.5);
}
#strings { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 2; }
#strings line { stroke: var(--string); stroke-width: 3; stroke-dasharray: 6 5; opacity: .9; }
#strings line.valid { stroke-dasharray: none; stroke: var(--string); }
#strings line.wrong { stroke: #555; stroke-dasharray: 2 6; }
#strings circle { fill: #222; stroke: #999; stroke-width: 1; }

.clue {
  position: relative;
  padding: 26px 12px 12px;
  background: var(--paper); color: var(--ink);
  border-radius: 4px;
  box-shadow: 0 4px 10px rgba(0,0,0,.35);
  cursor: pointer;
  transition: transform .15s, box-shadow .15s, outline-color .15s;
  outline: 3px solid transparent;
}
.clue:nth-child(3n) { transform: rotate(.8deg); }
.clue:nth-child(3n+1) { transform: rotate(-.7deg); }
.clue:hover { box-shadow: 0 8px 18px rgba(0,0,0,.45); }
.clue.selected { outline-color: var(--amber); transform: scale(1.03); z-index: 3; }
.clue.verified { background: #eef5e6; }
.clue.debunked { background: #d9d2c3; cursor: not-allowed; opacity: .75; }
.clue.debunked h3, .clue.debunked p { text-decoration: line-through; }
.clue-icon { position: absolute; top: -12px; left: 50%; transform: translateX(-50%); font-size: 26px; }
.clue h3 { margin: 0 0 6px; font-family: var(--font-type); font-size: 16px; }
.clue p { margin: 0 0 8px; font-size: 14px; }
.clue-status small { display: block; font-size: 12px; color: var(--muted); margin-top: 4px; }

.stamp {
  display: inline-block; padding: 2px 8px;
  border: 2px solid; border-radius: 4px;
  font-family: var(--font-type); text-transform: uppercase; font-size: 13px;
  transform: rotate(-4deg);
  animation: stamp .3s ease-out;
}
.stamp.ok { color: var(--green); }
.stamp.ko { color: var(--red); }
@keyframes stamp { from { transform: scale(2.2) rotate(-12deg); opacity: 0; } }

.desk { margin-top: 16px; display: flex; flex-direction: column; gap: 12px; }
.link-list { display: flex; flex-wrap: wrap; gap: 8px; min-height: 36px; }
.link-list .empty { margin: 0; color: #a99e88; font-style: italic; }
.chip {
  padding: 5px 10px; border-radius: 999px; border: 1px solid #666;
  background: #333; color: #eee; font-size: 13px;
}
.chip.valid { border-color: var(--green); background: #173d28; }
.chip.wrong { border-color: #777; background: #3a3a3a; color: #aaa; }
.chip:hover { text-decoration: line-through; }
.desk-actions { display: flex; flex-wrap: wrap; gap: 12px; justify-content: space-between; }

/* ---------- Publication ---------- */
.publication { max-width: 640px; margin: 0 auto; text-align: center; }
.newspaper {
  background: var(--paper); color: var(--ink);
  padding: 20px; border-radius: 4px; margin-bottom: 20px;
  box-shadow: 0 10px 30px rgba(0,0,0,.5);
  animation: spin-in .6s ease-out;
}
@keyframes spin-in { from { transform: rotate(-200deg) scale(.2); opacity: 0; } }
.np-mast { font-weight: 800; border-bottom: 3px double var(--ink); padding-bottom: 6px; letter-spacing: .05em; }
.np-mast span { color: var(--red); }
.newspaper h2 { font-family: Georgia, serif; font-size: clamp(22px, 5vw, 32px); margin: 12px 0; }
.np-quote { font-family: var(--font-type); color: var(--red); margin: 0; }

.recap { list-style: none; padding: 0; margin: 0 auto 16px; max-width: 420px; text-align: left; }
.recap li { display: flex; justify-content: space-between; padding: 6px 0; border-bottom: 1px dashed #4a443a; }
.recap b.bad { color: #ff6b7d; }

/* ---------- Phase 2 ---------- */
.riposte { max-width: 720px; margin: 0 auto; }
.attack {
  position: relative;
  background: #111; border-left: 6px solid var(--red);
  padding: 18px 18px 22px; border-radius: var(--radius);
  animation: shake .4s;
}
@keyframes shake { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }
.attack-tag { font-weight: 800; font-size: 12px; letter-spacing: .1em; color: var(--red); }
.attack-who { margin: 4px 0 8px; color: #aaa; font-size: 14px; }
.attack blockquote { margin: 0; font-size: clamp(18px, 3.5vw, 22px); font-weight: 600; }
.countdown { position: absolute; left: 0; right: 0; bottom: 0; height: 5px; background: #333; border-radius: 0 0 var(--radius) var(--radius); overflow: hidden; }
#countdown-bar { height: 100%; width: 100%; background: var(--amber); transition: width .1s linear; }

.options { display: grid; gap: 10px; margin-top: 16px; }
.option {
  text-align: left; padding: 14px 16px;
  background: var(--paper); color: var(--ink);
  border: 2px solid transparent; border-radius: var(--radius);
  font-weight: 600;
  transition: transform .1s, border-color .15s;
}
.option:hover:not(:disabled) { border-color: var(--red); transform: translateX(4px); }
.option:disabled { opacity: .5; }
.option.good { opacity: 1; border-color: var(--green); background: #dff0e3; }
.option.bad { opacity: 1; border-color: var(--red); background: #f6d9dd; }

.feedback { margin-top: 16px; padding: 14px 16px; border-radius: var(--radius); animation: fadein .3s; }
.feedback p { margin: 0 0 8px; }
.feedback.good { background: #173d28; }
.feedback.bad { background: #4a1820; }

/* ---------- Fin ---------- */
.end { max-width: 600px; margin: 0 auto; text-align: center; }
.end h2 { font-family: var(--font-type); font-size: clamp(30px, 7vw, 46px); margin: 0; }
.end .lead { margin: 8px auto 12px; }
.rank-emoji { font-size: 72px; animation: stamp .5s ease-out; }
.final-score { font-size: 48px; font-weight: 800; margin: 0 0 12px; font-variant-numeric: tabular-nums; }
.final-score small { font-size: 18px; color: #aaa; }
.share-card {
  text-align: left; white-space: pre-wrap; word-break: break-word;
  background: var(--paper); color: var(--ink);
  padding: 14px; border-radius: var(--radius);
  font-family: var(--font-ui); font-size: 15px;
}
.share-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin: 12px 0 18px; }
.learn { text-align: left; margin-top: 12px; background: rgba(255,255,255,.05); border-radius: var(--radius); padding: 10px 14px; }
.learn summary { cursor: pointer; font-weight: 600; }
.learn p { color: #d8cdb5; font-size: 14px; }

/* ---------- Tutoriel ---------- */
.tuto, .dossier-screen { max-width: 720px; margin: 0 auto; text-align: center; }
.tuto-head { display: flex; justify-content: space-between; align-items: center; }
.link-btn { background: none; border: 0; color: #a99e88; text-decoration: underline; padding: 4px; }
.link-btn:hover { color: var(--paper); }
.tuto h2, .dossier-screen h2 { font-family: var(--font-type); font-size: clamp(22px, 5vw, 32px); margin: 16px 0; }
.hl { color: var(--amber); }

.tuto-stage {
  position: relative;
  padding: 56px 16px 20px;
  background: #6b4f33 repeating-linear-gradient(45deg, rgba(0,0,0,.05) 0 2px, transparent 2px 6px);
  border-radius: var(--radius);
  box-shadow: inset 0 0 40px rgba(0,0,0,.5);
  text-align: left;
}
.tuto-cards { position: relative; display: grid; grid-template-columns: 1fr 1fr; gap: clamp(16px, 8vw, 72px); pointer-events: none; }
#tuto-string { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 2; overflow: visible; }
#tuto-string line { stroke: var(--string); stroke-width: 3; }
#tuto-string line.draw { stroke-dasharray: 1000; stroke-dashoffset: 1000; animation: draw .6s ease-out forwards; }
#tuto-string circle { fill: #222; stroke: #999; }
@keyframes draw { to { stroke-dashoffset: 0; } }

.tuto-timer {
  position: absolute; top: 12px; left: 50%; transform: translateX(-50%);
  padding: 4px 14px; border-radius: 999px;
  background: #111; font-weight: 800; font-size: 18px; font-variant-numeric: tabular-nums;
}
.tuto-timer.hit { animation: hit .5s; color: #ff6b7d; }
@keyframes hit { 30% { transform: translateX(-50%) scale(1.25); } }
.tuto-penalty {
  position: absolute; left: 100%; top: 0; margin-left: 8px;
  color: var(--red); font-weight: 800; white-space: nowrap;
  animation: float-up 1.2s ease-out forwards;
}
@keyframes float-up { to { transform: translateY(-24px); opacity: 0; } }

.cursor {
  position: absolute; top: 0; left: 0; z-index: 5;
  pointer-events: none; opacity: 0;
  transform: translate(50%, 260px);
  transition: transform .85s cubic-bezier(.5,0,.3,1), opacity .3s;
  filter: drop-shadow(0 4px 6px rgba(0,0,0,.5));
}
.cursor.visible { opacity: 1; }
.cursor svg { display: block; transition: transform .12s; transform-origin: 4px 2px; }
.cursor.clicking svg { transform: scale(.8); }
.cursor.clicking::before {
  content: ''; position: absolute; left: -14px; top: -14px; width: 36px; height: 36px;
  border: 3px solid var(--amber); border-radius: 50%;
  animation: ripple .4s ease-out forwards;
}
@keyframes ripple { from { transform: scale(.3); opacity: 1; } to { transform: scale(1.6); opacity: 0; } }

.tuto-bubble {
  margin: 16px auto 0; max-width: 520px; padding: 16px 18px;
  background: var(--paper); color: var(--ink);
  border-radius: var(--radius); box-shadow: 0 10px 30px rgba(0,0,0,.5);
  animation: pop .3s ease-out;
}
.tuto-bubble p { margin: 0 0 12px; }
@keyframes pop { from { transform: scale(.85); opacity: 0; } }

/* ---------- Dossier ---------- */
.dossier { position: relative; width: 220px; height: 170px; margin: 28px auto 32px; animation: bob 2.4s ease-in-out infinite; }
.card-back, .dossier-label { position: absolute; inset: 0; border-radius: 6px; }
.card-back {
  background: var(--paper-2) repeating-linear-gradient(0deg, transparent 0 18px, rgba(0,0,0,.08) 18px 19px);
  box-shadow: 0 2px 6px rgba(0,0,0,.4);
}
.card-back:nth-child(1) { transform: rotate(-8deg) translate(-10px, 4px); }
.card-back:nth-child(2) { transform: rotate(6deg) translate(8px, -2px); }
.card-back:nth-child(3) { transform: rotate(-3deg) translate(4px, 6px); }
.card-back:nth-child(4) { transform: rotate(4deg) translate(-6px, -4px); }
.card-back:nth-child(5) { transform: rotate(-1deg); }
.card-back:nth-child(6) { transform: rotate(2deg) translate(2px, 2px); }
.dossier-label {
  display: flex; align-items: center; justify-content: center;
  inset: auto 20px 50px; height: 44px;
  border: 3px solid var(--red); color: var(--red);
  font-family: var(--font-type); font-size: 22px; letter-spacing: .1em;
  transform: rotate(-8deg); background: rgba(244,236,216,.85);
}
@keyframes bob { 50% { transform: translateY(-6px); } }

/* Distribution des cartes au début de l'enquête */
.board.dealing { pointer-events: none; }
.clue.face-down { background: var(--paper-2) repeating-linear-gradient(0deg, transparent 0 18px, rgba(0,0,0,.08) 18px 19px); }
.clue.face-down > * { visibility: hidden; }
.clue.flip { animation: flip .35s ease-out; }
@keyframes flip { from { transform: rotateY(90deg); } }

/* ---------- Popup ---------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 30;
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
  background: rgba(10, 8, 6, .75);
  backdrop-filter: blur(2px);
  animation: fadein .3s ease;
}
.modal {
  max-width: 440px; width: 100%;
  padding: 24px 20px;
  background: var(--paper); color: var(--ink);
  border-radius: var(--radius);
  border-top: 6px solid var(--red);
  box-shadow: 0 20px 50px rgba(0,0,0,.6);
  text-align: center;
  animation: pop .35s ease-out;
}
.modal-icon { font-size: 48px; animation: shake .5s; }
.modal h2 { font-family: var(--font-type); font-size: clamp(22px, 5vw, 28px); margin: 8px 0 12px; }
.modal p { margin: 0 0 20px; }

/* ---------- Divers ---------- */
.disclaimer { text-align: center; font-size: 12px; color: #8a7f6c; padding: 16px; }

#toast {
  position: fixed; left: 50%; bottom: 20px; transform: translate(-50%, 120px);
  max-width: calc(100% - 32px);
  padding: 10px 16px; border-radius: var(--radius);
  background: #111; color: #fff; border: 1px solid #444;
  font-weight: 600; z-index: 20;
  transition: transform .25s;
}
#toast.show { transform: translate(-50%, 0); }
#toast.good { border-color: var(--green); }
#toast.bad { border-color: var(--red); }

#btn-replay { margin: 2rem auto; }

@media (max-width: 720px) {
  .board { grid-template-columns: repeat(2, 1fr); gap: 12px; padding: 12px; }
  .clue p { font-size: 13px; }
  .hud-brand { display: none; }
  #hud { justify-content: center; }
  .desk-actions .btn { width: 100%; }
}
@media (max-width: 480px) {
  .board { gap: 10px; padding: 10px; }
  .clue { padding: 22px 8px 8px; }
  .clue h3 { font-size: 14px; }
  .clue p { font-size: 12px; }
  .btn.small { font-size: 11px; padding: 4px 6px; }
}
@media (max-width: 320px) {
  .board { grid-template-columns: 1fr; }
}
