/* Keep text readable as the layout moves from one column to two. */
:root {
  --type-body: clamp(1rem, .96rem + .18vw, 1.125rem);
  --type-label: clamp(.8125rem, .78rem + .15vw, .9375rem);
  --type-heading: clamp(1.25rem, 1.08rem + .75vw, 1.75rem);
  --page-gutter: clamp(.625rem, 2vw, 1.5rem);
}

body { font-size: var(--type-body); line-height: 1.5; }
.hud { padding-inline: var(--page-gutter); }
.hud .logo { font-size: var(--type-heading); white-space: normal; }
.hud .logo small, .hud .hint, .stat, .mode-btn, .tab, .layer-tab { font-size: var(--type-label); }
.layout {
  grid-template-columns: minmax(0, 1fr);
  padding-inline: var(--page-gutter);
}
.panel { min-inline-size: 0; }
.tab { white-space: normal; }
.tab-body, .layer-body, .account-dialog { overflow-wrap: anywhere; }
.info-card p, .post-card p, .bottle-form label, .account-form label,
.schedule-form :is(input, select), .post-form :is(input, select, textarea),
.question-form input, .search-row input, .scene-name-field input {
  font-size: 1rem;
}
.feature-help, .course-card, .info-card b, .post-card h4 { font-size: var(--type-label); }
.welcome h1 { font-size: clamp(1.625rem, 1rem + 3vw, 3rem); }

.modal, .stage-card, .bottle-dialog {
  min-inline-size: 0;
  max-inline-size: min(100%, calc(100vw - 2 * var(--page-gutter)));
  max-block-size: calc(100dvh - 2 * var(--page-gutter));
}
.modal-mask, .stage-mask { padding: var(--page-gutter); }
.modal-head :is(.m-ic, .modal-close) { flex-shrink: 0; }
.layer-tabs { flex-wrap: wrap; }
.scene-form, .scene-form input, .schedule-form input { min-inline-size: 0; max-inline-size: 100%; }
.bottle-form { grid-template-columns: minmax(0, 1fr); }
.bottle-heading h2, .bottle-dialog h2 { font-size: var(--type-heading); line-height: 1.25; }

.account-banner { display: flex; align-items: center; justify-content: space-between; gap: .75rem; }
.account-avatar-edit { display: grid; place-items: center; inline-size: 2.5rem; block-size: 2.5rem; flex: none; }
.account-optional { padding: .5rem .65rem; border: 1px solid #c8aa82; border-radius: .375rem; }
.account-optional summary { color: #35552b; cursor: pointer; font-weight: 700; }
.account-optional label { margin-top: .65rem; }

@media (max-width: 39rem) {
  .hud { display: grid; grid-template-columns: minmax(0, 1fr); gap: .5rem; }
  .hud .stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .5rem; order: 2; }
  .hud .stats .stat:first-child { grid-column: 1 / -1; }
  .hud :is(.xp-wrap, .progress-wrap) { min-width: 0; }
  .hud .mode-switch { order: 1; margin: 0; width: 100%; justify-content: stretch; }
  .hud .mode-btn { flex: 1; }
  .hud-tools { order: 3; width: 100%; margin: 0; flex-wrap: wrap; }
  #accountEntry { margin: 0; }
  .hud .hint { order: 4; margin: 0; }
  .forum-category { flex-wrap: wrap; }
  .layer-tabs { gap: 4px; padding-inline: .5rem; }
  .layer-tab { flex: 1; min-width: 0; padding-inline: .25rem; }
}

@media (min-width: 36rem) {
  .bottle-form { grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); }
}

@media (min-width: 58rem) {
  .layout { grid-template-columns: minmax(0, 1fr) minmax(21rem, .53fr); }
}

@media (pointer: coarse) {
  :is(.welcome-actions, .account-dialog, .mode-switch, .bottle-panel) button,
  .tab, .layer-tab, .modal-close, .account-login { min-block-size: 44px; }
  .account-avatar-edit, .modal-close { min-inline-size: 44px; }
  .account-optional summary { min-block-size: 44px; display: list-item; align-content: center; }
}
