/* Size toolbar groups by their contents, never by a squeezed middle column. */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  overflow-x: visible;
}

.toolbar .toolbar-group {
  flex: 0 1 auto;
  min-width: 0;
  max-width: 100%;
}

.toolbar .window-group {
  flex: 0 1 auto;
  margin-inline: auto;
}

.toolbar .toolbar-group-controls {
  flex-wrap: wrap;
}

.toolbar .toolbar-group-controls > button {
  flex-shrink: 0;
}

.toolbar .toolbar-group-title {
  white-space: normal;
}

/* Use the browser's visible height, including after tablet rotation. */
@media (min-width: 901px) {
  .game-shell,
  .viewer {
    height: 100dvh;
  }
}

/* A dialog belongs to the viewport, not the narrower image column. */
.interruption-modal {
  position: fixed;
  z-index: 40;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  min-width: 0;
  min-height: 0;
  padding: max(12px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
}

.interruption-modal .interruption-card {
  width: min(880px, 100%);
  min-width: 0;
  min-height: 0;
  max-height: 100%;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  grid-template-columns: minmax(0, 1fr);
  grid-auto-rows: max-content;
  overflow-wrap: anywhere;
}

.interruption-header {
  flex-wrap: wrap;
}

.interruption-choice-wrap > * {
  min-width: 0;
}

.interruption-reference {
  max-width: 100%;
}

/* Desktop keeps its existing alignment. Compact mode uses the viewer's width. */
.compact-window-presets {
  display: none;
}

.toolbar.toolbar-compact {
  gap: 6px;
  padding-inline: 8px;
  align-content: start;
}

.toolbar.toolbar-compact .toolbar-group {
  padding: 5px 6px 6px;
  gap: 4px;
}

.toolbar.toolbar-compact .window-group {
  margin-inline: 0;
}

.toolbar.toolbar-compact .toolbar-group-controls {
  gap: 6px;
}

.toolbar.toolbar-compact .toolbar-group-controls > button {
  min-width: 44px;
  min-height: 44px;
}

.toolbar.toolbar-compact .preset-group .window-presets {
  display: none;
}

.toolbar.toolbar-compact .compact-window-presets {
  display: block;
  box-sizing: border-box;
  width: 160px;
  max-width: 100%;
  min-height: 44px;
  padding: 8px 28px 8px 8px;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='m1 1 5 5 5-5' fill='none' stroke='%23eaf0f7' stroke-width='2'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 9px center;
  border: 1px solid var(--line);
  border-radius: 7px;
  background-color: #303742;
  color: var(--text, #eaf0f7);
  font: inherit;
  font-size: 16px;
  color-scheme: dark;
}

.compact-window-presets:focus-visible {
  outline: 2px solid var(--accent, #46b3ec);
  outline-offset: 2px;
}
