/**
 * 簡單的選項佈局系統
 * 1. 選項橫列佈局，每個選項一行
 * 2. 選項外框佔螢幕 2/3 寬度
 * 3. 選項平均分配在外框中
 * 4. 容器高度根據選項數量動態調整
 * 5. 滾動提示系統
 */

/* ========================================
   主選單背景和標題
   ======================================== */
main-screen {
    background-image: url('../assets/scenes/cover.png');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}

/* 封面遊戲標題容器 */
.dynamic-title-container {
    position: absolute;
    top: 25vh;
    left: 5vw;
    right: 220px; /* 避開右下角選單 */
    bottom: 25vh;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10;
    color: white;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.8);
    overflow: hidden;
    box-sizing: border-box;
    padding: 20px;
}

/* 封面遊戲標題 */
.dynamic-main-title {
    font-weight: 900;
    margin: 0;
    color: #ffffff;
    text-shadow: 
        3px 3px 6px rgba(0, 0, 0, 0.8),
        0 0 30px rgba(255, 255, 255, 0.3);
    font-family: 'Microsoft JhengHei', 'PingFang TC', 'Noto Sans TC', sans-serif;
    word-wrap: break-word;
    overflow-wrap: break-word;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    text-align: center;
    font-size: 3rem;
    line-height: 1.2;
    letter-spacing: 0.05em;
}

/* 遊戲內隱藏標題 */
game-screen .dynamic-title-container {
    display: none !important;
}

/* ========================================
   主選單按鈕
   ======================================== */
main-screen main-menu {
    position: absolute;
    bottom: 20px;
    right: 20px;
    z-index: 3;
}

main-menu button[data-action="start"],
main-menu button[data-action="open-screen"],
main-menu button[data-open="load"],
main-menu button[data-open="settings"] {
    background-color: rgba(0, 0, 0, 0.7) !important;
    color: #ffffff !important;
    border: 1px solid rgba(255, 255, 255, 0.3) !important;
}

/* ========================================
   CSS 變數 - 最大可用高度
   ======================================== */
:root {
    /* 移除所有尺寸變數，完全交由 JS 控制 */
}

/* ========================================
   遊戲內選項佈局系統 (最終版)
   ======================================== */

/* 選項容器 - 定位和尺寸完全由 JS 控制 */
choice-container {
    /* JS 會覆寫 position, top, left, transform, maxHeight */
    position: absolute !important;
    
    width: 66.67vw !important;
    height: auto !important;
    /* 移除：max-height 由 JS 動態設定 */
    /* max-height: var(--max-available-height) !important; */
    
    background-color: rgba(0, 0, 0, 0.85) !important;
    border: 2px solid rgba(255, 255, 255, 0.3) !important;
    border-radius: 15px !important;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6) !important;
    
    padding: 16px !important;
    /* 修正：改為 scroll 讓滑桿常駐 */
    overflow-y: scroll !important;
    overflow-x: hidden !important;
    z-index: 100 !important;

    box-sizing: border-box !important;
    
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.5) rgba(0, 0, 0, 0.5);
}

choice-container::-webkit-scrollbar {
    width: 8px;
}

choice-container::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.5);
    border-radius: 4px;
    /* 新增：使用內陰影技巧強制軌道渲染，使其常駐 */
    box-shadow: inset 0 0 6px rgba(0, 0, 0, 0.3);
}

choice-container::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.5);
    border-radius: 4px;
}

choice-container::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.7);
}

choice-container.has-more-options::after {
    content: "↓ 更多選項 ↓";
    position: sticky;
    bottom: -16px;
    display: block;
    text-align: center;
    padding: 8px 0;
    margin: 0 -16px;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.9));
    color: rgba(255, 255, 255, 0.8);
    font-size: 0.9rem;
    pointer-events: none;
    z-index: 101;
}

choice-container [data-content=wrapper] {
    display: flex !important;
    flex-direction: column !important;
    justify-content: flex-start !important;
    gap: 8px !important;
    width: 100% !important;
    height: auto !important;
}

choice-container button {
    width: 100% !important;
    min-height: 50px !important;
    flex-shrink: 0;
    height: auto !important;
    padding: 12px 16px !important;
    margin: 0 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: flex-start !important;
    text-align: left !important;
    background-color: rgba(255, 255, 255, 0.15) !important;
    border: 2px solid rgba(255, 255, 255, 0.4) !important;
    color: #ffffff !important;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8) !important;
    border-radius: 8px !important;
    font-size: inherit !important;
    word-wrap: break-word !important;
    white-space: normal !important;
    hyphens: auto !important;
    overflow-wrap: break-word !important;
    line-height: 1.4 !important;
}

choice-container button:hover,
choice-container button:focus {
    background-color: rgba(255, 255, 255, 0.25) !important;
    border-color: rgba(255, 255, 255, 0.6) !important;
}

/* ========================================
   響應式調整
   ======================================== */

@media screen and (max-width: 1024px) {
    /* 不再需要設定 :root 變數 */
}

@media screen and (max-width: 768px) {
    choice-container {
        width: 75vw !important;
    }
}

@media screen and (max-width: 480px) {
    choice-container {
        width: 80vw !important;
    }
    choice-container button {
        padding: 10px 14px !important;
        font-size: 0.9rem !important;
    }
}

@media screen and (max-width: 360px) {
    choice-container {
        width: 84vw !important;
    }
    choice-container button {
        padding: 8px 12px !important;
        font-size: 0.85rem !important;
    }
}