@media (max-width: 980px) {
  html, body { min-width: 0; width: 100%; }
  .formation-header { position: static; flex-wrap: wrap; gap: 10px; padding: 10px; }
  .formation-title, .header-actions { flex-wrap: wrap; gap: 6px; }
  .formation-header button, .formation-header a { min-height: 44px; }
  .formation-main { width: calc(100% - 16px); }
  .formation-board { padding: 8px; }
  .board-heading { flex-direction: column; align-items: stretch; gap: 10px; }
  .play-mode-actions > div { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .play-mode-button { padding: 8px; }
  .formation-grid { grid-template-columns: minmax(0, 1fr); }
  .formation-lane-headings { display: none; }
  .character-portrait { height: 180px; }
  .chip-picker__body { grid-template-columns: minmax(0, 1fr); overflow: auto; }
  .chip-picker-list { max-height: 180px; flex-shrink: 0; }
  .chip-performance { overflow: visible; }
  .chip-performance__upper, .chip-performance__lower, .chip-performance__header { grid-template-columns: minmax(0, 1fr); }
  .chip-picker__footer { grid-template-columns: minmax(0, 1fr); max-height: 32dvh; overflow: auto; }
  .chip-filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .character-picker-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 980px) {
  .chip-category-tabs { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .character-picker-list { grid-template-columns: minmax(0, 1fr); }
}
/* Keep all six formation slots visible in a two-column, three-row board. */
@media (max-width: 980px) {
  html { height: 100%; overflow: hidden; }
  body { height: 100vh; height: 100dvh; min-height: 0; overflow: hidden; display: grid; grid-template-rows: auto minmax(0, 1fr); }
  .formation-header { min-height: 0; justify-content: flex-start; gap: 4px; padding: 4px 6px; }
  .formation-title, .header-actions { display: contents; }
  .formation-title > div, .header-actions .chip-source { display: none; }
  .formation-header button, .formation-header a { min-height: 28px; height: auto; font-size: 9px; padding: 3px 6px; }
  .formation-main { min-height: 0; width: calc(100% - 8px); margin: 0 4px; padding: 0 0 4px; }
  .formation-board { min-height: 0; padding: 4px; display: grid; grid-template-rows: auto minmax(0, 1fr); }
  .board-heading { gap: 2px; margin-bottom: 4px; }
  .board-heading > div:first-child { display: none; }
  .play-mode-actions { gap: 2px; }
  .play-mode-actions > span, .play-mode-button small { display: none; }
  .play-mode-actions > div { gap: 4px; }
  .play-mode-button { min-height: 28px; padding: 3px; }
  .play-mode-button strong { font-size: 10px; }
  .board-heading .formation-lock-status { font-size: 8px; line-height: 1.2; margin: 0; }
  .formation-grid { min-height: 0; grid-template-columns: repeat(2, minmax(0, 1fr)); grid-template-rows: repeat(3, minmax(0, 1fr)); gap: 4px; }
  .character-card { min-height: 0; display: grid; grid-template-rows: minmax(0, 1fr) auto; border-radius: 5px; }
  .character-card:hover { transform: none; }
  .character-portrait { height: 100%; min-height: 0; }
  .pair-badge { top: 2px; left: 2px; font-size: 6px; padding: 2px; }
  .portrait-edit-hint { right: 2px; bottom: 2px; font-size: 6px; padding: 2px; }
  .character-body { padding: 3px; }
  .character-name { gap: 3px; }
  .character-name h3 { font-size: 10px; white-space: nowrap; }
  .character-name span, .character-name em { font-size: 7px; }
  .chip-slots { gap: 3px; margin-top: 2px; }
  .chip-name-display { min-height: 20px; padding: 2px; grid-template-columns: 12px minmax(0, 1fr); gap: 2px; }
  .chip-name-display b { width: 12px; height: 12px; font-size: 7px; }
  .chip-name-display strong { font-size: 8px; }
  .chip-equipment-toolbar { margin-top: 2px; gap: 3px; }
  .chip-equipment-toolbar > span { font-size: 6px; }
  .chip-swap-button, .chip-edit-button { min-height: 22px; height: 22px; }
  .chip-edit-button { font-size: 8px; padding: 0 5px; }
}
@media (max-width: 980px) and (max-height: 420px) {
  .character-card { grid-template-columns: 44px minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); }
  .character-body { align-self: center; }
  .portrait-edit-hint { display: none; }
  .pair-badge { font-size: 5px; }
}
