:root {
    --bg-color: #0f172a;
    --text-color: #f8fafc;
    --maze-bg: #1e293b;
    --wall-color: #020617;
    --player-color: #3b82f6;
    --goal-color: #22c55e;
    --glass-bg: rgba(30, 41, 59, 0.7);
    --glass-border: rgba(255, 255, 255, 0.1);
}

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

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    font-family: 'Outfit', sans-serif;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
}

#app {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    padding: 20px;
}

header {
    text-align: center;
}

header h1 {
    font-size: 2.5rem;
    margin-bottom: 5px;
    background: linear-gradient(to right, #60a5fa, #a78bfa);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

header p {
    color: #94a3b8;
    margin-bottom: 5px;
}

.stats {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-top: 10px;
}

.stats p {
    font-size: 1.1rem;
    margin-bottom: 0;
}

#win-count {
    font-weight: bold;
    color: #86efac;
    font-size: 1.2rem;
}

#lives-count {
    font-weight: bold;
    color: #fca5a5;
    font-size: 1.2rem;
}

#damage-flash {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(220, 38, 38, 0.4);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s ease;
    z-index: 100;
}

#damage-flash.flash {
    opacity: 1;
}

#game-container {
    position: relative;
    padding: 10px;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.5);
    backdrop-filter: blur(10px);
}

#maze {
    display: grid;
    grid-template-columns: repeat(10, 1fr);
    grid-template-rows: repeat(10, 1fr);
    width: 320px;
    height: 320px;
    gap: 2px;
    background-color: #334155;
    border: 2px solid #334155;
    border-radius: 8px;
    overflow: hidden;
}

.cell {
    width: 100%;
    height: 100%;
    background-color: var(--maze-bg);
    transition: background-color 0.2s ease, transform 0.2s ease;
}

.cell.wall {
    background-color: var(--wall-color);
    box-shadow: inset 0 0 10px rgba(0,0,0,0.8);
}

.cell.player {
    background-color: var(--player-color);
    border-radius: 4px;
    box-shadow: 0 0 15px var(--player-color);
    transform: scale(0.85);
}

.cell.goal {
    background-color: var(--goal-color);
    border-radius: 4px;
    box-shadow: 0 0 15px var(--goal-color);
    animation: pulse 1.5s infinite alternate;
}

@keyframes pulse {
    from {
        transform: scale(0.85);
        box-shadow: 0 0 10px var(--goal-color);
    }
    to {
        transform: scale(0.95);
        box-shadow: 0 0 20px var(--goal-color);
    }
}

#overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(4px);
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 16px;
    opacity: 1;
    transition: opacity 0.3s ease;
    z-index: 10;
}

#overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.message-box {
    background: var(--glass-bg);
    padding: 30px;
    border-radius: 12px;
    text-align: center;
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 15px 30px rgba(0,0,0,0.7);
    transform: scale(1);
    transition: transform 0.3s ease;
}

#overlay.hidden .message-box {
    transform: scale(0.8);
}

.message-box h2 {
    color: #fcd34d;
    margin-bottom: 10px;
    font-size: 1.8rem;
    background: linear-gradient(to right, #fbbf24, #f59e0b);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.message-box p {
    margin-bottom: 20px;
    color: #e2e8f0;
}

#next-level-btn {
    background: linear-gradient(135deg, #3b82f6, #8b5cf6);
    color: white;
    border: none;
    padding: 10px 20px;
    font-size: 1.1rem;
    font-family: inherit;
    border-radius: 8px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

#next-level-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(139, 92, 246, 0.4);
}

#next-level-btn:active {
    transform: translateY(0);
}

.controls {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    margin-top: 10px;
}

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

.control-btn {
    width: 65px;
    height: 65px;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    color: white;
    font-size: 1.8rem;
    border-radius: 12px;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
    display: flex;
    justify-content: center;
    align-items: center;
}

@media (hover: hover) {
    .control-btn:hover {
        background: rgba(255, 255, 255, 0.1);
    }
}

.control-btn:active {
    transform: scale(0.95);
    background: rgba(255, 255, 255, 0.2);
}

.cell.life-collectible {
    background-color: #facc15;
    color: #854d0e;
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: bold;
    font-size: 0.9rem;
    border-radius: 4px;
    box-shadow: 0 0 10px rgba(250, 204, 21, 0.6);
    animation: bounce 1.5s infinite alternate;
    z-index: 2;
}

@keyframes bounce {
    from {
        transform: scale(0.85) translateY(0);
        box-shadow: 0 0 5px rgba(250, 204, 21, 0.4);
    }
    to {
        transform: scale(0.95) translateY(-2px);
        box-shadow: 0 0 15px rgba(250, 204, 21, 0.8);
    }
}
