/* Responsive Design - Mobile-First Approach for All Devices */

/* Base mobile styles (default) */
* {
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -khtml-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

/* Allow text selection for specific elements */
input, textarea, .quiz-question, .instructions {
    -webkit-user-select: text;
    -moz-user-select: text;
    -ms-user-select: text;
    user-select: text;
}

/* Touch-friendly button sizing */
button, .game-card, .memory-card, .quiz-option, .key {
    min-height: 44px;
    min-width: 44px;
}

/* Large phones and small tablets (portrait) */
@media (max-width: 600px) {
    .container {
        padding: 10px;
        max-width: 100%;
    }

    h1 {
        font-size: 2.2em;
        margin-bottom: 15px;
        line-height: 1.2;
    }

    .stats-bar {
        flex-direction: column;
        gap: 8px;
        font-size: 0.9em;
    }

    /* Game grid - single column on small screens */
    .games-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }

    .game-card {
        padding: 20px 15px;
        margin-bottom: 10px;
    }

    .game-title {
        font-size: 1.3em;
    }

    .game-description {
        font-size: 0.9em;
        line-height: 1.4;
    }

    /* Game areas */
    .game-area {
        padding: 15px 10px;
    }

    .game-header {
        flex-direction: column;
        text-align: center;
        gap: 10px;
    }

    .game-info {
        justify-content: center;
        flex-wrap: wrap;
        gap: 15px;
    }

    .score, .timer, .rate {
        font-size: 1.1em;
        padding: 8px 15px;
    }

    /* Controls */
    .controls {
        flex-wrap: wrap;
        gap: 10px;
    }

    .btn {
        padding: 12px 20px;
        font-size: 1em;
        min-width: 120px;
    }

    /* Snake Game */
    #snakeCanvas {
        width: 100%;
        max-width: 350px;
        height: auto;
    }

    /* Memory Game */
    .memory-grid {
        grid-template-columns: repeat(4, 65px);
        gap: 8px;
        justify-content: center;
    }

    .memory-card {
        width: 65px;
        height: 65px;
        font-size: 1.6em;
    }

    /* Quiz Game */
    .quiz-question {
        font-size: 1.3em;
        padding: 20px 15px;
        min-height: 100px;
    }

    .quiz-options {
        gap: 12px;
    }

    .quiz-option {
        padding: 15px;
        font-size: 1em;
    }

    .setup-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }

    /* Clicker Game */
    .clicker-button {
        width: 220px;
        height: 220px;
        font-size: 2.2em;
    }

    .upgrades-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }

    .upgrade-card {
        padding: 15px;
    }

    /* Wordle Game */
    .wordle-container {
        padding: 15px;
    }

    .wordle-grid {
        max-width: 300px;
        gap: 4px;
    }

    .wordle-cell {
        width: 50px;
        height: 50px;
        font-size: 1.6em;
    }

    .wordle-keyboard {
        max-width: 100%;
    }

    .key {
        min-width: 35px;
        height: 48px;
        font-size: 11px;
        margin: 1px;
    }

    .key.wide {
        min-width: 55px;
    }

    /* Pong Game */
    #pongCanvas {
        width: 100%;
        max-width: 400px;
        height: auto;
    }

    .pong-instructions {
        padding: 15px;
        font-size: 0.9em;
    }

    /* Modals */
    .modal-content {
        width: 95%;
        margin: 10% auto;
        padding: 25px 15px;
        max-height: 80vh;
        overflow-y: auto;
    }

    .modal-score {
        flex-direction: column;
        gap: 10px;
        text-align: center;
    }

    /* Leaderboard */
    .leaderboard-tabs {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }

    .leaderboard-tab {
        padding: 10px 8px;
        font-size: 0.9em;
    }

    .leaderboard-content {
        padding: 15px;
    }

    /* Footer */
    .footer {
        padding: 20px 10px;
        font-size: 0.9em;
        text-align: center;
    }

    .footer p {
        margin-bottom: 8px;
    }
}

/* Very small phones (iPhone SE, etc.) */
@media (max-width: 375px) {
    h1 {
        font-size: 1.8em;
    }

    .container {
        padding: 8px;
    }

    .game-card {
        padding: 15px 10px;
    }

    .clicker-button {
        width: 180px;
        height: 180px;
        font-size: 1.8em;
    }

    .memory-grid {
        grid-template-columns: repeat(4, 55px);
    }

    .memory-card {
        width: 55px;
        height: 55px;
        font-size: 1.4em;
    }

    .wordle-cell {
        width: 42px;
        height: 42px;
        font-size: 1.4em;
    }

    .wordle-grid {
        max-width: 250px;
    }

    .key {
        min-width: 28px;
        height: 42px;
        font-size: 10px;
    }

    .key.wide {
        min-width: 45px;
    }

    .quiz-question {
        font-size: 1.1em;
        padding: 15px 10px;
    }

    .modal-content {
        width: 98%;
        margin: 5% auto;
        padding: 20px 10px;
    }
}

/* Tablets (portrait) */
@media (min-width: 601px) and (max-width: 768px) {
    .games-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 20px;
    }

    .memory-grid {
        grid-template-columns: repeat(4, 70px);
    }

    .memory-card {
        width: 70px;
        height: 70px;
        font-size: 1.8em;
    }

    .clicker-button {
        width: 250px;
        height: 250px;
        font-size: 2.4em;
    }

    .upgrades-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .wordle-cell {
        width: 55px;
        height: 55px;
        font-size: 1.8em;
    }

    .key {
        min-width: 40px;
        height: 50px;
        font-size: 12px;
    }

    .key.wide {
        min-width: 60px;
    }
}

/* Tablets (landscape) and small laptops */
@media (min-width: 769px) and (max-width: 1024px) {
    .games-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    .upgrades-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .leaderboard-tabs {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* Large screens */
@media (min-width: 1025px) {
    .games-grid {
        grid-template-columns: repeat(3, 1fr);
        max-width: 1200px;
        margin: 0 auto;
    }

    .upgrades-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    .container {
        max-width: 1200px;
        margin: 0 auto;
    }
}

/* Landscape orientation adjustments for phones */
@media (max-height: 500px) and (orientation: landscape) {
    h1 {
        font-size: 1.8em;
        margin-bottom: 10px;
    }

    .game-header {
        margin-bottom: 15px;
    }

    .clicker-button {
        width: 150px;
        height: 150px;
        font-size: 1.6em;
    }

    .modal-content {
        margin: 2% auto;
        max-height: 90vh;
    }

    .quiz-question {
        padding: 15px;
        min-height: 80px;
    }

    .memory-card {
        width: 50px;
        height: 50px;
        font-size: 1.2em;
    }

    .memory-grid {
        grid-template-columns: repeat(4, 50px);
        gap: 6px;
    }
}