* {
    font-family: 'Press Start 2P', cursive;
    color: white;
    background-color: #181818;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html, body {
    margin: 0;
    padding: 0;
    overscroll-behavior: none;
    touch-action: none;
    height: 100%;
}

.grid {
    display: grid;
    grid-template-columns: 320px 200px;
    justify-content: center;
    gap: 10px;
    padding: 10px;
}

.right-column {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.game-board {
    border: solid 2px;
    display: block;
    max-width: 100%;
    height: auto;
    touch-action: none;
}

.play-button {
    background-color: #4caf50;
    font-size: 16px;
    padding: 15px 30px;
    cursor: pointer;
    border: none;
    border-radius: 4px;
}

.play-button:active {
    background-color: #3d8b40;
}

/* ---------- Touch controls ---------- */
.touch-controls {
    display: none;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 4px 0;
    user-select: none;
}

.touch-row {
    display: flex;
    gap: 8px;
    justify-content: center;
}

.touch-btn {
    background-color: #333;
    border: 2px solid #555;
    border-radius: 8px;
    color: white;
    font-size: 16px;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    touch-action: manipulation;
}

.touch-btn:active,
.touch-btn.active {
    background-color: #4caf50;
    border-color: #4caf50;
}

.touch-btn.drop {
    width: 120px;
    font-size: 12px;
}

.touch-btn.rotate {
    width: 44px;
    font-size: 18px;
}

/* Show touch controls on touch-capable / small screens */
@media (pointer: coarse), (max-width: 768px) {
    .touch-controls {
        display: flex;
    }

    body {
        display: flex;
        flex-direction: column;
        height: 100vh;
        height: 100dvh;
        overflow: hidden;
    }

    .grid {
        grid-template-columns: 1fr;
        grid-template-areas:
            "board"
            "info";
        justify-items: center;
        flex: 1 1 auto;
        min-height: 0;
        padding: 4px;
        gap: 2px;
    }

    .game-board {
        grid-area: board;
        width: auto;
        height: 100%;
        max-height: 100%;
        max-width: 90vw;
        min-height: 0;
        object-fit: contain;
    }

    .right-column {
        grid-area: info;
        width: 100%;
        max-width: 320px;
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        flex: 0 0 auto;
    }

    .next {
        width: 50px !important;
        height: 50px !important;
    }

    h1 {
        font-size: 14px;
        margin: 2px 0;
    }

    p {
        font-size: 11px;
        margin: 2px 0;
    }

    .play-button {
        font-size: 12px;
        padding: 6px 12px;
    }

    .touch-controls {
        flex: 0 0 auto;
        padding: 4px 0;
        padding-bottom: max(4px, env(safe-area-inset-bottom));
    }
}

@media (max-width: 380px) {
    .touch-btn {
        width: 40px;
        height: 40px;
        font-size: 14px;
    }

    .touch-btn.drop {
        width: 110px;
        font-size: 11px;
    }
}
