:root {
  --primary-dark: #1E3A8A;
  --card-bg: #FFFFFF;
}

body {
  margin: 0;
  padding: 15px;
  font-family: 'Nunito', sans-serif;
  background: linear-gradient(-45deg, #0F172A, #1E3A8A, #0284C7, #38BDF8, #4F46E5);
  background-size: 300% 300%;
  animation: fondBleuAnime 8s ease infinite;
  color: #111111;
  min-height: 100vh;
}

@keyframes fondBleuAnime {
  0%   { background-position: 0% 50%; }
  50%  { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

.container { max-width: 600px; margin: 0 auto; display: flex; flex-direction: column; gap: 20px; }

.header-container {
  text-align: center;
  position: relative;
  margin-top: 10px;
  margin-bottom: 25px;
}

.game-title {
  font-family: 'Lilita One', cursive;
  font-size: 54px;
  color: #FDE047;
  margin: 0;
  letter-spacing: 3px;
  text-shadow:
    -3px -3px 0 #111,
     3px -3px 0 #111,
    -3px  3px 0 #111,
     3px  3px 0 #111,
     0px  8px 0 #111;
  position: relative;
  z-index: 1;
}

.niveau-select-box {
  background: var(--card-bg);
  border-radius: 20px;
  padding: 20px;
  text-align: center;
  border: 4px solid #111111;
  box-shadow: 0 8px 0 #111111;
}

.niveau-select-box label {
  display: block;
  margin-bottom: 12px;
  font-family: 'Lilita One', cursive;
  color: #3B82F6;
  font-size: 26px;
  text-transform: uppercase;
  letter-spacing: 1px;
  text-shadow: 1px 1px 0px #BFDBFE;
}

select {
  width: 100%; padding: 16px; font-size: 22px; font-weight: 900;
  border: 4px solid #111111; border-radius: 12px;
  font-family: 'Nunito', sans-serif; color: #111111;
  outline: none; background: #F8FAFC;
  cursor: pointer;
  box-shadow: inset 0 4px 0 rgba(0,0,0,0.05);
  transition: all 0.2s;
}
select:focus { border-color: #3B82F6; background: #FFF; }

#menu-modules { display: flex; flex-direction: column; gap: 15px; }

.module-btn {
  background: linear-gradient(180deg, #60A5FA 0%, #2563EB 100%);
  border: 4px solid #111111;
  border-radius: 16px;
  padding: 20px 25px;
  font-size: 20px;
  font-weight: 900;
  color: #FFFFFF;
  cursor: pointer;
  box-shadow: 0 8px 0 #111111, 0 15px 20px rgba(0,0,0,0.3);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  display: none;
  text-align: left;
  text-shadow: 2px 2px 0px #1E3A8A;
  text-transform: uppercase;
}

.module-btn:hover {
  transform: scale(1.02);
}

.module-btn:active {
  transform: scale(1) translateY(8px);
  box-shadow: 0 0px 0 #111111, 0 5px 10px rgba(0,0,0,0.3);
}

@keyframes wiggle {
  0%, 100% { transform: rotate(0deg); }
  25% { transform: rotate(-15deg); }
  75% { transform: rotate(15deg); }
}

.module-btn:hover::first-letter {
  display: inline-block;
  animation: wiggle 0.4s ease-in-out infinite;
}

.msg-vide {
  text-align: center; font-weight: 900; color: #1E3A8A; padding: 30px;
  background: #DBEAFE; border-radius: 20px;
  border: 4px dashed #60A5FA;
  font-size: 18px;
}

#prof-panel {
  background: #0F172A; color: white; padding: 20px; border-radius: 20px;
  display: none; margin-bottom: 20px; overflow-x: auto;
  border: 4px solid #38BDF8;
  box-shadow: 0 8px 0 #082F49;
}
.prof-title { font-family: 'Lilita One', cursive; color: #38BDF8; margin-top: 0; margin-bottom: 15px; text-align: center; font-size: 24px; letter-spacing: 1px; }
.section-box { background: #1E293B; border-radius: 12px; padding: 15px; margin-bottom: 15px; border: 2px solid #334155; }
.section-header { display: flex; justify-content: space-between; align-items: center; cursor: pointer; }
.section-title { font-weight: 900; color: #94A3B8; font-size: 14px; text-transform: uppercase; margin: 0; }
.btn-toggle-section { background: transparent; border: none; color: #38BDF8; font-weight: bold; cursor: pointer; font-size: 14px; }
table { width: 100%; border-collapse: collapse; margin-top: 15px; min-width: 500px; }
th, td { padding: 10px 6px; text-align: center; border-bottom: 1px solid #334155; font-size: 13px; }
th { color: #38BDF8; font-weight: 900; }
.td-module { text-align: left; font-weight: 800; color: #F1F5F9; width: 220px; }

.switch { position: relative; display: inline-block; width: 44px; height: 24px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background-color: #475569; transition: .3s; border-radius: 24px; }
.slider:before { position: absolute; content: ""; height: 18px; width: 18px; left: 3px; bottom: 3px; background-color: white; transition: .3s; border-radius: 50%; box-shadow: 0 2px 4px rgba(0,0,0,0.3); }
input:checked + .slider { background-color: #10B981; }
input:checked + .slider:before { transform: translateX(20px); }

.btn-fermer-tout {
  background: rgba(239, 68, 68, 0.2); color: #FCA5A5; border: 1px solid rgba(239, 68, 68, 0.4);
  padding: 6px 10px; border-radius: 8px; font-size: 11px; font-weight: bold; cursor: pointer;
  margin-top: 6px; width: 100%; text-transform: uppercase;
}
.btn-fermer-tout:hover { background: rgba(239, 68, 68, 0.4); color: white; }

#app-container { display: none; max-width: 540px; margin: 0 auto; text-align: center; }

.stats-bar { display: flex; justify-content: space-between; font-family: 'Lilita One', cursive; color: #FFFFFF; margin-bottom: 12px; font-size: 20px; text-shadow: 2px 2px 0px #111111; letter-spacing: 1px; }

.question-box {
  background: #FFFFFF;
  border-radius: 24px;
  padding: 30px 25px;
  box-shadow: 0 8px 0 #111111;
  margin-bottom: 25px;
  border: 4px solid #111111;
  text-align: center;
}

#enonce { font-size: 28px; font-weight: 900; margin-bottom: 25px; color: #111111; }

input[type="text"], input[type="number"] {
  width: 100%; box-sizing: border-box; padding: 18px; font-size: 26px;
  text-align: center; border: 4px solid #111111; border-radius: 16px;
  font-family: 'Nunito', sans-serif; font-weight: 900; outline: none;
  background: #F8FAFC; color: #111111;
  box-shadow: inset 0 4px 0 rgba(0,0,0,0.05);
}
input:focus { border-color: #3B82F6; background: #FFF; }
input:disabled { background-color: #E2E8F0; color: #64748B; border-color: #94A3B8; }

.btn-valider, .btn-suivant {
  width: 100%; border: 4px solid #111111;
  padding: 18px; font-size: 24px; font-weight: 900; border-radius: 16px;
  margin-top: 20px; cursor: pointer; transition: transform 0.1s, box-shadow 0.1s;
  text-transform: uppercase;
  letter-spacing: 1px;
  font-family: 'Lilita One', cursive;
}
.btn-valider {
  background: linear-gradient(180deg, #FDE047 0%, #F59E0B 100%);
  box-shadow: 0 8px 0 #111111;
  color: #111111;
}
.btn-valider:active { transform: translateY(8px); box-shadow: 0 0px 0 #111111; }

.btn-suivant {
  background: linear-gradient(180deg, #6EE7B7 0%, #10B981 100%);
  box-shadow: 0 8px 0 #111111;
  color: #111111;
  display: none;
}
.btn-suivant:active { transform: translateY(8px); box-shadow: 0 0px 0 #111111; }

.btn-retour {
  background: #FFFFFF; color: #111111; border: 4px solid #111111; font-size: 16px;
  font-weight: 900; cursor: pointer; margin-top: 15px; padding: 12px 20px;
  border-radius: 16px; box-shadow: 0 6px 0 #111111;
  transition: transform 0.1s, box-shadow 0.1s;
  text-transform: uppercase;
}
.btn-retour:active { transform: translateY(6px); box-shadow: 0 0px 0 #111111; }

#feedback { font-size: 18px; font-weight: 900; margin-top: 20px; min-height: 30px; line-height: 1.5; text-align: left; }
.correct { color: #10B981; text-align: center !important; font-size: 24px; }
.incorrect { color: #EF4444; }

.resultat-box {
  background: white; border-radius: 24px; padding: 35px 25px; text-align: center;
  box-shadow: 0 8px 0 #111111;
  border: 4px solid #111111;
}
.score-final { font-family: 'Lilita One', cursive; font-size: 72px; color: #3B82F6; margin: 15px 0; text-shadow: 3px 3px 0px #111111; }
.comp-badge { display: inline-block; padding: 12px 26px; border-radius: 16px; border: 4px solid #111111; font-size: 26px; font-weight: 900; color: white; margin-bottom: 20px; box-shadow: 0 6px 0 #111111; }

/* --- BOUTONS QCM GEOMETRIE --- */
.btn-qcm-v2 {
  width: 100%;
  padding: 16px 20px;
  font-size: 26px;
  font-family: 'Lilita One', cursive;
  border: 4px solid #111111 !important;
  border-radius: 20px !important;
  background: #F0FDFA !important;
  color: #0F766E !important;
  cursor: pointer;
  transition: transform 0.1s, box-shadow 0.1s, background 0.1s, color 0.1s;
  text-align: center;
  margin-bottom: 12px;
  box-shadow: 0 6px 0 #111111 !important;
  letter-spacing: 1px;
  display: block;
}
.btn-qcm-v2:hover:not(:disabled) {
  background: #CCFBF1 !important;
  color: #111111 !important;
  transform: translateY(-2px);
  box-shadow: 0 8px 0 #111111 !important;
}
.btn-qcm-v2:active:not(:disabled) {
  transform: translateY(6px);
  box-shadow: 0 0px 0 #111111 !important;
}
.btn-qcm-v2:disabled {
  cursor: default;
  opacity: 0.95;
}
.rep-vrai {
  background: #10B981 !important;
  color: white !important;
  box-shadow: 0 6px 0 #065F46 !important;
  border-color: #065F46 !important;
}
.rep-fausse {
  background: #EF4444 !important;
  color: white !important;
  box-shadow: 0 6px 0 #7F1D1D !important;
  border-color: #7F1D1D !important;
}

/* ============================================================
   ACCUEIL : BANDEAU COMPACT & GRILLES PORTRAIT / PAYSAGE
   ============================================================ */
.top-bar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
  width: 100%;
  box-sizing: border-box;
}

.top-bar-left {
  display: flex;
  justify-content: flex-start;
}

.top-bar-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin: 0;
}

.top-bar-right {
  display: flex;
  justify-content: flex-end;
}

.select-compact {
  padding: 8px 10px;
  font-size: 15px;
  font-weight: 900;
  font-family: 'Nunito', sans-serif;
  border: 3px solid #111;
  border-radius: 10px;
  background: #FFFFFF;
  color: #1E3A8A;
  box-shadow: 0 4px 0 #111;
  cursor: pointer;
  outline: none;
  max-width: 115px;
}

.btn-classements-compact {
  background: linear-gradient(135deg, #FBBF24 0%, #D97706 100%);
  color: #111;
  border: 3px solid #111;
  border-radius: 10px;
  box-shadow: 0 4px 0 #92400E;
  padding: 8px 12px;
  font-size: 15px;
  font-weight: 900;
  font-family: 'Nunito', sans-serif;
  cursor: pointer;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 5px;
}

.btn-classements-compact .txt-classement {
  display: none;
}

.top-bar-center .game-title {
  font-size: 26px;
  margin: 0;
  line-height: 1;
}

.top-bar-center svg {
  width: 78px;
  height: 52px;
  margin-bottom: -6px;
}

.grille-une,
.grille-modules {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  width: 100%;
}

.grille-une .module-btn,
.grille-modules .module-btn {
  margin: 0 !important;
  width: 100%;
  box-sizing: border-box;
  min-height: 52px;
  display: flex !important;
  align-items: center;
  justify-content: center;
  text-align: center;
  line-height: 1.25;
}

/* --- MODE PAYSAGE / TABLETTE / PC --- */
@media (orientation: landscape) and (min-width: 560px), (min-width: 700px) {
  body.page-accueil .container {
    max-width: 900px;
  }

  .btn-classements-compact .txt-classement {
    display: inline;
  }

  .select-compact {
    max-width: 150px;
    font-size: 16px;
    padding: 9px 14px;
  }

  .top-bar-center {
    flex-direction: row;
    gap: 10px;
  }

  .top-bar-center svg {
    width: 64px;
    height: 44px;
    margin-bottom: 0;
  }

  .top-bar-center .game-title {
    font-size: 30px;
  }

  .grille-une,
  .grille-modules {
    grid-template-columns: repeat(2, 1fr);
  }

  #zone-recherche {
    max-width: 460px;
    margin: 14px auto 16px auto !important;
  }
}

/* --- GRAND ÉCRAN / TABLETTE PAYSAGE LARGE --- */
@media (min-width: 860px) {
  .grille-modules {
    grid-template-columns: repeat(3, 1fr);
  }
}
/* --- BOUTONS SPÉCIAL BREVET (ORANGE) --- */
.module-btn.module-brevet {
  background: linear-gradient(180deg, #F59E0B 0%, #D97706 100%);
  text-shadow: 2px 2px 0px #78350F;
}