* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
   height: 100%;
    background-color: #000;
    font-family: 'Arial', sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow: auto; /* allow scrolling on small devices */
    -webkit-overflow-scrolling: touch;
}

#gameContainer {
   height: 100%;
    background-color: #000;
    font-family: 'Arial', sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow: auto; /* allow scrolling on small devices */
    -webkit-overflow-scrolling: touch;
}

:root {
    --grid-cols: 10;       /* default columns */
    --cell-gap: 8px;
    --grid-max-width: 960px;
}




/* Mobile */
@media (max-width: 500px) {
    #gameContainer {
        flex-direction: column;
        padding: 10px;
    }
}

/* Tablet */
@media (min-width: 601px) and (max-width: 1024px) {
    #gameContainer {
        flex-direction: row;
    }
}

/* Desktop */
@media (min-width: 1025px) {
    #gameContainer {
        padding: 20px;
    }
}



/* First Screen Styles */
#firstScreen {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px;
}

#firstScreen h2 {
    font-size: 3rem;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.5);
    background: linear-gradient(45deg, #ff6b6b, #4ecdc4, #45b7d1);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

#firstScreen h3 {
    color: #ffef96;
    font-size: 1.5rem;
    font-weight: bold;
}

#firstScreen h4 {
    line-height: 1.6;
    font-size: 1rem;
    color: #f0f0f0;
}

#startButton {
    background: linear-gradient(45deg, #ff6b6b, #4ecdc4);
    border: none;
    padding: 15px 40px;
    border-radius: 4px;
    color: white;
    font-size: 1.2rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 1px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
}

#startButton:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0,0,0,0.4);
}

/* Game Screen Styles */
#gameScreen {
    width: 100%;
    height: 100vh;
    background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
    position: relative;
}

#gameStatus {
    position: absolute;
    top: 100px;
    left: 10px;
    font-size: 18px;
    color: #FFF;
    background-color: rgba(0, 0, 0, 0.2);
    padding: 10px;
    border-radius: 5px;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255,255,255,0.1);
}

#gameStatus div {
    margin-bottom: 5px;
    font-weight: bold;
}

#gameArea {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100vh;
    padding: 20px;
}

#gameGrid {
    display: grid;
    grid-template-columns: repeat(10, 1fr);
    grid-template-rows: repeat(10, 1fr);
    gap: 2px;
    background-color: rgba(0,0,0,0.3);
    padding: 10px;
    border-radius: 10px;
    margin-bottom: 30px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.3);
}

.grid-cell {
    width: 60px;
    height: 55px;
    background: linear-gradient(145deg, #2c3e50, #34495e);
    border-radius: 10px;
    border: 5px solid rgba(255,255,255,0.1);
    transition: all 0.2s ease;
}

.grid-cell.filled {
    box-shadow: inset 0 2px 4px rgba(255,255,255,0.3);
}

.grid-cell.preview {
    background: rgba(255,255,255,0.3);
    box-shadow: 0 0 10px rgba(255,255,255,0.5);
}

.grid-cell.invalid {
    background: rgba(255,0,0,0.3);
    box-shadow: 0 0 10px rgba(255,0,0,0.5);
}

#piecesArea {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
}

.piece-container {
    background: rgba(0,0,0,0.2);
    border-radius: 10px;
    padding: 10px;
    min-width: 50px;
    min-height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid rgba(255,255,255,0.1);
    transition: all 0.3s ease;
}

.piece-container:hover {
    transform: scale(1.05);
    border-color: rgba(255,255,255,0.3);
}

.piece {
    display: grid;
    gap: 2px;
    cursor: grab;
    transition: all 0.2s ease;
}

.piece:active {
    cursor: grabbing;
}

.piece.dragging {
    opacity: 0.8;
    transform: scale(0.5);
    z-index: 1000;
    position: absolute;
    pointer-events: none;
}

.piece-block {
    width: 20px;
    height: 20px;
    border-radius: 3px;
    border: 1px solid rgba(255,255,255,0.2);
    box-shadow: inset 0 1px 2px rgba(255,255,255,0.3);
}

/* Colors for different piece types */
.color-1 { background: linear-gradient(145deg, #ff6b6b, #ee5a52); }
.color-2 { background: linear-gradient(145deg, #4ecdc4, #44a08d); }
.color-3 { background: linear-gradient(145deg, #45b7d1, #3498db); }
.color-4 { background: linear-gradient(145deg, #f39c12, #e67e22); }
.color-5 { background: linear-gradient(145deg, #9b59b6, #8e44ad); }
.color-6 { background: linear-gradient(145deg, #2ecc71, #27ae60); }

/* Mobile Controls */
#mobileControls {
    position: absolute;
    bottom: 20px;
    right: 20px;
}

.mobile-btn {
    width: 60px;
    height: 60px;
    background: rgba(255,255,255,0.1);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    cursor: pointer;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    border: 2px solid rgba(255,255,255,0.2);
}

.mobile-btn:hover {
    background: rgba(255,255,255,0.2);
    transform: scale(1.1);
}

/* Game Over Popup */
#gameOverPopup {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    backdrop-filter: blur(10px);
}

.popup-content {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 40px;
    border-radius: 15px;
    text-align: center;
    color: white;
    box-shadow: 0 20px 60px rgba(0,0,0,0.5);
    border: 2px solid rgba(255,255,255,0.1);
    min-width: 300px;
}

.popup-content h2 {
    margin-bottom: 20px;
    font-size: 2rem;
    background: linear-gradient(45deg, #ff6b6b, #4ecdc4);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

#gameOverStats {
    margin-bottom: 30px;
    font-size: 1.2rem;
}

#gameOverStats p {
    margin-bottom: 10px;
}

.popup-content button {
    background: linear-gradient(45deg, #ff6b6b, #4ecdc4);
    border: none;
    padding: 12px 25px;
    border-radius: 4px;
    color: white;
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    margin: 5px;
    transition: all 0.3s ease;
}

.popup-content button:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
}

/* Responsive Design */
@media (max-width: 768px) {
    #firstScreen h2 {
        font-size: 2rem;
    }
    
    .grid-cell {
        width: 25px;
        height: 25px;
    }
    
    .piece-block {
        width: 18px;
        height: 18px;
    }
    
    #piecesArea {
        gap: 15px;
    }
    
    .piece-container {
        min-width: 80px;
        min-height: 80px;
        padding: 10px;
    }
}

@media (max-width: 480px) {
    .grid-cell {
        width: 22px;
        height: 22px;
    }
    
    .piece-block {
        width: 16px;
        height: 16px;
    }
    
    #gameStatus {
        font-size: 14px;
        padding: 8px;
    }
}

/* Animations */
@keyframes clearLine {
    0% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(1.1); }
    100% { opacity: 0; transform: scale(0); }
}

.clearing {
    animation: clearLine 0.5s ease-in-out;
}

@keyframes placePiece {
    0% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

.placed {
    animation: placePiece 0.2s ease-out;
}