* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    font-family: Arial, sans-serif;
    overflow: auto;
    user-select: none; /* 禁止选中文本 */
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

/* Orientation Overlay - Removed as per request */
/* #rotate-overlay styles removed */

.difficulty-menu {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 30px;
    padding: 40px;
    background: rgba(0, 0, 0, 0.35); /* Modified opacity to 0.35 */
    border-radius: 16px;
    box-shadow: 0 0 50px rgba(0, 0, 0, 0.5);
    max-width: 600px;
}

.difficulty-menu h1 {
    color: #4CAF50;
    font-size: 48px;
    text-align: center;
    margin-bottom: 20px;
}

.difficulty-menu h2 {
    color: #fff;
    font-size: 32px;
    text-align: center;
    margin-bottom: 30px;
}

.difficulty-buttons {
    display: flex;
    gap: 20px;
    justify-content: center;
    flex-wrap: wrap;
}

.difficulty-btn {
    padding: 20px 40px;
    font-size: 24px;
    font-weight: bold;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 120px;
}

.difficulty-btn.easy {
    background: #4CAF50;
    color: white;
}

.difficulty-btn.easy:hover {
    background: #45a049;
    transform: scale(1.05);
}

.difficulty-btn.normal {
    background: #FFC107;
    color: white;
}

.difficulty-btn.normal:hover {
    background: #FFB300;
    transform: scale(1.05);
}

.difficulty-btn.hard {
    background: #F44336;
    color: white;
}

.difficulty-btn.hard:hover {
    background: #D32F2F;
    transform: scale(1.05);
}

.version-info {
    margin-top: 20px;
    color: #666;
    font-size: 12px;
    font-family: monospace;
}

.difficulty-info {
    background: rgba(255, 255, 255, 0.1);
    padding: 20px;
    border-radius: 8px;
    margin-top: 20px;
}

.difficulty-info p {
    color: #fff;
    font-size: 16px;
    line-height: 1.6;
    margin: 10px 0;
}

.game-container {
    position: relative;
    box-shadow: 0 0 50px rgba(0, 0, 0, 0.5);
    border-radius: 8px;
    overflow: hidden;
}

#gameCanvas {
    display: block;
    background: #2d2d2d;
    cursor: crosshair;
    touch-action: none;
}



@media (max-width: 768px) {
    .difficulty-menu {
        padding: 20px;
        max-width: 90%;
    }

    .difficulty-menu h1 {
        font-size: 32px;
    }

    .difficulty-menu h2 {
        font-size: 24px;
    }

    .difficulty-buttons {
        flex-direction: column;
        align-items: stretch;
    }

    .difficulty-btn {
        width: 100%;
        padding: 15px 20px;
        font-size: 20px;
    }

    .difficulty-info p {
        font-size: 14px;
    }

    /* .game-container visibility is now handled by JS */

    #gameCanvas {
        width: 100%;
        height: auto;
    }

    .skill-button {
        display: block;
        bottom: 50px; /* 与摇杆对齐 */
        right: 50px;
        width: 80px;
        height: 80px;
        border-radius: 50%;
        padding: 0;
        display: flex;
        justify-content: center;
        align-items: center;
        font-size: 24px;
        background: rgba(255, 69, 0, 0.7); /* 半透明 */
        backdrop-filter: blur(5px);
        -webkit-tap-highlight-color: transparent;
        user-select: none;
    }


}

/* Joystick UI Styles */
#joystick-container {
    position: fixed;
    bottom: 50px; /* 稍微上移，避免太靠底 */
    left: 50px;   /* 稍微右移 */
    width: 120px; /* 稍微调小一点 */
    height: 120px;
    display: none; /* 默认隐藏，JS 检测到移动端或触摸时显示 */
    z-index: 1000;
    /* 避免点击穿透 */
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
}

@media (pointer: coarse) {
    /* 在触摸设备上显示摇杆 */
    #joystick-container {
        display: block;
    }
}

.joystick-base {
    position: relative;
    background: rgba(255, 255, 255, 0.15);
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    box-sizing: border-box;
    display: flex;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(5px);
}

.joystick-stick {
    background: rgba(255, 255, 255, 0.8);
    border-radius: 50%;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
    transition: transform 0.1s cubic-bezier(0.1, 0.7, 1.0, 0.1); /* 没操作时回弹动画 */
}

/* Inventory Grid System */
#inventoryGrid {
    position: relative;
    background: #222;
    border: 2px solid #555;
    border-radius: 4px;
    /* 网格线背景 */
    background-image: 
        linear-gradient(#333 1px, transparent 1px),
        linear-gradient(90deg, #333 1px, transparent 1px);
    background-size: 50px 50px; 
    /* width is dynamic via JS */
    box-sizing: content-box;
    margin: 0 auto;
}

/* 滚动条样式美化 (全局) */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 3px;
}
::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.4);
}

/* 特定容器的滚动条微调 (Inventory, Loot, Shop) */
.inventory-scroll-container::-webkit-scrollbar,
.custom-scroll::-webkit-scrollbar {
    width: 6px;
}
.inventory-scroll-container::-webkit-scrollbar-track,
.custom-scroll::-webkit-scrollbar-track {
    background: #1a1a1a;
}
.inventory-scroll-container::-webkit-scrollbar-thumb,
.custom-scroll::-webkit-scrollbar-thumb {
    background: #444;
}
.inventory-scroll-container::-webkit-scrollbar-thumb:hover,
.custom-scroll::-webkit-scrollbar-thumb:hover {
    background: #666;
}

#lootGrid {
    position: relative;
    background: #222;
    border: 2px solid #555;
    border-radius: 4px;
    background-image: 
        linear-gradient(#333 1px, transparent 1px),
        linear-gradient(90deg, #333 1px, transparent 1px);
    background-size: 50px 50px; 
    /* width/height controlled by JS */
    box-sizing: content-box;
    margin: 0 auto;
}

#lootPlayerInventoryGrid, #stashPlayerGrid, #stashGrid {
    position: relative;
    background: #222;
    border: 2px solid #555;
    border-radius: 4px;
    background-image: 
        linear-gradient(#333 1px, transparent 1px),
        linear-gradient(90deg, #333 1px, transparent 1px);
    background-size: 50px 50px; 
    /* width/height controlled by JS */
    box-sizing: content-box;
    margin: 0 auto;
}

/* 安全箱样式 (复用) */
#secureGrid, #lootSecureGrid {
    position: relative;
    background: #2d3e50;
    border: 2px solid #4a90e2;
    border-radius: 4px;
    background-image: 
        linear-gradient(#34495e 1px, transparent 1px),
        linear-gradient(90deg, #34495e 1px, transparent 1px);
    background-size: 50px 50px;
    /* width/height controlled by JS */
    box-sizing: content-box;
}

#secureGrid {
    margin-top: 10px;
}

.grid-item {
    position: absolute;
    background: rgba(60, 60, 60, 0.8);
    border: 1px solid #666;
    border-radius: 4px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 24px;
    cursor: pointer;
    box-sizing: border-box; /* 包含边框 */
    transition: transform 0.1s, background 0.2s;
    z-index: 10;
}

.grid-item:hover {
    background: rgba(80, 80, 80, 0.9);
    transform: scale(1.02);
    z-index: 11;
}

.grid-item .count {
    position: absolute;
    bottom: 2px;
    right: 4px;
    font-size: 12px;
    color: #fff;
    text-shadow: 1px 1px 0 #000;
}

/* 稀有度边框颜色 */
.grid-item.common { border-color: #ffffff; }
.grid-item.rare { border-color: #40C4FF; box-shadow: 0 0 5px rgba(64, 196, 255, 0.3); }
.grid-item.epic { border-color: #d32ce6; box-shadow: 0 0 8px rgba(211, 44, 230, 0.4); }
.grid-item.legendary { border-color: #FFD700; box-shadow: 0 0 10px rgba(255, 215, 0, 0.5); }
.grid-item.mythic { border-color: #FF0000; box-shadow: 0 0 15px rgba(255, 0, 0, 0.6); animation: pulse-red 2s infinite; }

@keyframes pulse-red {
    0% { box-shadow: 0 0 10px rgba(255, 0, 0, 0.5); }
    50% { box-shadow: 0 0 20px rgba(255, 0, 0, 0.8); }
    100% { box-shadow: 0 0 10px rgba(255, 0, 0, 0.5); }
}

/* Loot Box Specifics */
.loot-slot-unknown {
    background: #333;
    color: #666;
    font-size: 40px;
    border: 2px dashed #555;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* 拖拽落点预览 */
.ghost-placement {
    position: absolute;
    border: 2px dashed #888;
    border-radius: 4px;
    pointer-events: none;
    z-index: 50;
}
.ghost-placement.ghost-valid {
    border-color: #00E676;
    background: rgba(0, 230, 118, 0.2);
}
.ghost-placement.ghost-invalid {
    border-color: #FF5252;
    background: rgba(255, 82, 82, 0.2);
}

/* 丢弃提示样式已移除 */

/* 放大镜旋转动画 */
.magnifier {
    font-size: 24px;
    animation: search-move 1.5s infinite linear;
}

@keyframes search-move {
    0% { transform: translate(0, 0) rotate(0deg); }
    25% { transform: translate(5px, 5px) rotate(10deg); }
    50% { transform: translate(0, 10px) rotate(0deg); }
    75% { transform: translate(-5px, 5px) rotate(-10deg); }
    100% { transform: translate(0, 0) rotate(0deg); }
}

/* 宝箱摸索时的闪烁动画 */
.loot-slot-unknown.revealing {
    animation: pulse 0.5s infinite alternate;
    border-color: #FFD700;
}

@keyframes pulse {
    from { box-shadow: 0 0 5px rgba(255, 215, 0, 0.2); }
    to { box-shadow: 0 0 20px rgba(255, 215, 0, 0.6); }
}

/* Inventory Styles */
#inventoryMenu {
    background: rgba(0, 0, 0, 0.35) !important;
    backdrop-filter: blur(2px) !important;
}

#inventoryMenu .menu-box {
    background: rgba(30, 30, 30, 0.8); 
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.inv-slot {
    width: 60px;
    height: 60px;
    background: #444;
    border: 2px solid #666;
    border-radius: 6px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 32px; /* 增大图标 */
    cursor: pointer;
    position: relative;
    transition: all 0.2s;
    box-shadow: inset 0 0 10px rgba(0,0,0,0.5);
}

.inv-slot:hover {
    background: #555;
    border-color: #888;
    transform: scale(1.05);
    box-shadow: 0 0 15px rgba(255, 255, 255, 0.2);
}

/* 装备槽稀有度发光 */
.inv-slot[data-rarity="rare"] { border-color: #40C4FF; box-shadow: 0 0 10px rgba(64, 196, 255, 0.3); }
.inv-slot[data-rarity="epic"] { border-color: #d32ce6; box-shadow: 0 0 15px rgba(211, 44, 230, 0.4); }
.inv-slot[data-rarity="legendary"] { border-color: #FFD700; box-shadow: 0 0 20px rgba(255, 215, 0, 0.5); }
.inv-slot[data-rarity="mythic"] { border-color: #FF0000; box-shadow: 0 0 25px rgba(255, 0, 0, 0.6); animation: pulse-red 2s infinite; }

.inv-slot .count {
    position: absolute;
    bottom: 2px;
    right: 4px;
    font-size: 12px;
    color: white;
    font-weight: bold;
    text-shadow: 1px 1px 1px black;
}

.inv-slot.empty {
    cursor: default;
    background: #2a2a2a;
    border-color: #333;
}
.inv-slot.empty:hover {
    transform: none;
    border-color: #333;
}

/* 商店物品样式 */
.shop-item {
    transition: transform 0.2s, box-shadow 0.2s;
}

.shop-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 5px 15px rgba(255, 152, 0, 0.3) !important;
    background: rgba(255, 255, 255, 0.15) !important;
}

.shop-buy-btn {
    transition: all 0.2s;
}

.shop-buy-btn:active {
    transform: scale(0.95);
}

/* 确保商店菜单在最上层 */
#shopMenu {
    z-index: 4000;
}
/* 任务目标面板 */
.objective-panel {
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    text-align: center;
    pointer-events: none;
    z-index: 1000;
    text-shadow: 0 2px 4px rgba(0,0,0,0.8);
}

.objective-title {
    font-family: 'Courier New', monospace;
    font-size: 14px;
    color: #B0BEC5;
    letter-spacing: 2px;
    margin-bottom: 4px;
}

.objective-text {
    font-family: 'Impact', sans-serif;
    font-size: 24px;
    color: #FFD700;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* 资源面板 (HUD) */
.resource-panel {
    position: absolute;
    top: 80px; /* 下移，避免挡住左上角的玩家属性显示 */
    left: 20px; 
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 2000; /* 提高层级 */
    pointer-events: none; /* 防止遮挡点击 */
}

.resource-item {
    display: flex;
    align-items: center;
    background: rgba(0, 0, 0, 0.5);
    padding: 4px 10px; /* 减小内边距 */
    border-radius: 15px; /* 稍微减小圆角 */
    border: 1px solid rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(4px);
    transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    min-width: 80px; /* 设定最小宽度，保持对齐 */
}

.resource-item.bump {
    transform: scale(1.1); /* 减小动画幅度 */
}

.resource-item .icon {
    font-size: 16px; /* 减小图标 */
    margin-right: 6px;
}

.resource-item span:last-child {
    color: white;
    font-size: 14px; /* 减小字体 */
    font-weight: bold;
    font-family: monospace;
}

/* Game Notification */
.game-notification {
    position: absolute;
    top: 100px; /* 在 boss 血条下方 */
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.8);
    border: 2px solid #00E676;
    border-radius: 8px;
    padding: 15px 30px;
    z-index: 1000;
    pointer-events: none;
    animation: slideDown 0.5s ease-out;
}

.game-notification span {
    color: #00E676;
    font-size: 24px;
    font-weight: bold;
    font-family: monospace;
    text-transform: uppercase;
    letter-spacing: 2px;
}

@keyframes slideDown {
    from { transform: translate(-50%, -50px); opacity: 0; }
    to { transform: translate(-50%, 0); opacity: 1; }
}

/* Pause Button */
.pause-button {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 40px;
    height: 40px;
    background: rgba(0, 0, 0, 0.5);
    border: 2px solid rgba(255, 255, 255, 0.5);
    border-radius: 50%;
    color: white;
    font-size: 20px;
    cursor: pointer;
    z-index: 1001;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.3s ease;
}

.pause-button:hover {
    background: rgba(0, 0, 0, 0.8);
    transform: scale(1.1);
}

/* Overlay Menus (Pause & Game Over & Upgrade) */
.overlay, .overlay-menu {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.35);
    backdrop-filter: blur(5px);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 3000;
    animation: fadeIn 0.3s ease;
}

/* Resource Panel Styles */
.resource-panel {
    position: absolute;
    top: 20px;
    left: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 100;
    pointer-events: none; /* 防止阻挡鼠标事件 */
}

.resource-item {
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(0, 0, 0, 0.5);
    padding: 8px 12px;
    border-radius: 20px;
    color: #fff;
    font-weight: bold;
    border: 1px solid rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(2px);
    transition: transform 0.2s;
}

.resource-item .icon {
    font-size: 20px;
}

@media (max-width: 768px) {
    /* Mobile Resource Panel: Horizontal, under attributes (assuming attributes at top-left) */
    .resource-panel {
        top: 60px; /* Position under the hypothetical player attributes/HP bar */
        left: 10px;
        flex-direction: row;
        flex-wrap: wrap;
        gap: 5px;
        max-width: 90%;
    }

    .resource-item {
        padding: 4px 8px;
        font-size: 12px;
        border-radius: 12px;
        background: rgba(0, 0, 0, 0.2); /* Lighter background for less visual weight */
        border: none;
    }

    .resource-item .icon {
        font-size: 14px;
        margin-right: 2px;
    }
    
    /* Mobile Buff Selection Layout (2 top, 1 bottom) */
    #upgradeCards {
        display: grid !important;
        grid-template-columns: repeat(2, 1fr);
        gap: 10px !important;
        width: 100%;
    }
    
    #upgradeCards .upgrade-card {
        width: auto !important;
        height: auto !important;
        min-height: 120px;
        margin: 0 !important;
    }

    /* Make the 3rd card span full width if it's the last one (for 3 items) */
    #upgradeCards .upgrade-card:last-child:nth-child(3) {
        grid-column: span 2;
        width: 60% !important;
        margin: 0 auto !important;
    }

    /* Mobile Loot Box Compact Layout */
    #lootBoxMenu .menu-box {
        min-width: 0 !important;
        width: 95% !important;
        height: auto !important;
        max-height: 90vh !important;
        padding: 10px !important;
        gap: 5px !important;
    }

    #lootBoxMenu h2 {
        font-size: 18px !important;
        margin-bottom: 10px !important;
    }

    /* Adjust grids inside loot box for mobile */
    #lootBoxMenu .inventory-scroll-container {
        padding: 5px !important;
    }

    #lootBoxMenu .equip-slot-container .inv-slot {
        width: 30px !important;
        height: 30px !important;
        font-size: 16px !important;
    }
    
    /* Make the layout vertical on mobile for loot box */
    #lootBoxMenu > .menu-box > div {
        flex-direction: column;
        overflow-y: auto;
    }
    
    #lootBoxMenu > .menu-box > div > div:first-child {
        width: 100% !important;
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: space-between;
    }
}

/* Loot Box Global Compact Styles */
#lootBoxMenu .menu-box {
    padding: 15px !important;
    max-width: 900px;
}

#lootBoxMenu .equip-slot-container {
    gap: 5px !important;
}

#lootBoxMenu .inv-slot {
    width: 40px;
    height: 40px;
    font-size: 20px;
}

/* Close Button Style */
.close-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(0,0,0,0.5);
    border: 1px solid rgba(255,255,255,0.3);
    color: #fff;
    font-size: 24px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 100;
    transition: all 0.2s;
}

.close-btn:hover {
    background: rgba(200, 0, 0, 0.8);
    transform: scale(1.1);
}

.menu-box {
    background: rgba(30, 30, 30, 0.95);
    border-radius: 16px;
    padding: 30px;
    box-shadow: 0 0 50px rgba(0,0,0,0.8);
    max-height: 90vh;
    overflow-y: auto; /* 防止内容过高溢出 */
}

/* Upgrade Card Styles */
.upgrade-card {
    background: rgba(30, 30, 30, 0.95);
    border-radius: 10px;
    padding: 20px;
    width: 220px;
    height: 300px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    box-shadow: 0 4px 15px rgba(0,0,0,0.5);
    border: 2px solid #fff; /* Default border, overridden by JS */
}

.upgrade-card:hover {
    transform: scale(1.05);
    /* box-shadow handled by JS for color or use generic here */
    box-shadow: 0 0 20px rgba(255, 255, 255, 0.5); 
}

.overlay-menu h2 {
    color: white;
    font-size: 48px;
    margin-bottom: 40px;
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
}

.menu-buttons {
    display: flex;
    flex-direction: column;
    gap: 20px;
    align-items: center;
}

.menu-btn {
    padding: 15px 40px;
    font-size: 24px;
    background: transparent;
    border: 2px solid white;
    color: white;
    border-radius: 30px;
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 200px;
}

.menu-btn:hover {
    background: white;
    color: #1a1a2e;
    transform: scale(1.05);
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Mobile Optimizations */
@media (max-width: 768px) {
    /* Resource Panel: Compact Top Row, positioned under attributes */
    .resource-panel {
        top: 50px; /* Moved down to be under top-left attributes */
        left: 10px;
        right: auto;
        flex-direction: row;
        flex-wrap: wrap;
        gap: 4px;
        max-width: 80%;
    }

    .resource-item {
        padding: 2px 6px;
        min-width: auto;
        border-radius: 8px;
        background: rgba(0, 0, 0, 0.6);
    }

    .resource-item .icon {
        font-size: 14px;
        margin-right: 2px;
    }

    .resource-item span:last-child {
        font-size: 12px;
    }

    /* Upgrade Cards Mobile Adaptation */
    .upgrade-card {
        width: 45% !important; /* 2 cards per row */
        height: auto !important;
        min-height: 180px;
        padding: 10px !important;
        margin-bottom: 10px;
    }
    .upgrade-card h3 {
        font-size: 16px !important;
        margin-bottom: 5px !important;
    }
    .upgrade-card p {
        font-size: 12px !important;
        line-height: 1.2 !important;
    }
    .upgrade-card span {
        margin-top: 10px !important;
        font-size: 10px !important;
    }

    /* Dialogue System: Top Center & Smaller */
    #dialogue-layer-game, #dialogue-layer-ui {
        width: 95% !important;
        bottom: auto !important;
        top: 100px !important; /* Below resource panel */
        transform: translateX(-50%) !important;
    }

    #dialogue-layer-game .dialogue-text, #dialogue-layer-ui .dialogue-text {
        font-size: 12px !important;
    }

    #dialogue-layer-game > div, #dialogue-layer-ui > div {
        padding: 8px !important;
    }
    
    #dialogue-layer-game > div > div:first-child, 
    #dialogue-layer-ui > div > div:first-child {
        width: 32px !important;
        height: 32px !important;
        font-size: 20px !important;
        margin-right: 8px !important;
    }

    /* Menus: Full Screen & Responsive */
    .menu-box {
        width: 98% !important;
        max-width: 98% !important;
        max-height: 98vh !important;
        padding: 10px;
    }

    /* Inventory Layout Optimization */
    #inventoryMenu .menu-box > div {
        flex-direction: column;
    }

    #leftPanel {
        width: 100% !important;
        flex-direction: row;
        flex-wrap: wrap;
        gap: 5px;
        padding: 5px;
    }

    #statsPreview {
        width: 100%;
        font-size: 12px;
    }

    /* Loot Box Layout - Compact */
    #lootBoxMenu .menu-box {
        min-width: 0 !important;
        height: auto !important;
        max-height: 95vh !important;
        padding: 8px !important;
        gap: 10px !important;
    }
    
    #lootBoxMenu .menu-box > div {
        flex-direction: column;
        gap: 8px !important;
    }

    #lootBoxMenu .menu-box > div > div:first-child {
        width: 100% !important;
        flex-direction: row;
        flex-wrap: wrap;
        gap: 8px;
        padding: 5px;
        background: rgba(255, 255, 255, 0.05);
        border-radius: 8px;
    }

    /* Compact item grids on mobile */
    #inventoryGrid, #lootGrid, #lootPlayerInventoryGrid, #stashPlayerGrid, #stashGrid {
        background-size: 40px 40px !important; /* Smaller grid on mobile */
    }

    .grid-item {
        font-size: 20px !important;
    }

    .inv-slot {
        width: 45px !important;
        height: 45px !important;
        font-size: 24px !important;
    }

    /* Hide detailed descriptions if space is tight */
    #lootItemDesc, #itemDescription {
        font-size: 10px;
        height: 60px !important;
    }
    
    /* Adjust Pause Button */
    .pause-button {
        width: 30px;
        height: 30px;
        font-size: 16px;
        top: 10px;
        right: 10px;
    }
    
    /* Adjust Objective Text */
    .objective-panel {
        top: 30px;
        width: 100%;
    }
    .objective-text {
        font-size: 14px;
    }
    .objective-title {
        font-size: 10px;
    }
}

/* Ensure Landscape mode handles height properly */
@media (max-height: 500px) and (orientation: landscape) {
    .resource-panel {
        flex-direction: row;
    }
    
    .menu-box {
        flex-direction: row;
    }
    
    /* Force side-by-side for landscape even on small screens */
    #inventoryMenu .menu-box > div,
    #lootBoxMenu .menu-box > div {
        flex-direction: row;
    }
    
    #leftPanel {
        width: 200px !important;
        flex-direction: column;
    }
}
