:root {
    --black: #000000;
    --white: #FFFFFF;
    --gray-dark: #333333;
    --gray-medium: #666666;
    --gray-light: #999999;
    --red: #FF0000;
    --dot-size: 40px;
    --dot-gap: 20px;
    --transition-speed: 0.3s;
    --glow-size: 10px;
}

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

body {
    background-color: var(--black);
    color: var(--white);
    font-family: Arial, sans-serif;
    width: 100vw;
    height: 100vh;
    overflow: hidden;
}

#game-container {
    width: 100%;
    height: 100%;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Lives indicator (top-left) */
#lives-container {
    position: absolute;
    top: 20px;
    left: 20px;
    display: flex;
    gap: 10px;
}

.life {
    width: 15px;
    height: 15px;
    border-radius: 50%;
    background-color: var(--white);
    transition: opacity var(--transition-speed) ease-in-out;
}

.life.lost {
    opacity: 0.3;
}

/* Score display (top-right) */
#score-container {
    position: absolute;
    top: 20px;
    right: 20px;
    font-size: 32px;
}

/* Dots grid (center) */
#dots-grid {
    display: grid;
    grid-template-columns: repeat(5, calc(var(--dot-size) + var(--dot-gap)));
    grid-gap: var(--dot-gap);
    justify-content: center;
    align-items: center;
}

.dot {
    width: var(--dot-size);
    height: var(--dot-size);
    border-radius: 50%;
    background-color: var(--gray-dark);
    cursor: pointer;
    transition: all var(--transition-speed) ease-in-out;
}

.dot.active {
    background-color: var(--white);
    box-shadow: 0 0 var(--glow-size) var(--white);
    transform: scale(1.1);
    animation: pulse-urgent 0.6s ease-in-out infinite alternate;
}

@keyframes pulse-urgent {
    0% {
        transform: scale(1.05);
        box-shadow: 0 0 var(--glow-size) var(--white);
    }

    100% {
        transform: scale(1.15);
        box-shadow: 0 0 calc(var(--glow-size) * 1.5) var(--white);
    }
}

.dot.success {
    animation: success-pulse 0.4s ease-in-out;
}

.dot.failure {
    /* Change background to red for incorrect clicks */
    background-color: var(--red);
    /* Keep the quick-fade or remove/change animation as needed */
    /* Faster animation */
    animation: quick-fade 0.2s ease-in-out;
}

/* Add quick-fade animation if it doesn't exist or needs adjustment */
@keyframes quick-fade {
    0% {
        opacity: 1;
    }

    100% {
        opacity: 0.5;
        /* Or fade out completely if preferred */
    }
}


/* New class for missed dots */
.dot.missed {
    background-color: var(--red);
    /* Faster animation */
    animation: shake 0.2s ease-in-out;
}

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

    50% {
        transform: scale(1.2);
    }

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

@keyframes shake {
    0% {
        transform: translateX(0);
    }

    25% {
        transform: translateX(-5px);
    }

    50% {
        transform: translateX(5px);
    }

    75% {
        transform: translateX(-5px);
    }

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

/* Help button (bottom-right) */
#help-button {
    position: absolute;
    bottom: 20px;
    right: 20px;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: 2px solid var(--white);
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    font-size: 20px;
    transition: background-color var(--transition-speed) ease-in-out;
}

#help-button:hover {
    background-color: var(--gray-dark);
}

/* Help panel */
#help-panel {
    position: absolute;
    bottom: 60px;
    right: 20px;
    background-color: var(--gray-dark);
    border: 1px solid var(--white);
    padding: 20px;
    border-radius: 5px;
    max-width: 300px;
    transition: opacity var(--transition-speed) ease-in-out, transform var(--transition-speed) ease-in-out;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    line-height: 1.6;
}

#help-panel.hidden {
    opacity: 0;
    transform: translateY(20px);
    pointer-events: none;
}

#help-content p {
    margin-bottom: 10px;
    color: var(--white);
}

#help-content p:first-child {
    margin-bottom: 15px;
    font-weight: 500;
}

#help-content p:not(:first-child) {
    color: var(--gray-light);
    font-size: 0.95rem;
}

#close-help {
    position: absolute;
    top: 10px;
    right: 10px;
    cursor: pointer;
    font-size: 20px;
}

/* Pause overlay */
#pause-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    transition: opacity var(--transition-speed) ease-in-out;
}

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

#pause-overlay:before {
    content: "";
    width: 30px;
    height: 80px;
    border-left: 20px solid var(--white);
    border-right: 20px solid var(--white);
}

/* Game over overlay */
#game-over {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 20px;
    transition: opacity var(--transition-speed) ease-in-out;
}

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

#final-score,
#high-score {
    font-size: 48px;
}

#restart-button {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    border: 3px solid var(--white);
    position: relative;
    cursor: pointer;
    transition: background-color var(--transition-speed) ease-in-out;
}

#restart-button:after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    border-top: 3px solid var(--white);
    border-right: 3px solid var(--white);
    transform: translate(-70%, -50%) rotate(45deg);
}

#restart-button:hover {
    background-color: var(--gray-dark);
}

/* Error overlay */
#error-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--red);
    display: flex;
    justify-content: center;
    align-items: center;
    animation: error-border 0.5s infinite alternate;
    transition: opacity var(--transition-speed) ease-in-out;
}

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

#error-icon {
    width: 100px;
    height: 100px;
    position: relative;
}

#error-icon:before,
#error-icon:after {
    content: "";
    position: absolute;
    background-color: var(--white);
}

#error-icon:before {
    width: 100%;
    height: 10px;
    top: 45px;
    transform: rotate(45deg);
}

#error-icon:after {
    width: 100%;
    height: 10px;
    top: 45px;
    transform: rotate(-45deg);
}

@keyframes error-border {
    from {
        box-shadow: inset 0 0 0 5px var(--white);
    }

    to {
        box-shadow: inset 0 0 0 15px var(--white);
    }
}