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

html {
    /* Prevent double-tap zoom */
    touch-action: manipulation;
    -webkit-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
}

body {
    font-family: 'Arial', sans-serif;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    color: #fff;
    height: 100vh;
    width: 100vw;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    /* Additional properties to prevent zoom */
    touch-action: manipulation;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -khtml-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

.game-area {
    flex: 1;
    display: flex;
    gap: 1rem;
    position: relative;
    overflow: hidden;
    margin-top: 50px; /* Space for the fixed header */
    padding: 0.5rem;
    min-height: 0; /* Important for flex child to respect parent height */
    /* Prevent double-tap zoom on game area */
    touch-action: manipulation;
}

#mainGrid {
    flex: 1;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 0.5rem;
    min-width: 0; /* Important for flex child to respect parent width */
    min-height: 0; /* Important for flex child to respect parent height */
    /* Prevent double-tap zoom on main canvas */
    touch-action: manipulation;
}

.side-pieces {
    width: 200px;
    min-width: 200px; /* Prevent side pieces from shrinking */
    background: rgba(255, 255, 255, 0.05);
    border-radius: 0.5rem;
    padding: 0.5rem;
    display: flex;
    flex-direction: column;
    /* Prevent double-tap zoom on side pieces */
    touch-action: manipulation;
}

#pieceCanvas {
    width: 100%;
    height: 100%;
    min-height: 0; /* Important for flex child to respect parent height */
    /* Prevent double-tap zoom on piece canvas */
    touch-action: manipulation;
}

.controls {
    padding: 0.5rem;
    display: flex;
    gap: 0.5rem;
    justify-content: center;
    background: rgba(255, 255, 255, 0.05);
    flex-shrink: 0; /* Prevent controls from shrinking */
}

button {
    background: #4a90e2;
    color: white;
    border: none;
    padding: 0.4rem 0.8rem;
    border-radius: 0.3rem;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 40px;
    flex-shrink: 0; /* Prevent buttons from shrinking */
}

button:hover {
    background: #357abd;
    transform: translateY(-1px);
}

button:active {
    transform: translateY(0);
}

/* Custom scrollbar for the game area */
.game-area::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

.game-area::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

.game-area::-webkit-scrollbar-thumb {
    background: #4a90e2;
    border-radius: 4px;
}

.game-area::-webkit-scrollbar-thumb:hover {
    background: #357abd;
}

/* Media query for mobile devices in portrait mode */
@media (max-width: 768px) and (orientation: portrait) {
    .game-area {
        flex-direction: column;
        margin-top: 50px;
        padding: 0;
        gap: 0.5rem;
    }

    .side-pieces {
        width: 100%;
        min-width: 100%;
        height: 80px; /* Fixed height for horizontal piece bar */
        padding: 0.25rem;
        flex-direction: row;
        overflow-x: auto;
        overflow-y: hidden;
        white-space: nowrap;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none; /* Firefox */
        -ms-overflow-style: none; /* IE and Edge */
    }

    .side-pieces::-webkit-scrollbar {
        display: none; /* Chrome, Safari, Opera */
    }

    #pieceCanvas {
        height: 100%;
        width: auto;
        min-width: max-content;
    }

    #mainGrid {
        flex: 1;
        margin: 0; /* Remove uneven margins to center properly */
        width: 100%; /* Ensure full width */
    }

    .controls {
        padding: 0.25rem;
        gap: 0.25rem;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: rgba(26, 26, 26, 0.9);
        backdrop-filter: blur(5px);
        z-index: 1000;
    }

    button {
        padding: 0.3rem 0.6rem;
        font-size: 0.8rem;
        min-width: 35px;
    }
}

/* Media query for mobile devices in landscape mode */
@media (max-width: 768px) and (orientation: landscape) {
    .game-area {
        flex-direction: row;
        margin-top: 50px;
        padding: 0.25rem;
        gap: 0.5rem;
    }

    .side-pieces {
        width: 120px;
        min-width: 120px;
        height: 100%;
        padding: 0.25rem;
    }

    #pieceCanvas {
        height: 100%;
        width: 100%;
    }

    .controls {
        padding: 0.25rem;
        gap: 0.25rem;
    }

    button {
        padding: 0.3rem 0.6rem;
        font-size: 0.8rem;
        min-width: 35px;
    }
}

/* Media query for very small screens */
@media (max-width: 480px) {
    .game-area {
        margin-top: 70px; /* Even more space for header on very small screens */
    }

    .side-pieces {
        height: 100px; /* Smaller height for very small screens */
    }
} 