/* ==================== IMPORTS & RESET ==================== */
@import url('https://fonts.googleapis.com/css2?family=VT323&display=swap');

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

/* ==================== BODY ==================== */
body {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f0f23 100%);
    font-family: 'VT323', monospace;
    padding: 20px;
    gap: 20px;
}

/* ==================== NAVEGACIÓN SUPERIOR ==================== */
.top-nav {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
    justify-content: center;
}

.nav-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 20px;
    background: linear-gradient(145deg, #2d3748 0%, #1a202c 100%);
    border: 1px solid #4a5568;
    border-radius: 10px;
    color: #e2e8f0;
    text-decoration: none;
    font-family: 'VT323', monospace;
    font-size: 18px;
    letter-spacing: 1px;
    transition: all 0.2s ease;
    box-shadow: 
        0 4px 15px rgba(0, 0, 0, 0.3),
        inset 0 1px 2px rgba(255, 255, 255, 0.1);
}

.nav-btn:hover {
    background: linear-gradient(145deg, #3d4758 0%, #2d3748 100%);
    border-color: #5a6578;
    transform: translateY(-2px);
    box-shadow: 
        0 6px 20px rgba(0, 0, 0, 0.4),
        inset 0 1px 2px rgba(255, 255, 255, 0.15);
}

.nav-btn:active {
    transform: translateY(0);
    box-shadow: 
        0 2px 10px rgba(0, 0, 0, 0.3),
        inset 0 1px 2px rgba(255, 255, 255, 0.1);
}

.nav-icon {
    width: 20px;
    height: 20px;
    object-fit: contain;
}

.nav-icon svg,
.nav-btn svg.nav-icon {
    width: 20px;
    height: 20px;
    stroke: currentColor;
}

/* ==================== NOKIA PHONE ==================== */
.nokia-phone {
    position: relative;
    width: 420px;
    height: 780px;
    background: linear-gradient(
        145deg, 
        #6b7280 0%, 
        #5c6370 15%, 
        #4a5568 40%, 
        #3d4555 60%, 
        #4a5568 85%, 
        #6b7280 100%
    );
    border-radius: 40px;
    padding: 25px;
    box-shadow: 
        0 30px 80px rgba(0, 0, 0, 0.6),
        0 15px 40px rgba(0, 0, 0, 0.4),
        inset 0 2px 4px rgba(255, 255, 255, 0.15),
        inset 0 -3px 6px rgba(0, 0, 0, 0.25);
}

/* Speaker del teléfono */
.phone-speaker {
    position: absolute;
    top: 15px;
    left: 50%;
    transform: translateX(-50%);
    width: 80px;
    height: 10px;
    background: linear-gradient(180deg, #1a202c 0%, #2d3748 50%, #1a202c 100%);
    border-radius: 5px;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.5);
}

/* Logo NOKIA */
.nokia-brand {
    text-align: center;
    color: #1f2937;
    font-size: 32px;
    font-weight: bold;
    letter-spacing: 6px;
    margin-top: 10px;
    margin-bottom: 18px;
    text-shadow: 
        0 1px 1px rgba(255, 255, 255, 0.25),
        0 -1px 1px rgba(0, 0, 0, 0.2);
    font-family: 'Arial Black', Arial, sans-serif;
}

/* ==================== PANTALLA ==================== */
.screen-frame {
    background: linear-gradient(180deg, #2d3748 0%, #1a202c 100%);
    border-radius: 12px;
    padding: 18px;
    margin-bottom: 25px;
    box-shadow: 
        inset 0 2px 8px rgba(0, 0, 0, 0.5),
        0 2px 4px rgba(0, 0, 0, 0.3);
}

.lcd-screen {
    position: relative;
    width: 100%;
    height: 340px;
    background: #9bbc0f;
    border-radius: 6px;
    overflow: hidden;
    box-shadow: 
        inset 0 0 30px rgba(0, 0, 0, 0.1),
        inset 0 0 80px rgba(155, 188, 15, 0.4);
}

/* Efecto scanlines LCD */
.lcd-screen::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: 
        repeating-linear-gradient(
            0deg,
            transparent,
            transparent 2px,
            rgba(0, 0, 0, 0.03) 2px,
            rgba(0, 0, 0, 0.03) 4px
        );
    pointer-events: none;
    z-index: 10;
}

/* Efecto de reflejo en pantalla */
.lcd-screen::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 50%;
    background: linear-gradient(
        180deg,
        rgba(255, 255, 255, 0.08) 0%,
        transparent 100%
    );
    pointer-events: none;
    z-index: 11;
}

/* ==================== HEADER DEL JUEGO ==================== */
.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 15px;
    color: #0f380f;
    font-size: 22px;
}

.score {
    font-weight: bold;
    letter-spacing: 3px;
}

.high-score {
    font-size: 16px;
    opacity: 0.85;
    letter-spacing: 1px;
}

/* ==================== ÁREA DE JUEGO ==================== */
.game-area {
    position: relative;
    margin: 0 auto;
    width: calc(100% - 20px);
    height: 280px;
    border: 3px solid #0f380f;
    background: #9bbc0f;
}

#gameCanvas {
    display: block;
    width: 100%;
    height: 100%;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
}

/* ==================== OVERLAYS ==================== */
.start-overlay,
.game-over-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(155, 188, 15, 0.97);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    color: #0f380f;
    z-index: 20;
    text-align: center;
}

.game-over-overlay {
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease;
}

.game-over-overlay.show {
    opacity: 1;
    visibility: visible;
}

.start-overlay.hide {
    display: none;
}

.snake-icon {
    font-size: 50px;
    margin-bottom: 15px;
    filter: grayscale(100%) contrast(1.2);
}

.start-overlay h2,
.game-over-overlay h2 {
    font-size: 36px;
    margin-bottom: 15px;
    letter-spacing: 4px;
}

.start-overlay p,
.game-over-overlay p {
    font-size: 18px;
    margin-bottom: 8px;
    letter-spacing: 1px;
}

.start-hint {
    margin-top: 20px !important;
    font-size: 22px !important;
    font-weight: bold;
}

.restart-hint {
    margin-top: 15px;
    font-size: 16px !important;
}

/* ==================== KEYPAD ==================== */
.keypad {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

/* ==================== CRUCETA / D-PAD ==================== */
.d-pad {
    display: grid;
    grid-template-columns: 55px 55px 55px;
    grid-template-rows: 55px 55px 55px;
    gap: 5px;
    place-items: center;
}

/* Posiciones de la cruceta */
.d-pad .arrow.up {
    grid-column: 2;
    grid-row: 1;
}

.d-pad .arrow.left {
    grid-column: 1;
    grid-row: 2;
}

.d-pad .center {
    grid-column: 2;
    grid-row: 2;
}

.d-pad .arrow.right {
    grid-column: 3;
    grid-row: 2;
}

.d-pad .arrow.down {
    grid-column: 2;
    grid-row: 3;
}

/* ==================== BOTONES ==================== */
.key {
    background: linear-gradient(180deg, #4a5568 0%, #2d3748 100%);
    border: none;
    color: #d1d5db;
    cursor: pointer;
    box-shadow: 
        0 4px 10px rgba(0, 0, 0, 0.4),
        inset 0 1px 2px rgba(255, 255, 255, 0.15),
        inset 0 -1px 2px rgba(0, 0, 0, 0.2);
    transition: transform 0.08s ease, box-shadow 0.08s ease;
    font-family: 'VT323', monospace;
}

.key:hover {
    background: linear-gradient(180deg, #5a6578 0%, #3d4758 100%);
}

.key:active,
.key.active {
    transform: translateY(3px);
    box-shadow: 
        0 1px 4px rgba(0, 0, 0, 0.4),
        inset 0 1px 2px rgba(255, 255, 255, 0.1);
}

/* Flechas de la cruceta */
.key.arrow {
    width: 50px;
    height: 50px;
    font-size: 22px;
    border-radius: 10px;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Botón central de la cruceta */
.key.center {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(180deg, #374151 0%, #1f2937 100%);
    cursor: default;
    box-shadow: 
        0 3px 8px rgba(0, 0, 0, 0.5),
        inset 0 2px 4px rgba(255, 255, 255, 0.1);
}

.key.center:hover {
    background: linear-gradient(180deg, #374151 0%, #1f2937 100%);
}

/* Botones de acción (START / PAUSE) */
.action-buttons {
    display: flex;
    gap: 15px;
}

.key.action {
    width: 80px;
    height: 45px;
    font-size: 16px;
    border-radius: 10px;
    letter-spacing: 1px;
}

/* ==================== INSTRUCCIONES ==================== */
.instructions {
    position: fixed;
    bottom: 25px;
    left: 50%;
    transform: translateX(-50%);
    color: #9ca3af;
    font-size: 15px;
    text-align: center;
    opacity: 0.7;
    letter-spacing: 0.5px;
}

/* ==================== RESPONSIVE ==================== */
@media (max-width: 480px) {
    body {
        padding: 10px;
        gap: 15px;
    }
    
    .top-nav {
        gap: 10px;
    }
    
    .nav-btn {
        padding: 10px 15px;
        font-size: 16px;
    }
    
    .nav-icon {
        width: 18px;
        height: 18px;
    }
    
    .nokia-phone {
        width: 360px;
        height: 700px;
        padding: 20px;
        border-radius: 35px;
    }
    
    .nokia-brand {
        font-size: 26px;
        letter-spacing: 4px;
    }
    
    .screen-frame {
        padding: 14px;
        margin-bottom: 20px;
    }
    
    .lcd-screen {
        height: 300px;
    }
    
    .game-area {
        height: 245px;
    }
    
    .d-pad {
        grid-template-columns: 48px 48px 48px;
        grid-template-rows: 48px 48px 48px;
    }
    
    .key.arrow {
        width: 44px;
        height: 44px;
        font-size: 18px;
    }
    
    .key.center {
        width: 35px;
        height: 35px;
    }
    
    .key.action {
        width: 70px;
        height: 40px;
        font-size: 14px;
    }
    
    .instructions {
        font-size: 12px;
        bottom: 15px;
    }
}

@media (max-height: 800px) {
    .nokia-phone {
        height: 700px;
    }
    
    .lcd-screen {
        height: 300px;
    }
    
    .game-area {
        height: 245px;
    }
}
