@import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@400;700;900&display=swap');

:root {
    --neon-pink: #ff00ff;
    --neon-cyan: #00ffff;
    --deep-purple: #1a0033;
    --grid-color: rgba(255, 0, 255, 0.3);
}

body {
    margin: 0;
    background-color: #050010;
    color: white;
    font-family: 'Orbitron', sans-serif;
    overflow: hidden; /* Prevents scrollbars */
    height: 100vh; /* Full viewport height */
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center; /* Center vertically */
    user-select: none; /* Prevents text selection */
    touch-action: none; /* Disables browser gestures like swipe-to-refresh */
}

/* --- Background Synthwave Grid --- */
.world-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    perspective: 800px;
    overflow: hidden;
    z-index: -1;
}

.floor {
    position: absolute;
    bottom: -25%;
    left: -50%;
    width: 200%;
    height: 100%;
    background-image: 
        linear-gradient(transparent 95%, var(--neon-pink) 95%),
        linear-gradient(90deg, transparent 95%, var(--neon-pink) 95%);
    background-size: 60px 60px;
    transform: rotateX(60deg);
    animation: moveGrid 1s linear infinite;
    box-shadow: 0 -50px 100px var(--neon-pink);
    mask-image: linear-gradient(to top, rgba(0,0,0,1) 0%, rgba(0,0,0,0) 80%);
}

.sun {
    position: absolute;
    top: 5%; /* Adjusted for mobile */
    left: 50%;
    transform: translateX(-50%);
    width: 150px; /* Slightly smaller for mobile */
    height: 150px;
    background: linear-gradient(to bottom, #ffd700, #ff00ff);
    border-radius: 50%;
    box-shadow: 0 0 60px #ff00ff;
    mask-image: linear-gradient(to bottom, rgba(0,0,0,1) 60%, rgba(0,0,0,0.6) 65%, rgba(0,0,0,1) 70%, rgba(0,0,0,0.6) 75%, rgba(0,0,0,1) 80%);
    z-index: -2;
}

/* --- Game UI --- */
.ui-header {
    text-align: center;
    margin-bottom: 10px;
    flex-shrink: 0; /* Don't shrink header */
    z-index: 10;
}

h1 {
    margin: 0;
    font-size: clamp(20px, 5vw, 32px); /* Responsive font size */
    text-transform: uppercase;
    letter-spacing: 4px;
    text-shadow: 
        2px 0 var(--neon-cyan), 
        -2px 0 var(--neon-pink);
    animation: glitch 2s infinite alternate-reverse;
}

#score-board {
    font-size: clamp(14px, 3.5vw, 18px);
    color: var(--neon-cyan);
    text-shadow: 0 0 10px var(--neon-cyan);
    margin-top: 5px;
    display: flex;
    gap: 20px;
    justify-content: center;
}

.score-label {
    color: white;
    opacity: 0.8;
    font-size: 0.8em;
}

/* --- Game Area --- */
#gameArea {
    position: relative;
    /* Responsive Sizing */
    width: min(360px, 90vw); 
    height: min(550px, 60vh);
    
    border: 2px solid rgba(255, 255, 255, 0.1);
    background: rgba(26, 0, 51, 0.4);
    backdrop-filter: blur(2px);
    overflow: hidden;
    box-shadow: 
        0 0 20px var(--neon-cyan),
        inset 0 0 50px rgba(0, 255, 255, 0.1);
    border-radius: 4px;
    flex-shrink: 1; /* Allow shrinking on very small screens */
}

/* Player */
#player {
    position: absolute;
    bottom: 20px;
    width: 40px;
    height: 40px;
    background: transparent;
    border-bottom: 4px solid var(--neon-pink);
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    box-shadow: 0 10px 20px var(--neon-pink); 
    filter: drop-shadow(0 0 5px var(--neon-pink));
    transition: left 0.05s linear;
    z-index: 10;
    /* Ensure touch works better */
    pointer-events: none; 
}

#player::after {
    content: '';
    position: absolute;
    top: -25px; 
    left: -4px;
    width: 0;
    height: 0;
    border-left: 24px solid transparent;
    border-right: 24px solid transparent;
    border-bottom: 40px solid var(--neon-pink);
    opacity: 0.3; 
}

/* Enemy Blocks */
.block {
    position: absolute;
    width: 35px; /* Slightly smaller for mobile balance */
    height: 35px;
    background: rgba(0, 255, 255, 0.1);
    border: 2px solid var(--neon-cyan);
    box-shadow: 0 0 15px var(--neon-cyan), inset 0 0 10px var(--neon-cyan);
    z-index: 5;
    transform: rotate(45deg); 
}

/* --- Modals --- */
.modal {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.9);
    border: 1px solid var(--neon-cyan);
    padding: 20px;
    text-align: center;
    width: 80%;
    max-width: 280px;
    backdrop-filter: blur(10px);
    box-shadow: 0 0 30px rgba(0, 255, 255, 0.2);
    z-index: 50;
    border-radius: 8px;
}

.hidden { display: none !important; }

.modal h2 {
    color: white;
    font-size: 20px;
    text-shadow: 0 0 10px white;
    margin-top: 0;
}

.btn {
    margin-top: 15px;
    padding: 12px 24px;
    background: transparent;
    color: var(--neon-pink);
    border: 2px solid var(--neon-pink);
    font-family: 'Orbitron', sans-serif;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    text-transform: uppercase;
    transition: 0.3s;
    box-shadow: 0 0 10px var(--neon-pink);
    width: 100%;
    /* Prevent blue tap highlight on mobile */
    -webkit-tap-highlight-color: transparent;
}

.btn:active {
    background: var(--neon-pink);
    color: black;
    transform: scale(0.98);
}

/* --- Mobile Controls --- */
.controls {
    margin-top: 20px;
    display: flex;
    gap: 40px;
    z-index: 20;
    flex-shrink: 0;
}

.control-btn {
    width: 60px;
    height: 60px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    color: white;
    font-size: 24px;
    background: rgba(255, 255, 255, 0.05);
    cursor: pointer;
    transition: 0.1s;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.control-btn:active, .control-btn.active {
    border-color: var(--neon-cyan);
    background: rgba(0, 255, 255, 0.2);
    box-shadow: 0 0 20px var(--neon-cyan);
    transform: scale(0.95);
}

/* --- Animations --- */
@keyframes moveGrid {
    0% { transform: rotateX(60deg) translateY(0); }
    100% { transform: rotateX(60deg) translateY(60px); }
}

@keyframes glitch {
    0% { text-shadow: 2px 0 var(--neon-cyan), -2px 0 var(--neon-pink); }
    25% { text-shadow: -2px 0 var(--neon-cyan), 2px 0 var(--neon-pink); }
    50% { text-shadow: 2px 0 var(--neon-pink), -2px 0 var(--neon-cyan); }
    75% { text-shadow: -2px 0 var(--neon-pink), 2px 0 var(--neon-cyan); }
    100% { text-shadow: 2px 0 var(--neon-cyan), -2px 0 var(--neon-pink); }
}

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

@keyframes shake {
    0% { transform: translate(1px, 1px) rotate(0deg); }
    10% { transform: translate(-1px, -2px) rotate(-1deg); }
    20% { transform: translate(-3px, 0px) rotate(1deg); }
    30% { transform: translate(3px, 2px) rotate(0deg); }
    40% { transform: translate(1px, -1px) rotate(1deg); }
    50% { transform: translate(-1px, 2px) rotate(-1deg); }
    60% { transform: translate(-3px, 1px) rotate(0deg); }
    70% { transform: translate(3px, 1px) rotate(-1deg); }
    80% { transform: translate(-1px, -1px) rotate(1deg); }
    90% { transform: translate(1px, 2px) rotate(0deg); }
    100% { transform: translate(1px, -2px) rotate(-1deg); }
}

.shake {
    animation: shake 0.5s cubic-bezier(.36,.07,.19,.97) both;
}

.explosion {
    position: absolute;
    width: 50px;
    height: 50px;
    border: 2px solid white;
    border-radius: 50%;
    animation: pulse 0.4s ease-out forwards;
    z-index: 20;
}

/* --- Level Up Notification --- */
#level-up-msg {
    position: absolute;
    top: 40%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 40px;
    font-weight: 900;
    color: var(--neon-cyan);
    text-shadow: 
        0 0 10px white,
        0 0 20px var(--neon-pink);
    z-index: 100;
    pointer-events: none;
    letter-spacing: 5px;
    text-align: center;
    width: 100%;
    animation: flashText 0.2s infinite alternate;
}

@keyframes flashText {
    0% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
    100% { opacity: 0.8; transform: translate(-50%, -50%) scale(1.1); }
}

/* --- Name Input Styling --- */
#name-input {
    background: rgba(0, 0, 0, 0.6);
    border: 2px solid var(--neon-cyan);
    color: white;
    padding: 10px;
    font-family: 'Orbitron', sans-serif;
    text-transform: uppercase;
    text-align: center;
    font-size: 16px;
    width: 80%;
    margin-bottom: 10px;
    outline: none;
    box-shadow: 0 0 10px rgba(0, 255, 255, 0.2);
    border-radius: 4px;
}

#name-input::placeholder {
    color: rgba(255, 255, 255, 0.5);
}

#name-input:focus {
    box-shadow: 0 0 20px var(--neon-cyan);
    background: rgba(0, 255, 255, 0.1);
}

#player-info {
    color: #000000; /* Dark Teal */
    text-shadow: 0 0 5px #00ffff; /* Neon glow */
    font-size: 12px;
    margin-bottom: 5px;
    letter-spacing: 2px;
}