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

body {
    font-family: 'JetBrains Mono', monospace;
    background: linear-gradient(135deg, #0a0a15 0%, #1a1a2e 50%, #16213e 100%);
    min-height: 100vh;
    color: #fff;
    overflow-x: hidden;
}

#game-container {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    max-width: 1200px;
    margin: 0 auto;
    padding: 10px;
}

#header {
    padding: 15px;
    background: rgba(26, 26, 46, 0.9);
    border-radius: 12px;
    margin-bottom: 10px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.score-panel {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 30px;
}

.snake-score {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.2rem;
}

.snake-score .label {
    font-weight: 600;
    letter-spacing: 2px;
}

.snake-a .label, .snake-a .score {
    color: #00d4aa;
    text-shadow: 0 0 20px rgba(0, 212, 170, 0.5);
}

.snake-b .label, .snake-b .score {
    color: #4a9eff;
    text-shadow: 0 0 20px rgba(74, 158, 255, 0.5);
}

.snake-score .score {
    font-size: 2rem;
    font-weight: 800;
    min-width: 50px;
    text-align: center;
}

.snake-icon {
    font-size: 1.5rem;
}

.leader-indicator {
    font-size: 1.5rem;
    min-width: 40px;
    text-align: center;
    transition: color 0.3s ease;
}

#main {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    min-height: 400px;
}

#canvas {
    border-radius: 12px;
    box-shadow: 0 0 40px rgba(0, 212, 170, 0.2), 0 0 40px rgba(74, 158, 255, 0.2);
    border: 2px solid rgba(255, 255, 255, 0.1);
}

#game-over {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    background: rgba(10, 10, 20, 0.9);
    border-radius: 12px;
    z-index: 10;
    animation: fadeIn 0.3s ease;
}

#game-over.hidden {
    display: none;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.game-over-content {
    text-align: center;
    padding: 30px;
}

.game-over-content h2 {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 2.5rem;
    margin-bottom: 15px;
    animation: pulse 1s ease infinite;
}

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

.game-over-content p {
    font-size: 1.1rem;
    color: rgba(255, 255, 255, 0.8);
    margin-bottom: 25px;
}

#controls {
    padding: 15px;
    background: rgba(26, 26, 46, 0.9);
    border-radius: 12px;
    margin-top: 10px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    justify-content: center;
    align-items: center;
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
    align-items: center;
}

.control-group label {
    font-size: 0.7rem;
    color: rgba(255, 255, 255, 0.6);
    letter-spacing: 1px;
}

.primary-btn, .secondary-btn, #restart-btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    letter-spacing: 1px;
}

.primary-btn {
    background: linear-gradient(135deg, #00d4aa, #00a882);
    color: #1a1a2e;
    box-shadow: 0 0 20px rgba(0, 212, 170, 0.4);
}

.primary-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 0 30px rgba(0, 212, 170, 0.6);
}

.secondary-btn {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.secondary-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

#restart-btn {
    background: linear-gradient(135deg, #4a9eff, #3a7ecc);
    color: #fff;
    box-shadow: 0 0 20px rgba(74, 158, 255, 0.4);
}

#restart-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 0 30px rgba(74, 158, 255, 0.6);
}

input[type="range"] {
    width: 100px;
    height: 6px;
    -webkit-appearance: none;
    appearance: none;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
    outline: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    background: #00d4aa;
    border-radius: 50%;
    cursor: pointer;
}

select {
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 6px;
    color: #fff;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.85rem;
    cursor: pointer;
}

select option {
    background: #1a1a2e;
    color: #fff;
}

.toggle-group label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    flex-direction: row;
}

.toggle-label {
    font-size: 0.85rem !important;
    color: #fff !important;
}

input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: #00d4aa;
    cursor: pointer;
}

#speed-label {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.5);
}

.stats-panel {
    background: rgba(0, 0, 0, 0.3);
    padding: 12px 20px;
    border-radius: 8px;
    min-width: 180px;
}

.stats-panel h3 {
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.6);
    margin-bottom: 10px;
    letter-spacing: 1px;
}

.stat-row {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    padding: 3px 0;
    color: rgba(255, 255, 255, 0.8);
}

.stat-row span:last-child {
    font-weight: 600;
    color: #00d4aa;
}

.info-tooltip {
    position: relative;
    cursor: help;
}

.info-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.6);
}

.tooltip-text {
    position: absolute;
    bottom: 130%;
    left: 50%;
    transform: translateX(-50%);
    background: #1a1a2e;
    padding: 10px 15px;
    border-radius: 8px;
    font-size: 0.75rem;
    line-height: 1.4;
    width: 220px;
    text-align: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
    border: 1px solid rgba(255, 255, 255, 0.1);
    z-index: 100;
}

.info-tooltip:hover .tooltip-text {
    opacity: 1;
}

#footer {
    text-align: center;
    padding: 15px;
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.5);
}

#footer a {
    color: #00d4aa;
    text-decoration: none;
    transition: color 0.2s ease;
}

#footer a:hover {
    color: #40ffcc;
}

/* Mobile optimizations */
@media (max-width: 768px) {
    #game-container {
        padding: 5px;
    }
    
    #header {
        padding: 10px;
    }
    
    .score-panel {
        gap: 15px;
    }
    
    .snake-score {
        gap: 5px;
        font-size: 1rem;
    }
    
    .snake-score .score {
        font-size: 1.5rem;
        min-width: 35px;
    }
    
    .snake-score .label {
        font-size: 0.7rem;
    }
    
    .snake-icon {
        font-size: 1.2rem;
    }
    
    #controls {
        padding: 10px;
        gap: 10px;
    }
    
    .control-group:first-child {
        flex-direction: row;
        gap: 10px;
    }
    
    .primary-btn, .secondary-btn {
        padding: 10px 16px;
        font-size: 0.8rem;
    }
    
    .stats-panel {
        width: 100%;
        min-width: unset;
    }
    
    .game-over-content h2 {
        font-size: 1.8rem;
    }
    
    .tooltip-text {
        left: auto;
        right: -10px;
        transform: none;
        width: 200px;
    }
}

@media (max-width: 400px) {
    .snake-score .label {
        display: none;
    }
    
    .score-panel {
        gap: 20px;
    }
}