:root {
    --neon-pink: #ff2e97;
    --neon-blue: #00f3ff;
    --neon-purple: #b537f2;
    --neon-yellow: #f9f002;
    --neon-green: #00ff88;
    --dark-bg: #0a0a0a;
    --card-bg: rgba(0, 0, 0, 0.7);
    --border-glow: 0 0 15px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background: linear-gradient(135deg, var(--dark-bg), #1a1a1a);
    color: #ffffff;
    font-family: 'Open Sans', sans-serif;
    overflow-x: hidden;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    position: relative;
}

.cyber-grid {
    background-image:
        linear-gradient(rgba(255, 46, 151, 0.1) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 46, 151, 0.1) 1px, transparent 1px);
    background-size: 20px 20px;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: -1;
    pointer-events: none;
}

.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
}

header {
    text-align: center;
    margin-bottom: 20px;
    position: relative;
    z-index: 2;
    width: 100%;
}

.title {
    font-family: "Sigmar", serif;
    font-size: 3.5rem;
    margin-bottom: 10px;
    color: var(--neon-green);
    text-shadow: 0 0 20px rgba(0, 255, 136, 0.7);
    letter-spacing: 2px;
    text-transform: uppercase;
}

.sub-title {
    font-size: 1.5rem;
    margin-bottom: 20px;
    color: var(--neon-blue);
    text-shadow: 0 0 10px rgba(0, 243, 255, 0.5);
}

.game-wrapper {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

#game-container {
    width: 100%;
    max-width: 900px;
    aspect-ratio: 16/9;
    position: relative;
    background: var(--card-bg);
    border-radius: 15px;
    overflow: hidden;
    border: 2px solid var(--neon-blue);
    box-shadow: var(--border-glow) var(--neon-blue);
    transition: all 0.3s ease;
}

.target {
    position: absolute;
    width: 70px;
    height: 70px;
    border-radius: 50%;
    background: rgba(0, 255, 136, 0.2);
    border: 3px solid var(--neon-green);
    box-shadow: 0 0 15px var(--neon-green);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    animation: pulse 1.5s infinite;
    font-family: monospace;
    font-size: 1.8rem;
    color: var(--neon-green);
    text-shadow: 0 0 5px var(--neon-green);
    z-index: 2;
    transition: transform 0.2s ease;
}

.target:hover {
    transform: scale(1.1);
}

.target:active {
    transform: scale(0.9);
}

.stats-bar {
    display: flex;
    justify-content: space-between;
    width: 100%;
    max-width: 900px;
    padding: 15px;
    background: var(--card-bg);
    border-radius: 15px;
    border: 2px solid var(--neon-blue);
    box-shadow: var(--border-glow) var(--neon-blue);
}

.stat {
    text-align: center;
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 5px 0;
}

.stat-label {
    font-size: 1rem;
    color: var(--neon-blue);
    margin-bottom: 5px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.stat-value {
    font-size: 2rem;
    font-weight: bold;
    color: white;
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.7);
    font-family: 'League Gothic', sans-serif;
}

#timer .stat-value {
    color: var(--neon-yellow);
}

#score .stat-value {
    color: var(--neon-green);
}

#lives .stat-value {
    color: var(--neon-pink);
}

.game-over-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 10;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.5s ease;
    backdrop-filter: blur(4px);
}

.game-over-container.visible {
    opacity: 1;
    pointer-events: all;
}

.game-over-text {
    font-size: 2rem;
    font-weight: bold;
    color: var(--neon-pink);
    text-shadow: 0 0 15px var(--neon-pink);
    text-align: center;
    font-family: 'Sigmar', serif;
    letter-spacing: 2px;
}

.final-score {
    font-size: 1.5rem;
    color: var(--neon-green);
    margin-bottom: 40px;
    text-align: center;
    text-shadow: 0 0 10px var(--neon-green);
}

.button {
    background: linear-gradient(45deg, var(--neon-blue), var(--neon-purple));
    border: none;
    color: white;
    padding: 10px 25px; /* Reduced padding */
    font-size: 1.1rem; /* Reduced font size */
    font-weight: bold;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 0 15px rgba(0, 243, 255, 0.5);
    margin: 5px; /* Reduced margin */
    text-transform: uppercase;
    letter-spacing: 1px;
    z-index: 10; /* Ensure button is clickable */
    position: relative; /* Add relative position */
}

.button:hover {
    box-shadow: 0 0 20px rgba(255, 46, 151, 0.7);
    transform: translateY(-3px);
    background: linear-gradient(45deg, var(--neon-purple), var(--neon-pink));
}

.button:active {
    transform: translateY(0);
}

.back-btn {
    position: absolute;
    top: 20px;
    left: 20px;
    background: none;
    border: none;
    color: var(--neon-blue);
    font-size: 1.2rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.3s ease;
    z-index: 10;
    text-decoration: none;
}

.back-btn:hover {
    color: var(--neon-pink);
    transform: translateX(-5px);
}

#start-screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 5;
    padding: 20px;
}

.start-title {
    font-size: 3.5rem;
    font-weight: bold;
    color: var(--neon-green);
    text-shadow: 0 0 15px var(--neon-green);
    margin-bottom: -5px;
    text-align: center;
    font-family: 'Sigmar', serif;
    letter-spacing: 2px;
}

.instructions {
    text-align: left;
    width: 100%;
    max-width: 600px;
    margin-bottom: -10px;
    line-height: 1.8;
    background: rgba(0, 0, 0, 0.6);
    padding: 25px;
    border-radius: 15px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.instructions li {
    margin-bottom: 15px;
    list-style-type: none;
    font-size: 1.2rem;
}

.instructions li::before {
    content: ">";
    color: var(--neon-pink);
    margin-right: 12px;
    font-weight: bold;
}

.difficulty-container {
    display: flex;
    gap: 15px;
    margin-bottom: 10px;
    flex-wrap: wrap;
    justify-content: center;
}

.difficulty-btn {
    padding: 12px 25px;
    border: 2px solid var(--neon-blue);
    background: transparent;
    color: var(--neon-blue);
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 1.1rem;
    font-weight: bold;
    letter-spacing: 1px;
    min-width: 120px;
}

.difficulty-btn:hover {
    background-color: rgba(0, 243, 255, 0.2);
    box-shadow: 0 0 15px var(--neon-blue);
    transform: translateY(-2px);
}

.difficulty-btn.selected {
    background-color: var(--neon-blue);
    color: black;
    box-shadow: 0 0 15px var(--neon-blue);
}

.leaderboard {
    width: 100%;
    max-width: 900px;
    padding: 20px;
    background: var(--card-bg);
    border-radius: 15px;
    margin-top: 20px;
    border: 2px solid var(--neon-purple);
    box-shadow: var(--border-glow) var(--neon-purple);
}

.leaderboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.leaderboard-title {
    color: var(--neon-purple);
    text-align: center;
    font-size: 2rem;
    text-shadow: 0 0 10px var(--neon-purple);
    font-family: 'Sigmar', serif;
    letter-spacing: 1px;
    text-transform: uppercase;
}

.clear-btn {
    background: none;
    border: 1px solid var(--neon-pink);
    color: var(--neon-pink);
    padding: 5px 15px;
    font-size: 0.9rem;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.2s ease;
    letter-spacing: 1px;
}

.clear-btn:hover {
    background-color: var(--neon-pink);
    color: black;
    box-shadow: 0 0 10px var(--neon-pink);
}

.leaderboard-entries {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.leaderboard-entry {
    display: flex;
    justify-content: space-between;
    padding: 12px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    transition: all 0.2s ease;
}

.leaderboard-entry:hover {
    background: rgba(181, 55, 242, 0.1);
}

.leaderboard-entry.highlight {
    background: rgba(181, 55, 242, 0.2);
    border-radius: 8px;
    border: 1px solid var(--neon-purple);
    box-shadow: 0 0 10px rgba(181, 55, 242, 0.3);
}

.confirm-dialog {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.9);
    border: 2px solid var(--neon-purple);
    box-shadow: 0 0 20px var(--neon-purple);
    padding: 30px;
    border-radius: 15px;
    z-index: 100;
    text-align: center;
    max-width: 400px;
    width: 90%;
    backdrop-filter: blur(5px);
}

.confirm-dialog p {
    margin-bottom: 25px;
    font-size: 1.2rem;
    line-height: 1.6;
}

.confirm-dialog-buttons {
    display: flex;
    justify-content: center;
    gap: 15px;
}

@keyframes pulse {
    0%, 100% {
        box-shadow: 0 0 15px var(--neon-green);
        transform: scale(1);
    }
    50% {
        box-shadow: 0 0 25px var(--neon-green);
        transform: scale(1.05);
    }
}

/* Loading indicator */
.loading {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #000;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    transition: opacity 0.5s ease;
}

.loading-text {
    font-size: 2.5rem;
    color: var(--neon-green);
    text-shadow: 0 0 15px var(--neon-green);
    font-family: 'Sigmar', serif;
    letter-spacing: 2px;
    animation: glitch 1s infinite alternate;
}

@keyframes glitch {
    0% {
        text-shadow: 0.05em 0 0 var(--neon-pink), -0.05em -0.025em 0 var(--neon-blue),
            -0.025em 0.05em 0 var(--neon-green);
    }
    14% {
        text-shadow: 0.05em 0 0 var(--neon-pink), -0.05em -0.025em 0 var(--neon-blue),
            -0.025em 0.05em 0 var(--neon-green);
    }
    15% {
        text-shadow: -0.05em -0.025em 0 var(--neon-pink), 0.025em 0.025em 0 var(--neon-blue),
            -0.05em -0.05em 0 var(--neon-green);
    }
    49% {
        text-shadow: -0.05em -0.025em 0 var(--neon-pink), 0.025em 0.025em 0 var(--neon-blue),
            -0.05em -0.05em 0 var(--neon-green);
    }
    50% {
        text-shadow: 0.025em 0.05em 0 var(--neon-pink), 0.05em 0 0 var(--neon-blue),
            0 -0.05em 0 var(--neon-green);
    }
    99% {
        text-shadow: 0.025em 0.05em 0 var(--neon-pink), 0.05em 0 0 var(--neon-blue),
            0 -0.05em 0 var(--neon-green);
    }
    100% {
        text-shadow: -0.025em 0 0 var(--neon-pink), -0.025em -0.025em 0 var(--neon-blue),
            -0.025em -0.05em 0 var(--neon-green);
    }
}

/* Particle effects */
.particle {
    position: absolute;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background-color: var(--neon-pink);
    pointer-events: none;
    z-index: 3;
}

/* Level notification */
.level-notification {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 3.5rem;
    font-weight: bold;
    color: var(--neon-green);
    text-shadow: 0 0 20px var(--neon-green);
    z-index: 5;
    opacity: 0;
    pointer-events: none;
    font-family: 'Sigmar', serif;
    letter-spacing: 3px;
}

/* Digital code lines effect */
.code-line {
    position: absolute;
    height: 2px;
    background: var(--neon-green);
    opacity: 0.4;
    pointer-events: none;
    z-index: 1;
    box-shadow: 0 0 8px var(--neon-green);
}

/* Fix for mobile aspect ratio */
@media (max-width: 768px) {
    #game-container {
        aspect-ratio: 3/2; /* Less extreme aspect ratio for tablets */
    }
    
    /* Adjust font sizes for better fit */
    .start-title {
        font-size: 2rem;
        margin-bottom: 10px;
    }
    
    .instructions li {
        margin-bottom: 6px;
        font-size: 0.9rem;
    }
    
    .button {
        padding: 8px 20px;
        font-size: 1rem;
    }
}

@media (max-width: 480px) {
    #game-container {
        aspect-ratio: 4/3; /* More compact for phones */
        min-height: 350px; /* Ensure minimum height */
    }
    
    /* Further reduce sizes for mobile */
    .start-title {
        font-size: 1.8rem;
        margin-bottom: 8px;
    }
    
    .instructions {
        padding: 10px;
        margin-bottom: 15px;
    }
    
    .instructions li {
        margin-bottom: 5px;
        font-size: 0.85rem;
    }
    
    .difficulty-btn {
        padding: 6px 15px;
        font-size: 0.9rem;
        min-width: 80px;
    }
    
    .button {
        padding: 8px 18px;
        font-size: 0.9rem;
    }
}