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

body {
    font-family: 'Press Start 2P', cursive;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    transition: background 0.3s;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

body.theme-green  { background: #9bbc0f; }
body.theme-gray  { background: #9e9e9e; }
body.theme-wheat { background: #d2b48c; }
body.theme-blue  { background: #7aa2b5; }

.game-container {
    background: rgba(0, 0, 0, 0.15);
    border: 6px solid #5a5a4a;
    border-radius: 12px;
    padding: 20px;
    box-shadow: inset 0 0 10px rgba(0,0,0,0.5), 0 10px 20px rgba(0,0,0,0.6);
    display: flex;
    flex-direction: column;
    align-items: center;
    max-width: 95vw;
}

.game-header h1 {
    font-size: 18px;
    letter-spacing: 2px;
    margin-bottom: 15px;
    color: #2e2e1f;
    text-shadow: 2px 2px 0 #a0a080;
    text-align: center;
    line-height: 1.4;
}

.game-main {
    display: flex;
    gap: 25px;
    align-items: flex-start;
    flex-wrap: wrap;
    justify-content: center;
}

.canvas-wrapper {
    border: 6px solid #4a4a3a;
    border-radius: 6px;
    background: #0f0f0a;
    line-height: 0;
    box-shadow: inset 0 0 8px #000000;
}

#gameCanvas {
    display: block;
    image-rendering: pixelated;
}

.side-panel {
    display: flex;
    flex-direction: column;
    gap: 15px;
    min-width: 150px;
    align-items: center;
}

.panel-box {
    background: rgba(0, 0, 0, 0.2);
    border: 3px solid #5a5a4a;
    border-radius: 8px;
    padding: 10px 12px;
    text-align: center;
    width: 100%;
}

.panel-box h3 {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #3a3a2a;
    margin-bottom: 6px;
    text-shadow: 1px 1px 0 #b0b090;
}

.panel-box p {
    font-size: 18px;
    color: #1e1e10;
    text-shadow: 2px 2px 0 #9a9a7a;
}

#nextCanvas {
    background: #0f0f0a;
    border: 2px solid #4a4a3a;
    border-radius: 4px;
    display: block;
    margin: 0 auto;
    image-rendering: pixelated;
}

.color-swatches {
    display: flex;
    gap: 6px;
    justify-content: center;
    margin-top: 4px;
}

.swatch {
    width: 20px;
    height: 20px;
    border: 2px solid #3a3a2a;
    border-radius: 3px;
    cursor: pointer;
    transition: transform 0.1s;
}
.swatch:active {
    transform: scale(0.9);
}

#startButton {
    font-family: 'Press Start 2P', cursive;
    font-size: 12px;
    background: #c0b090;
    border: 3px solid #4a4a3a;
    border-radius: 8px;
    padding: 10px 15px;
    color: #2e2e1f;
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 1px;
    box-shadow: 3px 3px 0 #6a6a4a;
    transition: all 0.1s;
    width: 100%;
}
#startButton:active {
    box-shadow: 1px 1px 0 #6a6a4a;
    transform: translate(2px, 2px);
}

.touch-controls {
    display: none;
    flex-direction: column;
    gap: 10px;
    margin-top: 15px;
    align-items: center;
}

.control-row {
    display: flex;
    gap: 15px;
}

.ctrl-btn {
    font-family: 'Press Start 2P', cursive;
    font-size: 20px;
    width: 60px;
    height: 60px;
    border: 3px solid #4a4a3a;
    background: #c0b090;
    color: #2e2e1f;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 3px 3px 0 #6a6a4a;
    touch-action: manipulation;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}
.ctrl-btn:active {
    box-shadow: 1px 1px 0 #6a6a4a;
    transform: translate(2px, 2px);
}

@media (max-width: 700px) {
    .game-main {
        flex-direction: column;
        align-items: center;
    }
    .side-panel {
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
        gap: 10px;
    }
    .panel-box {
        flex: 1 1 45%;
        min-width: 100px;
    }
    .game-header h1 {
        font-size: 14px;
    }
}

body.touch-device .touch-controls {
    display: flex;
}
