* {
    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;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding: 20px 0;
}

.container {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
}

.game-container {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    padding: 20px;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.1);
    text-align: center;
    max-width: 600px;
    width: 100%;
}

header h1 {
    color: #333;
    margin-bottom: 15px;
    font-size: 2.5em;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
}

.game-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding: 10px 20px;
    background: #f8f9fa;
    border-radius: 10px;
}

.level-info span {
    margin-right: 20px;
    font-weight: bold;
    color: #495057;
}

#timer {
    color: #dc3545;
    font-size: 1.2em;
}

#key-status {
    font-weight: bold;
    padding: 5px 10px;
    border-radius: 5px;
    background: #ffc107;
    color: #333;
}

#key-status.collected {
    background: #28a745;
    color: white;
}

/* Grid Styles */
.grid {
    display: grid;
    gap: 2px;
    margin: 20px auto;
    padding: 10px;
    background: #dee2e6;
    border-radius: 10px;
    box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.1);
}

.grid.size-5 {
    grid-template-columns: repeat(5, 60px);
    grid-template-rows: repeat(5, 60px);
}

.grid.size-7 {
    grid-template-columns: repeat(7, 50px);
    grid-template-rows: repeat(7, 50px);
}

.grid.size-10 {
    grid-template-columns: repeat(10, 40px);
    grid-template-rows: repeat(10, 40px);
}

.cell {
    background: white;
    border: 1px solid #ced4da;
    border-radius: 4px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.5em;
    transition: all 0.3s ease;
    cursor: pointer;
    position: relative;
}

.cell:hover {
    background: #f8f9fa;
}

.cell.visited {
    background: #343a40;
    color: white;
}

.cell.player {
    background: #007bff;
    color: white;
}

.cell.key {
    background: #ffc107;
}

.cell.door {
    background: #28a745;
}

/* Wall styles - walls are between cells */
.cell {
    position: relative;
}

.cell.wall-top::before {
    content: '';
    position: absolute;
    top: -2px;
    left: 0;
    right: 0;
    height: 4px;
    background: #dc3545;
    z-index: 10;
    animation: wallBlink 1s ease-in-out;
}

.cell.wall-right::after {
    content: '';
    position: absolute;
    top: 0;
    right: -2px;
    bottom: 0;
    width: 4px;
    background: #dc3545;
    z-index: 10;
    animation: wallBlink 1s ease-in-out;
}

.cell.wall-bottom::before {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    right: 0;
    height: 4px;
    background: #dc3545;
    z-index: 10;
    animation: wallBlink 1s ease-in-out;
}

.cell.wall-left::after {
    content: '';
    position: absolute;
    top: 0;
    left: -2px;
    bottom: 0;
    width: 4px;
    background: #dc3545;
    z-index: 10;
    animation: wallBlink 1s ease-in-out;
}

@keyframes wallBlink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

/* Visible walls when "View Walls" is active */
.cell.show-wall-top::before {
    content: '';
    position: absolute;
    top: -2px;
    left: 0;
    right: 0;
    height: 4px;
    background: rgba(220, 53, 69, 0.6);
    z-index: 10;
}

.cell.show-wall-right::after {
    content: '';
    position: absolute;
    top: 0;
    right: -2px;
    bottom: 0;
    width: 4px;
    background: rgba(220, 53, 69, 0.6);
    z-index: 10;
}

.cell.show-wall-bottom::before {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    right: 0;
    height: 4px;
    background: rgba(220, 53, 69, 0.6);
    z-index: 10;
}

.cell.show-wall-left::after {
    content: '';
    position: absolute;
    top: 0;
    left: -2px;
    bottom: 0;
    width: 4px;
    background: rgba(220, 53, 69, 0.6);
    z-index: 10;
}

/* Controls */
.controls {
    margin-top: 20px;
}

.arrow-buttons {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    margin-bottom: 20px;
}

.horizontal-arrows {
    display: flex;
    gap: 20px;
    align-items: center;
}

.arrow-btn {
    background: #007bff;
    color: white;
    border: none;
    border-radius: 10px;
    width: 60px;
    height: 60px;
    font-size: 1.5em;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 8px rgba(0, 123, 255, 0.3);
}

.arrow-btn:hover {
    background: #0056b3;
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0, 123, 255, 0.4);
}

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

.arrow-btn:disabled {
    background: #6c757d;
    cursor: not-allowed;
    transform: none;
}

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

.control-btn {
    background: #6c757d;
    color: white;
    border: none;
    border-radius: 8px;
    padding: 10px 20px;
    font-size: 1em;
    cursor: pointer;
    transition: all 0.3s ease;
}

.control-btn:hover {
    background: #5a6268;
    transform: translateY(-1px);
}

#view-walls-btn {
    background: #28a745;
}

#view-walls-btn:hover {
    background: #218838;
}

/* Message Overlay */
.message-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    transition: opacity 0.3s ease;
}

.message-overlay.hidden {
    display: none;
}

.message-content {
    background: white;
    padding: 30px;
    border-radius: 15px;
    text-align: center;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.3);
    max-width: 400px;
    width: 90%;
}

.message-content h2 {
    margin-bottom: 15px;
    color: #333;
    font-size: 2em;
}

.message-content p {
    margin-bottom: 20px;
    color: #666;
    font-size: 1.1em;
}

/* Instructions */
.instructions {
    margin-top: 20px;
    padding: 15px;
    background: #e9ecef;
    border-radius: 10px;
    text-align: left;
}

.instructions h3 {
    margin-bottom: 10px;
    color: #495057;
}

.instructions ul {
    list-style-position: inside;
}

.instructions li {
    margin-bottom: 5px;
    color: #6c757d;
}

/* Responsive Design */
@media (max-width: 768px) {
    .game-container {
        margin: 10px;
        padding: 15px;
    }
    
    header h1 {
        font-size: 2em;
    }
    
    .game-info {
        flex-direction: column;
        gap: 10px;
    }
    
    .grid.size-5 {
        grid-template-columns: repeat(5, 50px);
        grid-template-rows: repeat(5, 50px);
    }
    
    .grid.size-7 {
        grid-template-columns: repeat(7, 40px);
        grid-template-rows: repeat(7, 40px);
    }
    
    .grid.size-10 {
        grid-template-columns: repeat(10, 30px);
        grid-template-rows: repeat(10, 30px);
    }
    
    .arrow-btn {
        width: 50px;
        height: 50px;
        font-size: 1.2em;
    }
}

/* Animation for level transitions */
@keyframes fadeIn {
    from { opacity: 0; transform: scale(0.9); }
    to { opacity: 1; transform: scale(1); }
}

.grid {
    animation: fadeIn 0.5s ease-in-out;
}

/* Sound effect indicator */
.sound-effect {
    position: absolute;
    top: -20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.8em;
    pointer-events: none;
    animation: soundPop 1s ease-out forwards;
}

@keyframes soundPop {
    0% { opacity: 0; transform: translateX(-50%) translateY(10px); }
    20% { opacity: 1; transform: translateX(-50%) translateY(-10px); }
    100% { opacity: 0; transform: translateX(-50%) translateY(-30px); }
}

/* Copyright Footer */
.copyright {
    text-align: center;
    padding: 15px;
    color: rgba(255, 255, 255, 0.8);
    font-size: 0.9em;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    backdrop-filter: blur(10px);
    margin-top: auto;
    width: 100%;
    max-width: 600px;
}