/* Snake Equation Game Styles */
.snake-equation-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: linear-gradient(45deg, #000033, #330066);
    padding: 10px;
    font-family: 'Press Start 2P', 'Courier New', monospace;
    height: 100%;
    width: 100%;
    color: #00ff00;
    position: relative;
    overflow: auto;
    gap: 8px;
    box-sizing: border-box;
}

.game-header {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 5px;
}

.controls {
    display: flex;
    gap: 5px;
    flex-wrap: wrap;
    align-items: center;
}

.game-info {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
}

.difficulty-btn, .start-btn {
    padding: 6px 12px;
    font-family: inherit;
    font-size: 10px;
    border: 2px solid #00ff00;
    background: #000033;
    color: #00ff00;
    cursor: pointer;
    transition: all 0.3s ease;
    white-space: nowrap;
}

.difficulty-btn:hover, .start-btn:hover {
    background: #00ff00;
    color: #000033;
    box-shadow: 0 0 10px #00ff00;
}

.difficulty-btn.active {
    background: #00ff00;
    color: #000033;
}

.score-display, .level-display, .progress-display {
    font-size: 12px;
    color: #ff00ff;
    text-shadow: 0 0 5px #ff00ff;
    white-space: nowrap;
}

.high-scores {
    width: 100%;
    background: rgba(0, 0, 51, 0.5);
    padding: 8px;
    border: 1px solid #00ff00;
    border-radius: 5px;
    margin: 5px 0;
    text-align: center;
}

.high-scores-title {
    color: #00ffff;
    font-size: 12px;
    margin-bottom: 5px;
    text-shadow: 0 0 5px #00ffff;
}

.high-scores-list {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 5px;
    color: #ffff00;
    font-size: 10px;
}

.target-equation, .current-equation {
    font-size: 12px;
    margin: 3px 0;
    color: #00ffff;
    text-shadow: 0 0 5px #00ffff;
    text-align: center;
    width: 100%;
}

.game-canvas {
    border: 2px solid #00ff00;
    box-shadow: 0 0 20px #00ff00;
    width: min(400px, 90%);
    height: min(400px, 90vw);
    margin: 5px 0;
    background: #000033;
}

.game-message {
    font-size: 20px;
    color: #ff0000;
    text-shadow: 0 0 5px #ff0000;
    text-align: center;
    display: none;
    animation: pulse 2s infinite;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 51, 0.9);
    padding: 15px;
    border-radius: 10px;
    z-index: 50;
}

.game-over-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 100;
}

.game-over-content {
    background: rgba(0, 0, 51, 0.9);
    padding: 20px;
    border: 2px solid #00ff00;
    border-radius: 10px;
    text-align: center;
    box-shadow: 0 0 20px #00ff00;
    animation: glowPulse 2s infinite;
    max-width: 90%;
}

.game-over-message {
    color: #ff0000;
    font-size: 20px;
    margin-bottom: 15px;
    text-shadow: 0 0 10px #ff0000;
}

.final-score {
    color: #00ffff;
    font-size: 16px;
    margin-bottom: 15px;
}

.new-high-score {
    color: #ffff00;
    font-size: 18px;
    margin-bottom: 15px;
    animation: rainbow 2s infinite;
}

.retry-btn {
    padding: 10px 20px;
    font-family: inherit;
    font-size: 14px;
    background: #000033;
    color: #00ff00;
    border: 2px solid #00ff00;
    cursor: pointer;
    transition: all 0.3s ease;
}

.retry-btn:hover {
    background: #00ff00;
    color: #000033;
    box-shadow: 0 0 20px #00ff00;
}

/* Animations */
@keyframes pulse {
    0% { opacity: 0.5; }
    50% { opacity: 1; }
    100% { opacity: 0.5; }
}

@keyframes glowPulse {
    0% { box-shadow: 0 0 20px #00ff00; }
    50% { box-shadow: 0 0 40px #00ff00; }
    100% { box-shadow: 0 0 20px #00ff00; }
}

@keyframes rainbow {
    0% { color: #ff0000; }
    20% { color: #ffff00; }
    40% { color: #00ff00; }
    60% { color: #00ffff; }
    80% { color: #ff00ff; }
    100% { color: #ff0000; }
}

/* Grid animation */
.snake-equation-container::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: 
        linear-gradient(90deg, #00ff0022 1px, transparent 1px) 0 0 / 20px 20px,
        linear-gradient(#00ff0022 1px, transparent 1px) 0 0 / 20px 20px;
    animation: gridMove 20s linear infinite;
    pointer-events: none;
    z-index: 0;
}

@keyframes gridMove {
    0% { transform: translate(0, 0); }
    100% { transform: translate(20px, 20px); }
}

/* Ensure all content stays above the grid background */
.game-header,
.target-equation,
.current-equation,
.game-canvas,
.game-message,
.high-scores {
    position: relative;
    z-index: 1;
}

/* Responsive adjustments */
@media (max-width: 500px) {
    .game-header {
        flex-direction: column;
        align-items: stretch;
    }

    .controls, .game-info {
        justify-content: center;
    }

    .difficulty-btn, .start-btn {
        font-size: 9px;
        padding: 5px 10px;
    }

    .high-scores-list {
        grid-template-columns: repeat(3, 1fr);
        font-size: 9px;
    }

    .game-canvas {
        width: 95%;
        height: 95vw;
    }
}