:root {
    --poke-blue: #2a75bb;
    --poke-yellow: #ffcb05;
    --dark-poke-blue: #3466AF;
}

body {
    font-family: 'Arial Black', 'Impact', sans-serif; /* Fallback for 'Luckiest Guy' */
    background-color: var(--dark-poke-blue);
    color: var(--poke-yellow);
    display: flex;
    justify-content: center;
    align-items: flex-start; /* Aligns content to the top */
    min-height: 100vh;
    margin: 0;
    padding: 10px 0;
    box-sizing: border-box; /* Ensures padding is included in height calculation */
    touch-action: manipulation;
}

#game-container {
    text-align: center;
    background: url(background.png) no-repeat center center;
    background-size: cover;
    padding: 10px;
    border-radius: 15px;
    border: 4px solid var(--poke-yellow);
    box-shadow: 0 0 20px rgba(0,0,0,0.5);
    max-width: 100vw;
    box-sizing: border-box;
}

h1 {
    font-size: clamp(1.0rem, 6vw, 1.5rem);
    -webkit-text-stroke: 2px var(--poke-blue);
    margin-top: 0;
    margin-bottom: 10px;
    text-shadow: 3px 3px 0 #000;
    line-height: 1;
}

#level-display {
    font-size: clamp(1rem, 4vw, 1.0rem);
    margin-bottom: 15px;
}

#maze-container {
    display: grid;
    border: 3px solid var(--poke-blue);
    margin: 0 auto;
    width: min(90vw, 80vh);
    height: min(90vw, 80vh);
    max-width: 500px;
    max-height: 500px;
}

.cell {
    width: 100%;
    height: 100%;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    image-rendering: pixelated;
}

.path {
    background-color: rgba(255, 255, 255, 0.4);
}

.wall {
    background-color: var(--dark-poke-blue);
    background-image: url('cubes.png');
}

.player {
    background-image: url(player.png);
}

.goal {
    background-image: url(goal.png);
}

.instructions {
    margin-top: 15px;
    font-size: 0.8rem;
    color: var(--poke-yellow);
    display: none; /* Hidden by default */
    font-family: 'Courier New', Courier, monospace; /* Fallback for 'Press Start 2P' */
}

#controls {
    margin-top: 20px;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(2, 1fr);
    gap: 10px;
    width: 180px;
    margin-left: auto;
    margin-right: auto;
}

.control-btn {
    font-family: 'Courier New', Courier, monospace; /* Fallback for 'Press Start 2P' */
    background-color: var(--poke-yellow);
    border: 3px solid var(--poke-blue);
    color: var(--poke-blue);
    border-radius: 50%;
    width: 50px;
    height: 50px;
    font-size: 24px;
    cursor: pointer;
    user-select: none;
    display: flex;
    justify-content: center;
    align-items: center;
}

.control-btn:active {
    transform: translateY(2px);
}

#btn-up { grid-column: 2; grid-row: 1; }
#btn-left { grid-column: 1; grid-row: 2; }
#btn-right { grid-column: 3; grid-row: 2; }
#btn-down { grid-column: 2; grid-row: 2; }


/* Modal styles */
.hidden {
    display: none !important;
}

#modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
}

#modal-content {
    background-color: #fff;
    padding: 20px;
    border-radius: 10px;
    text-align: center;
    border: 5px solid var(--poke-yellow);
    color: var(--poke-blue);
    max-width: 80%;
}

#modal-button, #restart-button {
    margin-top: 20px;
    padding: 10px 20px;
    font-family: 'Arial Black', 'Impact', sans-serif; /* Fallback for 'Luckiest Guy' */
    font-size: 1.2rem;
    background-color: var(--poke-yellow);
    border: 2px solid var(--poke-blue);
    color: var(--poke-blue);
    border-radius: 5px;
    cursor: pointer;
}

#restart-button {
    margin-left: 10px;
}

@media (max-width: 767px) {
    .instructions {
        display: block; /* Show on mobile */
    }
}

@media (min-width: 768px) {
    #controls {
        display: none; /* Hide on-screen controls on larger screens */
    }
}