* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Microsoft YaHei', Arial, sans-serif;
    background: #f5e6d3;
    color: #333;
    margin: 0;
    padding: 0;
    overflow: hidden;
    transition: background-color 0.3s ease;
    width: 100vw;
    height: 100vh;
}

.screen {
    text-align: center;
}

.hidden {
    display: none !important;
}

/* 关卡选择界面 */
#levelSelect {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    height: 100vh;
    padding: 20px;
}

.top-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

#levelSelect h1 {
    font-size: 48px;
    margin-bottom: 30px;
    color: #f39c12;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
}

.level-grid {
    display: flex;
    gap: 15px;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 20px 10px;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 12px 12px 0 0;
}

.level-grid::-webkit-scrollbar {
    height: 10px;
}

.level-grid::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 5px;
}

.level-grid::-webkit-scrollbar-thumb {
    background: #f39c12;
    border-radius: 5px;
}

.level-grid::-webkit-scrollbar-thumb:hover {
    background: #e67e22;
}

.level-btn {
    min-width: 80px;
    width: 80px;
    height: 80px;
    font-size: 24px;
    font-weight: bold;
    border: 3px solid #f39c12;
    border-radius: 12px;
    background: linear-gradient(145deg, #3498db, #2980b9);
    color: white;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
    flex-shrink: 0;
}

.level-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.4);
    background: linear-gradient(145deg, #3cb0fd, #2c82c9);
}

.level-btn:active {
    transform: translateY(0);
}

.level-btn.completed {
    background: linear-gradient(145deg, #27ae60, #229954);
    border-color: #2ecc71;
}

/* 颜色选择器 */
.color-selector {
    margin-top: 30px;
}

.color-selector h3 {
    font-size: 24px;
    margin-bottom: 15px;
}

.color-options {
    display: flex;
    gap: 15px;
    justify-content: center;
}

.color-btn {
    width: 60px;
    height: 60px;
    border: 3px solid white;
    border-radius: 50%;
    cursor: pointer;
    transition: transform 0.2s ease;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

.color-btn:hover {
    transform: scale(1.1);
}

.color-btn.active {
    border-color: #f39c12;
    border-width: 5px;
}

/* 游戏界面 */
#gameScreen {
    width: 100vw;
    height: 100vh;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
}

.top-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px;
    background: linear-gradient(135deg, rgba(255, 248, 243, 0.95) 0%, rgba(255, 245, 238, 0.95) 100%);
    border-bottom: 3px solid rgba(255, 182, 193, 0.3);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    flex-shrink: 0;
    z-index: 10;
    backdrop-filter: blur(5px);
}

.game-info {
    flex: 1;
}

.game-title {
    font-size: 22px;
    font-weight: bold;
    color: #d87093;
    margin: 0 0 5px 0;
    letter-spacing: 2px;
    text-shadow: 1px 1px 2px rgba(255, 255, 255, 0.8);
}

.game-rules {
    font-size: 13px;
    color: #999;
    margin: 0;
    line-height: 1.5;
    font-weight: 500;
}

.icon-btn {
    width: 45px;
    height: 45px;
    border: none;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.95);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    transition: all 0.3s ease;
}

.icon-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.icon-btn:active {
    transform: scale(0.95);
}

.icon-btn svg {
    color: #333;
}

/* Canvas容器 */
.canvas-container {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px;
    overflow: hidden;
}

#gameCanvas {
    display: block;
    max-width: 100%;
    max-height: 100%;
    margin: 0 auto;
}

#failMark {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    animation: failAnimation 0.5s ease-out;
    pointer-events: none;
    z-index: 9999;
}

.error-image {
    width: 100px;
    height: 100px;
    object-fit: contain;
}

/* 过关弹窗 */
.win-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn 0.3s ease;
}

.win-content {
    background: linear-gradient(135deg, #FFF5F5 0%, #FFE4E1 50%, #FFF0F0 100%);
    padding: 40px 50px;
    border-radius: 30px;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
    animation: bounceIn 0.5s ease;
    border: 3px solid #FFB6C1;
    position: relative;
    overflow: hidden;
}

.win-content::before {
    content: '🍑';
    position: absolute;
    font-size: 80px;
    top: -20px;
    left: -20px;
    opacity: 0.2;
    animation: float 3s ease-in-out infinite;
}

.win-content::after {
    content: '🍑';
    position: absolute;
    font-size: 60px;
    bottom: -15px;
    right: -15px;
    opacity: 0.2;
    animation: float 3s ease-in-out infinite 1.5s;
}

@keyframes float {
    0%, 100% {
        transform: translateY(0) rotate(0deg);
    }
    50% {
        transform: translateY(-10px) rotate(5deg);
    }
}

.win-content h1 {
    font-size: 48px;
    color: #D87093;
    margin: 0 0 15px 0;
    font-weight: bold;
    text-shadow: 1px 1px 3px rgba(255, 255, 255, 0.8);
    letter-spacing: 3px;
    position: relative;
    z-index: 1;
}

.win-subtitle {
    font-size: 18px;
    color: #BC8F8F;
    margin: 0;
    font-weight: 500;
    position: relative;
    z-index: 1;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes bounceIn {
    0% {
        opacity: 0;
        transform: scale(0.3);
    }
    50% {
        opacity: 1;
        transform: scale(1.05);
    }
    70% {
        transform: scale(0.9);
    }
    100% {
        transform: scale(1);
    }
}

/* 大关卡通过弹窗 */
.big-level-win-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1500;
    animation: fadeIn 0.3s ease;
}

.big-level-win-content {
    background: linear-gradient(135deg, #fff5f5 0%, #ffe4e4 100%);
    padding: 45px 55px;
    border-radius: 25px;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: scaleIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
    max-width: 420px;
    border: 3px solid #ffb6c1;
}

.medal-icon {
    font-size: 80px;
    margin-bottom: 20px;
    animation: medalSwing 2s ease-in-out infinite;
    filter: drop-shadow(0 8px 15px rgba(255, 182, 193, 0.4));
}

@keyframes medalSwing {
    0%, 100% {
        transform: rotate(-8deg);
    }
    50% {
        transform: rotate(8deg);
    }
}

.big-level-title {
    font-size: 38px;
    font-weight: 800;
    color: #ec4899;
    margin: 0 0 20px 0;
    letter-spacing: 2px;
}

.level-name {
    font-size: 24px;
    color: #f472b6;
    margin: 0 0 25px 0;
    font-weight: 700;
}

.star-line {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-bottom: 20px;
}

.star-item {
    font-size: 36px;
    display: inline-block;
    animation: starBounce 1s ease-in-out infinite;
}

.star-item:nth-child(1) {
    animation-delay: 0s;
}

.star-item:nth-child(2) {
    animation-delay: 0.15s;
}

.star-item:nth-child(3) {
    animation-delay: 0.3s;
}

@keyframes starBounce {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-10px);
    }
}

.continue-text {
    font-size: 15px;
    color: #f472b6;
    margin: 0;
    font-weight: 600;
    opacity: 0.9;
}

/* 底部关卡选择 */
.bottom-levels {
    background: linear-gradient(180deg, rgba(255, 248, 243, 0.95) 0%, rgba(255, 245, 238, 0.95) 100%);
    padding: 4px 0;
    border-top: 3px solid rgba(255, 182, 193, 0.3);
    box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.06);
    flex-shrink: 0;
    backdrop-filter: blur(5px);
}

/* 大关卡选择 */
.big-levels-scroll {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 4px 12px;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    border-bottom: 1px solid rgba(255, 182, 193, 0.2);
}

.big-levels-scroll::-webkit-scrollbar {
    display: none;
}

.big-level-item {
    min-width: 55px;
    padding: 6px 10px;
    border: 2px solid rgba(216, 112, 147, 0.3);
    border-radius: 6px;
    background: linear-gradient(135deg, #ffffff 0%, #fff5f5 100%);
    color: #666;
    font-size: 12px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    flex-shrink: 0;
    white-space: nowrap;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
}

.big-level-item:hover {
    transform: scale(1.05);
    box-shadow: 0 3px 8px rgba(216, 112, 147, 0.3);
}

.big-level-item.active {
    background: linear-gradient(135deg, #ff69b4 0%, #ff1493 100%);
    color: white;
    border-color: #ff1493;
    box-shadow: 0 3px 8px rgba(255, 20, 147, 0.4);
}

/* 小关卡选择 */
.small-levels-scroll {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 4px 12px;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
}

.small-levels-scroll::-webkit-scrollbar {
    display: none;
}

.small-level-item {
    min-width: 32px;
    width: 32px;
    height: 32px;
    border: 2px solid rgba(216, 112, 147, 0.3);
    border-radius: 6px;
    background: linear-gradient(135deg, #ffffff 0%, #fff5f5 100%);
    color: #666;
    font-size: 13px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
}

.small-level-item:hover {
    transform: scale(1.08);
    box-shadow: 0 3px 8px rgba(216, 112, 147, 0.3);
}

.small-level-item:active {
    transform: scale(0.95);
}

.small-level-item.active {
    background: linear-gradient(135deg, #64B5F6 0%, #42A5F5 100%);
    color: white;
    border-color: #2196F3;
    box-shadow: 0 3px 8px rgba(33, 150, 243, 0.4);
}

.small-level-item.completed {
    background: linear-gradient(135deg, #81C784 0%, #66BB6A 100%);
    color: white;
    border-color: #4CAF50;
    box-shadow: 0 3px 8px rgba(76, 175, 80, 0.4);
}

/* 颜色选择面板 */
.color-panel {
    position: fixed;
    top: 70px;  /* 从65px调整为70px，留出顶部栏的空间 */
    right: 15px;
    background: rgba(255, 255, 255, 0.98);
    padding: 10px;
    border-radius: 10px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    z-index: 1000;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(0, 0, 0, 0.08);
}

.color-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 6px;
}

.color-option {
    width: 36px;
    height: 36px;
    border: 2px solid rgba(0, 0, 0, 0.1);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.color-option:hover {
    transform: scale(1.1);
    border-color: rgba(0, 0, 0, 0.3);
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.2);
}

.color-option:active {
    transform: scale(0.95);
}

.color-option.active {
    border-color: #4CAF50;
    border-width: 3px;
    box-shadow: 0 0 0 2px rgba(76, 175, 80, 0.2);
}

@keyframes failAnimation {
    0% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.5) rotate(-45deg);
    }
    50% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1.2) rotate(5deg);
    }
    100% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(1) rotate(0deg);
    }
}

/* 胜利界面 */
#winScreen {
    animation: winAnimation 0.5s ease-out;
}

#winScreen h1 {
    font-size: 64px;
    color: #f39c12;
    margin-bottom: 40px;
    text-shadow: 3px 3px 6px rgba(0, 0, 0, 0.5);
    animation: bounce 1s infinite;
}

@keyframes bounce {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-20px);
    }
}

@keyframes winAnimation {
    0% {
        opacity: 0;
        transform: scale(0.5);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

.win-buttons {
    display: flex;
    gap: 30px;
    justify-content: center;
}

.win-buttons button {
    padding: 20px 40px;
    font-size: 24px;
    font-weight: bold;
    border: none;
    border-radius: 12px;
    background: linear-gradient(145deg, #3498db, #2980b9);
    color: white;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.3);
}

.win-buttons button:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.4);
}

/* 全部通关界面 */
.all-complete-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 50%, #f093fb 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    animation: fadeIn 0.5s ease;
    overflow: hidden;
}

.all-complete-content {
    background: linear-gradient(135deg, #ffffff 0%, #f8f9ff 100%);
    padding: 60px 50px;
    border-radius: 30px;
    text-align: center;
    box-shadow: 0 40px 100px rgba(0, 0, 0, 0.4),
                0 0 0 1px rgba(255, 255, 255, 0.5) inset;
    animation: scaleIn 0.6s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    max-width: 520px;
    position: relative;
    border: 3px solid rgba(255, 255, 255, 0.8);
}

@keyframes scaleIn {
    0% {
        opacity: 0;
        transform: scale(0.5) rotate(-5deg);
    }
    100% {
        opacity: 1;
        transform: scale(1) rotate(0deg);
    }
}

/* 烟花效果 */
.fireworks {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    overflow: hidden;
}

.firework {
    position: absolute;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    animation: fireworkAnimation 1.5s ease-out infinite;
}

.firework:nth-child(1) {
    top: 20%;
    left: 20%;
    background: #ff6b6b;
    animation-delay: 0s;
}

.firework:nth-child(2) {
    top: 30%;
    right: 20%;
    background: #4ecdc4;
    animation-delay: 0.5s;
}

.firework:nth-child(3) {
    bottom: 30%;
    left: 50%;
    background: #ffe66d;
    animation-delay: 1s;
}

@keyframes fireworkAnimation {
    0% {
        transform: scale(0) translateY(0);
        opacity: 1;
        box-shadow: 0 0 0 0 currentColor,
                    0 0 0 0 currentColor,
                    0 0 0 0 currentColor,
                    0 0 0 0 currentColor;
    }
    50% {
        opacity: 1;
    }
    100% {
        transform: scale(1) translateY(-20px);
        opacity: 0;
        box-shadow: -30px -30px 0 3px currentColor,
                    30px -30px 0 3px currentColor,
                    -30px 30px 0 3px currentColor,
                    30px 30px 0 3px currentColor;
    }
}

/* 奖杯图标 */
.trophy-icon {
    font-size: 90px;
    margin-bottom: 20px;
    animation: trophyBounce 1.2s ease-in-out infinite;
    filter: drop-shadow(0 8px 16px rgba(0, 0, 0, 0.15));
}

@keyframes trophyBounce {
    0%, 100% {
        transform: translateY(0) scale(1);
    }
    50% {
        transform: translateY(-15px) scale(1.1);
    }
}

/* 标题 */
.complete-title {
    font-size: 52px;
    font-weight: 900;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin: 0 0 15px 0;
    letter-spacing: 3px;
    text-shadow: 0 2px 10px rgba(102, 126, 234, 0.3);
    animation: titleShine 2s ease-in-out infinite;
}

@keyframes titleShine {
    0%, 100% {
        filter: brightness(1);
    }
    50% {
        filter: brightness(1.2);
    }
}

/* 描述 */
.complete-desc {
    font-size: 18px;
    color: #7c7c7c;
    margin: 0 0 35px 0;
    font-weight: 500;
}

/* 成就盒子 */
.achievement-box {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 30px;
    margin: 0 0 30px 0;
    padding: 25px 35px;
    background: linear-gradient(135deg, #f093fb15 0%, #667eea15 100%);
    border-radius: 20px;
    border: 2px solid rgba(102, 126, 234, 0.2);
}

.achievement-item {
    text-align: center;
}

.achievement-number {
    font-size: 44px;
    font-weight: 900;
    background: linear-gradient(135deg, #f093fb 0%, #667eea 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 5px;
    line-height: 1;
}

.achievement-label {
    font-size: 14px;
    color: #999;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.divider {
    width: 2px;
    height: 50px;
    background: linear-gradient(to bottom, transparent, #667eea, transparent);
}

/* 星星 */
.stars {
    margin-bottom: 35px;
    display: flex;
    gap: 15px;
    justify-content: center;
}

.star {
    font-size: 40px;
    display: inline-block;
    animation: starPulse 1.5s ease-in-out infinite;
    filter: drop-shadow(0 0 10px rgba(255, 215, 0, 0.5));
}

.star:nth-child(1) {
    animation-delay: 0s;
}

.star:nth-child(2) {
    animation-delay: 0.2s;
}

.star:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes starPulse {
    0%, 100% {
        transform: scale(1) rotate(0deg);
        opacity: 0.9;
    }
    50% {
        transform: scale(1.3) rotate(10deg);
        opacity: 1;
    }
}

/* 重新挑战按钮 */
.fancy-restart-btn {
    position: relative;
    padding: 18px 45px;
    font-size: 20px;
    font-weight: 700;
    border: none;
    border-radius: 50px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 10px 30px rgba(102, 126, 234, 0.4),
                0 0 0 0 rgba(102, 126, 234, 0.5);
    overflow: hidden;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    letter-spacing: 1px;
}

.fancy-restart-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    transition: left 0.5s ease;
}

.fancy-restart-btn:hover::before {
    left: 100%;
}

.fancy-restart-btn:hover {
    transform: translateY(-3px) scale(1.05);
    box-shadow: 0 15px 40px rgba(102, 126, 234, 0.6),
                0 0 0 8px rgba(102, 126, 234, 0.1);
}

.fancy-restart-btn:active {
    transform: translateY(-1px) scale(1.02);
}

.btn-icon {
    font-size: 22px;
    animation: rotateIcon 2s linear infinite;
}

@keyframes rotateIcon {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}

.btn-text {
    font-weight: 700;
}
