/* controls.css - Styles for D-Pad and Virtual Joystick Controls */

/* --- Control Type Selector --- */
.control-select {
    background: var(--dark-bg, #1a1a1a);
    border: 2px solid var(--grey-border, #555);
    color: var(--main-gold, #ffd700);
    padding: 5px 10px;
    font-family: 'Press Start 2P', cursive;
    font-size: 0.7rem;
    cursor: pointer;
    border-radius: 4px;
    outline: none;
    transition: all 0.2s ease;
}

.control-select:hover {
    border-color: var(--main-gold, #ffd700);
    background: rgba(255, 215, 0, 0.1);
}

.control-select:focus {
    border-color: var(--main-gold, #ffd700);
    box-shadow: 0 0 10px rgba(255, 215, 0, 0.3);
}

.control-select option {
    background: var(--dark-bg, #1a1a1a);
    color: var(--main-gold, #ffd700);
    padding: 5px;
}

/* --- Mobile Controls Container --- */
#mobile-dpad-container, #mobile-actions-container {
    position: fixed;
    bottom: 15px;
    z-index: 50;
    opacity: 0.8;
    transition: opacity 0.2s ease-in-out;
    touch-action: none;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

#mobile-dpad-container {
    left: 15px;
}

#mobile-actions-container {
    right: 15px;
}

#mobile-dpad-container:hover, #mobile-actions-container:hover {
    opacity: 1.0;
}

/* --- D-Pad Styles --- */
.mobile-dpad {
    display: grid;
    grid-template-columns: repeat(3, 50px);
    grid-template-rows: repeat(3, 50px);
    gap: 5px;
}

.mobile-dpad-btn {
    font-family: 'Press Start 2P', cursive;
    background-color: rgba(40, 40, 40, 0.9);
    border: 2px solid var(--grey-border, #555);
    color: var(--main-gold, #ffd700);
    border-radius: 10px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.5rem;
    -webkit-tap-highlight-color: transparent;
    transition: all 0.1s ease;
    box-shadow: 0 2px 0 #333;
}

.mobile-dpad-btn:active {
    transform: translateY(2px);
    box-shadow: 0 1px 0 #333;
    background-color: rgba(255, 215, 0, 0.2);
}

#mobile-dpad-up { grid-area: 1 / 2 / 2 / 3; }
#mobile-dpad-left { grid-area: 2 / 1 / 3 / 2; }
#mobile-dpad-center {
    grid-area: 2 / 2 / 3 / 3;
    opacity: 0.3;
    pointer-events: none;
}
#mobile-dpad-right { grid-area: 2 / 3 / 3 / 4; }
#mobile-dpad-down { grid-area: 3 / 2 / 4 / 3; }

/* --- Action Buttons --- */
.mobile-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.mobile-btn {
    font-family: 'Press Start 2P', cursive;
    background-color: rgba(40, 40, 40, 0.9);
    border: 2px solid var(--grey-border, #555);
    color: var(--main-gold, #ffd700);
    border-radius: 10px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 0.7rem;
    padding: 10px 5px;
    -webkit-tap-highlight-color: transparent;
    transition: all 0.1s ease;
    box-shadow: 0 2px 0 #333;
}

.mobile-btn:active {
    transform: translateY(2px);
    box-shadow: 0 1px 0 #333;
    background-color: rgba(255, 215, 0, 0.2);
}

#mobile-action-map {
    font-size: 1.2rem;
}

/* --- Virtual Joystick Styles --- */
#virtual-joystick-container {
    pointer-events: none;
    transition: opacity 0.2s ease-out;
}

#virtual-joystick-base {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(40, 40, 40, 0.9) 0%, rgba(20, 20, 20, 0.9) 100%);
    border: 3px solid rgba(255, 215, 0, 0.5);
    box-shadow: 0 0 20px rgba(255, 215, 0, 0.2), inset 0 0 20px rgba(0, 0, 0, 0.5);
}

#virtual-joystick-handle {
    position: absolute;
    width: 50px; /* Corresponds to handleSize in JS */
    height: 50px; /* Corresponds to handleSize in JS */
    border-radius: 50%;
    background: radial-gradient(circle, rgba(255, 215, 0, 0.9) 0%, rgba(255, 180, 0, 0.9) 100%);
    border: 2px solid rgba(255, 255, 255, 0.3);
    box-shadow: 0 0 15px rgba(255, 215, 0, 0.5);
    pointer-events: none;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

#virtual-joystick-touch-zone {
    /* Invisible touch zone for joystick activation */
    background: transparent;
    /* Debug mode - uncomment to see touch zone */
    /* background: rgba(255, 0, 0, 0.1); */
}

/* --- Responsive Adjustments --- */
@media (max-width: 480px) {
    .mobile-dpad {
        grid-template-columns: repeat(3, 45px);
        grid-template-rows: repeat(3, 45px);
        gap: 4px;
    }

    .mobile-dpad-btn {
        font-size: 1.3rem;
    }

    .mobile-btn {
        font-size: 0.6rem;
        padding: 8px 4px;
    }
}

/* --- Landscape Mode Adjustments --- */
body.layout-landscape #mobile-dpad-container,
body.layout-landscape #mobile-actions-container {
    bottom: 10px;
}

body.layout-landscape .mobile-dpad {
    grid-template-columns: repeat(3, 40px);
    grid-template-rows: repeat(3, 40px);
    gap: 3px;
}

body.layout-landscape .mobile-btn {
    padding: 6px 4px;
    font-size: 0.6rem;
}

/* --- Safe Area Support --- */
@supports (padding: max(0px)) {
    #mobile-actions-container {
        right: max(15px, env(safe-area-inset-right));
        bottom: max(15px, env(safe-area-inset-bottom));
    }

    #mobile-dpad-container {
        left: max(15px, env(safe-area-inset-left));
        bottom: max(15px, env(safe-area-inset-bottom));
    }
}

/* --- Hide Mobile Controls on Desktop --- */
@media (min-width: 769px) {
    #mobile-dpad-container,
    #mobile-actions-container,
    #virtual-joystick-container,
    #virtual-joystick-touch-zone,
    .mobile-only {
        display: none !important;
    }
}
