* {
    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-buttons {
    display: flex;
    justify-content: flex-end;
    padding: 10px 15px;
    position: absolute;
    top: 0;
    right: 0;
    z-index: 10;
}

.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;
}

/* 过关弹窗 */
.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, #667eea 0%, #764ba2 100%);
    padding: 50px 60px;
    border-radius: 20px;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: bounceIn 0.5s ease;
}

.win-content h1 {
    font-size: 48px;
    color: #fff;
    margin: 0 0 15px 0;
    font-weight: bold;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
    letter-spacing: 3px;
}

.win-subtitle {
    font-size: 18px;
    color: rgba(255, 255, 255, 0.9);
    margin: 0;
}

@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);
    }
}

/* 底部关卡选择 */
.bottom-levels {
    background: rgba(255, 255, 255, 0.6);
    padding: 5px 0;
    border-top: 2px solid rgba(0, 0, 0, 0.1);
    flex-shrink: 0;
}

.levels-scroll {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 5px 10px;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
}

.levels-scroll::-webkit-scrollbar {
    display: none;
}

.level-item {
    min-width: 32px;
    width: 32px;
    height: 32px;
    border: 1.5px solid #999;
    border-radius: 5px;
    background: #fff;
    color: #333;
    font-size: 12px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.level-item:hover {
    transform: scale(1.05);
}

.level-item:active {
    transform: scale(0.95);
}

.level-item.active {
    background: #4CAF50;
    color: white;
    border-color: #4CAF50;
}

.level-item.completed {
    background: #2196F3;
    color: white;
    border-color: #2196F3;
}

/* 颜色选择面板 */
.color-panel {
    position: fixed;
    top: 65px;
    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);
}
