/**
 * Mobile & Responsive Styles
 */

/* ============================================
   TOUCH CONTROLS
   ============================================ */

#touchControls {
    display: none; /* Hidden by default, shown on mobile */
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 1000;
    touch-action: none;
}

.dpad {
    position: relative;
    width: 180px;
    height: 180px;
    display: grid;
    grid-template-columns: 60px 60px 60px;
    grid-template-rows: 60px 60px 60px;
    gap: 0;
}

.dpad-btn {
    background: rgba(255, 107, 53, 0.3);
    border: 2px solid var(--color-primary);
    color: var(--color-primary);
    font-size: 24px;
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
    transition: all 0.1s ease;
    box-shadow: 0 0 10px rgba(255, 107, 53, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
}

.dpad-btn:active,
.dpad-btn.active {
    background: rgba(255, 107, 53, 0.7);
    box-shadow: 0 0 20px rgba(255, 107, 53, 0.8);
    transform: scale(0.95);
}

.dpad-up {
    grid-column: 2;
    grid-row: 1;
    border-radius: 10px 10px 0 0;
}

.dpad-left {
    grid-column: 1;
    grid-row: 2;
    border-radius: 10px 0 0 10px;
}

.dpad-center {
    grid-column: 2;
    grid-row: 2;
    background: rgba(187, 134, 252, 0.3);
    border-color: var(--color-secondary);
    color: var(--color-secondary);
    font-size: 20px;
}

.dpad-center:active,
.dpad-center.active {
    background: rgba(187, 134, 252, 0.7);
    box-shadow: 0 0 20px rgba(187, 134, 252, 0.8);
}

.dpad-right {
    grid-column: 3;
    grid-row: 2;
    border-radius: 0 10px 10px 0;
}

.dpad-down {
    grid-column: 2;
    grid-row: 3;
    border-radius: 0 0 10px 10px;
}

/* ============================================
   RESPONSIVE LAYOUT
   ============================================ */

/* Tablet & Mobile Landscape */
@media (max-width: 1024px) {
    #gameContainer {
        padding: 10px;
    }

    #gameCanvas {
        max-width: 100%;
        height: auto;
    }

    #hud {
        flex-wrap: wrap;
        gap: 10px;
    }

    .hud-panel {
        min-width: 120px;
    }

    #missionPanel {
        max-width: 300px;
        font-size: 12px;
    }

    .legend {
        max-width: 400px;
        font-size: 13px;
    }
}

/* Mobile Portrait */
@media (max-width: 768px) {
    body {
        overflow: hidden;
    }

    #gameContainer {
        padding: 5px;
    }

    #gameCanvas {
        width: 100vw !important;
        height: auto !important;
        max-height: 60vh;
    }

    /* HUD Compact */
    #hud {
        flex-direction: row;
        justify-content: space-between;
        padding: 8px;
        gap: 5px;
        font-size: 12px;
    }

    .hud-panel {
        min-width: 80px;
        padding: 5px;
    }

    .hud-title {
        font-size: 10px;
    }

    .hud-value {
        font-size: 16px;
    }

    .hud-combo {
        font-size: 11px;
    }

    /* Mission Panel Mobile */
    #missionPanel {
        position: fixed;
        top: 60px;
        left: 5px;
        right: auto;
        max-width: 250px;
        font-size: 11px;
        padding: 8px;
    }

    .mission-title {
        font-size: 12px;
    }

    .mission-item {
        font-size: 10px;
        padding: 3px;
    }

    /* Power-ups Display Mobile */
    #powerupsDisplay {
        top: 60px;
        right: 5px;
        gap: 5px;
    }

    .powerup-icon {
        width: 35px;
        height: 35px;
        font-size: 18px;
    }

    /* Audio Controls Mobile */
    #audioControls {
        top: 10px;
        right: 10px;
        gap: 5px;
    }

    .audio-btn {
        width: 35px;
        height: 35px;
        font-size: 18px;
    }

    /* Neon Signs - Smaller on mobile */
    .neon-sign {
        font-size: 16px !important;
    }

    /* Start Screen Mobile */
    #startScreen h1 {
        font-size: 48px;
    }

    #startScreen h2 {
        font-size: 20px;
    }

    .legend {
        max-width: 90vw;
        font-size: 11px;
        padding: 10px;
    }

    .legend-title {
        font-size: 14px;
    }

    .legend-item {
        font-size: 11px;
        padding: 3px 0;
    }

    #startBtn,
    #restartBtn {
        font-size: 16px;
        padding: 12px 30px;
    }

    /* Game Over Screen Mobile */
    #gameOverScreen h2 {
        font-size: 28px;
    }

    .game-over-stat {
        font-size: 14px;
        margin: 8px 0;
    }

    /* Pause Menu Mobile */
    #pauseMenu {
        padding: 20px;
    }

    #pauseMenu h2 {
        font-size: 28px;
    }

    #pauseMenu p {
        font-size: 14px;
    }

    /* Show Touch Controls */
    #touchControls {
        display: flex;
        bottom: 10px;
        right: 10px;
    }

    /* Adjust dpad size for smaller screens */
    .dpad {
        width: 150px;
        height: 150px;
        grid-template-columns: 50px 50px 50px;
        grid-template-rows: 50px 50px 50px;
    }

    .dpad-btn {
        font-size: 20px;
    }
}

/* Small Mobile */
@media (max-width: 480px) {
    #gameCanvas {
        max-height: 50vh;
    }

    #hud {
        font-size: 10px;
    }

    .hud-value {
        font-size: 14px;
    }

    #missionPanel {
        max-width: 200px;
        font-size: 10px;
    }

    #startScreen h1 {
        font-size: 36px;
    }

    #startScreen h2 {
        font-size: 16px;
    }

    .legend {
        font-size: 10px;
    }

    /* Smaller D-Pad */
    .dpad {
        width: 130px;
        height: 130px;
        grid-template-columns: 43px 43px 43px;
        grid-template-rows: 43px 43px 43px;
    }

    .dpad-btn {
        font-size: 18px;
        border-width: 1.5px;
    }

    #touchControls {
        bottom: 5px;
        right: 5px;
    }
}

/* Landscape Mobile */
@media (max-width: 896px) and (orientation: landscape) {
    #gameCanvas {
        max-height: 70vh;
    }

    #hud {
        padding: 5px;
    }

    #missionPanel {
        top: 50px;
        font-size: 10px;
    }

    #touchControls {
        bottom: 10px;
        right: 10px;
    }

    .dpad {
        width: 120px;
        height: 120px;
        grid-template-columns: 40px 40px 40px;
        grid-template-rows: 40px 40px 40px;
    }

    .dpad-btn {
        font-size: 16px;
    }

    .neon-sign {
        font-size: 14px !important;
    }
}

/* Desktop - Hide Touch Controls */
@media (min-width: 769px) {
    #touchControls {
        display: none !important;
    }
}

/* Prevent zoom on double-tap */
button {
    touch-action: manipulation;
}

/* Smooth touch scrolling where needed */
.legend,
#missionsList {
    -webkit-overflow-scrolling: touch;
}
