#video-modal-overlay {
    display: none; /* これだけを残す */
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.9);
    justify-content: center; /* 中央寄せのルールは残す */
    align-items: center; /* 中央寄せのルールは残す */
    z-index: 9999;
}

#video-modal {
    position: relative; /* 子要素 (閉じるボタン) の基準 */
    width: 90%;
    max-width: 1280px;
    /* heightをautoにして、aspect-ratioで高さを制御 */
    height: auto;
    aspect-ratio: 16 / 9; /* 動画のアスペクト比 */
    background-color: #000;
    border-radius: 8px;
    overflow: hidden;
    /* モーダル自体の位置調整 */
    /* top: 50%; left: 50%; transform: translate(-50%, -50%); は overlay で中央寄せするので不要 */
    display: flex;
    flex-direction: column; /* 内部コンテンツを縦に並べる */
    justify-content: center; /* 垂直方向中央寄せ */
    align-items: center; /* 水平方向中央寄せ */
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.7); /* 影を追加して視認性向上 */
}

#close-modal-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    background: none;
    border: none;
    color: white;
    font-size: 2em;
    cursor: pointer;
    z-index: 10000; /* モーダル内の最前面 */
    padding: 5px 10px;
    border-radius: 5px;
    transition: background-color 0.2s ease;
}

#close-modal-btn:hover {
    background-color: rgba(255, 255, 255, 0.2);
}

#player-container {
    width: 100%;
    /* カスタムコントロールがある場合とない場合を考慮 */
    height: 100%; /* これを100%にして、動画が親にフィットするようにする */
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: #000;
}

#player-container video,
#player-container iframe {
    width: 100%; /* 親コンテナにフィット */
    height: 100%; /* 親コンテナにフィット */
    display: block; /* インライン要素のマージンなど問題回避 */
}

.video-controls {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 40px;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 10px;
    box-sizing: border-box;
    color: white;
    font-size: 0.9em;
    opacity: 0; /* 初期状態では非表示（透明）にする */
    transition: opacity 0.3s ease; /* スムーズなフェードイン/アウト */
    z-index: 10;
    pointer-events: none; /* 初期状態ではクリックイベントを透過させる */
}

/* コントロールが表示される状態 */
.video-controls.active {
    opacity: 1; /* 表示状態 */
    pointer-events: auto; /* クリックイベントを有効にする */
}


.video-controls button {
    background: none;
    border: none;
    color: white;
    font-size: 1.5em;
    cursor: pointer;
    padding: 5px;
    transition: color 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.video-controls button:hover {
    color: #007bff;
}

.video-controls input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    background: transparent;
    cursor: pointer;
    flex-grow: 1;
    height: 8px;
    margin: 0 10px;
}

.video-controls input[type="range"]::-webkit-slider-runnable-track {
    background: #555;
    border-radius: 4px;
    height: 4px;
}

.video-controls input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    background-color: #007bff;
    height: 12px;
    width: 12px;
    border-radius: 50%;
    margin-top: -4px;
    border: none;
}

.video-controls input[type="range"]::-moz-range-track {
    background: #555;
    border-radius: 4px;
    height: 4px;
}

.video-controls input[type="range"]::-moz-range-thumb {
    background-color: #007bff;
    height: 12px;
    width: 12px;
    border-radius: 50%;
    border: none;
}

.time-display {
    min-width: 40px;
    text-align: center;
}

.volume-container {
    display: flex;
    align-items: center;
}

#volume-bar {
    width: 80px;
    margin-right: 5px;
}

.video-settings-menu {
    position: absolute;
    bottom: 50px;
    right: 10px;
    background-color: rgba(0, 0, 0, 0.85);
    border-radius: 5px;
    padding: 10px 0;
    min-width: 150px;
    color: white;
    z-index: 1020;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
}

.video-settings-menu ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.video-settings-menu li {
    padding: 8px 15px;
    cursor: pointer;
    transition: background-color 0.2s ease;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.video-settings-menu li:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.video-settings-menu li.checked::after {
    content: '✓';
    margin-left: 10px;
    color: #007bff;
}

.video-settings-menu .back-button {
    font-weight: bold;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
    padding-bottom: 5px;
    margin-bottom: 5px;
}

.video-settings-submenu {
    bottom: 50px;
    right: 10px;
}

#video-modal:hover .video-controls {
    opacity: 1;
    pointer-events: auto;
}

@media (max-width: 768px) {
    #video-modal {
        width: 95%;
    }
    .video-controls {
        height: 35px;
        padding: 0 5px;
    }
    .video-controls button {
        font-size: 1.3em;
        padding: 3px;
    }
    .video-controls input[type="range"] {
        margin: 0 5px;
    }
    .time-display {
        font-size: 0.8em;
        min-width: 35px;
    }
    #volume-bar {
        width: 60px;
    }
    .video-settings-menu {
        min-width: 120px;
        bottom: 45px;
    }
    .video-settings-menu li {
        padding: 6px 10px;
        font-size: 0.9em;
    }
}