:root {
    --bg-color: #050505;
    --card-bg: rgba(15, 15, 15, 0.7);
    --primary: #a855f7;
    --primary-hover: #9333ea;
    --text-main: #e2e8f0;
    --text-muted: #64748b;
    --glass-border: rgba(255, 255, 255, 0.05);
    --glass-shadow: 0 10px 40px 0 rgba(0, 0, 0, 0.6);
}

body {
    margin: 0;
    font-family: 'Inter', sans-serif;
    background: linear-gradient(135deg, #020617 0%, #09090b 50%, #171717 100%);
    background-attachment: fixed;
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
}

.container {
    width: 95%;
    max-width: 1100px;
    background: var(--card-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    padding: 2.5rem;
    box-shadow: var(--glass-shadow);
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

header {
    text-align: center;
}

header h1 {
    font-size: 3rem;
    margin: 0 0 0.5rem 0;
    background: linear-gradient(to right, #a78bfa, #f472b6);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    letter-spacing: -0.05em;
}

header p {
    color: var(--text-muted);
    margin: 0;
    font-size: 1.1rem;
}

.upload-section {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
    justify-content: center;
    background: rgba(0, 0, 0, 0.4);
    padding: 1.5rem;
    border-radius: 16px;
    border: 1px solid var(--glass-border);
    position: relative;
    overflow: hidden;
    box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.5);
    transition: all 0.3s ease;
}

.upload-section.dragover {
    border-color: var(--primary);
    background: rgba(139, 92, 246, 0.1);
    box-shadow: 0 0 20px rgba(139, 92, 246, 0.3);
}

/* 飾り */
.upload-section::before {
    content: '';
    position: absolute;
    top: -50px;
    left: -50px;
    width: 100px;
    height: 100px;
    background: var(--primary);
    filter: blur(50px);
    opacity: 0.3;
    border-radius: 50%;
}

.file-input-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    flex: 1;
    min-width: 200px;
}

.file-label {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    padding: 0.6rem 1.2rem;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
    width: 100%;
    justify-content: center;
    box-sizing: border-box;
    font-size: 0.95rem;
}

.file-label:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: translateY(-3px);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.2);
    border-color: rgba(255, 255, 255, 0.2);
}

.file-label input[type="file"] {
    display: none;
}

.icon {
    font-size: 1.2rem;
}

.file-name {
    font-size: 0.9rem;
    color: var(--text-muted);
    max-width: 200px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-align: center;
}

/* 複数音声選択プルダウン */
.audio-select {
    background: rgba(0, 0, 0, 0.4);
    color: var(--text-main);
    border: 1px solid var(--glass-border);
    padding: 0.5rem;
    border-radius: 8px;
    width: 100%;
    max-width: 300px;
    /* プルダウンの幅を拡大 (200px -> 300px) */
    font-family: inherit;
    font-size: 0.9rem;
    outline: none;
    cursor: pointer;
}

.audio-select option {
    background: var(--bg-color);
}

/* トグルスイッチ */
.option-group {
    width: 100%;
    margin-top: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
}

.toggle-switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 26px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(255, 255, 255, 0.1);
    transition: .4s;
    border-radius: 34px;
    border: 1px solid var(--glass-border);
}

.slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 4px;
    bottom: 3px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

input:checked+.slider {
    background-color: var(--primary);
    border-color: var(--primary);
}

input:focus+.slider {
    box-shadow: 0 0 0 2px rgba(139, 92, 246, 0.5);
}

input:checked+.slider:before {
    transform: translateX(22px);
}

.option-text {
    font-size: 0.95rem;
    color: var(--text-main);
    font-weight: 500;
}

/* メディアコントロール */
.media-controls {
    width: 100%;
    background: rgba(0, 0, 0, 0.4);
    padding: 1rem;
    border-radius: 12px;
    border: 1px solid var(--glass-border);
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-top: 0.5rem;
    box-sizing: border-box;
    animation: fadeIn 0.3s ease-out;
    box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.5);
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.control-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.ctrl-btn {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-main);
    border: 1px solid var(--glass-border);
    padding: 0.6rem 1rem;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    font-weight: 600;
}

.ctrl-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.ctrl-btn.danger:hover {
    background: rgba(239, 68, 68, 0.3);
    border-color: rgba(239, 68, 68, 0.5);
}

.play-icon {
    color: var(--primary);
}

.volume-row {
    background: rgba(255, 255, 255, 0.05);
    padding: 0.5rem 1rem;
    border-radius: 8px;
    border: 1px solid var(--glass-border);
}

.volume-row input[type="range"] {
    width: 250px;
    accent-color: var(--primary);
    cursor: pointer;
}

.vol-text {
    font-size: 0.8rem;
    color: var(--text-muted);
    min-width: 40px;
    text-align: right;
}

/* 小さめの音声シークバー */
.audio-seek-row {
    background: rgba(255, 255, 255, 0.05);
    padding: 0.4rem 1rem;
    border-radius: 8px;
    border: 1px solid var(--glass-border);
    margin-top: 0.5rem;
    width: 100%;
    box-sizing: border-box;
    /* はみ出し防止 */
}

.audio-seek-row input[type="range"] {
    flex: 1;
    height: 4px;
    accent-color: var(--primary);
    margin: 0 10px;
    cursor: pointer;
}

.seek-label {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.seek-time {
    font-size: 0.75rem;
    color: var(--text-main);
    min-width: 35px;
    font-variant-numeric: tabular-nums;
}

/* プレイヤーラッパー */
.player-wrapper {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* プレイヤー領域 */
.player-section {
    width: 100%;
    border-radius: 16px;
    overflow: hidden;
    background: #000;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.5), 0 10px 10px -5px rgba(0, 0, 0, 0.3);
    aspect-ratio: 16 / 9;
    position: relative;
    background: #000;
}

.player-section video {
    width: 100%;
    height: 100%;
    object-fit: contain;
    outline: none;
    background: transparent;
    display: block;
}

/* カスタムコントロール */
.custom-controls {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 2rem 1rem 0.5rem;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.9) 0%, rgba(0, 0, 0, 0) 100%);
    opacity: 0;
    transition: opacity 0.3s ease;
    display: flex;
    flex-direction: column;
    pointer-events: none;
}

.player-section:hover .custom-controls,
.custom-controls:hover {
    opacity: 1;
    pointer-events: auto;
}

.progress-container {
    width: 100%;
    height: 20px;
    /* クリック判定を拡大 */
    cursor: pointer;
    margin-bottom: 5px;
    position: relative;
    display: flex;
    align-items: center;
}

.progress-container::before {
    content: '';
    position: absolute;
    width: 100%;
    height: 5px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
    transition: height 0.1s ease;
}

.progress-container:hover::before,
.progress-container:hover .progress-bar {
    height: 8px;
}

.progress-bar {
    height: 5px;
    background: var(--primary);
    border-radius: 3px;
    width: 0%;
    position: relative;
    z-index: 1;
    transition: height 0.1s ease;
}

.progress-bar::after {
    content: '';
    position: absolute;
    right: -6px;
    top: 50%;
    transform: translateY(-50%);
    width: 12px;
    height: 12px;
    background: white;
    border-radius: 50%;
    opacity: 0;
    transition: opacity 0.2s;
}

.progress-container:hover .progress-bar::after {
    opacity: 1;
}

.controls-bottom {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.controls-left,
.controls-right {
    display: flex;
    align-items: center;
    gap: 15px;
}

.player-btn {
    background: none;
    border: none;
    color: white;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0;
    transition: color 0.2s, transform 0.1s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.player-btn:hover {
    color: var(--primary-hover);
    transform: scale(1.1);
}

.time-display {
    color: white;
    font-size: 0.85rem;
    font-variant-numeric: tabular-nums;
    user-select: none;
}

/* カスタムプレイヤー内ボリューム */
.player-volume-container {
    display: flex;
    align-items: center;
    gap: 5px;
    margin-left: 10px;
}

.player-volume-container .icon {
    font-size: 0.85rem;
    /* 音量アイコンを小さく */
}

.player-volume-slider {
    width: 80px;
    height: 4px;
    cursor: pointer;
    accent-color: var(--primary);
}

/* フルスクリーン時の対応 */
.player-section:-webkit-full-screen {
    width: 100vw;
    height: 100vh;
}

.player-section:fullscreen {
    width: 100vw;
    height: 100vh;
}

/* iOSライクな再生中ステータスバー */
.now-playing {
    display: flex;
    align-items: center;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    padding: 0.5rem 1rem;
    margin: 0 auto;
    width: fit-content;
    max-width: 90%;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
    opacity: 0;
    transform: translateY(-10px);
    transition: opacity 0.4s ease, transform 0.4s ease;
}

.now-playing.visible {
    opacity: 1;
    transform: translateY(0);
}

.now-playing-icon {
    margin-right: 12px;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    gap: 3px;
}

/* iOSのアクティビティインジケータ（波形）風のアニメーション */
.audio-bar {
    width: 3px;
    height: 12px;
    background-color: var(--primary);
    border-radius: 3px;
    animation: eq 1s ease-in-out infinite;
}

.audio-bar:nth-child(2) {
    animation-delay: 0.2s;
    height: 16px;
}

.audio-bar:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes eq {

    0%,
    100% {
        transform: scaleY(0.5);
    }

    50% {
        transform: scaleY(1);
    }
}

.now-playing-text-container {
    overflow: hidden;
    white-space: nowrap;
    position: relative;
    width: 300px;
    /* 固定幅にすることでスクロールの空白を制御 */
}

.now-playing-text {
    font-size: 0.95rem;
    color: var(--text-main);
    display: inline-block;
}

.now-playing-text.marquee {
    animation: marquee 10s linear infinite;
    padding-left: 300px;
    /* 親の幅と同じだけ余白を空ける */
}

@keyframes marquee {
    0% {
        transform: translate(0, 0);
    }

    100% {
        transform: translate(-100%, 0);
    }
}

/* ツールチップ (簡単な実装) */
.tooltip {
    position: relative;
}

.tooltip::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 120%;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 0.6rem 0.8rem;
    border-radius: 6px;
    font-size: 0.8rem;
    white-space: normal;
    /* 折り返しを許可 */
    width: max-content;
    max-width: 200px;
    /* 超えたら折り返す境界幅 */
    text-align: center;
    line-height: 1.3;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s, transform 0.2s;
    z-index: 10;
}

.tooltip:hover::after {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* レスポンシブ */
@media (max-width: 600px) {
    .container {
        width: 95%;
        padding: 1.5rem;
    }

    header h1 {
        font-size: 2rem;
    }
}