:root {
    --bg-color: #1a1a1a;
    --game-bg: #5c94fc;
    /* Mario/Giana sky blue */
}

body {
    margin: 0;
    padding: 0;
    background-color: var(--bg-color);
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    font-family: 'Press Start 2P', cursive;
    color: white;
    overflow: hidden;
}

#game-container {
    position: relative;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.8);
    border: 4px solid #333;
    background-color: #000;
}

canvas {
    display: block;
    background-color: var(--game-bg);
    image-rendering: pixelated;
    /* Essential for retro look */
}

/* CRT Scanline Effect */
.scanlines {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(to bottom,
            rgba(255, 255, 255, 0),
            rgba(255, 255, 255, 0) 50%,
            rgba(0, 0, 0, 0.2) 50%,
            rgba(0, 0, 0, 0.2));
    background-size: 100% 4px;
    pointer-events: none;
    z-index: 10;
    animation: scrollLines 10s linear infinite;
    mix-blend-mode: overlay;
    opacity: 0.6;
}

#loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 24px;
    z-index: 20;
    text-shadow: 2px 2px #000;
}

@keyframes scrollLines {
    0% {
        background-position: 0 0;
    }

    100% {
        background-position: 0 400px;
    }
}

/* --- Mobile / Touch Controls --- */

#touch-controls {
    display: none;
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 200;
}

.control-btn {
    pointer-events: auto;
    background: rgba(255, 255, 255, 0.2);
    border: 2px solid rgba(255, 255, 255, 0.5);
    color: white;
    border-radius: 50%;
    width: 80px;
    height: 80px;
    font-size: 32px;
    font-family: inherit;
    touch-action: manipulation;
    user-select: none;
    -webkit-user-select: none;
    display: flex;
    justify-content: center;
    align-items: center;
    outline: none;
    cursor: pointer;
}

.control-btn:active,
.control-btn.active {
    background: rgba(255, 255, 255, 0.6);
    transform: scale(0.95);
}

.d-pad {
    position: absolute;
    bottom: 30px;
    left: 30px;
    display: flex;
    gap: 20px;
}

.action-pad {
    position: absolute;
    bottom: 30px;
    right: 30px;
}

#btn-jump {
    width: 90px;
    height: 90px;
    background: rgba(255, 80, 80, 0.4);
    border-color: rgba(255, 80, 80, 0.8);
}

/* Fullscreen Button */
#ui-layer {
    position: fixed;
    top: 10px;
    right: 10px;
    z-index: 210;
}

.icon-btn {
    background: rgba(0, 0, 0, 0.5);
    border-radius: 5px;
    border: 1px solid #555;
    color: white;
    font-size: 24px;
    cursor: pointer;
    padding: 10px;
}

/* --- Media Queries --- */

/* Show controls on touch devices or small screens */
@media (max-width: 1024px) and (hover: none),
(pointer: coarse) {
    #touch-controls {
        display: block;
    }

    #game-container {
        width: 100%;
        height: 100%;
        border: none;
    }

    canvas {
        width: 100%;
        height: 100%;
        object-fit: contain;
    }
}

/* Landscape Hint */
#landscape-hint {
    display: none;
    position: fixed;
    inset: 0;
    background-color: #1a1a1a;
    z-index: 9999;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    color: white;
}

/* Show hint if width < height (Portrait) */
@media (max-width: 1024px) and (max-aspect-ratio: 11/10) {
    #landscape-hint {
        display: flex;
    }

    #game-container {
        opacity: 0;
    }
}