:root {
    --bg-color: #0a0a12;
    --game-bg: #11111a;
    --text-color: #ffffff;
    --accent-purple: #b026ff;
    --accent-fuschia: #ff00cc;
    --accent-cyan: #00ffff;
    --accent-green: #39ff14;
    --glass-bg: rgba(255, 255, 255, 0.05);
    --glass-border: rgba(255, 255, 255, 0.1);
}

html,
body {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    /* Prevent scrolling globally */
    background-color: var(--bg-color);
    color: var(--text-color);
    font-family: 'Outfit', sans-serif;
}

body {
    display: flex;
    justify-content: center;
    align-items: center;
}

.game-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    height: 100%;
    max-width: 100%;
    background: radial-gradient(circle at center, #1a1a2e 0%, #000000 100%);
    position: relative;
    box-sizing: border-box;
}

/* Header & Scoreboard */
.header {
    text-align: center;
    width: 100%;
    padding: 10px 0;
    z-index: 10;
}

h1 {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 700;
    background: linear-gradient(to right, var(--accent-fuschia), var(--accent-purple), var(--accent-cyan));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    text-shadow: 0 0 10px rgba(255, 0, 204, 0.5);
    letter-spacing: 2px;
}

.score-board {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    font-size: 0.9rem;
    font-weight: bold;
    margin-top: 5px;
}

.score-item {
    background: var(--glass-bg);
    padding: 0 15px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    border: 1px solid var(--glass-border);
    box-shadow: 0 0 10px rgba(0, 255, 255, 0.1);
    min-width: 80px;
}

.score-item span {
    color: var(--accent-green);
    text-shadow: 0 0 5px var(--accent-green);
    margin-left: 5px;
}

/* Game Area */
.game-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    flex: 1;
    /* Take remaining space */
    justify-content: center;
    position: relative;
}

#gameCanvas {
    background-color: var(--game-bg);
    border: 2px solid var(--accent-purple);
    border-radius: 5px;
    box-shadow: 0 0 20px rgba(176, 38, 255, 0.3);
    /* Responsive scaling */
    max-height: 65vh;
    /* Leave room for controls */
    max-width: 90vw;
    height: auto;
    width: auto;
    object-fit: contain;
}

/* Sidebar / Next Piece */
.sidebar {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: absolute;
    top: 10px;
    right: 10px;
    gap: 10px;
    pointer-events: none;
    /* Let touches pass through if needed */
}

.next-piece {
    background: var(--glass-bg);
    padding: 5px;
    border-radius: 8px;
    border: 1px solid var(--glass-border);
    display: flex;
    flex-direction: column;
    align-items: center;
    transform: scale(0.8);
    /* Smaller on mobile */
    transform-origin: top right;
}

.next-piece h3 {
    margin: 0 0 2px 0;
    color: var(--accent-cyan);
    font-size: 0.8rem;
}

#nextCanvas {
    background-color: rgba(0, 0, 0, 0.3);
    border-radius: 5px;
}

.controls-info {
    display: none;
    /* Hide on mobile */
}

#startBtn {
    background: linear-gradient(45deg, var(--accent-fuschia), var(--accent-purple));
    border: none;
    padding: 0 15px;
    height: 36px;
    min-width: 80px;
    border-radius: 8px;
    color: white;
    font-family: 'Outfit', sans-serif;
    font-weight: bold;
    font-size: 0.9rem;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    text-transform: uppercase;
    white-space: nowrap;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: auto;
    /* Ensure clickable */
}

#startBtn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(255, 0, 204, 0.4);
}

#startBtn:active {
    transform: translateY(0);
}

/* Mobile Controls */
.mobile-controls {
    position: fixed;
    bottom: 30px;
    right: 20px;
    /* Move to right side */
    left: auto;
    /* Reset left */
    display: flex;
    flex-direction: column;
    gap: 15px;
    /* Increased spacing */
    z-index: 9999;
    /* Ensure on top of everything */
    pointer-events: auto;
    touch-action: none;
    /* Prevent browser gestures */
}

.control-row {
    display: flex;
    gap: 15px;
    /* Increased spacing */
    justify-content: center;
}

.control-btn {
    width: 48px;
    /* Reduced size (~20%) */
    height: 48px;
    border-radius: 12px;
    border: none;
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(5px);
    color: white;
    font-size: 1.2rem;
    /* Smaller font */
    display: flex;
    justify-content: center;
    align-items: center;
    touch-action: none;
    /* Critical for instant touch */
    user-select: none;
    -webkit-user-select: none;
    box-shadow: 0 0 10px rgba(0, 255, 255, 0.3);
    transition: transform 0.05s, background 0.05s;
    /* Faster transition */
    cursor: pointer;
}

.control-btn:active {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(0.9);
    box-shadow: 0 0 20px rgba(0, 255, 255, 0.6);
}

.action-btn {
    background: rgba(176, 38, 255, 0.25);
    box-shadow: 0 0 10px rgba(176, 38, 255, 0.3);
}

.action-btn:active {
    background: rgba(176, 38, 255, 0.4);
    box-shadow: 0 0 20px rgba(176, 38, 255, 0.6);
}

#rotateBtn {
    border-radius: 50%;
}

/* Desktop Styles (> 1024px) */
@media (min-width: 1025px) {
    body {
        overflow: hidden;
        /* Still no scroll */
    }

    .game-container {
        width: 95%;
        max-width: 900px;
        height: auto;
        max-height: 95vh;
        padding: 20px;
        border-radius: 20px;
        box-shadow: 0 0 50px rgba(176, 38, 255, 0.2);
        justify-content: flex-start;
    }

    h1 {
        font-size: 3rem;
        margin-bottom: 15px;
    }

    .score-board {
        font-size: 1rem;
        margin-top: 0;
    }

    .game-area {
        flex-direction: row;
        align-items: flex-start;
        justify-content: center;
        gap: 20px;
    }

    #gameCanvas {
        max-height: 80vh;
        max-width: none;
    }

    .sidebar {
        position: static;
        width: auto;
        min-width: 150px;
        pointer-events: auto;
    }

    .next-piece {
        transform: none;
        padding: 10px;
    }

    .next-piece h3 {
        font-size: 1rem;
    }

    .controls-info {
        display: block;
        background: var(--glass-bg);
        padding: 10px;
        border-radius: 10px;
        border: 1px solid var(--glass-border);
        font-size: 0.8rem;
        color: #aaa;
        width: 100%;
        box-sizing: border-box;
    }

    .controls-info p {
        margin: 3px 0;
    }

    #startBtn {
        /* Desktop specific adjustments if needed, but global style should work */
        padding: 0 20px;
        font-size: 1rem;
        width: 100%;
        height: 44px;
        /* Added back for desktop */
        border-radius: 10px;
        /* Added back for desktop */
    }

    .mobile-controls {
        display: none;
    }
}