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

body {
    font-family: 'Arial', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 10px;
}

.game-container {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
    padding: 20px;
    max-width: 800px;
    width: 100%;
}

.game-header {
    text-align: center;
    margin-bottom: 20px;
}

.game-header h1 {
    font-size: 2.5rem;
    color: #333;
    margin-bottom: 15px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
}

.score-container {
    display: flex;
    justify-content: center;
    gap: 30px;
    flex-wrap: wrap;
}

.score-item {
    text-align: center;
    background: linear-gradient(45deg, #4CAF50, #45a049);
    color: white;
    padding: 10px 20px;
    border-radius: 10px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.score-item .label {
    display: block;
    font-size: 0.9rem;
    opacity: 0.9;
}

.score-item .value {
    display: block;
    font-size: 1.5rem;
    font-weight: bold;
    margin-top: 5px;
}

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

.game-board {
    position: relative;
    background: #000;
    border: 3px solid #333;
    border-radius: 10px;
    overflow: hidden;
}

#gameCanvas {
    display: block;
    background: #000;
}

.game-over {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.9);
    color: white;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    border-radius: 7px;
}

.game-over.hidden {
    display: none;
}

.game-over h2 {
    font-size: 2rem;
    margin-bottom: 20px;
    color: #ff4444;
}

.game-over p {
    font-size: 1.2rem;
    margin-bottom: 20px;
}

.game-sidebar {
    display: flex;
    flex-direction: column;
    gap: 20px;
    min-width: 200px;
}

.next-piece {
    background: #f5f5f5;
    padding: 15px;
    border-radius: 10px;
    text-align: center;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.next-piece h3 {
    margin-bottom: 10px;
    color: #333;
}

#nextCanvas {
    background: #000;
    border: 2px solid #333;
    border-radius: 5px;
}

.game-controls {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.btn {
    padding: 12px 24px;
    font-size: 1rem;
    font-weight: bold;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    background: linear-gradient(45deg, #2196F3, #1976D2);
    color: white;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.3);
}

.btn:active {
    transform: translateY(0);
}

.instructions {
    background: #f5f5f5;
    padding: 15px;
    border-radius: 10px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.instructions h3 {
    margin-bottom: 15px;
    color: #333;
    text-align: center;
}

.instruction-item {
    margin-bottom: 10px;
}

.instruction-item strong {
    color: #2196F3;
    display: block;
    margin-bottom: 5px;
}

.instruction-item p {
    font-size: 0.9rem;
    color: #666;
    line-height: 1.4;
}

.mobile-controls {
    display: none;
    padding: 10px;
    background: rgba(255, 255, 255, 0.9);
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 100;
    border-top: 1px solid #ddd;
}

.control-btn {
    width: 100%;
    height: 50px;
    font-size: 1.2rem;
    font-weight: bold;
    border: none;
    border-radius: 8px;
    background: linear-gradient(45deg, #FF9800, #F57C00);
    color: white;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.control-btn:active {
    transform: scale(0.95);
    background: linear-gradient(45deg, #F57C00, #E65100);
}

/* Responsive Design */
@media (max-width: 768px) {
    .game-container {
        padding: 10px;
        max-width: 100%;
        margin-bottom: 80px;
    }
    
    .game-header h1 {
        font-size: 1.8rem;
        margin-bottom: 10px;
    }
    
    .score-container {
        gap: 10px;
        margin-bottom: 15px;
    }
    
    .score-item {
        padding: 6px 12px;
        min-width: 80px;
    }
    
    .score-item .value {
        font-size: 1.2rem;
    }
    
    .game-main {
        flex-direction: column-reverse;
    }
    
    .game-sidebar {
        width: 100%;
        max-width: 100%;
        margin-bottom: 15px;
    }
    
    #gameCanvas {
        width: 100%;
        max-width: 100%;
        height: auto;
        aspect-ratio: 1/2;
    }
    
    .mobile-controls {
        display: grid;
        grid-template-columns: 1fr 1fr 1fr;
        grid-template-rows: auto auto;
        gap: 10px;
    }
    
    #rotateBtn {
        grid-column: 2;
        grid-row: 1;
    }
    
    #dropBtn {
        grid-column: 3;
        grid-row: 1;
    }
    
    #leftBtn {
        grid-column: 1;
        grid-row: 2;
    }
    
    #downBtn {
        grid-column: 2;
        grid-row: 2;
    }
    
    #rightBtn {
        grid-column: 3;
        grid-row: 2;
    }
    
    .instructions .instruction-item:last-child {
        display: block;
    }
    
    .instructions .instruction-item:first-child {
        display: none;
    }
}

@media (max-width: 480px) {
    .game-header h1 {
        font-size: 1.5rem;
    }
    
    .score-item {
        padding: 5px 10px;
        min-width: 70px;
    }
    
    .score-item .label {
        font-size: 0.8rem;
    }
    
    .score-item .value {
        font-size: 1rem;
    }
    
    .control-btn {
        height: 45px;
        font-size: 1rem;
    }
}

@media (min-width: 769px) {
    .mobile-controls {
        display: none !important;
    }
    
    .instructions .instruction-item:last-child {
        display: none;
    }
    
    .instructions .instruction-item:first-child {
        display: block;
    }
}