/* Snake Game - Neon Aesthetic */
:root {
    --bg-primary: #0a0a0f;
    --bg-secondary: #12121a;
    --bg-card: rgba(18, 18, 26, 0.9);
    --neon-green: #00ff88;
    --neon-green-glow: rgba(0, 255, 136, 0.5);
    --neon-red: #ff3366;
    --neon-yellow: #f7a600;
    --neon-blue: #00d4ff;
    --neon-purple: #a855f7;
    --text-primary: #f9fafb;
    --text-secondary: #a0a9b8;
    --text-muted: #6b7280;
    --font-family: 'Plus Jakarta Sans', sans-serif;
    --radius-md: 12px;
    --radius-lg: 20px;
    --transition-fast: 150ms ease;
    --transition-base: 300ms ease;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; overflow: hidden; touch-action: none; }
body {
    font-family: var(--font-family);
    background: var(--bg-primary);
    background-image: 
        radial-gradient(circle at 20% 80%, rgba(0, 255, 136, 0.03) 0%, transparent 50%),
        radial-gradient(circle at 80% 20%, rgba(0, 212, 255, 0.03) 0%, transparent 50%);
    color: var(--text-primary);
}

/* Navigation */
.game-nav {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 2rem;
    background: rgba(10, 10, 15, 0.9);
    backdrop-filter: blur(10px);
    z-index: 100;
    border-bottom: 1px solid rgba(0, 255, 136, 0.1);
}

.back-link {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 500;
    transition: var(--transition-fast);
}
.back-link svg { width: 20px; height: 20px; }
.back-link:hover { color: var(--neon-green); }

.game-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--neon-green);
    text-shadow: 0 0 10px var(--neon-green-glow);
}

.high-score {
    font-weight: 600;
    color: var(--neon-yellow);
}

/* Container */
.game-container {
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4.5rem 1rem 1rem;
}

/* Screens */
.screen { display: none; width: 100%; animation: fadeIn 0.4s ease; }
.screen.active { display: flex; align-items: center; justify-content: center; }
@keyframes fadeIn { from { opacity: 0; transform: scale(0.95); } to { opacity: 1; transform: scale(1); } }

.screen-content {
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    padding: 2.5rem;
    border-radius: var(--radius-lg);
    border: 1px solid rgba(0, 255, 136, 0.1);
    text-align: center;
    max-width: 400px;
    width: 100%;
}

/* Intro Screen */
.game-icon { font-size: 4rem; margin-bottom: 1rem; animation: snakeWiggle 2s ease-in-out infinite; }
@keyframes snakeWiggle { 0%, 100% { transform: rotate(-5deg); } 50% { transform: rotate(5deg); } }

.intro-screen h1 {
    font-size: 2.5rem;
    font-weight: 800;
    color: var(--neon-green);
    text-shadow: 0 0 20px var(--neon-green-glow);
    margin-bottom: 0.5rem;
}

.tagline { color: var(--text-secondary); margin-bottom: 2rem; }

/* Controls Info */
.controls-info { margin-bottom: 2rem; }
.controls-info h3 {
    font-size: 0.85rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 1rem;
}

.control-grid {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
}
.control-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0.75rem 1rem;
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    border: 1px solid rgba(255, 255, 255, 0.05);
}
.control-item .key {
    font-weight: 700;
    color: var(--neon-green);
    font-size: 0.9rem;
}
.control-item .desc {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Buttons */
.btn-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    background: var(--neon-green);
    color: var(--bg-primary);
    border: none;
    padding: 1rem 2.5rem;
    font-size: 1.1rem;
    font-weight: 700;
    border-radius: 9999px;
    cursor: pointer;
    transition: var(--transition-base);
    font-family: inherit;
    box-shadow: 0 0 20px var(--neon-green-glow);
}
.btn-primary svg { width: 20px; height: 20px; }
.btn-primary:hover { transform: translateY(-3px); box-shadow: 0 0 40px var(--neon-green-glow); }

.btn-secondary {
    padding: 0.75rem 1.5rem;
    background: transparent;
    border: 2px solid var(--text-muted);
    color: var(--text-secondary);
    border-radius: 9999px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition-base);
    font-family: inherit;
}
.btn-secondary:hover { border-color: var(--neon-green); color: var(--neon-green); }

.best-score {
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}
.best-score .label { display: block; font-size: 0.85rem; color: var(--text-muted); }
.best-score .value { font-size: 2rem; font-weight: 800; color: var(--neon-yellow); }

/* Game Screen */
.game-screen {
    flex-direction: column;
    gap: 1rem;
    max-width: 100%;
    height: calc(100vh - 60px);
    padding-top: 0;
}

.game-hud {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 2rem;
    padding: 0.5rem;
}

.score-display {
    display: flex;
    flex-direction: column;
    align-items: center;
}
.score-label { font-size: 0.75rem; color: var(--text-muted); text-transform: uppercase; }
.score-value {
    font-size: 2.5rem;
    font-weight: 800;
    color: var(--neon-green);
    text-shadow: 0 0 15px var(--neon-green-glow);
    line-height: 1;
}

.power-ups {
    display: flex;
    gap: 0.5rem;
}
.power-up {
    padding: 0.25rem 0.5rem;
    background: rgba(0, 212, 255, 0.2);
    border: 1px solid var(--neon-blue);
    border-radius: 9999px;
    font-size: 0.75rem;
    color: var(--neon-blue);
    animation: pulse 1s infinite;
}
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }

/* Game Wrapper */
.game-wrapper {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    flex: 1;
    min-height: 0;
}

#gameCanvas {
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    border: 2px solid rgba(0, 255, 136, 0.2);
    box-shadow: 0 0 30px rgba(0, 255, 136, 0.1);
    max-width: 100%;
    max-height: 100%;
}

/* Game Overlay */
.game-overlay {
    position: absolute;
    inset: 0;
    background: rgba(10, 10, 15, 0.9);
    display: none;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md);
}
.game-overlay.active { display: flex; }
.overlay-content { text-align: center; }
.overlay-icon { font-size: 3rem; display: block; margin-bottom: 1rem; }
.overlay-content h2 { color: var(--neon-green); margin-bottom: 0.5rem; }
.overlay-content p { color: var(--text-muted); }

/* Mobile Controls */
.mobile-controls {
    display: none;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem;
}
.control-row { display: flex; gap: 3rem; }
.control-btn {
    width: 60px;
    height: 60px;
    background: var(--bg-card);
    border: 2px solid var(--neon-green);
    border-radius: var(--radius-md);
    color: var(--neon-green);
    font-size: 1.5rem;
    cursor: pointer;
    transition: var(--transition-fast);
    font-family: inherit;
}
.control-btn:active {
    background: var(--neon-green);
    color: var(--bg-primary);
}

/* Game Over Screen */
.gameover-icon { font-size: 4rem; margin-bottom: 1rem; animation: shake 0.5s ease; }
@keyframes shake { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-10px); } 75% { transform: translateX(10px); } }

.gameover-screen h2 {
    font-size: 2rem;
    font-weight: 800;
    color: var(--neon-red);
    margin-bottom: 1rem;
}

.final-score {
    margin-bottom: 1rem;
}
.final-score .score-value {
    font-size: 4rem;
    font-weight: 800;
    color: var(--neon-green);
    text-shadow: 0 0 20px var(--neon-green-glow);
    line-height: 1;
}
.final-score .score-label {
    font-size: 1rem;
    color: var(--text-muted);
}

.new-record {
    background: rgba(247, 166, 0, 0.1);
    border: 1px solid var(--neon-yellow);
    color: var(--neon-yellow);
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-md);
    font-weight: 600;
    margin-bottom: 1rem;
    animation: glow 2s infinite;
}
@keyframes glow { 0%, 100% { box-shadow: 0 0 10px rgba(247, 166, 0, 0.3); } 50% { box-shadow: 0 0 25px rgba(247, 166, 0, 0.5); } }

.game-stats {
    display: flex;
    justify-content: center;
    gap: 1.5rem;
    padding: 1rem;
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    margin-bottom: 1.5rem;
}
.stat { text-align: center; }
.stat .stat-value { display: block; font-size: 1.5rem; font-weight: 700; color: var(--neon-blue); }
.stat .stat-label { font-size: 0.75rem; color: var(--text-muted); text-transform: uppercase; }

.gameover-actions { display: flex; gap: 1rem; justify-content: center; flex-wrap: wrap; }

/* Responsive */
@media (max-width: 768px) {
    .game-nav { padding: 0.75rem 1rem; }
    .game-title { font-size: 1rem; }
    .screen-content { padding: 1.5rem; }
    .control-grid { flex-direction: column; gap: 0.5rem; }
    .mobile-controls { display: flex; }
    .game-screen { padding: 0.5rem; }
    .score-value { font-size: 2rem; }
}

