/* ═══════════════════════════════════════════════════════════════════════════
   09-RESPONSIVE.CSS
   Mystery Temple - Galaxy Edition
   
   Mobile, tablet, and desktop breakpoints.
   ═══════════════════════════════════════════════════════════════════════════ */


/* ╔═══════════════════════════════════════════════════════════════════════════╗
   ║  TABLET BREAKPOINT (max-width: 900px)                                     ║
   ╚═══════════════════════════════════════════════════════════════════════════╝ */

@media (max-width: 900px) {
    /* Panels */
    .stats-panel,
    .level-panel {
        padding: var(--spacing-sm) var(--spacing-md);
    }

    .level-progress-bar {
        width: 100px;
    }

    .letters-panel,
    .heart-progress-panel {
        min-width: 130px;
    }

    .gem-counter-panel {
        padding: var(--spacing-sm);
    }

    /* Story Panel */
    .story-panel {
        padding: var(--spacing-sm) var(--spacing-lg);
        font-size: var(--font-sm);
    }

    /* Mobile Controls */
    .control-btn {
        width: 58px;
        height: 58px;
        font-size: 1.3em;
    }

    .control-btn.jump-btn {
        width: 72px;
        height: 72px;
        font-size: 1.6em;
    }

    .control-btn.slide-btn {
        width: 62px;
        height: 62px;
    }

    /* Chase Progress */
    .chase-progress {
        width: 240px;
        padding: var(--spacing-sm) var(--spacing-md);
    }

    /* Credits */
    .credits-title {
        font-size: 2em;
    }

    .credits-tech-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: var(--spacing-md);
    }
}


/* ╔═══════════════════════════════════════════════════════════════════════════╗
   ║  MOBILE BREAKPOINT (max-width: 600px)                                     ║
   ╚═══════════════════════════════════════════════════════════════════════════╝ */

@media (max-width: 600px) {
    /* Root adjustments */
    :root {
        --hud-padding: 8px;
        --spacing-lg: 12px;
        --spacing-xl: 18px;
    }

    /* HUD Layout */
    .game-hud {
        padding: var(--spacing-sm);
    }

    .hud-top {
        gap: var(--spacing-sm);
    }

    .hud-middle {
        padding: var(--spacing-sm) 0;
    }

    /* Stats Panel */
    .stats-panel {
        padding: var(--spacing-xs) var(--spacing-sm);
        gap: var(--spacing-sm);
    }

    .stat-item {
        min-width: 40px;
    }

    .stat-icon {
        font-size: 1em;
    }

    .stat-value {
        font-size: 0.95em;
    }

    .stat-label {
        display: none; /* Hide labels on mobile */
    }

    /* Lives Panel */
    .lives-panel {
        padding: var(--spacing-xs) var(--spacing-sm);
    }

    .life-heart {
        font-size: 1.2em;
    }

    .lives-text {
        font-size: var(--font-xs);
    }

    /* Level Panel */
    .level-panel {
        padding: var(--spacing-xs) var(--spacing-sm);
        min-width: 90px;
    }

    .level-title {
        font-size: var(--font-xs);
    }

    .level-progress-bar {
        width: 80px;
        height: 6px;
    }

    /* Gem Counter */
    .gem-counter-panel {
        padding: var(--spacing-xs);
    }

    .gem-count-item {
        padding: var(--spacing-xs) var(--spacing-sm);
        gap: var(--spacing-xs);
    }

    .gem-count-item .gem-label {
        display: none; /* Hide labels */
    }

    /* Letters Panel */
    .letters-panel {
        padding: var(--spacing-sm);
        min-width: 120px;
    }

    .letters-title {
        font-size: var(--font-xs);
    }

    .letter-slot {
        width: 26px;
        height: 32px;
        font-size: 0.95em;
    }

    /* Heart Progress */
    .heart-progress-panel {
        padding: var(--spacing-sm);
        min-width: 130px;
    }

    .heart-progress-icon {
        font-size: 0.8em;
    }

    .heart-progress-bar {
        height: 5px;
    }

    .heart-progress-text {
        font-size: var(--font-xs);
        min-width: 36px;
    }

    /* Chase Progress */
    .chase-progress {
        width: 220px;
        padding: var(--spacing-sm) var(--spacing-md);
        border-radius: var(--radius-lg);
    }

    .chase-progress h4 {
        font-size: var(--font-xs);
        margin-bottom: var(--spacing-xs);
    }

    .chase-bar {
        height: 10px;
    }

    .chase-distance {
        font-size: var(--font-xs);
    }

    /* Story Panel */
    .story-panel {
        padding: var(--spacing-sm) var(--spacing-md);
        font-size: var(--font-sm);
        max-width: 95%;
    }

    .hud-bottom {
        padding-bottom: 90px;
    }

    /* Speed Indicator */
    .speed-indicator {
        padding: var(--spacing-xs) var(--spacing-sm);
        font-size: var(--font-xs);
    }

    /* Mobile Controls */
    .mobile-controls {
        padding: var(--spacing-sm);
    }

    .control-group {
        gap: var(--spacing-sm);
    }

    .control-btn {
        width: 52px;
        height: 52px;
        font-size: 1.2em;
        border-width: 2px;
    }

    .control-btn.jump-btn {
        width: 66px;
        height: 66px;
        font-size: 1.5em;
    }

    .control-btn.slide-btn {
        width: 56px;
        height: 56px;
    }

    .control-btn.direction-btn {
        width: 50px;
        height: 50px;
    }

    /* Countdown */
    .countdown-big {
        font-size: 8em;
    }

    .countdown-go {
        font-size: 6em;
    }

    .countdown-text-big {
        font-size: 1.2em;
    }

    /* Overlays */
    .overlay {
        padding: var(--spacing-sm);
    }

    .overlay-content {
        padding: var(--spacing-lg);
        max-height: 95vh;
    }

    .overlay h2 {
        font-size: 1.5em;
        letter-spacing: 2px;
    }

    .title-icon {
        font-size: 2.5em;
    }

    /* Buttons */
    .btn {
        padding: var(--spacing-md) var(--spacing-xl);
        font-size: 0.95em;
    }

    /* Gesture Modal */
    .gesture-modal-content {
        padding: var(--spacing-md);
        max-height: 95vh;
    }

    .camera-container {
        height: 200px;
    }

    .gesture-target {
        font-size: 3em;
    }

    /* Hacking Terminal */
    .hack-terminal {
        padding: var(--spacing-md);
        width: 98%;
    }

    .hack-lines {
        max-height: 150px;
        font-size: var(--font-xs);
    }

    /* Morse Code */
    .morse-content {
        padding: var(--spacing-md);
    }

    .morse-text {
        font-size: var(--font-md);
        letter-spacing: 2px;
    }

    /* Cipher */
    .cipher-translation-container {
        padding: var(--spacing-md);
    }

    .cipher-header-icon {
        font-size: 2.5em;
    }

    .cipher-header-title {
        font-size: 1.1em;
    }

    .cipher-status-bar {
        padding: var(--spacing-xs);
    }

    .cipher-status-item {
        font-size: 0.55em;
        min-width: 40px;
    }

    .cipher-status-dot {
        width: 10px;
        height: 10px;
    }

    .cipher-keyboard-grid {
        gap: 3px;
    }

    .cipher-key {
        width: 24px;
        height: 30px;
        font-size: var(--font-xs);
    }

    .cipher-gesture-btn {
        width: 40px;
        height: 40px;
        font-size: 1.2em;
    }

    /* Temple Wall */
    .temple-wall-scene {
        height: 50vh;
        grid-template-columns: 0.5fr 4fr 0.5fr;
    }

    .temple-wall-panel {
        padding: var(--spacing-md);
    }

    .temple-wall-engraving-line {
        font-size: var(--font-md);
    }

    .temple-wall-engraving-line.sinhala {
        font-size: 0.9em;
    }

    .temple-continue-btn {
        padding: var(--spacing-sm) var(--spacing-xl);
        font-size: var(--font-sm);
    }

    /* Credits */
    .credits-title {
        font-size: 1.5em;
        letter-spacing: 4px;
    }

    .credits-subtitle {
        font-size: var(--font-md);
    }

    .credits-tech-grid {
        grid-template-columns: 1fr 1fr;
        gap: var(--spacing-sm);
    }

    .tech-item {
        padding: var(--spacing-sm);
    }

    .tech-icon {
        font-size: 1.5em;
    }

    .creator-section .main-creator {
        font-size: 1.5em;
    }

    .skip-btn {
        bottom: var(--spacing-md);
        right: var(--spacing-md);
        padding: var(--spacing-xs) var(--spacing-md);
    }

    /* Glitch */
    .glitch-text {
        font-size: var(--font-xl);
    }

    .glitch-progress-container {
        width: 250px;
    }

    /* Final Goodbye */
    .goodbye-icon {
        font-size: 4em;
    }

    .goodbye-text {
        font-size: var(--font-xl);
    }

    /* Boost Popup */
    .boost-popup {
        padding: var(--spacing-md) var(--spacing-lg);
    }

    .boost-popup-icon {
        font-size: 2em;
    }

    .boost-popup-text {
        font-size: 1.1em;
    }

    /* Revival */
    .revival-heart {
        font-size: 4em;
    }

    .revival-text {
        font-size: var(--font-xl);
    }
}


/* ╔═══════════════════════════════════════════════════════════════════════════╗
   ║  EXTRA SMALL SCREENS (max-width: 380px)                                   ║
   ╚═══════════════════════════════════════════════════════════════════════════╝ */

@media (max-width: 380px) {
    .stats-panel {
        gap: var(--spacing-xs);
    }

    .stat-item {
        min-width: 35px;
    }

    .stat-icon {
        font-size: 0.9em;
    }

    .stat-value {
        font-size: 0.85em;
    }

    .level-panel {
        min-width: 75px;
    }

    .level-progress-bar {
        width: 65px;
    }

    .control-btn {
        width: 46px;
        height: 46px;
        font-size: 1em;
    }

    .control-btn.jump-btn {
        width: 58px;
        height: 58px;
        font-size: 1.3em;
    }

    .control-btn.slide-btn {
        width: 50px;
        height: 50px;
    }

    .countdown-big {
        font-size: 6em;
    }

    .gesture-target {
        font-size: 2.5em;
    }

    .cipher-key {
        width: 22px;
        height: 28px;
    }

    .temple-wall-scene {
        height: 45vh;
    }

    .temple-wall-engraving-line {
        font-size: var(--font-sm);
    }

    .temple-wall-engraving-line.sinhala {
        font-size: 0.8em;
    }
}


/* ╔═══════════════════════════════════════════════════════════════════════════╗
   ║  LANDSCAPE MOBILE                                                         ║
   ╚═══════════════════════════════════════════════════════════════════════════╝ */

@media (max-height: 500px) and (orientation: landscape) {
    .game-hud {
        padding: var(--spacing-xs);
    }

    .hud-top {
        flex-wrap: nowrap;
    }

    .lives-panel {
        flex-direction: row;
        gap: var(--spacing-sm);
    }

    .hud-bottom {
        padding-bottom: 70px;
    }

    .story-panel {
        padding: var(--spacing-xs) var(--spacing-md);
        font-size: var(--font-xs);
    }

    .mobile-controls {
        padding: var(--spacing-xs);
    }

    .control-btn {
        width: 50px;
        height: 50px;
    }

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

    .countdown-big {
        font-size: 5em;
    }

    .overlay-content {
        padding: var(--spacing-md);
        max-height: 98vh;
    }

    .title-icon {
        font-size: 2em;
        margin-bottom: var(--spacing-sm);
    }

    .overlay h2 {
        font-size: 1.3em;
        margin-bottom: var(--spacing-sm);
    }
}


/* ╔═══════════════════════════════════════════════════════════════════════════╗
   ║  LARGE SCREENS (min-width: 1200px)                                        ║
   ╚═══════════════════════════════════════════════════════════════════════════╝ */

@media (min-width: 1200px) {
    .stats-panel,
    .level-panel {
        padding: var(--spacing-md) var(--spacing-xl);
    }

    .stat-value {
        font-size: 1.2em;
    }

    .level-progress-bar {
        width: 150px;
    }

    .letters-panel,
    .heart-progress-panel {
        min-width: 180px;
    }

    .story-panel {
        font-size: 1.1em;
        padding: var(--spacing-lg) var(--spacing-2xl);
    }

    .chase-progress {
        width: 320px;
    }

    .overlay-content {
        max-width: 550px;
        padding: var(--spacing-2xl) var(--spacing-3xl);
    }

    .cipher-translation-container {
        max-width: 580px;
    }

    .temple-wall-scene {
        height: 70vh;
        max-height: 500px;
    }
}


/* ╔═══════════════════════════════════════════════════════════════════════════╗
   ║  REDUCED MOTION PREFERENCE                                                ║
   ╚═══════════════════════════════════════════════════════════════════════════╝ */

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }

    .magic-particle,
    .shooting-star,
    .matrix-col,
    .credits-matrix-col {
        display: none !important;
    }
}


/* ╔═══════════════════════════════════════════════════════════════════════════╗
   ║  PERFORMANCE OPTIMIZATIONS                                                ║
   ╚═══════════════════════════════════════════════════════════════════════════╝ */

.btn,
.overlay-content,
.camera-container,
#gameCanvas,
.temple-wall-panel,
.control-btn {
    transform: translateZ(0);
    will-change: transform;
}

.overlay-content,
.cipher-translation-container,
.hack-lines,
.final-morse-list,
.morse-display {
    -webkit-overflow-scrolling: touch;
}


/* ╔═══════════════════════════════════════════════════════════════════════════╗
   ║  HIGH CONTRAST MODE                                                       ║
   ╚═══════════════════════════════════════════════════════════════════════════╝ */

@media (prefers-contrast: high) {
    :root {
        --color-primary: #00ff00;
        --color-secondary: #00ffff;
        --color-danger: #ff0000;
        --text-primary: #ffffff;
        --border-primary: #00ff00;
    }

    .btn {
        border-width: 3px;
    }

    .overlay-content {
        border-width: 4px;
    }
}