/* ==========================================================================
   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);
}

* { 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;
}

#gTop {
  position: relative; z-index: 3;
  display: flex; justify-content: space-between; align-items: center;
  padding: calc(18px + env(safe-area-inset-top, 0px)) 26px 0;
}
#gTag {
  font-family: "Special Elite", monospace;
  font-size: 12px; letter-spacing: 1.5px; color: var(--muted);
  text-transform: uppercase;
}

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

#gBox {
  position: relative; z-index: 3;
  width: min(960px, 100%);
  margin: 0 auto;
  background: linear-gradient(180deg, rgba(8, 12, 20, 0.82), rgba(6, 9, 15, 0.95));
  border: 1px solid var(--line);
  border-bottom: none;
  padding: 22px 28px calc(18px + 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: 13px; letter-spacing: 1.5px; color: var(--amber);
  text-transform: uppercase;
}
#gText {
  margin-top: 10px;
  font-size: clamp(15px, 2.2vw, 18px); line-height: 1.6;
  color: #e8e1d1; min-height: 3.2em;
}
#gNav {
  display: flex; justify-content: flex-end;
  margin-top: 14px;
}

/* ==========================================================================
   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 { padding: calc(12px + env(safe-area-inset-top, 0px)) 14px 0; }
  #gBox { padding: 18px 18px calc(16px + env(safe-area-inset-bottom, 0px)); }
}

@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; }
}
