/* ==========================================================================
   MEURTRE EN SÉRIES — feuille de style (écran titre + écran de jeu)
   Direction artistique : polar néo-noir premium — fond sombre, or, contraste.
   Typographie : Bebas Neue (titres) · Inter (textes) · Special Elite (carnet)
   ========================================================================== */

:root {
  --bg: #06090f;
  --amber: #d9a441;
  --amber-hi: #f0c165;
  --text: #e6e0d2;
  --muted: #9a93a0;
  --line: rgba(217, 164, 65, 0.35);
  --red: #c0472f;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

/* L'attribut hidden doit TOUJOURS gagner (compatibilité serveurs standards) */
[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  font-family: "Inter", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  text-align: left;
  overflow: hidden;
}

/* ==========================================================================
   1) ÉCRAN TITRE
   ========================================================================== */
#homeScreen {
  position: relative;
  width: 100vw; height: 100vh; height: 100dvh;
  display: flex; flex-direction: column;
  overflow: hidden;
  background: #06090f;
}

#bgWrap {
  position: absolute; inset: 0;
  background:
    radial-gradient(130% 100% at 15% 0%, rgba(18, 30, 50, 0.95), transparent 55%),
    radial-gradient(120% 100% at 90% 110%, rgba(48, 30, 16, 0.85), transparent 60%),
    linear-gradient(160deg, #0a111f 0%, #0c1526 45%, #14101a 100%);
}
#bgWrap img {
  width: 100%; height: 100%;
  object-fit: cover; object-position: center;
  transform: scale(1.06);
  animation: kenburns 28s ease-in-out infinite alternate;
  will-change: transform;
}
@keyframes kenburns { from { transform: scale(1.06); } to { transform: scale(1.16); } }

.overlay {
  position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(rgba(4, 7, 12, 0.45), rgba(4, 7, 12, 0.3) 40%, rgba(4, 7, 12, 0.9));
  box-shadow: inset 0 0 140px rgba(0, 0, 0, 0.6);
}

.grain {
  position: absolute; inset: -60%; z-index: 1; pointer-events: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='220' height='220'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='2' stitchTiles='stitch'/><feColorMatrix type='saturate' values='0'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
  opacity: 0.07;
  mix-blend-mode: overlay;
  animation: grainmove 0.8s steps(3) infinite;
}
@keyframes grainmove {
  0% { transform: translate(0, 0); }
  33% { transform: translate(-2%, 3%); }
  66% { transform: translate(3%, -2%); }
  100% { transform: translate(0, 0); }
}

#topBar {
  position: relative; z-index: 2;
  display: flex; justify-content: flex-end; align-items: center;
  padding: calc(18px + env(safe-area-inset-top, 0px)) 26px 0;
  animation: fadeIn 1.2s 0.4s ease-out both;
}
#soundBtn {
  background: none; border: 1px solid rgba(154, 147, 160, 0.45); color: var(--muted);
  font: 500 11px/1 "Inter"; letter-spacing: 2px; padding: 8px 14px; cursor: pointer;
  text-transform: uppercase;
}
#soundBtn:hover { border-color: var(--amber); color: var(--amber-hi); }

#homeMain {
  position: relative; z-index: 2;
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: space-between;
  padding: 0 26px calc(24px + env(safe-area-inset-bottom, 0px));
  text-align: center;
}

.titleBlock {
  margin-top: 6vh;
  display: flex; flex-direction: column; align-items: center;
  animation: riseIn 1.15s cubic-bezier(0.2, 0.7, 0.2, 1) both;
}

#titleEl {
  font-family: "Bebas Neue", "Arial Narrow", sans-serif;
  font-weight: 400;
  font-size: clamp(56px, 10vw, 124px);
  letter-spacing: clamp(2px, 0.5vw, 7px);
  line-height: 0.96;
  text-transform: uppercase;
  text-wrap: balance;
  background: linear-gradient(180deg, #fffdf6 0%, #f0e2bd 45%, #c9a44c 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
  filter: drop-shadow(0 3px 4px rgba(0, 0, 0, 0.8)) drop-shadow(0 10px 34px rgba(0, 0, 0, 0.65));
}

#taglineEl {
  margin-top: 20px;
  font-size: clamp(14px, 2.4vw, 17px);
  font-weight: 400; letter-spacing: 0.5px;
  color: #ddd3c0; line-height: 1.55;
  animation: riseIn 1.15s 0.15s cubic-bezier(0.2, 0.7, 0.2, 1) both;
}

#episodeRow {
  display: flex; align-items: center; gap: 16px;
  margin-top: 18px;
  animation: riseIn 1.15s 0.3s cubic-bezier(0.2, 0.7, 0.2, 1) both;
}
#episodeEl {
  font-family: "Bebas Neue", sans-serif; font-weight: 400;
  font-size: clamp(15px, 2.2vw, 21px);
  letter-spacing: 5px; color: var(--amber);
  text-transform: uppercase; white-space: nowrap;
}
.rule { width: 64px; height: 1px; background: linear-gradient(90deg, rgba(217, 164, 65, 0), rgba(217, 164, 65, 0.85)); }
.rule.rev { transform: scaleX(-1); }

#menu {
  display: flex; flex-direction: column; align-items: center; gap: 16px; margin-top: 4vh;
  width: 100%;
  animation: riseIn 1.15s 0.45s cubic-bezier(0.2, 0.7, 0.2, 1) both;
}

.cta {
  position: relative; overflow: hidden;
  font-family: "Bebas Neue", sans-serif; font-weight: 400;
  font-size: 26px; letter-spacing: 5px; text-transform: uppercase;
  padding: 18px 64px; cursor: pointer;
  color: #171006;
  background: linear-gradient(180deg, #f2c979 0%, #d9a441 55%, #b8842c 100%);
  border: 1px solid rgba(255, 225, 160, 0.65);
  outline: 1px solid rgba(217, 164, 65, 0.35); outline-offset: 6px;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.3);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.55), 0 0 44px rgba(217, 164, 65, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.5);
  transition: transform 0.18s ease, box-shadow 0.18s ease, filter 0.18s ease;
}
.cta::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(115deg, transparent 42%, rgba(255, 255, 255, 0.4) 50%, transparent 58%);
  transform: translateX(-130%);
  transition: transform 0.7s ease;
}
.cta:hover {
  transform: translateY(-2px);
  filter: brightness(1.07);
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.6), 0 0 80px rgba(240, 193, 101, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.5);
}
.cta:hover::after { transform: translateX(130%); }
.cta:active { transform: translateY(0); }

.cta.small {
  font-size: 18px; letter-spacing: 4px; padding: 12px 36px;
}

.cta.ghost {
  font-size: 20px; letter-spacing: 4px;
  background: none; color: rgba(230, 224, 210, 0.9);
  border-color: rgba(230, 224, 210, 0.45);
  outline: 1px solid rgba(230, 224, 210, 0.18); outline-offset: 5px;
  text-shadow: none; box-shadow: none;
}
.cta.ghost::after { display: none; }
.cta.ghost:hover { background: rgba(230, 224, 210, 0.95); color: #14100a; filter: none; }

.ghostBtn {
  background: none; border: 1px solid rgba(154, 147, 160, 0.45); color: var(--muted);
  font: 500 11px/1 "Inter"; letter-spacing: 2px; padding: 8px 14px; cursor: pointer;
  text-transform: uppercase;
}
.ghostBtn:hover { border-color: var(--amber); color: var(--amber-hi); }

#foot {
  position: relative; z-index: 2; text-align: center;
  font-size: 11px; letter-spacing: 1.5px; color: rgba(154, 147, 160, 0.8);
  padding: 10px 16px calc(12px + env(safe-area-inset-bottom, 0px));
  animation: fadeIn 1.2s 0.6s ease-out both;
}

/* ==========================================================================
   2) ÉCRAN DE JEU
   ========================================================================== */
#gameScreen {
  position: relative; z-index: 4;
  width: 100vw; height: 100vh; height: 100dvh;
  display: flex; flex-direction: column;
  overflow: hidden;
  background: #06090f;
  opacity: 1;
  transition: opacity 0.45s ease;
}

/* Contrôle d'affichage par classe (plus fiable que l'attribut hidden) */
#homeScreen:not(.active), #gameScreen:not(.active), #maintScreen:not(.active) { display: none !important; }
#gameScreen.gOut { opacity: 0; }

/* ==========================================================================
   2bis) ÉCRAN DE MAINTENANCE
   ========================================================================== */
#maintScreen {
  position: relative; z-index: 2;
  width: 100vw; height: 100vh; height: 100dvh;
  display: flex; flex-direction: column;
  overflow: hidden;
  background: #06090f;
}
#mBgWrap { position: absolute; inset: 0; }
#mBg {
  width: 100%; height: 100%;
  object-fit: cover; object-position: center;
  transform: scale(1.06);
  animation: kenburns 30s ease-in-out infinite alternate;
  will-change: transform;
}
#maintMain {
  position: relative; z-index: 2;
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 0 26px; text-align: center;
}
#maintKicker {
  font-family: "Special Elite", monospace;
  font-size: 14px; letter-spacing: 4px; color: var(--amber);
  text-transform: uppercase;
}
#mTitle {
  margin-top: 16px;
  font-family: "Bebas Neue", sans-serif; font-weight: 400;
  font-size: clamp(40px, 8vw, 84px);
  letter-spacing: 5px; line-height: 1; text-transform: uppercase;
  background: linear-gradient(180deg, #fffdf6 0%, #f0e2bd 45%, #c9a44c 100%);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent; color: transparent;
  filter: drop-shadow(0 3px 4px rgba(0, 0, 0, 0.8)) drop-shadow(0 10px 34px rgba(0, 0, 0, 0.65));
}
#mText {
  margin-top: 18px;
  font-size: clamp(14px, 2.2vw, 17px); line-height: 1.6;
  color: #ddd3c0; max-width: 620px;
}
#mFoot {
  position: relative; z-index: 2; text-align: center;
  padding: 10px 16px calc(14px + env(safe-area-inset-bottom, 0px));
}
.adminLink {
  font-size: 11px; letter-spacing: 2px; text-transform: uppercase;
  color: var(--muted); text-decoration: none;
}
.adminLink:hover { color: var(--amber-hi); }

#gBgWrap { position: absolute; inset: 0; }
#gBg {
  width: 100%; height: 100%;
  object-fit: cover; object-position: center;
  transform: scale(1.06);
  animation: kenburns 30s ease-in-out infinite alternate;
  will-change: transform;
}

/* ---- Barre de jeu (HUD) ---- */
#gTop.hud {
  position: absolute; top: 0; left: 0; right: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(14px + env(safe-area-inset-top, 0px)) 18px;
  background: linear-gradient(180deg, rgba(4, 7, 12, 0.75), transparent);
}
#gTop.hud .left { display: flex; align-items: center; gap: 14px; min-width: 0; }
.menuBtn {
  display: inline-flex; align-items: center; gap: 6px; flex: none;
  border: 1px solid rgba(154, 147, 160, 0.45); color: var(--muted);
  font: 500 11px/1 "Inter"; letter-spacing: 2px; text-transform: uppercase;
  padding: 8px 12px; border-radius: 4px; background: rgba(6, 9, 15, 0.35);
  cursor: pointer;
}
.menuBtn:hover { border-color: var(--amber); color: var(--amber-hi); }
.place {
  font-family: "Special Elite", monospace;
  font-size: 12px; letter-spacing: 1.5px;
  color: var(--muted); text-transform: uppercase;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.place #hudTime { color: var(--amber); }

.carnetBtn {
  display: inline-flex; align-items: center; gap: 10px; flex: none; cursor: pointer;
  border: 1px solid var(--line); border-radius: 6px; padding: 7px 12px 7px 14px;
  background: rgba(12, 16, 24, 0.6); color: var(--text);
  box-shadow: 0 0 0 1px rgba(240, 193, 101, 0.12), 0 0 22px rgba(217, 164, 65, 0.15);
  font-family: "Inter", sans-serif;
}
.carnetBtn:hover { border-color: var(--amber); }
.carnetBtn .lbl { font-family: "Bebas Neue", sans-serif; font-size: 15px; letter-spacing: 3px; color: var(--amber-hi); }
.carnetBtn .count {
  min-width: 22px; height: 22px; padding: 0 6px; border-radius: 11px;
  display: inline-flex; align-items: center; justify-content: center;
  background: linear-gradient(180deg, #f2c979, #d9a441); color: #171006;
  font: 600 12px/1 "Inter";
}
.carnetBtn .count.bump { animation: bump 0.45s ease; }
@keyframes bump { 0% { transform: scale(1); } 40% { transform: scale(1.35); } 100% { transform: scale(1); } }
.loupe { width: 15px; height: 15px; opacity: 0.9; flex: none; }

#gSpacer { position: relative; z-index: 2; flex: 1; cursor: pointer; }

#gBox {
  position: relative; z-index: 4;
  width: min(680px, 64vw, calc(100% - 24px));
  margin: 0 auto 0 0;
  background: linear-gradient(180deg, rgba(8, 12, 20, 0.7), rgba(6, 9, 15, 0.94));
  border-top: 1px solid var(--line);
  border-right: 1px solid var(--line);
  border-top-right-radius: 10px;
  padding: 18px 22px calc(16px + env(safe-area-inset-bottom, 0px));
  text-align: left;
  box-shadow: 0 -20px 60px rgba(0, 0, 0, 0.5);
}
#gSpeaker {
  font-family: "Special Elite", monospace;
  font-size: 12px; letter-spacing: 1.5px; color: var(--amber);
  text-transform: uppercase; margin-bottom: 8px;
}
#gText {
  font-size: 15px; line-height: 1.55;
  color: #e8e1d1; margin-bottom: 14px; min-height: 2.4em;
}
#gNav {
  display: flex; justify-content: flex-end;
  margin-top: 4px;
}

/* -------- Liste de choix -------- */
#gChoices {
  display: flex; flex-direction: column; gap: 8px;
  margin-bottom: 6px;
}
.choice {
  display: flex; align-items: center; gap: 10px; cursor: pointer;
  border: 1px solid var(--line); border-radius: 5px; padding: 11px 14px;
  background: rgba(10, 14, 22, 0.55); color: var(--text);
  font: 400 13px/1.3 "Inter"; letter-spacing: 0.6px; text-align: left;
  transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}
.choice:hover {
  border-color: var(--amber); color: var(--amber-hi);
  background: rgba(20, 16, 10, 0.6);
}
.choice .dot { width: 5px; height: 5px; border-radius: 50%; background: var(--amber); flex: none; }
.choice.locked { color: var(--muted); border-style: dashed; opacity: 0.7; cursor: default; }
.choice.locked:hover { color: var(--muted); border-color: var(--line); background: rgba(10, 14, 22, 0.55); }
.choice.locked .dot { background: var(--muted); }
.lockNote {
  font-family: "Special Elite", monospace;
  font-size: 10px; letter-spacing: 1px;
  color: var(--muted); margin-left: auto; text-transform: uppercase;
  white-space: nowrap;
}

/* -------- Toast (indice ramassé) -------- */
#toast {
  position: absolute; left: 18px;
  bottom: calc(18px + env(safe-area-inset-bottom, 0px)); z-index: 8;
  display: flex; align-items: center; gap: 8px;
  background: rgba(16, 17, 10, 0.92); border: 1px solid var(--amber);
  color: var(--amber-hi); font: 500 12px "Inter"; letter-spacing: 0.4px;
  padding: 9px 13px; border-radius: 6px;
  animation: toastIn 0.25s ease;
}
@keyframes toastIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ==========================================================================
   2ter) CARNET — panneau coulissant depuis la droite
   ========================================================================== */
#carnetWrap { position: fixed; inset: 0; z-index: 9; pointer-events: none; }
#cScrim {
  position: absolute; inset: 0;
  background: rgba(3, 5, 10, 0.55);
  opacity: 0; transition: opacity 0.25s ease;
}
#carnetPanel {
  position: absolute; top: 0; right: 0; bottom: 0;
  width: min(430px, 38vw, 100%);
  background: linear-gradient(180deg, #0d1017 0%, #0a0c12 100%);
  border-left: 1px solid var(--line);
  box-shadow: -30px 0 60px rgba(0, 0, 0, 0.55);
  transform: translateX(102%);
  transition: transform 0.32s cubic-bezier(0.2, 0.7, 0.2, 1);
  display: flex; flex-direction: column;
}
#carnetPanel::before {
  content: ""; position: absolute; inset: 0; pointer-events: none; opacity: 0.05;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='180' height='180'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/><feColorMatrix type='saturate' values='0'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
}
#carnetWrap.open { pointer-events: auto; }
#carnetWrap.open #cScrim { opacity: 1; }
#carnetWrap.open #carnetPanel { transform: none; }
.cHead { padding: 16px 18px 12px; border-bottom: 1px solid var(--line); }
.cTitle { display: flex; align-items: center; justify-content: space-between; }
.cTitle h2 {
  font-family: "Bebas Neue", sans-serif; font-weight: 400;
  font-size: 22px; letter-spacing: 3px; color: var(--amber-hi);
}
.cClose {
  color: var(--muted); font-size: 18px; line-height: 1; cursor: pointer;
  background: none; border: none; padding: 4px; font-family: "Inter", sans-serif;
}
.cClose:hover { color: var(--amber-hi); }
.cSub {
  font-family: "Special Elite", monospace;
  font-size: 11px; letter-spacing: 1px; color: var(--muted); margin-top: 6px;
}
.cList {
  flex: 1; overflow-y: auto;
  padding: 12px 14px;
  display: flex; flex-direction: column; gap: 10px;
}
.indice {
  position: relative;
  border: 1px solid rgba(154, 147, 160, 0.22);
  background: rgba(10, 14, 22, 0.6);
  border-radius: 6px; padding: 11px 13px;
}
.indice .nom {
  font-family: "Special Elite", monospace;
  font-size: 13px; letter-spacing: 0.5px; color: var(--amber-hi);
}
.indice .desc { font-size: 12px; line-height: 1.5; color: #b9b3a5; margin-top: 4px; }
.stamp {
  position: absolute; top: 8px; right: 8px; transform: rotate(7deg);
  border: 1.5px solid var(--red); color: var(--red);
  font: 700 9px/1 "Inter"; letter-spacing: 1.5px; text-transform: uppercase;
  padding: 3px 6px; border-radius: 3px; opacity: 0.9;
}
.cEmpty {
  color: var(--muted);
  font-size: 12px; font-style: italic; line-height: 1.6;
}

/* ==========================================================================
   3) ANIMATIONS & RESPONSIVE
   ========================================================================== */
@keyframes riseIn { from { opacity: 0; transform: translateY(24px); } to { opacity: 1; transform: none; } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

@media (max-width: 700px) {
  #topBar { padding: calc(12px + env(safe-area-inset-top, 0px)) 14px 0; }
  #titleEl { letter-spacing: 2px; }
  #episodeRow { gap: 10px; }
  .rule { width: 34px; }
  #menu { gap: 12px; }
  .cta { font-size: 22px; letter-spacing: 4px; padding: 16px 40px; width: min(320px, 86vw); }
  .cta.ghost { width: auto; font-size: 17px; }
  .cta.small { font-size: 16px; padding: 12px 28px; width: auto; }
  #gTop.hud { padding: calc(12px + env(safe-area-inset-top, 0px)) 12px 0; }
  #gBox { width: 100%; border-right: none; border-top-right-radius: 0; padding: 18px 18px calc(16px + env(safe-area-inset-bottom, 0px)); }
  #carnetPanel { width: 82%; }
  #toast { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  #bgWrap img, #gBg, #mBg, .grain { animation: none !important; }
  #bgWrap img, #gBg, #mBg { transform: none; }
  .titleBlock, #taglineEl, #episodeRow, #menu, #topBar, #foot { animation: none !important; }
}
