/* 手机竖屏适配层：只在窄屏竖屏生效，不改桌面布局。 */
.mail-wrap { display: grid; grid-template-columns: 340px 1fr; gap: 16px; }

@media (max-width: 720px) and (orientation: portrait) {
  :root {
    --mobile-pad: 12px;
    --mobile-safe-bottom: env(safe-area-inset-bottom, 0px);
    --mobile-top: 10px;
  }

  html, body { height: 100%; overscroll-behavior: none; }
  body { overflow: hidden; touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
  #app { position: fixed; inset: 0; }

  #frame {
    width: 100vw !important;
    height: 100vh !important;
    height: 100dvh !important;
    transform: translate(-50%, -50%) !important;
    box-shadow: none;
  }
  #stage {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover;
    object-position: 50% 50%;
  }
  .layer { overflow: hidden; }

  /* ---------- 登录 ---------- */
  #login { overflow-y: auto; -webkit-overflow-scrolling: touch; }
  .login-veil {
    background:
      linear-gradient(180deg, rgba(3, 5, 9, .78), rgba(3, 5, 9, .9) 48%, rgba(3, 5, 9, .97)),
      radial-gradient(ellipse at 70% 20%, rgba(6, 10, 18, .18), rgba(4, 7, 12, .84) 70%);
  }
  .login-box {
    position: relative;
    left: auto; top: auto;
    width: auto;
    margin: 54px 22px 92px;
  }
  .brand { margin-bottom: 30px; }
  .brand-sub { font-size: 11px; letter-spacing: 4px; }
  .brand-title {
    font-size: clamp(40px, 12.5vw, 60px);
    letter-spacing: 3px;
    line-height: 1.06;
  }
  .brand-line { font-size: 11px; letter-spacing: 2px; gap: 8px; }
  .login-form { width: 100%; gap: 14px; }
  .login-form label { font-size: 11px; letter-spacing: 2px; }
  .login-form input { padding: 12px 12px; font-size: 16px; }
  .server-row { flex-wrap: wrap; gap: 8px 12px; }
  .server-btn { padding: 9px 13px; }
  .login-settings-link { font-size: 11px; }
  .login-options { gap: 8px; }
  .login-form .remember-check { font-size: 11px; }
  .login-server-host { max-width: 56%; font-size: 9px; }
  .login-form .btn.big { width: 100%; padding: 14px 12px; font-size: 17px; letter-spacing: 4px; }
  .login-tip { font-size: 10px; line-height: 1.65; }
  .login-foot {
    left: 18px; right: 18px; bottom: calc(14px + var(--mobile-safe-bottom));
    font-size: 9px; letter-spacing: 1px; line-height: 1.6;
  }
  .login-foot span { display: block; margin: 3px 0 0; }

  /* ---------- 创角 ---------- */
  #create {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: calc(20px + env(safe-area-inset-top, 0px)) 14px calc(24px + var(--mobile-safe-bottom));
  }
  #create .panel-head h2 { font-size: 30px; letter-spacing: 4px; }
  #create .panel-head p { font-size: 11px; line-height: 1.7; letter-spacing: .3px; }
  .wuhun-list {
    grid-template-columns: 1fr;
    gap: 10px;
    margin-top: 18px;
  }
  .awaken-intro { min-height: 270px; padding: 24px 18px; }
  .awaken-sigil { width: 64px; height: 64px; font-size: 31px; }
  .awaken-title { margin-top: 16px; font-size: 23px; letter-spacing: 4px; }
  .awaken-intro p { font-size: 12px; line-height: 1.75; }
  .awaken-intro .btn { min-width: 0; width: 100%; max-width: 280px; margin-top: 20px; }
  .awaken-note { font-size: 10px; line-height: 1.5; }
  .wuhun-card { padding: 16px 14px 14px; }
  .wuhun-card h3 { font-size: 23px; }
  .awaken-toolbar { flex-direction: column; align-items: stretch; gap: 10px; }
  .awaken-toolbar .btn { min-width: 0; width: 100%; }
  .faction-pick { margin-top: 18px; }
  .faction-pick-head { display: block; }
  .faction-pick-head b { display: block; font-size: 15px; }
  .faction-pick-head span { display: block; margin-top: 4px; font-size: 10px; line-height: 1.5; }
  .faction-options { grid-template-columns: 1fr; gap: 8px; margin-top: 10px; }
  .faction-option { min-height: 58px; padding: 9px 12px; }
  .create-foot {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
    margin-top: 20px;
    padding: 12px 0 calc(8px + var(--mobile-safe-bottom));
    background: linear-gradient(180deg, transparent, rgba(4, 7, 12, .92) 20%);
  }
  .create-foot label { width: 100%; font-size: 11px; }
  .create-foot input { font-size: 16px; padding: 12px; }
  .create-foot .btn { width: 100%; padding: 12px; }
  .create-tip { font-size: 11px; line-height: 1.5; }

  /* ---------- HUD ---------- */
  .hud-top {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 6px;
    padding: calc(8px + env(safe-area-inset-top, 0px)) 10px 6px;
    align-items: start;
  }
  .player-card {
    min-width: 0;
    width: 100%;
    gap: 9px;
    padding: 7px 9px 7px 7px;
    background: linear-gradient(120deg, rgba(10, 15, 24, .94), rgba(10, 15, 24, .72));
  }
  .avatar { width: 46px; height: 46px; }
  .avatar span { font-size: 20px; }
  .player-meta { min-width: 0; }
  .player-meta .row1 { gap: 6px; flex-wrap: wrap; }
  .player-meta strong { max-width: 44vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 15px; }
  .lv { font-size: 9px; padding: 1px 5px; }
  .lv b { font-size: 11px; }
  .wuhun-tag { font-size: 9px; max-width: 24vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .bars { width: 100%; gap: 3px; margin-top: 5px; }
  .bar { height: 11px; }
  .bar span { font-size: 8px; line-height: 10px; }
  .money { padding-left: 6px; min-width: 54px; }
  .money em { font-size: 8px; letter-spacing: 1px; }
  .money b { font-size: 14px; }
  .map-title {
    display: flex;
    align-items: baseline;
    justify-content: flex-start;
    flex-wrap: wrap;
    gap: 2px 8px;
    padding-top: 0;
    text-align: left;
  }
  .map-title span { display: inline; font-size: 20px; letter-spacing: 4px; }
  .map-title em {
    display: inline;
    font-size: 9.5px;
    letter-spacing: 1.5px;
    color: #c8b98f;
    text-shadow: 0 1px 4px rgba(0, 0, 0, .95);
  }
  .hud-actions {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 5px;
    width: 100%;
  }
  .hud-action.dock-btn {
    width: 100%;
    height: 44px;
    flex-direction: row;
    gap: 4px;
    padding: 2px;
  }
  .hud-action.dock-btn b { font-size: 12px; letter-spacing: .5px; }
  .hud-action.dock-btn em { font-size: 9px; }

  .hud-left {
    left: 10px;
    right: 158px;
    top: calc(194px + env(safe-area-inset-top, 0px));
    width: auto;
    max-height: 118px;
    overflow-y: auto;
    gap: 5px;
    padding-right: 1px;
    scrollbar-width: thin;
  }
  .player-panel, .team-panel, .target-panel { padding: 7px 9px; }
  .player-panel .panel-label { font-size: 9px; margin-bottom: 5px; }
  .player-row { padding: 3px 0; }
  .player-row .player-name { font-size: 11px; }
  .player-attack { height: 22px; min-width: 36px; }
  .player-actions-btn { width: 24px; height: 22px; }

  .hud-bottom {
    left: 10px;
    right: 10px;
    bottom: calc(8px + var(--mobile-safe-bottom));
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
  }
  .chat { width: 100%; gap: 4px; }
  .chat-log {
    height: 72px;
    font-size: 10.5px;
    line-height: 1.5;
    padding: 6px 7px 2px;
  }
  .chat-input { gap: 4px; }
  .chat-input select { width: 64px; padding: 7px 3px; font-size: 11px; }
  .chat-input input { padding: 8px; font-size: 13px; }
  .chat-input .btn.tiny { padding: 5px 9px; font-size: 11px; }
  .dock {
    margin-left: 0;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 5px;
    width: 100%;
  }
  .dock-btn {
    width: 100%;
    height: 44px;
    gap: 1px;
  }
  .dock-btn b { font-size: 12px; letter-spacing: .5px; }
  .dock-btn em { font-size: 8px; }

  .scene-actions {
    left: 10px;
    right: 10px;
    top: auto;
    bottom: calc(175px + var(--mobile-safe-bottom));
    display: flex;
    flex-direction: row;
    align-items: stretch;
    gap: 6px;
  }
  .scene-actions .btn {
    flex: 1;
    min-width: 0;
    width: auto;
    padding: 7px 6px;
    text-align: center;
    font-size: 11px;
  }
  .scene-actions .btn small { font-size: 8px; }

  /* 野外页：纯文字魂兽表 + 翻页，不再在画布上叠怪物立绘与文字 */
  body.mobile-portrait.scene-field .hud-left,
  body.mobile-portrait.scene-field .scene-actions { display: none; }

  .mob-board {
    position: absolute;
    left: 10px;
    right: 10px;
    top: calc(206px + env(safe-area-inset-top, 0px));
    bottom: auto;
    display: flex;
    flex-direction: column;
    max-height: calc(100dvh - 390px);
    overflow: hidden;
    background: linear-gradient(160deg, rgba(9, 14, 23, .96), rgba(6, 10, 17, .93));
    border: 1px solid rgba(217, 178, 95, .24);
    border-radius: 2px;
    box-shadow: 0 14px 34px rgba(0, 0, 0, .24);
    pointer-events: auto;
  }
  .mob-board-head {
    flex: none;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 0 8px;
    min-height: 38px;
    padding: 3px 10px;
    border-bottom: 1px solid rgba(217, 178, 95, .14);
  }
  .mob-board-title { display: flex; align-items: baseline; gap: 7px; min-width: 0; }
  .mob-board-title b {
    flex: none;
    font-family: 'XinWei', serif;
    font-size: 18px;
    font-weight: 500;
    letter-spacing: 3px;
    color: #f3e3bd;
  }
  .mob-board-sub {
    grid-column: 1 / -1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 9px;
    line-height: 12px;
    color: #919baa;
  }
  .mob-board-tools { grid-column: 2; grid-row: 1; display: flex; align-items: center; gap: 2px; flex: none; }
  .mob-board-tools:empty { display: none; }
  .mob-board-tools button {
    border: 0;
    background: none;
    padding: 4px 5px;
    font-size: 11px;
    color: #d9b25f;
  }
  .mob-table-head,
  .mob-text-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 56px 40px 68px 40px;
    align-items: center;
    gap: 6px;
    width: 100%;
    padding-left: 10px;
    padding-right: 10px;
  }
  .mob-table-head {
    flex: none;
    min-height: 22px;
    font-size: 9px;
    letter-spacing: 1px;
    color: #707b8c;
    border-bottom: 1px solid rgba(151, 177, 196, .12);
  }
  .mob-board-list { flex: 1 1 auto; display: flex; flex-direction: column; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
  .mob-text-row {
    flex: none;
    height: clamp(28px, 3.8vh, 36px);
    border: 0;
    border-bottom: 1px solid rgba(151, 177, 196, .1);
    background: transparent;
    color: #c7d0dc;
    font-family: inherit;
    text-align: left;
  }
  .mob-text-row:nth-child(odd) { background: rgba(255, 255, 255, .018); }
  .mob-text-row:active { background: rgba(217, 178, 95, .08); }
  .mob-text-row.boss { background: rgba(217, 178, 95, .055); }
  .mob-text-row.dead { opacity: .42; }
  .mob-text-row .mob-name {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 13px;
    font-weight: 500;
    color: #f0e2c2;
  }
  .mob-text-row.boss .mob-name { color: #ff5c5c; }
  .mob-text-row .mob-year,
  .mob-text-row .mob-domain,
  .mob-text-row .mob-hp {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 10px;
    color: #98a3b2;
  }
  .mob-text-row .mob-domain { color: #aeb9c7; text-align: center; }
  .mob-text-row.boss .mob-domain { color: #d9b25f; }
  .mob-text-row .mob-state {
    font-size: 11px;
    text-align: right;
    color: #d9b25f;
    white-space: nowrap;
  }
  .mob-text-row.dead .mob-state { color: #707b8c; }
  .mob-board-empty {
    flex: 1;
    display: grid;
    place-items: center;
    min-height: 120px;
    color: #8d97a7;
    font-size: 12px;
  }
  .mob-board-foot {
    flex: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    min-height: 32px;
    padding: 2px 7px;
    border-top: 1px solid rgba(217, 178, 95, .14);
    font-size: 10px;
    color: #8d97a7;
  }
  .mob-board-foot button {
    border: 0;
    background: none;
    padding: 5px 7px;
    font-size: 11px;
    color: #d9b25f;
  }
  .mob-board-foot button:disabled { color: #535d6b; }
  .mob-board-foot span { letter-spacing: 1px; }

  /* 主城热点改为右侧快捷入口，避免 1600 坐标在小屏外溢 */
  #hotspot-layer {
    left: auto;
    right: 10px;
    top: calc(194px + env(safe-area-inset-top, 0px));
    bottom: auto;
    width: 138px;
    height: auto;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 5px;
    pointer-events: none;
  }
  #hotspot-layer .hotspot {
    position: static;
    left: auto !important;
    top: auto !important;
    transform: none;
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 6px;
    width: 100%;
    min-height: 42px;
    padding: 5px 6px;
    background: rgba(7, 12, 20, .76);
    border: 1px solid rgba(217, 178, 95, .22);
    border-radius: 2px;
    pointer-events: auto;
  }
  #hotspot-layer .hotspot .pin {
    width: 28px; height: 28px; font-size: 11px; flex: none;
    box-shadow: 0 0 12px rgba(217, 178, 95, .18);
  }
  #hotspot-layer .hotspot .label {
    padding: 0; border: 0; background: none; font-size: 10px; line-height: 1.25;
    text-align: left; text-shadow: 0 1px 3px #000;
  }
  #hotspot-layer .hotspot .label small { font-size: 8px; }

  .toasts { top: calc(170px + env(safe-area-inset-top, 0px)); width: calc(100% - 28px); }
  .toast { max-width: 100%; padding: 7px 11px; font-size: 11px; text-align: center; }

  /* ---------- 通用窗口：手机全屏抽屉 ---------- */
  .windows { position: fixed; inset: 0; }
  .window {
    left: 0 !important;
    top: 0 !important;
    transform: none !important;
    width: 100vw !important;
    max-width: 100vw !important;
    height: 100vh !important;
    height: 100dvh !important;
    max-height: none !important;
    background: linear-gradient(160deg, #0e141f, #070a11 68%, #05080d);
    border-radius: 0;
    border-left: 0;
    border-right: 0;
    box-shadow: none;
  }
  .win-head {
    position: sticky;
    top: 0;
    z-index: 30;
    flex: none;
    gap: 8px;
    min-height: 44px;
    padding: calc(6px + env(safe-area-inset-top, 0px)) 10px 6px;
    background: linear-gradient(180deg, rgba(14, 20, 31, .99), rgba(14, 20, 31, .94));
  }
  .win-head h3 { font-size: 18px; letter-spacing: 2px; white-space: nowrap; }
  .win-head .sub {
    min-width: 0; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    font-size: 9px; letter-spacing: .3px;
  }
  .win-close {
    flex: none; width: 38px; height: 38px; margin-left: 4px; font-size: 17px;
  }
  .win-body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 10px 10px calc(14px + var(--mobile-safe-bottom));
  }
  .win-foot {
    flex: none;
    flex-wrap: wrap;
    gap: 7px;
    padding: 8px 10px calc(8px + var(--mobile-safe-bottom));
    background: rgba(8, 12, 20, .96);
  }
  .win-foot .right { margin-left: auto; }

  /* 背包 */
  .bag-toolbar { flex-wrap: wrap; gap: 6px; padding: 7px; }
  .bag-act-group { width: 100%; gap: 5px; }
  .bag-act-group .btn { flex: 1; padding-left: 6px; padding-right: 6px; font-size: 11px; }
  .bag-act-hint { flex: 1 1 100%; margin-left: 0; white-space: normal; line-height: 1.45; }
  .bag-wrap { flex-direction: column; gap: 10px; }
  .bag-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    grid-auto-rows: auto;
    gap: 5px;
  }
  .bag-grid .slot { aspect-ratio: 1 / 1; min-height: 0; }
  .slot .item-img { width: 38px; height: 38px; }
  .slot .nm { font-size: 8px; }
  .bag-side { gap: 8px; }
  .item-detail { padding-top: 8px; font-size: 11px; line-height: 1.65; min-height: 90px; }
  .detail-actions { flex-wrap: wrap; }
  .detail-actions .btn { flex: 1; padding-left: 8px; padding-right: 8px; font-size: 12px; }

  /* 角色 */
  .character-window { width: 100vw !important; height: 100dvh !important; max-height: none !important; }
  .character-window .win-body { padding: 0; overflow-y: auto; }
  .char-ref-wrap {
    display: block;
    min-height: 0;
    border-left: 0;
    border-right: 0;
  }
  .char-ref-wrap .char-left { border-right: 0; border-bottom: 1px solid rgba(211, 173, 90, .3); }
  .char-ref-wrap .char-left-body { padding: 0 10px 8px; }
  .char-ref-wrap .char-right-body {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 0 8px 8px;
  }
  .char-pane-head { height: 30px; margin: 2px 10px 0; }
  .char-pane-head h3 { font-size: 17px; letter-spacing: 3px; padding: 0 10px; }
  .char-top { gap: 8px; }
  .char-wuhun-art { width: 94px; height: 94px; }
  .char-ring-label { font-size: 11px; line-height: 14px; }
  .char-rings { width: 100%; gap: 1px 6px; }
  .soul-ring { width: 38px; height: 23px; }
  .soul-ring img { width: 38px; height: 23px; }
  .char-ring-foot { width: 100%; margin-top: 3px; font-size: 10px; }
  .char-trait { white-space: normal; align-items: flex-start; padding: 4px 6px; font-size: 10px; line-height: 1.45; }
  .char-trait span { white-space: normal; overflow: visible; text-overflow: clip; }
  .char-info-row { grid-template-columns: 58px minmax(0, 1fr) 64px minmax(0, 1fr); gap: 1px 4px; padding: 2px 0; }
  .ci-label { font-size: 10px; letter-spacing: 1px; }
  .ci-value { font-size: 12px; }
  .char-vitals { gap: 3px; margin-top: 4px; }
  .char-vital { grid-template-columns: 25px minmax(0, 1fr) 83px; gap: 5px; }
  .vital-label { font-size: 10px; }
  .vital-side { font-size: 9px; }
  .vital-track em { font-size: 8px; }
  .char-left-foot { gap: 7px 12px; margin-top: 4px; padding-top: 4px; }
  .char-meta { font-size: 10px; }
  .char-gold-link { font-size: 11px; }
  .char-stat-col { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; padding: 2px 0 0; overflow: visible; }
  .char-stat-col .ref-stat-block:first-child { grid-column: 1; }
  .char-stat-col .ref-stat-block:nth-child(2) { grid-column: 2; }
  .char-stat-col .bone-set-box { grid-column: 1 / -1; margin-top: 2px; max-height: 88px; }
  .ref-stat-block h4, .bone-set-box h4 { font-size: 11px; letter-spacing: 2px; }
  .ref-stat-row { padding: 2.5px 0; font-size: 11px; letter-spacing: .3px; }
  .char-ref-wrap .bone-map { min-height: 380px; height: 380px; width: 100%; }
  .char-ref-wrap .bone-silhouette { width: 226px; height: 360px; }
  .char-ref-wrap .bone-slot.head { top: 0; }
  .char-ref-wrap .bone-slot.arm-l { top: 74px; right: 2px; }
  .char-ref-wrap .bone-slot.arm-r { top: 92px; left: 2px; }
  .char-ref-wrap .bone-slot.torso { top: 128px; }
  .char-ref-wrap .bone-slot.leg-l, .char-ref-wrap .bone-slot.leg-r { bottom: 66px; }
  .char-ref-wrap .bone-slot.ext1, .char-ref-wrap .bone-slot.ext2, .char-ref-wrap .bone-slot.ext3 { bottom: 0; }
  .char-ref-wrap .bone-menu { width: min(300px, calc(100vw - 16px)); }
  .char-right-foot { padding: 4px 2px 0; }
  .char-gold-btn { font-size: 12px; padding: 5px 10px; }

  /* 技能 / 组队 / 交易 / 铁匠铺 */
  .skill-list { grid-template-columns: 1fr; gap: 8px; }
  .skill-ring-head { flex-direction: column; align-items: stretch; gap: 8px; padding: 9px 10px; }
  .skill-ring-head .btn { min-width: 0; width: 100%; }
  .skill-card { padding: 10px; }
  .skill-card h4 { font-size: 13px; }
  .skill-card p { font-size: 11px; line-height: 1.55; }
  .skill-card .meta { flex-wrap: wrap; gap: 8px; font-size: 10px; }
  .member-list { gap: 5px; }
  .member { flex-wrap: wrap; padding: 7px 8px; font-size: 11px; gap: 6px; }
  .member .sp { margin-left: 0; }
  .trade-cols { grid-template-columns: 1fr; gap: 8px; }
  .trade-state { padding: 2px 0; }
  .trade-side { padding: 8px; }
  .trade-slots { grid-template-columns: repeat(3, 1fr); }
  .trade-money { flex-wrap: wrap; }
  .trade-money input { flex: 1; width: auto; min-width: 90px; }
  .sect-hero { flex-wrap: wrap; padding: 11px; gap: 10px; }
  .sect-seal { width: 44px; height: 44px; flex-basis: 44px; font-size: 21px; }
  .sect-hero h3 { font-size: 17px; }
  .sect-hero-actions { width: 100%; justify-content: flex-start; }
  .sect-grid { grid-template-columns: 1fr; gap: 9px; }
  .sect-upgrade-card { grid-column: auto; }
  .sect-create-row { flex-direction: column; }
  .sect-token-line { align-items: flex-start; flex-direction: column; }
  .sect-list-row { gap: 8px; }
  .sect-list-meta { display: none; }
  .sect-donate-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .sect-war-entry { flex-direction: column; align-items: flex-start; gap: 9px; }
  .sect-war-entry .btn { width: 100%; }
  .sect-war-hero { padding: 12px; gap: 10px; }
  .sect-war-hero h3 { font-size: 18px; }
  .sect-war-clock { flex-basis: 82px; }
  .sect-war-clock b { font-size: 24px; }
  .sect-war-grid { grid-template-columns: 1fr; gap: 9px; }
  .sect-war-players, .sect-war-sects { max-height: 220px; }
  .forge-grid { grid-template-columns: 1fr; gap: 8px; }
  .forge-picks { flex-direction: column; gap: 5px; }
  .forge-top { flex-wrap: wrap; gap: 6px; }
  .forge-top .btn { margin-left: 0; width: 100%; }
  .forge-card { padding: 9px; }
  .melt-bar { flex-wrap: wrap; gap: 7px; }
  .melt-bar .btn { margin-left: 0; width: 100%; }

  /* 商城 / 商店 / 地图 / 邮件 / 排行 */
  .mall-wrap { grid-template-columns: 1fr; gap: 9px; min-height: 0; }
  .mall-tabs {
    flex-direction: row;
    gap: 5px;
    padding: 0 0 6px;
    border-right: 0;
    border-bottom: 1px solid rgba(217, 178, 95, .16);
    overflow-x: auto;
  }
  .mall-tab { flex: 0 0 auto; width: auto; padding: 7px 8px; gap: 6px; }
  .mall-tab-glyph { width: 25px; height: 25px; font-size: 11px; }
  .mall-tab-copy b { font-size: 11px; }
  .mall-tab-copy em { display: none; }
  .mall-head { flex-direction: column; gap: 7px; padding-bottom: 8px; }
  .mall-head-copy h4 { font-size: 19px; }
  .mall-wallet { width: 100%; min-width: 0; text-align: left; }
  .mall-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); max-height: none; gap: 7px; padding-right: 0; }
  .mall-card { min-height: 150px; padding: 9px; }
  .goods { grid-template-columns: 1fr 1fr !important; gap: 7px; }
  .goods .good { padding: 8px; }
  .map-list { grid-template-columns: 1fr 1fr; gap: 7px; }
  .map-card { padding: 9px; }
  .list-row { flex-wrap: wrap; gap: 5px; padding: 8px 9px; font-size: 11px; }
  .list-row .time { width: 100%; margin-left: 0; }
  .mail-wrap { display: block; }
  .mail-wrap > .list {
    display: block;
    max-height: 190px;
    overflow-y: auto;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(217, 178, 95, .18);
  }
  .mail-wrap .list-row { margin-bottom: 5px; }
  .mail-wrap .mail-body { word-break: break-word; white-space: pre-wrap; font-size: 11px; line-height: 1.7; }
  .mail-wrap > div:last-child > div[style*="display:flex"] { flex-wrap: wrap; }
  .mail-body { font-size: 11px; line-height: 1.7; }

  /* 学院 */
  .window.academy-window { max-height: none; }
  .academy-hero { flex-direction: column; align-items: flex-start; gap: 7px; padding-bottom: 8px; }
  .academy-kicker { font-size: 20px; }
  .academy-sub { font-size: 10px; line-height: 1.5; }
  .academy-total { text-align: left; font-size: 10px; }
  .academy-total b { font-size: 24px; }
  .academy-tabs { margin: 9px 0 10px; overflow-x: auto; }
  .academy-tab { flex: none; padding: 8px 18px; font-size: 12px; }
  .academy-page { min-height: 0; }
  .course-card { align-items: flex-start; flex-wrap: wrap; gap: 8px; min-height: 0; padding: 8px; }
  .course-seal { width: 38px; height: 38px; font-size: 17px; }
  .course-info { flex: 1 1 calc(100% - 50px); }
  .course-title { gap: 7px; flex-wrap: wrap; }
  .course-title b { font-size: 16px; }
  .course-desc { white-space: normal; font-size: 10px; line-height: 1.45; }
  .course-action { width: 100%; flex-direction: row; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px; }
  .course-cost { width: auto; align-items: flex-start; text-align: left; font-size: 10px; }
  .course-cost span { justify-content: flex-start; }
  .course-study { text-align: left; white-space: normal; }
  .course-btn { min-width: 78px; font-size: 11px; }
  .calendar-head { align-items: flex-start; gap: 6px; }
  .calendar-head b { font-size: 17px; }
  .calendar-legend { flex-wrap: wrap; justify-content: flex-end; font-size: 9px; }
  .calendar-week span { font-size: 9px; }
  .cal-cell { min-height: 48px; padding: 4px 3px; }
  .cal-date { font-size: 10px; }
  .cal-date em { font-size: 7px; padding: 1px 2px; }
  .cal-reward { font-size: 8px; margin-top: 3px; }
  .cal-state { font-size: 8px; }
  .calendar-foot { flex-direction: column; align-items: stretch; gap: 7px; }
  .calendar-actions { width: 100%; }
  .calendar-actions .btn { flex: 1; min-width: 0; }
  .monthly-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .monthly-card { min-height: 52px; padding: 6px; }

  /* 战斗 */
  .battle-top {
    flex-wrap: wrap;
    gap: 6px 8px;
    padding: calc(8px + env(safe-area-inset-top, 0px)) 9px 6px;
    background: linear-gradient(180deg, rgba(5, 8, 14, .86), transparent);
  }
  .battle-title { font-size: 18px; letter-spacing: 3px; }
  .battle-turn { flex: 1 1 100%; order: 3; text-align: left; font-size: 10px; letter-spacing: 2px; }
  .battle-auto { gap: 7px; margin-left: auto; }
  .battle-auto label { font-size: 10px; }
  .battle-auto .btn { padding: 5px 8px; font-size: 10px; }
  #btn-flee { padding: 6px 9px; font-size: 10px; }
  .battle-targets {
    top: calc(86px + env(safe-area-inset-top, 0px)); left: 9px; right: 9px;
    transform: none; max-width: none; flex-wrap: nowrap; overflow-x: auto;
    justify-content: flex-start; padding: 5px 6px; gap: 5px;
  }
  .battle-targets .target-label { flex: 0 0 auto; }
  .battle-target-btn { padding: 4px 7px; font-size: 10px; }
  .battle-targets:not(.hidden) + .battle-log { top: calc(140px + env(safe-area-inset-top, 0px)); }
  .battle-log {
    left: 9px; top: calc(92px + env(safe-area-inset-top, 0px));
    width: calc(100% - 18px); height: 112px;
  }
  .battle-status {
    left: 9px; right: 9px; top: calc(212px + env(safe-area-inset-top, 0px));
    width: auto; max-height: 112px;
  }
  .battle-log-head, .battle-status-head { padding: 6px 8px; font-size: 13px; letter-spacing: 2px; }
  .battle-log-list { padding: 6px 8px; font-size: 10.5px; line-height: 1.5; }
  .battle-status-list { padding: 5px 8px; max-height: 82px; }
  .battle-status-row { padding: 5px 0 6px; }
  .battle-skills {
    left: 6px; right: 6px; bottom: calc(6px + var(--mobile-safe-bottom));
    width: auto; transform: none;
    gap: 4px;
  }
  .battle-skill-row { grid-template-columns: repeat(9, minmax(0, 1fr)); gap: 3px; }
  .skill-btn { width: auto; height: 44px; gap: 0; }
  .skill-btn b { max-width: 100%; font-size: 10px; }
  .skill-btn small { max-width: 100%; font-size: 7px; }
  .skill-btn .skill-key { top: 2px; left: 3px; font-size: 8px; }
  .skill-btn .cd { font-size: 14px; }
  .battle-result { min-width: 0; width: calc(100% - 24px); padding: 18px 14px; }
  .battle-result h3 { font-size: 26px; letter-spacing: 4px; }
  .battle-result p { font-size: 11px; }
  .loadout-options { grid-template-columns: 1fr 1fr; max-height: none; }

  /* 通用表单 */
  input, select { font-size: 16px; }
  .btn { padding: 9px 12px; }
  .btn.big { padding: 12px 18px; font-size: 16px; }
  .window .tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    overflow-x: visible;
  }
  .window .tabs .tab { flex: 0 0 auto; padding: 7px 9px; font-size: 11px; }
  .tabs { overflow-x: auto; }
  .tab { flex: none; padding: 6px 10px; }
  .tooltip { max-width: calc(100vw - 20px); font-size: 10.5px; line-height: 1.5; }
}

@media (max-width: 380px) and (orientation: portrait) {
  .mall-tabs { flex-wrap: wrap; overflow-x: visible; }
  .mall-tab { flex: 1 1 45%; }
}

/* 矮屏优先保证列表与底部聊天不叠压；角色仍从列表下沿露出并让腿部压到聊天区。 */
@media (max-width: 720px) and (orientation: portrait) and (max-height: 779px) {
  body.mobile-portrait.scene-field .mob-board {
    top: calc(206px + env(safe-area-inset-top, 0px));
  }
  body.mobile-portrait #hotspot-layer {
    top: calc(198px + env(safe-area-inset-top, 0px));
    width: 166px;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 4px;
  }
  body.mobile-portrait #hotspot-layer .hotspot {
    min-height: 40px;
    padding: 3px 4px;
    gap: 4px;
  }
  body.mobile-portrait #hotspot-layer .hotspot .pin { width: 22px; height: 22px; font-size: 9px; }
  body.mobile-portrait #hotspot-layer .hotspot .label { font-size: 8.5px; line-height: 1.15; }
  body.mobile-portrait #hotspot-layer .hotspot .label small { display: none; }
  body.mobile-portrait .hud-left {
    top: calc(198px + env(safe-area-inset-top, 0px));
    right: 180px;
    max-height: 126px;
  }
}

/* 极矮应用内窗口：压缩 HUD 与聊天区，保证文字表、聊天输入框、底部按钮同屏且不互相覆盖。 */
@media (max-width: 720px) and (orientation: portrait) and (max-height: 560px) {
  body.mobile-portrait .hud-top {
    gap: 4px;
    padding-top: calc(5px + env(safe-area-inset-top, 0px));
    padding-bottom: 4px;
  }
  body.mobile-portrait .player-card { padding: 5px 8px 5px 6px; gap: 7px; }
  body.mobile-portrait .avatar { width: 38px; height: 38px; }
  body.mobile-portrait .avatar span { font-size: 17px; }
  body.mobile-portrait .player-meta strong { font-size: 14px; }
  body.mobile-portrait .bar { height: 9px; }
  body.mobile-portrait .bar span { font-size: 7px; line-height: 8px; }
  body.mobile-portrait .money b { font-size: 12px; }
  body.mobile-portrait .map-title { display: none; }
  body.mobile-portrait .hud-action.dock-btn { height: 38px; }
  body.mobile-portrait .hud-action.dock-btn b { font-size: 11px; }
  body.mobile-portrait .hud-action.dock-btn em { font-size: 8px; }

  /* 主城设施在极矮窗口改成右侧 2×3 紧凑入口，不压住底部聊天。 */
  body.mobile-portrait #hotspot-layer {
    top: calc(122px + env(safe-area-inset-top, 0px));
    width: 166px;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 4px;
  }
  body.mobile-portrait #hotspot-layer .hotspot {
    min-height: 40px;
    padding: 3px 4px;
    gap: 4px;
  }
  body.mobile-portrait #hotspot-layer .hotspot .pin { width: 22px; height: 22px; font-size: 9px; }
  body.mobile-portrait #hotspot-layer .hotspot .label { font-size: 8.5px; line-height: 1.15; }
  body.mobile-portrait #hotspot-layer .hotspot .label small { display: none; }

  body.mobile-portrait .hud-left {
    top: calc(122px + env(safe-area-inset-top, 0px));
    right: 180px;
    max-height: 126px;
  }

  body.mobile-portrait.scene-field .mob-board {
    top: calc(132px + env(safe-area-inset-top, 0px));
    max-height: calc(100dvh - 230px);
  }
  body.mobile-portrait .mob-board-head { min-height: 30px; padding: 2px 8px; gap: 0 6px; }
  body.mobile-portrait .mob-board-title b { font-size: 15px; letter-spacing: 2px; }
  body.mobile-portrait .mob-board-tools button { font-size: 10px; padding: 3px 4px; }
  body.mobile-portrait .mob-board-sub { font-size: 8px; line-height: 10px; }
  body.mobile-portrait .mob-table-head { min-height: 16px; font-size: 8px; }
  body.mobile-portrait .mob-text-row { height: 30px; }
  body.mobile-portrait .mob-text-row .mob-name { font-size: 12px; }
  body.mobile-portrait .mob-text-row .mob-year,
  body.mobile-portrait .mob-text-row .mob-domain,
  body.mobile-portrait .mob-text-row .mob-hp { font-size: 9px; }
  body.mobile-portrait .mob-text-row .mob-state { font-size: 10px; }
  body.mobile-portrait .mob-board-foot { min-height: 26px; padding: 0 6px; font-size: 9px; }
  body.mobile-portrait .mob-board-foot button { padding: 4px 5px; font-size: 10px; }

  body.mobile-portrait .hud-bottom { gap: 4px; bottom: calc(6px + var(--mobile-safe-bottom)); }
  body.mobile-portrait .chat { gap: 2px; }
  body.mobile-portrait .chat-log {
    height: 26px;
    font-size: 8.5px;
    line-height: 1.35;
    padding: 2px 5px 0;
  }
  body.mobile-portrait .chat-input select { width: 58px; padding: 6px 2px; font-size: 10px; }
  body.mobile-portrait .chat-input input { padding: 7px; font-size: 12px; }
  body.mobile-portrait .chat-input .btn.tiny { padding: 5px 7px; font-size: 10px; }
  body.mobile-portrait .dock { gap: 4px; }
  body.mobile-portrait .dock-btn { height: 38px; }
  body.mobile-portrait .dock-btn b { font-size: 11px; }
  body.mobile-portrait .dock-btn em { font-size: 7px; }
}

/* ---------- 新版大陆地图：手机竖屏（与 PC 共用底图坐标） ---------- */
@media (max-width: 720px) and (orientation: portrait) {
  .window.worldmap-window {
    width: 100% !important; max-width: 100% !important; left: 0 !important; right: 0 !important;
    height: 100dvh !important; max-height: 100dvh !important;
  }
  .worldmap-window .win-body { overflow-y: auto; overflow-x: hidden; }
  .worldmap-shell { height: auto; min-height: 100%; }
  .worldmap-toolbar { padding: 6px 10px; gap: 8px; }
  .worldmap-tab { padding: 6px 10px; font-size: 11px; }
  .worldmap-status { display: none; }
  .worldmap-stage-wrap { flex: none; overflow: visible; padding: 0; }
  .worldmap-stage { aspect-ratio: 2048 / 1152; border-left: 0; border-right: 0; }
  .worldmap-region { display: none; }
  .worldmap-region em { display: none; }
  .worldmap-point { padding: 5px 3px; }
  .wm-dot { width: 6px; height: 6px; }
  .worldmap-point.major .wm-dot { width: 8px; height: 8px; }
  .wm-name { display: none; }
  .worldmap-point.major .wm-name { display: none; }
  .worldmap-point.selected .wm-name, .worldmap-point.current .wm-name { display: block !important; font-size: 8px; letter-spacing: 0; }
  .worldmap-compass { right: 8px; bottom: 8px; width: 26px; height: 26px; }
  .worldmap-compass span { font-size: 10px; }
  .worldmap-mobile-list { display: block; padding: 10px 10px 4px; }
  .wm-mobile-region { margin-bottom: 9px; }
  .wm-mobile-region > b {
    display: block; margin-bottom: 5px; color: #dcc38f; font-family: 'XinWei', serif;
    font-size: 13px; font-weight: 400; letter-spacing: 2px;
  }
  .wm-mobile-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; }
  .wm-mobile-map {
    min-width: 0; padding: 7px 8px; text-align: left; cursor: pointer;
    border: 1px solid rgba(217, 178, 95, .17); background: rgba(13, 24, 35, .68);
    color: #cfdae4;
  }
  .wm-mobile-map span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11px; }
  .wm-mobile-map em { display: block; margin-top: 3px; color: #788a9b; font-style: normal; font-size: 8px; }
  .wm-mobile-map.current { border-color: rgba(217, 178, 95, .5); background: rgba(71, 56, 26, .28); }
  .wm-mobile-map.selected { border-color: #d9b25f; box-shadow: inset 0 0 0 1px rgba(217, 178, 95, .28); }
  .wm-mobile-map.locked { opacity: .48; }
  .worldmap-detail {
    position: sticky; bottom: 0; z-index: 20; flex-wrap: wrap;
    padding: 8px 10px calc(8px + env(safe-area-inset-bottom, 0px)); gap: 7px;
  }
  .wm-detail-copy { flex: 1 1 55%; }
  .wm-detail-copy b { font-size: 14px; }
  .wm-detail-copy span { font-size: 9px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .wm-detail-tags { display: none; }
  .wm-enter { margin-left: auto; padding: 8px 11px; font-size: 11px; }

  /* ---------- 势力领地 ---------- */
  .territory-hero.faction {
    grid-template-columns: 62px minmax(0, 1fr);
    gap: 12px;
    padding: 14px;
  }
  .territory-emblem { width: 58px; height: 58px; }
  .territory-emblem b { font-size: 28px; }
  .territory-emblem span { display: none; }
  .territory-emblem::before, .territory-emblem::after { width: 5px; height: 5px; }
  .territory-hero.faction .territory-title h3 { font-size: 22px; letter-spacing: 3px; }
  .territory-hero.faction .territory-title p { font-size: 11px; }
  .territory-kicker { font-size: 9px; letter-spacing: 1px; }
  .territory-tags { gap: 4px; margin-top: 8px; }
  .territory-tags span { padding: 2px 6px; font-size: 8px; }
  .territory-counter {
    grid-column: 1 / -1; flex-direction: row; align-items: baseline; justify-content: flex-start;
    gap: 8px; min-height: 0; padding: 8px 10px;
  }
  .territory-counter b { font-size: 24px; }
  .territory-counter span { margin-top: 0; font-size: 10px; letter-spacing: 1px; }
  .territory-counter em { margin-top: 0; margin-left: auto; }
  .territory-section-head { align-items: flex-start; }
  .territory-section-tag { display: none; }
  .territory-boss-grid { grid-template-columns: 1fr; }
  .territory-boss { padding: 9px 10px 8px; }
  .territory-pool-grid { grid-template-columns: 1fr; max-height: 260px; }
  .tp-drop { max-width: 130px; }
  .territory-foot { flex-wrap: wrap; gap: 8px; }
  .territory-foot .btn { width: 100%; min-width: 0; }
}
