/* ==========================================================================
   1. 全域與重置 (Global & Reset)
   ========================================================================== */
* {
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 0;
    font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
    overflow: hidden;
    width: 100vw;
    height: 100vh;
    background-color: #000000; /* 黑色背景，隱藏視訊時會顯示這層 */
}

/* ==========================================================================
   2. 視訊與畫布 (Video & Canvas)
   ========================================================================== */
#video-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
}

.output_canvas {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* ==========================================================================
   3. UI 互動層 (UI Interaction Layer)
   ========================================================================== */
#root {
    position: relative;
    z-index: 10;
    width: 100%;
    height: 100%;
    pointer-events: none; /* 讓滑鼠可以穿透點擊背後的視訊 Canvas */
}

button, input, label, select, .settings-overlay {
    pointer-events: auto; /* 確保所有的 UI 元素都可以被正常點擊 */
}

/* ==========================================================================
   4. 左上角：設定按鈕 (Top Left: Settings Toggle)
   ========================================================================== */
#settings-toggle-btn {
    position: absolute;
    top: 20px;
    left: 20px;
    background-color: #e74c3c;
    color: white;
    border: none;
    border-radius: 8px;
    padding: 10px 20px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.2);
    transition: transform 0.2s, background 0.2s;
}

#settings-toggle-btn:hover {
    background-color: #c0392b;
    transform: scale(1.05);
}

/* ==========================================================================
   5. 右下角：主控選單與按鈕 (Bottom Right: Main Actions)
   ========================================================================== */
.main-actions {
    position: absolute;
    bottom: 30px;
    right: 20px;
    background-color: rgba(40, 40, 40, 0.85);
    padding: 15px;
    border-radius: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(10px);
}

/* 基礎按鈕樣式 (藥丸形狀) */
.action-btn {
    border: none;
    border-radius: 25px;
    padding: 12px 24px;
    font-size: 14px;
    font-weight: bold;
    color: white;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
}

.action-btn:hover {
    filter: brightness(1.1);
    transform: translateX(-5px); /* 懸停時會稍微往左邊凸出來 */
}

/* 按鈕顏色配置庫 */
.blue-btn { background-color: #3498db; }
.orange-btn { background-color: #f39c12; }
.gray-btn { background-color: #555555; }

/* 🌟 確保自由演奏按鈕預設為藍色 (解決您剛剛的問題) */
#free-play-btn {
    background-color: #3498db;
    color: white;
}

/* ==========================================================================
   6. 底部：進度條 (Bottom: Progress Bar)
   ========================================================================== */
#progress-container {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    width: 50%;
    height: 10px;
    background-color: rgba(255, 255, 255, 0.3);
    border-radius: 5px;
    overflow: hidden;
    pointer-events: auto;
    cursor: pointer;
    z-index: 20;
}

#progress-fill {
    height: 100%;
    width: 0%;
    background: #f39c12;
    transition: width 0.1s linear; /* 讓進度條跑起來更平滑 */
}

/* ==========================================================================
   7. 中央彈窗：系統設定外框 (Modal Settings)
   ========================================================================== */
.settings-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    z-index: 100;
}

.settings-overlay.show {
    opacity: 1;
    visibility: visible;
}

.settings-panel {
    background-color: white;
    width: 90%;
    max-width: 450px;
    border-radius: 16px;
    padding: 25px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
    transform: translateY(-20px);
    transition: transform 0.3s ease;
}

.settings-overlay.show .settings-panel {
    transform: translateY(0);
}

/* 彈窗標題區塊 */
.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #eee;
    padding-bottom: 15px;
    margin-bottom: 20px;
}

.panel-header h2 {
    margin: 0;
    font-size: 18px;
    color: #333;
    font-weight: bold;
}

.close-btn {
    background: none;
    border: none;
    font-size: 24px;
    color: #888;
    cursor: pointer;
}

.close-btn:hover {
    color: #333;
}

/* 彈窗內部卡片 (分類區塊，例如：線上歌曲、本機上傳) */
.control-card {
    background-color: #fafafa;
    border: 1px solid #f0f0f0;
    border-radius: 10px;
    padding: 15px;
    margin-bottom: 15px;
}

.control-card h3 {
    margin: 0 0 10px 0;
    font-size: 14px;
    color: #666;
    font-weight: bold;
}

/* ==========================================================================
   8. 彈窗內部的表單與小按鈕 (Forms & Little Buttons)
   ========================================================================== */
.search-input {
    width: 100%;
    padding: 12px 15px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 15px;
    color: #555;
    margin-bottom: 12px;
    box-sizing: border-box;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.search-input:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.15);
}

.panel-select {
    width: 100%;
    padding: 12px 15px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 15px;
    color: #333;
    background-color: white;
    cursor: pointer;
    box-sizing: border-box;
    transition: border-color 0.2s;
    outline: none;
    appearance: auto;
}

.panel-select:focus {
    border-color: #3498db;
}

.upload-btn {
    display: block;
    width: 100%;
    text-align: center;
    background-color: #e0e0e0;
    color: #333;
    font-weight: bold;
    padding: 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.upload-btn:hover {
    background-color: #d0d0d0;
}

/* 橫向按鈕列 (播放控制) */
.btn-row {
    display: flex;
    gap: 8px;
}

.sub-btn {
    flex: 1;
    background-color: white;
    border: 1px solid #ddd;
    color: #555;
    padding: 8px 0;
    border-radius: 6px;
    cursor: pointer;
    transition: background-color 0.2s, border-color 0.2s;
}

.sub-btn:hover {
    background-color: #f0f0f0;
    border-color: #ccc;
}

/* 單一滿版按鈕 (彈窗內) */
.mode-btn {
    width: 100%;
    background-color: white;
    border: 1px solid #ddd;
    color: #333;
    font-weight: bold;
    padding: 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.2s, border-color 0.2s;
}

.mode-btn:hover {
    background-color: #f5f5f5;
    border-color: #ccc;
}

.placeholder-text {
    font-size: 13px;
    color: #999;
}

/* ==========================================================================
   9. 動態狀態標籤 (Active States)
   ========================================================================== */
/* 🌟 按鈕被按下、啟動時的發光綠色狀態 */
.active-mode {
    background-color: #2ecc71 !important;
    box-shadow: 0 0 15px rgba(46, 204, 113, 0.8) !important;
    transform: scale(1.05) !important;
    color: white !important;
}

/* ==========================================================================
   🎤 長號系統專用 KTV 字幕特效
   ========================================================================== */
.lyrTok {
    position: relative;
    display: inline-block;
    white-space: pre; 
    margin: 0 2px;
}

/* 已經唱過的字 */
.lyrTok.done > span:first-child {
    color: #ffd700;
    text-shadow: 2px 2px 0 #000, -2px -2px 0 #000, 2px -2px 0 #000, -2px 2px 0 #000, 0 0 10px #ffd700;
}

/* 正在唱的字：由左掃到右 */
.lyrTok .ink {
    position: absolute;
    left: 0;
    top: 0;
    width: 0%; 
    overflow: hidden;
    color: #ffd700;
    white-space: pre;
    text-shadow: 2px 2px 0 #000, -2px -2px 0 #000, 2px -2px 0 #000, -2px 2px 0 #000, 0 0 15px #ffd700;
    transition: width 0.1s linear; 
}