* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Arial', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    color: #333;
}

#game-container {
    width: 100%;
    max-width: 800px;
    height: 100vh;
    max-height: 800px;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    position: relative;
}

.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    padding: 20px;
    display: none;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    overflow-y: auto;
    transition: all 0.3s ease;
}

/* 为开始界面添加额外的间距 */
#start-screen {
    justify-content: flex-start;
    padding-top: 40px;
}

/* 调整开始界面元素间距 */
#start-screen h1 {
    margin: 20px 0;
}

.player-info,
.difficulty-selector,
.start-buttons {
    margin-bottom: 25px;
    width: 100%;
    max-width: 300px;
}

.screen.active {
    display: flex;
}

/* 开始界面样式 */
#start-screen h1 {
    font-size: 3rem;
    margin-bottom: 2rem;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.player-info {
    text-align: center;
    margin-bottom: 2rem;
}

.player-info h2 {
    margin-bottom: 1rem;
    font-size: 1.5rem;
    color: #555;
}

#player-name {
    padding: 12px 20px;
    font-size: 1.1rem;
    border: 2px solid #667eea;
    border-radius: 25px;
    outline: none;
    transition: all 0.3s ease;
    width: 250px;
    text-align: center;
}

#player-name:focus {
    border-color: #764ba2;
    box-shadow: 0 0 10px rgba(102, 126, 234, 0.3);
}

.difficulty-selector {
    text-align: center;
    margin-bottom: 2rem;
}

.difficulty-selector h2 {
    margin-bottom: 1.5rem;
    font-size: 1.5rem;
    color: #555;
}

.difficulty-btn {
    display: block;
    margin: 10px auto;
    padding: 15px 30px;
    font-size: 1.1rem;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 25px;
    cursor: pointer;
    transition: all 0.3s ease;
    width: 200px;
}

.difficulty-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(102, 126, 234, 0.4);
}

.difficulty-btn:active {
    transform: translateY(0);
}

.language-selector {
    margin-bottom: 25px;
    width: 100%;
    max-width: 300px;
    text-align: center;
}

.language-selector h2 {
    margin-bottom: 1rem;
    font-size: 1.5rem;
    color: #555;
}

.language-btn {
    display: inline-block;
    margin: 0 10px;
    padding: 12px 24px;
    font-size: 1rem;
    background: linear-gradient(135deg, #FFA000 0%, #FF6F00 100%);
    color: white;
    border: none;
    border-radius: 25px;
    cursor: pointer;
    transition: all 0.3s ease;
    width: 100px;
}

.language-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 15px rgba(255, 160, 0, 0.4);
}

.language-btn:active {
    transform: translateY(0);
}

.start-buttons {
    text-align: center;
}

#leaderboard-btn {
    padding: 12px 24px;
    font-size: 1rem;
    background: linear-gradient(135deg, #4CAF50 0%, #45a049 100%);
    color: white;
    border: none;
    border-radius: 25px;
    cursor: pointer;
    transition: all 0.3s ease;
    width: 200px;
}

#leaderboard-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(76, 175, 80, 0.4);
}

/* 排行榜界面样式 */
#leaderboard-screen h1 {
    font-size: 2.5rem;
    margin-bottom: 2rem;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.leaderboard-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 2rem;
    flex-wrap: wrap;
    justify-content: center;
}

.tab-btn {
    padding: 10px 20px;
    font-size: 1rem;
    background: #f0f0f0;
    color: #555;
    border: none;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.tab-btn.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    box-shadow: 0 2px 10px rgba(102, 126, 234, 0.3);
}

.tab-btn:hover {
    background: linear-gradient(135deg, #5a6fd8 0%, #6a4093 100%);
    color: white;
    transform: translateY(-1px);
}

#leaderboard-content {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
    max-width: 500px;
    width: 100%;
    margin-bottom: 2rem;
    max-height: 400px;
    overflow-y: auto;
}

.leaderboard-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 15px;
    margin: 8px 0;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
    transition: all 0.2s ease;
}

.leaderboard-item:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.leaderboard-rank {
    font-weight: bold;
    color: #667eea;
    font-size: 1.2rem;
    min-width: 30px;
}

.leaderboard-name {
    flex: 1;
    margin: 0 15px;
    font-weight: 500;
}

.leaderboard-score {
    display: flex;
    gap: 15px;
    font-weight: bold;
    color: #333;
}

.leaderboard-time {
    color: #4CAF50;
}

.leaderboard-steps {
    color: #f44336;
}

.leaderboard-difficulty {
    font-size: 0.9rem;
    color: #777;
    background: #f0f0f0;
    padding: 3px 8px;
    border-radius: 10px;
}

.leaderboard-buttons {
    margin-top: 2rem;
}

#back-to-menu-btn {
    padding: 12px 24px;
    font-size: 1.1rem;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 25px;
    cursor: pointer;
    transition: all 0.3s ease;
}

#back-to-menu-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(102, 126, 234, 0.4);
}

/* 游戏界面样式 */
#game-screen {
    padding: 10px;
}

.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 20px;
    background: #f8f9fa;
    border-radius: 10px;
    margin-bottom: 10px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.stats {
    display: flex;
    gap: 20px;
    font-size: 1.1rem;
    font-weight: bold;
    color: #555;
}

#pause-btn {
    padding: 8px 16px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1rem;
    transition: all 0.3s ease;
}

#pause-btn:hover {
    background: #5a6fd8;
    transform: translateY(-1px);
}

#maze-container {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    background: #f0f0f0;
    border-radius: 10px;
    overflow: auto;
    position: relative;
    padding: 10px;
}

/* 迷宫样式 */
.maze {
    display: grid;
    gap: 1px;
    background: #ccc;
    padding: 10px;
    border-radius: 5px;
    max-width: 100%;
    max-height: 100%;
    width: 100%;
    height: 100%;
}

.cell {
    width: auto;
    height: auto;
    aspect-ratio: 1;
    background: white;
    position: relative;
    transition: all 0.2s ease;
}

/* 根据难度调整单元格大小 */
.maze[data-difficulty="easy"] .cell {
    min-width: 30px;
    min-height: 30px;
}

.maze[data-difficulty="medium"] .cell {
    min-width: 25px;
    min-height: 25px;
}

.maze[data-difficulty="hard"] .cell {
    min-width: 22px;
    min-height: 22px;
}

.maze[data-difficulty="expert"] .cell {
    min-width: 18px;
    min-height: 18px;
}

.cell.wall {
    background: linear-gradient(135deg, #333 0%, #555 100%);
    box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.5);
}

.cell.start {
    background: linear-gradient(135deg, #4CAF50 0%, #45a049 100%);
}

.cell.end {
    background: linear-gradient(135deg, #f44336 0%, #da190b 100%);
}

.cell.start::after {
    content: '🚩';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 1.2rem;
}

.cell.end::after {
    content: '🏁';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 1.2rem;
}

/* 角色样式 */
.player {
    position: absolute;
    width: 20px;
    height: 20px;
    background: linear-gradient(135deg, #ff6b6b 0%, #ee5a24 100%);
    border-radius: 50%;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    box-shadow: 0 2px 10px rgba(255, 107, 107, 0.6);
    transition: all 0.1s ease;
    z-index: 10;
}

.player.moving {
    animation: bounce 0.3s ease;
}

@keyframes bounce {
    0%, 100% { transform: translate(-50%, -50%) scale(1); }
    50% { transform: translate(-50%, -50%) scale(1.2); }
}

/* 结束界面样式 */
#end-screen h1 {
    font-size: 2.5rem;
    margin-bottom: 2rem;
    color: #4CAF50;
}

.end-stats {
    background: #f8f9fa;
    padding: 20px 40px;
    border-radius: 10px;
    margin-bottom: 2rem;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.end-stats p {
    font-size: 1.2rem;
    margin: 10px 0;
    color: #555;
}

.end-stats span {
    font-weight: bold;
    color: #333;
}

.end-buttons {
    display: flex;
    gap: 20px;
}

#restart-btn, #menu-btn {
    padding: 12px 24px;
    font-size: 1.1rem;
    border: none;
    border-radius: 25px;
    cursor: pointer;
    transition: all 0.3s ease;
    color: white;
}

#restart-btn {
    background: linear-gradient(135deg, #4CAF50 0%, #45a049 100%);
}

#menu-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

#restart-btn:hover, #menu-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2);
}

/* 暂停界面样式 */
#pause-screen h1 {
    font-size: 2.5rem;
    margin-bottom: 2rem;
    color: #667eea;
}

.pause-buttons {
    display: flex;
    gap: 20px;
}

#resume-btn, #quit-btn {
    padding: 12px 24px;
    font-size: 1.1rem;
    border: none;
    border-radius: 25px;
    cursor: pointer;
    transition: all 0.3s ease;
    color: white;
}

#resume-btn {
    background: linear-gradient(135deg, #4CAF50 0%, #45a049 100%);
}

#quit-btn {
    background: linear-gradient(135deg, #f44336 0%, #da190b 100%);
}

#resume-btn:hover, #quit-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2);
}

/* 响应式设计 */
@media (max-width: 768px) {
    #game-container {
        max-width: 100vw;
        max-height: 100vh;
        border-radius: 0;
    }

    #start-screen h1 {
        font-size: 2rem;
    }

    .difficulty-btn {
        width: 180px;
        padding: 12px 24px;
        font-size: 1rem;
    }

    .cell {
        width: 25px;
        height: 25px;
    }

    .stats {
        font-size: 1rem;
        gap: 10px;
    }

    .game-header {
        padding: 8px 15px;
    }
}

@media (max-width: 480px) {
    .cell {
        width: 20px;
        height: 20px;
    }

    .game-header {
        flex-direction: column;
        gap: 10px;
        padding: 10px;
    }

    .stats {
        justify-content: center;
    }

    #start-screen h1 {
        font-size: 1.8rem;
    }
}

/* 触摸控制样式 */
.touch-controls {
    display: none;
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    gap: 10px;
    width: 200px;
    height: 200px;
    padding: 10px;
    background: rgba(255, 255, 255, 0.8);
    border-radius: 20px;
    backdrop-filter: blur(10px);
}

.touch-btn {
    background: rgba(102, 126, 234, 0.8);
    border: none;
    border-radius: 50%;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    justify-content: center;
    align-items: center;
    width: 60px;
    height: 60px;
}

.touch-btn:hover, .touch-btn:active {
    background: rgba(102, 126, 234, 1);
    transform: scale(1.1);
}

.touch-btn.up {
    grid-column: 2;
    grid-row: 1;
}

.touch-btn.left {
    grid-column: 1;
    grid-row: 2;
}

.touch-btn.down {
    grid-column: 2;
    grid-row: 3;
}

.touch-btn.right {
    grid-column: 3;
    grid-row: 2;
}

/* 在小屏幕上显示触摸控制 */
@media (max-width: 768px) {
    .touch-controls {
        display: grid;
    }
}