/* 全局样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background-color: #2c3e50;
    font-family: Arial, sans-serif;
    touch-action: none; /* 防止移动端默认的触摸行为 */
}

/* 通用屏幕样式 */
.screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1a1c20 0%, #2d3436 100%);
    z-index: 1000;
}

.hidden {
    display: none !important;
}

/* 按钮样式 */
button {
    background: linear-gradient(45deg, #ff6b6b, #ff8e8e);
    border: none;
    border-radius: 25px;
    color: white;
    padding: 15px 30px;
    font-size: 18px;
    margin: 10px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 4px 15px rgba(255, 107, 107, 0.3);
}

button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(255, 107, 107, 0.4);
}

button:active {
    transform: translateY(1px);
}

button.back-button {
    background: linear-gradient(45deg, #6c757d, #495057);
    box-shadow: 0 4px 15px rgba(108, 117, 125, 0.3);
}

/* 标题样式 */
h1, h2 {
    color: #ffffff;
    text-align: center;
    margin-bottom: 30px;
    text-shadow: 0 2px 10px rgba(255, 255, 255, 0.2);
}

h1 {
    font-size: 48px;
    margin-bottom: 50px;
}

h2 {
    font-size: 36px;
}

/* 游戏界面样式 */
#gameUI {
    background: none;
    padding: 0;
    overflow: hidden;
}

.game-container {
    width: 100%;
    max-width: 800px;
    padding: 20px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 15px;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.3);
}

.game-header {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-bottom: 20px;
}

.game-info {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 12px;
    padding: 15px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 10px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.game-info span {
    display: flex;
    align-items: center;
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    color: #fff;
    font-size: 16px;
    white-space: nowrap;
}

.game-info span span {
    background: none;
    padding: 0 0 0 5px;
    color: #FFD700;
    font-weight: bold;
    font-size: 18px;
}

.game-controls {
    display: flex;
    justify-content: center;
    gap: 12px;
    padding: 10px;
}

.game-controls button {
    margin: 0 5px;
    padding: 8px 16px;
    font-size: 16px;
    border: none;
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    cursor: pointer;
    transition: all 0.3s ease;
}

.game-controls button:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.05);
}

.game-controls button:active {
    transform: scale(0.95);
}

#toggleMusicButton {
    display: flex;
    align-items: center;
    gap: 5px;
    background: rgba(138, 43, 226, 0.4);
}

#toggleMusicButton.muted {
    background: rgba(169, 169, 169, 0.4);
}

.canvas-container {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-top: 20px;
}

#gameCanvas {
    max-width: 100%;
    height: auto;
    border-radius: 10px;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.3);
}

/* 关卡选择网格 */
#levelGrid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 10px;
    max-width: 500px;
    width: 100%;
    padding: 20px;
}

.level-button {
    background: linear-gradient(45deg, #4CAF50, #45a049);
    color: white;
    border: none;
    border-radius: 10px;
    padding: 20px;
    font-size: 24px;
    cursor: pointer;
    text-align: center;
    transition: transform 0.2s;
}

.level-button:hover {
    transform: scale(1.05);
}

.level-button.locked {
    background: linear-gradient(45deg, #6c757d, #495057);
    cursor: not-allowed;
    opacity: 0.7;
}

/* 设置菜单样式 */
.setting-item {
    width: 100%;
    max-width: 300px;
    margin: 20px 0;
}

.setting-item label {
    display: block;
    margin-bottom: 10px;
    font-size: 18px;
}

.setting-item input[type="range"] {
    width: 100%;
    height: 8px;
    border-radius: 4px;
    background: #ffffff;
    outline: none;
    -webkit-appearance: none;
}

.setting-item input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 20px;
    height: 20px;
    background: #ff6b6b;
    border-radius: 50%;
    cursor: pointer;
}

/* 游戏结束菜单样式 */
.game-over-info {
    text-align: center;
    margin: 20px 0;
    font-size: 24px;
}

#stars {
    color: #ffd700;
    font-size: 36px;
    text-shadow: 0 0 10px rgba(255, 215, 0, 0.5);
}

/* 音频控制样式 */
.audio-controls {
    margin-top: 20px;
    padding: 15px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.volume-control {
    display: flex;
    align-items: center;
    gap: 10px;
}

.volume-control label {
    min-width: 80px;
    color: #fff;
}

.volume-control input[type="range"] {
    flex: 1;
    height: 5px;
    -webkit-appearance: none;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 5px;
    outline: none;
}

.volume-control input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 15px;
    height: 15px;
    background: #fff;
    border-radius: 50%;
    cursor: pointer;
}

.icon-button {
    background: none;
    border: none;
    font-size: 24px;
    color: #fff;
    cursor: pointer;
    padding: 5px;
    transition: transform 0.2s;
}

.icon-button:hover {
    transform: scale(1.1);
}

/* 响应式设计 */
@media (max-width: 768px) {
    .game-info {
        font-size: 14px;
        padding: 10px;
    }

    .game-info span {
        padding: 6px 10px;
        font-size: 14px;
    }

    .game-info span span {
        font-size: 16px;
    }

    .game-controls button {
        padding: 8px 16px;
        font-size: 14px;
    }

    .canvas-container {
        padding: 10px;
    }

    #gameCanvas {
        max-height: calc(100vh - 120px);
    }

    .audio-controls {
        padding: 10px;
    }

    .volume-control {
        flex-direction: column;
        align-items: stretch;
    }

    .volume-control label {
        text-align: center;
    }
}

/* 移动端适配 */
@media (max-width: 600px) {
    .game-container {
        height: 100vh;
    }

    .game-header {
        position: relative;
    }

    .canvas-container {
        padding: 5px;
    }

    .game-info {
        font-size: 12px;
    }

    .game-info > span {
        margin: 2px 5px;
    }
}

/* 横屏模式优化 */
@media (orientation: landscape) and (max-height: 500px) {
    .game-container {
        flex-direction: row;
    }

    .game-header {
        width: 200px;
        height: 100%;
    }

    .canvas-container {
        flex: 1;
        height: 100%;
    }

    #gameCanvas {
        max-height: 100vh;
        max-width: calc(100vw - 220px);
    }
}

/* 动画效果 */
@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.screen {
    animation: fadeIn 0.3s ease-in-out;
}
