/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Orbitron', monospace;
    background: linear-gradient(135deg, #0f0f23 0%, #1a1a3a 50%, #2d1b69 100%);
    color: #ffffff;
    overflow: hidden;
    height: 100vh;
    user-select: none;
}

/* Game Container */
.game-container {
    position: relative;
    width: 100vw;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Screen Management */
.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.3s ease-in-out;
}

.screen.hidden {
    opacity: 0;
    pointer-events: none;
}

/* Title Screen */
.title-content {
    text-align: center;
    animation: fadeInUp 1s ease-out;
}

.game-title {
    font-size: clamp(3rem, 8vw, 6rem);
    font-weight: 900;
    margin-bottom: 1rem;
    text-shadow: 0 0 20px rgba(0, 255, 255, 0.5);
}

.snake-text {
    color: #00ff88;
    text-shadow: 0 0 30px rgba(0, 255, 136, 0.8);
}

.byte-text {
    color: #ff6b6b;
    text-shadow: 0 0 30px rgba(255, 107, 107, 0.8);
}

.subtitle {
    font-size: clamp(1rem, 3vw, 1.5rem);
    color: #cccccc;
    margin-bottom: 3rem;
    opacity: 0.8;
}

/* Menu Buttons */
.menu-buttons {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 2rem;
}

.menu-btn {
    background: linear-gradient(45deg, #4a90e2, #357abd);
    border: none;
    color: white;
    padding: 1rem 2rem;
    font-size: clamp(1rem, 2.5vw, 1.2rem);
    font-family: 'Orbitron', monospace;
    font-weight: 700;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 1px;
    min-width: 200px;
    box-shadow: 0 4px 15px rgba(74, 144, 226, 0.3);
}

.menu-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(74, 144, 226, 0.5);
    background: linear-gradient(45deg, #5ba0f2, #4080cd);
}

.menu-btn.primary {
    background: linear-gradient(45deg, #00ff88, #00cc6a);
    box-shadow: 0 4px 15px rgba(0, 255, 136, 0.3);
}

.menu-btn.primary:hover {
    background: linear-gradient(45deg, #10ff98, #10dc7a);
    box-shadow: 0 6px 20px rgba(0, 255, 136, 0.5);
}

/* High Score Display */
.high-score-display {
    font-size: clamp(1rem, 2.5vw, 1.3rem);
    color: #ffd700;
    text-shadow: 0 0 10px rgba(255, 215, 0, 0.5);
    margin-bottom: 0.5rem;
}

/* Current Mode Display */
.current-mode {
    font-size: clamp(0.9rem, 2vw, 1.1rem);
    color: #4a90e2;
    text-shadow: 0 0 10px rgba(74, 144, 226, 0.5);
}

/* Instructions Screen */
.instructions-content {
    max-width: 800px;
    padding: 2rem;
    text-align: center;
}

.instructions-content h2 {
    font-size: clamp(2rem, 5vw, 3rem);
    margin-bottom: 2rem;
    color: #00ff88;
    text-shadow: 0 0 20px rgba(0, 255, 136, 0.5);
}

.instructions-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.instruction-item {
    background: rgba(255, 255, 255, 0.1);
    padding: 1.5rem;
    border-radius: 15px;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.instruction-icon {
    font-size: 2rem;
    margin-bottom: 1rem;
}

.instruction-text {
    font-size: 1rem;
    line-height: 1.5;
}

/* Settings Screen */
.settings-content {
    max-width: 500px;
    padding: 2rem;
    text-align: center;
}

.settings-content h2 {
    font-size: clamp(2rem, 5vw, 3rem);
    margin-bottom: 2rem;
    color: #4a90e2;
    text-shadow: 0 0 20px rgba(74, 144, 226, 0.5);
}

.setting-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    backdrop-filter: blur(10px);
}

.setting-item label {
    font-size: 1.1rem;
    font-weight: 600;
}

.setting-item input, .setting-item select {
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    padding: 0.5rem;
    border-radius: 5px;
    font-family: 'Orbitron', monospace;
}

/* Game Modes Screen */
.modes-content {
    max-width: 900px;
    padding: 2rem;
    text-align: center;
}

.modes-content h2 {
    font-size: clamp(2rem, 5vw, 3rem);
    margin-bottom: 2rem;
    color: #00ff88;
    text-shadow: 0 0 20px rgba(0, 255, 136, 0.5);
}

.modes-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.mode-item {
    background: rgba(255, 255, 255, 0.1);
    padding: 1.5rem;
    border-radius: 15px;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.mode-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.3);
    background: rgba(255, 255, 255, 0.15);
}

.mode-item h3 {
    font-size: 1.5rem;
    margin-bottom: 1rem;
    color: #00ff88;
}

.mode-item p {
    font-size: 0.9rem;
    line-height: 1.5;
    margin-bottom: 1.5rem;
    flex-grow: 1;
}

.select-mode-btn {
    background: linear-gradient(45deg, #00ff88, #00cc6a);
    border: none;
    color: white;
    padding: 0.7rem 1.5rem;
    font-size: 1rem;
    font-family: 'Orbitron', monospace;
    font-weight: 700;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 1px;
    align-self: center;
    box-shadow: 0 4px 15px rgba(0, 255, 136, 0.3);
}

.select-mode-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 255, 136, 0.5);
    background: linear-gradient(45deg, #10ff98, #10dc7a);
}

/* Game Screen */
#gameScreen {
    flex-direction: column;
    padding: 1rem;
}

.game-ui {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    max-width: 800px;
    margin-bottom: 1rem;
    padding: 0 1rem;
}

.score-panel {
    display: flex;
    gap: 2rem;
}

.score-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    font-size: clamp(0.8rem, 2vw, 1rem);
}

.label {
    color: #cccccc;
    font-size: 0.8em;
    margin-bottom: 0.2rem;
}

.pause-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    padding: 0.5rem;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.5rem;
    transition: all 0.3s ease;
}

.pause-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

/* Game Canvas */
#gameCanvas {
    border: 3px solid #00ff88;
    border-radius: 15px;
    box-shadow: 0 0 30px rgba(0, 255, 136, 0.3);
    background: #000814;
    max-width: 90vw;
    max-height: 60vh;
}

/* Mobile Controls */
.mobile-controls {
    display: none;
    margin-top: 1rem;
    user-select: none;
}

.control-row {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin: 0.5rem 0;
}

.control-btn {
    background: rgba(255, 255, 255, 0.2);
    border: 2px solid rgba(255, 255, 255, 0.3);
    color: white;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    font-size: 1.5rem;
    cursor: pointer;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
}

.control-btn:hover, .control-btn:active {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

/* Game Over Screen */
.game-over-content {
    text-align: center;
    animation: fadeInUp 0.5s ease-out;
}

.game-over-title {
    font-size: clamp(2.5rem, 6vw, 4rem);
    color: #ff6b6b;
    text-shadow: 0 0 30px rgba(255, 107, 107, 0.8);
    margin-bottom: 2rem;
}

.final-stats {
    margin-bottom: 2rem;
}

.stat-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    backdrop-filter: blur(10px);
    max-width: 400px;
    margin-left: auto;
    margin-right: auto;
}

.stat-label {
    font-size: 1.1rem;
    color: #cccccc;
}

.stat-value {
    font-size: 1.2rem;
    font-weight: 700;
    color: #00ff88;
}

.new-high-score {
    font-size: 1.5rem;
    color: #ffd700;
    text-shadow: 0 0 20px rgba(255, 215, 0, 0.8);
    margin-bottom: 1rem;
    animation: pulse 1s infinite;
}

.game-over-buttons {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    align-items: center;
}

/* Pause Screen */
.pause-content {
    text-align: center;
}

.pause-content h2 {
    font-size: clamp(2.5rem, 6vw, 4rem);
    color: #ffd700;
    text-shadow: 0 0 30px rgba(255, 215, 0, 0.8);
    margin-bottom: 2rem;
}

.pause-buttons {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    align-items: center;
}

/* Animations */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
}

/* Responsive Design */
@media (max-width: 768px) {
    .mobile-controls {
        display: block;
    }
    
    .score-panel {
        gap: 1rem;
    }
    
    .instructions-grid {
        grid-template-columns: 1fr;
    }
    
    .game-over-buttons,
    .pause-buttons {
        width: 100%;
        max-width: 300px;
    }
    
    .menu-btn {
        width: 100%;
    }
}

@media (max-width: 480px) {
    .game-container {
        padding: 0.5rem;
    }
    
    .title-content,
    .instructions-content,
    .settings-content {
        padding: 1rem;
    }
    
    .control-btn {
        width: 50px;
        height: 50px;
        font-size: 1.2rem;
    }
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
    .mobile-controls {
        display: block;
    }
    
    .menu-btn:hover,
    .control-btn:hover,
    .pause-btn:hover {
        transform: none;
    }
    
    .menu-btn:active,
    .control-btn:active,
    .pause-btn:active {
        transform: scale(0.95);
    }
}
/* Danger flash effect */
@keyframes dangerFlash {
    0%, 100% {
        background: linear-gradient(135deg, #0f0f23 0%, #1a1a3a 50%, #2d1b69 100%);
    }
    50% {
        background: linear-gradient(135deg, #3d0000 0%, #5a0000 50%, #7d0000 100%);
    }
}

body.danger-flash {
    animation: dangerFlash 0.3s ease-in-out;
}
