/* Modern Reset & Typography */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    user-select: none;
    -webkit-user-select: none;
}

body {
    background-color: #0b0914;
    background-image: 
        radial-gradient(circle at 20% 30%, rgba(255, 102, 0, 0.15) 0%, transparent 40%),
        radial-gradient(circle at 80% 70%, rgba(0, 153, 255, 0.12) 0%, transparent 40%),
        linear-gradient(rgba(18, 16, 28, 0.8) 0%, rgba(11, 9, 20, 0.95) 100%);
    color: #ffffff;
    font-family: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow-x: hidden;
    padding: 10px;
}

/* Arcade Cabinet Wrapper */
.arcade-wrapper {
    width: 100%;
    max-width: 800px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.arcade-cabinet {
    width: 100%;
    background: linear-gradient(135deg, #1e1310 0%, #0d0605 100%);
    border: 4px solid #ff7700;
    border-radius: 20px;
    box-shadow: 
        0 0 30px rgba(255, 85, 0, 0.3),
        0 0 100px rgba(0, 0, 0, 0.8),
        inset 0 0 15px rgba(255, 255, 255, 0.05);
    padding: 24px;
    position: relative;
    overflow: hidden;
}

/* Neon Header */
.arcade-header {
    text-align: center;
    margin-bottom: 20px;
    border-bottom: 3px double #e65c00;
    padding-bottom: 15px;
}

.arcade-title {
    font-family: 'Press Start 2P', cursive;
    font-size: 2.2rem;
    color: #ff6600;
    text-shadow: 
        0 0 5px #ff6600,
        0 0 15px #ff4400,
        0 0 30px #ff2200;
    letter-spacing: 2px;
    animation: pulse-neon 2s infinite alternate;
}

.subtitle {
    font-family: 'Press Start 2P', cursive;
    font-size: 0.8rem;
    color: #ffcc00;
    text-shadow: 0 0 10px #ff9900;
    margin-top: 8px;
    letter-spacing: 4px;
}

@keyframes pulse-neon {
    0% {
        text-shadow: 0 0 5px #ff6600, 0 0 10px #ff4400, 0 0 20px #ff2200;
    }
    100% {
        text-shadow: 0 0 8px #ff8800, 0 0 20px #ff5500, 0 0 40px #ff3300;
    }
}

/* Main Screen Area */
.screen-container {
    position: relative;
    width: 100%;
    aspect-ratio: 1.6; /* Matches 640x400 Canvas aspect ratio */
    background-color: #000;
    border: 8px solid #28150d;
    border-radius: 10px;
    box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.9);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* Game Canvas */
#gameCanvas {
    width: 100%;
    height: 100%;
    object-fit: contain;
    background-color: #5c94fc; /* Sky Blue */
    display: block;
}

/* Classic HUD overlay */
.hud {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    padding: 12px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(to bottom, rgba(0, 0, 0, 0.8) 0%, rgba(0, 0, 0, 0) 100%);
    z-index: 5;
    font-family: 'Press Start 2P', cursive;
    font-size: 10px;
    letter-spacing: 1px;
}

.hud-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.hud-label {
    color: #ffffff;
    text-shadow: 1px 1px 0px #000;
}

.hud-value {
    color: #ff9900;
    text-shadow: 1px 1px 0px #000;
}

/* CRT Overlay Effect */
.crt-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.crt-overlay.active {
    opacity: 1;
    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));
    background-size: 100% 4px, 6px 100%;
    animation: crt-flicker 0.15s infinite;
}

.crt-overlay.active::before {
    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.2) 50%), linear-gradient(90deg, rgba(255, 0, 0, 0.05), rgba(0, 255, 0, 0.02), rgba(0, 0, 255, 0.05));
    background-size: 100% 3px, 3px 100%;
    z-index: 10;
}

/* CRT Screen Glare & Curve */
.screen-glare {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle at 50% 15%, rgba(255, 255, 255, 0.08) 0%, rgba(255, 255, 255, 0) 70%);
    pointer-events: none;
    z-index: 11;
}

@keyframes crt-flicker {
    0% { opacity: 0.98; }
    50% { opacity: 1.0; }
    100% { opacity: 0.99; }
}

/* Game Screen Overlays */
.game-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(15, 8, 5, 0.88);
    backdrop-filter: blur(4px);
    z-index: 8;
    display: flex;
    justify-content: center;
    align-items: center;
    text-align: center;
    transition: opacity 0.3s ease;
}

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

.overlay-content {
    padding: 30px;
    max-width: 85%;
}

.game-logo {
    font-family: 'Press Start 2P', cursive;
    font-size: 2.2rem;
    color: #ff9900;
    text-shadow: 
        0 4px 0px #b33600,
        0 8px 15px rgba(0, 0, 0, 0.5);
    line-height: 1.3;
    margin-bottom: 25px;
}

.game-logo span {
    color: #ffcc00;
    text-shadow: 
        0 4px 0px #a38200,
        0 8px 15px rgba(0, 0, 0, 0.5);
}

.blink {
    font-family: 'Press Start 2P', cursive;
    font-size: 9px;
    color: #00ffff;
    text-shadow: 0 0 5px rgba(0, 255, 255, 0.8);
    animation: blink-anim 1.5s infinite;
    cursor: pointer;
    margin-bottom: 25px;
}

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

.instructions {
    margin-top: 15px;
    padding: 15px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 119, 0, 0.2);
    border-radius: 8px;
    font-size: 12px;
    color: #d2cbb5;
    line-height: 1.6;
}

.instructions h3 {
    font-family: 'Press Start 2P', cursive;
    font-size: 8px;
    color: #ff5500;
    margin-bottom: 10px;
}

.control-keys {
    display: flex;
    flex-direction: column;
    gap: 8px;
    text-align: left;
    max-width: 320px;
    margin: 0 auto;
}

kbd {
    background: #3a1c0d;
    border: 1px solid #733c1f;
    border-radius: 4px;
    padding: 2px 6px;
    font-family: inherit;
    font-weight: bold;
    color: #ffffff;
    box-shadow: 0 2px 0 #1c0a03;
}

/* Game Over / Win Screens */
.game-over-text {
    font-family: 'Press Start 2P', cursive;
    font-size: 2.2rem;
    color: #ff3300;
    text-shadow: 0 0 20px rgba(255, 51, 0, 0.8);
    margin-bottom: 30px;
    animation: shake 0.5s ease infinite alternate;
}

.game-win-text {
    font-family: 'Press Start 2P', cursive;
    font-size: 2.2rem;
    color: #ffcc00;
    text-shadow: 0 0 20px rgba(255, 204, 0, 0.8);
    margin-bottom: 20px;
}

@keyframes shake {
    0% { transform: translateY(0); }
    100% { transform: translateY(-3px); }
}

.final-score-box {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 153, 0, 0.3);
    padding: 15px 25px;
    border-radius: 10px;
    margin-bottom: 25px;
    font-family: 'Press Start 2P', cursive;
    font-size: 10px;
    line-height: 2;
    text-align: left;
}

.final-score-box span {
    color: #ffff00;
}

.pause-text {
    font-family: 'Press Start 2P', cursive;
    font-size: 2.5rem;
    color: #00ffff;
    text-shadow: 0 0 15px rgba(0, 255, 255, 0.8);
    margin-bottom: 15px;
}

/* Primary Arcade Buttons */
.arcade-btn-primary {
    font-family: 'Press Start 2P', cursive;
    font-size: 11px;
    padding: 14px 28px;
    background: linear-gradient(to bottom, #ff5500 0%, #cc3300 100%);
    border: none;
    border-bottom: 4px solid #881e00;
    border-radius: 6px;
    color: #ffffff;
    cursor: pointer;
    text-shadow: 1px 1px 0px #000;
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.4);
    transition: all 0.1s ease;
}

.arcade-btn-primary:active {
    transform: translateY(2px);
    border-bottom-width: 2px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.4);
}

/* Physical Console Buttons Panel */
.arcade-controls {
    display: flex;
    justify-content: space-between;
    margin-top: 20px;
    gap: 10px;
    flex-wrap: wrap;
}

.arcade-console-btn {
    background: linear-gradient(180deg, #381c10 0%, #200f08 100%);
    border: 2px solid #8f4825;
    border-bottom: 4px solid #572912;
    color: #ebd9cf;
    padding: 8px 14px;
    border-radius: 6px;
    font-weight: bold;
    font-size: 11px;
    cursor: pointer;
    box-shadow: 0 3px 5px rgba(0, 0, 0, 0.3);
    transition: all 0.1s ease;
    display: flex;
    align-items: center;
    gap: 6px;
}

.arcade-console-btn:hover {
    background: linear-gradient(180deg, #4d2616 0%, #30170c 100%);
    color: #ffffff;
    border-color: #ba6034;
}

.arcade-console-btn:active {
    transform: translateY(2px);
    border-bottom-width: 2px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

/* Mobile Virtual Gamepad */
.mobile-gamepad {
    display: none; /* Hidden on Desktop */
    width: 100%;
    justify-content: space-between;
    align-items: center;
    padding: 10px 20px;
    background: rgba(26, 13, 7, 0.9);
    border: 2px solid #8a431a;
    border-radius: 15px;
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.5);
    touch-action: none;
}

/* D-Pad Layout */
.dpad {
    position: relative;
    width: 130px;
    height: 130px;
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    grid-template-rows: 1fr 1fr 1fr;
    align-items: center;
    justify-items: center;
}

.dpad-center {
    grid-column: 2;
    grid-row: 2;
    width: 44px;
    height: 44px;
    background-color: #381c0d;
    border: 1px solid #733c1f;
    z-index: 2;
}

.dpad-btn {
    width: 44px;
    height: 44px;
    background-color: #381c0d;
    border: 3px solid #733c1f;
    color: #ffffff;
    font-size: 18px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    z-index: 1;
}

.dpad-btn:active {
    background-color: #ff5500;
    border-color: #ffaa66;
    box-shadow: 0 0 10px rgba(255, 85, 0, 0.6);
}

#btnLeft {
    grid-column: 1;
    grid-row: 2;
    border-radius: 6px 0 0 6px;
    border-right: none;
    width: 46px;
}

#btnDown {
    grid-column: 2;
    grid-row: 3;
    border-radius: 0 0 6px 6px;
    border-top: none;
    height: 46px;
    width: 46px;
}

#btnRight {
    grid-column: 3;
    grid-row: 2;
    border-radius: 0 6px 6px 0;
    border-left: none;
    width: 46px;
}

/* Action Buttons Layout (A/B/Eye) */
.action-buttons {
    display: flex;
    gap: 12px;
}

.action-btn {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: none;
    color: #ffffff;
    font-family: 'Press Start 2P', cursive;
    font-size: 14px;
    text-shadow: 1px 1px 0px rgba(0,0,0,0.5);
    box-shadow: 
        0 4px 0px rgba(0, 0, 0, 0.4),
        0 8px 15px rgba(0, 0, 0, 0.3);
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: transform 0.05s ease, box-shadow 0.05s ease;
}

.action-btn:active {
    transform: translateY(3px);
    box-shadow: 
        0 1px 0px rgba(0, 0, 0, 0.4),
        0 2px 5px rgba(0, 0, 0, 0.3);
}

.btn-a {
    background: linear-gradient(135deg, #ff5500 0%, #cc3300 100%);
    border: 3px solid #ffaa66;
}

.btn-b {
    background: linear-gradient(135deg, #00d2ff 0%, #0077b3 100%);
    border: 3px solid #b3f0ff;
    color: #050d18;
}

.btn-eye {
    background: linear-gradient(135deg, #a855f7 0%, #6b21a8 100%);
    border: 3px solid #e9d5ff;
    font-size: 18px;
}

/* HUD Sight Statuses */
.sight-ready {
    color: #38bdf8;
    text-shadow: 0 0 6px rgba(56, 189, 248, 0.8);
    animation: blink-anim 1.5s infinite;
}

.sight-active {
    color: #a855f7;
    text-shadow: 0 0 10px rgba(168, 85, 247, 0.9);
}

.sight-cd {
    color: #94a3b8;
}

/* Motivational Retry Text */
.motivate-text {
    font-family: 'Outfit', sans-serif;
    font-size: 1.1rem;
    font-weight: 700;
    color: #fbbf24;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.8);
    margin: 15px 0 20px 0;
}

/* Responsive Scaling */
@media (max-width: 768px) {
    body {
        padding: 5px;
    }

    .arcade-cabinet {
        padding: 12px;
        border-radius: 12px;
    }

    .arcade-header {
        margin-bottom: 10px;
        padding-bottom: 8px;
    }

    .arcade-title {
        font-size: 1.4rem;
    }

    .subtitle {
        font-size: 0.6rem;
        letter-spacing: 2px;
    }

    .hud {
        padding: 8px 10px;
        font-size: 8px;
    }

    .arcade-controls {
        display: none; /* Hide bottom panel controls on small screens, keep it simple */
    }

    .mobile-gamepad {
        display: flex; /* Show virtual controls */
    }

    .game-logo {
        font-size: 1.5rem;
    }

    .blink {
        font-size: 8px;
    }

    .instructions {
        display: none; /* Hide keyboard controls on mobile */
    }

    .game-over-text {
        font-size: 1.8rem;
    }

    .game-win-text {
        font-size: 1.6rem;
    }
}
