/* ==================== MOBILE RESPONSIVE STYLES ==================== */

/* Mobile detection class */
body.mobile-device {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
}

/* Prevent scrolling on mobile */
body.mobile-device,
body.mobile-device #game {
    overflow: hidden;
    position: fixed;
    width: 100%;
    height: 100%;
}

/* ==================== MOBILE CONTROLS ==================== */

.mobile-controls {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    pointer-events: none !important;
    z-index: 1000 !important;
    display: none !important;
}

/* Show only on mobile */
body.mobile-device .mobile-controls {
    display: block !important;
}

/* ==================== JOYSTICKS ==================== */

.joystick-container {
    position: absolute;
    pointer-events: auto;
}

.left-joystick {
    bottom: 30px;
    left: 30px;
}

.right-joystick {
    bottom: 30px;
    right: 30px;
}

/* Touch Look Area (swipe to look/aim) */
.touch-look-area {
    position: absolute;
    top: 0;
    right: 0;
    width: 50%;
    height: 100%;
    pointer-events: auto;
    /* Semi-transparent overlay to show the touch area - can be removed for production */
    /* background: rgba(255, 0, 0, 0.1); */
}

.joystick-base {
    width: 120px;
    height: 120px;
    background: radial-gradient(circle, rgba(0, 212, 255, 0.3) 0%, rgba(0, 212, 255, 0.1) 100%);
    border: 3px solid rgba(0, 212, 255, 0.6);
    border-radius: 50%;
    position: relative;
    box-shadow: 0 0 30px rgba(0, 212, 255, 0.5), inset 0 0 20px rgba(0, 212, 255, 0.2);
    backdrop-filter: blur(5px);
}

.joystick-stick {
    width: 50px;
    height: 50px;
    background: linear-gradient(135deg, #00ffff, #00aaff);
    border: 3px solid rgba(255, 255, 255, 0.8);
    border-radius: 50%;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    box-shadow: 0 0 20px rgba(0, 255, 255, 0.8), 0 4px 15px rgba(0, 0, 0, 0.5), inset 0 2px 10px rgba(255, 255, 255, 0.3);
    transition: transform 0.05s;
}

.joystick-label {
    position: absolute;
    bottom: -25px;
    left: 50%;
    transform: translateX(-50%);
    color: rgba(255, 255, 255, 0.6);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 2px;
    font-family: 'Rajdhani', sans-serif;
}

/* ==================== ACTION BUTTONS ==================== */

.mobile-btn {
    background: linear-gradient(135deg, rgba(0, 212, 255, 0.4), rgba(0, 136, 255, 0.4));
    border: 3px solid rgba(0, 212, 255, 0.8);
    border-radius: 15px;
    color: white;
    font-family: 'Rajdhani', sans-serif;
    font-weight: 700;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    box-shadow: 0 0 20px rgba(0, 212, 255, 0.6), 0 4px 15px rgba(0, 0, 0, 0.4);
    pointer-events: auto;
    cursor: pointer;
    transition: all 0.1s;
    -webkit-tap-highlight-color: transparent;
    backdrop-filter: blur(5px);
}

.mobile-btn:active,
.mobile-btn.active {
    background: linear-gradient(135deg, rgba(0, 255, 255, 0.8), rgba(0, 200, 255, 0.8));
    transform: scale(0.95);
    box-shadow: 0 0 30px rgba(0, 255, 255, 0.9), 0 2px 10px rgba(0, 212, 255, 0.8);
    border-color: rgba(0, 255, 255, 1);
}

.btn-icon {
    font-size: 24px;
}

.btn-label {
    font-size: 10px;
    letter-spacing: 1px;
}

/* Action buttons group (right side) */
.action-buttons {
    position: absolute;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.action-buttons .mobile-btn {
    width: 70px;
    height: 70px;
}

/* Shoot button (large, bottom right) */
.shoot-button-container {
    position: absolute;
    right: 170px;
    bottom: 30px;
}

.shoot-btn {
    width: 100px;
    height: 100px;
}

.shoot-btn .btn-icon {
    font-size: 36px;
}

/* Pause button (top left) */
.pause-btn {
    position: absolute;
    top: 20px;
    left: 20px;
    width: 50px;
    height: 50px;
}

.pause-btn .btn-icon {
    font-size: 28px;
}

/* ==================== WEAPON SELECTOR (MOBILE) ==================== */

.mobile-weapon-selector {
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 8px;
    pointer-events: auto;
}

.mobile-weapon-btn {
    width: 50px;
    height: 50px;
    background: rgba(0, 0, 0, 0.5);
    border: 2px solid rgba(136, 146, 176, 0.3);
    border-radius: 10px;
    color: rgba(255, 255, 255, 0.6);
    font-family: 'Rajdhani', sans-serif;
    font-size: 20px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
}

.mobile-weapon-btn:active,
.mobile-weapon-btn.active {
    background: rgba(0, 212, 255, 0.3);
    border-color: var(--primary-color);
    color: var(--primary-color);
    box-shadow: 0 0 15px rgba(0, 212, 255, 0.4);
}

/* ==================== HUD ADJUSTMENTS FOR MOBILE ==================== */

@media (max-width: 768px), (orientation: landscape) and (max-height: 500px) {

    /* Scale down HUD elements */
    .hud-corner {
        font-size: 12px;
    }

    .health-container,
    .ammo-container {
        padding: 8px 12px;
    }

    .stat-label {
        font-size: 10px;
    }

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

    .stat-icon {
        font-size: 20px;
    }

    /* Leaderboard */
    .leaderboard {
        max-height: 200px;
        font-size: 11px;
    }

    .leaderboard-title {
        font-size: 12px;
        padding: 6px;
    }

    /* Minimap */
    .minimap-container {
        width: 120px;
        height: 120px;
    }

    .minimap-container canvas {
        width: 120px !important;
        height: 120px !important;
    }

    /* Kill feed */
    .kill-feed {
        font-size: 11px;
        max-width: 200px;
    }

    /* Chat */
    .chat-messages {
        max-height: 100px;
        font-size: 11px;
    }

    .chat-input-wrapper input {
        font-size: 12px;
        padding: 6px 10px;
    }

    /* Hide desktop weapon selector on mobile */
    body.mobile-device .weapon-selector {
        display: none;
    }

    /* Controls hint - hide on mobile */
    body.mobile-device .controls-hint {
        display: none;
    }

    /* Gold display - smaller */
    .gold-display {
        padding: 6px 10px;
    }

    /* Crosshair - smaller */
    .crosshair {
        width: 30px;
        height: 30px;
    }

    .crosshair-line {
        width: 12px;
        height: 2px;
    }

    /* Team scores - smaller */
    .team-scores {
        padding: 10px 15px;
        gap: 15px;
        font-size: 11px;
    }

    .team-score {
        padding: 6px 12px;
        gap: 8px;
    }

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

    .team-score-value {
        font-size: 24px;
    }

    /* Main menu adjustments */
    .game-title {
        font-size: 3em;
        letter-spacing: 5px;
    }

    .game-subtitle {
        font-size: 1.2em;
    }

    .btn-play {
        padding: 15px 40px;
        font-size: 18px;
    }

    /* Settings menu */
    body.mobile-device .settings-container {
        width: 95%;
        max-width: 500px;
        font-size: 13px;
    }

    /* Death screen */
    .death-title {
        font-size: 2.5em;
    }

    .death-stats {
        gap: 15px;
    }

    /* Pause menu */
    .pause-menu {
        width: 90%;
        max-width: 400px;
    }

    .btn-pause {
        padding: 12px 30px;
        font-size: 16px;
    }
}

/* ==================== LANDSCAPE MODE SPECIFIC ==================== */

@media (orientation: landscape) and (max-height: 500px) {

    /* Optimize for landscape */
    .hud-top-left,
    .hud-top-right {
        top: 10px;
    }

    .hud-bottom-left,
    .hud-bottom-right {
        bottom: 10px;
    }

    .left-joystick {
        bottom: 20px;
        left: 20px;
    }

    .right-joystick {
        bottom: 20px;
        right: 20px;
    }

    .shoot-button-container {
        right: 150px;
        bottom: 20px;
    }

    .action-buttons {
        right: 15px;
    }
}

/* ==================== PORTRAIT MODE WARNING ==================== */
/* DISABLED - Message stays even in landscape, causing issues */

/* ==================== VERY SMALL SCREENS ==================== */

@media (max-width: 480px) {

    .joystick-base {
        width: 100px;
        height: 100px;
    }

    .joystick-stick {
        width: 40px;
        height: 40px;
    }

    .action-buttons .mobile-btn {
        width: 60px;
        height: 60px;
    }

    .shoot-btn {
        width: 80px;
        height: 80px;
    }

    .mobile-weapon-btn {
        width: 45px;
        height: 45px;
        font-size: 18px;
    }

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

    .shoot-btn .btn-icon {
        font-size: 30px;
    }

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

/* ==================== TABLET ADJUSTMENTS ==================== */

@media (min-width: 481px) and (max-width: 768px) {

    /* Slightly larger controls for tablets */
    .joystick-base {
        width: 140px;
        height: 140px;
    }

    .joystick-stick {
        width: 60px;
        height: 60px;
    }

    .action-buttons .mobile-btn {
        width: 80px;
        height: 80px;
    }

    .shoot-btn {
        width: 110px;
        height: 110px;
    }
}

/* ==================== HIGH DPI SCREENS ==================== */

@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {

    /* Sharper borders and shadows */
    .mobile-btn,
    .joystick-base {
        border-width: 3px;
    }
}

/* ==================== TOUCH FEEDBACK ==================== */

.mobile-btn:active::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.3) 0%, transparent 70%);
    border-radius: inherit;
    transform: translate(-50%, -50%);
    animation: ripple 0.4s ease-out;
    pointer-events: none;
}

@keyframes ripple {
    0% {
        width: 0;
        height: 0;
        opacity: 1;
    }
    100% {
        width: 200%;
        height: 200%;
        opacity: 0;
    }
}

/* ==================== PERFORMANCE OPTIMIZATIONS ==================== */

body.mobile-device .mobile-controls * {
    -webkit-backface-visibility: hidden;
    -moz-backface-visibility: hidden;
    -webkit-transform: translate3d(0, 0, 0);
    -moz-transform: translate3d(0, 0, 0);
}

/* Disable hover effects on mobile */
body.mobile-device *:hover {
    /* No hover on mobile */
}

/* ==================== iOS SPECIFIC FIXES ==================== */

/* iOS Safari fixes */
body.ios-device {
    -webkit-text-size-adjust: none;
    text-size-adjust: none;
    -webkit-user-select: none;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    position: fixed;
    width: 100vw;
    height: 100vh;
    overflow: hidden;
}

body.ios-device #game {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    overflow: hidden;
}

body.ios-device #gameCanvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw !important;
    height: 100vh !important;
}

body.ios-device canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw !important;
    height: 100vh !important;
}

/* Prevent iOS bounce */
body.ios-device,
body.ios-device #game,
body.ios-device * {
    overscroll-behavior: none;
}

/* Force mobile controls to show on iOS */
body.ios-device .mobile-controls {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
}
