/* public/css/style.css */
:root {
    --bg-color: #1a1a2e;
    --card-bg: #16213e;
    --primary-color: #e94560;
    --secondary-color: #0f3460;
    --success-color: #4caf50;
    --danger-color: #f44336;
    --text-color: #eaeaea;
    --highlight: #f9a826;
    --border-radius: 8px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Segoe UI', Tahoma, sans-serif; background-color: var(--bg-color); color: var(--text-color); display: flex; justify-content: center; align-items: center; min-height: 100vh; }
#app-container { width: 100%; max-width: 800px; padding: 20px; }
header h1 { text-align: center; margin-bottom: 30px; color: var(--primary-color); }

/* ==== 視圖控制 ==== */
.view-section { display: none; animation: fadeIn 0.3s ease-in-out; }
.view-section.active { display: block; }
.hidden { display: none !important; }

/* ==== 基礎元件 ==== */
.card { background-color: var(--card-bg); padding: 30px; border-radius: var(--border-radius); box-shadow: 0 4px 6px rgba(0,0,0,0.3); margin-bottom: 20px; text-align: center; }
.divider { text-align: center; margin: 20px 0; color: #666; font-weight: bold; }
input[type="text"], input[type="password"] { width: 100%; padding: 12px; margin: 10px 0; border: none; border-radius: var(--border-radius); background-color: rgba(255,255,255,0.1); color: var(--text-color); font-size: 16px; }
input:focus { outline: 2px solid var(--primary-color); }

/* 按鈕系統 */
button { width: 100%; padding: 12px; margin-top: 15px; border: none; border-radius: var(--border-radius); font-size: 16px; font-weight: bold; cursor: pointer; transition: background-color 0.2s; color: white; }
.primary-btn { background-color: var(--primary-color); }
.primary-btn:hover { background-color: #d13d55; }
.secondary-btn { background-color: var(--secondary-color); }
.secondary-btn:hover { background-color: #0b274a; }
.success-btn { background-color: var(--success-color); }
.success-btn:hover { background-color: #388e3c; }
.danger-btn { background-color: var(--danger-color); }
.danger-btn:hover { background-color: #d32f2f; }
button:disabled { background-color: #555; cursor: not-allowed; }

/* ==== 大廳與名單 ==== */
.lobby-header { text-align: center; margin-bottom: 20px; }
.highlight { color: var(--highlight); font-size: 1.5em; letter-spacing: 2px; }
.player-list-container { background-color: var(--card-bg); padding: 20px; border-radius: var(--border-radius); margin-bottom: 20px; }
#player-list { list-style-type: none; margin-top: 10px; }
#player-list li { padding: 10px; border-bottom: 1px solid rgba(255,255,255,0.1); display: flex; justify-content: space-between; }
.host-badge { background-color: var(--highlight); color: #000; padding: 2px 6px; border-radius: 4px; font-size: 0.8em; font-weight: bold; }

/* ==== 檔案總管 (房主選擇區) ==== */
.file-item { display: flex; justify-content: space-between; align-items: center; padding: 10px; border-bottom: 1px solid rgba(255,255,255,0.1); transition: background 0.2s; gap: 10px; }
.file-item:hover { background: rgba(255,255,255,0.05); }
.file-item.is-folder { color: var(--highlight); font-weight: bold; cursor: pointer; }
.file-info { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.file-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; text-align: left; }
.styled-cb { width: 18px; height: 18px; cursor: pointer; flex-shrink: 0; margin: 0; }
.mini-preview-btn { background: var(--secondary-color); color: white; border: none; padding: 6px 12px !important; border-radius: 4px; cursor: pointer; font-size: 0.85em; width: max-content !important; flex-shrink: 0; margin: 0 !important; }
.mini-preview-btn:hover { background: #0b274a; }

/* ==== 遊戲核心區塊 ==== */
.game-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 15px; flex-wrap: wrap; gap: 10px; }
.header-stats { display: flex; gap: 10px; align-items: center; }
.timer-display { font-size: 1.1rem; font-weight: bold; color: var(--highlight); background: rgba(0,0,0,0.5); padding: 5px 15px; border-radius: 20px; }
.progress-badge { font-size: 1.1rem; font-weight: bold; color: #fff; background: var(--success-color); padding: 5px 15px; border-radius: 20px; transition: all 0.3s ease; }

/* 影片與倒數 */
.video-container { position: relative; width: 100%; background: #000; border-radius: var(--border-radius); overflow: hidden; margin-bottom: 15px; aspect-ratio: 16/9; display: flex; justify-content: center; align-items: center; }
#dubbing-video { width: 100%; height: 100%; object-fit: contain; }
#countdown-overlay { position: absolute; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0, 0, 0, 0.7); display: flex; justify-content: center; align-items: center; font-size: 8rem; font-weight: bold; color: var(--highlight); z-index: 10; text-shadow: 0 0 20px rgba(249, 168, 38, 0.8); }
#exhibit-video {
  width: 100%;
  height: 100%;
  /* 使用 object-fit 確保影片填滿容器且不變形 */
  object-fit: contain; 
}
/* 音波圖 */
.audio-visualizer-container { position: relative; width: 100%; height: 80px; background-color: #0b132b; border-radius: var(--border-radius); margin-bottom: 15px; overflow: hidden; border: 1px solid rgba(255,255,255,0.1); }
#waveform-canvas { width: 100%; height: 100%; display: block; }
.status-badge { position: absolute; top: 5px; right: 10px; background: rgba(244, 67, 54, 0.2); color: #f44336; padding: 3px 8px; border-radius: 12px; font-size: 0.8rem; font-weight: bold; border: 1px solid #f44336; animation: blink 1s infinite; }

.button-group { display: flex; flex-direction: column; gap: 10px; margin-top: 15px; }
.button-group button { margin-top: 0; }

/* ==== 投票區塊 ==== */
#exhibit-overlay { position: absolute; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0, 0, 0, 0.8); display: flex; justify-content: center; align-items: center; font-size: 2rem; color: #fff; z-index: 10; }
.vote-group { display: flex; flex-direction: column; align-items: center; margin-bottom: 20px; }
.vote-group label { font-size: 1.2rem; font-weight: bold; margin-bottom: 10px; color: var(--highlight); }
.star-rating { display: flex; gap: 10px; }
.star-btn { width: 45px; height: 45px; border-radius: 50%; background-color: rgba(255,255,255,0.1); border: 2px solid #555; color: white; font-size: 1.2rem; cursor: pointer; transition: all 0.2s ease; margin-top: 0; padding: 0; }
.star-btn:hover { background-color: rgba(255,255,255,0.2); transform: scale(1.1); }
.star-btn.selected { background-color: var(--highlight); border-color: var(--highlight); color: #000; transform: scale(1.1); box-shadow: 0 0 10px var(--highlight); }

/* ==== 結算排行榜與下載區 ==== */
.hall-of-fame .card { padding: 20px; transition: transform 0.3s; }
.hall-of-fame .card:hover { transform: scale(1.05); }

.download-list { list-style: none; padding: 0; margin-top: 10px; }
.download-list li { display: flex; justify-content: space-between; align-items: center; padding: 15px; border-bottom: 1px solid rgba(255,255,255,0.1); background: rgba(0,0,0,0.2); border-radius: 8px; margin-bottom: 10px; }
.download-list li:last-child { border-bottom: none; }
.download-score { font-size: 0.85em; color: #aaa; margin-top: 5px; }
.download-btn { width: auto !important; padding: 8px 15px !important; text-decoration: none; margin: 0 !important; }

/* ==== 動畫 ==== */
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes popIn { 0% { transform: scale(0.5); opacity: 0; } 50% { transform: scale(1.2); opacity: 1; } 100% { transform: scale(1); opacity: 0; } }
@keyframes blink { 0% { opacity: 1; } 50% { opacity: 0.4; } 100% { opacity: 1; } }