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

body {
    color: white;
    background-color: #111;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    font-family: 'Courier New', monospace;
}

h2 {
    height: 50px;
    padding: 10px;
    text-align: center;
    color: white;
    font-weight: normal;
}
a{
    color: white;
    text-decoration: none;
    border-bottom: 3px double white;
}
a:hover{
    background: #333;
}

#gameContainer {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    width: 100%;
    height: 100vh;
}

#scorePanel {
    color: #fff;
    font-size: 18px;
    padding: 12px 20px;
    text-align: center;
    background: rgba(0, 0, 0, 0.7);
    border-bottom: 1px solid #333;
    height: 50px;
    flex-shrink: 0;
}

#canvasWrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    background: #000;
    position: relative;
    /* margin-block: 30px; */
}

#gameCanvas {
    background-color: #000;
    display: block;
    max-width: 100%;
    max-height: 100%;
    border: 1px solid #333;
}

#controls {
    height: 20vh;
    max-height: 20vh;
    margin-top: 30px;
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    grid-template-rows: 1fr 1fr;
    gap: 10px;
    padding: 10px;
    background: rgba(20, 20, 20, 0.9);
    box-sizing: border-box;
    width: 100%;
    flex-shrink: 0;
}

.control-btn {
    background-color: #333;
    color: #fff;
    border: 2px solid #444;
    border-radius: 8px;
    font-size: 28px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    user-select: none;
    transition: all 0.1s;
}

.control-btn:active {
    background-color: #444;
    transform: scale(0.95);
}

#up-btn {
    grid-column: 2;
    grid-row: 1;
}

#left-btn {
    grid-column: 1;
    grid-row: 2;
}

#right-btn {
    grid-column: 3;
    grid-row: 2;
}

#down-btn {
    grid-column: 2;
    grid-row: 2;
}

#gameOver {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #fff;
    font-size: 28px;
    text-align: center;
    display: none;
    z-index: 20;
    background: rgba(0, 0, 0, 0.85);
    padding: 30px;
    border: 2px solid #fff;
    border-radius: 10px;
    width: 80%;
    max-width: 350px;
}

#restartBtn {
    background: #333;
    color: #fff;
    border: 1px solid #555;
    padding: 12px 25px;
    margin-top: 20px;
    font-family: 'Courier New', monospace;
    font-size: 18px;
    cursor: pointer;
    border-radius: 5px;
    transition: background 0.3s;
}

#restartBtn:hover {
    background: #444;
}

#finalScore {
    margin: 15px 0;
    font-size: 22px;
}

/* Hide controls on non-touch devices */
@media (hover: hover) and (pointer: fine) {
    #controls {
        display: none;
    }

    #canvasWrapper {
        height: calc(100vh - 100px);
    }
}