#ui { 
    position: absolute; 
    top: 20px; 
    left: 20px; 
    width: 280px; /* 固定宽度 */
    background: rgba(255,255,255,0.9); 
    padding: 15px; 
    border-radius: 8px; 
    line-height: 1.6; 
    box-shadow: 0 2px 10px rgba(0,0,0,0.1); 
    /* 动画时长 0.4s (300-500ms) */
    transition: left 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
    z-index: 100;
}

#ui.collapsed {
    left: -320px; /* 280 + 30 + margin, 确保完全隐藏主体 */
}

/* 关卡选择面板 - 独立右侧小窗 */
#level-panel {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 220px;
    background: rgba(255,255,255,0.9);
    padding: 15px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    transition: right 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
    z-index: 100;
}

#level-panel.collapsed {
    right: -260px; /* 220 + 30 + margin */
}

/* 侧边切换按钮 - 位于 #ui 内部 */
#toggleSidebarBtn {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 28px;
    height: 28px;
    background: transparent;
    color: #555;
    border: 1px solid #ddd;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
    z-index: 102;
    padding: 0;
    font-size: 14px;
    line-height: 1;
}

/* 收起状态下的按钮样式 - 变为侧边悬浮条 */
#ui.collapsed #toggleSidebarBtn {
    position: fixed; /* 脱离 #ui 的相对定位 */
    left: 0;
    top: 20px;
    right: auto;
    background: #2c3e50; /* 深色高对比 */
    color: #fff;
    border: none;
    width: 36px;
    height: 48px;
    border-radius: 0 6px 6px 0;
    box-shadow: 2px 2px 8px rgba(0,0,0,0.3);
    font-size: 18px;
}

#toggleSidebarBtn:hover {
    background: #f0f0f0;
    color: #333;
    transform: scale(1.1);
}

#ui.collapsed #toggleSidebarBtn:hover {
    background: #34495e;
    color: #fff;
    width: 44px; /* 悬停伸长 */
    transform: none;
}

/* --- 关卡面板切换按钮 (类似左侧) --- */
#toggleLevelPanelBtn {
    position: absolute;
    top: 10px;
    right: 10px; /* 放在右上角，避免遮挡左侧文字 */
    width: 28px;
    height: 28px;
    background: transparent;
    color: #555;
    border: 1px solid #ddd;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
    z-index: 102;
    padding: 0;
    font-size: 14px;
    line-height: 1;
}

/* 关卡面板收起状态 - 按钮贴右侧 */
#level-panel.collapsed #toggleLevelPanelBtn {
    position: fixed;
    right: 0;
    left: auto;
    top: 20px;
    background: #2c3e50;
    color: #fff;
    border: none;
    width: 36px;
    height: 48px;
    border-radius: 6px 0 0 6px; /* 圆角在左侧 */
    box-shadow: -2px 2px 8px rgba(0,0,0,0.3);
    font-size: 18px;
}

#toggleLevelPanelBtn:hover {
    background: #f0f0f0;
    color: #333;
    transform: scale(1.1);
}

#level-panel.collapsed #toggleLevelPanelBtn:hover {
    background: #34495e;
    color: #fff;
    width: 44px;
    transform: none;
}

/* 移动端适配 */
@media (max-width: 768px) {
    #ui {
        width: 240px;
        font-size: 14px;
    }
    
    #level-panel {
        width: 180px;
        right: 10px;
        top: 60px; /* 避开可能的顶部元素 */
        font-size: 12px;
    }
    
    #toggleSidebarBtn, #toggleLevelPanelBtn {
        width: 32px;
        height: 32px;
    }
}
