/* Shared phone layout, loaded after each chapter's existing styles. */
@media (max-width: 1000px) {
  body .investigation-header.game-header,
  body .investigation-header.chapter-header {
    grid-template-columns: minmax(0, 1fr) repeat(3, 44px);
    gap: 4px;
    padding: 8px 16px 0;
    min-height: 100px;
  }
  body .investigation-header .game-brand { grid-column: 1; grid-row: 1; overflow-wrap: anywhere; }
  body .investigation-header nav {
    grid-column: 1 / -1;
    grid-row: 2;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 4px 12px;
  }
  body .investigation-header nav a { min-height: 44px; }
  body .investigation-header .reread-menu { grid-column: 2; grid-row: 1; }
  body .investigation-header .help-menu,
  body .investigation-header .case-help { grid-column: 3; grid-row: 1; }
  body .investigation-header [data-sound-toggle] {
    grid-column: 4;
    grid-row: 1;
    width: 44px;
    min-height: 44px;
    max-width: 44px;
  }
  body .investigation-header .shell-menu > summary,
  body .investigation-header .case-help > details > summary { width: 44px; min-height: 44px; }
}
@media (max-width: 760px) {
  html { -webkit-text-size-adjust: 100%; }
  body { padding-bottom: max(16px, env(safe-area-inset-bottom, 0px)); }
  body main { min-width: 0; }
  body main h1, body main h2, body main h3,
  body .team-roster strong, body .entry-form p { overflow-wrap: anywhere; }

  body main[class] button:not(.scene-region):not(.hotspot),
  body main[class] summary,
  body main .chapter-open,
  body main .r-top > a,
  body main .document-top > a,
  body main .finance-top > a,
  body main .chapter-history {
    min-height: 44px !important;
    min-width: 44px !important;
    touch-action: manipulation;
  }
  body main[class] input:not([type=checkbox]):not([type=radio]),
  body main[class] select,
  body main[class] textarea {
    font-size: 16px !important;
    max-width: 100%;
  }
  body main[class] input:not([type=checkbox]):not([type=radio]),
  body main[class] select { min-height: 44px !important; }

  body .r-top, body .document-top, body .finance-top {
    gap: 6px !important;
    align-items: stretch;
  }
  body .r-top > a, body .r-top > button,
  body .document-top > a, body .document-top > button,
  body .finance-top > a, body .finance-top > button {
    white-space: normal !important;
    line-height: 1.35 !important;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-align: center;
  }
  body .r-paper-tools, body .document-paper-tools, body .finance-paper-tools {
    gap: 8px;
    align-items: center;
  }
  body .r-paper-tools button,
  body .document-paper-tools button,
  body .finance-paper-tools button {
    flex: 0 0 44px;
    width: 44px !important;
    min-width: 44px !important;
    min-height: 44px !important;
  }
  body .r-paper-tools select,
  body .document-paper-tools select,
  body .finance-paper-tools select { min-width: 0; }

  body .invite-tools { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; }
  body .invite-tools input, body .invite-tools button { width: 100%; }
  body .team-roster article { flex-wrap: wrap; gap: 8px 16px; }
  body .team-roster strong { min-width: 0; flex: 1 1 200px; }
  body .case-actions, body .reader-pager { flex-wrap: wrap; }
  body .case-actions a, body .reader-tools button { min-height: 44px; }
  body .entry-actions > button, body .entry-form > button { max-width: 100%; white-space: normal; }
  body .r-final textarea { scroll-margin-top: 24px; }
}

/* Preserve room for landscape keyboards without forcing a tall inner scroller. */
@media (max-width: 760px) and (max-height: 500px) {
  body .r-document { min-height: 180px; height: 65svh; }
  body .reader-layout figure { position: static; }
}
