@media screen and (max-width: 700px), screen and (max-width: 1000px) and (max-height: 500px) and (pointer: coarse) {
  html:has(:is(.record-detail, .chart-zoom, .card-export)[open]) { overflow: hidden; }
  .record-detail, .chart-zoom, .card-export { inset: 0; margin: 0; width: 100%; max-width: 100%; height: 100dvh; max-height: 100dvh; border: 0; border-radius: 0; }
  .record-detail-header, .chart-zoom-header { padding: max(10px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) 10px max(12px, env(safe-area-inset-left)); gap: 10px; }
  .record-detail-header h2, .chart-zoom-header h2 { min-width: 0; font-size: 16px; line-height: 1.5; }
  .record-detail-header button, .chart-zoom-close { flex: 0 0 auto; min-height: 44px; }
  .record-detail-body, .chart-zoom-content { padding: 14px max(12px, env(safe-area-inset-right)) max(20px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left)); overscroll-behavior: contain; }
  .record-overview { padding: 12px; }
  .record-overview-heading h3 { font-size: 16px; line-height: 1.6; }
  .record-overview-context { gap: 6px 8px; font-size: 12px; }
  .record-overview-context span + span { border-left: 0; padding-left: 0; }
  .record-detail-facts { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .record-overview .record-overview-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .record-overview-stats > div { padding: 10px; }
  .record-overview-stats > div:nth-child(3) { border-left: 0; }
  .record-overview-stats > div:nth-child(n+3) { border-top: 1px solid var(--line); }
  .record-overview-stats dd { font-size: 16px; }
  .record-overview .record-overview-metadata { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .record-overview-metadata > div { display: grid; gap: 4px; }
  .record-detail-section { margin-top: 20px; padding-top: 14px; }
  .record-detail-section > summary { min-height: 44px; padding-block: 12px; line-height: 1.6; }
  .record-deck-grid, .record-relic-grid, .record-choice-grid.is-shop,
  .record-choice-grid.has-three, .record-choice-grid.has-four { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .record-item { padding: 10px; }
  .record-item-name { line-height: 1.5; }
  .record-item-note, .record-enchantment { line-height: 1.6; }
  .record-choice-group { grid-template-columns: minmax(0, 1fr); padding: 10px; gap: 8px; }
  .record-choice-header { flex-direction: row; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 6px; }
  .record-choice-header h3 { font-size: 13px; }
  .record-choice { min-height: 44px; padding: 8px; }
  .record-party .record-item { flex: 1 1 130px; }
  .record-sender-archive { flex-wrap: wrap; gap: 10px; }
  .record-detail .table-wrap table { min-width: 560px; }
  .record-detail .table-wrap { border: 1px solid var(--line); border-radius: 8px; }
  .record-detail .table-wrap::before { content: '左右にスクロールして履歴を確認'; position: sticky; left: 0; display: block; padding: 8px; width: max-content; color: var(--muted); font-size: 11px; }
  .record-error-entry { padding: 10px; min-width: 0; }
  .record-error-entry pre { font-size: 12px; line-height: 1.7; }
  #chart-zoom .chart-zoom-stage > :is(.count-chart, .ascension-chart, .card-balance-scroll) { min-width: 760px; }
  #chart-zoom .chart-zoom-stage[data-source="all-floor-distribution"] .count-chart,
  #chart-zoom .chart-zoom-stage[data-source="floor-progress-chart"] .count-chart { min-width: 1120px; }
  #chart-zoom .chart-zoom-stage > .activity-pie { min-width: 0; grid-template-columns: minmax(0, 1fr); }
  #chart-zoom .chart-expandable { padding-top: 0; }
  #chart-zoom .activity-pie svg { width: min(100%, 300px); }
  #chart-zoom .activity-pie-legend { font-size: 14px; gap: 14px; }
  .card-export { box-sizing: border-box; padding: max(12px, env(safe-area-inset-top)) 12px max(20px, env(safe-area-inset-bottom)); overflow: auto; }
  .card-export-header { position: sticky; top: 0; z-index: 1; flex-wrap: nowrap; gap: 10px; background: #fff; padding-block: 8px 12px; }
  .card-export-header h2 { font-size: 16px; line-height: 1.5; min-width: 0; }
  #card-export-close { flex-shrink: 0; }
  .card-export-actions { gap: 8px; }
  .card-export-actions button { flex: 1 1 auto; }
  .card-export textarea { min-height: 180px; height: 40dvh; font-size: 16px; }
}

@media screen and (max-width: 359px) {
  .record-deck-grid, .record-relic-grid, .record-choice-grid.is-shop,
  .record-choice-grid.has-three, .record-choice-grid.has-four { grid-template-columns: minmax(0, 1fr); }
}
