/* ===================================================================
 * style-responsive.css — 响应式布局（最后加载，覆盖前面所有样式）
 * 断点：<768px 手机（底部导航 + 单列 + 横滑行动条）
 *       769~1024px 平板（紧凑侧栏 + 自适应网格）
 * 目标：零横向滚动、卡片不溢出、按钮可点、行动条可横滑
 * =================================================================== */

/* 底部导航默认隐藏（桌面只见左侧栏） */
.bottom-nav { display: none; }
.bottom-bar { display: none; }

/* ===== 全局溢出与弹性字号 ===== */
html, body { overflow-x: hidden; }
button, input, select { font-family: inherit; }
img { max-width: 100%; }

/* ===================================================================
 * 手机端：< 768px
 * =================================================================== */
@media (max-width: 768px) {
  /* 用动态视口高度，规避移动端地址栏导致的 100vh 溢出 */
  #app { height: 100dvh; min-height: 100dvh; }
  .topbar, .shell, .stage { overflow-x: hidden; }

  /* ---- 0. 主内容区底部预留免责声明条 + 底栏 ---- */
  .stage { padding-bottom: calc(100px + env(safe-area-inset-bottom, 0px)); }

  /* ---- 1. 侧边栏 → 底部导航 ---- */
  .sidebar { display: none !important; }
  .bottom-bar {
    display: flex !important; flex: 0 0 56px; width: 100%;
    background: linear-gradient(180deg, rgba(22,22,30,.96), rgba(10,10,15,.98));
    border-top: 1px solid var(--ui-line);
    box-shadow: 0 -4px 16px rgba(0,0,0,.4);
    padding-bottom: calc(2px + env(safe-area-inset-bottom, 0px));
    z-index: 50;
  }
  .bottom-nav {
    display: flex !important;
    flex: 1 1 auto; min-width: 0; width: auto;
    align-items: stretch; justify-content: flex-start;
    padding: 2px;
    overflow-x: auto; overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .bottom-nav::-webkit-scrollbar { display: none; }
  .bottom-nav .nav-btn {
    flex: 1 0 46px; min-width: 46px;
    flex-direction: column; align-items: center; justify-content: center; gap: 2px;
    padding: 4px 1px; margin: 0;
    font-size: 10px; letter-spacing: 0; line-height: 1.1;
    clip-path: none; border-radius: 3px;
    white-space: nowrap;
    -webkit-tap-highlight-color: transparent;
  }
  .bottom-nav .nav-btn > span:last-child {
    max-width: 100%; overflow: hidden; text-overflow: ellipsis;
  }
  .bottom-nav .nav-ico { font-size: 18px; line-height: 1; }
  .bottom-nav .nav-foot { display: none; }
  /* 手机端工具区：设置/重置固定在外层右端，不随导航横向滚动（桌面在侧边栏 nav-foot） */
  .bottom-tools {
    flex: 0 0 auto; display: flex; align-items: stretch;
    background: linear-gradient(90deg, rgba(10,10,15,0) 0%, rgba(10,10,15,.9) 22%, rgba(10,10,15,.98) 100%);
    box-shadow: -10px 0 12px rgba(10,10,15,.85);
    padding: 2px 2px 2px 8px;
  }
  /* 工具区不在 .bottom-nav 内，需独立补齐底栏按钮形态（否则继承侧栏的斜切 clip-path） */
  .bottom-tools .nav-tool {
    flex: 0 0 46px; min-width: 46px;
    flex-direction: column; align-items: center; justify-content: center; gap: 2px;
    padding: 4px 1px; font-size: 10px; letter-spacing: 0; line-height: 1.1;
    clip-path: none; border-radius: 3px; white-space: nowrap;
    -webkit-tap-highlight-color: transparent;
  }
  .bottom-tools .nav-tool .nav-ico { font-size: 18px; line-height: 1; }
  .bottom-tools .nav-tool > span:last-child { max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
  .bottom-tools .nav-tool .nav-ico { color: var(--ui-gold); }
  .bottom-tools .nav-tool.danger .nav-ico { color: #e8846f; }
  .bottom-tools .nav-tool:active { background: rgba(196,168,124,.18); }
  .shell { flex: 1 1 auto; min-height: 0; }

  /* ---- 顶栏：压缩高度，资源条横滑，隐藏次要状态 ---- */
  .topbar {
    flex: 0 0 46px; gap: 8px; padding: 0 10px;
  }
  .brand { font-size: 13px; letter-spacing: 1px; gap: 6px; }
  .brand em { display: none; }
  .brand-mark { width: 10px; height: 10px; }
  .res-strip {
    justify-content: flex-start; flex-wrap: nowrap;
    overflow-x: auto; overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    gap: 5px; padding-bottom: 2px;
    scrollbar-width: none;
  }
  .res-strip::-webkit-scrollbar { display: none; }
  .res-chip { padding: 2px 6px; font-size: 10px; flex: 0 0 auto; }
  .top-right { display: none; }

  /* ---- 2. 战斗区：上下对峙、卡片换行 ---- */
  .battle-view { gap: 6px; padding: 8px 8px 10px; }
  .battle-view .actionbar {
    flex-wrap: nowrap !important;
    justify-content: flex-start !important;
    align-items: center !important;
    overflow-x: auto !important; overflow-y: visible !important;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
    /* 左侧/顶部留白，保证 lead 头像放大+金边+NEXT 标签完整不被裁 */
    gap: 6px; min-height: 86px; padding: 22px 14px 10px;
    scrollbar-width: thin; scrollbar-color: #4a445e transparent;
  }
  .battle-view .av-node { flex: 0 0 auto; }
  /* lead 放大与 NEXT 标签与 PC 端完全一致（scale 1.2 + 金色 NEXT），不再单独缩小 */
  .battle-view .av-face-wrap { width: 40px; height: 40px; }
  .battle-view .av-cap { max-width: 46px; font-size: 9px; }

  .battle-view .resource-bar { gap: 6px; padding: 5px 8px; flex-wrap: wrap; }
  .battle-view .resource-bar .rb-note { display: none; }
  .battle-view .rb-label { font-size: 11px; }

  /* 敌我上下排列，各占整行 */
  .battle-view .arena {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 6px; padding: 2px 0;
  }
  .battle-view .side {
    flex: 0 0 auto !important; width: 100% !important;
    margin: 0 !important; align-items: stretch !important;
  }
  .battle-view .side-title { margin-bottom: 4px; font-size: 11px; text-align: center; }
  /* 紧凑头像模式：auto-fit 让少数单位也均分整行居中，8 个时正好一行排下 */
  .battle-view .team {
    display: grid !important;
    grid-template-columns: repeat(auto-fit, minmax(42px, 1fr)) !important;
    justify-content: center;
    gap: 4px; width: 100%; min-width: 0;
  }
  .battle-view .unit {
    min-width: 0 !important; max-width: 100%; overflow: hidden;
    padding: 2px !important; border-radius: 3px;
    display: flex; flex-direction: column; align-items: stretch;
  }
  .battle-view .unit .ava {
    width: 100% !important; height: auto !important;
    aspect-ratio: 1 / 1; padding: 0; margin: 0; border: 0;
    border-radius: 2px; overflow: hidden;
  }
  .battle-view .unit .ava .ava-img {
    width: 100% !important; height: 100% !important;
    object-fit: cover; display: block;
  }
  .battle-view .unit .body { padding: 0; min-width: 0; }
  /* 隐藏所有冗余文字（名字/等级/标签/数值/弱点/状态），根治竖排挤压 bug。
     保留：血条 + 能量条（我方）/ 韧性条（敌方）——终结技就绪是最核心战斗信息 */
  .battle-view .unit .row1,
  .battle-view .unit .mini,
  .battle-view .unit .hp-txt,
  .battle-view .unit .en-txt,
  .battle-view .unit .status-row,
  .battle-view .unit .weak,
  .battle-view .unit .tough-label { display: none !important; }
  .battle-view .unit .bar.hp {
    height: 2px !important; min-height: 2px; margin-top: 2px;
    border-radius: 0; background: rgba(255,255,255,.12);
  }
  .battle-view .unit .bar.hp i { border-radius: 0; height: 100%; }
  /* 能量条（我方）：淡蓝，满能量金色闪烁提示可放终结技 */
  .battle-view .unit .bar.energy {
    display: block !important; height: 2px !important; min-height: 2px;
    margin-top: 2px; border-radius: 0; background: rgba(255,255,255,.12);
  }
  .battle-view .unit .bar.energy i { border-radius: 0; height: 100%; background: #5ac8fa; }
  .battle-view .unit .bar.energy.full i {
    background: linear-gradient(90deg, #f0dca6, #d8b96a);
    box-shadow: 0 0 5px rgba(216,185,106,.95);
    animation: energyPulse 1.2s ease-in-out infinite;
  }
  /* 韧性条（敌方）：白条置底；击破后变红 */
  .battle-view .unit .bar.tough {
    display: block !important; height: 2px !important; min-height: 2px;
    margin-top: 2px; border-radius: 0; background: rgba(255,255,255,.12);
  }
  .battle-view .unit .bar.tough i { border-radius: 0; height: 100%; background: #e8e6f0; }
  .battle-view .unit .bar.tough.broken i { background: #e57373; }
  @keyframes energyPulse { 0%,100% { opacity: 1; } 50% { opacity: .45; } }
  /* 任何残留文字强制单行省略，绝不竖排 */
  .battle-view .unit span { white-space: nowrap !important; overflow: hidden; text-overflow: ellipsis; }
  /* 能量就绪：能量条金色闪烁之外，头像外圈再加金光双重提示 */
  .battle-view .unit:has(.bar.energy.full) .ava { box-shadow: 0 0 6px 1px var(--gold, #d8b96a); }

  /* ---- 控制按钮变大、日志压缩 ---- */
  .battle-view .controls { gap: 5px; padding: 6px 8px; justify-content: center; }
  .battle-view .controls .btn {
    min-height: 38px; padding: 7px 12px; font-size: 13px;
    -webkit-tap-highlight-color: transparent;
  }
  .battle-view .ctrl-note, .battle-view .ctrl-sep { display: none; }
  /* 日志已移入右侧抽屉，抽屉内日志样式 */
  .log-drawer { width: 85vw; max-width: 85vw; }
  .log-drawer-head { padding: 12px 14px; font-size: 14px; }
  .log-drawer .battle-log { padding: 10px 14px; font-size: 11.5px; line-height: 1.75; }

  /* ---- 3. 菜单视图：多栏堆叠 ---- */
  .char-view {
    grid-template-columns: 1fr !important;
    max-width: 100%; padding: 10px; gap: 10px;
    overflow-x: hidden;
  }
  .char-list { height: auto; max-height: 210px; overflow-y: auto; }
  .char-detail, .char-panel { grid-column: auto !important; min-width: 0; }
  .inv-wrap, .team-wrap, .codex-wrap, .camp-wrap, .univ-grid, .tm-grid {
    grid-template-columns: 1fr !important; min-width: 0 !important;
    padding: 10px !important; gap: 10px !important;
  }
  .lp-wrap { grid-template-columns: 1fr !important; min-width: 0 !important; }

  /* 网格：一行放 3~4 个，无横向滚动 */
  .inv-grid, .codex-grid, .mat-grid, .abyss-grid, .camp-nodes {
    grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)) !important;
    gap: 6px !important; width: 100%;
  }
  .camp-grid, .sr-nodes {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)) !important;
    gap: 8px !important;
  }
  .gacha-grid { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; gap: 8px !important; }
  .eidolon-grid, .stat-grid-2, .cd-stats { grid-template-columns: repeat(2, minmax(0,1fr)) !important; }
  .inv-item, .codex-cell, .cd-cell { min-width: 0; }

  /* ---- 关卡视图：悬浮栏不压底导、Tab横滑、卡片两列不溢出 ---- */
  .stage-view { padding: 12px 10px 190px !important; overflow-x: hidden; }
  /* 标题与描述：标题不换行竖排，描述换行收窄 */
  .stage-title { flex-direction: column; align-items: flex-start; gap: 4px; margin-bottom: 12px; padding-bottom: 10px; }
  .stage-title h2 { font-size: 20px; letter-spacing: 2px; white-space: nowrap; }
  .stage-title span { font-size: 11px; line-height: 1.4; }
  /* 顶部 Tab：可横滑 + 隐藏滚动条但保留滑动，所有标签能滑到 */
  .map-tabs {
    gap: 4px; margin-bottom: 14px;
    overflow-x: auto !important; overflow-y: hidden;
    white-space: nowrap; flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch; scrollbar-width: none;
  }
  .map-tabs::-webkit-scrollbar { display: none; }
  .map-tab { flex: 0 0 auto; padding: 9px 14px; font-size: 13px; letter-spacing: .5px; }
  /* 区域标题：长描述省略，不撑破 */
  .sr-head { flex-wrap: wrap; gap: 4px 8px; }
  .sr-head b { font-size: 14px; }
  .sr-head span { font-size: 10px; overflow-wrap: anywhere; }
  /* 卡片网格：强行两列，minmax(0,1fr) 防撑破；文字单行省略 */
  .camp-grid, .sr-nodes, .abyss-grid, .camp-nodes {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 8px !important; width: 100%; min-width: 0;
  }
  .stage-node, .camp-card, .mat-node { min-width: 0 !important; width: 100%; overflow: hidden; padding: 10px !important; }
  .stage-node b, .camp-card b, .sn-head b, .sn-lv, .sn-enemies, .sn-loot, .sn-first, .cc-name, .cc-sub {
    white-space: nowrap !important; overflow: hidden; text-overflow: ellipsis; display: block;
  }
  .sn-head { flex-wrap: nowrap; gap: 4px; }
  .sn-head b { flex: 1 1 auto; min-width: 0; }
  .sn-lv { flex: 0 0 auto; }
  /* 关卡详情弹窗：窄屏单列敌人阵容，操作区撑满 */
  .sd-wrap { width:100%; padding:16px 14px 18px; max-height:74vh; }
  .sd-title b { font-size:17px; }
  .sd-enemies { grid-template-columns:1fr; }
  .sd-actions .btn { min-width:0; flex:1 1 0; }
  .sd-actions .btn.primary.big { min-width:0; letter-spacing:1px; }

  /* ---- 4. 弹窗自适应 + 内部滚动 ---- */
  .modal { padding: 10px; }
  .modal-box {
    width: 92vw !important; max-width: 92vw !important;
    max-height: 82vh !important; max-height: 82dvh !important;
    margin: auto; overflow: hidden;
    display: flex; flex-direction: column;
  }
  .modal-head { flex: 0 0 auto; padding: 10px 12px; font-size: 13px; }
  .modal-body {
    flex: 1 1 auto; overflow-y: auto; overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    padding: 12px; font-size: 13px;
    overflow-wrap: anywhere; word-break: break-word;
  }
  .modal-foot { flex: 0 0 auto; padding: 8px 12px; }
  .modal-box.narrow { width: 92vw !important; }
  .modal-body.single { max-height: none !important; }

  /* 字体弹性收敛：长描述不撑破卡片 */
  .stage { font-size: 13px; }

  /* 图鉴角色档案：单列纵向，整卷滚动 */
  .modal-box.modal-wide { width: 96vw; max-height: 92vh; }
  .modal-box.modal-wide .modal-body { overflow: auto; display: block; }
  .cd-book { display: block; }
  .cdb-left { border-right: none; border-bottom: 1px solid var(--ui-line); }
  .cdb-figure { height: 42vh; }
  .cdb-right { overflow: visible; padding: 14px 14px 18px; }
  .cdb-name { font-size: 21px; letter-spacing: 3px; }

  /* 行迹星盘 / 星魂星图：窄屏横向滚动，节点保持间距不重叠 */
  .sx-stage, .ec-map { min-width: 440px; }
  .sxn-core { width: 42px; height: 42px; }
  .sxn-center .sxn-core { width: 68px; height: 68px; }
  .sxn-label { max-width: 82px; font-size: 11px; }
  .ecn-hex { width: 54px; height: 54px; }
  .ecn-num { font-size: 18px; }
  .ecn-name { max-width: 78px; font-size: 10.5px; }
  .ecd-desc { font-size: 11.5px; line-height: 1.8; }

  .panel { padding: 12px; }
  .desc, .skill-desc, .effect-txt { font-size: 11px; overflow-wrap: anywhere; }
}

/* ===================================================================
 * 小屏手机：< 420px 进一步压缩
 * =================================================================== */
@media (max-width: 420px) {
  .battle-view .team { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .battle-view .av-face-wrap { width: 36px; height: 36px; }
  .bottom-nav .nav-btn { font-size: 9px; }
  .bottom-nav .nav-ico { font-size: 16px; }
  .inv-grid, .codex-grid, .mat-grid, .abyss-grid, .camp-nodes {
    grid-template-columns: repeat(auto-fill, minmax(78px, 1fr)) !important;
  }
}

/* ===================================================================
 * 平板：769~1024px 紧凑侧栏 + 网格自适应（不隐藏侧栏）
 * =================================================================== */
@media (min-width: 769px) and (max-width: 1024px) {
  .sidebar { flex-basis: 76px; width: 76px; padding: 12px 6px; }
  .nav-btn { font-size: 11px; padding: 10px 2px; }
  .nav-ico { font-size: 15px; }
  .battle-view { padding: 10px 14px 12px; }
  .battle-view .side { flex-basis: 260px; width: 260px; }
  .battle-view .arena { gap: 24px; }
  .codex-grid { grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); }
  /* 平板角色布局统一由文件末尾的 768~1366 断点管理（两栏，面板不再整行下置） */
}

/* ===================================================================
 * 手机端补充修复（2026-11-19）：战斗卡片限宽、角色立绘限高、
 * 编队栏溢出、模拟宇宙层数换行、日志长文本折行
 * =================================================================== */
@media (max-width: 768px) {
  /* 1. 战斗卡片：auto-fit 会把 3 个单位拉满 1/3 屏，限制单卡最大 84px */
  .battle-view .team {
    grid-template-columns: repeat(auto-fit, minmax(40px, 84px)) !important;
    justify-content: center !important;
  }
  .battle-view .unit { max-width: 84px; }
  .battle-view .av-node { min-width: 44px; }

  /* 2. 角色页：立绘限高 + 列表宽度收敛（右上角「3」不再被裁） */
  .char-stage { height: auto !important; max-height: none !important; }
  .portrait { height: 34vh; flex: 0 0 auto; min-height: 0; }   /* 缩高让操作名片上移，避开底部声明 */
  .pt-img { object-fit: cover !important; }        /* 手机维持饱满裁切，全屏用 contain */
  .cm-avatar { width: 72px; height: 72px; flex-basis: 72px; }
  .cm-name { font-size: 16px; }
  .cm-row2 .btn { font-size: 11px; padding: 4px 7px; }
  .char-list { width: 100% !important; min-width: 0 !important; overflow-x: hidden; }
  .char-list .cl-head, .char-list .cl-title, .char-list .ch-list-head { min-width: 0; }
  .char-grid { grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)) !important; }

  /* 3. 编队：两栏改整行，角色池网格自适应（右侧不再有大片空白/裁切） */
  .tm-grid { grid-template-columns: 1fr !important; }
  .tm-panel { min-width: 0 !important; width: 100%; }
  .tm-panel-roster .char-grid { grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)) !important; }

  /* 4. 模拟宇宙：层数点换行不溢出 */
  .univ-progress { flex-wrap: wrap; gap: 8px; }
  .up-dot { width: 30px; height: 30px; font-size: 12px; }

  /* 5. 日志：长文本换行但不逐字符竖排 */
  .lg-row { flex-wrap: wrap; row-gap: 2px; }
  .lg-d { flex: 1 1 100%; word-break: break-word; overflow-wrap: anywhere; }
  .lg-m { white-space: normal; overflow-wrap: anywhere; }
  .lg-bar { gap: 6px; }
  .lg-search { width: 100%; flex: 1 1 100%; }

  /* 6. 后台战斗悬浮窗：窄屏不遮挡操作，宽度收敛 */
  .battle-fab { right: 10px; bottom: 72px; min-width: 0; max-width: calc(100vw - 20px); padding: 8px 10px; }
  .bf-body em { max-width: 180px; }
}

@media (max-width: 768px) {
  /* 角色列表标题：计数徽标不再贴边裁切 */
  .col-title { width: 100%; box-sizing: border-box; padding-right: 10px; }
  .char-list { padding-right: 8px; box-sizing: border-box; }
  /* 编队页顶部预设条：横向滑动不吃掉宽度 */
  .team-tabs { margin-right: 0; }
}

/* ==== 手机端行动条：从「左侧竖排绝对定位」改为「顶部横滑条」 ====
 * style-items.css 的竖条用 top/bottom 绝对定位拉伸，窄屏会遮挡战区和资源条，
 * 这里整体覆盖回流内横向滚动（与 PC 竖条是两套布局，互不干扰）。 */
@media (max-width: 768px) {
  .battle-view .actionbar {
    position: static !important;
    left: auto !important; top: auto !important; bottom: auto !important;
    transform: none !important;
    width: 100% !important; max-height: 96px !important;
    flex-direction: row !important;
    align-items: center !important; justify-content: flex-start !important;
    overflow-x: auto !important; overflow-y: hidden !important;
    padding: 18px 10px 8px !important;
    min-height: 84px;
    background: rgba(255, 255, 255, 0.02) !important;
    border: 1px solid var(--ui-line2) !important;
    border-radius: 4px;
    gap: 8px;
  }
  .battle-view .actionbar .av-node { width: auto !important; }
  .battle-view .actionbar .av-face-wrap { width: 40px !important; height: 40px !important; }
  .battle-view .actionbar .av-next { display: flex !important; }
  .battle-view .arena { padding-left: 0 !important; }
}

@media (max-width: 768px) {
  /* 图鉴页签：单行不折字，可横滑 */
  #codex-tabs, .codex-view .tabs {
    overflow-x: auto; flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch; scrollbar-width: none;
  }
  #codex-tabs::-webkit-scrollbar, .codex-view .tabs::-webkit-scrollbar { display: none; }
  #codex-tabs .tab, .codex-view .tabs .tab {
    flex: 0 0 auto; white-space: nowrap; padding: 7px 12px; font-size: 12.5px;
  }
  .codex-view .stage-title h2 { font-size: 20px; }
}

/* ===================================================================
 * 手机端滚动与布局根治（2026-11-19 10:20）
 * 问题：.stage 仅 character/inventory/gacha 有 overflow-y:auto，
 *       编队/图鉴/宇宙/日志内容超出被裁死；角色列表在窄屏被压没；
 *       各视图底部被固定导航遮挡。
 * =================================================================== */
@media (max-width: 768px) {
  /* 1. 所有主视图统一可滚动 + 惯性滚动 */
  .stage { overflow-y: auto !important; overflow-x: hidden !important; -webkit-overflow-scrolling: touch; }
  .stage.view-battle { overflow: hidden !important; }   /* 战斗页整屏固定，不滚动 */

  /* 2. 统一底部留白：56px 底栏 + 安全区 + 24px 缓冲 */
  .char-view, .team-view, .inv-wrap, .codex-view, .univ-view, .logs-view,
  .gacha-view {
    padding-bottom: calc(84px + env(safe-area-inset-bottom, 0px)) !important;
  }
  .stage-view { padding-bottom: calc(190px + env(safe-area-inset-bottom, 0px)) !important; }

  /* 3. 编队：强制上下堆叠（flex column，兼容原 grid） */
  .tm-grid {
    display: flex !important; flex-direction: column !important;
    gap: 10px !important; width: 100% !important;
  }
  .tm-panel { width: 100% !important; min-width: 0 !important; }

  /* 4. 角色页：左侧列表改顶部横向头像栏（绝不隐藏） */
  .char-view { display: flex !important; flex-direction: column !important; gap: 10px; }
  .char-list {
    display: block !important;
    width: 100% !important; min-width: 0 !important;
    height: auto !important; max-height: none !important;
    overflow: visible !important; padding: 0 2px !important;
    order: -1;
  }
  .char-list .cl-filter { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; }
  .char-list .char-grid {
    display: flex !important; flex-direction: row !important; flex-wrap: nowrap !important;
    gap: 6px !important; width: 100%;
    overflow-x: auto !important; overflow-y: hidden !important;
    -webkit-overflow-scrolling: touch;
    padding: 2px 2px 8px !important;
  }
  .char-list .char-grid::-webkit-scrollbar { display: none; }
  .char-list .char-cell {
    flex: 0 0 62px !important; min-width: 62px !important; max-width: 62px !important;
    padding: 5px 3px !important;
  }
  .char-list .char-cell .cc-name { font-size: 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .char-list .char-cell .cc-lv { font-size: 9px; }
  .char-meta { order: 0; }        /* 手机：名片+升级按钮置顶，绝不被底部声明/导航压住 */
  .char-stage { order: 1; }
  .char-panel { order: 2; }
}

@media (max-width: 768px) {
  /* 角色页 flex 塌陷修正：立绘区与页签面板都按内容高度排布，面板不再被压扁 */
  .char-view { gap: 8px !important; }
  .char-stage { flex: 0 0 auto !important; }
  .char-panel { flex: 0 0 auto !important; min-height: 0; }
  .char-panel .tab-body { min-height: 320px; }

  /* 背包/图鉴/宇宙/日志 底部留白统一（实际滚动容器可能是视图自身） */
  .inv-view, .codex-view, .univ-view, .logs-view, .gacha-view {
    padding-bottom: calc(88px + env(safe-area-inset-bottom, 0px)) !important;
  }
}

/* ===================================================================
 * 手机端横向溢出根治（2026-11-19 10:35）
 * 真凶：.stage 是 flex column，视图根（.team-view 等）作为 flex item
 *       默认 min-width:auto → 内部 nowrap（8 个队伍标签）把 min-content
 *       撑到 658px，overflow:hidden 只裁不滚 → 右侧按钮/数量被切。
 * =================================================================== */
@media (max-width: 768px) {
  /* 1. 所有视图根：可收缩 + 严格不超视口 */
  .stage > * {
    min-width: 0 !important;
    width: 100% !important;
    max-width: 100vw !important;
    box-sizing: border-box;
  }
  .team-view, .view-team, .stage.view-team {
    width: 100% !important; max-width: 100vw !important;
    overflow-x: hidden !important;
    padding-left: 10px !important; padding-right: 10px !important;
  }
  /* 2. 编队内部：面板/槽位/角色网格全部 100% 且可收缩 */
  .tm-grid { width: 100% !important; max-width: 100% !important; }
  .tm-panel, .tm-slots, .tm-slot {
    width: 100% !important; max-width: 100% !important; box-sizing: border-box;
  }
  .tm-slot { min-width: 0 !important; }
  /* 编队槽保持横向 4 槽（竖式卡），角色面板不再撑满视口高度 */
  .tm-slots { display: grid !important; grid-template-columns: repeat(4, 1fr) !important; }
  .tm-panel-roster { height: auto !important; min-height: 0 !important; }
  .tm-slot .tm-info { min-width: 0; overflow: hidden; }
  .tm-slot .tm-info b, .tm-slot .tm-info span {
    display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
  .tm-slot .tm-ops { flex: 0 0 auto; }
  .tm-panel h3 { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .tm-panel-roster .char-grid {
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr)) !important;
    width: 100% !important;
  }
  /* 3. 队伍预设条自带横滑，不再把父级撑宽 */
  .team-tabs { max-width: 100% !important; width: 100% !important; }
  /* 4. 全局保险：任何页面都不允许横向滚动 */
  html, body, #app, .shell, .stage { max-width: 100vw; overflow-x: hidden !important; }
}

/* ===================================================================
 * 平板/半屏断点（2026-11-20）：768~1366 角色三栏→两栏 + 声明遮挡修复
 * =================================================================== */
@media (min-width: 768px) and (max-width: 1366px) {
  /* 两栏：左列表 220px + 右详情占满；右栏 = 顶部角色名片(头像/名字/星级/属性/等级/升级晋阶按钮) + 下方页签面板 */
  .char-view {
    grid-template-columns: 220px minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr);
    height: calc(100vh - 132px); gap: 12px; overflow-x: hidden;
  }
  .char-view > * { width: 100%; min-width: 0; }
  .char-list { grid-column: 1; grid-row: 1 / span 2; height: 100% !important; overflow: auto; }
  .char-stage { display: none; }                          /* 仅隐藏立绘；操作区已剥离到 char-meta，绝不丢失 */
  .char-meta { grid-column: 2; grid-row: 1; }             /* 角色名片：代替大立绘，操作按钮齐全 */
  .char-panel { grid-column: 2; grid-row: 2; height: 100% !important; overflow: auto; }
  .battle-view { flex-wrap: wrap; }
  .battle-view .side { flex: 1 1 240px; width: auto; max-width: 100%; }
  .team-view { flex: 1; height: auto; min-height: 0; overflow-y: auto; }
  .tm-panel-roster { min-height: 240px; flex: 0 0 auto; }
  .tm-panel-roster .char-grid { overflow-y: auto; }
}
