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

body {
    background-color: #080808;
    color: #fff;
    font-family: 'Press Start 2P', monospace;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    overflow: hidden;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
    padding: 10px;
}

.game-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 15px;
    width: 100%;
    max-width: 400px;
    margin: auto;
    position: relative;
}

#game-container {
    position: relative;
    width: 100%;
    max-height: calc(100vh - 170px);
    aspect-ratio: 2 / 3;
    background-color: #111;
    border: 3px solid #ff4500;
    box-shadow: 0 0 25px rgba(255, 69, 0, 0.4), inset 0 0 20px rgba(0, 0, 0, 0.8);
    border-radius: 12px;
    overflow: hidden;
    touch-action: none;
}

#game-canvas {
    display: block;
    width: 100%;
    height: 100%;
    image-rendering: pixelated;
    object-fit: contain;
}

#ui-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

#score-display {
    position: absolute;
    top: 15px;
    left: 15px;
    font-size: clamp(10px, 3.5vw, 14px);
    color: #ffcc00;
    text-shadow: 2px 2px 0px #000;
    z-index: 10;
}

.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;
    text-align: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    pointer-events: auto;
    z-index: 20;
    padding: 20px;
}

.overlay.active {
    opacity: 1;
    visibility: visible;
}

.overlay h1 {
    font-size: clamp(20px, 6.5vw, 28px);
    color: #ff4500;
    margin-bottom: 20px;
    text-shadow: 0 0 10px #ff4500, 3px 3px 0px #8b0000;
    line-height: 1.3;
}

.overlay p {
    font-size: clamp(8px, 2.5vw, 10px);
    line-height: 2;
    margin-bottom: 15px;
    color: #ccc;
}

button {
    font-family: 'Press Start 2P', monospace;
    font-size: clamp(10px, 3vw, 12px);
    padding: 12px 18px;
    background-color: #ff4500;
    color: #fff;
    border: 4px solid #8b0000;
    border-radius: 4px;
    cursor: pointer;
    margin-top: 20px;
    transition: transform 0.1s, background-color 0.2s, box-shadow 0.2s;
    outline: none;
    box-shadow: 0 4px 10px rgba(255, 69, 0, 0.4);
}

button:hover {
    background-color: #ff6347;
    transform: scale(1.05);
    box-shadow: 0 6px 15px rgba(255, 69, 0, 0.6);
}

button:active {
    transform: scale(0.95);
    box-shadow: 0 2px 5px rgba(255, 69, 0, 0.3);
}

/* Mobile Controls & Responsive layout styling */
#mobile-controls {
    display: none;
    justify-content: center;
    gap: 40px;
    width: 100%;
    padding: 10px 10px 0 10px;
    box-sizing: border-box;
    z-index: 20;
}

body.touch-device #mobile-controls {
    display: flex;
}

.ctrl-btn {
    width: 70px;
    height: 70px;
    background: rgba(255, 69, 0, 0.15);
    border: 2px solid rgba(255, 69, 0, 0.4);
    border-radius: 50%;
    color: #fff;
    font-size: 1.8rem;
    font-weight: bold;
    cursor: pointer;
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.1s ease;
    touch-action: manipulation;
    user-select: none;
    -webkit-user-select: none;
    outline: none;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
    margin-top: 0; /* Override button margin-top */
}

.ctrl-btn:active {
    background: rgba(255, 69, 0, 0.4);
    border-color: #ff4500;
    box-shadow: 0 0 15px rgba(255, 69, 0, 0.8);
    transform: scale(0.92);
}

.instructions-hint {
    text-align: center;
    color: rgba(255, 255, 255, 0.5);
    font-size: clamp(8px, 2vw, 10px);
    letter-spacing: 1px;
    text-transform: uppercase;
    margin-top: 5px;
    pointer-events: none;
    line-height: 1.5;
}

.instructions-hint strong {
    color: #ffcc00;
}

/* Visibility classes */
.mobile-only {
    display: none !important;
}

.desktop-only {
    display: inline !important;
}

body.touch-device .desktop-only {
    display: none !important;
}

body.touch-device .mobile-only {
    display: inline !important;
}

/* Landscape overlay for mobile screens to maximize game viewport size */
@media (max-height: 550px) and (orientation: landscape) {
    #mobile-controls {
        position: absolute;
        bottom: 15px;
        left: 0;
        right: 0;
        padding: 0 30px;
        justify-content: space-between;
        pointer-events: none;
    }
    .ctrl-btn {
        pointer-events: auto;
        width: 60px;
        height: 60px;
        font-size: 1.5rem;
    }
    #game-container {
        max-height: 75vh;
    }
}
