* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Microsoft YaHei', sans-serif;
}

.hidden {
    display: none !important;
}

/* 优化网页中像素与切图的缩放渲染，防止 WebView 拉伸导致的模糊 */ 
html, body, canvas, img, 
.equip-slot, 
.inv-grid-item, 
.inv-qty-badge, 
.minimap-bg-asset, 
.hud-avatar-frame, 
.hud-minimap-frame-v2, 
.hud-menu-btn img, 
.hud-chat-btn img,
.selected::after {
    image-rendering: -moz-crisp-edges;         /* Firefox */
    image-rendering: -webkit-optimize-contrast; /* Safari / iOS WebView */
    image-rendering: crisp-edges;              /* CSS3 标准 */
    image-rendering: pixelated;                /* Chrome / Android WebView */
}


:root {
    --app-vh: 1vh;
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-right: env(safe-area-inset-right, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --safe-left: env(safe-area-inset-left, 0px);
}

body {
    background-color: #2c3e50;
    display: flex;
    justify-content: center;
    align-items: center;
    height: calc(var(--app-vh) * 100);
    overflow: hidden;
    padding-top: var(--safe-top);
    padding-right: var(--safe-right);
    padding-bottom: var(--safe-bottom);
    padding-left: var(--safe-left);
}

#game-container {
    position: relative;
    width: 100vw;
    height: 100vh;
    background-color: #000;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
}

#game-canvas {
    display: block;
    width: 100%;
    height: 100%;
    image-rendering: auto;
    image-rendering: -webkit-optimize-contrast;
    filter: contrast(1.05) saturate(1.08) brightness(1.01);
}

#ui-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    /* 让点击穿透UI层到Canvas，子元素需要恢复pointer-events */
}

.ui-panel {
    pointer-events: auto;
    background: rgba(0, 0, 0, 0.3);
    /* 更透明 */
    border: none;
    /* 去掉粗边框 */
    color: #fff;
    padding: 10px;
}

/* ===================================================
   全新 HUD 系统 (根据参考图复刻)
   =================================================== */

.hud-container {
    position: absolute;
    pointer-events: auto;
    display: flex;
    z-index: 100;
}

/* --- 左上角：角色状态栏 --- */
#player-hud-top-left {
    top: calc(10px + var(--safe-top));
    left: calc(10px + var(--safe-left));
    align-items: flex-start;
    gap: 10px;
}

/* 双倍攻防状态：紧贴角色血条下方，横竖屏均常驻显示。 */
.hud-double-buff {
    position: fixed;
    top: calc(98px + var(--safe-top));
    left: calc(14px + var(--safe-left));
    z-index: 2147482971;
    display: flex;
    align-items: center;
    gap: 6px;
    min-height: 22px;
    padding: 3px 8px;
    border: 1px solid #d8ab43;
    border-radius: 12px;
    color: #fff6d2;
    background: linear-gradient(135deg, rgba(50, 24, 15, .92), rgba(20, 35, 48, .92));
    box-shadow: 0 2px 7px rgba(0,0,0,.52), inset 0 0 0 1px rgba(255,238,169,.14);
    font-size: 12px;
    font-weight: 800;
    text-shadow: 0 1px 2px #000;
    pointer-events: none;
}
.hud-double-buff.hidden { display: none !important; }
.hud-double-buff i { height: 13px; width: 1px; background: rgba(255,232,157,.55); }
.double-buff-atk { color: #ff9f8e; }
.double-buff-def { color: #93d9ff; }

.hud-avatar-frame {
    position: relative;
    width: 84px;
    height: 84px;
    background: rgba(0, 0, 0, 0.6);
    border: 3px solid #5d4037;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
}

.hud-avatar-frame img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

#hud-player-level {
    position: absolute;
    bottom: -5px;
    right: -5px;
    background: #fff;
    color: #333;
    border: 2px solid #5d4037;
    border-radius: 4px;
    padding: 2px 6px;
    font-size: 16px;
    font-weight: bold;
    font-style: italic;
    box-shadow: 1px 1px 3px rgba(0, 0, 0, 0.5);
    z-index: 10;
}

.hud-status-bars {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding-top: 5px;
}

.hud-bar-container {
    position: relative;
    width: 180px;
    height: 24px;
    background: #333;
    border: 2px solid #5d4037;
    border-radius: 4px;
    overflow: hidden;
}

.hud-bar-fill {
    height: 100%;
    width: 100%;
    transition: width 0.3s ease;
}

.hp .hud-bar-fill {
    background: linear-gradient(to right, #e74c3c, #c0392b);
}

.mp .hud-bar-fill {
    background: linear-gradient(to right, #3498db, #2980b9);
}

.hud-bar-text {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    color: #fff;
    font-size: 14px;
    font-weight: bold;
    text-shadow: 1px 1px 2px #000;
}

/* --- 左侧：队伍状态栏 --- */
#team-hud {
    position: absolute;
    top: calc(110px + var(--safe-top));
    left: calc(10px + var(--safe-left));
    z-index: 90;
    background: rgba(30, 20, 10, 0.7);
    border: 1px solid #5d4037;
    border-radius: 4px;
    padding: 4px;
    width: 120px;
    pointer-events: auto;
}

.team-hud-title {
    color: #f1c40f;
    font-size: 11px;
    font-weight: bold;
    text-align: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
    padding-bottom: 2px;
    margin-bottom: 2px;
}

.team-member {
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid #3d2b27;
    border-radius: 4px;
    padding: 4px;
    margin-bottom: 4px;
}

.team-member .tm-name {
    color: #ecf0f1;
    font-size: 12px;
    font-weight: bold;
    display: flex;
    justify-content: space-between;
    margin-bottom: 3px;
}

.team-member .tm-leader-icon {
    color: #f1c40f;
    font-size: 12px;
}

.tm-bar-bg {
    width: 100%;
    height: 4px;
    background: rgba(0, 0, 0, 0.6);
    border-radius: 2px;
    margin-bottom: 1px;
    overflow: hidden;
}

.tm-hp-fill {
    height: 100%;
    background: linear-gradient(to right, #e74c3c, #c0392b);
    transition: width 0.3s;
}

.tm-mp-fill {
    height: 100%;
    background: linear-gradient(to right, #3498db, #2980b9);
    transition: width 0.3s;
}

/* 竖屏：组队面板下移，避免被"仙途历练"挂签遮挡 [退] 按钮 */
.screen-mode-portrait #team-hud {
    top: calc(150px + var(--safe-top)) !important;
    z-index: 95 !important;
}

/* --- 右上角：地图与任务 --- */
#map-hud-top-right {
    top: calc(10px + var(--safe-top));
    right: calc(10px + var(--safe-right));
    flex-direction: column;
    align-items: flex-end;
    gap: 8px;
}

.hud-minimap-frame-v2 {
    position: relative;
    width: 154px;
    /* 根据资源比例微调 */
}

.minimap-bg-asset {
    width: 100%;
    display: block;
}

#hud-map-name {
    position: absolute;
    top: 6px;
    left: 0;
    width: 100%;
    text-align: center;
    color: #ffd700;
    font-weight: bold;
    font-size: 14px;
    text-shadow: 1px 1px 2px #000;
    pointer-events: none;
}

#hud-minimap-render {
    position: absolute;
    top: 32px;
    left: 14px;
    right: 14px;
    bottom: 12px;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    background: transparent;
}

#minimap-canvas {
    width: 120px;
    height: 120px;
    background: transparent;
}

#hud-quest-tracker {
    width: 140px;
    background: rgba(60, 40, 20, 0.7);
    border: 1px solid #5d4037;
    padding: 8px;
    color: #eee;
}

.quest-header {
    color: #f1c40f;
    font-weight: bold;
    font-size: 14px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
    padding-bottom: 4px;
    margin-bottom: 5px;
}

.quest-title {
    font-size: 13px;
    color: #fff;
    margin-bottom: 2px;
}

.quest-desc {
    font-size: 11px;
    color: #ccc;
}

/* --- 顶部中右：功能按键 --- */
#function-menu-top {
    top: calc(10px + var(--safe-top));
    right: calc(170px + var(--safe-right));
    gap: 15px;
}

.hud-menu-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
    transition: transform 0.1s;
}

.hud-menu-btn:hover {
    transform: scale(1.1);
}

.hud-menu-btn img {
    width: 64px;
    height: 64px;
}

/* 顶部功能快捷栏：折叠状态 */
#function-menu-top.is-collapsed .hud-menu-btn:not(#function-menu-collapse-btn) {
    display: none !important;
}

#function-menu-collapse-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    background: linear-gradient(135deg, rgba(61, 36, 17, 0.9), rgba(26, 15, 7, 0.9));
    border: 1.5px solid #d4af37;
    border-radius: 8px;
    padding: 4px 6px;
    color: #ffd700;
    min-width: 42px;
    min-height: 42px;
    box-shadow: 0 3px 8px rgba(0,0,0,0.5);
    transition: all 0.2s ease;
    user-select: none;
}
#function-menu-collapse-btn:hover {
    transform: scale(1.08);
    box-shadow: 0 0 10px rgba(212, 175, 55, 0.6);
}
#function-menu-collapse-icon {
    font-size: 14px;
    line-height: 1;
    font-weight: bold;
}
#function-menu-collapse-text {
    font-size: 10px;
    line-height: 1;
    margin-top: 2px;
    font-weight: bold;
}

/* --- 左下角：聊天系统 --- */
#chat-hud-bottom-left {
    bottom: calc(15px + var(--safe-bottom));
    left: calc(15px + var(--safe-left));
    flex-direction: column;
    gap: 8px;
    max-width: 320px;
    width: 40%;
}

#hud-chat-logs {
    background: rgba(0, 0, 0, 0.3);
    padding: 10px;
    border-radius: 8px;
    max-height: 150px;
    overflow-y: hidden;
    pointer-events: none;
}

.chat-line {
    color: #fff;
    font-size: 13px;
    margin-bottom: 4px;
    text-shadow: 1px 1px 1px #000;
}

.chat-line .name {
    color: #f1c40f;
    margin-right: 5px;
}

#hud-chat-btn-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
}

.hud-chat-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
}

.hud-chat-btn img {
    width: 52px;
    height: 52px;
}

#hud-currency-quick {
    color: #f1c40f;
    font-weight: bold;
    font-size: 14px;
    text-shadow: 1px 1px 2px #000;
}

/* --- 右下角：主菜单 --- */
#main-menu-bottom-right {
    bottom: calc(15px + var(--safe-bottom));
    right: calc(56px + var(--safe-right));
    gap: 8px;
}

/* --- 右下角：HUD 界面一键收缩/展开浮动按钮 --- */
#hud-collapse-toggle {
    position: absolute;
    bottom: calc(16px + var(--safe-bottom));
    right: calc(10px + var(--safe-right));
    z-index: 105;
    background: rgba(30, 20, 10, 0.85);
    border: 1.5px solid #d4af37;
    border-radius: 6px;
    padding: 4px 3px;
    height: 54px;
    width: 32px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.6), inset 0 0 6px rgba(212, 175, 55, 0.2);
    user-select: none;
    transition: all 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
    pointer-events: auto;
}

#hud-collapse-toggle:hover {
    background: rgba(45, 30, 15, 0.95);
    border-color: #ffd700;
    box-shadow: 0 0 10px rgba(255, 215, 0, 0.5);
    transform: scale(1.06);
}

#hud-collapse-icon {
    font-size: 13px;
    color: #ffd700;
    line-height: 1;
    font-weight: bold;
    transition: transform 0.3s ease;
}

#hud-collapse-text {
    font-size: 10px;
    color: #f5ebe0;
    font-weight: bold;
    margin-top: 3px;
    white-space: nowrap;
    text-shadow: 1px 1px 2px #000;
}

/* 处于收缩（沉浸纯净模式）状态时的按钮样式 */
#hud-collapse-toggle.collapsed-mode {
    background: rgba(18, 12, 8, 0.94);
    border-color: #00f5d4;
    box-shadow: 0 0 12px rgba(0, 245, 212, 0.45);
    animation: hud-glow-pulse 2s infinite ease-in-out;
}

#hud-collapse-toggle.collapsed-mode #hud-collapse-icon {
    color: #00f5d4;
}

#hud-collapse-toggle.collapsed-mode #hud-collapse-text {
    color: #00f5d4;
}

@keyframes hud-glow-pulse {
    0%, 100% {
        box-shadow: 0 0 6px rgba(0, 245, 212, 0.3);
    }
    50% {
        box-shadow: 0 0 14px rgba(0, 245, 212, 0.7);
    }
}

/* --- 全局 HUD 平滑展开/收缩过渡 --- */
#player-hud-top-left,
#team-hud,
#function-menu-top,
#map-hud-top-right,
#chat-hud-bottom-left,
#main-menu-bottom-right,
#hud-exp-bar-container {
    transition: transform 0.35s cubic-bezier(0.2, 0.8, 0.2, 1), opacity 0.35s ease, pointer-events 0.35s ease;
}

/* 当 ui-layer 处于 hud-collapsed 状态时，四大角落的 UI 全部平滑收缩离开屏幕 */
.hud-collapsed #player-hud-top-left,
.hud-collapsed #team-hud {
    transform: translate3d(-140%, 0, 0) !important;
    opacity: 0 !important;
    pointer-events: none !important;
}

.hud-collapsed #function-menu-top {
    transform: translate3d(0, -150%, 0) !important;
    opacity: 0 !important;
    pointer-events: none !important;
}

.hud-collapsed #map-hud-top-right {
    transform: translate3d(140%, 0, 0) !important;
    opacity: 0 !important;
    pointer-events: none !important;
}

.hud-collapsed #chat-hud-bottom-left {
    transform: translate3d(-140%, 0, 0) !important;
    opacity: 0 !important;
    pointer-events: none !important;
}

.hud-collapsed #main-menu-bottom-right {
    transform: translate3d(140%, 0, 0) !important;
    opacity: 0 !important;
    pointer-events: none !important;
}

.hud-collapsed #hud-exp-bar-container {
    opacity: 0 !important;
    pointer-events: none !important;
}

/* 覆盖旧 UIPanel 的透明度 */
.ui-panel {
    background: rgba(30, 20, 10, 0.9) !important;
    border: 2px solid #5d4037 !important;
}

#chat-input-wrap {
    display: flex;
    gap: 4px;
    padding: 4px;
    background: rgba(0, 0, 0, 0.4);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

#chat-input {
    flex: 1;
    background: rgba(30, 20, 10, 0.8);
    border: 1px solid #5d4037;
    color: #fff;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 13px;
    outline: none;
}

#chat-input:focus {
    border-color: #f1c40f;
}

#chat-send-btn {
    background: linear-gradient(135deg, #e67e22, #d35400);
    border: 1px solid #5d4037;
    color: white;
    padding: 0 10px;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
}

#battle-log {
    list-style: none;
}

#battle-log li {
    margin-bottom: 2px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    line-height: 1.4;
}

/* 任务追踪面板 */
#quest-tracker {
    position: absolute;
    top: 80px;
    left: 10px;
    width: 160px;
    /* 缩小面板宽度 */
    background: rgba(0, 0, 0, 0.5);
    pointer-events: none;
    z-index: 40;
}

#quest-tracker h3 {
    color: #f1c40f;
    font-size: 14px;
    border-bottom: 1px solid #555;
    padding-bottom: 5px;
    margin-bottom: 5px;
}

/* 角色面板宽度优化 */
#hero-inventory-panel {
    width: 780px;
    height: 500px;
    display: flex;
    padding: 0;
    flex-direction: column;
    background: rgba(20, 10, 5, 0.95);
}

.modal-panel {
    pointer-events: auto;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: #3e2723;
    border: 4px solid #8d6e63;
    border-radius: 10px;
    color: white;
    padding: 20px;
    display: flex;
    flex-direction: column;
    z-index: 2147483000 !important;
    /* 调高至2147483000，确保高于全局半透明遮罩层 (2147482995) 与所有HUD层 */
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.9);
}

.hidden {
    display: none !important;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid #5d4037;
    padding-bottom: 10px;
    margin-bottom: 10px;
    flex-shrink: 0;
}

.close-btn {
    background: #c0392b;
    color: white;
    border: none;
    width: 24px;
    height: 24px;
    border-radius: 12px;
    cursor: pointer;
    font-weight: bold;
}

#create-role-panel {
    text-align: center;
}

.role-select {
    margin: 20px 0;
    display: flex;
    justify-content: space-around;
}

#role-name-input {
    width: 80%;
    padding: 8px;
    margin-bottom: 20px;
    background: #1a1a1a;
    border: 1px solid #8d6e63;
    color: #fff;
}

#create-role-panel button {
    padding: 10px 30px;
    background: #27ae60;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 16px;
    font-weight: bold;
}

/* 商城列表样式 */
.shop-item {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid #795548;
    padding: 10px;
    margin-bottom: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.shop-item-info h4 {
    color: #ffeb3b;
    margin-bottom: 5px;
}

.shop-item-info p {
    font-size: 12px;
    color: #ccc;
}

.buy-btn {
    background: #e67e22;
    color: white;
    border: none;
    padding: 5px 15px;
    border-radius: 3px;
    cursor: pointer;
}

.shop-filter-bar {
    padding: 2px;
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
    align-items: center;
}

.shop-filter-bar::-webkit-scrollbar {
    display: none;
}

.shop-filter-bar .filter-btn {
    background: #4e342e;
    color: #bdc3c7;
    border: 1px solid #5d4037;
    padding: 4px 8px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 11px;
    flex-shrink: 0;
    transition: all 0.15s ease;
}

.shop-filter-bar .filter-btn:hover {
    background: #5d4037;
    color: #fff;
}

.shop-filter-bar .filter-btn.active {
    background: #f39c12;
    color: #fff;
    border-color: #f1c40f;
    font-weight: bold;
}

/* 大厂手游风 - 右侧纵向 Tab 导航栏 (参考经典手游商城 - 亮湛蓝调) */
.shop-side-tab {
    background: linear-gradient(90deg, #16375f, #112743);
    color: #a4caf0;
    border: 1px solid #1f4570;
    padding: 12px 6px;
    text-align: center;
    font-size: 13px;
    font-weight: bold;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.15s ease;
    display: flex;
    justify-content: center;
    align-items: center;
    letter-spacing: 1px;
}

.shop-side-tab:hover {
    background: linear-gradient(90deg, #224d80, #193a63);
    color: #ffffff;
}

.shop-side-tab.active {
    background: linear-gradient(90deg, #2980b9, #3498db);
    color: #ffffff;
    border: 1px solid #5dade2;
    border-left: 4px solid #f1c40f;
    box-shadow: 0 0 14px rgba(52, 152, 219, 0.6);
    transform: translateX(-2px);
}

.shop-side-tab.points-tab {
    background: linear-gradient(90deg, #d35400, #e67e22);
    color: #ffffff;
    border-color: #f39c12;
}

.shop-side-tab.points-tab.active {
    background: linear-gradient(90deg, #e74c3c, #c0392b);
    border-color: #f1c40f;
    box-shadow: 0 0 12px rgba(231, 76, 60, 0.5);
    transform: translateX(-2px);
}

/* 综合面板左侧装备孔位 */
.equip-slot {
    width: 48px !important;
    height: 48px !important;
    background-size: 100% 100% !important;
    background-repeat: no-repeat !important;
    background-position: center !important;
    border: none !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    background-color: transparent !important;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    position: relative;
    transition: all 0.2s;
}

.equip-slot img {
    width: 32px !important;
    height: 32px !important;
    max-width: 32px !important;
    max-height: 32px !important;
    object-fit: contain !important;
    image-rendering: pixelated !important;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.45));
}

/* Empty slot backgrounds */
#eq-head { background-image: url('https://pics.fj1008611.cn/xcx/game/img/ui/bbtk.png') !important; }
#eq-armor { background-image: url('https://pics.fj1008611.cn/xcx/game/img/ui/bbyf.png') !important; }
#eq-belt { background-image: url('https://pics.fj1008611.cn/xcx/game/img/ui/bbys.png') !important; }
#eq-shoes { background-image: url('https://pics.fj1008611.cn/xcx/game/img/ui/bbxz.png') !important; }
#eq-weapon { background-image: url('https://pics.fj1008611.cn/xcx/game/img/ui/bbwq.png') !important; }
#eq-necklace { background-image: url('https://pics.fj1008611.cn/xcx/game/img/ui/bbxl.png') !important; }
#eq-ring { background-image: url('https://pics.fj1008611.cn/xcx/game/img/ui/bbjz.png') !important; }
#eq-accessory { background-image: url('https://pics.fj1008611.cn/xcx/game/img/ui/bbtx.png') !important; }

/* Equipped slot quality backgrounds */
.equip-slot.q-normal { background-image: url('https://pics.fj1008611.cn/xcx/game/img/ui/bbzbwpz.png') !important; }
.equip-slot.q-good { background-image: url('https://pics.fj1008611.cn/xcx/game/img/ui/bbzbls.png') !important; }
.equip-slot.q-rare { background-image: url('https://pics.fj1008611.cn/xcx/game/img/ui/bbzbzs.png') !important; }
.equip-slot.q-epic { background-image: url('https://pics.fj1008611.cn/xcx/game/img/ui/bbzbhs.png') !important; }
.equip-slot.q-artifact { background-image: url('https://pics.fj1008611.cn/xcx/game/img/ui/cs.png') !important; }

.equip-slot:hover {
    filter: brightness(1.2);
    transform: scale(1.05);
}

.equip-slot .slot-bg {
    display: none !important;
}

/* 综合面板右侧包裹网格里的独立物品格子 */
.inv-grid-item {
    background: url('https://pics.fj1008611.cn/xcx/game/img/ui/bbpt.png') no-repeat center center;
    background-size: 100% 100% !important;
    border: 1px solid rgba(93, 64, 55, 0.3) !important;
    border-radius: 4px !important;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1) !important;
    background-color: transparent !important;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    cursor: pointer;
    transition: all 0.2s ease;
}

.inv-grid-item:hover {
    filter: brightness(1.15);
    transform: scale(1.05);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    border-color: rgba(243, 156, 18, 0.6) !important;
}

/* Item grid item quality backgrounds */
.inv-grid-item.q-normal { background-image: url('https://pics.fj1008611.cn/xcx/game/img/ui/bbbs.png') !important; }
.inv-grid-item.q-good { background-image: url('https://pics.fj1008611.cn/xcx/game/img/ui/bbls.png') !important; }
.inv-grid-item.q-rare { background-image: url('https://pics.fj1008611.cn/xcx/game/img/ui/bbzs.png') !important; }
.inv-grid-item.q-epic { background-image: url('https://pics.fj1008611.cn/xcx/game/img/ui/bbhs.png') !important; }
.inv-grid-item.q-artifact { background-image: url('https://pics.fj1008611.cn/xcx/game/img/ui/cs.png') !important; }

.inv-grid-item-inner {
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    color: white;
    font-size: 11px;
    font-weight: bold;
    text-align: center;
    text-shadow: 1px 1px 2px #000;
    pointer-events: none;
    border: none !important;
}

/* 物品选中高亮边框 */
.inv-grid-item.selected::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url('https://pics.fj1008611.cn/xcx/game/img/ui/bbwp.png') no-repeat center center;
    background-size: 100% 100% !important;
    pointer-events: none;
    z-index: 10;
}

/* 物品堆叠数量标记 */
.inv-qty-badge {
    position: absolute;
    bottom: 3px;
    right: 3px;
    width: 20px;
    height: 20px;
    background: linear-gradient(135deg, #f39c12, #e67e22);
    color: #ffffff !important;
    font-size: 11px;
    font-family: "Courier New", Courier, monospace, sans-serif;
    font-weight: bold;
    display: flex;
    justify-content: center;
    align-items: center;
    text-shadow: 1px 1px 1px #000;
    pointer-events: none;
    z-index: 15;
    padding-top: 1px;
    box-sizing: border-box;
    border-radius: 50%;
    border: 2px solid #fff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

/* 物品绑定标记 (左上角红底白字) */
.inv-bind-badge {
    position: absolute;
    top: 3px;
    left: 3px;
    background: linear-gradient(135deg, #e74c3c, #c0392b);
    color: #ffffff;
    font-size: 9.5px;
    line-height: 1;
    padding: 2px 4px;
    border-radius: 3px;
    font-weight: bold;
    text-shadow: 1px 1px 1px rgba(0, 0, 0, 0.8);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
    pointer-events: none;
    z-index: 15;
    border: 1px solid rgba(255, 255, 255, 0.3);
}

/* 背包物品网格容器 */
#inventory-grid {
    flex: 1;
    padding: 10px;
    overflow-y: auto;
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 6px;
    grid-auto-rows: 60px;
    background: linear-gradient(135deg, rgba(239, 228, 213, 0.95), rgba(223, 216, 200, 0.95));
    border-radius: 6px;
}

#hero-avatar-wrap {
    position: absolute !important;
    left: 50% !important;
    top: 43% !important; /* pulled up from 50% */
    transform: translate(-50%, -50%) !important;
    width: 120px !important;
    height: 200px !important;
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
}

.equip-slots-col {
    position: absolute !important;
    top: 68px !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 16px !important;
}
.equip-slots-col.left-col {
    left: 12px !important;
}
.equip-slots-col.right-col {
    right: 12px !important;
}

/* 物品数量角标 */
.inv-item-count {
    position: absolute;
    bottom: 2px;
    right: 4px;
    color: #fff;
    text-shadow: 1px 1px 2px #000;
    box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.8);
    transition: background 0.2s;
}

/* 物品操作悬浮菜单 */
#item-action-menu {
    pointer-events: auto;
    z-index: 2147483500 !important;
}

/* 玩家交互菜单与交易弹窗 */
#player-interaction-menu,
#trade-modal {
    pointer-events: auto;
    z-index: 999999 !important;
}

#game-prompt-overlay,
#game-confirm-overlay,
#custom-prompt-modal,
#rename-modal-overlay,
#title-modal,
#fine-reset-modal,
#bulk-chest-result-overlay,
#pet-rename-modal,
#pet-feed-modal,
#pet-release-modal,
#synth-item-picker-modal,
#consignment-detail-modal,
#rps-result-modal,
#ai-prompt-overlay,
#sms-modal-overlay {
    pointer-events: auto;
    z-index: 2147483600 !important;
}

#item-action-menu .action-btn,
#item-action-menu button {
    pointer-events: auto;
    cursor: pointer;
    width: 100%;
    border: 1px solid #555;
    border-radius: 3px;
    padding: 6px 5px;
    font-size: 13px;
    font-weight: bold;
    color: #fff;
    background: rgba(0, 0, 0, 0.5);
    margin-bottom: 4px;
}

#item-action-menu .action-btn:hover,
#item-action-menu button:hover {
    filter: brightness(1.3);
}


/* 战斗十字菜单 */
#combat-action-panel {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    pointer-events: auto;
    z-index: 1000;
}

.combat-cross-menu {
    display: grid;
    grid-template-areas:
        ". top ."
        "left center right"
        ". bottom .";
    gap: 8px;
    align-items: center;
    justify-items: center;
}

.cross-slot {
    width: 66px;
    height: 66px;
    border-radius: 50% !important;
    background: radial-gradient(circle, #8a2b2b 0%, #4a1515 100%) !important;
    border: 2px double #dfc29a !important;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.6), inset 0 0 10px rgba(223, 194, 154, 0.25) !important;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    color: #dfc29a !important;
    font-weight: bold;
    font-size: 15px;
    font-family: '楷体', 'KaiTi', 'Georgia', serif;
    text-shadow: 1px 1px 3px rgba(0,0,0,0.9);
    transition: transform 0.15s ease, box-shadow 0.15s ease, filter 0.15s ease !important;
    position: relative;
}

.cross-slot::before {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    right: 2px;
    bottom: 2px;
    border: 1px solid rgba(223, 194, 154, 0.15);
    border-radius: 50%;
    pointer-events: none;
}

.cross-slot:hover {
    transform: scale(1.08);
    background: radial-gradient(circle, #a13d3d 0%, #5a1d1d 100%) !important;
    box-shadow: 0 0 15px rgba(223, 194, 154, 0.5), inset 0 0 12px rgba(223, 194, 154, 0.4) !important;
    filter: brightness(1.25);
}

.cross-slot:active {
    transform: scale(0.94);
}

.cross-slot.center {
    grid-area: center;
    width: 74px;
    height: 74px;
    background: radial-gradient(circle, #b13535 0%, #611515 100%) !important;
    border: 2.5px double #dfc29a !important;
    box-shadow: 0 5px 12px rgba(0, 0, 0, 0.7), inset 0 0 12px rgba(223, 194, 154, 0.3) !important;
    z-index: 10;
}

.cross-slot.center button {
    font-size: 17px !important;
}

.cross-slot.top {
    grid-area: top;
}

.cross-slot.left {
    grid-area: left;
}

.cross-slot.right {
    grid-area: right;
}

.cross-slot.bottom {
    grid-area: bottom;
}

.cross-slot button {
    width: 100%;
    height: 100%;
    background: transparent;
    border: none;
    color: inherit;
    font: inherit;
    cursor: pointer;
}


/* 战斗状态下的 UI 隐藏与简化 */
#ui-layer.battling #player-hud-top-left,
#ui-layer.battling #function-menu-top,
#ui-layer.battling #main-menu-bottom-right,
#ui-layer.battling #map-hud-top-right,
#ui-layer.battling #hud-quest-tracker {
    display: none !important;
}

#ui-layer.battling #map-name-display {
    display: block !important;
}

#map-name-display {
    position: absolute;
    top: 15px;
    right: 20px;
    color: #2ecc71;
    font-size: 16px;
    font-weight: bold;
    text-shadow: 1px 1px 2px #000;
    pointer-events: none;
}

/* ===================================================
   响应式适配：移动端竖屏优先布局
   针对屏幕宽度小于 1024px 的设备
   =================================================== */
@media screen and (max-width: 1024px) {
    body {
        background: #000;
        height: 100vh;
        margin: 0;
        overflow: hidden;
    }

    #game-container {
        width: 100vw !important;
        height: 100vh !important;
        transform: none !important;
        box-shadow: none;
        margin: 0;
    }

    /* ---- 左上角状态栏 (头像与血蓝条) ---- */
    #player-hud-top-left {
        top: calc(10px + var(--safe-top));
        left: calc(15px + var(--safe-left));
        gap: 8px;
    }

    .hud-avatar-frame {
        width: 40px;
        /* 缩小头像框 */
        height: 40px;
        border-width: 2px;
    }

    #hud-player-level {
        font-size: 10px;
        /* 缩小等级文字 */
        padding: 1px 3px;
        bottom: -2px;
        right: -2px;
    }

    .hud-status-bars {
        gap: 6px;
        padding-top: 2px;
    }

    .hud-bar-container {
        width: 110px;
        /* 缩小条宽 */
        height: 14px;
        /* 缩小条高 */
        border-width: 1px;
    }

    .hud-bar-text {
        font-size: 9px;
        /* 缩小数值文字 */
        line-height: 14px;
    }

    /* ---- 顶部中右：功能按键 (排行、社交、商城) ---- */
    #function-menu-top {
        top: calc(10px + var(--safe-top));
        right: calc(180px + var(--safe-right));
        gap: 12px;
    }

    .hud-menu-btn img {
        width: 58px;
        height: 58px;
    }

    /* ---- 右上角：小地图与任务 ---- */
    #map-hud-top-right {
        top: calc(10px + var(--safe-top));
        right: calc(15px + var(--safe-right));
    }

    .hud-minimap-frame-v2 {
        width: 100px;
    }

    #hud-map-name {
        font-size: 10px;
        top: 3px;
    }

    #hud-minimap-render {
        top: 18px;
        left: 8px;
        right: 8px;
        bottom: 7px;
    }

    #minimap-canvas {
        width: 64px;
        height: 64px;
    }

    #hud-quest-tracker {
        width: 90px;
        padding: 4px;
    }

    .quest-header {
        font-size: 13px;
    }

    .quest-title {
        font-size: 12px;
    }

    .quest-desc {
        font-size: 11px;
    }

    /* ---- 左下角：聊天系统 ---- */
    #chat-hud-bottom-left {
        bottom: calc(15px + var(--safe-bottom));
        left: calc(15px + var(--safe-left));
        gap: 4px;
        max-width: 200px;
        /* 极小化宽度 */
    }

    #hud-chat-logs {
        padding: 4px;
        max-height: 75px;
        /* 极小化高度 */
    }

    .chat-line {
        font-size: 10px;
        /* 字体极小化 */
    }

    .hud-chat-btn img {
        width: 42px;
        height: 42px;
    }

    #hud-currency-quick {
        font-size: 13px;
    }

    /* ---- 右下角：主菜单 ---- */
    #main-menu-bottom-right {
        bottom: calc(15px + var(--safe-bottom));
        right: calc(48px + var(--safe-right)) !important;
        gap: 8px !important;
    }

    #main-menu-bottom-right .hud-menu-btn img {
        width: 58px;
        height: 58px;
    }

    /* ---- 弹窗面板适配 ---- */
    .modal-panel {
        max-width: 96vw;
        max-height: 82dvh;
        /* 减小，防止被浏览器刘海/工具栏遮挡 */
        padding: 5px;
        border-width: 2px;
        overflow: hidden;
        display: flex;
        flex-direction: column;
    }

    .modal-panel h2 {
        font-size: 16px !important;
        padding: 6px !important;
    }

    .hero-tab {
        padding: 6px 4px !important;
        font-size: 12px !important;
    }

    #chat-input-wrap,
    .chat-input-row {
        display: flex;
        gap: 8px;
        padding: 4px;
        flex-shrink: 0;
    }

    /* --- 登录/注册面板 --- */
    #login-panel {
        width: min(300px, 88vw) !important;
        max-height: 80dvh !important;
        overflow-y: auto !important;
        padding: 12px !important;
    }

    #login-panel h2 {
        font-size: 15px !important;
        margin-bottom: 6px !important;
    }

    /* --- 创建角色面板（单独缩小）--- */
    #create-role-panel {
        width: min(280px, 86vw) !important;
        max-height: 75dvh !important;
        overflow-y: auto !important;
        padding: 10px 12px !important;
    }

    #create-role-panel h2 {
        font-size: 14px !important;
        margin-bottom: 6px !important;
        padding-bottom: 4px !important;
        border-bottom: 1px solid #5d4037;
    }

    /* 族名标签缩小 */
    #create-role-panel .role-select>div[style*="color:#f1c40f"],
    #create-role-panel .role-select>div[style*="color:#3498db"],
    #create-role-panel .role-select>div[style*="color:#e74c3c"] {
        font-size: 12px !important;
    }

    /* 选项行间距压缩 */
    #create-role-panel .role-select {
        gap: 2px !important;
    }

    #create-role-panel .role-select label {
        font-size: 12px !important;
    }

    /* 名称输入框 */
    #role-name-input {
        margin-top: 6px !important;
        padding: 5px !important;
        font-size: 13px !important;
    }

    /* 进入游戏按钮 */
    #create-role-panel button {
        padding: 7px 20px !important;
        font-size: 13px !important;
        margin-top: 6px !important;
    }

    /* --- 设置面板 --- */
    #settings-panel {
        width: min(280px, 90vw) !important;
        max-height: 80dvh !important;
    }

    #settings-panel>div {
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* --- 聊天弹窗 --- */
    #chat-modal-panel {
        width: min(500px, 92vw) !important;
        height: 100dvh !important;
        max-height: 100dvh !important;
        border-radius: 0 !important;
    }

    #chat-modal-panel #chat-modal-log-container {
        flex: 1 !important;
        max-height: none !important;
    }

    /* --- 角色面板（背包）--- */
    #hero-inventory-panel {
        width: min(760px, 96vw) !important;
        height: min(480px, 92dvh) !important;
    }

    /* 标题栏压缩：减小 padding 和字体 */
    #hero-inventory-panel .panel-header {
        padding: 5px 8px !important;
        padding-bottom: 5px !important;
        margin-bottom: 0 !important;
        min-height: 0 !important;
    }

    #hero-inventory-panel .panel-header h2 {
        font-size: 13px !important;
        margin: 0 !important;
    }

    #hero-inventory-panel .close-btn {
        width: 32px !important;
        height: 32px !important;
        min-width: 32px !important;
        min-height: 32px !important;
        border-radius: 50% !important;
        font-size: 16px !important;
        line-height: 30px !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        padding: 0 !important;
        flex-shrink: 0 !important;
        background: rgba(0, 0, 0, 0.45) !important;
        border: 1.5px solid rgba(255, 255, 255, 0.5) !important;
        color: #fff !important;
        cursor: pointer !important;
        touch-action: manipulation !important;
        z-index: 100 !important;
    }

    /* 左侧角色区域收窄，并允许纵向滚动以显示全部装备槽 */
    #hero-inventory-panel .hero-panel-left {
        flex: 0 0 200px !important;
        position: relative !important;
        height: 100% !important;
        overflow: hidden !important;
        /* 关闭不稳定的滚动，改用固定布局 */
        background: #dfd8c8 !important;
    }

    #hero-inventory-panel #fashion-selector-wrap {
        position: absolute !important;
        bottom: 8px !important; /* 更靠近底部 */
        left: 0 !important;
        width: 100% !important;
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        z-index: 100 !important;
        background: rgba(0, 0, 0, 0.5) !important;
        padding: 2px 0 !important; /* 极窄内边距 */
        gap: 3px !important; /* 压缩元素间距 */
    }
    #fashion-selector-wrap button {
        padding: 2px 8px !important; /* 按钮瘦身 */
        font-size: 10px !important; /* 字体缩小 */
    }
    #fashion-name-preview {
        font-size: 11px !important;
        min-width: 60px !important;
    }

    #hero-name-txt {
        font-size: 13px !important;
        margin-bottom: 0 !important;
        padding-top: 5px !important;
    }

    #hero-class-txt {
        font-size: 11px !important;
        margin-bottom: 5px !important;
    }

    /* 头像容器调整位置，避免太挤 */
    #hero-avatar-wrap {
        width: 120px !important;
        height: 140px !important;
        top: 44% !important; /* 下移一点，避免顶部拥挤 */
    }

    /* 装备槽也整体下移 */
    #hero-inventory-panel .equip-slots-col {
        top: 72px !important; /* 下移一点，避免顶部拥挤 */
        gap: 8px !important;
    }
    
    #hero-inventory-panel .equip-slot {
        width: 46px !important;
        height: 46px !important;
        margin-bottom: 0px !important;
    }

    #hero-inventory-panel .equip-slot .slot-bg {
        display: none !important;
    }

    #inventory-grid {
        grid-auto-rows: 58px !important;
        gap: 6px !important;
    }

    /* --- 帮派面板 --- */
    #guild-panel {
        width: min(720px, 96vw) !important;
        max-height: 85dvh !important;
    }

    #guild-tabs-content {
        height: auto !important;
        max-height: calc(85dvh - 60px) !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch;
    }

    .guild-sidenav-btn {
        padding: 12px 14px;
        color: #bfa88f;
        font-size: 13px;
        font-weight: bold;
        cursor: pointer;
        border-left: 3px solid transparent;
        transition: all 0.2s ease;
        display: flex;
        align-items: center;
        gap: 6px;
        user-select: none;
        font-family: "KaiTi", "STKaiti", "Microsoft YaHei", serif;
    }

    .guild-sidenav-btn:hover {
        background: rgba(139, 30, 27, 0.25);
        color: #fce8d0;
    }

    .guild-sidenav-btn.active {
        background: linear-gradient(90deg, rgba(139, 30, 27, 0.6) 0%, rgba(93, 20, 18, 0.15) 100%);
        color: #ffd700;
        border-left-color: #ffd700;
        text-shadow: 0 0 6px rgba(255, 215, 0, 0.4);
    }

    /* --- 好友/社交面板 --- */
    #social-panel {
        width: min(560px, 96vw) !important;
        max-height: 82dvh !important;
    }

    #social-panel>div:last-child {
        height: auto !important;
        max-height: calc(82dvh - 120px) !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch;
    }

    /* --- 排行榜面板 --- */
    #leaderboard-panel {
        width: min(360px, 92vw) !important;
        max-height: 82dvh !important;
    }

    #leaderboard-list {
        height: auto !important;
        max-height: calc(82dvh - 160px) !important;
        overflow-y: auto !important;
    }

    /* --- 商城面板 --- */
    #shop-panel {
        width: min(360px, 94vw) !important;
        max-height: 82dvh !important;
    }

    #shop-list {
        max-height: calc(82dvh - 140px) !important;
    }

    /* --- 技能/竞技场面板 --- */
    #skills-panel,
    #arena-panel {
        width: min(360px, 92vw) !important;
        max-height: 80dvh !important;
    }

    #skills-list-container {
        max-height: calc(80dvh - 100px) !important;
    }

    /* --- 交易面板 --- */
    #trade-modal {
        width: min(700px, 96vw) !important;
        height: min(400px, 78dvh) !important;
    }

    #trade-content {
        height: auto !important;
        flex: 1;
        min-height: 0;
    }

    #hero-tab-stats,
    #hero-tab-inventory {
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    .equip-slot {
        width: 40px;
        height: 40px;
    }

    .equip-slot .slot-bg {
        font-size: 16px;
    }

    .cross-slot {
        width: 46px !important;
        height: 46px !important;
        border: 1.5px solid #dfc29a !important;
        font-size: 11px !important;
    }
    .cross-slot.center {
        width: 52px !important;
        height: 52px !important;
        border: 2px solid #dfc29a !important;
    }
    .cross-slot.center button {
        font-size: 12px !important;
    }
    .cross-slot button {
        font-size: 11px !important;
    }

    .combat-cross-menu {
        gap: 2px !important;
    }

    /* 移动端/竖屏下物品操作与装备对比悬浮菜单 */
    #item-action-menu {
        max-width: 96vw !important;
        box-sizing: border-box !important;
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.9) !important;
        border-radius: 6px !important;
    }

    #item-action-menu .action-btn,
    #item-action-menu button {
        padding: 5px 4px !important;
        font-size: 11.5px !important;
        line-height: 1.25 !important;
        margin-bottom: 3px !important;
    }
}

/* 超小屏兜底 (宽度 < 380px, 如 SE) */
@media screen and (max-width: 380px) {
    .hud-bar-container {
        width: 80px;
    }

    .hud-menu-btn img {
        width: 32px;
        height: 32px;
    }

    #chat-hud-bottom-left {
        max-width: 160px;
    }

    #map-hud-top-right,
    #hud-quest-tracker {
        width: 70px;
    }
}

/* 横屏模式（高度 < 600px，适用于手机横放，如 vivo Y85 2280×1080 横屏）*/
@media screen and (orientation: landscape) and (max-height: 600px) {
    body {
        background: #000;
    }

    /* 头像框和血条极度压缩 */
    .hud-avatar-frame {
        width: 32px !important;
        height: 32px !important;
    }

    #hud-player-level {
        font-size: 8px !important;
        padding: 1px 2px !important;
    }

    .hud-bar-container {
        width: 90px !important;
        height: 12px !important;
    }

    .hud-bar-text {
        font-size: 8px !important;
    }

    .hud-status-bars {
        gap: 4px !important;
    }

    /* 右上角小地图收窄 */
    .hud-minimap-frame-v2 {
        width: 72px !important;
    }

    #hud-minimap-render {
        top: 14px !important;
        left: 6px !important;
        right: 6px !important;
        bottom: 5px !important;
    }

    #minimap-canvas {
        width: 48px !important;
        height: 48px !important;
    }

    #hud-map-name {
        font-size: 8px !important;
        top: 2px !important;
    }

    /* 任务追踪在横屏下优化展示 */
    #hud-quest-tracker {
        display: block;
        width: 84px !important;
        padding: 4px 6px !important;
        background: rgba(45, 30, 15, 0.85) !important;
        border: 1px solid rgba(200, 160, 80, 0.35) !important;
        border-radius: 4px;
        margin-top: 2px;
    }
    #hud-quest-tracker.hidden,
    body.in-tower #hud-quest-tracker {
        display: none !important;
    }
    #hud-quest-tracker .quest-header {
        font-size: 9px !important;
        padding-bottom: 2px !important;
        margin-bottom: 2px !important;
    }
    #hud-quest-tracker .quest-title {
        font-size: 8.5px !important;
        margin-bottom: 1px !important;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    #hud-quest-tracker .quest-desc {
        font-size: 8px !important;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    /* 顶部功能键右移避开小地图 */
    #function-menu-top {
        right: calc(115px + var(--safe-right)) !important;
        gap: 12px !important;
        top: calc(8px + var(--safe-top)) !important;
    }

    #function-menu-top .hud-menu-btn img {
        width: 48px !important;
        height: 48px !important;
    }

    /* 右下角主菜单按键缩小并向左让位 */
    #main-menu-bottom-right {
        gap: 6px !important;
        right: calc(46px + var(--safe-right)) !important;
        bottom: calc(8px + var(--safe-bottom)) !important;
    }

    #hud-collapse-toggle {
        right: calc(6px + var(--safe-right)) !important;
        bottom: calc(8px + var(--safe-bottom)) !important;
        height: 48px !important;
        width: 30px !important;
    }

    #main-menu-bottom-right .hud-menu-btn img {
        width: 50px !important;
        height: 50px !important;
    }

    /* 左下角聊天区域压缩 */
    #chat-hud-bottom-left {
        bottom: calc(6px + var(--safe-bottom)) !important;
        max-width: 160px !important;
        gap: 3px !important;
    }

    #hud-chat-logs {
        max-height: 50px !important;
        padding: 3px !important;
    }

    .hud-chat-btn img {
        width: 34px !important;
        height: 34px !important;
    }

    .chat-line {
        font-size: 9px !important;
    }

    /* 战斗菜单缩小 */
    .cross-slot {
        width: 38px !important;
        height: 38px !important;
        border: 1px solid #dfc29a !important;
        font-size: 10px !important;
    }
    .cross-slot.center {
        width: 44px !important;
        height: 44px !important;
        border: 1.5px solid #dfc29a !important;
    }
    .cross-slot.center button {
        font-size: 11px !important;
    }
    .cross-slot button {
        font-size: 10px !important;
    }

    .combat-cross-menu {
        gap: 4px !important;
    }

    /* 横屏下角色面板：极度压缩，装备槽更小，时装切换器隐藏 */
    #hero-inventory-panel {
        width: min(700px, 96vw) !important;
        height: min(340px, 92dvh) !important;
    }

    #hero-inventory-panel .equip-slot {
        width: 38px !important;
        height: 38px !important;
    }

    #hero-inventory-panel .equip-slot .slot-bg {
        display: none !important;
    }

    #inventory-grid {
        grid-auto-rows: 44px !important;
        gap: 4px !important;
    }

    #hero-inventory-panel .equip-slots-col {
        top: 56px !important; /* 下移一点，避免顶部拥挤 */
        gap: 4px !important;
    }

    #hero-inventory-panel #hero-avatar-wrap {
        width: 100px !important;
        height: 120px !important;
        top: 44% !important; /* 下移一点，避免顶部拥挤 */
    }

    /* 横屏时时装切换器隐藏，节省左侧空间 */
    #fashion-selector-wrap {
        display: none !important;
    }

    /* 弹窗面板在横屏下的定位与高度限制，确保不超出屏幕顶底 */
    .modal-panel {
        top: 8px !important;
        transform: translate(-50%, 0) !important;
        max-height: calc(100dvh - 16px) !important;
        padding: 8px !important;
    }

    /* 横屏下神秘商城适配 */
    #shop-panel {
        width: min(460px, 95vw) !important;
        max-height: calc(100dvh - 16px) !important;
    }

    #shop-list {
        max-height: calc(100dvh - 130px) !important;
    }

    /* 横屏下技能、竞技场、排行榜适配 */
    #skills-panel,
    #arena-panel,
    #leaderboard-panel {
        width: min(400px, 92vw) !important;
        max-height: calc(100dvh - 16px) !important;
    }
    
    #skills-list-container,
    #leaderboard-list {
        max-height: calc(100dvh - 110px) !important;
    }
}

/* --- 最底部：经验条 (全屏) --- */
#hud-exp-bar-container {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: rgba(0, 0, 0, 0.6);
    z-index: 9999;
}

#hud-exp-bar-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(to right, #2ecc71, #27ae60);
    box-shadow: 0 0 8px rgba(46, 204, 113, 0.5);
    transition: width 0.4s ease-out;
}

/* Login Background Overlay */
.login-bg-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: url('https://pics.fj1008611.cn/xcx/game/img/ui/001.png') no-repeat center center;
    background-size: cover;
    z-index: 2000;
    /* between game-container and modal-panels */
}

/* 跑马灯公告横幅 */
.announcement-banner {
    position: absolute;
    top: 70px; /* 避开左上角头像和右上角菜单 */
    left: 0;
    width: 100%;
    height: 36px;
    background-color: rgba(0, 0, 0, 0.65);
    z-index: 99; /* 渲染在地图和玩家之上，但在弹窗之下 */
    overflow: hidden;
    display: flex;
    align-items: center;
    border-top: 1px solid rgba(243, 156, 18, 0.25);
    border-bottom: 1px solid rgba(243, 156, 18, 0.25);
    pointer-events: none; /* 鼠标点击穿透 */
}

.announcement-banner.hidden {
    display: none !important;
}

.announcement-text {
    position: absolute;
    white-space: nowrap;
    font-size: 14px;
    font-weight: bold;
    color: #f1c40f;
    text-shadow: 1px 1px 2px #000;
    left: 0;
    transform: translate3d(100%, 0, 0);
}

.announcement-text.scrolling {
    animation: marquee-scroll 15s linear forwards; /* 滚动一次并保持在结束状态 */
}

@keyframes marquee-scroll {
    0% {
        transform: translate3d(100%, 0, 0);
    }
    100% {
        transform: translate3d(-100%, 0, 0);
    }
}

/* 自动识别屏幕高度：当可视高度 <= 600px 时，强制调整所有弹窗面板的位置与最大高度，防止关闭按钮和头部被挤出屏幕 */
@media screen and (max-height: 600px) {
    .modal-panel {
        top: 8px !important;
        transform: translate(-50%, 0) !important;
        max-height: calc(100dvh - 16px) !important;
        padding: 8px !important;
    }
    #settings-panel {
        padding: 0 !important;
        height: calc(100dvh - 16px) !important;
    }
}

/* 猜拳与寄卖子弹窗专属居中遮罩样式（严格置顶，居中显示，防被商城头部遮挡，固定底部操作按钮） */
#rps-create-modal.hidden,
#rps-challenge-modal.hidden,
#rps-records-modal.hidden,
#consignment-sell-modal.hidden,
#consignment-records-modal.hidden {
    display: none !important;
}

#rps-create-modal:not(.hidden),
#rps-challenge-modal:not(.hidden),
#rps-records-modal:not(.hidden),
#consignment-sell-modal:not(.hidden),
#consignment-records-modal:not(.hidden) {
    position: fixed !important;
    top: 50% !important;
    left: 50% !important;
    transform: translate(-50%, -50%) !important;
    z-index: 1000005 !important;
    max-height: 94dvh !important;
    max-height: 94vh !important;
    padding: 0 !important;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
    box-shadow: 0 0 50px rgba(0, 0, 0, 0.9), 0 0 0 1000vmax rgba(0, 0, 0, 0.65) !important;
}

/* Custom Battle Victory Panel (Retro Style matching Image 3) */
.victory-panel-v3 {
    width: 300px;
    padding: 0 !important;
    background: #e7d7b6 !important; /* Beige background */
    border: 4px solid #3d2314 !important; /* Dark brown outer border */
    box-shadow: inset 0 0 0 2px #8c6239, 0 10px 30px rgba(0, 0, 0, 0.6) !important; /* Inner gold border and shadows */
    border-radius: 0px !important; /* Pixel art style has sharp corners */
    overflow: hidden;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    flex-direction: column;
    z-index: 9999 !important; /* High z-index */
    image-rendering: pixelated;
    pointer-events: auto;
}

.pixel-corner {
    position: absolute;
    width: 4px;
    height: 4px;
    background: #8c6239;
    border: 2px solid #3d2314;
    z-index: 20;
}
.pixel-corner.tl { top: -4px; left: -4px; }
.pixel-corner.tr { top: -4px; right: -4px; }
.pixel-corner.bl { bottom: -4px; left: -4px; }
.pixel-corner.br { bottom: -4px; right: -4px; }

/* Top Header */
.victory-header-v3 {
    position: relative;
    background: #37160f !important; /* Dark brown header */
    border-bottom: 4px solid #3d2314;
    box-shadow: inset 0 -2px 0 #8c6239;
    color: #ffd880; /* Gold text */
    text-align: center;
    padding: 10px 0;
    font-size: 16px;
    font-weight: bold;
    font-family: "Microsoft YaHei", sans-serif;
    letter-spacing: 2px;
    text-shadow: 1px 1px 0px #000;
}

/* Close Button in header */
.victory-close-v3 {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: transparent;
    border: none;
    color: #ffd880;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    text-shadow: 1px 1px 0px #000;
    outline: none;
}

.victory-close-v3:hover {
    color: #fff;
}

/* Reward Card / Container */
.victory-reward-card-v3 {
    background: #decbb2; /* Slightly darker beige card */
    border: 1px solid #c9b093;
    border-radius: 8px;
    padding: 15px 25px;
    margin: 20px auto;
    width: 80%;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    gap: 8px;
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.05);
}

.victory-reward-row-v3 {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 15px;
    color: #3b2214; /* Dark brown text */
    font-weight: bold;
    font-family: "Microsoft YaHei", sans-serif;
}

.victory-reward-row-v3 .label {
    letter-spacing: 4px;
}

.victory-reward-row-v3 .value {
    font-family: monospace, sans-serif;
}

/* Body / Padding container */
.victory-body-v3 {
    padding: 10px 0;
    width: 100%;
}

/* Custom Combat Skill Selection Panel V3 */
.combat-skill-overlay-v3 {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.4);
    z-index: 2999;
    display: flex;
    justify-content: center;
    align-items: center;
    pointer-events: auto;
}

.combat-skill-panel-v3 {
    position: relative;
    background: url('https://pics.fj1008611.cn/xcx/game/img/ui/combat_skill_panel.png') no-repeat;
    background-size: 100% 100%;
    width: 220px;
    padding: 24px 18px; /* Padding to fit buttons inside the border */
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 3000;
    box-sizing: border-box;
    max-height: 85vh;
    overflow-y: auto;
    scrollbar-width: none; /* Hide scrollbars in Firefox */
}

.combat-skill-panel-v3::-webkit-scrollbar {
    display: none; /* Hide scrollbars in Chrome/Safari */
}

.combat-skill-btn-v3 {
    background: url('https://pics.fj1008611.cn/xcx/game/img/ui/combat_skill_slot.png') no-repeat;
    background-size: 100% 100%;
    width: 100%;
    height: 44px;
    border: none;
    background-color: transparent;
    display: flex;
    justify-content: center;
    align-items: center;
    color: #ffd880; /* Gold text matching the layout mockup */
    font-size: 16px;
    font-weight: bold;
    font-family: "Microsoft YaHei", sans-serif;
    text-shadow: 1px 1px 2px #000;
    cursor: pointer;
    box-sizing: border-box;
    transition: transform 0.1s, filter 0.1s;
    outline: none;
    padding: 0 10px;
}

.combat-skill-btn-v3:hover {
    filter: brightness(1.2);
}

.combat-skill-btn-v3:active {
    transform: scale(0.95);
    filter: brightness(1.3);
}

.combat-skill-btn-v3.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    filter: grayscale(0.8) brightness(0.8);
    pointer-events: none;
}

/* ===================================================
   新手引导 UI 增强样式 (一键穿戴浮窗 & 装备空槽提示)
   =================================================== */

/* 获得新装备一键穿戴浮窗 */
.quick-equip-popup {
    position: fixed;
    bottom: 80px;
    right: 15px;
    width: 260px;
    background: rgba(30, 20, 14, 0.95);
    border: 1.5px solid #d4af37;
    border-radius: 8px;
    padding: 10px 12px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.6), inset 0 0 10px rgba(212, 175, 55, 0.15);
    z-index: 10000;
    pointer-events: auto;
    display: flex;
    flex-direction: column;
    gap: 6px;
    animation: quickEquipSlideIn 0.3s ease-out;
    backdrop-filter: blur(4px);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

@keyframes quickEquipSlideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.quick-equip-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px dashed rgba(212, 175, 55, 0.4);
    padding-bottom: 4px;
}

.quick-equip-title {
    font-size: 12px;
    font-weight: bold;
    color: #f1c40f;
    letter-spacing: 0.5px;
}

.quick-equip-close {
    background: none;
    border: none;
    color: #a08c75;
    font-size: 14px;
    cursor: pointer;
    line-height: 1;
    padding: 0 2px;
}

.quick-equip-close:hover {
    color: #fff;
}

.quick-equip-body {
    display: flex;
    align-items: center;
    gap: 10px;
}

.quick-equip-icon {
    width: 36px;
    height: 36px;
    border: 1px solid #8b5a2b;
    border-radius: 4px;
    background: rgba(0, 0, 0, 0.4);
    display: flex;
    justify-content: center;
    align-items: center;
    flex-shrink: 0;
}

.quick-equip-info {
    flex: 1;
    min-width: 0;
}

.quick-equip-name {
    font-size: 13px;
    font-weight: bold;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.quick-equip-stat {
    font-size: 11px;
    color: #2ecc71;
    margin-top: 2px;
}

.quick-equip-btn {
    background: linear-gradient(135deg, #1e824c, #27ae60);
    border: 1px solid #2ecc71;
    color: #fff;
    font-size: 12px;
    font-weight: bold;
    padding: 5px 0;
    border-radius: 4px;
    cursor: pointer;
    text-align: center;
    width: 100%;
    margin-top: 2px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    transition: transform 0.1s, filter 0.1s;
}

.quick-equip-btn:active {
    transform: scale(0.97);
    filter: brightness(1.15);
}

/* 空装备槽位呼吸动画 (新手提醒) */
@keyframes slotEmptyGlow {
    0%, 100% {
        border-color: #8b5a2b;
        box-shadow: none;
    }
    50% {
        border-color: #d4af37;
        box-shadow: 0 0 6px rgba(212, 175, 55, 0.5);
    }
}

.slot-empty-notice {
    animation: slotEmptyGlow 2s infinite ease-in-out;
}

/* ─────────────────────────────────────────────────────────────
   新手村擂台荣誉称号专属边框与光效 (状元/榜眼/探花)
───────────────────────────────────────────────────────────── */
.title-border-zhuangyuan {
    display: inline-block;
    padding: 2px 8px;
    color: #fffbe6 !important;
    font-weight: bold;
    border-radius: 4px;
    background: linear-gradient(135deg, rgba(212, 175, 55, 0.4), rgba(255, 215, 0, 0.2));
    border: 1.5px solid #ffd700 !important;
    box-shadow: 0 0 8px rgba(255, 215, 0, 0.7), inset 0 0 4px rgba(255, 215, 0, 0.5);
    text-shadow: 0 0 4px #ffd700;
}

.title-border-bangyan {
    display: inline-block;
    padding: 2px 8px;
    color: #ffffff !important;
    font-weight: bold;
    border-radius: 4px;
    background: linear-gradient(135deg, rgba(192, 192, 192, 0.4), rgba(230, 247, 255, 0.2));
    border: 1.5px solid #e6f7ff !important;
    box-shadow: 0 0 8px rgba(230, 247, 255, 0.7), inset 0 0 4px rgba(255, 255, 255, 0.5);
    text-shadow: 0 0 4px #ffffff;
}

.title-border-tanhua {
    display: inline-block;
    padding: 2px 8px;
    color: #f6ffed !important;
    font-weight: bold;
    border-radius: 4px;
    background: linear-gradient(135deg, rgba(82, 196, 26, 0.4), rgba(183, 235, 143, 0.2));
    border: 1.5px solid #52c41a !important;
    box-shadow: 0 0 8px rgba(82, 196, 26, 0.7), inset 0 0 4px rgba(183, 235, 143, 0.5);
    text-shadow: 0 0 4px #52c41a;
}




/* ====================================================================
   移动端专属竖屏 UI (v3 完整恢复版) — 包含底部导航横排 / HUD 位置修正
   仅在 body.screen-mode-portrait 下生效
   ==================================================================== */

/* 0. 安全区变量定义（iPhone 刘海/Android 挖孔屏适配） */
.screen-mode-portrait {
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --safe-left: env(safe-area-inset-left, 0px);
    --safe-right: env(safe-area-inset-right, 0px);
}

/* 通用：portrait-only / landscape-only 可见性控制 */
.portrait-only  { display: none !important; }
.landscape-only { display: none !important; }
.screen-mode-portrait .portrait-only   { display: flex !important; }
.screen-mode-landscape .landscape-only { display: flex !important; }

/* === 1. 顶部通栏：头像与角色状态卡 (温润金镶玉卡片) === */
.screen-mode-portrait #player-hud-top-left {
    position: fixed !important;
    top: calc(8px + var(--safe-top)) !important;
    left: calc(8px + var(--safe-left)) !important;
    width: 210px !important;
    max-width: 50vw !important;
    padding: 5px 8px !important;
    border-radius: 10px !important;
    border: 2px solid #b8860b !important;
    background: linear-gradient(135deg, rgba(255, 248, 220, 0.96), rgba(245, 222, 179, 0.92)) !important;
    backdrop-filter: blur(8px) !important;
    box-shadow: 0 4px 14px rgba(80, 50, 15, 0.16), inset 0 0 0 1px rgba(255, 255, 255, 0.8) !important;
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    gap: 8px !important;
    z-index: 2147482970 !important;
}
.screen-mode-portrait #player-hud-top-left .hud-avatar-frame {
    width: 44px !important;
    height: 44px !important;
    border-radius: 8px !important;
    border: 2px solid #b8860b !important;
    box-shadow: 0 2px 6px rgba(139, 90, 20, 0.25) !important;
    overflow: hidden !important;
    flex-shrink: 0 !important;
}
.screen-mode-portrait #player-hud-top-left #hud-player-level {
    font-size: 10px !important;
    background: linear-gradient(135deg, #d35400, #e67e22) !important;
    color: #fff !important;
    border-radius: 3px !important;
    padding: 0 5px !important;
    bottom: -4px !important;
    right: -4px !important;
    position: absolute !important;
    font-weight: bold !important;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2) !important;
}
.screen-mode-portrait #player-hud-top-left .hud-status-bars {
    width: 115px !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 4px !important;
    min-width: 0 !important;
}
.screen-mode-portrait .hud-double-buff {
    top: calc(63px + var(--safe-top));
    left: calc(8px + var(--safe-left));
    font-size: 9px;
    min-height: 17px;
    padding: 2px 6px;
    gap: 4px;
}
.screen-mode-portrait #player-hud-top-left .hud-bar-container {
    height: 12px !important;
    border-radius: 6px !important;
    background: #2c1810 !important;
    position: relative !important;
    overflow: hidden !important;
    border: 1px solid rgba(0, 0, 0, 0.35) !important;
}
.screen-mode-portrait .hud-bar-text {
    font-size: 9px !important;
    line-height: 12px !important;
    position: absolute !important;
    width: 100% !important;
    text-align: center !important;
    color: #fff !important;
    text-shadow: 0 0 2px rgba(0, 0, 0, 0.8) !important;
    top: 0 !important;
}

/* === 2. 右上角小地图 (金饰卷轴玉框 + 牌匾地图名) === */
.screen-mode-portrait #map-hud-top-right {
    position: fixed !important;
    top: calc(8px + var(--safe-top)) !important;
    right: calc(8px + var(--safe-right)) !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    gap: 2px !important;
    z-index: 2147482970 !important;
    transform: none !important;
}
.screen-mode-portrait #map-hud-top-right .hud-minimap-frame-v2 {
    width: 80px !important;
    height: 80px !important;
    border: 2px solid #b8860b !important;
    border-radius: 8px !important;
    background: rgba(255, 248, 220, 0.9) !important;
    padding: 2px !important;
    overflow: hidden !important;
    box-sizing: border-box !important;
    box-shadow: 0 4px 14px rgba(80, 50, 15, 0.2), inset 0 0 0 1px rgba(255, 255, 255, 0.7) !important;
}
.screen-mode-portrait #minimap-canvas {
    width: 74px !important;
    height: 60px !important;
    display: block !important;
}
.screen-mode-portrait #hud-map-name {
    font-size: 10px !important;
    height: 16px !important;
    line-height: 16px !important;
    padding: 0 8px !important;
    border-radius: 3px !important;
    background: linear-gradient(135deg, #8d5a2b, #b8860b) !important;
    color: #fff4d4 !important;
    font-weight: bold !important;
    border: 1px solid #d4af37 !important;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3) !important;
    white-space: nowrap !important;
}

/* 竖屏下任务追踪框 / 塔排行榜 / 公会宅 HUD 精简隐藏 */
.screen-mode-portrait #hud-quest-tracker,
.screen-mode-portrait #tower-hud-leaderboard,
.screen-mode-portrait #guild-residence-hud {
    display: none !important;
}

/* === 3. 右侧活动功能快捷按钮列 (位置移至右侧、尺寸调大) === */
.screen-mode-portrait #function-menu-top {
    position: fixed !important;
    top: calc(108px + var(--safe-top)) !important;
    right: calc(8px + var(--safe-right)) !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 8px !important;
    z-index: 2147482970 !important;
    transition: all 0.22s ease !important;
}
.screen-mode-portrait #function-menu-top .hud-menu-btn {
    width: 50px !important;
    height: 50px !important;
    border-radius: 50% !important;
    background: linear-gradient(135deg, rgba(255, 248, 220, 0.95), rgba(245, 222, 179, 0.9)) !important;
    border: 2px solid #b8860b !important;
    box-shadow: 0 4px 10px rgba(80, 50, 15, 0.22), inset 0 0 0 1px rgba(255, 255, 255, 0.6) !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    flex-shrink: 0 !important;
    transition: transform 0.12s ease !important;
}
.screen-mode-portrait #function-menu-top .hud-menu-btn:active {
    transform: scale(0.9) !important;
}
.screen-mode-portrait #function-menu-top .hud-menu-btn img {
    width: 36px !important;
    height: 36px !important;
    object-fit: contain !important;
}

/* 竖屏折叠状态：隐藏其他按钮，仅保留收缩/展开按钮 */
.screen-mode-portrait #function-menu-top.is-collapsed {
    gap: 0 !important;
}
.screen-mode-portrait #function-menu-top.is-collapsed .hud-menu-btn:not(#function-menu-collapse-btn) {
    display: none !important;
}
.screen-mode-portrait #function-menu-collapse-btn {
    width: 44px !important;
    height: 44px !important;
    border-radius: 50% !important;
    background: linear-gradient(135deg, #3d2411 0%, #1a0f07 100%) !important;
    border: 2px solid #d4af37 !important;
    color: #ffd700 !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    cursor: pointer !important;
    box-shadow: 0 4px 12px rgba(0,0,0,0.6), inset 0 0 8px rgba(212,175,55,0.3) !important;
    user-select: none !important;
    touch-action: manipulation !important;
    transition: transform 0.15s ease, background 0.2s ease !important;
}
.screen-mode-portrait #function-menu-collapse-btn:active {
    transform: scale(0.9) !important;
}
.screen-mode-portrait #function-menu-collapse-icon {
    font-size: 13px !important;
    line-height: 1 !important;
    color: #ffd700 !important;
}
.screen-mode-portrait #function-menu-collapse-text {
    font-size: 9px !important;
    color: #ffd700 !important;
    font-weight: bold !important;
    line-height: 1 !important;
    margin-top: 2px !important;
}

/* 隐藏右侧离开按钮（地图内自有传送阵，界面彻底纯净） */
#hud-exit-map-btn,
.screen-mode-portrait #hud-exit-map-btn {
    display: none !important;
    visibility: hidden !important;
}

/* ================================================
   === 4. 底部导航栏：全宽横排 5 个纯美术大图标 ===
   ================================================ */
.screen-mode-portrait #main-menu-bottom-right {
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    width: 100vw !important;
    max-width: 100vw !important;
    height: auto !important;
    flex-direction: row !important;
    justify-content: space-evenly !important;
    align-items: center !important;
    gap: 3px !important;
    padding: 6px 6px calc(8px + var(--safe-bottom)) 36px !important;
    background: linear-gradient(180deg,
        rgba(0, 0, 0, 0) 0%,
        rgba(40, 20, 5, 0.65) 30%,
        rgba(25, 12, 0, 0.90) 100%) !important;
    border-top: 1.5px solid rgba(200, 158, 88, 0.55) !important;
    z-index: 2147482990 !important;
    box-sizing: border-box !important;
    border-radius: 0 !important;
    transition: transform 0.35s cubic-bezier(0.2, 0.8, 0.2, 1), opacity 0.35s ease !important;
}

/* 竖屏下 HUD 折叠时，底部导航栏向下滑出屏幕 */
.screen-mode-portrait #ui-layer.hud-collapsed #main-menu-bottom-right,
.screen-mode-portrait .hud-collapsed #main-menu-bottom-right,
#ui-layer.hud-collapsed.screen-mode-portrait #main-menu-bottom-right {
    transform: translate3d(0, 150%, 0) !important;
    opacity: 0 !important;
    pointer-events: none !important;
}

/* 5 个导航按钮：纯图标，更大更清晰易点 */
.screen-mode-portrait #main-menu-bottom-right .hud-menu-btn {
    flex: 1 1 0 !important;
    min-width: 0 !important;
    max-width: 72px !important;
    width: auto !important;
    height: auto !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 2px !important;
    border-radius: 0 !important;
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    overflow: visible !important;
}
.screen-mode-portrait #main-menu-bottom-right .hud-menu-btn img {
    width: 50px !important;
    height: 50px !important;
    display: block !important;
    object-fit: contain !important;
    box-sizing: border-box !important;
    border-radius: 12px !important;
    border: 1.5px solid #c89e58 !important;
    background: linear-gradient(180deg, #fff4d4 0%, #f1d89e 100%) !important;
    padding: 3px !important;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.38), inset 0 0 0 1px rgba(255, 255, 255, 0.6) !important;
    transition: transform 0.1s ease !important;
}
.screen-mode-portrait #main-menu-bottom-right .hud-menu-btn:active img {
    transform: scale(0.92) !important;
}

/* 彻底隐藏底部按钮下方所有的文字标签（文字不要，图标大而清晰，界面极其清爽） */
.bottom-btn-label,
.screen-mode-portrait .bottom-btn-label {
    display: none !important;
    visibility: hidden !important;
    height: 0 !important;
    width: 0 !important;
    overflow: hidden !important;
}

/* HUD 折叠按钮：竖屏放置在最底部左侧（紧贴底部导航栏左端，始终可点击切换展开/收起） */
.screen-mode-portrait #hud-collapse-toggle {
    position: fixed !important;
    right: auto !important;
    left: calc(6px + var(--safe-left)) !important;
    bottom: calc(7px + var(--safe-bottom)) !important;
    width: 26px !important;
    height: 50px !important;
    border-radius: 7px !important;
    z-index: 2147482995 !important;
    background: rgba(26, 15, 6, 0.92) !important;
    border: 1.5px solid #d4af37 !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.6) !important;
}

/* === 5. 底部经验条：浮到导航栏正上方，全宽带金边 === */
.screen-mode-portrait #hud-exp-bar-container {
    position: fixed !important;
    bottom: calc(66px + var(--safe-bottom)) !important;
    left: calc(10px + var(--safe-left)) !important;
    right: calc(10px + var(--safe-right)) !important;
    width: auto !important;
    height: 6px !important;
    border-radius: 4px !important;
    border: 1px solid rgba(200, 158, 88, 0.8) !important;
    background: rgba(28, 14, 4, 0.72) !important;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.55) !important;
    z-index: 2147482980 !important;
    overflow: hidden !important;
}
.screen-mode-portrait #hud-exp-bar-fill {
    height: 100% !important;
    background: linear-gradient(90deg, #27ae60, #2ecc71, #82e0aa) !important;
    transition: width 0.4s cubic-bezier(.2,.8,.2,1) !important;
}

/* === 6. 左下角聊天：隐藏重复的圆形聊天图标，消息气泡整齐浮于经验条上方 === */
.screen-mode-portrait .hud-chat-btn,
.screen-mode-portrait #hud-chat-btn-wrap {
    display: none !important;
}
.screen-mode-portrait #chat-hud-bottom-left {
    bottom: calc(76px + var(--safe-bottom)) !important;
    left: calc(10px + var(--safe-left)) !important;
    max-width: 65vw !important;
    gap: 3px !important;
}

/* === 7. 面板通用：竖屏通用层级、遮罩 & 触控优化 === */
/* 全局弹窗层级：无论横屏、竖屏，所有面板必须统一置顶于遮罩层(2147482995)之上 */
.modal-panel,
.screen-mode-portrait .modal-panel,
.screen-mode-landscape .modal-panel,
#hero-inventory-panel,
#shop-panel,
#settings-panel,
#chat-modal-panel,
#skills-panel,
#arena-panel,
#leaderboard-panel,
#trade-modal,
#guild-panel,
#social-panel,
#boss-panel,
#team-panel,
#warehouse-panel,
#mail-panel,
#statue-panel,
#battle-victory-panel,
#quest-panel,
#activity-panel {
    z-index: 2147483000 !important;
}

/* 通用全屏遮罩层（点击快速关闭弹窗） */
#global-modal-backdrop {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    background: rgba(0, 0, 0, 0.6) !important;
    z-index: 2147482995 !important;
    backdrop-filter: blur(2px) !important;
    -webkit-backdrop-filter: blur(2px) !important;
    transition: opacity 0.2s ease !important;
}

/* 竖屏下弹窗关闭按钮统一切换为友好大触控区 (36x36px) */
.screen-mode-portrait .close-btn,
.screen-mode-portrait .panel-header .close-btn,
.screen-mode-portrait #hero-inventory-panel .close-btn,
.screen-mode-portrait #shop-panel .close-btn {
    width: 36px !important;
    height: 36px !important;
    width: 36px !important;
    height: 36px !important;
    min-width: 36px !important;
    min-height: 36px !important;
    border-radius: 50% !important;
    font-size: 18px !important;
    line-height: 34px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    cursor: pointer !important;
    touch-action: manipulation !important;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.5) !important;
    border: 1.5px solid rgba(255, 255, 255, 0.4) !important;
    background: linear-gradient(135deg, #e74c3c, #c0392b) !important;
    color: #fff !important;
    font-weight: bold !important;
    transition: transform 0.12s ease !important;
    flex-shrink: 0 !important;
    z-index: 100 !important;
}
.screen-mode-portrait .close-btn:active {
    transform: scale(0.88) !important;
}

/* 竖屏商城面板自适应与防遮挡 */
.screen-mode-portrait #shop-panel {
    width: min(96vw, 920px) !important;
    max-width: 96vw !important;
    height: auto !important;
    max-height: 88dvh !important;
    position: fixed !important;
    top: 50% !important;
    left: 50% !important;
    transform: translate(-50%, -50%) !important;
    z-index: 2147483000 !important;
}
.screen-mode-portrait #shop-panel .panel-header {
    height: auto !important;
    min-height: 44px !important;
    padding: 6px 44px 6px 8px !important; /* 给右侧关闭按钮留出安全区域 */
    position: relative !important;
    flex-wrap: wrap !important;
    gap: 6px !important;
}
.screen-mode-portrait #shop-panel .panel-header .close-btn {
    position: absolute !important;
    right: 6px !important;
    top: 50% !important;
    transform: translateY(-50%) !important;
    z-index: 100 !important;
}
.screen-mode-portrait #shop-panel .panel-header .close-btn:active {
    transform: translateY(-50%) scale(0.88) !important;
}
.screen-mode-portrait #shop-mode-tab-shop,
.screen-mode-portrait #shop-mode-tab-consignment,
.screen-mode-portrait #shop-mode-tab-rps {
    padding: 4px 6px !important;
    font-size: 10.5px !important;
}
.screen-mode-portrait #shop-points-badge {
    padding: 2px 6px !important;
    font-size: 10px !important;
}

.screen-mode-portrait .panel-header {
    border-bottom: 2px solid #c89e58 !important;
}
.screen-mode-portrait .panel-header h2,
.screen-mode-portrait .modal-panel h2 {
    color: #5c2d12 !important;
    text-shadow: 0 1px 0 rgba(255, 255, 255, 0.8) !important;
}
.screen-mode-portrait #settings-panel {
    width: 95vw !important;
    max-width: 95vw !important;
}
.screen-mode-portrait #settings-panel-main-layout {
    flex-direction: column !important;
}
.screen-mode-portrait #settings-panel-tabs-nav {
    width: 100% !important;
    height: auto !important;
    flex-direction: row !important;
    overflow-x: auto !important;
    border-right: none !important;
    border-bottom: 1px solid #c89e58 !important;
    background: #f1e6d0 !important;
    padding: 4px !important;
    flex-wrap: nowrap !important;
    scrollbar-width: none !important;
}
.screen-mode-portrait #settings-panel-tabs-nav::-webkit-scrollbar {
    display: none !important;
}
.screen-mode-portrait #settings-panel-tabs-nav button {
    white-space: nowrap !important;
    flex-shrink: 0 !important;
    width: auto !important;
    padding: 6px 12px !important;
    font-size: 11px !important;
    background: #fffdf8 !important;
    border: 1px solid #c89e58 !important;
    color: #5c3818 !important;
    border-radius: 4px !important;
}
.screen-mode-portrait #settings-panel-tabs-nav button.active {
    background: linear-gradient(135deg, #b8860b, #d4af37) !important;
    color: #ffffff !important;
    font-weight: bold !important;
}

/* ====================================================================
   【竖屏背包 UI 大改版 V2】PORTrait HERO INVENTORY REVAMP V2
   .screen-mode-portrait 下独占；左右→上下堆叠；不溢出不挤压
   ==================================================================== */

/* ===== A. 面板整体 ===== */
.screen-mode-portrait #hero-inventory-panel {
    /* 尺寸：宽度 94vw(窄屏友好)，高度取 min(86dvh, 820px) 留安全距离 */
    width: min(940px, 94vw) !important;
    max-width: 94vw !important;
    height: auto !important;
    max-height: 86dvh !important;
    /* 纵向堆叠 */
    flex-direction: column !important;
    /* 固定居中 + 金边玉韵：略下移避开顶部HUD */
    position: fixed !important;
    top: 54% !important;
    left: 50% !important;
    transform: translate(-50%, -50%) !important;
    z-index: 2147483000 !important;
    border: 2.5px solid #c89e58 !important;
    border-radius: 14px !important;
    background: linear-gradient(160deg, #f6ecd6 0%, #efe4d5 40%, #e5d6bc 100%) !important;
    box-shadow: 0 16px 40px rgba(60, 40, 15, 0.55),
                inset 0 0 0 1px rgba(255, 248, 220, 0.9) !important;
    overflow: hidden !important;
}

/* ===== B. 顶部角色横条 (hero-panel-left)：200px，装备 + 头像 + 套装全部收纳 ===== */
.screen-mode-portrait #hero-inventory-panel .hero-panel-left {
    flex: 0 0 200px !important;
    width: 100% !important;
    height: 200px !important;
    border-right: none !important;
    border-bottom: 2px solid #c89e58 !important;
    background: linear-gradient(180deg,
        rgba(255, 243, 212, 0.95) 0%,
        rgba(223, 216, 200, 0.95) 100%) !important;
    position: relative !important;
    overflow: hidden !important;
    padding: 0 !important;
    box-sizing: border-box !important;
}

/* 名字/职业：更紧凑地贴顶 */
.screen-mode-portrait #hero-inventory-panel .hero-panel-left > div:first-child {
    padding-top: 4px !important;
    z-index: 10;
    position: relative;
}
.screen-mode-portrait #hero-name-txt {
    font-size: 13px !important;
    color: #5c2d12 !important;
    letter-spacing: 0.3px !important;
    padding-top: 2px !important;
    margin: 0 0 1px 0 !important;
    text-shadow: 0 1px 0 rgba(255, 255, 255, 0.7) !important;
}
.screen-mode-portrait #hero-class-txt {
    font-size: 10.5px !important;
    color: #8b5a2b !important;
    margin-bottom: 0 !important;
}

/* 立绘：居中，尺寸紧凑但不糊 */
.screen-mode-portrait #hero-avatar-wrap {
    width: 78px !important;
    height: 92px !important;
    top: 52% !important;
    left: 50% !important;
    transform: translate(-50%, -50%) !important;
    z-index: 3 !important;
    filter: drop-shadow(0 3px 6px rgba(80, 40, 10, 0.2)) !important;
}

/* 装备槽：32px 小格子，gap 2px，距顶部32px，确保底部不与套装条重叠 */
.screen-mode-portrait #hero-inventory-panel .equip-slots-col {
    gap: 2px !important;
    top: 32px !important;
    z-index: 5 !important;
}
.screen-mode-portrait #hero-inventory-panel .equip-slots-col.left-col {
    left: 8px !important;
}
.screen-mode-portrait #hero-inventory-panel .equip-slots-col.right-col {
    right: 8px !important;
}
.screen-mode-portrait #hero-inventory-panel .equip-slot {
    width: 32px !important;
    height: 32px !important;
    border-radius: 5px !important;
    border: 1.5px solid #a67c38 !important;
    box-shadow: 0 1px 3px rgba(80, 40, 10, 0.2),
                inset 0 0 0 1px rgba(255, 255, 255, 0.5) !important;
    background: rgba(255, 248, 220, 0.9) !important;
}
.screen-mode-portrait #hero-inventory-panel .equip-slot .slot-bg {
    display: none !important;
}
.screen-mode-portrait #hero-inventory-panel .equip-slot img {
    width: 100% !important;
    height: 100% !important;
    object-fit: contain !important;
}

/* 套装加成：24px 底部横条 */
.screen-mode-portrait #hero-suit-display-wrap {
    bottom: 2px !important;
    left: 50% !important;
    transform: translateX(-50%) !important;
    right: auto !important;
    width: 74% !important;
    min-width: 240px !important;
    max-width: 340px !important;
    min-height: 22px !important;
    max-height: 22px !important;
    padding: 2px 8px !important;
    overflow: hidden !important;
    z-index: 10 !important;
    box-sizing: border-box !important;
    background: linear-gradient(90deg, rgba(26, 18, 12, 0.93), rgba(42, 28, 18, 0.93)) !important;
}
.screen-mode-portrait #hero-suit-display-wrap > div:first-child {
    font-size: 9.5px !important;
    line-height: 18px !important;
}
.screen-mode-portrait #hero-suit-display-wrap > div:nth-child(2) {
    display: none !important;
}

/* 竖屏隐藏时装选择器（防止挤占顶部空间） */
.screen-mode-portrait #fashion-selector-wrap {
    display: none !important;
}

/* ===== C. 下方内容区 (hero-panel-right) ===== */
.screen-mode-portrait #hero-inventory-panel .hero-panel-right {
    flex: 1 1 auto !important;
    min-height: 0 !important;
    width: 100% !important;
    max-height: calc(90dvh - 200px) !important;
    background: linear-gradient(180deg, #fdf6e6 0%, #f1e4d0 100%) !important;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
}

/* 标题栏 */
.screen-mode-portrait #hero-inventory-panel .panel-header {
    height: 30px !important;
    min-height: 30px !important;
    padding: 0 10px !important;
    margin: 0 !important;
    flex-shrink: 0 !important;
    box-sizing: border-box !important;
    background: linear-gradient(90deg, #6d4c41 0%, #8d5a3c 50%, #6d4c41 100%) !important;
    border-bottom: 1px solid #c89e58 !important;
}
.screen-mode-portrait #hero-inventory-panel .panel-header h2 {
    font-size: 13px !important;
    color: #ffe680 !important;
    letter-spacing: 1px !important;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5) !important;
}
.screen-mode-portrait #hero-inventory-panel .close-btn {
    width: 36px !important;
    height: 36px !important;
    min-width: 36px !important;
    min-height: 36px !important;
    border-radius: 50% !important;
    font-size: 18px !important;
    line-height: 36px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 0 !important;
    flex-shrink: 0 !important;
    cursor: pointer !important;
    touch-action: manipulation !important;
    background: rgba(0, 0, 0, 0.4) !important;
    border: 1px solid rgba(255, 255, 255, 0.4) !important;
    color: #fff !important;
    z-index: 100 !important;
}

/* 右侧主区 (tab 父容器) 去掉 overflow 问题 */
.screen-mode-portrait #hero-inventory-panel .hero-panel-right > div:nth-child(2) {
    flex: 1 1 auto !important;
    min-height: 0 !important;
    overflow: hidden !important;
    display: flex !important;
    flex-direction: column !important;
}

/* Tab 条 32px 高 */
.screen-mode-portrait #hero-inventory-panel .hero-tab {
    height: 32px !important;
    line-height: 32px !important;
    min-height: 32px !important;
    font-size: 12.5px !important;
    color: #5c2d12 !important;
    background: #d7ccc8 !important;
    flex-shrink: 0 !important;
    transition: all 0.18s ease !important;
}
.screen-mode-portrait #hero-inventory-panel .hero-tab.active {
    background: linear-gradient(180deg, #fff4d4 0%, #f1d89e 100%) !important;
    color: #8b4513 !important;
    font-weight: bold !important;
    border-bottom: 2px solid #c89e58 !important;
    box-shadow: inset 0 -4px 8px rgba(200, 158, 88, 0.15) !important;
}

/* ===== D. 属性页 ===== */
.screen-mode-portrait #hero-tab-stats {
    padding: 10px 14px !important;
    overflow-y: auto !important;
}
.screen-mode-portrait #hero-tab-stats .stat-btn {
    min-width: 28px !important;
    min-height: 28px !important;
    font-size: 15px !important;
    border-radius: 6px !important;
}

/* ===== E. 背包 & 网格：彻底解决"挤压"问题 ===== */
.screen-mode-portrait #hero-tab-inventory {
    flex: 1 1 auto !important;
    min-height: 0 !important;
    overflow: hidden !important;
    flex-direction: column !important;
}
.screen-mode-portrait #hero-tab-inventory[style*="display: flex"],
.screen-mode-portrait #hero-tab-inventory[style*="display:flex"] {
    display: flex !important;
}

/* 背包顶部工具栏：紧凑 */
.screen-mode-portrait #hero-tab-inventory > div:first-child {
    padding: 5px 8px !important;
    gap: 4px !important;
    flex-shrink: 0 !important;
    flex-wrap: wrap !important;
}
.screen-mode-portrait #hero-tab-inventory > div:first-child button {
    padding: 4px 8px !important;
    font-size: 10.5px !important;
    border-radius: 5px !important;
}
.screen-mode-portrait #hero-tab-inventory > div:first-child > div:nth-child(2) {
    font-size: 10px !important;
    gap: 4px !important;
    flex-shrink: 1 !important;
    min-width: 0 !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
}

/* --- 核心：背包网格 5 列，CELL 100% 宽度保持方形 --- */
.screen-mode-portrait #inventory-grid {
    flex: 1 1 auto !important;
    min-height: 0 !important;
    display: grid !important;
    /* 严格 5 等分，minmax(0,1fr) 防止内容溢出撑破列宽 */
    grid-template-columns: repeat(5, minmax(0, 1fr)) !important;
    /* 自动每行：cell 内在决定高度（aspect-ratio 驱动） */
    grid-auto-rows: auto !important;
    gap: 5px !important;
    padding: 8px !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    box-sizing: border-box !important;
    align-content: start !important;
    /* 覆盖 @media(max-width:1024px) 的 58px 死高度 */
    /* 删除：任何 ::before 占位 */
}
/* 移除 V1 的错误 ::before 占位 hack */
.screen-mode-portrait #inventory-grid::before {
    content: none !important;
    display: none !important;
}

/* 单个格子：aspect-ratio=1 保证正方形；内容用 flex 居中 */
.screen-mode-portrait .inv-grid-item {
    /* ===== padding-bottom 方形 hack（兼容所有 WebView/老浏览器）=====
       原理：CSS % padding 永远基于"父容器宽度"计算，
       padding-bottom:100% = 当前格子宽度 × 100% → 完美正方形。*/
    display: block !important;
    position: relative !important;
    width: 100% !important;
    height: 0 !important;
    padding: 0 0 100% 0 !important;
    box-sizing: border-box !important;
    min-width: 0 !important;
    min-height: 0 !important;
    max-width: none !important;
    max-height: none !important;
    /* 视觉：边框 + 背景（背景图在 品质 class 上定义，background 包含 padding-box 所以正常显示）*/
    border-radius: 5px !important;
    border: 1.5px solid #a67c38 !important;
    background-color: rgba(255, 248, 220, 0.9) !important;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.55),
                0 1px 3px rgba(80, 40, 10, 0.13) !important;
    overflow: visible !important;
    aspect-ratio: auto !important;  /* 覆盖旧规则 */
}
.screen-mode-portrait .inv-grid-item-inner {
    /* 绝对定位 填满 padding-bottom 撑出的方形区域 */
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100% !important;
    height: 100% !important;
    padding: 2px !important;
    box-sizing: border-box !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    overflow: hidden !important;
    z-index: 2 !important;
}
.screen-mode-portrait .inv-grid-item-inner img {
    max-width: 100% !important;
    max-height: 100% !important;
    width: 100% !important;
    height: 100% !important;
    object-fit: contain !important;
    display: block !important;
}

/* 数量角标：缩小，不越界 */
.screen-mode-portrait .inv-qty-badge {
    position: absolute !important;
    bottom: 0 !important;
    right: 0 !important;
    left: auto !important;
    top: auto !important;
    font-size: 8.5px !important;
    line-height: 11px !important;
    font-weight: bold !important;
    min-width: 11px !important;
    padding: 0 2px !important;
    background: linear-gradient(135deg, #6d4c41, #8b5a2b) !important;
    color: #fff4d4 !important;
    border-radius: 2px 0 4px 0 !important;
    text-align: center !important;
    z-index: 10 !important;
    box-sizing: border-box !important;
}

/* 选中：金框发光 */
.screen-mode-portrait .inv-grid-item.selected::after {
    content: '' !important;
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 0 !important;
    padding: 0 0 100% 0 !important;
    box-sizing: border-box !important;
    border: 2px solid #d4af37 !important;
    border-radius: 5px !important;
    box-shadow: 0 0 8px rgba(212, 175, 55, 0.75) !important;
    pointer-events: none !important;
    z-index: 30 !important;
    display: block !important;
}

/* 宠物页和仓库页：同样不允许溢出 */
.screen-mode-portrait #hero-tab-pet,
.screen-mode-portrait #hero-tab-warehouse {
    flex: 1 1 auto !important;
    min-height: 0 !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
}

/* ===== F. 横屏媒体查询 (max-width:1024px) 内的 portrait 专属修正 ===== */
/* 保证在 1024px 规则内，竖屏模式强制使用我们的布局，而不是左-右挤压 */
@media screen and (max-width: 1024px) {
    body.screen-mode-portrait #hero-inventory-panel {
        width: min(940px, 94vw) !important;
        height: auto !important;
        max-height: 90dvh !important;
        flex-direction: column !important;
    }
    body.screen-mode-portrait #hero-inventory-panel .hero-panel-left {
        flex: 0 0 200px !important;
        width: 100% !important;
        height: 200px !important;
        border-right: none !important;
        border-bottom: 2px solid #c89e58 !important;
    }
    body.screen-mode-portrait #inventory-grid {
        grid-template-columns: repeat(5, minmax(0, 1fr)) !important;
        grid-auto-rows: auto !important;
        gap: 5px !important;
    }
    body.screen-mode-portrait #hero-inventory-panel .equip-slot {
        width: 32px !important;
        height: 32px !important;
    }
}
/* 横屏与小屏设备关闭按钮触控增强 */
@media screen and (max-height: 600px), screen and (max-width: 950px) {
    .modal-panel .close-btn,
    .panel-header .close-btn,
    #hero-inventory-panel .close-btn,
    #shop-panel .close-btn {
        width: 32px !important;
        height: 32px !important;
        min-width: 32px !important;
        min-height: 32px !important;
        border-radius: 50% !important;
        font-size: 16px !important;
        line-height: 30px !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        cursor: pointer !important;
        touch-action: manipulation !important;
        z-index: 100 !important;
    }
}

/* ==========================================================================
   【任务栏系统】横屏与竖屏响应式适配样式
   ========================================================================== */

/* 快捷菜单中的任务按钮 */
#function-btn-quest {
    position: relative;
    cursor: pointer;
}

/* 横屏顶部已有任务入口，不再重复显示小地图下方的任务追踪框。 */
body:not(.screen-mode-portrait) #hud-quest-tracker {
    display: none !important;
}

/* 竖屏下小地图下方轻巧任务挂签 */
#hud-portrait-quest-badge {
    display: none;
}
.screen-mode-portrait #hud-portrait-quest-badge {
    display: flex !important;
    position: fixed !important;
    top: calc(108px + var(--safe-top)) !important;
    left: calc(8px + var(--safe-left)) !important;
    max-width: calc(100vw - 80px) !important;
    z-index: 2147482960 !important;
    background: linear-gradient(135deg, rgba(30, 20, 10, 0.94), rgba(60, 40, 20, 0.96)) !important;
    border: 1.5px solid #d4af37 !important;
    border-radius: 16px !important;
    padding: 4px 10px !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5), inset 0 0 6px rgba(212, 175, 55, 0.25) !important;
    backdrop-filter: blur(4px) !important;
    cursor: pointer !important;
    align-items: center !important;
    gap: 6px !important;
    transition: transform 0.12s ease !important;
}
.screen-mode-portrait #hud-portrait-quest-badge:active {
    transform: scale(0.95) !important;
}
.portrait-quest-inner {
    display: flex;
    align-items: center;
    gap: 5px;
    width: 100%;
    overflow: hidden;
}
.pq-icon {
    font-size: 14px;
    flex-shrink: 0;
}
.pq-text {
    font-size: 11px;
    color: #fff4d4;
    font-weight: bold;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
}
.pq-arrow {
    font-size: 11px;
    color: #f1c40f;
    font-weight: bold;
    flex-shrink: 0;
}

/* 仙途任务录大面板 - 默认横屏居中 */
#quest-panel {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    box-sizing: border-box;
}

/* 竖屏移动端适配仙途任务录 */
.screen-mode-portrait #quest-panel {
    width: min(940px, 94vw) !important;
    max-width: 94vw !important;
    height: auto !important;
    max-height: 86dvh !important;
    position: fixed !important;
    top: 50% !important;
    left: 50% !important;
    transform: translate(-50%, -50%) !important;
    border-radius: 12px !important;
    border: 2.5px solid #c89e58 !important;
}
.screen-mode-portrait #quest-panel .panel-header {
    height: 36px !important;
    padding: 0 10px !important;
}
.screen-mode-portrait #quest-panel .panel-header h2 {
    font-size: 14px !important;
}
.screen-mode-portrait #quest-panel .quest-tabs-bar {
    height: 38px !important;
}
.screen-mode-portrait #quest-panel .quest-tab-btn {
    line-height: 38px !important;
    font-size: 13px !important;
}
.screen-mode-portrait #quest-panel .quest-panel-body {
    padding: 10px !important;
}

/* 竖屏下随身仓库网格自适应 */
.screen-mode-portrait #warehouse-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr)) !important;
    gap: 4px !important;
}

/* ====================================================================
   角色 / 背包体验收口：统一人物、物品、宠物与仓库的信息层级
   ==================================================================== */
#hero-inventory-panel .hero-tab-guide {
    display: flex;
    align-items: center;
    gap: 6px;
    min-height: 27px;
    padding: 4px 10px;
    box-sizing: border-box;
    color: #6b421e;
    background: linear-gradient(90deg, #fff7df, #f6e5bc, #fff7df);
    border-bottom: 1px solid #d1ad67;
    font-size: 11px;
    line-height: 1.35;
    flex-shrink: 0;
    box-shadow: inset 0 1px rgba(255,255,255,.85);
}
#hero-inventory-panel .hero-tab-guide-icon {
    color: #b87614;
    font-size: 10px;
    text-shadow: 0 1px #fff;
    flex: 0 0 auto;
}
#hero-inventory-panel .hero-tab-guide-text {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
#hero-inventory-panel .hero-panel-left {
    background:
        radial-gradient(ellipse at 50% 35%, rgba(255,255,255,.8), transparent 50%),
        linear-gradient(180deg, #f9edcf 0%, #dfc493 100%) !important;
}
#hero-inventory-panel .equip-slot {
    transition: transform .15s ease, box-shadow .15s ease;
}
#hero-inventory-panel .equip-slot:active {
    transform: scale(.93);
}
#hero-inventory-panel .equip-slot.slot-empty-notice {
    animation: hero-empty-slot-pulse 1.8s ease-in-out infinite;
}
@keyframes hero-empty-slot-pulse {
    0%, 100% { box-shadow: 0 0 0 rgba(212,175,55,0); }
    50% { box-shadow: 0 0 9px rgba(212,175,55,.8); }
}
#hero-inventory-panel #hero-tab-pet > div,
#hero-inventory-panel #hero-tab-warehouse > div {
    background: linear-gradient(180deg, rgba(255,253,245,.92), rgba(242,228,200,.92));
}
#hero-inventory-panel #hero-tab-pet > div > div:first-child,
#hero-inventory-panel #hero-tab-warehouse > div > div:first-child,
#hero-inventory-panel #hero-tab-inventory > div:first-child {
    background: linear-gradient(90deg, #f9efd9, #ead3a3, #f9efd9) !important;
    border-bottom-color: #c89e58 !important;
    box-shadow: inset 0 1px rgba(255,255,255,.85);
}
#hero-inventory-panel #inventory-grid,
#hero-inventory-panel #warehouse-grid {
    background-image: linear-gradient(rgba(115,76,35,.035) 1px, transparent 1px), linear-gradient(90deg, rgba(115,76,35,.035) 1px, transparent 1px);
    background-size: 18px 18px;
}

@media screen and (max-width: 1024px) {
    .screen-mode-portrait #hero-inventory-panel {
        top: 52% !important;
        max-height: 88dvh !important;
    }
    .screen-mode-portrait #hero-inventory-panel .hero-panel-left {
        flex-basis: 190px !important;
        height: 190px !important;
    }
    .screen-mode-portrait #hero-inventory-panel .hero-panel-right {
        max-height: calc(88dvh - 190px) !important;
    }
    .screen-mode-portrait #hero-inventory-panel .hero-tab-guide {
        min-height: 25px !important;
        padding: 3px 8px !important;
        font-size: 10px !important;
    }
}

