/* Responsive Design for Tetris Game */

/* Tablets and smaller desktops */
@media screen and (max-width: 768px) {
    body {
        padding: 10px;
    }
    
    #game-container {
        padding: 15px;
        transform: scale(0.9);
    }
    
    #game-area {
        gap: 15px;
    }
    
    #side-panel {
        min-width: 180px;
        padding: 12px;
    }
    
    #next-piece-container h3 {
        font-size: 16px;
    }
    
    .score-item {
        font-size: 14px;
        padding: 6px 10px;
    }
    
    .label {
        font-size: 12px;
    }
    
    .score-value {
        font-size: 16px;
    }
}

/* Mobile phones */
@media screen and (max-width: 480px) {
    body {
        padding: 5px;
        justify-content: flex-start;
        padding-top: 20px;
    }
    
    #game-container {
        padding: 10px;
        transform: scale(0.8);
        margin-bottom: 120px; /* Space for mobile controls */
    }
    
    #game-area {
        flex-direction: column;
        gap: 10px;
        align-items: center;
    }
    
    #side-panel {
        width: 100%;
        max-width: 300px;
        display: flex;
        flex-direction: row;
        justify-content: space-between;
        align-items: flex-start;
        gap: 15px;
        padding: 10px;
    }
    
    #next-piece-container {
        flex: 1;
        margin-bottom: 0;
    }
    
    #next-piece-container h3 {
        font-size: 14px;
        margin-bottom: 5px;
    }
    
    #next-piece-canvas {
        width: 80px;
        height: 80px;
    }
    
    #score-container {
        flex: 2;
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }
    
    .score-item {
        font-size: 12px;
        padding: 4px 8px;
        flex-direction: column;
        align-items: center;
        text-align: center;
    }
    
    .label {
        font-size: 10px;
        margin-bottom: 2px;
    }
    
    .score-value {
        font-size: 14px;
    }
    
    /* Show mobile controls */
    #mobile-controls {
        display: flex !important;
    }
    
    .control-button {
        width: 50px;
        height: 50px;
        font-size: 20px;
    }
    
    /* Menu adjustments */
    #menu-container, #game-over-container {
        min-width: 280px;
        padding: 20px;
        margin: 10px;
    }
    
    #menu-container h1, #game-over-container h2 {
        font-size: 24px;
        margin-bottom: 20px;
    }
    
    button {
        padding: 10px 20px;
        font-size: 14px;
        margin: 5px;
    }
    
    #pause-message {
        padding: 20px;
        margin: 10px;
    }
    
    #pause-message h2 {
        font-size: 20px;
    }
    
    #pause-message p {
        font-size: 14px;
    }
}

/* Very small mobile phones */
@media screen and (max-width: 360px) {
    #game-container {
        transform: scale(0.7);
    }
    
    #side-panel {
        flex-direction: column;
        align-items: center;
    }
    
    #score-container {
        grid-template-columns: 1fr;
        width: 100%;
    }
    
    .control-button {
        width: 45px;
        height: 45px;
        font-size: 18px;
    }
}

/* Landscape orientation for mobile */
@media screen and (max-height: 600px) and (orientation: landscape) {
    body {
        padding: 5px;
    }
    
    #game-container {
        transform: scale(0.7);
        padding: 10px;
    }
    
    #game-area {
        gap: 10px;
    }
    
    #side-panel {
        min-width: 150px;
        padding: 8px;
    }
    
    #next-piece-container h3 {
        font-size: 12px;
    }
    
    #next-piece-canvas {
        width: 60px;
        height: 60px;
    }
    
    .score-item {
        font-size: 11px;
        padding: 4px 6px;
    }
    
    .label {
        font-size: 9px;
    }
    
    .score-value {
        font-size: 12px;
    }
    
    #mobile-controls {
        bottom: 10px;
    }
    
    .control-button {
        width: 40px;
        height: 40px;
        font-size: 16px;
    }
}

/* High DPI displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    #game-canvas, #next-piece-canvas {
        image-rendering: crisp-edges;
        image-rendering: pixelated;
    }
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
    button:hover {
        transform: none;
        background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    }
    
    .control-button:hover {
        transform: none;
        background: rgba(255, 255, 255, 0.9);
        color: #667eea;
    }
    
    .score-item:hover {
        background: rgba(255, 255, 255, 0.1);
    }
}

/* Reduced motion preferences */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    button:hover {
        transform: none;
    }
    
    .control-button:hover {
        transform: none;
    }
    
    .pulse {
        animation: none;
    }
    
    .fade-in {
        animation: none;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    #menu-container, #game-over-container {
        background: rgba(30, 30, 30, 0.95);
        color: #fff;
    }
    
    #menu-container h1, #game-over-container h2, #high-scores h2 {
        color: #fff;
    }
    
    #scores-list li {
        color: #fff;
        background: rgba(102, 126, 234, 0.2);
    }
    
    #pause-message {
        background: rgba(30, 30, 30, 0.95);
        color: #fff;
    }
    
    #pause-message h2 {
        color: #fff;
    }
    
    #pause-message p {
        color: #ccc;
    }
    
    #game-over p {
        color: #ccc;
    }
}

/* Print styles */
@media print {
    body {
        background: white;
    }
    
    #game-container {
        background: white;
        box-shadow: none;
    }
    
    #mobile-controls,
    #pause-overlay {
        display: none !important;
    }
    
    button {
        display: none;
    }
}