:root {
    --bg-color: #0f172a;
    --maze-bg: #1e293b;
    --wall-color: #64748b;
    --path-color: #334155;
    --player-color: #06b6d4;
    --goal-color: #10b981;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --accent: #3b82f6;

    --font-main: 'Outfit', sans-serif;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    user-select: none;
    /* Prevent selection while playing */
}

body {
    background-color: var(--bg-color);
    color: var(--text-primary);
    font-family: var(--font-main);
    height: 100vh;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
}

.app-container {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    position: relative;
    max-width: 1200px;
    margin: 0 auto;
}

/* HEADER / HUD */
.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 2rem;
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(10px);
    z-index: 10;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.title {
    font-size: 1.5rem;
    font-weight: 600;
    letter-spacing: 2px;
    color: var(--accent);
}

.hud-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 80px;
}

.hud-item .label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    letter-spacing: 1px;
    margin-bottom: 2px;
}

.hud-item .value {
    font-family: monospace;
    font-size: 1.5rem;
    font-weight: 600;
}

/* GAME BOARD */
.game-board {
    flex: 1;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    overflow: hidden;
}

.maze-grid {
    display: grid;
    background-color: var(--maze-bg);
    border: 2px solid var(--wall-color);
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
    position: relative;
    transition: all 0.5s ease;
}

.cell {
    background-color: var(--path-color);
    position: relative;
    box-sizing: border-box;
}

/* Walls are rendered as borders. 
   State: 'wall-top', 'wall-right', 'wall-bottom', 'wall-left' classes 
   But simpler: we can just use inline styles for borders if grid is strict, 
   OR use CSS classes for borders. Using classes is cleaner. */
.cell.border-t {
    border-top: 1px solid var(--wall-color);
}

.cell.border-r {
    border-right: 1px solid var(--wall-color);
}

.cell.border-b {
    border-bottom: 1px solid var(--wall-color);
}

.cell.border-l {
    border-left: 1px solid var(--wall-color);
}

.cell.goal {
    background-color: rgba(16, 185, 129, 0.2);
}

.cell.goal::after {
    content: '';
    position: absolute;
    width: 50%;
    height: 50%;
    background-color: var(--goal-color);
    border-radius: 50%;
    top: 25%;
    left: 25%;
    animation: pulse 1s infinite alternate;
}

#player {
    position: absolute;
    background-color: var(--player-color);
    border-radius: 4px;
    transition: transform 0.1s linear;
    /* Smooth movement */
    z-index: 5;
    box-shadow: 0 0 10px var(--player-color);
}

/* OVERLAYS */
.overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.95);
    display: none;
    /* Hidden by default */
    justify-content: center;
    align-items: center;
    z-index: 100;
    backdrop-filter: blur(5px);
}

.overlay.active {
    display: flex;
}

.modal {
    background: #1e293b;
    padding: 3rem;
    border-radius: 16px;
    text-align: center;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
    max-width: 500px;
    width: 90%;
}

.modal h1 {
    font-size: 2.5rem;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.modal p {
    color: var(--text-secondary);
    margin-bottom: 2rem;
    line-height: 1.6;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent), #2563eb);
    color: white;
    border: none;
    padding: 1rem 3rem;
    font-size: 1.2rem;
    border-radius: 50px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    font-weight: 600;
    font-family: var(--font-main);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(59, 130, 246, 0.4);
}

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

.ranking-preview {
    margin-top: 2rem;
    padding-top: 2rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.ranking-preview h3 {
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

.ranking-preview ul {
    list-style: none;
    text-align: left;
}

.ranking-preview li {
    background: rgba(255, 255, 255, 0.05);
    margin-bottom: 0.5rem;
    padding: 0.8rem;
    border-radius: 8px;
    display: flex;
    justify-content: space-between;
    font-family: monospace;
}

/* ANIMATIONS */
@keyframes pulse {
    from {
        transform: scale(0.8);
        opacity: 0.8;
    }

    to {
        transform: scale(1.1);
        opacity: 1;
    }
}

.btn-quit {
    background: rgba(239, 68, 68, 0.2);
    border: 1px solid rgba(239, 68, 68, 0.5);
    color: #fca5a5;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: none;
    /* Flex when active */
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1.2rem;
    transition: all 0.2s;
    margin-left: 1rem;
}

.btn-quit:hover {
    background: rgba(239, 68, 68, 0.8);
    color: white;
    transform: rotate(90deg);
}