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

body {
    font-family: 'Arial', sans-serif;
    overflow: hidden;
    background: #2C3E50;
    color: #ECF0F1;
}

#game-canvas {
    display: block;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    cursor: crosshair;
}

/* Screens */
.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    background: rgba(44, 62, 80, 0.95);
    z-index: 1000;
}

/* Loading Screen */
#loading-screen h1 {
    font-size: 48px;
    animation: pulse 1.5s ease-in-out infinite;
}

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

/* Menu Screen */
.menu-container {
    text-align: center;
    max-width: 400px;
    padding: 40px;
    background: rgba(52, 73, 94, 0.9);
    border-radius: 20px;
    box-shadow: 0 10px 50px rgba(0, 0, 0, 0.5);
}

.game-title {
    font-size: 64px;
    font-weight: bold;
    margin-bottom: 30px;
    color: #3498DB;
    text-shadow: 0 0 20px rgba(52, 152, 219, 0.8);
}

.menu-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

#nickname-input {
    padding: 15px;
    font-size: 18px;
    border: 2px solid #3498DB;
    border-radius: 10px;
    background: rgba(44, 62, 80, 0.8);
    color: #ECF0F1;
    text-align: center;
    outline: none;
    transition: all 0.3s;
}

#nickname-input:focus {
    border-color: #5DADE2;
    box-shadow: 0 0 15px rgba(52, 152, 219, 0.5);
}

.skin-selector {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 15px;
}

.skin-preview {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #3498DB, #2980B9);
    border: 3px solid #ECF0F1;
    box-shadow: 0 0 20px rgba(52, 152, 219, 0.6);
}

.btn {
    padding: 15px 30px;
    font-size: 18px;
    font-weight: bold;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s;
    background: #34495E;
    color: #ECF0F1;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
}

.btn-primary {
    background: linear-gradient(135deg, #3498DB, #2980B9);
    font-size: 24px;
    padding: 20px 40px;
}

.btn-primary:hover {
    background: linear-gradient(135deg, #5DADE2, #3498DB);
}

/* Death Screen */
.death-container {
    text-align: center;
    max-width: 400px;
    padding: 40px;
    background: rgba(52, 73, 94, 0.95);
    border-radius: 20px;
    box-shadow: 0 10px 50px rgba(0, 0, 0, 0.5);
}

.death-title {
    font-size: 48px;
    color: #E74C3C;
    margin-bottom: 20px;
}

.death-stats {
    margin: 30px 0;
    font-size: 20px;
}

.death-stats p {
    margin: 10px 0;
}

.death-stats span {
    color: #3498DB;
    font-weight: bold;
    font-size: 24px;
}

.death-buttons {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-top: 20px;
}

/* Game HUD */
#game-hud {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 100;
}

.hud-score {
    position: absolute;
    top: 20px;
    left: 20px;
    background: rgba(44, 62, 80, 0.8);
    padding: 15px 25px;
    border-radius: 10px;
    text-align: center;
}

.score-label {
    font-size: 14px;
    opacity: 0.7;
    text-transform: uppercase;
}

.score-value {
    font-size: 32px;
    font-weight: bold;
    color: #3498DB;
}

.hud-leaderboard {
    position: absolute;
    top: 20px;
    right: 20px;
    background: rgba(44, 62, 80, 0.8);
    padding: 15px;
    border-radius: 10px;
    min-width: 200px;
}

.leaderboard-title {
    font-size: 16px;
    font-weight: bold;
    text-align: center;
    margin-bottom: 10px;
    color: #3498DB;
    text-transform: uppercase;
}

.leaderboard-list {
    font-size: 14px;
}

.leaderboard-item {
    padding: 5px 10px;
    margin: 3px 0;
    border-radius: 5px;
    display: flex;
    justify-content: space-between;
}

.leaderboard-item.player {
    background: rgba(52, 152, 219, 0.3);
    font-weight: bold;
}

.leaderboard-rank {
    color: #F39C12;
    font-weight: bold;
    margin-right: 10px;
}

.hud-minimap {
    position: absolute;
    bottom: 20px;
    right: 20px;
    background: rgba(44, 62, 80, 0.8);
    padding: 10px;
    border-radius: 10px;
}

#minimap-canvas {
    display: block;
    border: 2px solid #34495E;
    border-radius: 5px;
}

.hud-fps {
    position: absolute;
    bottom: 20px;
    left: 20px;
    background: rgba(44, 62, 80, 0.8);
    padding: 10px 15px;
    border-radius: 10px;
    font-size: 14px;
    font-family: 'Courier New', monospace;
}

/* High Score Display */
.high-score-display {
    background: rgba(44, 62, 80, 0.6);
    padding: 15px 25px;
    border-radius: 10px;
    margin-bottom: 20px;
    text-align: center;
}

.high-score-label {
    font-size: 12px;
    opacity: 0.7;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.high-score-value {
    font-size: 36px;
    font-weight: bold;
    color: #F39C12;
    text-shadow: 0 0 10px rgba(243, 156, 18, 0.5);
    margin-top: 5px;
}

/* Settings Icon */
.settings-icon {
    position: absolute;
    top: 20px;
    right: 20px;
    background: rgba(44, 62, 80, 0.8);
    border: 2px solid #3498DB;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s;
    color: #3498DB;
}

.settings-icon:hover {
    background: rgba(52, 152, 219, 0.3);
    transform: rotate(45deg);
}

/* Modals */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.modal-content {
    background: rgba(52, 73, 94, 0.98);
    border-radius: 20px;
    max-width: 600px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 25px 30px;
    border-bottom: 2px solid rgba(52, 152, 219, 0.3);
}

.modal-header h2 {
    color: #3498DB;
    font-size: 28px;
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    font-size: 36px;
    color: #ECF0F1;
    cursor: pointer;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.3s;
}

.modal-close:hover {
    background: rgba(231, 76, 60, 0.3);
    color: #E74C3C;
}

.modal-body {
    padding: 30px;
}

/* Settings Section */
.settings-section {
    margin-bottom: 30px;
}

.settings-section h3 {
    color: #5DADE2;
    font-size: 20px;
    margin-bottom: 15px;
    border-bottom: 1px solid rgba(52, 152, 219, 0.2);
    padding-bottom: 10px;
}

.setting-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    background: rgba(44, 62, 80, 0.5);
    border-radius: 10px;
    margin-bottom: 10px;
}

.setting-item label {
    font-size: 16px;
    font-weight: bold;
}

/* Toggle Switch */
.toggle-switch {
    width: 50px;
    height: 26px;
    appearance: none;
    background: #34495E;
    border-radius: 13px;
    position: relative;
    cursor: pointer;
    transition: background 0.3s;
}

.toggle-switch:checked {
    background: #27AE60;
}

.toggle-switch::before {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: white;
    top: 3px;
    left: 3px;
    transition: transform 0.3s;
}

.toggle-switch:checked::before {
    transform: translateX(24px);
}

/* Key Bind Button */
.key-bind {
    padding: 10px 20px;
    background: rgba(52, 152, 219, 0.2);
    border: 2px solid #3498DB;
    border-radius: 8px;
    color: #3498DB;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s;
    min-width: 150px;
    text-align: center;
}

.key-bind:hover {
    background: rgba(52, 152, 219, 0.4);
    transform: scale(1.05);
}

.key-bind.recording {
    background: rgba(231, 76, 60, 0.3);
    border-color: #E74C3C;
    color: #E74C3C;
    animation: pulse-border 1s infinite;
}

@keyframes pulse-border {
    0%, 100% { border-color: #E74C3C; }
    50% { border-color: #C0392B; }
}

/* Snake Preview Large */
.snake-preview-large {
    width: 200px;
    height: 200px;
    margin: 0 auto 30px;
    border-radius: 20px;
    background: rgba(44, 62, 80, 0.8);
    border: 3px solid #3498DB;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

/* Color Picker Grid */
.color-picker-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(50px, 1fr));
    gap: 10px;
    margin-top: 15px;
}

.color-option {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    cursor: pointer;
    border: 3px solid transparent;
    transition: all 0.3s;
    position: relative;
}

.color-option:hover {
    transform: scale(1.1);
    border-color: rgba(255, 255, 255, 0.5);
}

.color-option.selected {
    border-color: #3498DB;
    box-shadow: 0 0 20px rgba(52, 152, 219, 0.8);
}

.color-option.selected::after {
    content: '✓';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: white;
    font-size: 24px;
    font-weight: bold;
    text-shadow: 0 0 5px rgba(0, 0, 0, 0.8);
}

/* Pattern Picker Grid */
.pattern-picker-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 15px;
    margin-top: 15px;
}

.pattern-option {
    width: 80px;
    height: 80px;
    border-radius: 10px;
    cursor: pointer;
    border: 3px solid transparent;
    transition: all 0.3s;
    background: rgba(44, 62, 80, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    text-align: center;
    padding: 5px;
}

.pattern-option:hover {
    transform: scale(1.05);
    border-color: rgba(255, 255, 255, 0.5);
}

.pattern-option.selected {
    border-color: #3498DB;
    background: rgba(52, 152, 219, 0.3);
    box-shadow: 0 0 15px rgba(52, 152, 219, 0.6);
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .game-title {
        font-size: 48px;
    }

    .menu-container {
        max-width: 90%;
        padding: 30px 20px;
    }

    .settings-icon {
        top: 10px;
        right: 10px;
        width: 40px;
        height: 40px;
    }

    .hud-score {
        top: 10px;
        left: 10px;
        padding: 10px 15px;
    }

    .score-value {
        font-size: 24px;
    }

    .hud-leaderboard {
        top: 10px;
        right: 10px;
        min-width: 150px;
        font-size: 12px;
    }

    .hud-minimap {
        bottom: 10px;
        right: 10px;
    }

    .modal-content {
        width: 95%;
    }

    .color-picker-grid {
        grid-template-columns: repeat(auto-fill, minmax(40px, 1fr));
    }

    .color-option {
        width: 40px;
        height: 40px;
    }

    .pattern-picker-grid {
        grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
    }

    .pattern-option {
        width: 60px;
        height: 60px;
    }
}
