/* 统一字体为思源黑体 Normal */
@font-face {
    font-family: 'Source Han Sans CN';
    src: local('Source Han Sans CN Normal'),
         local('思源黑体 Normal'),
         url('SourceHanSansCN-Normal.woff2') format('woff2'),
         url('SourceHanSansCN-Normal.woff') format('woff');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Source Han Sans CN', '思源黑体', sans-serif;
}
body {
    background: #1a1a1a;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    min-height: 100dvh;
    padding: 24px;
    overflow-x: hidden;
    overflow-y: auto;
    width: 100%;
    height: auto;
}

/* 播放器容器样式 */
.player-container {
    background: #222222;
    border: 4px solid #111111;
    border-radius: 12px;
    box-shadow: 
        0 15px 40px rgba(0, 0, 0, 0.95),
        0 5px 15px rgba(0, 0, 0, 0.8),
        inset 0 0 30px rgba(0, 0, 0, 0.85);
    width: min(1150px, calc(100vw - 48px));
    max-width: none;
    aspect-ratio: 1150 / 625;
    height: auto;
    flex: 0 0 auto;
    display: flex;
    gap: 0;
    padding: 0;
    position: relative;
    overflow: hidden;
    background-image: 
        radial-gradient(circle at 50% 50%, rgba(30,30,30,0.9) 0%, rgba(20,20,20,1) 100%),
        repeating-linear-gradient(0deg, transparent 0px, transparent 2px, rgba(0,0,0,0.1) 2px, rgba(0,0,0,0.1) 3px);
    transform: none;
}
.player-container::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 40px;
    background: linear-gradient(180deg, rgba(40,40,40,0.3) 0%, transparent 100%);
    pointer-events: none;
    border-radius: 8px 8px 0 0;
}
.player-container::before {
    display: none;
}

/* 左侧控制区样式 */
.left-controls {
    display: flex;
    flex-direction: column;
    gap: 20px;
    width: 200px;
    padding: 20px 15px 20px 20px;
    background: #1a1a1a;
    border-right: 4px solid #111111;
    box-shadow: 
        8px 0 20px rgba(0, 0, 0, 0.9),
        inset 0 0 20px rgba(0, 0, 0, 0.8);
    position: relative;
    z-index: 2;
    border-radius: 8px 0 0 8px;
    background-image: 
        radial-gradient(circle at 50% 50%, rgba(25,25,25,0.95) 0%, rgba(18,18,18,1) 100%);
}
.left-controls::before {
    content: '';
    position: absolute;
    right: -4px;
    top: 0;
    bottom: 0;
    width: 4px;
    background: #181818;
    box-shadow: 
        2px 0 10px rgba(0, 0, 0, 0.9),
        inset 0 0 8px rgba(0,0,0,0.95),
        0 0 2px rgba(30,30,30,0.5);
    border-radius: 0 3px 3px 0;
    background-image: linear-gradient(90deg, #151515 0%, #1c1c1c 50%, #151515 100%);
}

/* 通用按钮样式 */
.control-btn {
    background: #282828;
    border: none;
    border-radius: 8px;
    color: #0f0;
    font-size: 20px;
    font-weight: bold;
    height: 70px;
    cursor: pointer;
    box-shadow: 
        0 8px 12px rgba(0, 0, 0, 0.9),
        0 3px 6px rgba(0,0,0,0.7),
        inset 0 2px 3px rgba(50,50,50,0.1),
        inset 0 -2px 5px rgba(0, 0, 0, 0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
    background-image: 
        radial-gradient(circle at 50% 40%, rgba(35,35,35,1) 0%, rgba(25,25,25,1) 100%);
    border: 1px solid #1f1f1f;
    transition: none;
}
.control-btn:active {
    transform: translateY(3px);
    box-shadow: 
        0 2px 4px rgba(0, 0, 0, 0.95),
        inset 0 4px 8px rgba(0, 0, 0, 0.95),
        inset 0 -1px 2px rgba(50,50,50,0.05);
    background: #222222;
    background-image: radial-gradient(circle at 50% 50%, rgba(22,22,22,1) 0%, rgba(18,18,18,1) 100%);
}
.control-btn::after {
    content: '';
    position: absolute;
    top: 1px;
    left: 1px;
    right: 1px;
    bottom: 1px;
    border: 1px solid #2f2f2f;
    border-radius: 7px;
    pointer-events: none;
    opacity: 0.6;
    box-shadow: inset 0 0 1px rgba(60,60,60,0.2);
}

/* 播放/暂停按钮 */
#playPauseBtn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
}

/* 状态指示灯 */
.status-indicator {
    width: 20px;
    height: 20px;
    background-color: #222;
    border-radius: 4px;
    position: relative;
    box-shadow: 
        inset 0 0 6px rgba(0,0,0,0.9),
        0 0 2px rgba(0,0,0,0.8);
    border: 1px solid #1a1a1a;
    flex-shrink: 0;
}
.status-indicator.playing {
    background-color: #d00;
    box-shadow: inset 0 0 6px rgba(0,0,0,0.6);
    border: 1px solid #b00;
}

/* 播放图标 */
.icon-play {
    width: 0;
    height: 0;
    border-left: 18px solid #0f0;
    border-top: 12px solid transparent;
    border-bottom: 12px solid transparent;
    filter: contrast(1.1) brightness(0.9);
}

/* 暂停图标 */
.icon-pause {
    width: 20px;
    height: 24px;
    border-left: 6px solid #0f0;
    border-right: 6px solid #0f0;
    filter: contrast(1.1) brightness(0.9);
}

#playPauseBtn.playing .icon-pause {
    display: block;
}
#playPauseBtn.playing .icon-play {
    display: none;
}
#playPauseBtn .icon-pause {
    display: none;
}

/* 音量增加图标 */
.volume-up-icon {
    position: relative;
    width: 40px;
    height: 40px;
}
.volume-up-icon .greater-than {
    position: absolute;
    top: 4px;
    left: 50%;
    transform: translateX(-50%);
    width: 16px;
    height: 16px;
}
.volume-up-icon .greater-than::before,
.volume-up-icon .greater-than::after {
    content: '';
    position: absolute;
    width: 2px;
    height: 16px;
    background-color: #0f0;
    top: 0;
}
.volume-up-icon .greater-than::before {
    left: 8px;
    transform: rotate(45deg);
    transform-origin: top left;
}
.volume-up-icon .greater-than::after {
    right: 8px;
    transform: rotate(-45deg);
    transform-origin: top right;
}
.volume-up-icon .plus {
    position: absolute;
    bottom: 6px;
    left: 50%;
    transform: translateX(-50%);
    width: 16px;
    height: 16px;
}
.volume-up-icon .plus::before,
.volume-up-icon .plus::after {
    content: '';
    position: absolute;
    background-color: #0f0;
}
.volume-up-icon .plus::before {
    top: 7px;
    left: 0;
    width: 16px;
    height: 2px;
}
.volume-up-icon .plus::after {
    top: 0;
    left: 7px;
    width: 2px;
    height: 16px;
}

/* 音量减小图标 */
.volume-down-icon {
    position: relative;
    width: 40px;
    height: 40px;
}
.volume-down-icon .minus {
    position: absolute;
    top: 4px;
    left: 50%;
    transform: translateX(-50%);
    width: 16px;
    height: 2px;
    background-color: #0f0;
}
.volume-down-icon .less-than {
    position: absolute;
    bottom: 4px;
    left: 50%;
    transform: translateX(-50%);
    width: 16px;
    height: 16px;
}
.volume-down-icon .less-than::before,
.volume-down-icon .less-than::after {
    content: '';
    position: absolute;
    width: 2px;
    height: 16px;
    background-color: #0f0;
    bottom: 0;
}
.volume-down-icon .less-than::before {
    left: 8px;
    transform: rotate(-45deg);
    transform-origin: bottom left;
}
.volume-down-icon .less-than::after {
    right: 8px;
    transform: rotate(45deg);
    transform-origin: bottom right;
}

/* 静音按钮文字 */
#muteBtn {
    font-size: 18px;
    font-weight: bold;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: #0f0;
}

/* 右侧区域 */
.right-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 20px;
    padding: 20px 20px 20px 15px;
    position: relative;
    border-radius: 0 8px 8px 0;
    background-image: radial-gradient(circle at 50% 50%, rgba(22,22,22,0.05) 0%, transparent 100%);
}

/* 磁带仓 */
.tape-deck {
    display: flex;
    align-items: center;
    gap: 20px;
    height: 80px;
    background: #1d1d1d;
    border-radius: 8px;
    padding: 15px;
    box-shadow: 
        inset 0 0 20px rgba(0, 0, 0, 0.95),
        0 6px 10px rgba(0, 0, 0, 0.85);
    background-image: radial-gradient(circle at 50% 50%, #1e1e1e 0%, #191919 100%);
    border: 1px solid #151515;
}

/* 弹出按钮 */
.eject-btn {
    width: 70px;
    height: 70px;
    background: #282828;
    border: none;
    border-radius: 8px;
    color: #0f0;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 
        0 8px 12px rgba(0, 0, 0, 0.9),
        0 3px 6px rgba(0,0,0,0.7),
        inset 0 2px 3px rgba(50,50,50,0.1),
        inset 0 -2px 5px rgba(0, 0, 0, 0.95);
    position: relative;
    overflow: hidden;
    background-image: radial-gradient(circle at 50% 40%, rgba(35,35,35,1) 0%, rgba(25,25,25,1) 100%);
    border: 1px solid #1f1f1f;
    flex-shrink: 0;
}
.eject-btn:active {
    transform: translateY(3px);
    box-shadow: 
        0 2px 4px rgba(0, 0, 0, 0.95),
        inset 0 4px 8px rgba(0, 0, 0, 0.95),
        inset 0 -1px 2px rgba(50,50,50,0.05);
    background: #222222;
    background-image: radial-gradient(circle at 50% 50%, rgba(22,22,22,1) 0%, rgba(18,18,18,1) 100%);
}
.eject-btn::after {
    content: '';
    position: absolute;
    top: 1px;
    left: 1px;
    right: 1px;
    bottom: 1px;
    border: 1px solid #2f2f2f;
    border-radius: 7px;
    pointer-events: none;
    opacity: 0.6;
    box-shadow: inset 0 0 1px rgba(60,60,60,0.2);
}

/* 弹出图标 */
.eject-icon {
    position: relative;
    width: 30px;
    height: 30px;
}
.eject-icon::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 12px solid transparent;
    border-right: 12px solid transparent;
    border-bottom: 12px solid #0f0;
    filter: contrast(1.1) brightness(0.9);
}
.eject-icon::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 24px;
    height: 8px;
    background-color: #0f0;
    filter: contrast(1.1) brightness(0.9);
}

/* 磁带槽 */
.tape-slot {
    flex: 1;
    height: 50px;
    background: #111111;
    border: 1px solid #0a0a0a;
    border-radius: 8px;
    position: relative;
    overflow: hidden;
    box-shadow: 
        inset 0 0 15px rgba(0, 0, 0, 0.98),
        0 3px 6px rgba(0, 0, 0, 0.85);
    background-image: repeating-linear-gradient(0deg, #101010 0px, #101010 1px, #0e0e0e 1px, #0e0e0e 2px);
}
.tape-slot::before,
.tape-slot::after {
    content: '';
    position: absolute;
    width: 100%;
    height: 1px;
    background: linear-gradient(90deg, transparent 10%, rgba(0, 255, 0, 0.25) 30%, rgba(0, 255, 0, 0.25) 70%, transparent 90%);
    left: 0;
    box-shadow: 0 0 2px rgba(0,0,0,0.9);
}
.tape-slot::before { top: 12px; }
.tape-slot::after { bottom: 12px; }

/* 磁带标签 */
.tape-label {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #0f0;
    font-size: 14px;
    font-family: 'Source Han Sans CN', '思源黑体', monospace;
    letter-spacing: 1px;
    white-space: nowrap;
    filter: blur(0.2px);
}

/* 可视化区域 */
.visualizer {
    flex: 1;
    background: #0f0f0f;
    border: 1px solid #0a0a0a;
    border-radius: 8px;
    position: relative;
    overflow: hidden;
    box-shadow: 
        inset 0 0 30px rgba(0, 0, 0, 0.98),
        0 6px 10px rgba(0, 0, 0, 0.85);
    background-image: radial-gradient(circle at 50% 50%, #0e0e0e 0%, #0c0c0c 100%);
}
#c {
    width: 100%;
    height: 100%;
    display: block;
}

/* 底部栏 */
.footer-bar {
    height: 30px;
    background: #1f1f1f;
    border: 1px solid #0a0a0a;
    border-radius: 8px;
    box-shadow: 
        inset 0 0 15px rgba(0, 0, 0, 0.95),
        0 3px 6px rgba(0, 0, 0, 0.85);
    background-image: radial-gradient(circle at 50% 50%, #202020 0%, #1b1b1b 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 10px;
    position: relative;
}

/* 页脚链接样式 */
.footer-bar a {
    color: #0f0; 
    text-decoration: none;
    font-size: 14px;
    letter-spacing: 1px;
}
.footer-bar a:focus,
.footer-bar a:active {
    outline: none;
}

#fileInput {
    display: none;
}

/* ============================================================
   移动端：纵向布局，优先扩大 Canvas 显示区域
   ============================================================ */

@media (max-width: 768px) and (orientation: portrait) {
    body {
        align-items: flex-start;
        justify-content: center;
        padding: max(12px, env(safe-area-inset-top)) 12px max(12px, env(safe-area-inset-bottom));
        min-height: 100vh;
        min-height: 100dvh;
    }

    .player-container {
        width: 100%;
        max-width: 520px;
        height: auto;
        aspect-ratio: auto;
        display: grid;
        grid-template-columns: minmax(0, 1fr);
        grid-template-areas:
            "display"
            "controls"
            "tape"
            "footer";
        gap: 12px;
        padding: 12px;
        border-width: 3px;
        border-radius: 10px;
        overflow: visible;
        transform: none;
    }

    /* 让右侧区域的三个内容直接参与外层 Grid 排列 */
    .right-section {
        display: contents;
    }

    .visualizer {
        grid-area: display;
        width: 100%;
        height: clamp(250px, 44dvh, 390px);
        min-height: 250px;
        flex: none;
    }

    .left-controls {
        grid-area: controls;
        width: 100%;
        display: grid;
        grid-template-columns: repeat(5, minmax(0, 1fr));
        gap: 8px;
        padding: 10px;
        border-right: none;
        border-radius: 8px;
        box-shadow: inset 0 0 16px rgba(0, 0, 0, 0.8);
    }

    .left-controls::before {
        display: none;
    }

    .control-btn {
        min-width: 0;
        height: 54px;
        font-size: 16px;
        border-radius: 7px;
    }

    #playPauseBtn {
        gap: 7px;
    }

    .status-indicator {
        width: 12px;
        height: 12px;
    }

    .icon-play {
        border-left-width: 13px;
        border-top-width: 9px;
        border-bottom-width: 9px;
    }

    .icon-pause {
        width: 16px;
        height: 18px;
        border-left-width: 5px;
        border-right-width: 5px;
    }

    .volume-up-icon,
    .volume-down-icon {
        transform: scale(0.8);
    }

    #muteBtn {
        font-size: 12px;
        letter-spacing: 0;
    }

    .system-audio-icon {
        width: 21px;
        height: 21px;
    }

    .tape-deck {
        grid-area: tape;
        width: 100%;
        height: 62px;
        gap: 10px;
        padding: 6px 10px;
    }

    .eject-btn {
        width: 48px;
        height: 48px;
    }

    .tape-slot {
        height: 44px;
    }

    .footer-bar {
        grid-area: footer;
        height: 26px;
    }

    .footer-bar a {
        font-size: 11px;
    }
}

/* 手机横屏及较矮的平板横屏：保留横向硬件面板，不旋转 */
@media (max-width: 900px) and (orientation: landscape) and (max-height: 520px) {
    body {
        padding: 10px;
        min-height: 100vh;
        min-height: 100dvh;
        align-items: center;
        overflow-y: auto;
    }

    .player-container {
        width: min(96vw, calc((100dvh - 20px) * 1.84));
        aspect-ratio: 1150 / 625;
        height: auto;
        transform: none;
    }

    .left-controls {
        width: 17.4%;
        padding: 12px 10px;
        gap: 12px;
    }

    .control-btn {
        height: 52px;
        font-size: 16px;
    }

    .right-section {
        gap: 12px;
        padding: 12px 12px 12px 10px;
    }

    .tape-deck {
        height: 64px;
        padding: 8px;
        gap: 12px;
    }

    .eject-btn {
        width: 48px;
        height: 48px;
    }
}

/* 超窄手机：按钮优先保证可点击 */
@media (max-width: 360px) and (orientation: portrait) {
    .player-container {
        padding: 8px;
        gap: 9px;
    }

    .left-controls {
        gap: 5px;
        padding: 7px;
    }

    .control-btn {
        height: 48px;
    }

    .visualizer {
        height: 270px;
    }
}

/* 系统声音捕获按钮图标 —— 绿色圆形 */
.system-audio-icon {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background-color: #0f0;
    filter: contrast(1.1) brightness(0.9);
    position: relative;
    box-shadow: 0 0 8px rgba(0, 255, 0, 0.35);
}

/* 激活状态（正在捕获系统声音）时，加一层呼吸光晕 */
#systemAudioBtn.active .system-audio-icon {
    animation: audio-pulse 1.5s ease-in-out infinite;
}

@keyframes audio-pulse {
    0%, 100% {
        box-shadow: 0 0 8px rgba(0, 255, 0, 0.35);
    }
    50% {
        box-shadow: 0 0 20px rgba(0, 255, 0, 0.8), 0 0 35px rgba(0, 255, 0, 0.4);
    }
}

/* 键盘焦点与减少动态效果 */
.control-btn:focus-visible,
.eject-btn:focus-visible,
.footer-bar a:focus-visible {
    outline: 2px solid #48F76B;
    outline-offset: 3px;
}

@media (prefers-reduced-motion: reduce) {
    #systemAudioBtn.active .system-audio-icon {
        animation: none;
    }
}
