/* ============================================================
   CYBER QUIZ CHALLENGE — recreation
   ============================================================ */
:root {
  --green: #2fa869;
  --green-d: #289a5e;
  --red: #e0492f;
  --red-d: #d23f27;
  --purple: #6f56cb;
  --purple-d: #5e46b8;
  --blue: #4a86e8;
  --ink: #2b2b2b;
  --ink-soft: #6b6b6b;
  --paper: #e7e1d9;   /* warm light game bg */
  --sage: #dde4e0;    /* cool light game bg */
  --dark: #333333;    /* dark noise bg */
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--dark);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  user-select: none;
}

#bg-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  display: block;
}

/* Rainbow screen-edge frame, flashed when the player answers correctly.
   Same gradient as the Démarrer/Valider buttons, masked to a border ring. */
@property --rb-angle { syntax: "<angle>"; initial-value: 0deg; inherits: false; }
#correct-flash {
  position: fixed;
  inset: 0;
  z-index: 40;
  pointer-events: none;
  padding: 12px;                 /* ring thickness */
  background: conic-gradient(from var(--rb-angle),
    #aef23a, #21e6ff, #2d6cff, #8b2fff, #ff2bd6, #aef23a);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
          mask-composite: exclude;
  opacity: 0;
  transition: opacity .12s ease;
}
#correct-flash.show {
  opacity: 1;
  animation: rb-spin 1.1s linear infinite;
}
@keyframes rb-spin { to { --rb-angle: 360deg; } }
@media (prefers-reduced-motion: reduce) {
  #correct-flash.show { animation: none; }
}


/* Slowly shifting colour wash behind the home title (screen-blended over the
   pixel noise). Hue rotates continuously => smooth cross-fade between colours. */
#home-fx {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  opacity: 0;
  transition: opacity 1s ease;
  /* soft, desaturated tones (not vivid) */
  background: linear-gradient(125deg, #5b5276, #4f6585, #4a7d72, #7d7355, #74566e, #5b5276);
  background-size: 300% 300%;
  mix-blend-mode: screen;
  animation: home-shift 6s ease-in-out infinite, home-hue 5s linear infinite;
}
#home-fx.on { opacity: .5; }
@keyframes home-shift { 0%, 100% { background-position: 0% 50%; } 50% { background-position: 100% 50%; } }
@keyframes home-hue   { to { filter: hue-rotate(360deg); } }

main#screen {
  position: relative;
  z-index: 3;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.hidden { display: none !important; }

/* ============================================================
   HUD
   ============================================================ */
.hud {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 5;
  display: flex;
  justify-content: space-between;
  padding: 30px 44px;
  pointer-events: none;
}
.hud-right { text-align: right; }
.hud-label {
  font-size: 13px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--ink-soft);
  font-weight: 600;
  opacity: .8;
}
.hud-value {
  font-size: 48px;
  font-weight: 800;
  letter-spacing: -.02em;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  line-height: 1.05;
}
.hud.light .hud-label, .hud.light .hud-value { color: var(--ink); }
.hud.invert .hud-label { color: rgba(255,255,255,.7); }
.hud.invert .hud-value { color: #fff; }
/* softly fading timer on the "Comment jouer ?" / countdown screen */
.hud-value.blink { animation: softblink 1.6s ease-in-out infinite; }
@keyframes softblink { 0%, 100% { opacity: 1; } 50% { opacity: .12; } }

/* ============================================================
   Generic helpers
   ============================================================ */
.fade-in { animation: fadeIn .35s ease both; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.pop-in { animation: popIn .3s cubic-bezier(.2,.9,.3,1.3) both; }
@keyframes popIn { from { opacity: 0; transform: scale(.9); } to { opacity: 1; transform: scale(1); } }

/* ============================================================
   HOME
   ============================================================ */
.home {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
}
/* gentle pendulum sway of the whole title */
.home-title {
  transform-origin: center top;
  animation: title-sway 5s ease-in-out infinite;
}
@keyframes title-sway {
  0%, 100% { transform: rotate(-2deg); }
  50%      { transform: rotate(2deg); }
}

.home h1 {
  font-size: clamp(68px, 12vw, 176px);
  font-weight: 900;
  line-height: .9;
  letter-spacing: -.03em;
  color: #f3efe9;
  text-shadow: 0 2px 30px rgba(0,0,0,.35);
}
.home .sub {
  margin-top: 6px;
  font-size: clamp(19px, 2.8vw, 36px);
  font-weight: 800;
  letter-spacing: .22em;
  color: #f3efe9;
  animation: sub-glow 3.6s ease-in-out infinite;
}
@keyframes sub-glow {
  0%, 100% { opacity: .82; text-shadow: 0 0 0 transparent; }
  50%      { opacity: 1;   text-shadow: 0 0 22px rgba(255,255,255,.45); }
}
.home .actions { margin-top: 56px; display: flex; flex-direction: column; align-items: center; gap: 28px; }
/* Bigger CTA buttons on the home page only (text scales with them) */
.home .btn-primary { padding: 30px 92px; font-size: 40px; }
.home .link-btn { font-size: 30px; gap: 12px; }
.home .link-btn svg { width: 32px; height: 32px; }

.btn-primary {
  background: var(--purple);
  color: #fff;
  border: none;
  border-radius: 999px;
  padding: 22px 66px;
  font-size: 27px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  box-shadow: 0 10px 30px rgba(111,86,203,.45);
  transition: transform .12s ease, background .15s ease;
}
.btn-primary:hover { background: var(--purple-d); transform: translateY(-2px); }
.btn-primary:active { transform: translateY(0); }

.link-btn {
  background: none;
  border: none;
  color: #e8e3dc;
  font-family: inherit;
  font-size: 20px;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  opacity: .9;
  transition: opacity .15s ease;
}
.link-btn:hover { opacity: 1; }
.link-btn svg { width: 22px; height: 22px; }

/* ============================================================
   CLASSEMENT
   ============================================================ */
.board {
  width: min(740px, 90vw);
  text-align: center;
}
.board h2 {
  font-size: clamp(40px, 5.6vw, 60px);
  font-weight: 800;
  color: #f3efe9;
  letter-spacing: -.02em;
  margin-bottom: 26px;
}
.board-list { display: flex; flex-direction: column; }
.board-row {
  display: flex;
  align-items: center;
  gap: 19px;
  padding: 17px 8px;
  border-top: 1px solid rgba(255,255,255,.09);
  color: #ece7e0;
}
.board-row:last-child { border-bottom: 1px solid rgba(255,255,255,.09); }
.board-rank {
  width: 36px;
  text-align: center;
  font-weight: 700;
  font-size: 19px;
  color: #b9b3ab;
  flex: none;
}
.board-rank.medal { font-size: 24px; }
.board-name {
  flex: 1;
  text-align: left;
  font-size: 17px;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: #d8d3cc;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.board-score { font-weight: 800; font-size: 19px; color: #f3efe9; }
.board-row.you { background: rgba(111,86,203,.18); border-radius: 8px; }
.board-row.you .board-name { color: #fff; }

.btn-pill {
  margin-top: 30px;
  background: #f3efe9;
  color: var(--ink);
  border: none;
  border-radius: 999px;
  padding: 20px 56px;
  font-size: 23px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: transform .12s ease, background .15s;
}
.btn-pill:hover { transform: translateY(-2px); background: #fff; }
.board-foot { margin-top: 16px; font-size: 11px; color: #777; letter-spacing: .05em; }

/* ============================================================
   COUNTDOWN (3 · 2 · 1 · GO before the game starts)
   ============================================================ */
.countdown {
  font-size: clamp(150px, 30vw, 380px);
  font-weight: 900;
  color: var(--ink);
  line-height: 1;
  letter-spacing: -.02em;
  animation: countPop .8s ease both;
}
.countdown.go { color: var(--green); font-size: clamp(90px, 18vw, 220px); }
@keyframes countPop {
  0%   { opacity: 0; transform: scale(.45); }
  35%  { opacity: 1; transform: scale(1.12); }
  100% { opacity: .9; transform: scale(1); }
}

/* ============================================================
   RULES
   ============================================================ */
.rules-overlay {
  position: fixed; inset: 0; z-index: 6;
  background: rgba(220,222,216,.55);
  backdrop-filter: blur(2px);
  display: flex; align-items: center; justify-content: center;
}
.rules {
  text-align: center;
  width: min(1000px, 94vw);
}
.rules h2 {
  font-size: clamp(32px, 4.2vw, 48px);
  font-weight: 800;
  color: var(--ink);
  margin-bottom: 34px;
}
.rules-cards { display: flex; gap: 18px; justify-content: center; flex-wrap: wrap; }
.rule-card {
  flex: 1 1 0;
  min-width: 250px;
  max-width: 320px;
  background: rgba(255,255,255,.5);
  border: 1px solid rgba(0,0,0,.06);
  border-radius: 14px;
  padding: 26px 24px;
  text-align: center;
}
.rule-card .ic {
  width: 64px; height: 64px;
  margin: 0 auto 16px;
  border-radius: 12px;
  background: rgba(0,0,0,.05);
  display: flex; align-items: center; justify-content: center;
}
.rule-card .ic svg { width: 36px; height: 36px; stroke: #4a4a4a; }
.rule-card p { font-size: 17px; line-height: 1.45; color: #3a3a3a; font-weight: 500; }
.rule-card .note {
  margin-top: 16px;
  font-size: 13.5px;
  color: #7a7a7a;
  display: flex; align-items: center; gap: 8px; justify-content: center;
  line-height: 1.35;
}
.rule-card .note svg { width: 19px; height: 19px; flex: none; stroke: #9a9a9a; }
.rules .btn-primary { margin-top: 34px; }

/* ============================================================
   QUESTION (gameplay)
   ============================================================ */
.q {
  width: min(1000px, 95vw);
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.q-title {
  font-size: clamp(36px, 5vw, 56px);
  font-weight: 800;
  color: var(--ink);
  line-height: 1.15;
  letter-spacing: -.01em;
  margin-bottom: 30px;
  max-width: 860px;
}
/* "Bon réflexe / Mauvais réflexe" statement (light bg, not a hacker fight) */
.reflex-stmt { display: flex; flex-direction: column; align-items: center; }
.q-title.reflexq {
  text-transform: uppercase;
  font-style: italic;
  font-weight: 800;
  font-size: clamp(30px, 4.2vw, 46px);
  max-width: 880px;
  margin-bottom: 0;
}

/* small caption with icon (Mot de passe / phone number / etc.) */
.q-cap {
  display: inline-flex; align-items: center; gap: 9px;
  font-size: 22px; font-weight: 600; color: #555;
  margin-bottom: 14px;
}
.q-cap svg { width: 28px; height: 28px; stroke: #555; }

/* URL pill */
.q-pill {
  display: inline-flex; align-items: center; gap: 12px;
  background: rgba(255,255,255,.35);
  border: 1.5px solid rgba(0,0,0,.18);
  border-radius: 999px;
  padding: 24px 46px;
  font-size: clamp(22px, 2.7vw, 30px);
  color: #2b2b2b;
  font-weight: 500;
}
.q-pill svg { width: 23px; height: 23px; stroke: #555; flex: none; }

/* Password box */
.q-box {
  background: rgba(255,255,255,.5);
  border: 1.5px solid rgba(0,0,0,.18);
  border-radius: 8px;
  padding: 30px 42px;
  font-size: clamp(32px, 4.6vw, 54px);
  font-weight: 500;
  color: #2b2b2b;
  letter-spacing: .01em;
  max-width: 90vw;
  overflow-wrap: anywhere;
}

/* SMS bubble */
.sms { width: min(470px, 88vw); text-align: left; }
.sms-head {
  display: flex; align-items: center; gap: 10px;
  font-weight: 700; font-size: 24px; color: #2b2b2b;
  margin-bottom: 12px; justify-content: center;
}
.sms-head svg { width: 30px; height: 30px; fill: #2b2b2b; }
.sms-bubble {
  background: rgba(255,255,255,.65);
  border-radius: 4px 16px 16px 16px;
  padding: 20px 22px 14px;
  font-size: 20.5px;
  line-height: 1.4;
  color: #333;
  position: relative;
  box-shadow: 0 2px 8px rgba(0,0,0,.05);
}
.sms-time { display: block; text-align: right; font-size: 15px; color: #999; margin-top: 6px; }

/* Answer buttons — anchored near the bottom of the screen */
.q-answers, .hf-answers {
  position: fixed;
  bottom: 9vh;
  left: 50%;
  transform: translateX(-50%);
  display: flex; gap: 30px; justify-content: center;
  z-index: 4;
}
.ans {
  position: relative;
  min-width: 240px;
  border: 3px solid rgba(255,255,255,.92);
  border-radius: 9px;
  padding: 34px 52px 28px;
  font-size: 34px;
  font-weight: 700;
  font-family: inherit;
  color: #fff;
  cursor: pointer;
  white-space: nowrap;
  transition: transform .1s ease, filter .12s ease;
}
.ans:hover { transform: translateY(-2px); filter: brightness(1.04); }
.ans:active { transform: translateY(0); }
.ans.green { background: var(--green); box-shadow: 0 8px 20px rgba(47,168,105,.35); }
.ans.red   { background: var(--red);   box-shadow: 0 8px 20px rgba(224,73,47,.35); }
.ans .key {
  position: absolute; top: 10px; left: 10px;
  width: 31px; height: 31px;
  border: 1.5px solid rgba(255,255,255,.7);
  border-radius: 5px;
  font-size: 15px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  opacity: .85;
}
.ans.correct { animation: flashGreen .5s ease; }
.ans.wrong   { animation: flashRed .5s ease; }
@keyframes flashGreen { 0%,100%{filter:brightness(1)} 50%{filter:brightness(1.4)} }
@keyframes flashRed { 0%,100%{transform:translateX(0)} 20%{transform:translateX(-7px)} 60%{transform:translateX(7px)} }

/* ============================================================
   HACKER FIGHT
   ============================================================ */
.hf {
  width: min(880px, 95vw);
  text-align: center;
  display: flex; flex-direction: column; align-items: center;
}
.hf-q {
  font-size: clamp(27px, 3.8vw, 42px);
  font-weight: 700;
  font-style: italic;
  color: #f1ece6;
  text-shadow: 0 1px 16px rgba(0,0,0,.5);
  margin-bottom: 26px;
  text-transform: none;
  max-width: 800px;
  line-height: 1.3;
}
.hf-q.caps { text-transform: uppercase; font-style: italic; letter-spacing: .02em; }

/* Hacker fight intro page */
.hf-intro { text-align: center; color: #f1ece6; }
.hf-intro-skull {
  font-size: clamp(72px, 14vw, 150px);
  line-height: 1;
  filter: drop-shadow(0 0 22px rgba(224,73,47,.7));
  animation: hf-pulse 1s ease-in-out infinite;
}
.hf-intro-title {
  margin-top: 6px;
  font-size: clamp(52px, 11vw, 130px);
  font-weight: 900;
  letter-spacing: .04em;
  color: #fff;
  text-shadow: 0 0 26px rgba(224,73,47,.85), 0 0 8px rgba(255,255,255,.35);
  animation: hf-glitch 1.4s steps(2) infinite;
}
.hf-intro-sub {
  margin-top: 16px;
  font-size: clamp(17px, 2.6vw, 28px);
  font-weight: 600;
  color: #e6cdc8;
}
.hf-intro-sub b { color: var(--red); letter-spacing: .04em; }
@keyframes hf-pulse  { 50% { transform: scale(1.12); } }
@keyframes hf-glitch { 0%,100% { transform: translateX(0); } 50% { transform: translateX(2px); } }
.hf-thumb { font-size: 46px; margin-bottom: 16px; }
.hf .ans { background: rgba(40,36,34,.82); box-shadow: none; border: 3px solid rgba(255,255,255,.92); }
.hf .ans:hover { background: rgba(40,36,34,.95); }

/* ============================================================
   CLIC minigame
   ============================================================ */
.clic-screen {
  position: fixed; inset: 0; z-index: 4;
  background: var(--blue);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  color: #fff;
}
.clic-hint { font-size: clamp(20px, 2.9vw, 31px); font-weight: 500; margin-bottom: 30px; opacity: .95; }
.clic-btn {
  width: min(660px, 88vw);
  background: transparent;
  border: 3px solid #fff;
  border-radius: 12px;
  color: #fff;
  font-size: clamp(34px, 5.6vw, 62px);
  font-weight: 800;
  font-family: inherit;
  padding: 40px 0;
  cursor: pointer;
  transition: transform .05s ease, background .08s;
}
.clic-btn:active { transform: scale(.985); background: rgba(255,255,255,.12); }
.clic-bar {
  margin-top: 26px;
  width: min(660px, 88vw); height: 84px;
  border: 3px solid #fff;
  border-radius: 12px;
  overflow: hidden;
  background: rgba(255,255,255,.12);
}
.clic-bar > i {
  display: block; height: 100%; width: 0%;
  background: rgba(255,255,255,.45);
  transition: width .08s ease-out;
}
.clic-foot {
  position: fixed; bottom: 30px; left: 0; right: 0; text-align: center;
  font-size: 18px; color: rgba(255,255,255,.85);
}
.kbd {
  border: 1.5px solid rgba(255,255,255,.7);
  border-radius: 6px; padding: 3px 10px; margin-left: 6px;
  font-size: 15px; font-weight: 600;
}

/* ============================================================
   FULLSCREEN STATES (game over / hacked / explication / score / pseudo)
   ============================================================ */
.fs {
  position: fixed; inset: 0; z-index: 8;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  text-align: center;
}
.fs.red { background: var(--red); color: #f3efe9; }
.fs-huge {
  font-size: clamp(64px, 16vw, 220px);
  font-weight: 900;
  line-height: .92;
  letter-spacing: -.02em;
}
.fs-mid { font-size: clamp(40px, 9vw, 120px); font-weight: 900; letter-spacing: -.02em; }

/* Explication */
.expl { padding: 0 8vw; }
.expl .verdict { font-size: clamp(56px, 11vw, 130px); font-weight: 900; }
.expl p { margin-top: 18px; font-size: clamp(19px, 2.8vw, 26px); font-weight: 500; line-height: 1.5; max-width: 640px; opacity: .95; }
.expl .btn-pill { position: absolute; bottom: 7vh; left: 50%; transform: translateX(-50%); }
.expl .btn-pill:hover { transform: translateX(-50%) translateY(-2px); }
/* no rainbow border on the explication button */
.expl .btn-pill::before, .expl .btn-pill::after { content: none; }

/* Score */
.score-screen .label {
  font-size: clamp(22px, 3vw, 31px);
  font-weight: 600; letter-spacing: .12em; color: #e8e3dc;
  text-transform: uppercase; margin-bottom: 6px;
}
.score-screen .big {
  font-size: clamp(78px, 14vw, 176px);
  font-weight: 900; color: #f3efe9; letter-spacing: -.02em;
}

/* Pseudo */
.pseudo { width: min(900px, 95vw); text-align: center; }
.pseudo h2 { font-size: clamp(34px, 4.6vw, 52px); font-weight: 800; color: #f3efe9; margin-bottom: 50px; }
.pseudo-input {
  font-size: clamp(34px, 5.6vw, 54px);
  font-weight: 700; color: #fff;
  border-bottom: 2px solid rgba(255,255,255,.5);
  min-height: 1.4em; min-width: 340px; display: inline-block;
  padding: 4px 10px; margin-bottom: 30px; letter-spacing: .06em;
}
.pseudo-input .caret { color: #6f56cb; animation: blink 1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.keyboard { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.kb-row { display: flex; gap: clamp(4px, 1vw, 12px); flex-wrap: wrap; justify-content: center; }
.kb-key {
  background: none; border: none; color: #e8e3dc;
  font-family: inherit; font-size: clamp(22px, 3.1vw, 34px); font-weight: 700;
  cursor: pointer; padding: 4px 8px; border-radius: 6px;
  transition: background .1s, color .1s;
}
.kb-key:hover { background: rgba(255,255,255,.12); color: #fff; }
.kb-key.boxed { border: 1.5px solid rgba(255,255,255,.4); }
.kb-key.space { border: 1.5px solid rgba(255,255,255,.4); padding: 8px 48px; font-size: 19px; letter-spacing: .1em; }
.pseudo .btn-primary { margin-top: 22px; }

@media (max-width: 720px) {
  .rules-cards { flex-direction: column; align-items: center; }
  .rule-card { max-width: 92vw; }
  .hud { padding: 16px 20px; }
  .hud-value { font-size: 34px; }
}

/* ============================================================
   ANIMATED BUTTON BORDERS  (menu buttons only — NOT gameplay answers)
   - .btn-primary (Démarrer ×2, Valider) : gradient rotates AROUND the button
   - .btn-pill (Fermer / Ok j'ai compris) : gradient sweeps RIGHT -> LEFT
   A masking pseudo-element keeps the button's own colour in the centre,
   leaving only an animated gradient ring.
   ============================================================ */
@keyframes btn-spin  { to { transform: translate(-50%, -50%) rotate(360deg); } }
@keyframes btn-sweep { to { transform: translateX(-50%); } }

.btn-primary, .btn-pill {
  position: relative;
  overflow: hidden;
  isolation: isolate;
  z-index: 0;
}
/* centre mask = the button's own background colour */
.btn-primary::after, .btn-pill::after {
  content: "";
  position: absolute;
  inset: 3px;
  border-radius: inherit;
  background: inherit;
  z-index: -1;
}
/* rotating gradient (primary buttons) */
.btn-primary::before {
  content: "";
  position: absolute;
  left: 50%; top: 50%;
  width: 260%; aspect-ratio: 1;
  transform: translate(-50%, -50%);
  background: conic-gradient(from 0deg,
    #aef23a, #21e6ff, #2d6cff, #8b2fff, #ff2bd6, #aef23a);
  animation: btn-spin 2.6s linear infinite;
  z-index: -2;
}
/* right-to-left sweeping gradient (pill buttons) */
.btn-pill::before {
  content: "";
  position: absolute;
  top: 0; left: 0;
  height: 100%; width: 200%;
  background: linear-gradient(90deg,
    #aef23a, #21e6ff, #2d6cff, #8b2fff, #ff2bd6,
    #aef23a, #21e6ff, #2d6cff, #8b2fff, #ff2bd6);
  animation: btn-sweep 2s linear infinite;
  z-index: -2;
}
/* a touch more bloom on the primary buttons */
.btn-primary { box-shadow: 0 10px 30px rgba(111,86,203,.45), 0 0 16px rgba(123,60,255,.4); }

@media (prefers-reduced-motion: reduce) {
  .btn-primary::before, .btn-pill::before { animation: none; }
}
