html,body { min-height: 100vh; }
dialog:not([open]) { display: none; }
.legacy-dialog[open] {
  display: block;
  position: fixed;
  z-index: 100;
  top: 16px;
  bottom: 16px;
  left: 16px;
  right: 16px;
  width: calc(100% - 32px);
  margin: 0 auto;
  overflow: auto;
  max-height: calc(100vh - 32px);
}
.legacy-modal-open::before {
  content: '';
  position: fixed;
  inset: 0;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,.5);
  z-index: 99;
}
.legacy-modal-open { overflow: hidden; }
.setup-message { color: #666; margin-top: 16px; font-size: 14px; }

/* Margins provide spacing for Safari versions without flex gap. */
.sentence-actions { gap: 0; }
.sentence-actions button + button { margin-left: 4px; }
.speak-sentence { gap: 0; }
.speak-sentence > span + span { margin-left: 6px; }
.sentence-tiles { gap: 0; }
.sentence-token + .sentence-token { margin-left: 8px; }
.classic-tile { gap: 0; }
.classic-tile > strong { margin-top: 4px; }
.tool-buttons { gap: 0; }
.tool-buttons > * { margin: 0 9px 9px 0; }
.primary,.secondary { gap: 0; }
.primary > span + span,.secondary > span + span { margin-left: 8px; }
.classic-page-controls { gap: 0; }
.classic-page-controls > * + * { margin-left: 10px; }
#previous-page > [data-icon] { margin-right: 8px; }
#next-page > [data-icon] { margin-left: 8px; }

/* The iPad board opens with every visible choice in a compact, responsive grid. */
#tiles:not(.few-choices) {
  grid-template-columns: repeat(auto-fit, minmax(108px, 1fr));
}
#tiles:not(.few-choices) .classic-tile {
  justify-content: center;
  min-height: 96px;
  padding: 8px 6px 6px;
}
#tiles:not(.few-choices) .folder-tile {
  padding-top: calc(8px + var(--tab-height));
}
#tiles:not(.few-choices) .classic-tile strong {
  font-size: 16px;
}
#tiles:not(.few-choices) .choice-picture {
  height: 54px;
}
@media (min-width: 740px) {
  #tiles:not(.few-choices) { grid-template-columns: repeat(auto-fit, minmax(135px, 1fr)); }
  #tiles:not(.few-choices) .classic-tile { min-height: 104px; }
  #tiles:not(.few-choices) .choice-picture { height: 58px; }
}
