* {
    box-sizing: border-box;
}

html, body {
    height: 100%;
    margin: 0;
    overflow: hidden; /* Prevent scrolling on desktop */
}

body {
    background-color: #121212;
    color: #e0e0e0;
    font-family: 'Press Start 2P', cursive;
    display: flex;
    justify-content: center;
    align-items: center;
}

.container {
    display: flex;
    flex-direction: row;
    gap: 30px;
    align-items: flex-start;
}

main {
    position: relative; /* For overlay positioning */
    border: 4px solid #888;
    border-radius: 10px;
    padding: 10px;
    background-color: #212121;
}

#game-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.75);
    color: white;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 10;
    border-radius: 6px;
}

#overlay-text {
    font-size: 1.5em;
    text-align: center;
    margin-bottom: 20px;
}

#start-btn {
    font-family: 'Press Start 2P', cursive;
    font-size: 1em;
    padding: 10px 20px;
    background-color: #f44336;
    color: white;
    border: 2px solid #fff;
    border-radius: 5px;
    cursor: pointer;
}

canvas#tetris {
    display: block;
    background-color: #000;
    border-radius: 5px;
}

aside {
    width: 200px;
    text-align: center;
}

h1 {
    font-size: 2.5em;
    color: #f44336;
    margin-bottom: 20px;
    text-shadow: 3px 3px 0px #444;
}

.info-box {
    background-color: #212121;
    border: 2px solid #888;
    border-radius: 10px;
    padding: 15px;
    margin-bottom: 20px;
}

.info-box h2 {
    font-size: 1em;
    color: #f44336;
    margin-top: 0;
    margin-bottom: 10px;
    border-bottom: 2px solid #888;
    padding-bottom: 5px;
}

#score {
    font-size: 1.8em;
    color: #fff;
    margin: 0;
}

canvas#next {
    background-color: #000;
    border-radius: 5px;
}

.controls-desktop {
    display: block;
}

.touch-controls {
    display: none; /* Hidden by default */
}

/* Mobile Styles */
@media (max-width: 768px) {
    html, body {
        height: 100vh;
        overflow: hidden;
    }
    body {
        flex-direction: column;
        justify-content: space-between;
        padding: 10px;
    }
    .container {
        display: flex;
        flex-direction: row;
        align-items: flex-start;
        width: 100%;
        gap: 15px;
    }
    main {
        flex: 0 0 auto;
        padding: 6px;
        border-width: 3px;
    }
    canvas#tetris {
        width: 144px; /* 12 blocks * 12px/block */
        height: 240px; /* 20 blocks * 12px/block */
    }
    aside {
        flex: 1;
        width: auto;
        text-align: left;
    }
    h1 {
        font-size: 1.5em;
        text-align: center;
        margin: 0 0 10px 0;
    }
    .info-box {
        padding: 10px;
        margin-bottom: 10px;
        text-align: center;
    }
    .info-box h2 {
        font-size: 0.8em;
    }
    #score {
        font-size: 1.2em;
    }
    canvas#next {
        width: 60px;
        height: 60px;
    }
    .controls-desktop {
        display: none;
    }
    .touch-controls {
        display: grid;
        flex-shrink: 0;
        grid-template-columns: repeat(3, 1fr);
        grid-template-rows: auto auto;
        gap: 10px;
        width: 100%;
        max-width: 360px;
        margin-top: 15px;
    }
    .touch-controls button {
        font-size: 1.2em;
        padding: 12px;
        border-radius: 10px;
        border: 2px solid #888;
        background: #212121;
        color: #e0e0e0;
        font-family: 'Press Start 2P', cursive;
        -webkit-tap-highlight-color: transparent;
    }
    #rotate-btn {
        grid-column: 1 / -1;
    }
}
