/* Responsive Design and Media Queries */

/* Game screen container - let JS handle sizing */
#game-screen.active {
    overflow: hidden;
    position: relative;
    width: 100%;
    height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* Mobile adjustments */
@media (max-width: 1023px) {
    body {
        overflow: hidden;
        margin: 0;
        padding: 0;
    }

    #game-canvas {
        /* Let JavaScript set the size - don't override with !important */
        display: block;
        margin: 0 auto;
    }

    #game-screen {
        padding: 0;
    }

    .mobile-controls {
        display: block !important;
    }
}

/* Desktop: Full canvas, keyboard controls */
@media (min-width: 1024px) {
    #game-canvas {
        width: 100%;
        max-width: 1200px;
        height: auto;
    }

    .mobile-controls {
        display: none !important;
    }
}

/* Tablet Landscape / Large Mobile: Touch controls, optimized layout */
@media (min-width: 768px) and (max-width: 1023px) and (orientation: landscape) {
    #game-canvas {
        width: 100%;
        height: auto;
    }

    .mobile-controls {
        display: block;
    }
}

/* Mobile Landscape: Compact UI, prominent touch controls */
@media (max-width: 767px) and (orientation: landscape) {
    body {
        font-size: 14px;
    }

    #game-canvas {
        width: 100%;
        height: calc(100vh - 60px);
    }

    .mobile-controls {
        display: block;
    }

    .hud {
        font-size: 0.9em;
        padding: 0.5rem 1rem;
    }

    /* Compact intro screen for mobile landscape */
    .intro-container {
        padding: var(--spacing-md);
    }

    .game-title {
        font-size: 2rem;
        margin-bottom: 0.5rem;
    }

    .game-subtitle {
        font-size: 0.9rem;
        margin-bottom: var(--spacing-sm);
    }

    .features {
        gap: 0.5rem;
        margin-bottom: var(--spacing-md);
    }

    .feature {
        font-size: 0.9rem;
        padding: 0.5rem;
    }

    .intro-form {
        gap: var(--spacing-sm);
    }

    .intro-form input {
        padding: 0.6rem 0.8rem;
        font-size: 0.9rem;
    }

    .intro-form .btn-primary {
        padding: 0.8rem 1.5rem;
        font-size: 1rem;
    }

    .tutorial-hint {
        padding: var(--spacing-sm);
        margin-top: var(--spacing-sm);
    }

    .tutorial-hint p {
        font-size: 0.85rem;
    }
}

/* Mobile Portrait: PRIMARY MODE */
@media (max-width: 767px) and (orientation: portrait) {
    /* Portrait is now the default - no blocking */
    body {
        overflow: hidden;
        touch-action: none; /* Prevent pull-to-refresh */
    }

    #game-canvas {
        /* JavaScript handles sizing - don't override */
        display: block;
    }

    .mobile-controls {
        display: block !important;
        position: fixed;
        bottom: 10px;
        left: 0;
        right: 0;
    }

    .control-btn {
        min-width: 70px;
        min-height: 70px;
        font-size: 1.8rem;
        border-width: 3px;
    }

    .control-btn-jump {
        min-width: 120px;
        min-height: 80px;
        font-size: 1.3rem;
    }

    .hud {
        font-size: 0.85rem;
        padding: 0.5rem;
        position: fixed;
        top: 0;
    }
}

/* Very small screens */
@media (max-width: 480px) and (orientation: landscape) {
    .control-btn {
        min-width: 45px;
        min-height: 45px;
        font-size: 1rem;
    }

    .control-btn-jump {
        min-width: 70px;
        min-height: 55px;
        font-size: 0.9rem;
    }

    .hud {
        font-size: 0.8rem;
        padding: 0.3rem 0.8rem;
    }

    #lives-display {
        font-size: 0.9rem;
    }
}

/* Tablet Portrait: Also supported */
@media (min-width: 768px) and (max-width: 1023px) and (orientation: portrait) {
    /* Portrait is fully supported */
    #game-canvas {
        width: 100vw !important;
        height: 100vh !important;
    }
}

/* High DPI displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    #game-canvas {
        image-rendering: -webkit-optimize-contrast;
        image-rendering: crisp-edges;
    }
}

/* Reduce motion for accessibility */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Dark mode support (already dark, but in case system prefers light) */
@media (prefers-color-scheme: light) {
    /* Game is intentionally dark themed, no changes needed */
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
    /* Larger tap targets */
    .btn-primary {
        min-height: 48px;
        padding: 1rem 2rem;
    }

    input[type="text"],
    input[type="email"],
    textarea {
        min-height: 44px;
        font-size: 16px; /* Prevents zoom on iOS */
    }

    .option-label {
        min-height: 44px;
    }

    .control-btn {
        min-width: 60px;
        min-height: 60px;
    }

    /* Remove hover effects on touch devices */
    .feature:hover,
    .stat-box:hover,
    .leaderboard-entry:hover {
        transform: none;
    }
}

/* Landscape orientation detection for all devices */
@media (orientation: landscape) {
    #rotate-message {
        display: none;
    }
}

/* Very wide screens */
@media (min-width: 1920px) {
    .intro-container,
    .results-container {
        max-width: 1000px;
    }

    #game-canvas {
        max-width: 1600px;
    }
}

/* Safe area insets for notched devices */
@supports (padding: env(safe-area-inset-left)) {
    .hud {
        padding-left: max(var(--spacing-md), env(safe-area-inset-left));
        padding-right: max(var(--spacing-md), env(safe-area-inset-right));
    }

    .mobile-controls .controls-left {
        left: max(var(--spacing-md), env(safe-area-inset-left));
    }

    .mobile-controls .controls-right {
        right: max(var(--spacing-md), env(safe-area-inset-right));
    }
}
