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

body {
    font-family: 'Courier New', monospace;
    background: #0a0a0a;
    color: #00ff00;
    overflow: auto;
    min-height: 100vh;
    touch-action: manipulation;
    -webkit-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

/* Animated background */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: 
        radial-gradient(circle at 20% 50%, rgba(0, 255, 255, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 80% 50%, rgba(255, 0, 255, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 50% 100%, rgba(0, 255, 0, 0.1) 0%, transparent 50%);
    animation: backgroundPulse 8s ease-in-out infinite;
    z-index: -1;
}

@keyframes backgroundPulse {
    0%, 100% { opacity: 0.5; }
    50% { opacity: 1; }
}

.screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    visibility: hidden;
    transition: all 0.5s ease;
}

.screen:not(#leaderboardScreen):not(#nameScreen) {
    display: flex;
    align-items: center;
    justify-content: center;
}

#nameScreen,
#leaderboardScreen {
    display: flex;
    flex-direction: column;
    align-items: center;
}

#nameScreen {
    overflow-y: auto;
    padding: 40px 20px 40px;
    min-height: 100vh;
}

#leaderboardScreen {
    overflow-y: auto;
    padding: 60px 20px 20px;
    min-height: 100vh;
}

.screen.active {
    opacity: 1;
    visibility: visible;
}

.container {
    text-align: center;
    max-width: 600px;
    padding: 20px;
    margin: auto;
}

.game-title {
    font-size: clamp(2.5rem, 8vw, 4rem);
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 0.5rem;
    margin-bottom: 1rem;
    text-shadow: 
        0 0 10px #00ff00,
        0 0 20px #00ff00,
        0 0 30px #00ff00,
        0 0 40px #00ff00;
    animation: titleGlow 2s ease-in-out infinite alternate;
}

@keyframes titleGlow {
    from { text-shadow: 0 0 10px #00ff00, 0 0 20px #00ff00, 0 0 30px #00ff00, 0 0 40px #00ff00; }
    to { text-shadow: 0 0 20px #00ff00, 0 0 30px #00ff00, 0 0 40px #00ff00, 0 0 50px #00ff00; }
}

.subtitle {
    font-size: clamp(0.9rem, 3vw, 1.2rem);
    color: #00ffff;
    margin-bottom: 3rem;
    text-transform: uppercase;
    letter-spacing: 0.3rem;
    opacity: 0.8;
}

.input-group {
    margin-bottom: 2rem;
}

#playerName {
    width: 100%;
    padding: 1rem;
    font-size: 1.2rem;
    font-family: 'Courier New', monospace;
    background: rgba(0, 0, 0, 0.8);
    border: 2px solid #00ff00;
    color: #00ff00;
    text-transform: uppercase;
    letter-spacing: 0.1rem;
    margin-bottom: 1rem;
    transition: all 0.3s ease;
}

#playerName:focus {
    outline: none;
    box-shadow: 0 0 20px rgba(0, 255, 0, 0.5);
    border-color: #00ffff;
}

#playerName::placeholder {
    color: rgba(0, 255, 0, 0.5);
}

.difficulty-selector {
    margin: 2rem 0;
}

.difficulty-label {
    font-size: 1rem;
    color: #00ffff;
    text-transform: uppercase;
    letter-spacing: 0.1rem;
    margin-bottom: 1rem;
    opacity: 0.8;
}

.difficulty-options {
    display: flex;
    justify-content: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.difficulty-btn {
    padding: 0.8rem 1.5rem;
    font-size: 1rem;
    font-family: 'Courier New', monospace;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 0.1rem;
    background: transparent;
    border: 2px solid #00ff00;
    color: #00ff00;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.difficulty-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(0, 255, 0, 0.2), transparent);
    transition: left 0.5s ease;
}

.difficulty-btn:hover::before {
    left: 100%;
}

.difficulty-btn:hover {
    background: rgba(0, 255, 0, 0.1);
    transform: scale(1.05);
}

.difficulty-btn.active {
    background: rgba(0, 255, 0, 0.2);
    border-color: #00ffff;
    color: #00ffff;
    box-shadow: 0 0 15px rgba(0, 255, 255, 0.5);
}

.difficulty-btn[data-difficulty="easy"].active {
    border-color: #00ff00;
    color: #00ff00;
    box-shadow: 0 0 15px rgba(0, 255, 0, 0.5);
}

.difficulty-btn[data-difficulty="hard"].active {
    border-color: #ff0000;
    color: #ff0000;
    box-shadow: 0 0 15px rgba(255, 0, 0, 0.5);
}

.neon-btn {
    padding: 1rem 2rem;
    font-size: 1.2rem;
    font-family: 'Courier New', monospace;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 0.1rem;
    background: transparent;
    border: 2px solid #00ff00;
    color: #00ff00;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.neon-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(0, 255, 0, 0.3), transparent);
    transition: left 0.5s ease;
}

.neon-btn:hover::before {
    left: 100%;
}

.neon-btn:hover {
    background: rgba(0, 255, 0, 0.1);
    box-shadow: 0 0 20px rgba(0, 255, 0, 0.5);
    transform: scale(1.05);
}

.neon-btn:active {
    transform: scale(0.98);
}

.game-options {
    margin: 2rem 0;
    padding: 1.5rem;
    background: rgba(0, 255, 0, 0.05);
    border: 1px solid rgba(0, 255, 0, 0.3);
    border-radius: 5px;
}

.options-label {
    font-size: 1rem;
    color: #00ffff;
    text-transform: uppercase;
    letter-spacing: 0.1rem;
    margin-bottom: 1rem;
    text-align: center;
}

.option-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0;
}

.option-text {
    font-size: 0.9rem;
    color: #00ff00;
    text-transform: uppercase;
    letter-spacing: 0.05rem;
}

.toggle-switch {
    position: relative;
    display: inline-block;
    width: 60px;
    height: 30px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 255, 0, 0.2);
    transition: 0.4s;
    border: 2px solid #00ff00;
    border-radius: 30px;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 3px;
    bottom: 3px;
    background-color: #00ff00;
    transition: 0.4s;
    border-radius: 50%;
    box-shadow: 0 0 10px rgba(0, 255, 0, 0.5);
}

input:checked + .toggle-slider {
    background-color: rgba(255, 0, 255, 0.2);
    border-color: #ff00ff;
}

input:checked + .toggle-slider:before {
    transform: translateX(30px);
    background-color: #ff00ff;
    box-shadow: 0 0 10px rgba(255, 0, 255, 0.5);
}

.screen-links {
    margin: 1.5rem 0;
}

.link-btn {
    background: transparent;
    border: none;
    color: #00ffff;
    font-size: 0.9rem;
    font-family: 'Courier New', monospace;
    text-transform: uppercase;
    letter-spacing: 0.1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: underline;
    opacity: 0.8;
}

.link-btn:hover {
    opacity: 1;
    color: #ffffff;
    text-shadow: 0 0 5px #00ffff;
}

.game-stats {
    margin: 1.5rem 0;
    padding: 1.5rem;
    background: rgba(0, 255, 0, 0.05);
    border: 1px solid rgba(0, 255, 0, 0.3);
    border-radius: 5px;
}

.stats-label {
    font-size: 0.8rem;
    color: #00ffff;
    text-transform: uppercase;
    letter-spacing: 0.15rem;
    margin-bottom: 1rem;
    opacity: 0.7;
}

.stats-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0;
    gap: 1rem;
}

.stats-value {
    font-size: 1.5rem;
    font-weight: bold;
    color: #00ff00;
    text-shadow: 0 0 10px rgba(0, 255, 0, 0.5);
    min-width: 100px;
    text-align: right;
    transition: all 0.3s ease;
}

.stats-value.updated {
    animation: statsGlow 0.5s ease-out;
}

@keyframes statsGlow {
    0% {
        color: #00ffff;
        text-shadow: 0 0 20px rgba(0, 255, 255, 0.8);
        transform: scale(1.1);
    }
    100% {
        color: #00ff00;
        text-shadow: 0 0 10px rgba(0, 255, 0, 0.5);
        transform: scale(1);
    }
}

.stats-text {
    font-size: 0.85rem;
    color: #00ff00;
    text-transform: uppercase;
    letter-spacing: 0.05rem;
    opacity: 0.8;
}

.instructions {
    margin-top: 2rem;
    opacity: 0.7;
}

.controls {
    display: flex;
    justify-content: center;
    gap: 2rem;
    flex-wrap: wrap;
}

.control-item {
    font-size: 0.9rem;
    color: #00ffff;
    text-transform: uppercase;
    letter-spacing: 0.1rem;
}

/* Game Screen Styles */
.game-header {
    position: absolute;
    top: 20px;
    left: 0;
    right: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 40px;
    z-index: 10;
}

.player-info {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

.player-name {
    font-size: 1.2rem;
    color: #00ffff;
    text-transform: uppercase;
    letter-spacing: 0.1rem;
}

.score-display {
    font-size: 1rem;
    color: #00ff00;
    margin-top: 0.5rem;
}

.game-status {
    font-size: 1.2rem;
    color: #ff00ff;
    text-transform: uppercase;
    letter-spacing: 0.1rem;
}

.game-container {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

#gameCanvas {
    border: 3px solid #00ff00;
    box-shadow: 
        0 0 20px rgba(0, 255, 0, 0.5),
        inset 0 0 20px rgba(0, 255, 0, 0.1);
    background: rgba(0, 0, 0, 0.9);
    touch-action: none;
    cursor: pointer;
}

#gameCanvas:active {
    box-shadow: 
        0 0 30px rgba(0, 255, 0, 0.8),
        inset 0 0 30px rgba(0, 255, 0, 0.2);
    border-color: #00ffff;
}

/* Touch feedback overlay */
.touch-indicator {
    position: absolute;
    border: 2px solid #00ffff;
    border-radius: 50%;
    pointer-events: none;
    opacity: 0;
    animation: touchRipple 0.5s ease-out;
}

@keyframes touchRipple {
    0% {
        opacity: 1;
        transform: scale(0.5);
    }
    100% {
        opacity: 0;
        transform: scale(2);
    }
}

.game-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.game-overlay.hidden {
    opacity: 0;
    visibility: hidden;
}

.overlay-content {
    text-align: center;
}

.overlay-content h2 {
    font-size: 2.5rem;
    color: #ff0000;
    text-transform: uppercase;
    letter-spacing: 0.2rem;
    margin-bottom: 1rem;
    text-shadow: 0 0 10px #ff0000;
}

.overlay-content p {
    font-size: 1.2rem;
    color: #00ff00;
    margin-bottom: 2rem;
}

/* Leaderboard Styles */
#leaderboardScreen {
    overflow-y: auto;
    padding: 80px 20px 20px;
    min-height: 100vh;
}

.leaderboard-container {
    width: 100%;
    max-width: 600px;
    margin: 0 auto;
    padding-bottom: 2rem;
}

.leaderboard-section {
    margin-bottom: 2rem;
}

.recent-games-section {
    margin-bottom: 2rem;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.section-title {
    font-size: 1.5rem;
    color: #00ffff;
    text-transform: uppercase;
    letter-spacing: 0.2rem;
    text-shadow: 0 0 10px rgba(0, 255, 255, 0.5);
}

.play-again-top {
    font-size: 0.8rem;
    padding: 0.6rem 1.2rem;
}

.leaderboard-list {
    background: rgba(0, 0, 0, 0.8);
    border: 2px solid #00ff00;
    padding: 1rem;
    max-height: 500px;
    overflow-y: auto;
}

.recent-games-list {
    background: rgba(0, 0, 0, 0.6);
    border: 1px solid rgba(0, 255, 0, 0.5);
    padding: 0.8rem;
    max-height: 250px;
    overflow-y: auto;
}

.leaderboard-entry {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.8rem;
    margin-bottom: 0.5rem;
    background: rgba(0, 255, 0, 0.05);
    border: 1px solid rgba(0, 255, 0, 0.3);
    transition: all 0.3s ease;
    gap: 0.5rem;
}

.leaderboard-entry:hover {
    background: rgba(0, 255, 0, 0.1);
    transform: translateX(5px);
}

.recent-game-entry {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.4rem 0.6rem;
    margin-bottom: 0.3rem;
    background: rgba(0, 255, 0, 0.02);
    border: 1px solid rgba(0, 255, 0, 0.2);
    font-size: 0.85rem;
    transition: all 0.3s ease;
}

.recent-game-entry:hover {
    background: rgba(0, 255, 0, 0.05);
    transform: translateX(3px);
}

.leaderboard-rank {
    font-size: 1.2rem;
    font-weight: bold;
    color: #00ffff;
    margin-right: 1rem;
    min-width: 30px;
}

.leaderboard-name {
    flex: 2;
    text-transform: uppercase;
    letter-spacing: 0.1rem;
}

.leaderboard-score {
    font-weight: bold;
    color: #00ff00;
    text-align: right;
    min-width: 60px;
}

.recent-game-name {
    flex: 1;
    text-transform: uppercase;
    letter-spacing: 0.05rem;
    color: rgba(0, 255, 0, 0.8);
}

.recent-game-score {
    font-weight: bold;
    color: rgba(0, 255, 0, 0.9);
    margin-right: 1rem;
}

.recent-game-difficulty {
    font-size: 0.75rem;
    padding: 0.2rem 0.4rem;
    border-radius: 3px;
    text-transform: uppercase;
    letter-spacing: 0.05rem;
}

.recent-game-difficulty.easy {
    background: rgba(0, 255, 0, 0.2);
    color: #00ff00;
    border: 1px solid rgba(0, 255, 0, 0.5);
}

.recent-game-difficulty.medium {
    background: rgba(255, 255, 0, 0.2);
    color: #ffff00;
    border: 1px solid rgba(255, 255, 0, 0.5);
}

.recent-game-difficulty.hard {
    background: rgba(255, 0, 0, 0.2);
    color: #ff0000;
    border: 1px solid rgba(255, 0, 0, 0.5);
}

.your-score {
    background: rgba(255, 0, 255, 0.1);
    border: 2px solid #ff00ff;
    padding: 1.5rem;
    margin-bottom: 2rem;
}

.your-score-label {
    font-size: 0.9rem;
    color: #ff00ff;
    text-transform: uppercase;
    letter-spacing: 0.1rem;
    margin-bottom: 0.5rem;
}

.your-score-value {
    font-size: 2rem;
    font-weight: bold;
    color: #ff00ff;
    text-shadow: 0 0 10px #ff00ff;
}

/* Responsive Design */
@media (max-width: 768px) {
    .game-header {
        padding: 0 20px;
    }
    
    #gameCanvas {
        width: 90vw;
        height: 90vw;
        max-width: 500px;
        max-height: 500px;
    }
    
    .controls {
        gap: 1rem;
    }
    
    #leaderboardScreen {
        padding: 10px;
    }
    
    .container {
        padding: 10px;
    }
}

/* Loading animation */
.loading {
    animation: pulse 1s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* Error state for input */
#playerName.error {
    border-color: #ff0000;
    box-shadow: 0 0 20px rgba(255, 0, 0, 0.5);
    animation: shake 0.5s ease-in-out;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-10px); }
    75% { transform: translateX(10px); }
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Current player highlight in leaderboard */
.leaderboard-entry.current-player {
    background: rgba(255, 0, 255, 0.2);
    border-color: #ff00ff;
    box-shadow: 0 0 10px rgba(255, 0, 255, 0.3);
}

/* No scores message */
.no-scores {
    text-align: center;
    color: rgba(0, 255, 0, 0.5);
    font-style: italic;
    padding: 2rem;
    text-transform: uppercase;
    letter-spacing: 0.1rem;
}

/* Food animation */
@keyframes foodPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

/* Snake head glow effect */
.snake-head-glow {
    filter: drop-shadow(0 0 10px #00ffff);
}

/* Watch button styles */
.watch-btn {
    background: transparent;
    border: 1px solid #00ffff;
    color: #00ffff;
    padding: 4px 12px;
    font-size: 10px;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.2s ease;
    box-shadow: 0 0 5px rgba(0, 255, 255, 0.3);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.watch-btn:hover {
    background: rgba(0, 255, 255, 0.2);
    box-shadow: 0 0 15px rgba(0, 255, 255, 0.6);
    transform: scale(1.05);
}

.no-replay {
    color: #666;
    font-size: 10px;
    font-style: italic;
}
