/* 游戏全屏容器 */
.game-wrapper {
    position: relative;
    width: 100%;
    height: 90vh; /* 占据大部分屏幕 */
    overflow: hidden;
    background: #000;
    border-radius: 20px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3);
    margin-top: 20px;
}

/* === 背景层控制 === */
#bg-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
}

/* 模式1: 渐变 */
.bg-gradient {
    background: linear-gradient(135deg, #FFAB76 0%, #88DD88 100%);
    animation: hueRotate 10s infinite alternate;
}

/* 模式2: 图片 */
#bg-image {
    width: 100%;
    height: 100%;
    background-size: cover;
    background-position: center;
    filter: blur(5px); /* 模糊处理以免干扰视线 */
}

/* 模式3: 视频 */
#bg-video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* 遮罩层 (让背景变暗，凸显音符) */
#bg-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4); /* 40% 黑色遮罩 */
    backdrop-filter: blur(2px);
}

/* === 游戏界面 === */
.game-interface {
    position: relative;
    z-index: 10;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.game-header {
    display: flex;
    justify-content: space-between;
    width: 90%;
    max-width: 600px;
    margin-top: 20px;
    color: white;
    text-shadow: 0 2px 5px rgba(0, 0, 0, 0.5);
    font-family: "Quicksand", sans-serif;
}

.score-box, .combo-box {
    display: flex;
    flex-direction: column;
    align-items: center;
}

#score-num {
    font-size: 2em;
    font-weight: 700;
}

#combo-num {
    font-size: 2.5em;
    font-weight: 800;
    color: #FFAB76;
}

.label {
    font-size: 0.8em;
    letter-spacing: 2px;
    opacity: 0.8;
}

/* === 轨道系统 (透视效果) === */
.track-container {
    position: absolute;
    bottom: 0;
    width: 100%;
    max-width: 500px;
    height: 85%;
    background: linear-gradient(to bottom, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 0.1) 100%);
    perspective: 1000px; /* 3D透视 */
    display: flex;
    border-top: 2px solid rgba(255, 255, 255, 0.1);
}

.lane {
    flex: 1;
    border-right: 1px solid rgba(255, 255, 255, 0.15);
    position: relative;
}

.lane:first-child {
    border-left: 1px solid rgba(255, 255, 255, 0.15);
}

/* 按键提示 */
.key-hint {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    color: rgba(255, 255, 255, 0.5);
    font-weight: bold;
    font-size: 1.2em;
}

/* 判定线 */
.judgment-line {
    position: absolute;
    bottom: 80px; /* 判定区域高度 */
    width: 100%;
    height: 4px;
    background: linear-gradient(to right, #FFAB76, #88DD88);
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.8);
    z-index: 5;
}

/* 音符 (Note) */
.note {
    position: absolute;
    width: 25%; /* 占一个车道宽度 (100% / 4) */
    height: 12px; /* 音符厚度 */
    background: #FFAB76; /* Minori Orange */
    border-radius: 4px;
    box-shadow: 0 0 10px #FFAB76;
    top: -20px; /* 初始在屏幕外 */
    z-index: 6;
    /* 后面用JS控制 top */
}

/* 轨道2和3换个颜色方便区分 */
.note.track-1, .note.track-2 {
    background: #88DD88;
    box-shadow: 0 0 10px #88DD88;
}

/* 按下特效 */
.lane.active {
    background: linear-gradient(to top, rgba(255, 171, 118, 0.4) 0%, transparent 50%);
}

/* 判定文字 (Perfect/Great) */
#judgment-display {
    position: absolute;
    top: 40%;
    font-size: 3em;
    font-weight: 900;
    font-style: italic;
    color: #fff;
    text-shadow: 0 0 20px rgba(255, 171, 118, 0.8);
    opacity: 0;
    transform: scale(0.8);
    transition: all 0.1s;
}

#judgment-display.show {
    opacity: 1;
    transform: scale(1.2);
}

/* === 设置模态框 === */
.glass-modal {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(15px);
    z-index: 100;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    color: white;
}

.song-cover {
    width: 150px;
    height: 150px;
    border-radius: 15px;
    margin-bottom: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.song-title {
    margin: 5px 0;
    font-size: 2em;
}

.song-artist {
    opacity: 0.7;
    margin-bottom: 30px;
}

.toggle-group {
    display: flex;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    padding: 4px;
    margin-top: 10px;
    margin-bottom: 30px;
}

.btn-toggle {
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.6);
    padding: 8px 16px;
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.3s;
}

.btn-toggle.active {
    background: #FFAB76;
    color: white;
    font-weight: bold;
}

.start-btn {
    font-size: 1.5em;
    padding: 15px 50px;
    margin-bottom: 10px;
}

.btn-text {
    color: white;
    text-decoration: underline;
    cursor: pointer;
    background: none;
    border: none;
}

@keyframes hueRotate {
    from {
        filter: hue-rotate(0deg);
    }
    to {
        filter: hue-rotate(30deg);
    }
}

/* === 核心背景控制 (修改) === */
/* 视频元素默认铺满 */
.bg-video-element {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    z-index: 1; /* 最底层 */
}

/* 图片层 */
#bg-image {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-size: cover;
    background-position: center;
    filter: blur(5px);
    z-index: 2; /* 在视频之上 */
    display: none; /* 默认隐藏 */
}

/* 渐变层 (纯色背景) */
.bg-gradient-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #FFAB76 0%, #88DD88 100%);
    animation: hueRotate 10s infinite alternate;
    z-index: 3; /* 在图片之上 */
    display: none; /* 默认隐藏 */
}

/* 当父容器有特定类时，显示对应层 */
/* MV模式: 视频(z1)可见，其他隐藏 */
/* Static模式: 图片(z2)显示，挡住视频 */
.bg-mode-image #bg-image {
    display: block;
}

/* Gradient模式: 渐变(z3)显示，挡住视频和图片 */
.bg-mode-gradient {
    background: linear-gradient(135deg, #FFAB76 0%, #88DD88 100%);
    animation: hueRotate 10s infinite alternate;
}

/* 在Gradient模式下，为了性能，我们不需要额外的div，直接给 bg-layer 加背景色遮挡即可，
   但为了保险，视频必须保持 opacity: 1 (不可见但播放中) 或者只是 z-index 低 */


/* === 选歌界面 UI (新增) === */
.select-title {
    font-family: "Quicksand", sans-serif;
    font-weight: 800;
    letter-spacing: 2px;
    margin-bottom: 20px;
    border-bottom: 2px solid #FFAB76;
    padding-bottom: 5px;
}

.song-list-container {
    width: 80%;
    max-width: 400px;
    height: 200px;
    overflow-y: auto;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    margin-bottom: 20px;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.song-item {
    padding: 10px 15px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    cursor: pointer;
    transition: background 0.2s;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.song-item:hover {
    background: rgba(255, 255, 255, 0.1);
}

.song-item.active {
    background: #FFAB76;
    color: #fff;
    font-weight: bold;
}

.selected-song-info {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 20px;
    background: rgba(0, 0, 0, 0.3);
    padding: 15px;
    border-radius: 12px;
    width: 80%;
    max-width: 400px;
}

.song-cover-small {
    width: 60px;
    height: 60px;
    border-radius: 8px;
    object-fit: cover;
}

.song-text-group {
    text-align: left;
}

#preview-title {
    margin: 0;
    font-size: 1.2em;
}

#preview-artist {
    margin: 0;
    font-size: 0.8em;
    opacity: 0.8;
}

.preview-diff {
    font-size: 0.8em;
    margin-top: 5px;
    background: #884499;
    padding: 2px 8px;
    border-radius: 4px;
    display: inline-block;
}