/* Bouton Accueil partag   inclure dans les pages ateliers */
@import url('https://fonts.googleapis.com/css2?family=Fredoka:wght@600&display=swap');

.kids-home-link {
  position: fixed;
  top: 1rem;
  left: 1rem;
  z-index: 200;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  min-height: 3rem;
  padding: 0.55rem 1.1rem;
  border: 3px solid #c4b5fd;
  border-radius: 999px;
  background: #fff;
  color: #6d28d9;
  font-family: 'Fredoka', system-ui, sans-serif;
  font-size: 1rem;
  font-weight: 600;
  text-decoration: none;
  box-shadow: 0 4px 0 #a78bfa, 0 8px 20px rgba(109, 40, 217, 0.15);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.kids-home-link:hover,
.kids-home-link:focus-visible {
  transform: translateY(-2px);
  box-shadow: 0 6px 0 #a78bfa, 0 12px 24px rgba(109, 40, 217, 0.2);
  outline: none;
}

.kids-home-link:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 #a78bfa;
}

/* Barre haut droite  Aide + numro du jeu */
.kids-top-bar {
  position: fixed;
  top: 1rem;
  right: 1rem;
  left: auto;
  z-index: 5100;
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.kids-aide-btn {
  min-height: 2.75rem;
  padding: 0.45rem 0.95rem;
  border: 3px solid;
  border-radius: 999px;
  background: #fff;
  font-family: 'Fredoka', system-ui, sans-serif;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 0 rgba(15, 23, 42, 0.15), 0 8px 20px rgba(15, 23, 42, 0.1);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.kids-top-bar--fr .kids-aide-btn {
  color: #6d28d9;
  border-color: #c4b5fd;
  box-shadow: 0 4px 0 #a78bfa, 0 8px 20px rgba(109, 40, 217, 0.12);
}

.kids-top-bar--math .kids-aide-btn {
  color: #d97706;
  border-color: #fdba74;
  box-shadow: 0 4px 0 #fb923c, 0 8px 20px rgba(217, 119, 6, 0.12);
}

.kids-top-bar--sci .kids-aide-btn {
  color: #059669;
  border-color: #6ee7b7;
  box-shadow: 0 4px 0 #34d399, 0 8px 20px rgba(5, 150, 105, 0.12);
}

.kids-aide-btn:hover,
.kids-aide-btn:focus-visible {
  transform: translateY(-2px);
  outline: none;
}

.kids-aide-btn:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 rgba(15, 23, 42, 0.15);
}

/* Numero du jeu  coin haut droit (fallback avant barre Aide) */
.kids-game-num.kids-game-num--page {
  position: fixed;
  top: 1rem;
  right: 1rem;
  left: auto;
  z-index: 300;
  min-width: 2.75rem;
  height: 2.75rem;
  padding: 0 0.6rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  font-family: 'Fredoka', system-ui, sans-serif;
  font-weight: 700;
  font-size: 1.15rem;
  line-height: 1;
  border: 3px solid;
  box-shadow: 0 4px 0 rgba(15, 23, 42, 0.15), 0 8px 24px rgba(15, 23, 42, 0.12);
  pointer-events: none;
}

.kids-top-bar .kids-game-num.kids-game-num--page {
  position: static;
  top: auto;
  right: auto;
  left: auto;
  z-index: auto;
}

.kids-game-num--page.kids-game-num--fr {
  background: #f3e8ff;
  color: #6d28d9;
  border-color: #c4b5fd;
  box-shadow: 0 4px 0 #a78bfa, 0 8px 20px rgba(109, 40, 217, 0.12);
}

.kids-game-num--page.kids-game-num--math {
  background: #fff7ed;
  color: #d97706;
  border-color: #fdba74;
  box-shadow: 0 4px 0 #fb923c, 0 8px 20px rgba(217, 119, 6, 0.12);
}

.kids-game-num--page.kids-game-num--sci {
  background: #ecfdf5;
  color: #059669;
  border-color: #6ee7b7;
  box-shadow: 0 4px 0 #34d399, 0 8px 20px rgba(5, 150, 105, 0.12);
}

@media (prefers-reduced-motion: reduce) {
  .kids-home-link { transition: none; }
}

/* ??? Tablette Apple (iPad)  mode paysage ??? */
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  -webkit-overflow-scrolling: touch;
}

@media (orientation: landscape) and (max-height: 820px) {
  body {
    overflow-x: auto;
    overflow-y: auto;
  }

  body:has(> .kids-home-link):not(:has(.wrap)) {
    padding-top: max(3rem, calc(env(safe-area-inset-top, 0px) + 2.75rem));
    padding-left: max(0.5rem, env(safe-area-inset-left, 0px));
    padding-right: max(0.5rem, env(safe-area-inset-right, 0px));
  }

  .wrap,
  main.wrap {
    padding-top: max(3rem, calc(env(safe-area-inset-top, 0px) + 2.5rem)) !important;
    padding-left: max(0.75rem, env(safe-area-inset-left, 0px)) !important;
    padding-right: max(0.75rem, env(safe-area-inset-right, 0px)) !important;
    padding-bottom: max(0.75rem, env(safe-area-inset-bottom, 0px)) !important;
  }

  .kids-home-link {
    top: max(0.4rem, env(safe-area-inset-top, 0px));
    left: max(0.4rem, env(safe-area-inset-left, 0px));
    min-height: 2.5rem;
    padding: 0.35rem 0.75rem;
    font-size: 0.85rem;
  }

  .kids-top-bar {
    top: max(0.4rem, env(safe-area-inset-top, 0px));
    right: max(0.4rem, env(safe-area-inset-right, 0px));
  }

  .kids-aide-btn {
    min-height: 2.15rem;
    padding: 0.3rem 0.65rem;
    font-size: 0.8rem;
  }

  .kids-game-num.kids-game-num--page,
  .kids-top-bar .kids-game-num.kids-game-num--page {
    min-width: 2.15rem;
    height: 2.15rem;
    font-size: 0.9rem;
  }

  h1 {
    font-size: clamp(1.15rem, 3vw, 1.6rem) !important;
  }

  .lead {
    font-size: 0.85rem !important;
    margin-bottom: 0.35rem !important;
  }

  .mode-bar {
    margin: 0.5rem 0 !important;
    gap: 0.35rem !important;
  }

  .mode-btn,
  .tab {
    min-height: 2.35rem !important;
    padding: 0.3rem 0.65rem !important;
    font-size: 0.78rem !important;
  }

  .chips {
    margin: 0.4rem 0 0.65rem !important;
  }

  .chip {
    padding: 0.35rem 0.7rem !important;
    font-size: 0.85rem !important;
  }

  .card,
  .game-card {
    padding: 0.85rem !important;
  }

  .scene {
    font-size: 2.2rem !important;
    margin: 0.25rem 0 !important;
  }

  .choice,
  .pool-item,
  .btn {
    min-height: 2.75rem;
  }

  .grid {
    grid-template-columns: repeat(5, minmax(2.2rem, 2.5rem)) !important;
    grid-template-rows: repeat(5, minmax(2.2rem, 2.5rem)) !important;
  }

  .cell {
    font-size: 1.35rem !important;
  }

  .mode-group {
    margin: 0.4rem 0 0.2rem !important;
  }

  .mode-group-label {
    font-size: 0.68rem !important;
    margin-bottom: 0.25rem !important;
  }

  .equation {
    font-size: clamp(1.5rem, 5vw, 2rem) !important;
    margin: 0.15rem 0 0.5rem !important;
  }

  .visual {
    min-height: 3rem !important;
    margin: 0.35rem 0 !important;
  }

  .chain-zone,
  .hand-zone {
    min-height: 4rem !important;
    padding: 0.5rem !important;
  }

  .tile {
    width: 6.5rem !important;
    height: 3.2rem !important;
  }

  .tile .half {
    font-size: 1.5rem !important;
  }

  .bins {
    grid-template-columns: 1fr 1fr !important;
  }

  #game-container {
    flex-direction: row !important;
    flex-wrap: wrap !important;
    justify-content: center !important;
    gap: 0.75rem !important;
  }

  #board {
    grid-template-columns: repeat(4, 56px) !important;
    grid-template-rows: repeat(5, 56px) !important;
  }

  #board .cell {
    width: 56px !important;
    height: 56px !important;
    font-size: 1.25rem !important;
  }
}

/* Dizaines (rouge) / Units (bleu) */
.du-d, .du-dizaine { color: #dc2626 !important; font-weight: 800; }
.du-u, .du-unite { color: #2563eb !important; font-weight: 800; }
.du-c { color: #64748b; font-weight: 800; }

/* Consigne  bien visible sur tous les ateliers */
.prompt,
#prompt,
#modePrompt,
.consigne,
[data-mb-prompt],
.instruction,
.task-prompt {
  display: block !important;
  width: 100% !important;
  box-sizing: border-box !important;
  margin: 0 0 1rem !important;
  padding: 0.85rem 1.1rem !important;
  text-align: center !important;
  font-family: "Fredoka", system-ui, sans-serif !important;
  font-size: clamp(1.15rem, 2.6vw, 1.55rem) !important;
  font-weight: 700 !important;
  line-height: 1.35 !important;
  color: #4c1d95 !important;
  background: linear-gradient(180deg, #f5f3ff 0%, #ede9fe 100%) !important;
  border: 3px solid #a78bfa !important;
  border-radius: 1rem !important;
  box-shadow:
    0 4px 0 #8b5cf6,
    0 10px 22px rgba(109, 40, 217, 0.14) !important;
  letter-spacing: 0.01em;
}

.prompt:empty,
#prompt:empty,
#modePrompt:empty {
  display: none !important;
  padding: 0 !important;
  margin: 0 !important;
  border: none !important;
  box-shadow: none !important;
}

/* Modale aide guide */
body.mb-aide-open {
  overflow: hidden;
}

.mb-aide {
  position: fixed;
  inset: 0;
  z-index: 5500;
  display: grid;
  place-items: center;
  padding: 1rem;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(4px);
  font-family: 'Nunito', system-ui, sans-serif;
}

.mb-aide[hidden] {
  display: none !important;
}

.mb-aide-card {
  width: min(480px, 100%);
  max-height: min(90vh, 640px);
  overflow: auto;
  background: #fff;
  border-radius: 1.4rem;
  padding: 1.2rem 1.15rem 1rem;
  border: 3px solid #c4b5fd;
  box-shadow: 0 16px 40px rgba(109, 40, 217, 0.18);
}

.mb-aide-card--math {
  border-color: #fdba74;
  box-shadow: 0 16px 40px rgba(217, 119, 6, 0.15);
}

.mb-aide-card--sci {
  border-color: #6ee7b7;
  box-shadow: 0 16px 40px rgba(5, 150, 105, 0.15);
}

.mb-aide-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.65rem;
}

.mb-aide-head h2 {
  margin: 0;
  font-family: 'Fredoka', system-ui, sans-serif;
  font-size: 1.25rem;
  color: #5b21b6;
}

.mb-aide-card--math .mb-aide-head h2 { color: #b45309; }
.mb-aide-card--sci .mb-aide-head h2 { color: #047857; }

.mb-aide-close {
  width: 2.25rem;
  height: 2.25rem;
  border: 2px solid #e2e8f0;
  border-radius: 999px;
  background: #f8fafc;
  font-size: 1.35rem;
  line-height: 1;
  cursor: pointer;
  color: #64748b;
}

.mb-aide-close:hover,
.mb-aide-close:focus-visible {
  border-color: #c4b5fd;
  background: #f5f3ff;
  outline: none;
}

.mb-aide-steps {
  display: flex;
  justify-content: center;
  gap: 0.45rem;
  margin-bottom: 0.85rem;
}

.mb-aide-dot {
  width: 0.65rem;
  height: 0.65rem;
  border-radius: 999px;
  background: #e2e8f0;
}

.mb-aide-dot.is-active {
  background: #8b5cf6;
  transform: scale(1.25);
}

.mb-aide-card--math .mb-aide-dot.is-active { background: #fb923c; }
.mb-aide-card--sci .mb-aide-dot.is-active { background: #34d399; }

.mb-aide-dot.is-done {
  background: #c4b5fd;
}

.mb-aide-label {
  margin: 0 0 0.55rem;
  font-family: 'Fredoka', system-ui, sans-serif;
  font-size: 0.95rem;
  font-weight: 700;
  color: #64748b;
}

.mb-aide-sub {
  margin: 0.65rem 0 0.35rem;
  font-size: 0.85rem;
  font-weight: 800;
  color: #94a3b8;
}

.mb-aide-panel {
  padding: 0.85rem 1rem;
  border-radius: 0.95rem;
  font-weight: 700;
  line-height: 1.45;
  text-align: center;
}

.mb-aide-panel--consigne,
.mb-aide-panel--question {
  background: linear-gradient(180deg, #f5f3ff 0%, #ede9fe 100%);
  border: 2px solid #c4b5fd;
  color: #4c1d95;
  font-size: clamp(1rem, 2.5vw, 1.2rem);
}

.mb-aide-panel--exercise {
  background: #fffbeb;
  border: 2px dashed #fcd34d;
  color: #78350f;
  font-size: clamp(1.05rem, 2.8vw, 1.35rem);
  font-family: 'Fredoka', system-ui, sans-serif;
}

.mb-aide-panel--exercise.mb-aide-panel--sticky {
  margin-bottom: 0.75rem;
}

.mb-aide-panel--info {
  background: #f0fdf4;
  border: 2px solid #86efac;
  color: #166534;
}

.mb-aide-tip {
  margin: 0.65rem 0 0;
  text-align: center;
  font-size: 0.85rem;
  font-weight: 700;
  color: #94a3b8;
}

.mb-aide-choices {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.mb-aide-choice {
  min-height: 2.85rem;
  min-width: 4.5rem;
  padding: 0.45rem 0.85rem;
  border: 3px solid #c4b5fd;
  border-radius: 0.75rem;
  background: #fff;
  font-family: 'Fredoka', system-ui, sans-serif;
  font-size: 1.05rem;
  font-weight: 600;
  color: #5b21b6;
  cursor: pointer;
  box-shadow: 0 3px 0 #a78bfa;
}

.mb-aide-card--math .mb-aide-choice {
  border-color: #fdba74;
  color: #b45309;
  box-shadow: 0 3px 0 #fb923c;
}

.mb-aide-card--sci .mb-aide-choice {
  border-color: #6ee7b7;
  color: #047857;
  box-shadow: 0 3px 0 #34d399;
}

.mb-aide-choice.is-picked,
.mb-aide-choice:hover,
.mb-aide-choice:focus-visible {
  background: #ede9fe;
  outline: none;
}

.mb-aide-card--math .mb-aide-choice.is-picked,
.mb-aide-card--math .mb-aide-choice:hover { background: #ffedd5; }

.mb-aide-card--sci .mb-aide-choice.is-picked,
.mb-aide-card--sci .mb-aide-choice:hover { background: #ecfdf5; }

.mb-aide-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.45rem;
  margin-top: 1rem;
}

.mb-aide-btn {
  min-height: 2.75rem;
  padding: 0.5rem 1rem;
  border: none;
  border-radius: 0.85rem;
  font-family: 'Fredoka', system-ui, sans-serif;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
}

.mb-aide-btn--primary {
  background: #7c3aed;
  color: #fff;
  box-shadow: 0 4px 0 #5b21b6;
}

.mb-aide-card--math .mb-aide-btn--primary {
  background: #ea580c;
  box-shadow: 0 4px 0 #c2410c;
}

.mb-aide-card--sci .mb-aide-btn--primary {
  background: #059669;
  box-shadow: 0 4px 0 #047857;
}

.mb-aide-btn--ghost {
  background: #fff;
  color: #64748b;
  border: 2px solid #e2e8f0;
}

.mb-aide-btn--listen {
  background: #f5f3ff;
  color: #6d28d9;
  border: 2px solid #c4b5fd;
}

.mb-aide-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

@media (prefers-reduced-motion: reduce) {
  .kids-aide-btn,
  .mb-aide-dot.is-active { transition: none; transform: none; }
}

