* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Comic Sans MS', cursive, sans-serif;
    background: linear-gradient(135deg, #ff9a9e 0%, #fecfef 50%, #fecfef 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

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

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

.game-info {
    display: grid;
    grid-template-columns: auto auto;
    grid-template-rows: auto auto;
    gap: 10px;
    margin-bottom: 30px;
    padding: 15px;
    background: linear-gradient(45deg, #ffeaa7, #fdcb6e);
    border-radius: 20px;
    align-items: center;
}

.level-status {
    font-size: 1.4em;
    font-weight: bold;
    color: #6c5ce7;
    background: rgba(255, 255, 255, 0.3);
    padding: 5px 15px;
    border-radius: 15px;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.1);
}

.flag-status {
    font-size: 1.3em;
    font-weight: bold;
    color: #2d3436;
    justify-self: end;
}

#flag-count {
    color: #e17055;
    font-weight: bold;
}

.message {
    grid-column: 1 / -1;
    text-align: center;
    font-size: 1.1em;
    color: #636e72;
    font-weight: 500;
}


.maze-container {
    margin: 30px 0;
    padding: 20px;
    background: linear-gradient(45deg, #a8e6cf, #88d8c0);
    border-radius: 20px;
    overflow: hidden;
}

.maze {
    display: grid;
    gap: 2px;
    background: #2d3436;
    padding: 10px;
    border-radius: 10px;
    margin: 0 auto;
    width: fit-content;
}

.maze-cell {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8em;
    transition: all 0.3s ease;
    border-radius: 4px;
    position: relative;
}

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

.maze-cell.wall {
    background: #2d3436;
}

.maze-cell.start {
    background: #00b894;
    border: 3px solid #00a085;
}

.maze-cell.flag {
    background: #fdcb6e;
    border: 3px solid #f39c12;
    animation: flagWave 2s infinite ease-in-out;
}

.maze-cell.flag.collected {
    background: #ddd;
    opacity: 0.5;
    border-color: #bbb;
    animation: none;
}

.maze-cell.end {
    background: #fd79a8;
    border: 3px solid #e84393;
    animation: goalGlow 2s infinite ease-in-out;
}

.maze-cell.player {
    background: #55efc4;
    border: 3px solid #00b894;
    animation: playerBounce 1s infinite ease-in-out;
    z-index: 10;
}

@keyframes flagWave {
    0%, 100% { transform: scale(1) rotate(0deg); }
    50% { transform: scale(1.1) rotate(5deg); }
}

@keyframes goalGlow {
    0%, 100% { box-shadow: 0 0 10px rgba(253, 121, 168, 0.5); }
    50% { box-shadow: 0 0 20px rgba(253, 121, 168, 0.8); }
}

@keyframes playerBounce {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

.controls {
    margin-top: 20px;
}

.control-info {
    margin-bottom: 20px;
    padding: 15px;
    background: rgba(255, 255, 255, 0.8);
    border-radius: 15px;
    border: 2px solid #ddd;
}

.control-info p {
    margin: 5px 0;
    color: #2d3436;
    font-weight: 500;
}

.btn {
    font-family: 'Comic Sans MS', cursive, sans-serif;
    font-size: 1.2em;
    font-weight: bold;
    padding: 12px 25px;
    border: none;
    border-radius: 25px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
    margin: 5px;
}

.restart-btn {
    background: linear-gradient(45deg, #fd79a8, #fdcb6e);
    color: white;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
}

.restart-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
}

.winner-display {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.winner-content {
    background: white;
    padding: 50px;
    border-radius: 30px;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: bounceIn 0.8s ease;
}

@keyframes bounceIn {
    0% {
        transform: scale(0.3);
        opacity: 0;
    }
    50% {
        transform: scale(1.05);
    }
    70% {
        transform: scale(0.9);
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.winner-emoji {
    font-size: 6em;
    margin-bottom: 20px;
    animation: rotate 2s infinite linear;
}

@keyframes rotate {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.winner-text {
    font-size: 2.5em;
    font-weight: bold;
    color: #ff6b9d;
    margin-bottom: 30px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
}

.play-again-btn {
    background: linear-gradient(45deg, #00b894, #55efc4);
    color: white;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
}

.play-again-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
}

.winner-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
}

.next-level-btn {
    background: linear-gradient(45deg, #6c5ce7, #a29bfe);
    color: white;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
}

.next-level-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
}

@media (max-width: 600px) {
    .game-container {
        padding: 20px;
        margin: 10px;
    }
    
    .game-header h1 {
        font-size: 2em;
    }
    
    .maze-cell {
        width: 30px;
        height: 30px;
        font-size: 1.4em;
    }
    
    .game-info {
        grid-template-columns: 1fr;
        text-align: center;
    }
    
    .flag-status {
        justify-self: center;
    }
    
    .control-info {
        font-size: 0.9em;
    }
}