* {
    box-sizing: border-box;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
    -webkit-user-drag: none;
}

body,
html {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    background-color: #000;
    font-family: 'Press Start 2P', cursive;
    touch-action: none;
}

.controls-container {
    position: absolute;
    bottom: 20px;
    left: 0;
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px;
    pointer-events: none;
    z-index: 100;
    touch-action: none;
}

.dpad-container {
    width: 150px;
    height: 150px;
    position: relative;
    background-image: url('../assets/ui/button_xboxone_dpad_dark_1.png');
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    image-rendering: pixelated;
    pointer-events: auto;
}

.dpad-btn {
    position: absolute;
    background: transparent !important;
    border: none !important;
    outline: none !important;
    width: 50px;
    height: 50px;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
    transition: transform 0.1s ease;
    touch-action: none;
}

.dpad-up { top: 0; left: 50px; }
.dpad-down { bottom: 0; left: 50px; }
.dpad-left { left: 0; top: 50px; }
.dpad-right { right: 0; top: 50px; }

.action-buttons {
    display: grid;
    grid-template-columns: repeat(2, 60px);
    grid-template-rows: repeat(2, 60px);
    gap: 15px;
    transform: rotate(45deg);
    pointer-events: auto;
    margin-right: 20px;
}

.action-btn {
    width: 60px;
    height: 60px;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    background-color: transparent !important;
    border: none !important;
    outline: none !important;
    cursor: pointer;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
    transition: transform 0.1s ease;
    transform: rotate(-45deg);
    image-rendering: pixelated;
    touch-action: none;
}

.action-btn:active, .btn-active {
    transform: rotate(-45deg) scale(1.15) !important;
    filter: brightness(1.3);
}

.btn-a { background-image: url('../assets/ui/button_xbox_digital_a_2.png'); }
.btn-b { background-image: url('../assets/ui/button_xbox_digital_b_2.png'); }
.btn-x { background-image: url('../assets/ui/button_xbox_digital_x_2.png'); }
.btn-y { background-image: url('../assets/ui/button_xbox_digital_y_2.png'); }

#game-wrapper {
    position: relative;
    width: 100vw;
    height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background: #000;
}

#game-container {
    width: 88%;
    height: 88%;
    display: flex;
    justify-content: center;
    align-items: center;
    image-rendering: pixelated;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 1;
    background: #000;
    overflow: hidden;
}

#game-container canvas {
    width: 100% !important;
    height: 100% !important;
    object-fit: fill;
}

.game-viewport-container {
    position: relative;
    width: 90vmin;
    height: 90vmin;
    max-width: 450px;
    max-height: 450px;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 0 30px rgba(0,0,0,1);
    background: #000;
}

.vignette {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    background: radial-gradient(circle, transparent 70%, rgba(0, 0, 0, 0.4) 150%);
    z-index: 50;
}

/* Project Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(10px);
}

.modal-content {
    position: relative;
    background-color: #000;
    margin: 2vh auto;
    width: 95vw;
    height: 96vh;
    border: 2px solid #444;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 0 50px rgba(0,0,0,1);
    animation: modalPop 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes modalPop {
    from { transform: scale(0.8); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.close-btn {
    position: absolute;
    top: 15px;
    right: 25px;
    color: #fff;
    font-size: 44px;
    font-weight: bold;
    cursor: pointer;
    z-index: 2001;
    line-height: 1;
    transition: all 0.2s;
    text-shadow: 0 0 10px rgba(0,0,0,0.8);
    user-select: none;
}

.close-btn:hover {
    color: #ff4444;
    transform: scale(1.1);
}

#project-iframe {
    width: 100%;
    height: 100%;
    border: none;
    background: #fff;
}

/* Mobile specific modal adjustments */
@media (max-width: 768px) {
    .modal-content {
        width: 100%;
        height: 100%;
        margin: 0;
        border-radius: 0;
        border: none;
        position: fixed;
        top: 0;
        left: 0;
    }
    .close-btn {
        top: 20px;
        right: 25px;
        font-size: 50px;
        background: rgba(0,0,0,0.5);
        border-radius: 50%;
        width: 60px;
        height: 60px;
        display: flex;
        align-items: center;
        justify-content: center;
        padding-bottom: 5px;
    }
}

@media (min-width: 769px) {
    .game-viewport-container {
        width: 100vw !important;
        height: 100vh !important;
        max-width: none !important;
        max-height: none !important;
        margin: 0 !important;
        box-shadow: none !important;
        background: #000;
    }
    #game-container {
        width: 100% !important;
        height: 100% !important;
    }
    .controls-container {
        display: none !important;
    }
}

@media (max-width: 768px) {
    #game-wrapper {
        justify-content: flex-start !important;
        padding-top: 30px;
        height: 100vh;
        overflow: hidden;
        background-image: linear-gradient(rgba(0,0,0,0.4), rgba(0,0,0,0.4)), url('../assets/ui/mobile_bg.png');
        background-size: cover;
        background-position: center;
        background-color: transparent !important;
    }

    .game-viewport-container {
        width: 92vw !important;
        height: 92vw !important;
        max-width: 400px;
        max-height: 400px;
        margin-bottom: 30px;
        box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    }

    .controls-container {
        position: relative !important;
        bottom: 0 !important;
        left: 0 !important;
        display: flex !important;
        flex-direction: row !important;
        justify-content: space-between !important;
        align-items: center !important;
        width: 100% !important;
        padding: 0 15px !important;
        margin-top: 10px !important;
        pointer-events: auto !important;
    }

    .dpad-container {
        width: 130px !important;
        height: 130px !important;
        transform: none !important;
    }

    .action-buttons {
        margin-right: 5px !important;
        gap: 12px !important;
        grid-template-columns: repeat(2, 58px) !important;
        grid-template-rows: repeat(2, 58px) !important;
        transform: rotate(45deg) !important;
    }

    .action-btn {
        width: 58px !important;
        height: 58px !important;
    }
}
