
/* La scène conserve son format 3:2 pour garder les zones de jeu alignées. */
body.play-mode .app {
  max-width: none;
  padding: clamp(4px, 1vw, 14px);
}
body.play-mode .title-card { min-width: 0; }
body.play-mode .scene-card,
body.play-mode .words-card { min-width: 0; }
body.play-mode .scene {
  width: 100%;
  max-height: none;
  touch-action: pan-y;
}
body.play-mode .words {
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  min-height: 0;
  overflow: visible;
}
body.play-mode .word {
  flex: 0 1 auto;
  min-width: 0;
  min-height: 44px;
  padding: 8px 12px;
  font-size: clamp(18px, 2.2vw, 28px);
}
body.play-mode.script-ecole-mode .word,
body.play-mode.dumont-mode .word {
  font-size: clamp(25px, 2.7vw, 35px) !important;
}
body.play-mode .bottom-actions {
  justify-content: space-between;
  gap: 6px;
  margin-top: 10px;
  padding-bottom: 0;
}
body.play-mode .reset-btn { padding-inline: 9px; }
body.play-mode .footer { margin-top: 8px; }

/* Sur un écran large, la hauteur disponible dimensionne la scène.
   Les mots et les commandes occupent la colonne voisine. */
@media (min-width: 980px), (min-width: 740px) and (orientation: landscape) {
  body.play-mode .header {
    flex-direction: row;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
  }
  body.play-mode .header-actions { width: auto; }
  body.play-mode .title-card { padding: 10px 14px; }
  body.play-mode .title-card h1 { font-size: clamp(19px, 2.5vw, 30px); }
  body.play-mode .layout {
    display: grid;
    grid-template-columns:
      minmax(0, min(calc(max(230px, 100dvh - 126px) * 1.5 + 16px), calc(100% - clamp(220px, 24vw, 390px) - 10px)))
      minmax(0, 1fr);
    align-items: start;
  }
  body.play-mode .words-card { padding: 12px; }
  body.play-mode .word {
    padding: 7px 9px;
    font-size: clamp(17px, min(1.55vw, 3.2dvh), 27px);
  }
  body.play-mode.script-ecole-mode .word,
  body.play-mode.dumont-mode .word {
    font-size: clamp(22px, min(2.05vw, 4dvh), 34px) !important;
  }
}

@media (min-width: 740px) and (orientation: landscape) and (max-height: 520px) {
  body.play-mode .words { gap: 6px; }
  body.play-mode .word { min-height: 38px; }
  body.play-mode .reset-btn,
  body.play-mode .prev-btn,
  body.play-mode .next-btn { min-height: 40px; }
}

@media (max-width: 640px) {
  body.play-mode .header { gap: 6px; margin-bottom: 6px; }
  body.play-mode .title-card { width: 100%; padding: 9px 12px; }
  body.play-mode .header-actions { gap: 4px; }
  body.play-mode .scene-nav { gap: 2px; padding: 2px; }
  body.play-mode .scene-link,
  body.play-mode .scene-nav button.scene-link,
  body.play-mode .home-link { padding: 8px 6px; font-size: 12px; }
  body.play-mode .gear { width: 40px; height: 40px; }
  body.play-mode .words-card { padding: 10px; }
}

/* Les anciens jeux plafonnent séparément la largeur de chaque panneau. */
body.play-mode .layout > .scene-card,
body.play-mode .layout > .words-card { max-width: none; margin: 0; }
body.play-mode .words > .word {
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
}
body.play-mode .words > .word .mot { flex: 0 0 auto; }
body.play-mode .layout:has(.scene.scene-3) { --scene-ratio: var(--third-scene-ratio, 1.5); }
body.play-mode .scene.scene-3 { width: 100% !important; }
.drawer { top: 12px; overflow-y: auto; }
.drawer .drawer-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 2;
  background: #fff;
}
.drawer .drawer-close {
  flex: none;
  border: 0;
  border-radius: 50%;
  background: #eaf1f8;
  color: #49657e;
  cursor: pointer;
}

@media (max-width: 380px) {
  body.play-mode .header-actions { flex-wrap: wrap; }
}

/* Grille de mots dimensionnée par la largeur réelle du panneau. */
body.play-mode .words-card {
  container-type: inline-size;
  display: flex;
  flex-direction: column;
}
body.play-mode .words-top { margin-bottom: 12px; }
body.play-mode .words-title,
body.play-mode .progress { font-size: clamp(14px, 1.2vw, 20px); }
body.play-mode .words {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-auto-rows: minmax(clamp(48px, calc(11cqw + 10px), 84px), 1fr);
  gap: clamp(6px, .8vw, 14px);
  flex: 1;
}
body.play-mode .words .word {
  --fit-letters: max(8, var(--word-letters, 10));
  --fit-width: calc((100cqw - clamp(6px, .8vw, 14px)) / 2 - 16px);
  align-self: center;
  width: 100%;
  height: 100%;
  min-height: 48px;
  max-height: clamp(70px, 10dvh, 115px);
  padding: 5px 6px;
  font-size: min(var(--word-font-limit, 100px), clamp(12px, calc(var(--fit-width) / (var(--fit-letters) * .72)), 64px));
}
body.play-mode .scene-card {
  position: sticky;
  top: 4px;
  z-index: 4;
  align-self: start;
  width: 100%;
}
body.play-mode.script-ecole-mode .words .word,
body.play-mode.dumont-mode .words .word {
  font-size: min(var(--word-font-limit, 100px), clamp(16px, calc(var(--fit-width) / (var(--fit-letters) * var(--script-ratio, .56))), 70px)) !important;
}
body.play-mode.script-ecole-mode .words { --script-ratio: .62; }

@media (min-width: 980px), (min-width: 740px) and (orientation: landscape) {
  body.play-mode .layout {
    grid-template-columns:
      minmax(0, min(calc(max(230px, 100dvh - 126px) * var(--scene-ratio, 1.5) + 16px), calc(100% - clamp(280px, 35vw, 740px) - 10px)))
      minmax(0, 1fr);
    align-items: stretch;
  }
  body.play-mode .words-card { padding: clamp(10px, 1vw, 20px); }
  body.play-mode .home-link,
  body.play-mode .scene-link,
  body.play-mode .scene-nav button.scene-link {
    display: inline-flex;
    align-items: center;
    min-height: 40px;
    font-size: clamp(14px, 1.15vw, 20px);
  }
}

@media (min-width: 740px) and (orientation: landscape) and (max-height: 520px) {
  body.play-mode .words { grid-auto-rows: minmax(38px, 1fr); gap: 5px; }
  body.play-mode .words .word {
    --fit-width: calc((100cqw - 5px) / 2 - 12px);
    min-height: 38px;
    padding: 3px 4px;
    font-size: min(var(--word-font-limit, 100px), clamp(12px, calc(var(--fit-width) / (var(--fit-letters) * .72)), 28px));
  }
  body.play-mode.script-ecole-mode .words .word,
  body.play-mode.dumont-mode .words .word {
    font-size: min(var(--word-font-limit, 100px), clamp(16px, calc(var(--fit-width) / (var(--fit-letters) * var(--script-ratio, .56))), 30px)) !important;
  }
}

/* Commandes et réglages de lecture plus faciles à lire et à toucher. */
body.play-mode .gear {
  width: clamp(46px, 4vw, 64px);
  height: clamp(46px, 4vw, 64px);
  font-size: clamp(24px, 2.2vw, 34px);
}
.drawer {
  width: min(720px, calc(100vw - 24px));
  max-height: calc(100dvh - 24px);
  padding: clamp(14px, 2vw, 28px);
  font-size: clamp(17px, 1.35vw, 23px);
}
.drawer h2 { font-size: clamp(25px, 2.1vw, 34px); }
.drawer .sub,
.drawer .audio-info,
.drawer .audio-status,
.drawer .setting .title,
.drawer .choice small { font-size: clamp(14px, 1.1vw, 18px); }
.drawer .drawer-close { width: 48px; height: 48px; font-size: 24px; }
.drawer .choice { min-height: 64px; padding: 12px 14px; }
.drawer .preview.fredoka { font-size: clamp(17px, 1.35vw, 23px); }
.drawer .preview.script,
.drawer .preview.dumont { font-size: clamp(32px, 2.6vw, 44px); }
.drawer input[type=checkbox],
.drawer input[type=radio] { width: 23px; height: 23px; flex-shrink: 0; }
.drawer .setting.row > label { max-width: none; }
@media (max-width: 640px) {
  .drawer {
    top: 8px;
    right: 8px;
    width: calc(100vw - 16px);
    max-height: calc(100dvh - 16px);
  }
}

/* Quand les cartes s'empilent, celle de la scène 1 sert d'illustration. */
@media (max-width: 860px) {
  .responsive-duplicate-image { display: none !important; }
}

/* Priorité sur les anciennes règles de taille minimale en cursive. */
body.play-mode .words > .word {
  min-width: 0 !important;
  max-width: 100% !important;
  padding-inline: 6px !important;
}
@media (min-width: 740px) and (orientation: landscape) and (max-height: 520px) {
  body.play-mode .words > .word { padding-inline: 4px !important; }
}

/* Les expressions composées conservent leurs espaces et peuvent revenir à la ligne. */
body.play-mode .words > .word[data-responsive-phrase] {
  display: block;
  align-content: center;
  white-space: nowrap;
}
@media (max-width: 460px) {
  body.play-mode .words:has(> [data-responsive-phrase]) {
    grid-auto-rows: minmax(48px, auto);
  }
  body.play-mode .words > .word[data-responsive-phrase] {
    --fit-letters: max(8, var(--word-longest-part));
    height: auto;
    max-height: none;
    white-space: normal;
  }
}
