/**
 * 關卡選擇器樣式
 */

.level-selector-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: hsl(0, 60%, 24%);
    /* 暗紅色底 */
    backdrop-filter: blur(15px);
    z-index: 10005;
    /* 高於 Difficulty Selector */
    display: flex;
    justify-content: center;
    align-items: center;
}

.level-selector-overlay.hidden {
    display: none;
}

/* 邊框 */
.level-selector-container {
    width: 95%;
    max-width: 600px;
    height: 98%;
    background: hsl(0, 60%, 24%);
    /* 暗紅色底 */
    border: 2px solid hsl(45, 70%, 40%);
    /* 金色邊框 */
    border-radius: 30px;
    box-shadow: 0 0 30px rgba(0, 0, 0, 0.8), inset 0 0 10px rgba(255, 215, 0, 0.2);
    padding: 10px;
    display: flex;
    flex-direction: column;
    color: hsl(51, 100%, 50%);
    /* 金黃色字體 */
    position: relative;
    overflow: hidden;
    user-select: none;
    /* 防止選擇文字 */
}

/* 標題 */
.level-selector-title {
    text-align: center;
    font-size: 40px;
    font-weight: bold;
    /*字間距*/
    letter-spacing: 4px;
    margin: 10px 0 10px 0;
    color: hsl(45, 50%, 80%);
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);

}

/* 關卡格 */
.level-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    /* 寬 5 格 */
    gap: 10px;
    overflow-y: auto;
    padding: 20px;
    flex: 1;
    scrollbar-width: thin;
    scrollbar-color: hsl(45, 50%, 80%) transparent;
    cursor: grab;
    touch-action: pan-y;
    /* 允許垂直原生捲動，但我們 JS 會攔截拖拽 */
    -webkit-overflow-scrolling: touch; /* 啟動 iOS 原生慣性捲動 */
}

.level-grid:active {
    cursor: grabbing;
}

.level-grid::-webkit-scrollbar {
    width: 6px;
}

.level-grid::-webkit-scrollbar-thumb {
    background-color: #ffd700;
    border-radius: 3px;
}

/*格子*/
.level-item {
    aspect-ratio: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 8px;
    font-size: 32px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s;
    position: relative;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
    border: 2px solid rgba(255, 255, 255, 0.3);
    color: white;
}

.level-item:hover:not(.locked) {
    transform: scale(1.1);
    filter: brightness(1.5);
    z-index: 2;
    box-shadow: 0 0 8px hsla(0, 0%, 100%, 0.5);
}

/* 難度背景顏色 */
.green-bg {
    background: linear-gradient(135deg, #27ae60, #1e8449);
}

.blue-bg {
    background: linear-gradient(135deg, #2980b9, #1a5276);
}

.red-bg {
    background: linear-gradient(135deg, #c0392b, #7b241c);
}

.purple-bg {
    background: linear-gradient(135deg, #8e44ad, #512e5f);
}

.gold-bg {
    background: linear-gradient(135deg, #f1c40f, #b7950b);
    color: #333;
}

/* 鎖定狀態：暗亮度顏色顯示 */
.level-item.locked {
    opacity: 0.5; /* 替換 filter: brightness 解決 iPad 灰色渲染 Bug */
    pointer-events: none; /* 讓鎖定的按鈕不觸發 hover 甚至 click */
    cursor: not-allowed;
    border-color: transparent;
}

/* 狀態圖示 */
.status-icon {
    position: absolute;
    bottom: -4px;
    right: -4px;
    font-size: 28px;
    line-height: 1;
}

.status-icon.star {
    color: #ffd700;
    /* 黃色星星 */
    text-shadow: 0 0 3px rgba(0, 0, 0, 0.8);
}

.status-icon.lock {
    color: #fff;
    opacity: 0.8;
}

.level-num {
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.8);
}

@media (max-width: 480px) {
    .level-item {
        font-size: 24px;
    }

    .level-grid {
        gap: 10px;
    }
}