* {
    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;
    padding: 20px;
}

.container {
    background: white;
    border-radius: 15px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    padding: 30px;
    max-width: 900px;
    width: 100%;
}

.header {
    text-align: center;
    margin-bottom: 30px;
}

.header h1 {
    color: #333;
    margin-bottom: 10px;
    font-size: 2em;
}

.instruction {
    color: #666;
    font-size: 0.95em;
    line-height: 1.6;
    margin-bottom: 15px;
}

.game-area {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 30px;
    margin-bottom: 30px;
    background: #f5f5f5;
    padding: 20px;
    border-radius: 10px;
    overflow: hidden;
    flex-wrap: wrap;
}

.maze-container {
    display: grid;
    gap: 0;
    background: #333;
    padding: 0;
    border-radius: 5px;
    width: 465px;
    height: 465px;
    overflow: hidden;
    position: relative;
}

.maze-cell {
    position: relative;
    background: white;
    border: none;
}

.maze-cell.wall {
    background: #333;
}

.maze-cell.path {
    background: #f9f9f9;
}

.maze-cell.player {
    background: #f9f9f9 !important;
    position: relative;
}

.maze-cell.player::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 70%;
    height: 70%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 50%;
}

.maze-cell.food {
    background: #f9f9f9 !important;
    position: relative;
}

.maze-cell.food::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 70%;
    height: 70%;
    background: #ff6b6b;
    border-radius: 50%;
    box-shadow: inset 0 0 3px rgba(0, 0, 0, 0.2);
}

.controls {
    text-align: center;
    margin-bottom: 25px;
    padding: 20px;
    background: #f9f9f9;
    border-radius: 10px;
}

.control-info {
    color: #666;
    margin-bottom: 15px;
    font-size: 0.9em;
}

/* 虛擬方向鍵控制 */
.virtual-controls {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 15px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.btn-row {
    display: flex;
    gap: 10px;
}

.btn-arrow {
    width: 50px;
    height: 50px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 50%;
    font-size: 1.2em;
    cursor: pointer;
    transition: all 0.1s;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    user-select: none;
    touch-action: manipulation;
}

.btn-arrow:hover {
    transform: scale(1.1);
    box-shadow: 0 3px 10px rgba(102, 126, 234, 0.3);
}

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

.btn-up {
    margin-bottom: 10px;
}

.btn-left {
    margin-right: 10px;
}

.btn-right {
    margin-left: 10px;
}

.btn-new-game {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 12px 30px;
    font-size: 1em;
    border-radius: 25px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    font-weight: bold;
}

.btn-new-game:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 20px rgba(102, 126, 234, 0.4);
}

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

.stats {
    background: #f0f0f0;
    padding: 20px;
    border-radius: 10px;
}

.stats h2 {
    color: #333;
    font-size: 1.2em;
    margin-bottom: 15px;
}

.time-records {
    background: white;
    padding: 15px;
    border-radius: 8px;
    min-height: 60px;
    color: #666;
    font-size: 0.95em;
    line-height: 1.8;
    white-space: pre-wrap;
    font-family: 'Courier New', monospace;
}

.time-records p {
    color: #999;
}

.time-record-item {
    color: #333;
    padding: 5px 0;
}

.time-record-item .number {
    color: #667eea;
    font-weight: bold;
}

.time-record-item .time {
    color: #764ba2;
    font-weight: bold;
}

/* 響應式設計 */
@media (max-width: 600px) {
    .container {
        padding: 15px;
    }

    .header h1 {
        font-size: 1.5em;
    }

    .instruction {
        font-size: 0.85em;
    }

    .game-area {
        flex-direction: column;
        gap: 20px;
    }

    .maze-container {
        width: 372px;
        height: 372px;
    }

    .btn-arrow {
        width: 45px;
        height: 45px;
        font-size: 1em;
    }
}

@media (max-width: 500px) {
    .maze-container {
        width: 310px;
        height: 310px;
    }

    .btn-arrow {
        width: 40px;
        height: 40px;
        font-size: 0.9em;
    }

    .control-info {
        font-size: 0.8em;
    }
}
