:root {
  --font-display: "Bebas Neue", "Arial Narrow", Impact, sans-serif;
  --font-body: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --amber: #ffb347;
  --ember: #ff6b35;
  --text: #f5efe4;
  --text-dim: rgba(245, 239, 228, 0.74);
  --card-bg: rgba(7, 9, 11, 0.88);
  --radius: 18px;
  --shadow: 0 20px 55px rgba(0, 0, 0, 0.5);
}

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

[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  font-family: var(--font-body);
  color: var(--text);
  background: #07090b;
  text-align: left;
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

#bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  background-color: #0a0d0f;
  background-size: cover;
  background-position: center;
  opacity: 0;
  transition: opacity 1.4s ease;
}
#bg.ready { opacity: 1; }

#bgOverlay {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background:
    radial-gradient(120% 80% at 50% -10%, rgba(0, 0, 0, 0.18) 0%, rgba(0, 0, 0, 0.42) 55%, rgba(0, 0, 0, 0.72) 100%),
    linear-gradient(to bottom, rgba(5, 7, 9, 0.30) 0%, rgba(5, 7, 9, 0.55) 60%, rgba(5, 7, 9, 0.92) 100%);
}

#app {
  position: relative;
  z-index: 2;
  max-width: 1060px;
  min-height: 100dvh;
  margin: 0 auto;
  padding: 44px 18px 40px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

#hero {
  text-align: center;
  margin-bottom: 34px;
}

.eyebrow {
  margin: 0 0 12px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.34em;
  text-transform: uppercase;
  color: var(--amber);
}

#titleEl {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(40px, 9.5vw, 128px);
  line-height: 0.92;
  letter-spacing: 0.03em;
  text-shadow: 0 6px 40px rgba(0, 0, 0, 0.55);
  user-select: none;
}
#titleEl .accent { color: var(--ember); }

.tagline {
  margin: 16px auto 0;
  max-width: 560px;
  font-size: clamp(15px, 3vw, 17px);
  font-weight: 700;
  line-height: 1.6;
  color: #ffffff;
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.5);
}

.intro {
  margin: 14px auto 0;
  max-width: 680px;
  font-size: clamp(13px, 2.8vw, 15px);
  line-height: 1.7;
  color: var(--text-dim);
  text-align: justify;
  text-align-last: center;
  text-wrap: pretty;
}

#modesCtn {
  width: 100%;
  display: grid;
  gap: 18px;
  grid-template-columns: 1fr;
}

.modeCard {
  position: relative;
  width: 100%;
  text-align: left;
  background: var(--card-bg);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform 0.28s ease, box-shadow 0.28s ease;
  animation: fadeUp 0.5s ease both;
}
.modeCard:nth-child(2) { animation-delay: 0.08s; }
.modeCard:nth-child(3) { animation-delay: 0.16s; }

.modeCard:hover { transform: translateY(-6px); box-shadow: 0 30px 70px rgba(0, 0, 0, 0.62); }
.modeCard:focus-visible { outline: 3px solid var(--amber); outline-offset: 3px; }

.modeCard .imgWrap {
  position: relative;
  display: block;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  background: #0a0d0f;
}
.modeCard img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scale(1.03);
  transition: transform 0.5s ease;
}
.modeCard:hover img { transform: scale(1.1); }

.modeCard .imgWrap::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(6, 8, 10, 0.95) 2%, rgba(6, 8, 10, 0.25) 58%, rgba(6, 8, 10, 0.05) 100%);
  pointer-events: none;
}

.modeCard .body {
  display: block;
  padding: 18px 18px 20px;
}

.modeCard .badge {
  display: inline-block;
  margin-bottom: 10px;
  padding: 5px 12px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--amber);
  border: 1px solid rgba(255, 179, 71, 0.45);
  border-radius: 999px;
}

.modeCard h2 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 30px;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: #ffffff;
}

.modeCard .desc {
  display: block;
  margin-top: 8px;
  font-size: 14px;
  line-height: 1.55;
  color: var(--text-dim);
  text-align: justify;
  text-align-last: left;
}

.modeCard .cta {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 8px;
  margin-top: 14px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--ember);
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ====== VUE DE JEU ====== */

#gameView {
  position: fixed;
  inset: 0;
  z-index: 5;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background: #07090b;
}

#sceneBg {
  position: absolute;
  inset: 0;
  z-index: 0;
  background-size: cover;
  background-position: center;
  opacity: 1;
  transition: opacity 0.9s ease;
}
#sceneBg.loading { opacity: 0; }

#gameScrim {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background: linear-gradient(to bottom, rgba(5, 7, 9, 0.45) 0%, rgba(5, 7, 9, 0.25) 38%, rgba(5, 7, 9, 0.62) 62%, rgba(5, 7, 9, 0.95) 100%);
}

#gameBar {
  position: sticky;
  top: 0;
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: rgba(7, 9, 11, 0.55);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  font-size: 13px;
  font-weight: 600;
}

#gameBar #gameModeLabel {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#scoreEl {
  font-weight: 700;
  color: var(--amber);
  letter-spacing: 0.04em;
}

#backBtn {
  width: 38px;
  height: 38px;
  flex: none;
  border: 1px solid rgba(245, 239, 228, 0.3);
  border-radius: 12px;
  background: rgba(245, 239, 228, 0.08);
  color: var(--text);
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding-bottom: 3px;
}
#backBtn:hover, #backBtn:focus-visible { background: rgba(245, 239, 228, 0.16); outline: none; }
#backBtn:focus-visible { outline: 2px solid var(--amber); }

.gamePanel {
  position: relative;
  z-index: 2;
  margin: min(34vh, 380px) auto 0;
  max-width: 640px;
  padding: 22px 20px 26px;
  background: rgba(7, 9, 11, 0.88);
  border-radius: 22px 22px 0 0;
  box-shadow: 0 -14px 50px rgba(0, 0, 0, 0.45);
}

.sceneBadge {
  display: inline-block;
  margin-bottom: 10px;
  padding: 5px 12px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--amber);
  border: 1px solid rgba(255, 179, 71, 0.45);
  border-radius: 999px;
}

#sceneTitle {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 34px;
  letter-spacing: 0.02em;
  color: #ffffff;
}

#sceneText {
  margin-top: 12px;
  font-size: 15px;
  line-height: 1.7;
  color: var(--text-dim);
  text-align: justify;
  text-align-last: left;
  text-wrap: pretty;
}

#choicesCtn {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 20px;
}

.choiceBtn {
  width: 100%;
  padding: 15px 16px;
  border: 1px solid rgba(245, 239, 228, 0.22);
  border-radius: 14px;
  background: rgba(245, 239, 228, 0.07);
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.5;
  text-align: justify;
  text-align-last: left;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}
.choiceBtn:hover:not(:disabled) { background: rgba(255, 179, 71, 0.14); border-color: rgba(255, 179, 71, 0.55); }
.choiceBtn:focus-visible { outline: 3px solid var(--amber); outline-offset: 2px; }
.choiceBtn:disabled { cursor: default; opacity: 0.75; }
.choiceBtn.goodPick { border-color: #4caf50; background: rgba(76, 175, 80, 0.18); }
.choiceBtn.badPick { border-color: #e23b1f; background: rgba(226, 59, 31, 0.18); }

#feedbackModal {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 22px;
  background: rgba(4, 6, 8, 0.78);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  animation: fadeIn 0.25s ease;
}

.fbCard {
  width: 100%;
  max-width: 520px;
  max-height: 86vh;
  overflow-y: auto;
  padding: 28px 24px;
  border-radius: 20px;
  background: #101417;
  border: 1px solid rgba(245, 239, 228, 0.14);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6);
  text-align: center;
}

.fbIcon {
  width: 64px;
  height: 64px;
  margin: 0 auto 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-size: 30px;
  font-weight: 800;
  line-height: 1;
}
#feedbackModal.good .fbIcon { background: rgba(76, 175, 80, 0.2); color: #7fe08a; border: 2px solid rgba(76, 175, 80, 0.6); }
#feedbackModal.bad .fbIcon { background: rgba(226, 59, 31, 0.2); color: #ff8a6b; border: 2px solid rgba(226, 59, 31, 0.6); }

#fbTitle {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 30px;
  letter-spacing: 0.02em;
}
#feedbackModal.good #fbTitle { color: #7fe08a; }
#feedbackModal.bad #fbTitle { color: #ff8a6b; }

#fbText {
  margin-top: 12px;
  font-size: 15px;
  line-height: 1.7;
  color: var(--text-dim);
  text-align: justify;
  text-align-last: left;
  text-wrap: pretty;
}

#fbNextBtn, #csHomeBtn {
  margin-top: 22px;
  padding: 14px 26px;
  border: none;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--ember), #e23b1f);
  color: #ffffff;
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
}
#fbNextBtn:hover, #fbNextBtn:focus-visible, #csHomeBtn:hover, #csHomeBtn:focus-visible {
  filter: brightness(1.12);
  outline: none;
}

#comingSoonCtn {
  text-align: center;
}
#comingSoonCtn .csEmoji {
  display: block;
  font-size: 44px;
  margin-bottom: 8px;
}
#comingSoonCtn h2 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 30px;
  letter-spacing: 0.02em;
  color: #ffffff;
}
#comingSoonCtn p {
  margin-top: 10px;
  font-size: 15px;
  line-height: 1.7;
  color: var(--text-dim);
  text-align: justify;
  text-align-last: center;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@media (min-width: 720px) {
  #app { padding-top: 56px; }
  #modesCtn { grid-template-columns: repeat(3, 1fr); gap: 20px; }
  .modeCard .imgWrap { aspect-ratio: 16 / 9; }
  #gameBar { padding: 14px 28px; }
  .gamePanel { padding: 28px 30px 34px; }
}

/* ====== ÉCRAN DE RÉCOMPENSE ====== */

#rewardView {
  position: fixed;
  inset: 0;
  z-index: 9;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 22px;
  overflow-y: auto;
  background: radial-gradient(120% 100% at 50% 0%, #1c1b10 0%, #0c0d09 55%, #060705 100%);
  animation: fadeIn 0.4s ease;
}

.rewardCard {
  width: 100%;
  max-width: 540px;
  text-align: center;
  padding: 30px 24px 34px;
  border-radius: 22px;
  background: rgba(10, 11, 8, 0.85);
  border: 1px solid rgba(255, 215, 106, 0.3);
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.7), inset 0 0 60px rgba(255, 190, 60, 0.05);
}

.rewardMsg {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(26px, 6.5vw, 46px);
  line-height: 1.15;
  text-transform: uppercase;
  filter: drop-shadow(0 3px 12px rgba(255, 190, 60, 0.35));
}
.rewardMsgInner {
  display: block;
  background: linear-gradient(180deg, #fff8dc 0%, #ffd76a 40%, #e8a13a 70%, #b8771f 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.rewardBadgeFrame {
  width: 190px;
  height: 190px;
  margin: 22px auto 18px;
  border-radius: 50%;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 35% 30%, #33392b, #171a12 70%);
  border: 3px solid rgba(255, 215, 106, 0.6);
  box-shadow: 0 0 50px rgba(255, 190, 60, 0.3);
}

.rewardBadgeFrame img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.rewardBadgeName {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 30px;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  background: linear-gradient(180deg, #ffe9a8, #ffc145 60%, #e8962a);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

#rewardText {
  margin-top: 12px;
  font-size: 15px;
  line-height: 1.7;
  color: var(--text-dim);
  text-align: justify;
  text-align-last: center;
}

#rewardNextBtn {
  margin-top: 24px;
  padding: 16px clamp(16px, 4.5vw, 30px);
  border: none;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--ember), #e23b1f);
  color: #ffffff;
  font-family: inherit;
  font-size: clamp(12px, 3.4vw, 14px);
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  white-space: nowrap;
  max-width: 100%;
  cursor: pointer;
}
#rewardNextBtn:hover, #rewardNextBtn:focus-visible { filter: brightness(1.12); outline: none; }

@media (prefers-reduced-motion: reduce) {
  .modeCard, .modeCard img, #bg, #sceneBg, #feedbackModal, #rewardView, #finalView { transition: none; animation: none; }
}

/* ====== ÉCRAN FINAL (APOTHÉOSE) ====== */

#finalView {
  position: fixed;
  inset: 0;
  z-index: 9;
  overflow-y: auto;
  background: #07090b;
  animation: fadeIn 0.4s ease;
}

#finalBg {
  position: fixed;
  inset: 0;
  background-image: url(assets/final-bg.webp);
  background-size: cover;
  background-position: center;
  opacity: 0.5;
}

#finalView::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(to bottom, rgba(5, 7, 9, 0.35) 0%, rgba(5, 7, 9, 0.5) 55%, rgba(5, 7, 9, 0.85) 100%);
}

.finalCard {
  position: relative;
  z-index: 1;
  max-width: 660px;
  margin: 0 auto;
  padding: 34px 22px 44px;
  text-align: center;
}

.finalTitle {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(34px, 8.5vw, 62px);
  line-height: 1.05;
  text-transform: uppercase;
  filter: drop-shadow(0 4px 18px rgba(255, 190, 60, 0.4));
}

.finalTitleInner {
  display: block;
  background: linear-gradient(180deg, #fff8dc 0%, #ffd76a 40%, #e8a13a 70%, #b8771f 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.finalScore {
  margin-top: 20px;
  padding: 16px 20px 18px;
  border-radius: 16px;
  background: rgba(7, 9, 11, 0.62);
  border: 1px solid rgba(255, 215, 106, 0.35);
}

.finalScoreLabel {
  font-family: var(--font-display);
  font-size: 19px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.finalScoreValue {
  margin-top: 6px;
  font-family: var(--font-display);
  font-size: clamp(30px, 7vw, 44px);
  background: linear-gradient(180deg, #ffe9a8, #ffc145 60%, #e8962a);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.finalScoreMsg {
  margin-top: 8px;
  font-size: 15px;
  line-height: 1.6;
  color: var(--text);
}

.finalGrimoire {
  margin-top: 22px;
  text-align: left;
  padding: 24px 22px;
  border-radius: 18px;
  background: linear-gradient(180deg, #f6e9c4 0%, #ecdcae 55%, #e2d09c 100%);
  border: 2px solid #c9a95f;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.55), inset 0 0 0 3px rgba(255, 255, 255, 0.35);
  color: #4a3415;
}

.finalGrimoire h3 {
  text-align: center;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(22px, 5.5vw, 30px);
  letter-spacing: 0.05em;
  color: #5b3f16;
}

.grimoireIntro {
  text-align: center;
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin: 8px 0 16px;
  color: #7a5a26;
}

.rule {
  padding: 12px 0;
  border-top: 1px dashed rgba(90, 64, 20, 0.45);
}
.rule:first-of-type { border-top: none; }

.ruleTitle {
  display: block;
  font-weight: 700;
  font-size: 15px;
  color: #3f2d10;
}

.ruleText {
  display: block;
  margin-top: 4px;
  font-size: 13.5px;
  line-height: 1.6;
  color: #5a451f;
}

#finalHomeBtn {
  margin-top: 26px;
  padding: 16px clamp(18px, 5vw, 34px);
  border: none;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--ember), #e23b1f);
  color: #ffffff;
  font-family: inherit;
  font-size: clamp(12px, 3.4vw, 14px);
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  white-space: nowrap;
  cursor: pointer;
}
#finalHomeBtn:hover, #finalHomeBtn:focus-visible { filter: brightness(1.12); outline: none; }

