@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&display=swap');

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body, html {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    background-color: #0b1d3a;
    background-image: radial-gradient(circle at center, #112952 0%, #050d1a 100%);
    overflow: hidden;
    font-family: 'Press Start 2P', 'Courier New', Courier, monospace;
    display: flex;
    justify-content: center;
    align-items: center;
}

#app-wrapper {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    width: 100vw;
    height: 100vh;
    padding: 10px;
    gap: 15px;
    position: relative;
}

#game-container {
    position: relative;
    width: 90vw;
    height: calc(90vw * 1.3333); /* 3:4 Aspect Ratio */
    max-width: calc((85vh - 120px) * 0.75); /* Subtract control area height */
    max-height: calc(85vh - 120px);
    box-shadow: 0 10px 40px rgba(0,0,0,0.8), inset 0 0 20px rgba(255,255,255,0.05);
    background: linear-gradient(to bottom, var(--sky-top, #0b1d3a), var(--sky-bottom, #1a4282));
    border: 4px solid #1a3c6d;
    border-radius: 12px;
    overflow: hidden;
    transition: background 0.5s ease;
    container-type: size;
    container-name: game;
}

#hud {
    position: absolute;
    top: clamp(10px, 3cqw, 20px);
    left: clamp(10px, 3cqw, 20px);
    right: clamp(10px, 3cqw, 20px);
    display: flex;
    justify-content: space-between;
    color: white;
    text-shadow: 2px 2px 0px #000;
    z-index: 10;
    font-size: clamp(9px, 3cqw, 14px);
    pointer-events: none;
}

#parachute-status {
    color: #ff3333; /* Default closed color */
    transition: color 0.2s ease;
}

canvas {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
    image-rendering: pixelated; /* Essential for retro pixel art look */
}

#overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(4px);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    color: white;
    text-align: center;
    z-index: 20;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.4s ease;
    padding: 20px;
}

#overlay.active {
    opacity: 1;
    pointer-events: auto;
}

h1 {
    font-size: clamp(18px, 6.5cqw, 36px);
    margin-bottom: 25px;
    color: #ffcc00;
    text-shadow: 4px 4px 0px #aa2200;
    line-height: 1.5;
}

p {
    font-size: clamp(9px, 2.4cqw, 12px);
    line-height: 1.8;
    text-shadow: 2px 2px 0px #000;
    max-width: 90%;
}

/* Mobile Controls Styling */
#mobile-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    max-width: 600px;
    padding: 10px 15px;
    box-sizing: border-box;
    user-select: none;
    -webkit-user-select: none;
    z-index: 30;
}

.control-group-left {
    display: flex;
    gap: 15px;
}

.control-group-right {
    display: flex;
}

.control-btn {
    background: rgba(26, 60, 109, 0.45);
    border: 2px solid rgba(255, 255, 255, 0.15);
    border-radius: 16px;
    color: white;
    font-family: inherit;
    font-size: 24px;
    width: 70px;
    height: 70px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4), inset 0 2px 4px rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    transition: background 0.1s ease, transform 0.05s ease, border-color 0.1s ease;
    touch-action: manipulation;
}

.control-btn:active, .control-btn.active {
    background: rgba(255, 204, 0, 0.85);
    color: #0b1d3a;
    border-color: #ffcc00;
    transform: scale(0.92);
    box-shadow: 0 0 15px rgba(255, 204, 0, 0.5);
}

.action-btn {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    font-size: 32px;
    background: rgba(255, 51, 51, 0.45);
    border: 2px solid rgba(255, 51, 51, 0.25);
    box-shadow: 0 8px 24px rgba(255, 51, 51, 0.2), inset 0 2px 4px rgba(255, 255, 255, 0.2);
}

.action-btn:active, .action-btn.active {
    background: rgba(255, 51, 51, 0.9);
    color: white;
    border-color: #ff3333;
    box-shadow: 0 0 20px rgba(255, 51, 51, 0.6);
}

/* Responsive Layout Logic */
@media (orientation: landscape) {
    #app-wrapper {
        flex-direction: row;
        justify-content: center;
        align-items: center;
        gap: 30px;
        padding: 5px;
    }
    #game-container {
        height: 95vh;
        width: calc(95vh * 0.75);
        max-height: 95vh;
        max-width: calc(95vh * 0.75);
    }
    #mobile-controls {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        pointer-events: none;
        padding: 0;
        max-width: none;
        display: block;
    }
    .control-group-left {
        position: absolute;
        bottom: 20px;
        left: 20px;
        pointer-events: auto;
    }
    .control-group-right {
        position: absolute;
        bottom: 20px;
        right: 20px;
        pointer-events: auto;
    }
    .control-btn {
        width: 60px;
        height: 60px;
        font-size: 18px;
        border-radius: 12px;
    }
    .action-btn {
        width: 70px;
        height: 70px;
        font-size: 24px;
    }
}

/* Hide controls on standard desktop configurations */
@media (hover: hover) and (pointer: fine) {
    #mobile-controls {
        display: none !important;
    }
    #app-wrapper {
        padding: 0;
    }
    #game-container {
        width: 600px;
        height: 800px;
        max-width: 100%;
        max-height: 100%;
    }
}
