/* MOBILE START */
.nav-toggle { display: none; background: none; border: 1px solid var(--color-border); color: var(--color-text); border-radius: 8px;
  width: 42px; height: 38px; font-size: 1.3rem; line-height: 1; cursor: pointer; }
@media (max-width: 900px) {
  /* nav: logo + burger, links drop down as a panel */
  nav { padding: 0 1rem; }
  .nav-logo { white-space: nowrap; font-size: 1.05rem; }
  .nav-toggle { display: inline-flex; align-items: center; justify-content: center; }
  .nav-links { display: none; position: fixed; top: 60px; left: 0; right: 0; flex-direction: column; gap: 0;
    background: rgba(0,0,0,0.97); border-bottom: 1px solid var(--color-border); padding: 0.5rem 0 0.75rem; margin: 0;
    max-height: calc(100vh - 60px); overflow-y: auto; }
  .nav-links.open { display: flex; }
  .nav-links li { list-style: none; }
  .nav-links a { display: block; padding: 0.85rem 1.25rem; font-size: 0.95rem; }
  .nav-dropdown-menu { position: static; transform: none; display: block; min-width: 0; border: none; border-radius: 0;
    background: rgba(255,255,255,0.03); padding: 0; }
  .nav-dropdown-menu a { padding-left: 2.25rem; font-size: 0.85rem; }

  section { padding-left: 1rem; padding-right: 1rem; }

  /* character card: stack, portrait full width */
  .char-top { grid-template-columns: 1fr; min-height: 0; }
  .char-info { padding: 1.5rem 1.25rem; border-right: none; border-bottom: 1px solid var(--color-border); }
  .char-desc { max-width: none; }
  .char-portrait-col { width: 100%; height: auto; min-height: 0; max-height: none; aspect-ratio: 8 / 9; padding: 0.5rem; overflow: hidden; }
  .char-portrait-col img { max-height: 100%; }
  .char-items-grid { grid-template-columns: repeat(2, 1fr); }
  .char-item-col { border-right: none; border-bottom: 1px solid var(--color-border); padding: 1rem; }
  .skins-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .char-card img, .char-card svg, .char-card video { max-width: 100%; }
  .char-card table { display: block; overflow-x: auto; }
  /* the General / Contextual Combat / Movement panels are an inline three-column grid: stack them */
  .char-card div[style*="grid-template-columns:repeat(3,1fr)"] { grid-template-columns: 1fr !important; }
  .patch-list-grid > .muted { grid-column: 1 / -1; }
  .char-card div[style*="padding:1.1rem 2rem"] { padding-left: 0.9rem !important; padding-right: 0.9rem !important; }
  .char-card span[style*="white-space:nowrap"] { white-space: normal !important; text-align: right; }

  /* patch history, modals, galleries */
  .history-layout { grid-template-columns: 1fr; }
  .sub-portrait-col { width: 100%; min-width: 0; }
  #patch-modal, #char-history-modal { max-width: 100%; width: 100%; border-radius: 0; }
  .video-grid { grid-template-columns: 1fr; }
  .vl-actor { width: 100%; }
  #music-tracklist-overlay { width: 100%; max-width: 100%; }

  /* download */
  .download-card { flex-direction: column; align-items: stretch; }
  .download-card > div { flex-shrink: 1; min-width: 0; flex-wrap: wrap; }
  .download-card .btn { flex: 1 1 140px; justify-content: center; }

  /* perks */
  .perks-toggle-icon { width: 92px; height: 92px; }
}
@media (max-width: 560px) {
  .char-items-grid { grid-template-columns: 1fr; }
  .perks-grid { grid-template-columns: 1fr; }
  .perk-stat-row, .perk-stat-head { grid-template-columns: minmax(0, 1fr) repeat(3, minmax(52px, auto)); gap: 4px; }
  h1 { font-size: 2.4rem; }
}
/* MOBILE END */

/* High zoom and narrow screens: keep patch portraits from squeezing notes.
   The desktop layout remains side-by-side; only the narrow layout stacks. */
@media (max-width: 900px) {
  #patch-modal-char-detail .sub-entry,
  #char-history-body .sub-entry,
  #history .sub-entry {
    flex-direction: column;
    min-height: 0;
    height: auto;
    width: 100%;
  }

  #patch-modal-char-detail .sub-entry > .sub-portrait-col,
  #char-history-body .sub-entry > .sub-portrait-col,
  #history .sub-entry > .sub-portrait-col {
    width: 100%;
    min-width: 0;
    flex: 0 0 auto;
    height: clamp(130px, 28dvh, 280px);
  }

  #patch-modal-char-detail .sub-entry > .sub-portrait-col img.fullbody,
  #char-history-body .sub-entry > .sub-portrait-col img.fullbody,
  #history .sub-entry > .sub-portrait-col img.fullbody {
    height: 100%;
    width: auto;
    max-height: 100%;
    max-width: 100%;
    object-fit: contain;
  }

  #patch-modal-char-detail .sub-entry > .sub-abilities-col,
  #char-history-body .sub-entry > .sub-abilities-col,
  #history .sub-entry > .sub-abilities-col {
    box-sizing: border-box;
    min-width: 0;
    width: 100%;
    flex: 0 0 auto;
    overflow-wrap: break-word;
    padding: 0.85rem;
  }
}
