/* Snake Game Pro - Ultra-fast, beautiful styling */

/* Enhanced animated background */
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 50%, #667eea 100%);
    background-size: 400% 400%;
    animation: gradientShift 8s ease infinite;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    position: relative;
}

body::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: radial-gradient(circle at 20% 30%, rgba(255, 255, 255, 0.1) 0%, transparent 50%),
                radial-gradient(circle at 80% 70%, rgba(255, 255, 255, 0.05) 0%, transparent 50%),
                radial-gradient(circle at 50% 50%, rgba(255, 255, 255, 0.02) 0%, transparent 70%);
    pointer-events: none;
}

@keyframes gradientShift {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

/* Additional styles beyond critical CSS */
.game-layout {
    display: flex;
    gap: 2rem;
    align-items: flex-start;
    justify-content: center;
    max-width: 800px;
    margin: 0 auto;
}

.game-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.game-status {
    min-height: 2rem;
    color: #ffd700;
    font-size: 1.1rem;
    font-weight: 600;
    text-align: center;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
    margin-bottom: 0.5rem;
}

.instructions-section {
    flex: 1;
    max-width: 400px;
    min-width: 300px;
}

.controls {
    margin-top: 1.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.score-display {
    display: flex;
    gap: 2rem;
    justify-content: center;
    margin-bottom: 1rem;
}

.score, .high-score {
    background: rgba(255, 255, 255, 0.2);
    padding: 0.5rem 1rem;
    border-radius: 25px;
    color: white;
    font-weight: 600;
    font-size: 1.1rem;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.score span, .high-score span {
    color: #ffd700;
    font-weight: 700;
}

.game-info {
    color: white;
    margin-bottom: 1rem;
}

.instructions-btn {
    background: linear-gradient(45deg, #4ecdc4, #44a08d);
    color: white;
    border: 2px solid #fff;
    padding: 0.8rem 1.5rem;
    border-radius: 50px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 8px 16px rgba(0,0,0,0.2);
    text-transform: uppercase;
    letter-spacing: 1px;
    min-width: 140px;
}

.instructions-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 24px rgba(0,0,0,0.3);
    background: linear-gradient(45deg, #5dd5cd, #4fa08d);
}

/* Instructions Popup */
.instructions-popup {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(10px);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 10000;
    opacity: 0;
    transition: all 0.3s ease;
}

.instructions-popup.show {
    display: flex;
    opacity: 1;
}

.instructions-content {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.2) 0%, rgba(255, 255, 255, 0.1) 100%);
    backdrop-filter: blur(20px);
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 20px;
    padding: 2rem;
    max-width: 500px;
    max-height: 80vh;
    overflow-y: auto;
    color: white;
    position: relative;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
    transform: scale(0.8);
    transition: transform 0.3s ease;
}

.instructions-popup.show .instructions-content {
    transform: scale(1);
}

.close-btn {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    font-size: 1.5rem;
    width: 35px;
    height: 35px;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.close-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

.instructions-content h3 {
    text-align: center;
    margin-bottom: 2rem;
    font-size: 1.5rem;
    color: #ffd700;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

.instruction-section {
    margin-bottom: 1.5rem;
}

.instruction-section h4 {
    color: #4ecdc4;
    font-size: 1.2rem;
    margin-bottom: 0.8rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
    padding-bottom: 0.5rem;
}

.instruction-section p {
    margin-bottom: 0.5rem;
    line-height: 1.6;
    font-size: 1rem;
}

.instruction-section ul {
    margin: 0 0 0 1.5rem;
    padding: 0;
}

.instruction-section li {
    margin-bottom: 0.5rem;
    line-height: 1.6;
    font-size: 0.95rem;
    color: #f0f0f0;
}

.game-info p {
    font-size: 1rem;
    margin-bottom: 1rem;
    opacity: 0.9;
}

.button-group {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 1rem;
}

.start-btn {
    background: linear-gradient(45deg, #ff6b6b, #ee5a24) !important;
    color: white !important;
    border: 3px solid #fff !important;
    padding: 1rem 2rem !important;
    border-radius: 50px !important;
    font-size: 1.1rem !important;
    font-weight: 600 !important;
    cursor: pointer !important;
    transition: all 0.3s ease !important;
    box-shadow: 0 10px 20px rgba(0,0,0,0.2) !important;
    text-transform: uppercase !important;
    letter-spacing: 1px !important;
    min-width: 150px !important;
    display: inline-block !important;
    visibility: visible !important;
    opacity: 1 !important;
    z-index: 9999 !important;
    position: relative !important;
}

/* Mobile Controls */
.mobile-controls {
    display: none;
    margin-top: 1rem;
}

.d-pad {
    display: grid;
    grid-template-rows: auto auto auto;
    gap: 0.5rem;
    justify-items: center;
    max-width: 200px;
    margin: 0 auto;
}

.middle-row {
    display: flex;
    gap: 3rem;
    align-items: center;
}

.control-btn {
    width: 60px;
    height: 60px;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    font-size: 1.5rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s ease;
    backdrop-filter: blur(10px);
    border: 2px solid rgba(255, 255, 255, 0.3);
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.control-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

.control-btn:active {
    background: rgba(255, 255, 255, 0.4);
    transform: scale(0.95);
}


/* Game States */
.game-over {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 2rem;
    border-radius: 15px;
    text-align: center;
    backdrop-filter: blur(20px);
    border: 2px solid rgba(255, 255, 255, 0.2);
    z-index: 15000;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
}

.game-over h2 {
    font-size: 2rem;
    margin-bottom: 1rem;
    color: #ff6b6b;
}

.game-over p {
    margin-bottom: 1.5rem;
    font-size: 1.1rem;
}

.restart-btn {
    background: linear-gradient(45deg, #4ecdc4, #44a08d);
    color: white;
    border: none;
    padding: 0.8rem 1.5rem;
    border-radius: 25px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.restart-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(0,0,0,0.3);
}

/* Responsive Design */
@media (max-width: 768px) {
    .game-layout {
        flex-direction: column;
        gap: 1.5rem;
        align-items: center;
    }
    
    .mobile-controls {
        display: block;
    }
    
    #gameCanvas {
        width: 90vw;
        height: 90vw;
        max-width: 400px;
        max-height: 400px;
    }
    
    .score-display {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    h1 {
        font-size: 2rem;
        margin-bottom: 1rem;
    }
    
    .game-container {
        padding: 0.5rem;
    }
    
    .instructions-content {
        margin: 1rem;
        max-width: calc(100vw - 2rem);
        max-height: 85vh;
        padding: 1.5rem;
    }
    
    .instruction-section h4 {
        font-size: 1.1rem;
    }
    
    .instruction-section p, .instruction-section li {
        font-size: 0.9rem;
    }
}

@media (max-width: 480px) {
    .game-layout {
        gap: 1rem;
    }
    
    .control-btn {
        width: 50px;
        height: 50px;
        font-size: 1.2rem;
    }
    
    .middle-row {
        gap: 2rem;
    }
    
    .start-btn {
        padding: 0.8rem 1.5rem;
        font-size: 1rem;
        min-width: 160px;
    }
    
    .instructions-btn {
        padding: 0.7rem 1.3rem;
        font-size: 0.9rem;
        min-width: 130px;
    }
    
    .instructions-content {
        padding: 1rem;
        margin: 0.5rem;
        max-height: 90vh;
    }
    
    .instructions-content h3 {
        font-size: 1.3rem;
        margin-bottom: 1.5rem;
    }
    
    .instruction-section h4 {
        font-size: 1rem;
    }
    
    .instruction-section p, .instruction-section li {
        font-size: 0.85rem;
        line-height: 1.5;
    }
}

/* Animations */
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

.pulse {
    animation: pulse 1s infinite;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.slide-in {
    animation: slideIn 0.5s ease-out;
}

/* Performance optimizations */
* {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

canvas {
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    /* Already optimized for dark theme */
}

/* High contrast mode */
@media (prefers-contrast: high) {
    .control-btn,
    .start-btn,
    .score,
    .high-score {
        border: 2px solid white;
    }
} 