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

:root {
    --bg-gradient: linear-gradient(135deg, #0f0c20 0%, #15102a 50%, #06040a 100%);
    --arcade-border: #ff007f;
    --neon-blue: #00ffff;
    --neon-yellow: #ffff00;
    --text-color: #ffffff;
    --ui-bg: rgba(15, 12, 32, 0.85);
    --font-retro: 'Press Start 2P', monospace;
    --font-sans: 'Outfit', sans-serif;
}

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

body {
    background: var(--bg-gradient);
    font-family: var(--font-sans);
    color: var(--text-color);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow-x: hidden;
    padding: 20px;
}

.game-title {
    font-family: var(--font-retro);
    font-size: 2.2rem;
    color: var(--neon-yellow);
    text-shadow: 0 0 10px rgba(255, 255, 0, 0.6), 3px 3px 0px #d400ff;
    margin-bottom: 20px;
    letter-spacing: 2px;
    text-align: center;
    animation: pulse 2s infinite alternate;
}

/* Arcade Cabinet Wrapper */
.arcade-container {
    position: relative;
    background: #1c1830;
    border: 6px solid #2d264f;
    border-radius: 16px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.8),
                0 0 30px rgba(255, 0, 127, 0.2),
                inset 0 0 15px rgba(255, 255, 255, 0.05);
    padding: 12px;
    max-width: 824px;
    width: 100%;
}

.screen-glow {
    position: relative;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 0 20px rgba(0, 255, 255, 0.15);
}

.screen-glow::after {
    content: " ";
    display: block;
    position: absolute;
    top: 0; left: 0; bottom: 0; right: 0;
    background: linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.25) 50%), linear-gradient(90deg, rgba(255, 0, 0, 0.06), rgba(0, 255, 0, 0.02), rgba(0, 0, 255, 0.06));
    z-index: 5;
    background-size: 100% 4px, 6px 100%;
    pointer-events: none;
}

#gameCanvas {
    display: block;
    background: #5c94fc; /* Classic Mario sky blue */
    width: 800px;
    height: 480px;
    max-width: 100%;
    height: auto;
    border-radius: 8px;
}

/* UI Overlay Screens */
.overlay-screen {
    position: absolute;
    top: 12px;
    left: 12px;
    right: 12px;
    bottom: 12px;
    background: var(--ui-bg);
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 10;
    backdrop-filter: blur(8px);
    transition: opacity 0.3s ease, visibility 0.3s;
}

.overlay-screen.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.screen-title {
    font-family: var(--font-retro);
    font-size: 2rem;
    margin-bottom: 25px;
    text-align: center;
    letter-spacing: 2px;
}

.start-title {
    color: var(--neon-blue);
    text-shadow: 0 0 10px rgba(0, 255, 255, 0.5);
}

.gameover-title {
    color: #ff3b30;
    text-shadow: 0 0 10px rgba(255, 59, 48, 0.5);
}

.clear-title {
    color: #4cd964;
    text-shadow: 0 0 10px rgba(76, 217, 100, 0.5);
}

.stats-container {
    background: rgba(255, 255, 255, 0.05);
    border: 1px dashed rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    padding: 15px 30px;
    margin-bottom: 25px;
    text-align: center;
}

.stat-row {
    font-family: var(--font-retro);
    font-size: 0.9rem;
    margin: 8px 0;
    color: #ddd;
}

.stat-val {
    color: var(--neon-yellow);
}

.btn {
    font-family: var(--font-retro);
    font-size: 1rem;
    color: #fff;
    background: transparent;
    border: 3px solid #fff;
    padding: 12px 30px;
    cursor: pointer;
    border-radius: 4px;
    outline: none;
    transition: all 0.2s ease;
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.1);
}

.btn-start {
    border-color: var(--neon-blue);
    text-shadow: 0 0 5px var(--neon-blue);
    box-shadow: 0 0 15px rgba(0, 255, 255, 0.2);
}

.btn-start:hover {
    background: var(--neon-blue);
    color: #000;
    box-shadow: 0 0 25px rgba(0, 255, 255, 0.5);
    transform: translateY(-2px);
}

.btn-restart {
    border-color: var(--arcade-border);
    text-shadow: 0 0 5px var(--arcade-border);
    box-shadow: 0 0 15px rgba(255, 0, 127, 0.2);
}

.btn-restart:hover {
    background: var(--arcade-border);
    color: #fff;
    box-shadow: 0 0 25px rgba(255, 0, 127, 0.5);
    transform: translateY(-2px);
}

/* Control Guide */
.control-guide {
    display: flex;
    gap: 30px;
    margin-top: 25px;
    color: #8a88a0;
    font-size: 0.9rem;
    background: rgba(255, 255, 255, 0.02);
    padding: 10px 20px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.control-item {
    display: flex;
    align-items: center;
    gap: 8px;
}

.key {
    background: #332d59;
    border-bottom: 3px solid #1c1830;
    color: #fff;
    padding: 4px 10px;
    border-radius: 4px;
    font-family: monospace;
    font-weight: bold;
    font-size: 0.85rem;
}

@keyframes pulse {
    0% { transform: scale(1); }
    100% { transform: scale(1.03); }
}

@media (max-width: 820px) {
    #gameCanvas {
        aspect-ratio: 5 / 3;
    }
    .control-guide {
        flex-direction: column;
        gap: 10px;
        align-items: center;
    }
}

/* Touch Controls for Mobile Devices — visible by default, hidden on desktop */
.touch-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 15px;
    padding: 5px 10px;
    width: 100%;
    user-select: none;
    -webkit-user-select: none;
    touch-action: none;
}

/* Hide touch controls ONLY on large screens with a fine pointer (real desktop mouse) */
@media (pointer: fine) and (min-width: 821px) {
    .touch-controls {
        display: none !important;
    }
}

.dpad {
    display: flex;
    gap: 15px;
}

.touch-btn {
    width: 68px;
    height: 68px;
    font-size: 1.6rem;
    font-weight: bold;
    color: #ffffff;
    background: rgba(28, 24, 48, 0.9);
    border: 3px solid var(--neon-blue);
    border-radius: 50%;
    outline: none;
    box-shadow: 0 0 12px rgba(0, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
    transition: transform 0.05s ease, background 0.05s ease, box-shadow 0.05s ease;
}

.touch-btn:active, .touch-btn.active {
    background: var(--neon-blue);
    color: #000000;
    box-shadow: 0 0 20px rgba(0, 255, 255, 0.7);
    transform: scale(0.92);
}

.action-buttons {
    display: flex;
}

.jump-btn {
    width: 110px;
    height: 68px;
    border-radius: 34px;
    border-color: var(--arcade-border);
    font-family: var(--font-retro);
    font-size: 0.75rem;
    box-shadow: 0 0 12px rgba(255, 0, 127, 0.2);
}

.jump-btn:active, .jump-btn.active {
    background: var(--arcade-border);
    color: #ffffff;
    box-shadow: 0 0 20px rgba(255, 0, 127, 0.7);
    border-color: #ffffff;
}

/* Prevent selection and zoom across elements */
body, button, canvas, .touch-controls {
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
    touch-action: manipulation;
}

/* Mobile responsive optimization */
@media (max-width: 820px) {
    body {
        padding: 8px;
    }
    .game-title {
        font-size: 1.4rem;
        margin-bottom: 10px;
    }
    .arcade-container {
        border-width: 3px;
        padding: 6px;
        border-radius: 12px;
    }
    .screen-glow {
        border-radius: 6px;
    }
    .overlay-screen {
        top: 6px; left: 6px; right: 6px; bottom: 6px;
        border-radius: 6px;
    }
    .screen-title {
        font-size: 1.1rem;
        margin-bottom: 12px;
    }
    .btn {
        padding: 8px 18px;
        font-size: 0.75rem;
        border-width: 2px;
    }
    .control-guide {
        display: none; /* Hide keyboard help on mobile viewports */
    }
}

