/* ==========================================================================
   NEON RUSH - Main Stylesheet
   
   Table of Contents:
   1. Custom Fonts
   2. Variables & Animations
   3. Base & Layout
   4. Header
   5. Game Device & Reflection
   6. Game Screen Elements
   7. Game UI
   8. Footer
   9. Media Queries
   ========================================================================== */

/* ==========================================================================
   1. Custom Fonts
   ========================================================================== */
@font-face {
    font-family: 'NeonWorld';
    src: url('assets/fonts/NEON\ WORLD\ DEMO.ttf') format('truetype'),
         url('assets/fonts/NEON\ WORLD\ DEMO.otf') format('opentype');
    font-weight: normal;
    font-style: normal;
    font-display: swap; /* Improve font loading performance */
}

@font-face {
    font-family: 'ArcadeClassic';
    src: url('assets/fonts/ARCADECLASSIC.TTF') format('truetype');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

/* ==========================================================================
   2. Variables & Animations
   ========================================================================== */
:root {
    /* Core color palette */
    --neon-cyan: #0ff;
    --neon-magenta: #f0f;
    --neon-yellow: #fedb3d;
    --dark-purple: #170a5e;
    --darker-purple: #090021;
    --grid-pink: #e807cb;
    
    /* Functional colors */
    --text-glow: var(--neon-cyan);
    --text-glow-alt: var(--neon-magenta);
    --button-color: var(--neon-cyan);
    --header-color: var(--neon-cyan);
    --gradient-start: var(--neon-cyan);
    --gradient-end: var(--neon-magenta);
}

/* CSS Custom Properties */
@property --outrun {
    syntax: "<number>";
    initial-value: 0;
    inherits: false;
    robustness: initial;
}

/* Animations */
@keyframes outrun {
    to { --outrun: 1; }
}

@keyframes textPulse {
    0% { opacity: 0.8; filter: brightness(0.8); }
    50% { opacity: 1; filter: brightness(1.2); }
    100% { opacity: 0.8; filter: brightness(0.8); }
}

@keyframes buttonGlow {
    0% { box-shadow: 0 0 5px var(--button-color), 0 0 10px var(--button-color); }
    50% { box-shadow: 0 0 15px var(--button-color), 0 0 20px var(--button-color); }
    100% { box-shadow: 0 0 5px var(--button-color), 0 0 10px var(--button-color); }
}

/* ==========================================================================
   3. Base & Layout
   ========================================================================== */
body {
    margin: 0;
    padding: 0;
    overflow: auto;
    touch-action: manipulation;
    font-family: 'Arial Rounded MT Bold', 'Arial', sans-serif;
    color: #fff;
    min-height: 100vh;
    
    /* Enhanced synthwave background with diagonal stripes */
    background: 
        linear-gradient(135deg, 
            transparent 0%, 
            transparent 30%, 
            rgba(0, 255, 255, 0.4) 30%, 
            rgba(0, 255, 255, 0.4) 40%, 
            transparent 40%, 
            transparent 60%, 
            rgba(232, 7, 203, 0.4) 60%, 
            rgba(232, 7, 203, 0.4) 70%, 
            transparent 70%, 
            transparent 90%, 
            rgba(254, 219, 61, 0.4) 90%, 
            rgba(254, 219, 61, 0.4) 100%),
        radial-gradient(circle at center, var(--dark-purple) 0%, var(--darker-purple) 70%);
    background-size: 100% 100%;
    background-position: 0% 0%;
    
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
}

/* Common glow line style */
.glow-line {
    height: 2px;
    background: linear-gradient(to right, 
        transparent, 
        var(--gradient-start), 
        var(--gradient-end), 
        var(--gradient-start), 
        transparent);
    margin: 10px auto;
    width: 80%;
    box-shadow: 0 0 10px var(--gradient-start), 0 0 20px var(--gradient-end);
}

/* ==========================================================================
   4. Header
   ========================================================================== */
header {
    width: 100%;
    text-align: center;
    padding: 20px 0;
    background-color: rgba(0, 0, 0, 0.7);
    margin-bottom: 20px;
    position: relative;
    z-index: 10;
}

header h1 {
    font-family: 'NeonWorld', 'Courier New', monospace;
    font-size: 4em;
    margin: 0;
    color: transparent;
    background: linear-gradient(to right, var(--gradient-start), var(--gradient-end));
    -webkit-background-clip: text;
    background-clip: text;
    text-shadow: 0 0 10px rgba(0, 255, 255, 0.5), 0 0 20px rgba(255, 0, 255, 0.5);
    letter-spacing: 5px;
    animation: textPulse 3s infinite;
}

/* ==========================================================================
   5. Game Device & Reflection
   ========================================================================== */
#reflection-container {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* Device container */
#device-container {
    position: relative;
    width: 800px;
    height: 950px;
    padding-top: 50px;
    transform-style: preserve-3d;
    perspective: 1000px;
    z-index: 2;
}

#device-image {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
    position: relative;
    z-index: 1;
}

/* Reflection element */
#device-reflection {
    position: relative;
    width: 800px;
    height: 700px;
    margin-top: -80px;
    margin-bottom: -115px;
    transform-origin: center top;
    z-index: 1;
    overflow: hidden;
}

#reflection-image {
    display: block;
    width: 100%;
    height: 950px;
    object-fit: contain;
    transform: scaleY(-1);
    opacity: 0.7;
    -webkit-mask-image: 
        linear-gradient(to top,
            rgba(0, 0, 0, 0.8) 0%, 
            rgba(0,0,0,0.4) 30%, 
            rgba(0,0,0,0.2) 55%, 
            rgba(0,0,0,0) 75%);
    filter: blur(1px) brightness(0.5);
}

/* Bottom fade for reflection */
#device-reflection::after {
    content: "";
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 80px;
    z-index: 3;
    pointer-events: none;
}

/* Reflection floor effect */
#reflection-container::before {
    content: "";
    position: absolute;
    bottom: 0;
    left: -200px;
    right: -200px;
    height: 300px;
    background: linear-gradient(to bottom, transparent, rgba(0, 0, 0, 0.8));
    transform: perspective(800px) rotateX(60deg);
    transform-origin: center bottom;
    z-index: 0;
    pointer-events: none;
    opacity: 0.3;
}

/* Glowing floor */
#reflection-container::after {
    content: "";
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 200px;
    background: radial-gradient(
        ellipse at center, 
        rgba(0, 255, 255, 0.05) 0%, 
        rgba(255, 0, 255, 0.05) 40%, 
        transparent 80%
    );
    z-index: 0;
    pointer-events: none;
}

/* Horizontal glow lines in reflection */
.glow-line-horizontal {
    position: absolute;
    height: 1px;
    left: 0;
    right: 0;
    background: linear-gradient(
        to right,
        transparent,
        rgba(0, 255, 255, 0.3),
        rgba(255, 0, 255, 0.3),
        rgba(0, 255, 255, 0.3),
        transparent
    );
    z-index: 2;
    box-shadow: 0 0 8px rgba(0, 255, 255, 0.5);
}

/* ==========================================================================
   6. Game Screen Elements
   ========================================================================== */
#screen-area {
    position: absolute;
    top: 20.2%;
    left: 21.5%;
    width: 56%;
    height: 34.4%;
    overflow: hidden;
    border-radius: 4px;
    background-color: #000;
    z-index: 2;
    box-shadow: 
        inset 0 0 10px var(--neon-cyan),
        0 0 15px var(--neon-cyan),
        0 0 25px rgba(0, 255, 255, 0.5);
    border: 1px solid rgba(0, 255, 255, 0.8);
}

/* Speaker ripple effect */
#speaker-ripple {
    position: absolute;
    bottom: 28.7%;
    left: 49.8%;
    transform: translate(-50%, 0);
    width: 105px;
    height: 105px;
    border-radius: 50%;
    background: radial-gradient(
        circle,
        rgba(246, 255, 0, 0.575) 0%,
        rgba(240, 0, 255, 0.4) 40%,
        rgba(0, 255, 255, 0.1) 80%
    );
    pointer-events: none;
    opacity: 1; /* Start invisible */
    z-index: 10;
    transition: opacity 0.5s ease;
    box-shadow: 0 0 10px rgba(255, 247, 0, 0.523);
    border: 1px solid rgba(240, 0, 255, 0.3);
}

#speaker-ripple.active {
    opacity: 0.7; /* Subtle visibility when active */
    animation: speakerRipple 0.9s infinite ease-out;
}

@keyframes speakerRipple {
    0% {
        transform: translate(-50%, 0) scale(0.8);
        opacity: 0.4;
        box-shadow: 0 0 8px rgba(255, 0, 0, 0.5);
    }
    25% {
        opacity: 0.4;
        box-shadow: 0 0 15px rgba(255, 183, 0, 0.6);
    }
    50% {
        transform: translate(-50%, 0) scale(1.1);
        opacity: 0.4;
        box-shadow: 0 0 12px rgba(128, 255, 0, 0.6);
    }
    100% {
        transform: translate(-50%, 0) scale(0.9);
        opacity: 0.4;
        box-shadow: 0 0 6px rgba(0, 255, 238, 0.4);
    }
}

/* Create a second ripple for more complex effect */
#speaker-ripple::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 40%;
    height: 40%;
    border-radius: 50%;
    background: rgba(240, 0, 255, 0.3);
    animation: innerRipple 1.5s infinite alternate ease-in-out;
}

@keyframes innerRipple {
    0% {
        transform: translate(-50%, -50%) scale(0.8);
        opacity: 0.3;
    }
    100% {
        transform: translate(-50%, -50%) scale(1.2);
        opacity: 0.15;
    }
}

#game-canvas {
    width: 100%;
    height: 100%;
    position: relative;
}

/* ==========================================================================
   7. Game UI
   ========================================================================== */
#score-display {
    position: absolute;
    top: 10px;
    left: 10px;
    color: var(--neon-cyan);
    font-family: 'ArcadeClassic', monospace;
    font-size: 1.5em;
    text-shadow: 
        0 0 5px var(--neon-cyan), 
        0 0 10px var(--neon-cyan);
    z-index: 100;
    letter-spacing: 4px;
    text-transform: uppercase;
}

#game-over {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.85);
    color: #0ff;
    padding: 30px;
    border-radius: 5px;
    text-align: center;
    display: none;
    border: 2px solid #0ff;
    box-shadow: 0 0 15px #0ff, 0 0 30px #0ff;
    z-index: 100;
    animation: borderPulse 2s infinite;
    min-width: 250px;
}

.game-over-content {
    width: 100%;
    text-align: center;
}

#game-over h1 {
    margin-top: 0;
    font-family: 'ArcadeClassic', monospace;
    text-shadow: 0 0 8px #0ff, 0 0 15px #f0f;
    letter-spacing: 5px;
    font-size: 2.5em;
    margin-bottom: 20px;
    text-transform: uppercase;
    color: #0ff;
}

#final-score {
    font-family: 'ArcadeClassic', monospace;
    font-size: 1.8em;
    margin-bottom: 25px;
    text-shadow: 0 0 5px #0ff;
    letter-spacing: 3px;
    text-transform: uppercase;
}

#restart-btn {
    background: #0ff;
    color: #000;
    border: none;
    padding: 15px 25px;
    margin-top: 15px;
    font-family: 'ArcadeClassic', monospace;
    font-weight: bold;
    cursor: pointer;
    border-radius: 5px;
    transition: all 0.3s ease;
    box-shadow: 0 0 15px #0ff;
    letter-spacing: 3px;
    font-size: 1.5em;
    text-transform: uppercase;
    position: relative;
    overflow: hidden;
}

#restart-btn::before {
    content: "";
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(
        to right,
        rgba(255, 255, 255, 0) 0%,
        rgba(255, 255, 255, 0.3) 50%,
        rgba(255, 255, 255, 0) 100%
    );
    transform: rotate(45deg);
    animation: buttonGlow 2s infinite;
    z-index: -1;
}

#restart-btn:hover {
    background: #f0f;
    box-shadow: 0 0 20px #f0f;
    transform: scale(1.05);
}

#restart-btn:active {
    transform: scale(0.95);
}

@keyframes buttonGlow {
    0% { transform: rotate(45deg) translate(-100%, -100%); }
    100% { transform: rotate(45deg) translate(100%, 100%); }
}

@keyframes borderPulse {
    0%, 100% {
        border-color: #0ff;
        box-shadow: 0 0 10px #0ff, 0 0 20px #0ff;
    }
    50% {
        border-color: #f0f;
        box-shadow: 0 0 10px #f0f, 0 0 20px #f0f;
    }
}

/* ==========================================================================
   8. Footer
   ========================================================================== */
footer {
    width: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    padding: 20px 0;
    margin-top: 40px;
    text-align: center;
    position: relative;
    z-index: 10;
}

.footer-content {
    display: flex;
    justify-content: space-around;
    align-items: flex-start;
    flex-wrap: wrap;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

.instructions {
    text-align: left;
    margin: 10px;
}

.instructions h3 {
    color: var(--neon-cyan);
    font-family: 'ArcadeClassic', monospace;
    font-size: 1.8em;
    text-shadow: 0 0 5px var(--neon-cyan);
    letter-spacing: 2px;
    margin-bottom: 10px;
}

.instructions p {
    font-size: 1em;
    line-height: 1.5;
    margin: 5px 0;
}

.key {
    display: inline-block;
    background-color: rgba(0, 0, 0, 0.7);
    border: 1px solid var(--neon-cyan);
    border-radius: 4px;
    padding: 2px 8px;
    color: var(--neon-cyan);
    text-shadow: 0 0 3px var(--neon-cyan);
    box-shadow: 0 0 5px var(--neon-cyan);
}

.credits {
    text-align: right;
    margin: 10px;
}

.credits p {
    font-size: 0.9em;
    margin: 5px 0;
}

.spotify-credit {
    margin-top: 20px;
    width: 100%;
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
    text-align: center;
}

.spotify-credit p {
    color: var(--neon-cyan);
    font-size: 14px;
    margin-bottom: 10px;
    text-shadow: 0 0 5px var(--neon-cyan);
}

.spotify-embed {
    width: 100%;
    max-width: 600px;
    margin: 30px auto 0;
    padding: 0 20px;
    text-align: center;
}

.music-credit {
    color: var(--neon-cyan);
    font-size: 1.1em;
    margin-bottom: 15px;
    text-shadow: 0 0 5px var(--neon-cyan);
    font-family: 'ArcadeClassic', monospace;
    letter-spacing: 2px;
}

.spotify-embed iframe {
    width: 100%;
    max-width: 600px;
    margin: 0 auto;
    box-shadow: 0 0 20px rgba(0, 255, 255, 0.3);
    transition: box-shadow 0.3s ease;
}

.spotify-embed iframe:hover {
    box-shadow: 0 0 30px rgba(0, 255, 255, 0.5);
}

/* ==========================================================================
   9. Media Queries
   ========================================================================== */
@media (max-width: 1200px) {
    #device-container, #device-reflection {
        width: 600px;
    }
    #device-container {
        height: 700px;
    }
    #reflection-image {
        height: 700px;
    }
}

@media (max-width: 768px) {
    #device-container, #device-reflection {
        width: 450px;
    }
    #device-container {
        height: 525px;
    }
    #reflection-image {
        height: 525px;
    }
    #device-reflection {
        height: 400px;
    }
    
    header h1 {
        font-size: 2.5em;
    }
    
    .footer-content {
        flex-direction: column;
        align-items: center;
    }
    
    .instructions, .credits {
        text-align: center;
        margin-bottom: 20px;
    }
    
    .spotify-embed {
        padding: 0 15px;
    }
}

@media (max-width: 480px) {
    #device-container, #device-reflection {
        width: 300px;
    }
    #device-container {
        height: 350px;
    }
    #reflection-image {
        height: 350px;
    }
    #device-reflection {
        height: 300px;
    }
    
    header h1 {
        font-size: 2.5em;
    }
    
    .footer-content {
        flex-direction: column;
        align-items: center;
    }
    
    .instructions, .credits {
        text-align: center;
        margin-bottom: 20px;
    }
    
    .spotify-embed {
        padding: 0 10px;
    }
    .music-credit {
        font-size: 0.9em;
    }
}