/* Base Reset */
body,
html {
    margin: 0;
    padding: 0;
    font-family: monospace;
    background-color: #3a2d56;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
}

/* GameBoy Layout */
.gameboy {
    background-color: #5f4c82; /* Game Boy Color purple shell */
    width: 441px;
    height: 735px;
    border-radius: 20px;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.6);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 10px;
    position: relative;
}

@media(max-width: 768px) {
    .gameboy {
        width: 100vw;
        height: 100vh;
        border-radius: 0;
    }
}

/* Screen */
.screen {
    background-color: black;
    border: 4px solid #0f380f;
    width: 90%;
    height: 55%;
    margin-top: 20px;
    border-radius: 10px;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: inset 0 4px 8px rgba(0, 0, 0, 0.5);
    overflow: hidden;
}

.game {
    text-align: center;
    width: 90%;
}

/* Titles */
h1 {
    font-size: 2rem;
    margin-bottom: 10px;
    text-transform: uppercase;
    color: #9bbc0f;
}

.description,
.description p {
    font-size: 1.2rem;
    margin: 0 auto;
    padding: 0 auto;
    color: white;
}

/* Grid container */
#grid {
    display: grid;
    grid-template-columns: repeat(10, 1fr); /* Adjust to match gridSize */
    grid-template-rows: repeat(10, 1fr); /* Adjust to match gridSize */
    width: 400px; /* Adjust as needed */
    height: 400px; /* Adjust as needed */
    border: 2px solid #0f380f;
    margin: 20px auto;
    /* initially hide */
    display: none;
}

/* Individual cells */
.cell {
    width: 100%;
    height: 100%;
}

.cell.light-green {
    background-color: #9bbc0f;
}

.cell.dark-green {
    background-color: #0f380f;
}

/* Snake styling */
.snake {
    background-color: #e600ff; /* Snake color */
    z-index: 1000;
}

/* Apple styling */
.apple {
    background-color: red; /* Apple color */
    z-index: 999;
}

/* Controls Section */
.controls {
    margin-top: 20px;
    display: flex;
    justify-content: space-between;
    width: 80%;
    align-items: center;
}

/* D-Pad */
.dpad {
    position: relative;
    width: 120px;
    height: 120px;
}

/* Base Styling for D-Pad Buttons */
.dpad-btn {
    background-color: #0f380f;
    color: #9bbc0f;
    border: none;
    border-radius: 5px;
    position: absolute;
    width: 42px;
    height: 42px;
    font-size: 1.5rem;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    z-index: 1;
}

.dpad-btn.up {
    top: 0;
    left: 50%;
    transform: translateX(-50%);
}

.dpad-btn.down {
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
}

.dpad-btn.left {
    top: 50%;
    left: 0;
    transform: translateY(-50%);
}

.dpad-btn.right {
    top: 50%;
    right: 0;
    transform: translateY(-50%);
}

/* D-Pad Center to Connect Buttons */
.dpad-center {
    background-color: #0f380f;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 40px;
    border: 2px solid transparent;
    z-index: 0;
    border-radius: 5px;
}

/* A and B Buttons */
.action-buttons {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    height: 200px;
}

.btn {
    background-color: #0f380f;
    color: #9bbc0f;
    border: 2px solid #9bbc0f;
    border-radius: 50%;
    width: 60px;
    height: 60px;
    font-size: 1.8rem;
    cursor: pointer;
    transition: transform 0.1s, background-color 0.2s;
}

.btn:hover {
    background-color: #9bbc0f;
    color: #0f380f;
}

.btn:active {
    transform: scale(0.9);
}

/* Start Button */
.start-btn {
    background-color: #0f380f;
    color: #9bbc0f;
    border: 2px solid #9bbc0f;
    border-radius: 5px;
    width: 100px;
    height: 40px;
    font-size: 1.2rem;
    cursor: pointer;
    transition: transform 0.1s, background-color 0.2s;
    margin-bottom: 20px;
}

.start-btn:hover {
    background-color: #9bbc0f;
    color: #0f380f;
}

.start-btn:active {
    transform: scale(0.9);
}

/* Hidden Canvas for Debugging or Fallback */
canvas {
    display: none;
    z-index: 1000;
}