* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f172a 100%);
    color: white;
    overflow: hidden;
    height: 100vh;
    overscroll-behavior: none;
}

.container {
    position: relative;
    width: 100vw;
    height: 100vh;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f172a 100%);
    overflow: hidden;
}

.hidden {
    display: none !important;
}

/* 🔐 密碼輸入面板 - 必要元件 */
.password-modal {
    position: fixed;
    inset: 0;
    background: linear-gradient(135deg, #1a1a2e, #16213e, #0f172a);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    transition: opacity 0.5s ease-out;
    backdrop-filter: blur(10px);
}

.password-container {
    background: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(16px);
    border-radius: 20px;
    padding: 40px;
    max-width: 400px;
    width: 90%;
    text-align: center;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
}

.password-icon {
    font-size: 80px;
    margin-bottom: 20px;
    color: #3b82f6;
    text-shadow: 0 0 20px rgba(59, 130, 246, 0.5);
}

.password-title {
    color: white;
    font-size: 24px;
    font-weight: bold;
    margin-bottom: 15px;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
}

.password-subtitle {
    color: #60a5fa;
    font-size: 16px;
    margin-bottom: 30px;
    line-height: 1.5;
}

.password-input-group {
    margin-bottom: 25px;
}

.password-input {
    width: 100%;
    padding: 15px 20px;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    color: white;
    font-size: 16px;
    text-align: center;
    transition: all 0.3s ease;
    outline: none;
}

.password-input:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
    background: rgba(255, 255, 255, 0.15);
}

.password-input::placeholder {
    color: rgba(255, 255, 255, 0.5);
}

.password-actions {
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
}

.password-btn {
    padding: 12px 25px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.unlock-btn {
    background: linear-gradient(135deg, #3b82f6, #1d4ed8);
    color: white;
    min-width: 120px;
}

.unlock-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(59, 130, 246, 0.4);
}

.unlock-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.cancel-btn {
    background: linear-gradient(135deg, #6b7280, #4b5563);
    color: white;
}

.cancel-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(107, 114, 128, 0.4);
}

.password-error {
    color: #ef4444;
    font-size: 14px;
    margin-top: 15px;
    padding: 10px;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: 8px;
    animation: shake 0.5s ease-in-out;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

.password-help {
    margin-top: 20px;
    padding: 15px;
    background: rgba(59, 130, 246, 0.1);
    border: 1px solid rgba(59, 130, 246, 0.2);
    border-radius: 12px;
    font-size: 12px;
    color: #60a5fa;
    line-height: 1.4;
}

/* 載入畫面 */
.loading-screen {
    position: fixed;
    inset: 0;
    background: linear-gradient(135deg, #1a1a2e, #16213e, #0f172a);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    transition: opacity 0.5s ease-out;
    backdrop-filter: blur(10px);
}

.loading-animation {
    width: 80px;
    height: 80px;
    border: 4px solid rgba(59, 130, 246, 0.2);
    border-top: 4px solid #3b82f6;
    border-radius: 50%;
    animation: spin 1.5s linear infinite;
    margin-bottom: 30px;
    box-shadow: 0 0 20px rgba(59, 130, 246, 0.3);
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading-title {
    color: white;
    font-size: 24px;
    font-weight: bold;
    margin-bottom: 15px;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
}

.loading-subtitle {
    color: #60a5fa;
    font-size: 16px;
    margin-bottom: 10px;
    text-align: center;
}

.loading-status {
    color: #9ca3af;
    font-size: 14px;
    text-align: center;
    font-style: italic;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 0.7; }
    50% { opacity: 1; }
}

/* 標題列 */
.header {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 50; /* 提高 header 的 z-index */
    background: linear-gradient(to bottom, rgba(0,0,0,0.95) 0%, rgba(0,0,0,0.9) 70%, transparent 100%);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(107, 114, 128, 0.3);
    transition: all 0.3s ease;
}

.header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    gap: 8px;
    min-height: 60px;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.control-btn {
    width: 32px;
    height: 32px;
    background: rgba(31, 41, 55, 0.8);
    border: 1px solid rgba(107, 114, 128, 0.5);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    cursor: pointer;
    transition: all 0.3s;
    backdrop-filter: blur(4px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.3);
    position: relative;
}

.control-btn:hover {
    background: rgba(55, 65, 81, 0.8);
    transform: scale(1.05);
}

/* 🔐 加密狀態指示器 - 可選移除 */
.encryption-indicator {
    position: absolute;
    top: -2px;
    right: -2px;
    width: 8px;
    height: 8px;
    background: #10b981;
    border: 1px solid rgba(0, 0, 0, 0.8);
    border-radius: 50%;
    animation: pulse-green 2s infinite;
}

@keyframes pulse-green {
    0%, 100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
    50% { box-shadow: 0 0 0 4px rgba(16, 185, 129, 0); }
}

.title-area {
    flex: 1;
    display: flex;
    justify-content: center;
    min-width: 0;
    max-width: 300px;
}

.mobile-title {
    display: none;
    color: white;
    font-size: 14px;
    font-weight: bold;
    text-align: center;
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.title-box {
    background: linear-gradient(to right, rgba(31, 41, 55, 0.8), rgba(55, 65, 81, 0.8));
    backdrop-filter: blur(4px);
    border-radius: 20px;
    padding: 8px 16px;
    border: 1px solid rgba(107, 114, 128, 0.3);
    box-shadow: 0 4px 8px rgba(0,0,0,0.3);
    text-align: center;
    position: relative;
}

/* 移除標題前的鎖頭圖示 */
.title-text {
    color: white;
    font-size: 14px;
    font-weight: bold;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.nav-btn {
    width: 28px;
    height: 28px;
    background: rgba(55, 65, 81, 0.8);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    cursor: pointer;
    transition: all 0.3s;
    border: 1px solid rgba(107, 114, 128, 0.3);
}

.nav-btn:hover:not(.disabled) {
    background: rgba(75, 85, 99, 0.8);
}

.nav-btn.disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.event-counter {
    color: white;
    font-size: 12px;
    white-space: nowrap;
    padding: 4px 12px;
    text-align: center;
    min-width: 50px;
}

.media-counter {
    color: rgb(156, 163, 175);
    font-size: 12px;
    white-space: nowrap;
    background: rgba(31, 41, 55, 0.6);
    padding: 4px 12px;
    border-radius: 20px;
    border: 1px solid rgba(107, 114, 128, 0.3);
}

/* 設定選單 - 修正 z-index 問題 */
.settings-menu {
    position: absolute;
    top: 48px;
    left: 0;
    background: rgba(17, 24, 39, 0.95);
    border: 1px solid rgba(107, 114, 128, 0.3);
    border-radius: 12px;
    padding: 12px 16px;
    backdrop-filter: blur(16px);
    min-width: 160px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.5);
    z-index: 1000;
    opacity: 0;
    transform: translateY(-10px);
    transition: all 0.3s ease;
    pointer-events: none;
}

.settings-menu.visible {
    opacity: 1;
    transform: translateY(0);
    pointer-events: all;
}

.settings-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid rgba(107, 114, 128, 0.2);
}

.settings-item:last-child {
    border-bottom: none;
}

.settings-item span {
    color: white;
    font-size: 12px;
}

.toggle-switch {
    width: 40px;
    height: 20px;
    background: #6b7280;
    border-radius: 10px;
    position: relative;
    cursor: pointer;
    transition: background-color 0.3s;
}

.toggle-switch.active {
    background: #3b82f6;
}

.toggle-knob {
    width: 16px;
    height: 16px;
    background: white;
    border-radius: 50%;
    position: absolute;
    top: 2px;
    left: 2px;
    transition: transform 0.3s;
}

.toggle-switch.active .toggle-knob {
    transform: translateX(20px);
}

.settings-btn {
    width: 100%;
    background: #10b981;
    color: white;
    border: none;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.3s;
    margin-top: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.settings-btn:hover {
    background: #059669;
}

.skip-btn {
    background: #f59e0b !important;
}

.skip-btn:hover {
    background: #d97706 !important;
}

/* 🔐 加密狀態提示 */
.encryption-status {
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.3);
    border-radius: 8px;
    padding: 8px 12px;
    margin-top: 8px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.encryption-status-text {
    color: #10b981;
    font-size: 11px;
    font-weight: 600;
}

/* 移除字幕區域的加密保護水印 */
.subtitle-area {
    padding: 12px 16px;
    /* background: linear-gradient(to right, rgba(31, 41, 55, 0.6), rgba(55, 65, 81, 0.6)); */
    backdrop-filter: blur(4px);
    border-radius: 12px;
    margin: 0 16px 12px 16px;
    border: 1px solid rgba(107, 114, 128, 0.2);
    box-shadow: 0 4px 8px rgba(0,0,0,0.3);
    transition: all 0.3s ease;
    opacity: 1;
    position: relative;
    z-index: 10;
}

.subtitle-area.transitioning {
    opacity: 0.5;
    transform: scale(0.98);
}

.subtitle-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 8px;
}

.event-date {
    color: rgb(209, 213, 219);
    font-size: 12px;
    flex-shrink: 0;
}

.event-title {
    color: white;
    font-size: 14px;
    font-weight: bold;
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.subtitle-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.event-description {
    color: rgb(229, 231, 235);
    font-size: 12px;
    line-height: 1.5;
    transition: opacity 0.3s ease;
}

.typewriter-cursor {
    animation: blink 1s infinite;
}

@keyframes blink {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0; }
}

/* 主要內容區域 */
.main-content {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    padding-top: 140px;
    transition: all 0.5s ease;
}

.main-content.transitioning {
    opacity: 0.7;
    transform: scale(0.98);
}

.main-content.grid-mode {
    padding-top: 80px;
}

.media-area {
    flex: 1;
    position: relative;
    padding: 8px 12px;
    min-height: 0;
}

/* 媒體輪播模式 */
.media-carousel {
    width: 100%;
    height: 100%;
    display: flex;
    gap: 16px;
}

.main-media {
    flex: 1;
    position: relative;
    background: linear-gradient(135deg, #1f2937, #000000);
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid rgba(107, 114, 128, 0.3);
    box-shadow: 0 8px 16px rgba(0,0,0,0.5);
    transition: all 0.5s ease;
}

.main-media.transitioning {
    opacity: 0.5;
    transform: scale(0.95);
}

.media-display {
    position: absolute;
    inset: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.3s ease;
}

.youtube-container {
    position: relative;
    width: 100%;
    height: 0;
    padding-bottom: 56.25%; /* 16:9 比例 */
    overflow: hidden;
    border-radius: 8px;
}

.youtube-container iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: none;
}

@media (max-width: 768px) {
    .media-display {
        inset: 8px; /* 減少邊距 */
    }
    
    .youtube-container {
        padding-bottom: 56.25%; /* 保持 16:9 比例 */
        border-radius: 6px;
    }
    
    /* 確保 YouTube 縮圖在手機版正確顯示 */
    .thumbnail-item {
        width: 48px;
        height: 48px;
        flex-shrink: 0;
    }
    
    .thumbnail-image {
        width: 100%;
        height: 100%;
        object-fit: cover; /* 確保圖片填滿容器且不變形 */
        object-position: center; /* 居中顯示 */
    }
    
    /* 網格模式下的 YouTube 調整 */
    .grid-item-content {
        width: 100%;
        height: 100%;
        display: flex;
        align-items: center;
        justify-content: center;
        overflow: hidden; /* 防止內容溢出 */
    }
    
    .grid-item-content .youtube-container {
        padding-bottom: 100%; /* 網格中使用正方形比例 */
    }
}

@media (max-width: 480px) {
    .youtube-container {
        padding-bottom: 75%; /* 調整為 4:3 比例，更適合小螢幕 */
    }
    
    .media-display {
        inset: 4px;
    }
}

.media-display img,
.media-display video {
    max-width: 100%;
    max-height: 100%;
    width: 100%;
    object-fit: contain;
    cursor: pointer;
    transition: opacity 0.3s;
}

.media-nav-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 48px;
    height: 48px;
    background: rgba(31, 41, 55, 0.9);
    border: 1px solid rgba(107, 114, 128, 0.5);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    cursor: pointer;
    transition: all 0.3s;
    backdrop-filter: blur(4px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.3);
    z-index: 20;
}

.media-nav-btn:hover:not(.disabled) {
    background: rgba(55, 65, 81, 0.9);
    transform: translateY(-50%) scale(1.05);
}

.media-nav-btn.disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.media-nav-btn.prev {
    left: 16px;
}

.media-nav-btn.next {
    right: 16px;
}

.media-counter-overlay {
    position: absolute;
    top: 16px;
    right: 16px;
    background: rgba(17, 24, 39, 0.9);
    border: 1px solid rgba(107, 114, 128, 0.5);
    color: white;
    font-size: 12px;
    padding: 6px 12px;
    border-radius: 20px;
    backdrop-filter: blur(4px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.3);
    z-index: 20;
}

/* 媒體縮圖導航 - 改進顯示邏輯和排列 */
.media-thumbnails {
    width: 80px;
    position: relative;
    display: flex;
    align-items: center;
}

.thumbnails-container {
    width: 100%;
    height: 100%;
    background: linear-gradient(to bottom, rgba(31, 41, 55, 0.8), rgba(17, 24, 39, 0.6));
    border-radius: 12px;
    border: 1px solid rgba(107, 114, 128, 0.2);
    padding: 12px 8px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.thumbnails-scroll {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    height: 100%;
    overflow-y: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
    min-height: 100%;
}

.thumbnails-scroll::-webkit-scrollbar {
    display: none;
}

.thumbnail-item {
    position: relative;
    flex-shrink: 0;
    width: 56px;
    height: 56px;
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    border: 2px solid transparent;
    transition: all 0.3s;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

.thumbnail-item.active {
    border-color: #3b82f6;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.3);
    transform: scale(1.05);
}

.thumbnail-item:hover:not(.active) {
    border-color: rgba(107, 114, 128, 0.7);
    transform: scale(1.02);
}

.thumbnail-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.thumbnail-video-icon {
    position: absolute;
    top: 4px;
    right: 4px;
    background: rgba(17, 24, 39, 0.8);
    border: 1px solid rgba(107, 114, 128, 0.5);
    border-radius: 50%;
    padding: 2px;
    color: white;
}

.thumbnail-index {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(to top, rgba(0,0,0,0.8), transparent);
    color: white;
    font-size: 10px;
    text-align: center;
    padding: 2px;
}

/* 媒體網格模式 */
.media-grid {
    width: 100%;
    height: 100%;
    padding: 16px;
    background: linear-gradient(135deg, #1f2937, #000000, #1f2937);
    transition: all 0.3s ease;
}

.grid-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
    height: 100%;
    overflow-y: auto;
}

.grid-item {
    position: relative;
    aspect-ratio: 1;
    border-radius: 12px;
    overflow: hidden;
    cursor: pointer;
    border: 2px solid transparent;
    transition: all 0.3s;
    box-shadow: 0 4px 12px rgba(0,0,0,0.5);
}

.grid-item.active {
    border-color: #3b82f6;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.3);
    transform: scale(1.05);
}

.grid-item:hover:not(.active) {
    border-color: rgba(107, 114, 128, 0.7);
    transform: scale(1.02);
}

.grid-item-content {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.grid-item-content img,
.grid-item-content video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.grid-item-info {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(to top, rgba(0,0,0,0.9), transparent);
    color: white;
    padding: 8px;
    border-top: 1px solid rgba(107, 114, 128, 0.3);
}

.grid-item-name {
    font-size: 10px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* 時間軸面板 */
.timeline-panel {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 101;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.timeline-panel.visible {
    opacity: 1;
    pointer-events: all;
}

.timeline-content {
    background: rgba(17, 24, 39, 0.9);
    backdrop-filter: blur(16px);
    border-radius: 16px;
    padding: 24px;
    max-width: 800px;
    width: 100%;
    max-height: 80vh;
    overflow: hidden;
}

.timeline-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
}

.timeline-title {
    color: white;
    font-size: 18px;
    font-weight: bold;
    display: flex;
    align-items: center;
    gap: 8px;
}

.timeline-close {
    width: 32px;
    height: 32px;
    background: rgba(107, 114, 128, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    cursor: pointer;
    transition: all 0.3s;
    border: 1px solid rgba(107, 114, 128, 0.3);
}

.timeline-close:hover {
    background: rgba(107, 114, 128, 0.4);
}

.timeline-scroll {
    overflow-y: auto;
    max-height: 60vh;
    position: relative;
    padding-left: 8px;
}

.timeline-line {
    position: absolute;
    left: 32px;
    top: 0;
    bottom: 0;
    width: 2px;
    background: rgba(107, 114, 128, 0.3);
}

.timeline-item {
    position: relative;
    display: flex;
    align-items: start;
    gap: 16px;
    padding-bottom: 32px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.timeline-item:hover {
    opacity: 0.9;
}

.timeline-item.active {
    opacity: 1;
}

.timeline-node {
    position: relative;
    z-index: 10;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 2px solid white;
    background: #6b7280;
    transition: all 0.3s;
    margin-left: 8px;
}

.timeline-item.active .timeline-node {
    background: #3b82f6;
    border-color: #60a5fa;
    transform: scale(1.25);
}

.timeline-item:hover .timeline-node {
    background: #60a5fa;
}

.timeline-event {
    flex: 1;
    min-width: 0;
}

.timeline-event-content {
    background: rgba(31, 41, 55, 0.5);
    border-radius: 12px;
    padding: 16px;
    transition: all 0.3s;
    border: 1px solid rgba(107, 114, 128, 0.2);
}

.timeline-item:hover .timeline-event-content {
    background: rgba(31, 41, 55, 0.8);
}

.timeline-event-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
}

.timeline-event-date {
    font-size: 10px;
    color: #9ca3af;
    background: rgba(107, 114, 128, 0.2);
    border-radius: 20px;
    padding: 4px 8px;
}

.timeline-event-title {
    font-weight: 600;
    color: white;
    font-size: 14px;
}

.timeline-item.active .timeline-event-title {
    color: #60a5fa;
}

.timeline-event-description {
    color: #d1d5db;
    font-size: 12px;
    line-height: 1.5;
    margin-bottom: 12px;
}

.timeline-event-media {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 10px;
    color: #9ca3af;
}

/* 說明面板 */
.help-panel {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    backdrop-filter: blur(4px);
}

.help-panel.visible {
    opacity: 1;
    pointer-events: all;
}

.help-content {
    background: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(16px);
    border-radius: 16px;
    padding: 24px;
    max-width: 600px;
    width: 100%;
    max-height: 80vh;
    overflow-y: auto;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.help-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
}

.help-title {
    color: white;
    font-size: 18px;
    font-weight: bold;
    display: flex;
    align-items: center;
    gap: 8px;
}

.help-section {
    margin-bottom: 24px;
}

.help-section h3 {
    color: #60a5fa;
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 12px;
}

.help-item {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
    font-size: 14px;
    color: #d1d5db;
}

.help-key {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    padding: 4px 8px;
    font-size: 12px;
    color: white;
    min-width: 40px;
    text-align: center;
}

.help-tip {
    background: rgba(59, 130, 246, 0.1);
    border: 1px solid rgba(59, 130, 246, 0.2);
    border-radius: 12px;
    padding: 16px;
    color: #d1d5db;
    font-size: 12px;
    line-height: 1.5;
}

.help-tip h4 {
    color: #60a5fa;
    font-weight: 600;
    margin-bottom: 8px;
}

/* 全螢幕媒體檢視器 */
.media-viewer {
    position: fixed;
    inset: 0;
    background: black;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.media-viewer.visible {
    opacity: 1;
    pointer-events: all;
}

.media-viewer-close {
    position: absolute;
    top: 16px;
    right: 16px;
    z-index: 60;
    width: 48px;
    height: 48px;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    cursor: pointer;
    transition: all 0.3s;
    backdrop-filter: blur(8px);
}

.media-viewer-close:hover {
    background: rgba(0, 0, 0, 0.7);
}

.media-viewer-content {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 32px;
}

.media-viewer-content img,
.media-viewer-content video {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

/* 響應式設計 */
@media (max-width: 768px) {
    .title-area {
        display: none;
    }

    .mobile-title {
        display: block;
    }

    .header-content {
        padding: 8px 12px;
        min-height: 56px;
    }
    
    .control-btn {
        width: 28px;
        height: 28px;
    }

    .subtitle-area {
        margin: 0 8px 8px 8px;
        padding: 10px 12px;
    }

    .event-title {
        font-size: 13px;
    }

    .event-date {
        font-size: 11px;
    }

    .event-description {
        font-size: 11px;
    }

    .main-content {
        padding-top: 120px;
    }

    /* 手機版：縮圖移到底部 */
    .media-carousel {
        flex-direction: column;
        gap: 12px;
    }

    .main-media {
        flex: 1;
    }

    .media-thumbnails {
        width: 100%;
        height: 80px;
        order: 2;
    }

    .thumbnails-container {
        padding: 8px 12px;
    }

    .thumbnails-scroll {
        flex-direction: row;
        justify-content: center;
        align-items: center;
        overflow-x: auto;
        overflow-y: hidden;
        height: 100%;
        gap: 8px;
    }

    .thumbnail-item {
        width: 48px;
        height: 48px;
        flex-shrink: 0;
    }

    .media-nav-btn {
        width: 40px;
        height: 40px;
    }

    .media-nav-btn.prev {
        left: 8px;
    }

    .media-nav-btn.next {
        right: 8px;
    }

    .grid-container {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 12px;
    }

    .timeline-content {
        padding: 16px;
        margin: 8px;
    }

    .help-content {
        padding: 16px;
        margin: 8px;
    }

    .password-container {
        padding: 30px 20px;
    }

    .password-title {
        font-size: 20px;
    }

    .password-subtitle {
        font-size: 14px;
    }
}

/* 動畫效果 */
.fade-in {
    animation: fadeIn 0.3s ease;
}

.fade-out {
    animation: fadeOut 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

@keyframes fadeOut {
    from { opacity: 1; transform: scale(1); }
    to { opacity: 0; transform: scale(0.95); }
}

.slide-in-right {
    animation: slideInRight 0.3s ease;
}

@keyframes slideInRight {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

.slide-out-left {
    animation: slideOutLeft 0.3s ease;
}

@keyframes slideOutLeft {
    from { transform: translateX(0); opacity: 1; }
    to { transform: translateX(-100%); opacity: 0; }
}

/* 🔐 防止內容選取和右鍵功能 */
* {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
}

/* 🔐 隱藏滾動條但保持功能 */
*::-webkit-scrollbar {
    width: 4px;
}

*::-webkit-scrollbar-track {
    background: transparent;
}

*::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
}

*::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* 動態調整內容高度 */
.main-content { padding-top: 0; }            /* 交給 JS 設定 */
.main-content.grid-mode { padding-top: 0; }  /* 交給 JS 設定 */

/* ========== 字體大小控制（全站） ========== */

/* 預設字級變數（會被 data-font 覆蓋） */
:root {
    --mf-title-size: 28px;          /* 桌面標題（.title-text / .mobile-title） */
    --mf-subtitle-title-size: 18px; /* 字幕區的小標題（.event-title） */
    --mf-subtitle-text-size: 16px;  /* 字幕段落（.event-description） */
    --mf-date-size: 12px;           /* 日期（.event-date） */
}

/* 3 檔字級：將屬性掛在 <html data-font="..."> 上 */
html[data-font="small"] {
    --mf-title-size: 20px;
    --mf-subtitle-title-size: 12px;
    --mf-subtitle-text-size: 10px;
    --mf-date-size: 11px;
}
html[data-font="medium"] {
    --mf-title-size: 24px;
    --mf-subtitle-title-size: 14px;
    --mf-subtitle-text-size: 12px;
    --mf-date-size: 10px;
}
html[data-font="large"] {
    --mf-title-size: 30px;
    --mf-subtitle-title-size: 20px;
    --mf-subtitle-text-size: 18px;
    --mf-date-size: 14px;
}

/* 把變數套到實際元件上 */
.title-text,
.mobile-title {
    font-size: var(--mf-title-size);
    line-height: 1.15;
}
.subtitle-area .event-title {
    font-size: var(--mf-subtitle-title-size);
    line-height: 1.25;
}
.subtitle-area .event-description {
    font-size: var(--mf-subtitle-text-size);
    line-height: 1.7;
}
.subtitle-area .event-date {
    font-size: var(--mf-date-size);
}

/* 設定選單內按鈕樣式（可依你現有風格微調） */
.font-size-controls {
    display: inline-flex;
    gap: 6px;
    margin-left: 8px;
}
.font-btn {
    background: rgba(31, 41, 55, 0.7);
    color: #e5e7eb;
    border: 1px solid rgba(107, 114, 128, 0.5);
    border-radius: 8px;
    padding: 4px 10px;
    font-size: 12px;
    cursor: pointer;
    transition: transform .06s ease, background .2s ease, border-color .2s ease;
}
.font-btn:hover { transform: translateY(-1px); }
.font-btn.active {
    background: rgba(59, 130, 246, 0.85);
    border-color: rgba(147, 197, 253, 0.7);
    color: white;
}

/* 跑馬燈 */

/* 單行省略（預設狀態） */
.truncate-one-line{
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* 跑馬燈外層（會套在原文字元素上，或把原文字元素包起來） */
.marquee{
  position: relative;
  overflow: hidden;
  white-space: nowrap;
  /* 兩側做一點淡出，較不突兀（可調） */
  -webkit-mask-image: linear-gradient(to right, transparent 0, #000 24px, #000 calc(100% - 24px), transparent 100%);
          mask-image: linear-gradient(to right, transparent 0, #000 24px, #000 calc(100% - 24px), transparent 100%);
}

/* 內層軌道：真正移動的容器 */
.marquee__inner{
  display: inline-flex;
  gap: var(--gap, 48px);        /* 兩段文字間距 */
  will-change: transform;
  animation: marquee-scroll linear infinite;
  animation-duration: var(--duration, 12s);
}

/* 單段內容（會複製 2 份做無縫輪播） */
.marquee__content{
  display: inline-block;
}

/* 滾動動畫 */
@keyframes marquee-scroll{
  from{ transform: translateX(0); }
  to  { transform: translateX(calc(-50% - var(--gap, 48px)/2)); }
}

/* 滑鼠移入暫停（可選） */
.marquee:hover .marquee__inner{
  animation-play-state: paused;
}

/* 使用者偏好：減少動效時，直接顯示省略 */
@media (prefers-reduced-motion: reduce){
  .marquee .marquee__inner{ animation: none; }
}

/* 跑馬燈 */