:root {
    --primary: #4336f3;
    --accent: #ff0055;
    --bg-color: #87CEEB;
    /* Sky blue essentially */
    --text-color: #2c2c2c;
    --font-main: 'VT323', monospace;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: var(--font-main);
    image-rendering: pixelated;
    /* Crucial for pixel art crispness */
}

body {
    width: 100vw;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    background: #000;
    overflow: hidden;
    user-select: none;
}

#game-container {
    position: relative;
    /* Full Screen / Ultrawide Support */
    width: 100%;
    height: 100%;

    background: var(--bg-color);
    box-shadow: 0 0 0 10px #333;
    border: 4px solid #fff;
    overflow: hidden;
}

canvas {
    display: block;
    width: 100%;
    height: 100%;
    image-rendering: pixelated;
}

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

#hud {
    display: flex;
    flex-direction: column;
    padding: 20px;
    font-size: 2.2rem;
    color: #fff;
    text-shadow: 4px 4px 0 #000;
    text-transform: uppercase;
    gap: 10px;
    background: rgba(0, 0, 0, 0.3);
    /* improved visibility */
    border-radius: 0 0 20px 0;
    width: fit-content;
    position: relative;
    z-index: 10;
    /* Lower than Game Over screen */
    transition: opacity 0.3s;
}

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

.hud-top {
    display: flex;
    flex-direction: column;
    /* Stack on mobile/smaller screens */
    gap: 10px;
    width: 100%;
}

@media (min-width: 800px) {
    .hud-top {
        flex-direction: row;
        justify-content: space-between;
        gap: 40px;
    }
}

.progress-container {
    width: 320px;
    height: 30px;
    background: #111;
    border: 4px solid #fff;
    box-shadow: 4px 4px 0 #000;
    position: relative;
    overflow: hidden;
    margin-left: 0;
}

#progress-bar {
    width: 0%;
    height: 100%;
    background: #44ff44;
    transition: width 0.3s steps(10);
    box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.5), 0 0 20px rgba(68, 255, 68, 0.4);
}

#level-progress {
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.5rem;
    color: #fff;
    text-shadow: 2px 2px 0 #000;
    pointer-events: none;
    z-index: 2;
}

.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background: rgba(0, 0, 0, 0.85);
    pointer-events: auto;
    transition: opacity 0.2s steps(4);
}

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

.title {
    font-size: 8rem;
    color: #ffd700;
    /* Gold */
    margin-bottom: 20px;
    text-shadow: 8px 8px 0 #b8860b, 12px 12px 0 #000;
    letter-spacing: 5px;
    text-align: center;
    line-height: 1;
}

.subtitle {
    font-size: 3rem;
    color: #fff;
    margin-bottom: 4rem;
    text-shadow: 3px 3px 0 #000;
}

.btn {
    padding: 20px 40px;
    font-size: 3rem;
    color: #000;
    background: #fff;
    border: 4px solid #000;
    box-shadow: 8px 8px 0 #000;
    cursor: pointer;
    font-family: var(--font-main);
    text-transform: uppercase;
    transition: transform 0.1s;
}

.btn:hover {
    transform: translate(-4px, -4px);
    box-shadow: 12px 12px 0 #000;
    background: #f0f0f0;
}

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

#game-over-screen h1 {
    font-size: 6rem;
    color: #ff0055;
    text-shadow: 6px 6px 0 #000;
    margin-bottom: 2rem;
}

/* Settings UI */
.settings-container {
    display: flex;
    flex-wrap: wrap;
    /* Allow wrapping on small screens */
    justify-content: center;
    gap: 40px;
    margin-bottom: 40px;
    width: 80%;
    max-width: 800px;
}

.setting {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.setting label {
    font-size: 2rem;
    color: #fff;
    text-shadow: 2px 2px 0 #000;
}


/* =========================================
   UI REVAMP: INDUSTRIAL DASHBOARD
   ========================================= */

/* FULL SCREEN OVERLAY */
#customize-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(10, 10, 12, 0.98);
    /* Deep void */
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

#customize-screen .title {
    font-family: 'VT323', monospace;
    font-size: 5rem;
    color: #00E5FF;
    /* Cyan Neon */
    text-transform: uppercase;
    letter-spacing: 0.5rem;
    margin-bottom: 2rem;
    text-shadow: 0 0 10px #00E5FF, 4px 4px 0 #000;
}

/* CONTAINER: The Dashboard Panel */
.customizer-container {
    display: flex;
    flex-direction: row;
    gap: 4rem;
    padding: 3rem;
    background: #1a1a1a;
    /* Dark Metal */
    border: 4px solid #444;
    box-shadow:
        0 0 0 4px #000,
        /* Inner outline */
        0 0 40px rgba(0, 229, 255, 0.2);
    /* Outer Glow */
    border-radius: 4px;
    align-items: center;
}

/* LEFT: CRT MONITOR PREVIEW */
.preview-box {
    width: 320px;
    height: 320px;
    background: #000;
    border: 8px solid #333;
    /* Bezel */
    border-radius: 20px;
    /* CRT Curve */
    position: relative;
    overflow: hidden;
    box-shadow: inset 0 0 20px #000;
}

/* Background Scene inside CRT */
.preview-box canvas {
    background: #87CEEB;
    /* Game Sky */
    width: 100%;
    height: 100%;
    image-rendering: pixelated;
    z-index: 1;
}

/* Scanlines and CRT Glow */
.preview-box::after {
    content: "";
    /* Removed REC text */
    position: absolute;
    top: 20px;
    left: 20px;
    color: #ff0055;
    font-family: monospace;
    animation: blink 1s infinite;
    pointer-events: none;
    z-index: 10;
    text-shadow: 0 0 5px #ff0055;
    background: transparent;
}

.preview-box::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background:
        linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.25) 50%),
        radial-gradient(circle at center, rgba(0, 0, 0, 0) 60%, rgba(0, 0, 0, 0.4) 100%);
    background-size: 100% 4px, 100% 100%;
    pointer-events: none;
    z-index: 5;
}

@keyframes blink {
    50% {
        opacity: 0;
    }
}

/* RIGHT: CONTROLS (Industrial Switches) */
.parts-selectors {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.part-row {
    display: flex;
    align-items: center;
    background: #222;
    border: 2px solid #555;
    padding: 0.5rem;
    box-shadow: 4px 4px 0 #000;
}

.part-row label {
    font-size: 1.8rem;
    width: 100px;
    color: #ffd700;
    /* Gold */
    text-align: right;
    margin-right: 1rem;
    text-shadow: 2px 2px 0 #000;
}

.part-row span {
    font-size: 2rem;
    width: 180px;
    text-align: center;
    color: #fff;
}

.arrow-btn {
    width: 50px;
    height: 50px;
    background: #333;
    color: #00E5FF;
    border: 2px solid #00E5FF;
    font-size: 2rem;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.1s;
}

.arrow-btn:hover {
    background: #00E5FF;
    color: #000;
    box-shadow: 0 0 10px #00E5FF;
}

.arrow-btn:active {
    transform: scale(0.95);
}

/* DONE BUTTON */
#close-customize-btn {
    margin-top: 3rem;
    width: auto;
    min-width: 300px;
    align-self: center;
    padding: 1.5rem;
    font-size: 2.5rem;
    background: #ff0055;
    color: #fff;
    border: none;
    border-top: 4px solid #ff5588;
    border-bottom: 4px solid #aa0033;
    text-shadow: 2px 2px 0 #000;
    cursor: pointer;
    text-transform: uppercase;
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.5);
}

#close-customize-btn:hover {
    background: #ff2266;
    transform: translateY(-2px);
    box-shadow: 0 12px 24px rgba(255, 0, 85, 0.4);
}

/* DROPDOWN MENU POLISH */
.pixel-select {
    font-family: var(--font-main);
    font-size: 2rem;
    padding: 10px 20px;
    border: 4px solid #000;
    background: #222;
    /* Dark background to match theme */
    color: #fff;
    /* White text */
    box-shadow: 4px 4px 0 #000;
    cursor: pointer;
    outline: none;
    appearance: none;
    text-align: center;
    min-width: 200px;
    text-transform: uppercase;

    /* Custom Arrow Hack (SVG encoded) or just solid block since appearance none removes it */
    background-image: linear-gradient(45deg, transparent 50%, #fff 50%),
        linear-gradient(135deg, #fff 50%, transparent 50%);
    background-position: calc(100% - 20px) calc(1em + 5px),
        calc(100% - 15px) calc(1em + 5px);
    background-size: 5px 5px,
        5px 5px;
    background-repeat: no-repeat;
}

.pixel-select:hover {
    background-color: #333;
    transform: translate(-2px, -2px);
    box-shadow: 6px 6px 0 #000;
}

.pixel-select option {
    background: #222;
    color: #fff;
}

/* Volume Controls */
.volume-controls {
    display: flex;
    align-items: center;
    gap: 15px;
}

#volume-slider {
    width: 150px;
    height: 10px;
    appearance: none;
    -webkit-appearance: none;
    background: #333;
    border: 2px solid #fff;
    outline: none;
    cursor: pointer;
}

#volume-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 20px;
    height: 30px;
    background: #00E5FF;
    border: 2px solid #000;
    box-shadow: 4px 4px 0 #000;
}

.pixel-btn-small {
    padding: 5px 15px;
    font-size: 1.5rem;
    color: #fff;
    background: #444;
    border: 3px solid #000;
    box-shadow: 3px 3px 0 #000;
    cursor: pointer;
    text-transform: uppercase;
}

.pixel-btn-small:hover {
    background: #666;
}

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

/* In-Game Controls */
#ingame-controls {
    position: absolute;
    top: 20px;
    right: 20px;
    display: flex;
    gap: 10px;
    align-items: center;
    background: rgba(0, 0, 0, 0.5);
    padding: 10px;
    border: 2px solid #fff;
    pointer-events: auto;
    z-index: 100;
}

#ingame-volume-slider {
    width: 100px;
    height: 8px;
    background: #333;
    appearance: none;
    -webkit-appearance: none;
    border: 1px solid #fff;
    cursor: pointer;
}

#ingame-volume-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 15px;
    height: 20px;
    background: #00E5FF;
    border: 1px solid #000;
}

/* Game Over Overhaul */
#game-over-screen {
    background: rgba(20, 0, 0, 0.9);
    /* Dark Red Overlay */
    backdrop-filter: blur(5px);
}

.game-over-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 30px;
}

.glitch-text {
    font-size: 8rem;
    color: #ff0055;
    text-shadow: 5px 5px 0 #000;
    position: relative;
    animation: glitch 1s infinite alternate;
}

@keyframes glitch {
    0% {
        transform: translate(0);
    }

    20% {
        transform: translate(-2px, 2px);
    }

    40% {
        transform: translate(-2px, -2px);
    }

    60% {
        transform: translate(2px, 2px);
    }

    80% {
        transform: translate(2px, -2px);
    }

    100% {
        transform: translate(0);
    }
}

.score-display {
    display: flex;
    gap: 50px;
    margin-bottom: 20px;
}

.final-score-box,
.high-score-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: #111;
    padding: 20px;
    border: 4px solid #fff;
    box-shadow: 8px 8px 0 #000;
    min-width: 200px;
}

.score-label {
    font-size: 1.5rem;
    color: #888;
    margin-bottom: 10px;
}

.score-val {
    font-size: 4rem;
    color: #00E5FF;
    text-shadow: 3px 3px 0 #000;
}

.pulse-btn {
    animation: pulse 1.5s infinite;
}

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

    50% {
        transform: scale(1.05);
    }

    100% {
        transform: scale(1);
    }
}