:root {
    --cabinet-bg: #1a1a24;
    --cabinet-border: #2d2d3a;
    --bezel-bg: #0d0d13;
    --accent-red: #ff3b30;
    --accent-blue: #007aff;
    --accent-yellow: #ffcc00;
    --accent-green: #34c759;
    --neon-blue: rgba(0, 240, 255, 0.8);
    --neon-pink: rgba(255, 0, 128, 0.8);
    --text-shadow-neon: 0 0 5px var(--neon-blue), 0 0 10px var(--neon-blue);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
}

body {
    background-color: #08080c;
    background-image: 
        radial-gradient(at 0% 0%, rgba(30, 20, 60, 0.4) 0px, transparent 50%),
        radial-gradient(at 100% 100%, rgba(10, 40, 70, 0.4) 0px, transparent 50%);
    font-family: 'Press Start 2P', monospace;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    color: #fff;
    overflow: hidden;
}

/* Arcade Cabinet Container */
.arcade-cabinet {
    width: 600px;
    background: var(--cabinet-bg);
    border: 6px solid var(--cabinet-border);
    border-radius: 20px 20px 10px 10px;
    box-shadow: 
        0 0 30px rgba(0, 0, 0, 0.8),
        0 0 0 2px rgba(255, 255, 255, 0.05),
        inset 0 10px 0 rgba(255, 255, 255, 0.1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Header */
.cabinet-header {
    background: #111118;
    padding: 15px;
    border-bottom: 4px solid #000;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: inset 0 -2px 5px rgba(0,0,0,0.5);
}

.cabinet-header h1 {
    font-size: 14px;
    color: #fff;
    text-shadow: 0 0 6px var(--neon-pink);
    letter-spacing: 2px;
}

.coin-slot {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 8px;
    color: #ff9500;
    text-shadow: 0 0 4px rgba(255, 149, 0, 0.5);
}

.led {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: #333;
}

.led.light-green {
    background-color: #34c759;
    box-shadow: 0 0 8px #34c759;
    animation: blink 2s infinite;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

/* Bezel around the CRT screen */
.screen-bezel {
    background: var(--bezel-bg);
    padding: 25px;
    border-bottom: 6px solid #000;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: inset 0 0 40px rgba(0,0,0,0.9);
}

/* CRT Screen Wrapper */
.crt-screen {
    position: relative;
    width: 100%;
    aspect-ratio: 256 / 240;
    max-width: 512px;
    background: #000;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 
        0 0 0 4px #000,
        0 0 20px rgba(0, 240, 255, 0.15);
}

#gameCanvas {
    width: 100%;
    height: 100%;
    display: block;
    image-rendering: -moz-crisp-edges;
    image-rendering: -webkit-crisp-edges;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    background-color: #5c94fc; /* Classic NES sky blue */
}

/* CRT Screen Effects */
.scanlines {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        rgba(18, 16, 16, 0) 50%, 
        rgba(0, 0, 0, 0.25) 50%
    );
    background-size: 100% 4px;
    z-index: 10;
    pointer-events: none;
}

.crt-glow {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle, transparent 65%, rgba(0, 0, 0, 0.4) 100%);
    box-shadow: inset 0 0 30px rgba(0, 240, 255, 0.1);
    z-index: 11;
    pointer-events: none;
}

.glass-reflection {
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(
        45deg,
        rgba(255,255,255,0) 45%,
        rgba(255,255,255,0.03) 48%,
        rgba(255,255,255,0.06) 50%,
        rgba(255,255,255,0.03) 52%,
        rgba(255,255,255,0) 55%
    );
    transform: rotate(-15deg);
    z-index: 12;
    pointer-events: none;
}

/* CRT Flicker animation */
@keyframes crt-flicker {
    0% { opacity: 0.985; }
    50% { opacity: 1; }
    100% { opacity: 0.985; }
}

.crt-screen::after {
    content: " ";
    display: block;
    position: absolute;
    top: 0; left: 0; bottom: 0; right: 0;
    background: rgba(18, 16, 16, 0.05);
    opacity: 0;
    z-index: 13;
    pointer-events: none;
    animation: crt-flicker 0.15s infinite;
}

/* Overlay Base */
.overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 20;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    text-align: center;
    padding: 20px;
}

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

/* Start Screen specific */
.title-logo {
    font-size: 26px;
    font-weight: bold;
    line-height: 1.4;
    margin-bottom: 5px;
    letter-spacing: 2px;
    text-shadow: 3px 3px 0px #000;
}

.mario-text-red { color: #e52521; }
.mario-text-green { color: #43b047; }
.mario-text-yellow { color: #fcc111; }
.mario-text-blue { color: #00a6ed; }
.mario-text-orange { color: #f37021; }

.subtitle {
    font-size: 16px;
    color: #fff;
    letter-spacing: 6px;
    margin-bottom: 25px;
    text-shadow: 2px 2px 0px #000;
}

.menu-options {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 25px;
    width: 80%;
    max-width: 250px;
}

.retro-btn {
    font-family: 'Press Start 2P', monospace;
    font-size: 10px;
    color: #fff;
    background: #e52521;
    border: 3px solid #fff;
    border-radius: 4px;
    padding: 12px 10px;
    cursor: pointer;
    box-shadow: 4px 4px 0px #000;
    outline: none;
    transition: transform 0.1s, box-shadow 0.1s;
}

.retro-btn:active {
    transform: translate(2px, 2px);
    box-shadow: 2px 2px 0px #000;
}

.retro-btn.secondary {
    background: #43b047;
}

.controls-guide {
    font-size: 7px;
    color: #aaa;
    line-height: 1.8;
    margin-bottom: 20px;
}

.copyright {
    font-size: 7px;
    color: #666;
}

/* Game Over Screen */
.game-over-text {
    font-size: 28px;
    color: #e52521;
    text-shadow: 3px 3px 0px #000;
    margin-bottom: 30px;
    letter-spacing: 2px;
    animation: flash 1s infinite alternate;
}

@keyframes flash {
    from { opacity: 0.3; }
    to { opacity: 1; }
}

/* Victory Screen */
.victory-text {
    font-size: 22px;
    color: #fcc111;
    text-shadow: 3px 3px 0px #000;
    margin-bottom: 15px;
    letter-spacing: 1px;
}

.victory-subtext {
    font-size: 9px;
    color: #fff;
    line-height: 1.8;
    margin-bottom: 8px;
}

.victory-subtext.font-small {
    font-size: 7px;
    color: #aaa;
    margin-bottom: 20px;
}

.score-summary {
    font-size: 10px;
    color: #43b047;
    margin-bottom: 25px;
}

/* Loading Overlay */
.loading-text {
    font-size: 10px;
    color: #fff;
    animation: blink 1s infinite;
}

/* Cabinet Controls Area (D-pad & Buttons) */
.cabinet-controls {
    background: #15151f;
    padding: 15px 20px 20px 20px;
    border-top: 4px solid #000;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
}

/* Touch Controls Layout */
.touch-controls {
    display: flex;
    width: 100%;
    justify-content: space-between;
    align-items: center;
    max-width: 460px;
    /* Hidden by default on large desktop, visible on smaller layouts */
}

.dpad {
    display: flex;
    gap: 12px;
    position: relative;
}

.touch-btn {
    font-family: inherit;
    color: #fff;
    background: #222;
    border: 3px solid #444;
    box-shadow: inset 0 4px 0 rgba(255,255,255,0.1), 0 4px 6px rgba(0,0,0,0.4);
    cursor: pointer;
    outline: none;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    transition: background 0.05s, transform 0.05s, box-shadow 0.05s;
}

.touch-btn:active {
    background: #333;
    transform: translateY(2px);
    box-shadow: inset 0 2px 0 rgba(255,255,255,0.1), 0 2px 3px rgba(0,0,0,0.4);
}

.dpad-btn {
    width: 55px;
    height: 55px;
    border-radius: 10px;
    font-size: 18px;
}

.action-buttons {
    display: flex;
    gap: 20px;
}

.action-btn {
    width: 65px;
    height: 65px;
    border-radius: 50%;
    font-size: 16px;
    font-weight: bold;
    color: #fff;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.6);
}

.action-btn span {
    font-size: 6px;
    margin-top: 4px;
    color: #ccc;
    font-weight: normal;
}

.action-btn.run {
    background: #f0251b;
    border-color: #b0100a;
}
.action-btn.run:active {
    background: #c9170f;
}

.action-btn.jump {
    background: #fc9b19;
    border-color: #b86b07;
}
.action-btn.jump:active {
    background: #d47e0a;
}

/* Speaker Grill Styling */
.speaker-grill {
    display: flex;
    gap: 6px;
    justify-content: center;
    width: 100%;
}

.grill-bar {
    width: 25px;
    height: 6px;
    background: #0d0d13;
    border-radius: 3px;
    box-shadow: inset 0 1px 1px rgba(0,0,0,0.8), 0 1px 0 rgba(255,255,255,0.05);
}

/* Responsiveness to fit different screens */
@media (max-width: 640px) {
    body {
        padding: 5px;
    }
    
    .arcade-cabinet {
        width: 100%;
        max-width: 100%;
        height: 100%;
        border-radius: 0;
        border: none;
    }

    .cabinet-header {
        padding: 10px;
    }

    .screen-bezel {
        padding: 10px;
        flex-grow: 1;
    }

    .crt-screen {
        max-width: 100%;
    }

    .cabinet-controls {
        padding: 15px;
    }

    .dpad-btn {
        width: 50px;
        height: 50px;
    }

    .action-btn {
        width: 55px;
        height: 55px;
        font-size: 14px;
    }
}

/* Desktop layout touch controls visible by default too, for click testing or desktop touch screen */
/* But we can style it to be nicely arranged */
