/* 重置样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Arial', sans-serif;
    background-color: #f0f2f5;
    color: #333;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
    background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
}

.container {
    max-width: 800px;
    width: 100%;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    padding: 20px;
    text-align: center;
    backdrop-filter: blur(10px);
    position: relative;
}

.game-title {
    color: #4caf50;
    margin-bottom: 20px;
    font-size: 2.5em;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
    font-weight: bold;
}

/* 游戏信息栏 */
.game-info {
    display: flex;
    justify-content: space-around;
    margin-bottom: 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 15px;
    border-radius: 10px;
    color: white;
    flex-wrap: wrap;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

.info-item {
    display: flex;
    flex-direction: column;
    margin: 0 10px;
}

.info-label {
    font-size: 0.9em;
    opacity: 0.9;
    margin-bottom: 5px;
    font-weight: normal;
}

.info-value {
    font-size: 1.8em;
    font-weight: bold;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
}

/* 游戏容器 */
.game-container {
    display: flex;
    justify-content: center;
    margin-bottom: 20px;
    background: rgba(238, 242, 247, 0.8);
    border-radius: 10px;
    padding: 15px;
    box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.1);
    overflow-x: auto;
}

/* 游戏棋盘 */
.game-board {
    display: grid;
    gap: 2px;
    background: #34495e;
    border: 3px solid #2c3e50;
    border-radius: 8px;
    padding: 10px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
}

/* 游戏格子 */
.cell {
    width: 50px;
    height: 50px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.5em;
    font-weight: bold;
    transition: all 0.2s ease;
    position: relative;
    cursor: pointer;
    border-radius: 4px;
}

/* 不同类型的格子 */
.cell.wall {
    background: linear-gradient(135deg, #7f8c8d, #95a5a6);
    box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.5);
    cursor: default;
}

.cell.floor {
    background: linear-gradient(135deg, #ecf0f1, #bdc3c7);
}

.cell.target {
    background: linear-gradient(135deg, #f39c12, #e67e22);
    animation: pulse 2s infinite;
}

/* 箱子 */
.box {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, #3498db, #2980b9);
    border: 3px solid #2c3e50;
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    transition: all 0.1s ease;
    position: absolute;
    top: 5px;
    left: 5px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 0.8em;
    color: white;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
}

.box.on-target {
    background: linear-gradient(135deg, #e74c3c, #c0392b);
    animation: boxOnTarget 1s infinite alternate;
}

/* 玩家角色 */
.player {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, #2ecc71, #27ae60);
    border-radius: 50%;
    border: 3px solid #27ae60;
    box-shadow: 0 3px 10px rgba(46, 204, 113, 0.5);
    transition: all 0.1s ease;
    position: absolute;
    top: 5px;
    left: 5px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1em;
    color: white;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
    z-index: 10;
}

.player.up {
    transform: rotate(-90deg);
}

.player.down {
    transform: rotate(90deg);
}

.player.left {
    transform: rotate(180deg);
}

.player.right {
    transform: rotate(0deg);
}

/* 控制区域 */
.control-section {
    display: flex;
    justify-content: space-around;
    align-items: center;
    gap: 30px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

/* 控制按钮 */
.control-buttons {
    display: flex;
    justify-content: center;
    gap: 15px;
    flex-wrap: wrap;
}

.btn {
    padding: 12px 24px;
    font-size: 16px;
    font-weight: bold;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 120px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.btn-primary {
    background: linear-gradient(135deg, #4caf50, #45a049);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(76, 175, 80, 0.4);
}

.btn-secondary {
    background: linear-gradient(135deg, #ff9800, #f57c00);
    color: white;
}

.btn-secondary:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(255, 152, 0, 0.4);
}

.btn-danger {
    background: linear-gradient(135deg, #f44336, #da190b);
    color: white;
}

.btn-danger:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(244, 67, 54, 0.4);
}

.btn:active {
    transform: translateY(-1px);
}

/* 方向控制按钮 */
.direction-controls {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.control-row {
    display: flex;
    gap: 8px;
}

.dir-btn {
    width: 60px;
    height: 60px;
    font-size: 20px;
    font-weight: bold;
    border: none;
    border-radius: 10px;
    background: linear-gradient(135deg, #2196f3, #1976d2);
    color: white;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 15px rgba(33, 150, 243, 0.3);
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
}

.dir-btn:hover {
    background: linear-gradient(135deg, #1976d2, #1565c0);
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(33, 150, 243, 0.4);
}

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

/* 游戏说明 */
.game-instructions {
    text-align: left;
    background: rgba(248, 249, 250, 0.8);
    padding: 20px;
    border-radius: 10px;
    border: 1px solid #e9ecef;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.1);
}

.game-instructions h3 {
    color: #4caf50;
    margin-bottom: 15px;
    font-size: 1.3em;
    text-align: center;
}

.game-instructions ul {
    list-style-type: none;
    padding-left: 0;
}

.game-instructions li {
    margin-bottom: 12px;
    padding-left: 30px;
    position: relative;
    line-height: 1.6;
    font-size: 1em;
    color: #555;
}

.game-instructions li:before {
    content: "▶";
    color: #4caf50;
    font-weight: bold;
    position: absolute;
    left: 0;
    font-size: 1.2em;
    line-height: 1;
}

/* 模态框 */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    backdrop-filter: blur(5px);
    overflow-y: auto;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: white;
    padding: 30px;
    border-radius: 15px;
    text-align: center;
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.3);
    max-width: 500px;
    width: 90%;
    margin: 20px;
}

.modal-content h2 {
    color: #4caf50;
    margin-bottom: 20px;
    font-size: 2em;
}

.modal-content p {
    margin-bottom: 15px;
    font-size: 1.2em;
    color: #555;
}

/* 关卡列表 */
.level-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
    gap: 10px;
    margin: 20px 0;
    max-height: 400px;
    overflow-y: auto;
    padding: 10px;
    background: #f8f9fa;
    border-radius: 8px;
}

.level-item {
    width: 60px;
    height: 60px;
    display: flex;
    justify-content: center;
    align-items: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    font-weight: bold;
    font-size: 1.2em;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

.level-item:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 10px rgba(102, 126, 234, 0.4);
}

.level-item.current {
    background: linear-gradient(135deg, #4caf50, #45a049);
    box-shadow: 0 4px 15px rgba(76, 175, 80, 0.5);
}

/* 胜利按钮组 */
.win-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin-top: 20px;
    flex-wrap: wrap;
}

/* 动画效果 */
@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.8;
    }
}

@keyframes boxOnTarget {
    0% {
        transform: scale(1);
    }
    100% {
        transform: scale(1.05);
    }
}

/* 响应式设计 */
@media (max-width: 768px) {
    .container {
        padding: 15px;
    }
    
    .game-title {
        font-size: 2em;
    }
    
    .cell {
        width: 40px;
        height: 40px;
    }
    
    .box,
    .player {
        width: 32px;
        height: 32px;
        top: 4px;
        left: 4px;
        font-size: 0.7em;
    }
    
    .control-section {
        flex-direction: column;
        gap: 20px;
    }
    
    .game-info {
        flex-direction: column;
        gap: 10px;
    }
    
    .info-item {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        width: 100%;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 10px;
    }
    
    .game-title {
        font-size: 1.8em;
    }
    
    .cell {
        width: 35px;
        height: 35px;
    }
    
    .box,
    .player {
        width: 28px;
        height: 28px;
        top: 3.5px;
        left: 3.5px;
    }
    
    .btn {
        padding: 10px 18px;
        font-size: 14px;
        min-width: 100px;
    }
    
    .dir-btn {
        width: 50px;
        height: 50px;
        font-size: 18px;
    }
    
    .game-instructions {
        padding: 15px;
    }
    
    .game-instructions li {
        padding-left: 25px;
        font-size: 0.9em;
    }
    
    .modal-content {
        padding: 20px;
    }
    
    .level-item {
        width: 50px;
        height: 50px;
        font-size: 1em;
    }
}

/* 滚动条样式 */
.level-list::-webkit-scrollbar {
    width: 8px;
}

.level-list::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.level-list::-webkit-scrollbar-thumb {
    background: #667eea;
    border-radius: 4px;
}

.level-list::-webkit-scrollbar-thumb:hover {
    background: #764ba2;
}