/* The two breakpoints. Both are declared here and nowhere else. */
@media (max-width: 1050px) {
  .app-shell { grid-template-columns: 205px minmax(0, 1fr); }
  .content { padding: 28px 24px; }
  .topbar { padding: 0 24px; }
  .match-detail-layout { grid-template-columns: minmax(0, 1fr) 220px; }
  .predictions-layout { grid-template-columns: minmax(0, 1fr) 250px; }
}
@media (max-width: 960px) and (orientation: portrait), (max-width: 780px) {
  .app-shell { display: block; }
  .sidebar { min-height: auto; padding: 14px 16px 12px; border-right: 0; border-bottom: 1px solid var(--line); gap: 12px; }
  .brand { padding: 0 2px; }
  .nav-label, .sidebar-spacer{ display: none; }
  .nav { display: flex; overflow-x: visible; flex-wrap: wrap; padding-bottom: 2px; }
  .nav-btn { width: auto; white-space: nowrap; padding: 8px 10px; }
  .topbar { height: 62px; padding: 0 16px; }

  .content { padding: 24px 16px 32px; }
  .match-detail-page { gap: 12px; }
  .match-detail-hero { padding: 16px 14px 18px; }
  .match-detail-heading { align-items: flex-start; padding-bottom: 14px; }
  .match-detail-heading h1 { font-size: 15px; }
  .match-detail-versus { grid-template-columns: minmax(0, 1fr) 72px minmax(0, 1fr); gap: 6px; min-height: 158px; padding: 18px 0 6px; }
  .match-detail-team-logo { width: 54px; height: 54px; border-radius: var(--radius-tile); font-size: 15px; }
  .match-detail-team strong { font-size: 13px; }
  .match-detail-team > span:last-child { font-size: 9px; }
  .match-detail-score strong { font-size: 28px; }
  .match-detail-facts { grid-auto-flow: row; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .member-row { grid-template-columns: 26px minmax(0, 1fr) auto; gap: 8px; padding: 10px 12px; }
  .member-avatar { width: 26px; height: 26px; }

  /* 与「今日比赛」同一套排布:左上 = 标志 + 名称 + 阶段/BO,右上 = 时间,下面一行双方与比分。 */
  .match-strip { grid-template-columns: 26px minmax(0, 1fr) auto; grid-template-areas: "mark names when" "versus versus versus"; row-gap: 10px; }
  .match-strip-when { grid-area: when; }
  .match-strip-mark { grid-area: mark; }
  .match-strip-names { grid-area: names; }
  .match-strip-versus { grid-area: versus; }

  /* 窄屏：左侧那条装饰带收起来,改成时间右侧的胜/败徽章。 */
  .match-strip-win, .match-strip-loss { box-shadow: none; }
  .match-strip-result { display: inline-flex; align-items: center; justify-content: center; min-width: 18px; padding: 1px 5px; border-radius: var(--radius-xs); font-size: 10px; }
  .match-strip-win .match-strip-result { background: color-mix(in srgb, var(--win) 18%, transparent); color: var(--win); }
  .match-strip-loss .match-strip-result { background: color-mix(in srgb, var(--danger) 18%, transparent); color: var(--danger); }
  .match-strip-mark-img { width: 26px; height: 26px; border-radius: var(--radius-xs); }
  .match-strip-names strong { font-size: 11px; }
  .match-strip-names span { font-size: 10px; }
  .match-strip-logo { width: 34px; height: 34px; }
  .match-strip-team { font-size: 14px; font-weight: 700; }
  .match-strip-score { font-size: 17px; }
  .match-detail-facts > div { border-bottom: 1px solid var(--line); }
  .match-detail-facts > div:nth-child(2n) { border-right: 0; }
  .match-detail-facts > div:nth-last-child(2) { border-bottom: 0; }
  .match-detail-facts > div:last-child { grid-column: 1 / -1; border-right: 0; border-bottom: 0; }
  .match-detail-layout { grid-template-columns: minmax(0, 1fr); }
  .predictions-layout { grid-template-columns: minmax(0, 1fr); }
  .match-rosters, .match-statistics, .match-duels, .match-maps, .match-context-panel, .match-source-panel { padding: 14px; }
  .duel-grid { grid-template-columns: minmax(145px, 1fr) repeat(var(--duel-columns), minmax(104px, 1fr)); }
  .match-roster-grid { grid-template-columns: minmax(0, 1fr); gap: 14px; }
  .match-roster-team + .match-roster-team { padding: 14px 0 0; border-top: 1px solid var(--line); border-left: 0; }
  /* 窄屏不折行也不压扁：保持一行，卡片给一个可读的最小宽度，超出就横向滚动。 */
  .match-map-grid { grid-auto-columns: minmax(230px, 1fr); }
  .match-map-card { min-height: 148px; }
  .demo-team-previews, .demo-binding-targets { grid-template-columns: minmax(0, 1fr); }
  /* 画布尺寸由平移缩放视口接管:这里再写 width:100% 会把内容的自然宽度压掉,
     自适应就会按容器宽度算错比例(内容固定列宽,于是溢出)。 */
  .bracket-readonly { padding-inline: 10px; }
  .bracket-readonly .bracket-canvas { justify-content: start; min-width: 0; }
  .page-head { align-items: flex-start; flex-direction: column; gap: 14px; }
  .page-head .primary-btn { align-self: stretch; }
  .overview-grid, .profile-grid, .admin-layout{ grid-template-columns: minmax(0, 1fr); }
  .room-screen { padding: 16px; }
  .room-screen-head { align-items: flex-start; flex-wrap: wrap; gap: 14px; }
  .room-brand { min-width: 0; }
  .room-context { order: 3; flex-basis: 100%; }
  .room-head-actions { width: 100%; justify-content: space-between; }
  .room-head-actions .integration { font-size: 9px; }
  .room-screen-body { grid-template-columns: minmax(0, 1fr); }

  .room-spectators { margin-top: 18px; }
  .room-spectators .slots { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .feature { min-height: 240px; padding: 24px; }
  /* 竖屏下首页是一列,这里再缩进就和下面的「最近比赛」对不齐了。 */
  .overview-grid .feature-schedule { padding: 0; }
  .feature-brand { gap: 16px; }
  .feature-name { font-size: 24px; }
  /* 窄屏上水印只会挤占名字,直接不显示。 */
  .feature-watermark { display: none; }

  .toolbar { align-items: stretch; flex-direction: column; }

  .search { max-width: none; width: 100%; }
  .profile-stats { grid-template-columns: minmax(0, 1fr); }
  /* 「我的预测」一行在窄屏改成两行：标题占满第一行，支持对象与对错徽章在第二行。
     不这样排的话，长赛事名会把右侧两个标签一路挤到只剩一个字。 */
  .prediction-row { flex-wrap: wrap; gap: 6px; }
  .prediction-row-main { flex-basis: 100%; }
  .form-row { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .admin-tabs { display: flex; overflow-x: auto; }
  .admin-tab { white-space: nowrap; }
  .admin-panel { padding: 14px; overflow: auto; }
  .admin-panel-head { align-items: flex-start; flex-direction: column; }
  .admin-search { max-width: none; width: 100%; }
  .data-table { min-width: 620px; }
  .series-row { grid-template-columns: 42px minmax(130px, 1fr) 80px; }
  .series-row .table-actions { display: none; }
  .series-directory-card { grid-template-columns: 46px minmax(0,1fr); padding: 10px 12px; gap: 10px; }
  .series-directory-avatar .series-avatar { width: 46px; height: 46px; }
  .series-directory-copy strong { font-size: 13px; }
  .series-detail-brand { align-items: flex-start; }
  .series-avatar-large { width: 52px; height: 52px; }
  .room-player-slots { grid-template-columns: repeat(2, minmax(0, 1fr)); }

  .series-detail-head { align-items: flex-start; flex-direction: column; }
  .series-detail-head .secondary-btn { align-self: stretch; }
  .series-detail-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .series-detail-stats > div { border-bottom: 1px solid var(--line); }
  .series-detail-stats > div:nth-child(2n) { border-right: 0; }
  .series-detail-stats > div:last-child { grid-column: 1 / -1; border-bottom: 0; border-right: 0; }

  .overlay { padding: 0; align-items: flex-end; }

  /* 导入预览：四列在窄屏会把备注压成一个字一行。改成两行 —— 行号独占左列，
     昵称与 id 排第一行、备注整行放在下面。靠 DOM 里那层 `.import-row-main`
     （预览与导入结果共用），而不是 `grid-column` 跨列：跨列要求备注不是被自动
     放置的第 3 个子项，只有多包一层才成立。 */
  .import-row, .import-failure { grid-template-columns: 22px minmax(0, 1fr); align-items: start; }
  .import-row-main, .import-failure-main { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
  .import-row-name, .import-failure-id { flex: 1 1 96px; }
  .import-row-id { flex: 0 1 134px; }
  .import-row-note, .import-failure-note { flex: 1 1 100%; }

}
