body, html {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    overflow: auto; /* 允许滚动，以便在小屏幕上查看完整内容 */
    font-family: 'Arial', sans-serif;
}

#game-container {
    width: 1920px; /* 固定宽度，适配PC端设计 */
    height: 1080px; /* 固定高度，适配PC端设计 */
    position: relative;
    margin: 0 auto; /* 居中显示 */
}

.screen {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    display: none;
    background-size: cover;
    background-position: center;
}

.screen.active {
    display: block;
}

#start-screen {
    background-image: url('images/cover.webp');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    align-items: flex-end;
}

#start-btn {
    padding: 20px 50px;
    font-size: 28px;
    font-weight: bold;
    color: white;
    background: linear-gradient(135deg, #ff6f61 0%, #e65a50 100%);
    border: none;
    border-radius: 15px;
    cursor: pointer;
    margin-bottom: 120px;
    margin-right: 850px;
    box-shadow: 0 6px 20px rgba(0,0,0,0.3);
    transition: all 0.3s;
}

#start-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0,0,0,0.4);
}

.disclaimer {
    position: absolute;
    bottom: 10px;
    width: 100%;
    text-align: center;
    color: white;
    font-size: 12px;
    background-color: rgba(0,0,0,0.5);
    padding: 5px 0;
}

/* Level 1 Styles */
#level1 {
    background-image: url('images/round1_forest.webp');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}

.level-instruction {
    position: absolute;
    top: 5px;
    left: 17%;
    transform: translateX(-50%);
    background-color: rgba(255, 255, 255, 0.95);
    padding: 15px 30px;
    border-radius: 20px;
    font-size: 18px;
    font-weight: bold;
    color: #333;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    text-align: center;
    max-width: 90%;
    z-index: 100;
}

#top-groups {
    position: absolute;
    top: 28%;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 60px;
}

.color-block {
    width: 120px;
    height: 250px;
    border: 4px solid #333;
    border-radius: 12px;
    box-shadow: 0 8px 20px rgba(0,0,0,0.4), inset 0 2px 5px rgba(255,255,255,0.3);
}

#ground-area {
    position: absolute;
    top: 58%;
    left: 50%;
    transform: translateX(-50%);
    width: 80%;
    height: 300px;
    display: flex;
    align-items: center;
    justify-content: center;
}

#ground-blocks {
    display: flex;
    gap: 8px;
    align-items: center;
}

.hole-container {
    display: flex;
    gap: 8px;
    position: relative;
}

.hole-container::before {
    content: '';
    position: absolute;
    left: -24px;
    right: -24px;
    top: -14px;
    bottom: -14px;
    border-radius: 120px / 60px;
    background: radial-gradient(ellipse at center, rgba(0,0,0,0.1) 0%, rgba(0,0,0,0.3) 50%, rgba(0,0,0,0.1) 100%); /* 微妙径向渐变增强洞穴感 */
    border: 2px solid rgba(0, 0, 0, 0.2); /* 微妙边框显示轮廓 */
    box-shadow: inset 0 0 30px rgba(0, 0, 0, 0.3); /* 内阴影增强深度感 */
    opacity: 0; /* 设为完全透明，不显示阴影块，但保持结构以防需要恢复 */
    z-index: 5; /* 洞背景层级，低于固定方块 */
    pointer-events: none; /* 不阻挡鼠标事件，确保拖拽检测正常 */
}

.ground-slot {
    width: 120px;
    height: 250px;
    border: 4px solid #333;
    border-radius: 12px;
    box-shadow: 0 8px 20px rgba(0,0,0,0.4), inset 0 2px 5px rgba(255,255,255,0.3);
    position: relative;
    z-index: 10; /* 固定方块层级 */
}

.ground-slot.hole-slot {
    background: transparent;
    border: 4px dashed rgba(0, 0, 0, 0.4);
    box-shadow: none;
}

.ground-slot.drop-active {
    border-color: rgba(255, 193, 7, 0.8);
}

.ground-slot.drop-target {
    background-color: rgba(76, 175, 80, 0.2);
    border-color: rgba(76, 175, 80, 0.8);
    border-style: solid;
}

#color-options {
    position: absolute;
    bottom: 8%;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 40px;
}

.block-group {
    display: flex;
    gap: 8px;
    cursor: grab;
    transition: transform 0.2s;
    touch-action: none; /* 触屏更顺滑 */
    z-index: 200; /* 拖拽方块层级 */
    position: relative;
    will-change: transform; /* 优化拖拽闪烁 */
    transform: translate3d(0, 0, 0); /* 强制硬件加速 */
    backface-visibility: hidden; /* 优化闪烁 */
}

.block-group:hover {
    transform: scale(1.05);
}

.block-group.dragging {
    z-index: 300; /* 拖拽时最高层级 */
    transform: translateZ(0); /* 保持3D加速上下文 */
    backface-visibility: hidden; /* 优化闪烁 */
}

.group-block {
    width: 120px;
    height: 250px;
    border: 4px solid #333;
    border-radius: 12px;
    box-shadow: 0 8px 20px rgba(0,0,0,0.4), inset 0 2px 5px rgba(255,255,255,0.3);
    position: relative;
    z-index: 201; /* 拖拽方块内层级 */
}

.draggable-color {
    width: 120px;
    height: 250px;
    cursor: grab;
    border: 4px solid #333;
    border-radius: 12px;
    box-shadow: 0 8px 20px rgba(0,0,0,0.4), inset 0 2px 5px rgba(255,255,255,0.3);
    transition: transform 0.2s;
}

.draggable-color:hover {
    transform: scale(1.08);
}

.draggable-color:active {
    cursor: grabbing;
}

/* 第一关小男孩样式 */
.boy-level1 {
    position: absolute;
    top: 35%;
    left: 10px;
    width: 320px;
    height: 440px;
    background-image: url('images/walk-sprite.png');
    background-repeat: no-repeat;
    background-position: 0 0;
    background-size: 1900px 440px;
    transform: translateX(0);
    display: none;
    z-index: 1000;
}

/* 第二关小男孩样式 */
.boy-level2 {
    position: absolute;
    top: 20%;
    left: 150px;
    width: 140px;
    height: 260px;
    background-image: url('images/walk-sprite.png');
    background-repeat: no-repeat;
    background-position: 0 0;
    background-size: 840px 260px;
    transform: translateX(0);
    display: none;
    z-index: 1000;
}

/* 第三关小男孩样式 */
.boy-level3 {
    position: absolute;
    top: 20%;
    left: 130px;
    width: 320px;
    height: 460px;
    background-image: url('images/walk-sprite.png');
    background-repeat: no-repeat;
    background-position: 0 0;
    background-size: 1920px 460px;
    transform: translateX(0);
    display: none;
    z-index: 1000;
}

/* Level 2 Styles */
#level2 {
    background-image: url('images/round2_mountain.webp');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}

#bridge-left {
    position: absolute;
    top: 40%;
    left: 14%;
    display: flex;
}

#bridge-gap {
    position: absolute;
    top: 40%;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 6px;
    min-width: 432px; /* 3个板块的宽度 + 间隙 */
    min-height: 80px; /* 板块高度 */
}

#bridge-right {
    position: absolute;
    top: 40%;
    right: 14%;
    display: flex;
}

/* 桥板组（固定的和可拖动的） */
.plank-group {
    display: flex;
    gap: 6px;
}

/* 单个桥板 */
.symbol-plank {
    width: 140px;
    height: 80px;
    border: 4px solid #5d4037;
    background: linear-gradient(135deg, #8d6e63 0%, #6d4c41 100%);
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 42px;
    border-radius: 10px;
    box-shadow: 0 6px 15px rgba(0,0,0,0.5);
    color: #ffeb3b;
    text-shadow: 3px 3px 6px rgba(0,0,0,0.6);
}

/* 缺口空槽 */
.gap-slot {
    width: 140px;
    height: 80px;
    border: 4px dashed rgba(255, 255, 255, 0.6);
    border-radius: 10px;
    background-color: rgba(135, 206, 235, 0.2);
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 42px;
    color: #ffeb3b;
    text-shadow: 3px 3px 6px rgba(0,0,0,0.6);
    transition: all 0.3s;
}

.gap-slot.filled {
    border: 4px solid #5d4037;
    background: linear-gradient(135deg, #8d6e63 0%, #6d4c41 100%);
    box-shadow: 0 6px 15px rgba(0,0,0,0.5);
}

#bridge-gap.drop-active .gap-slot {
    border-color: rgba(255, 193, 7, 0.8);
}

#bridge-gap.drop-target .gap-slot {
    background-color: rgba(76, 175, 80, 0.3);
    border-color: rgba(76, 175, 80, 0.8);
    border-style: solid;
}

/* 可拖动桥板组选项区 */
#plank-options {
    position: absolute;
    bottom: 18%;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 40px;
}

.draggable-plank-group {
    display: flex;
    gap: 6px;
    cursor: grab;
    transition: transform 0.2s;
    touch-action: none;
    position: relative;
}

.draggable-plank-group:hover {
    transform: scale(1.05);
}

.draggable-plank-group.dragging {
    z-index: 300;
    transform: rotate(1deg);
}

.draggable-plank-group .draggable-plank {
    width: 140px;
    height: 80px;
    border: 4px solid #5d4037;
    background: linear-gradient(135deg, #8d6e63 0%, #6d4c41 100%);
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 42px;
    border-radius: 10px;
    box-shadow: 0 6px 15px rgba(0,0,0,0.5);
    color: #ffeb3b;
    text-shadow: 3px 3px 6px rgba(0,0,0,0.6);
    pointer-events: none;
}

.draggable-plank-group:active {
    cursor: grabbing;
}

/* Level 3 Styles */
#level3 {
    background-image: url('images/round3_river.webp');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}

#path-options {
    position: absolute;
    top: 60%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    flex-direction: column;
    gap: 35px;
}

.path {
    cursor: pointer;
    border: 5px solid transparent;
    padding: 15px 25px;
    background-color: rgba(255, 255, 255, 0.7);
    border-radius: 25px;
    transition: all 0.3s;
    min-width: 900px; /* 9个音符 × 90px */
    display: flex;
    justify-content: center;
    box-shadow: 0 6px 20px rgba(0,0,0,0.3);
}

.path:hover {
    border-color: #ff6f61;
    background-color: rgba(255, 255, 255, 0.9);
    transform: scale(1.05);
    box-shadow: 0 8px 25px rgba(255, 111, 97, 0.5);
}

/* 七彩动画效果 - 只改变边框和阴影，不改变背景 */
.path.rainbow-animation {
    border-color: #ff6f61;
    transform: scale(1.05);
    box-shadow: 0 0 30px rgba(255, 215, 0, 0.8), 0 0 50px rgba(255, 105, 180, 0.6);
}

/* 音符样式 */
.music-note {
    font-weight: bold;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
    transition: all 0.3s;
}

/* 音符逐个发光动画 */
.path.rainbow-animation .music-note {
    animation: noteGlowSequence 0.4s ease-in-out forwards;
}

/* 为每个音符设置不同的延迟时间，实现逐个发光效果 */
.path.rainbow-animation .note-0 { animation-delay: 0s; }
.path.rainbow-animation .note-1 { animation-delay: 0.15s; }
.path.rainbow-animation .note-2 { animation-delay: 0.3s; }
.path.rainbow-animation .note-3 { animation-delay: 0.45s; }
.path.rainbow-animation .note-4 { animation-delay: 0.6s; }
.path.rainbow-animation .note-5 { animation-delay: 0.75s; }
.path.rainbow-animation .note-6 { animation-delay: 0.9s; }
.path.rainbow-animation .note-7 { animation-delay: 1.05s; }
.path.rainbow-animation .note-8 { animation-delay: 1.2s; }

@keyframes noteGlowSequence {
    0% { 
        fill: #333; 
        text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
    }
    50% { 
        fill: #ffd700; 
        text-shadow: 0 0 25px #ffd700, 0 0 40px #ffd700, 0 0 55px #ff6f61, 0 0 70px #ff6f61;
    }
    100% { 
        fill: #ffd700; 
        text-shadow: 0 0 20px #ffd700, 0 0 35px #ffd700, 0 0 45px #ff6f61;
    }
}

/* Game Over Styles */
#game-over {
    background-image: url('images/GameOver.webp');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}

#game-over .level-instruction {
    position: absolute;
    top: 5%;
    left: 20%;
    transform: translate(-50%, -50%);
    font-size: 24px;
    padding: 25px 45px;
    background-color: rgba(255, 255, 255, 0.95);
    animation: fadeInScale 0s ease-in-out;
}

@keyframes fadeInScale {
    0% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.8);
    }
    100% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
}

@keyframes walk-level1 {
    from { background-position: 0 0; }
    to { background-position: -1920px 0; } /* 第一关：6帧 × 320px */
}

@keyframes walk-level2 {
    from { background-position: 0 0; }
    to { background-position: -840px 0; } /* 第二关：6帧 × 140px */
}

@keyframes walk-level3 {
    from { background-position: 0 0; }
    to { background-position: -1920px 0; } /* 第三关：6帧 × 320px */
}
