/* ============================================
 * MOBILE D-PAD CONTROLLER COMPONENT
 * Reusable neon-style directional controller
 * ============================================ */

/* Old mobile-dpad-container styles - replaced by new layout */

/* Old mobile detection styles - replaced by new layout */

/* Mobile Controls Layout - Full Screen Bottom Container */
.mobile-controls-layout {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 25vh;
    /* Quarter of viewport height */
    min-height: 120px;
    max-height: 200px;
    display: none;
    background: rgba(15, 23, 42, 0.95);
    /*border-top: 2px solid rgba(59, 130, 246, 0.3);*/
    backdrop-filter: blur(10px);
    z-index: 1000;
    pointer-events: auto;
}

@media (max-width: 768px) and (pointer: coarse) {
    .mobile-controls-layout {
        display: flex;
    }

    /* Hide by default, show only when game is running */
    .mobile-controls-layout {
        display: none;
    }

    .mobile-controls-layout.game-running {
        display: flex !important;
    }
}

/* Left half - Action buttons */
.mobile-left-controls {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px;
    /*border-right: 1px solid rgba(59, 130, 246, 0.2);*/
}

/* Right half - D-pad container */
.mobile-dpad-container {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px;
    pointer-events: auto;
    z-index: 1000;
}

.mobile-dpad {
    width: 100%;
    max-width: 180px;
    aspect-ratio: 1;
    /* Maintain square ratio */
    position: relative;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
}

/* D-pad base structure */
.dpad-base {
    width: 100%;
    height: 100%;
    position: relative;
    background: radial-gradient(circle at center, rgba(59, 130, 246, 0.1), rgba(15, 23, 42, 0.9));
    border-radius: 50%;
    border: 2px solid rgba(59, 130, 246, 0.3);
    box-shadow:
        0 0 20px rgba(59, 130, 246, 0.2),
        inset 0 0 20px rgba(15, 23, 42, 0.5);
}

/* Individual D-pad buttons */
.dpad-btn {
    position: absolute;
    width: 50px;
    height: 50px;
    padding: 0;
    background: linear-gradient(145deg, rgba(59, 130, 246, 0.15), rgba(16, 185, 129, 0.1));
    border: 2px solid rgba(59, 130, 246, 0.4);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(241, 245, 249, 0.7);
    font-size: 1.2rem;
    font-weight: 700;
    text-shadow: 0 0 10px currentColor;
    box-shadow:
        0 0 15px rgba(59, 130, 246, 0.2),
        inset 0 0 10px rgba(15, 23, 42, 0.3);
    cursor: pointer;
    transition: all 0.15s ease;
    backdrop-filter: blur(10px);
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

/* Button positions - spread out more */
.dpad-btn.up {
    top: -10px;
    left: 50%;
    transform: translateX(-50%);
    height: 60px;
}

.dpad-btn.down {
    bottom: -10px;
    left: 50%;
    transform: translateX(-50%);
    height: 60px;
}

.dpad-btn.left {
    left: -10px;
    top: 50%;
    transform: translateY(-50%);
    width: 60px;
}

.dpad-btn.right {
    right: -10px;
    top: 50%;
    transform: translateY(-50%);
    width: 60px;
}

/* Button icons using SVG arrows */
.dpad-btn {
    color: #10b981;
}

.dpad-btn svg {
    width: 1.4rem;
    height: 1.4rem;
    pointer-events: none;
}

/* Active/pressed state */
.dpad-btn.active,
.dpad-btn:active {
    transform: translateX(-50%) scale(0.95);
    background: linear-gradient(145deg, rgba(16, 185, 129, 0.3), rgba(59, 130, 246, 0.2));
    border-color: rgba(16, 185, 129, 0.6);
    color: rgba(16, 185, 129, 1);
    box-shadow:
        0 0 25px rgba(16, 185, 129, 0.4),
        inset 0 0 15px rgba(16, 185, 129, 0.1);
}

.dpad-btn.down.active,
.dpad-btn.down:active {
    transform: translateX(-50%) scale(0.95);
}

.dpad-btn.left.active,
.dpad-btn.left:active {
    transform: translateY(-50%) scale(0.95);
}

.dpad-btn.right.active,
.dpad-btn.right:active {
    transform: translateY(-50%) scale(0.95);
}

/* Pause button on left side */
.mobile-pause-btn {
    padding: 5px;
    width: 80px;
    height: 80px;
    background: radial-gradient(circle at center, rgba(59, 130, 246, 0.15), rgba(15, 23, 42, 0.9));
    border: 2px solid rgba(59, 130, 246, 0.4);
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(241, 245, 249, 0.7);
    font-size: 1.8rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.15s ease;
    backdrop-filter: blur(10px);
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    box-shadow:
        0 0 20px rgba(59, 130, 246, 0.3),
        inset 0 0 15px rgba(15, 23, 42, 0.3);
}

.mobile-pause-btn:hover,
.mobile-pause-btn:active {
    background: radial-gradient(circle, rgba(59, 130, 246, 0.25), rgba(16, 185, 129, 0.1));
    border-color: rgba(59, 130, 246, 0.6);
    color: rgba(59, 130, 246, 1);
    box-shadow:
        0 0 25px rgba(59, 130, 246, 0.4),
        inset 0 0 15px rgba(59, 130, 246, 0.1);
    transform: scale(0.95);
}

.mobile-pause-btn svg {
    width: 2rem;
    height: 2rem;
    pointer-events: none;
}


/* Responsive adjustments */
@media (max-width: 480px) {
    .mobile-controls-layout {
        height: 20vh;
        min-height: 200px;
        max-height: 250px;
    }

    .mobile-dpad {
        max-width: 140px;
    }

    .dpad-btn {
        width: 45px;
        height: 45px;
        font-size: 1.1rem;
    }

    .mobile-pause-btn {
        width: 60px;
        height: 60px;
        font-size: 1.4rem;
    }

    .mobile-pause-btn svg {
        width: 1.6rem;
        height: 1.6rem;
    }

    .dpad-btn svg {
        width: 1.1rem;
        height: 1.1rem;
    }


    .mobile-left-controls,
    .mobile-dpad-container {
        padding: 5px;
    }
}

/* Accessibility improvements */
.dpad-btn:focus {
    outline: 2px solid rgba(16, 185, 129, 0.5);
    outline-offset: 2px;
}

/* Prevent text selection on touch */
.mobile-dpad-container * {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
}

/* Enhanced button press feedback */
.dpad-btn:active,
.dpad-btn.active {
    color: rgba(16, 185, 129, 1);
}

.dpad-btn:active svg,
.dpad-btn.active svg {
    transform: scale(1.1);
    filter: drop-shadow(0 0 8px #10b981);
}

/* Vibration feedback class (optional) */
.dpad-btn.vibrate {
    animation: vibrate 0.1s ease-in-out;
}

@keyframes vibrate {

    0%,
    100% {
        transform: translateX(-50%);
    }

    25% {
        transform: translateX(-52%);
    }

    75% {
        transform: translateX(-48%);
    }
}

.dpad-btn.down.vibrate {
    animation: vibrate-down 0.1s ease-in-out;
}

@keyframes vibrate-down {

    0%,
    100% {
        transform: translateX(-50%);
    }

    25% {
        transform: translateX(-52%);
    }

    75% {
        transform: translateX(-48%);
    }
}

.dpad-btn.left.vibrate {
    animation: vibrate-left 0.1s ease-in-out;
}

@keyframes vibrate-left {

    0%,
    100% {
        transform: translateY(-50%);
    }

    25% {
        transform: translateY(-52%);
    }

    75% {
        transform: translateY(-48%);
    }
}

.dpad-btn.right.vibrate {
    animation: vibrate-right 0.1s ease-in-out;
}

@keyframes vibrate-right {

    0%,
    100% {
        transform: translateY(-50%);
    }

    25% {
        transform: translateY(-52%);
    }

    75% {
        transform: translateY(-48%);
    }
}