@import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@400;700;900&display=swap');

:root {
    --bg-primary: 220 15% 8%;
    --bg-secondary: 220 15% 12%;
    --bg-tertiary: 220 15% 16%;
    --text-primary: 0 0% 95%;
    --text-secondary: 0 0% 70%;
    --accent-neon: 120 100% 50%;
    --accent-pink: 330 100% 60%;
    --accent-blue: 200 100% 60%;
    --accent-yellow: 60 100% 60%;
    --danger: 0 100% 60%;
    --shadow-neon: 0 0 20px hsl(var(--accent-neon));
    --shadow-pink: 0 0 20px hsl(var(--accent-pink));
    --shadow-blue: 0 0 20px hsl(var(--accent-blue));
}

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

body {
    font-family: 'Orbitron', monospace;
    background: linear-gradient(135deg, 
        hsl(var(--bg-primary)) 0%, 
        hsl(var(--bg-secondary)) 50%, 
        hsl(var(--bg-primary)) 100%);
    color: hsl(var(--text-primary));
    min-height: 100vh;
    margin: 0;
    padding: 0;
    overflow: hidden;
}

.game-layout {
    display: flex;
    height: 100vh;
    width: 100vw;
}

/* Mobile Controls */
.mobile-controls {
    display: none;
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 1000;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.mobile-controls.show {
    display: flex;
}

.control-row {
    display: flex;
    gap: 10px;
    align-items: center;
}

.control-btn {
    width: 60px;
    height: 60px;
    border: 2px solid hsl(var(--accent-neon));
    background: hsl(var(--bg-secondary) / 0.8);
    color: hsl(var(--accent-neon));
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    font-weight: bold;
    cursor: pointer;
    user-select: none;
    transition: all 0.2s ease;
    backdrop-filter: blur(10px);
}

.control-btn:active {
    background: hsl(var(--accent-neon) / 0.2);
    box-shadow: var(--shadow-neon);
    transform: scale(0.95);
}

/* Mobile Layout Adjustments */
@media screen and (max-width: 768px) {
    .game-layout {
        flex-direction: column;
    }
    
    .game-layout.mobile-landscape {
        flex-direction: row;
    }
    
    .sidebar {
        width: 100%;
        height: auto;
        min-height: 120px;
        border-right: none;
        border-bottom: 2px solid hsl(var(--accent-neon) / 0.3);
        padding: 10px;
    }
    
    .game-layout.mobile-landscape .sidebar {
        width: 200px;
        min-width: 200px;
        height: 100vh;
        border-bottom: none;
        border-right: 2px solid hsl(var(--accent-neon) / 0.3);
    }
    
    .game-area {
        flex: 1;
        padding: 10px;
    }
    
    .score-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }
    
    .game-layout.mobile-landscape .score-grid {
        grid-template-columns: 1fr;
        gap: 5px;
    }
    
    .score-item {
        padding: 8px;
        font-size: 0.9em;
    }
    
    .game-layout.mobile-landscape .score-item {
        padding: 5px;
        font-size: 0.8em;
    }
    
    .btn {
        padding: 8px 16px;
        font-size: 0.9em;
    }
    
    .game-layout.mobile-landscape .btn {
        padding: 6px 12px;
        font-size: 0.8em;
    }
}

.sidebar {
    width: 300px;
    min-width: 300px;
    background: linear-gradient(180deg, 
        hsl(var(--bg-secondary)) 0%, 
        hsl(var(--bg-tertiary)) 100%);
    border-right: 2px solid hsl(var(--accent-neon) / 0.3);
    padding: 2rem;
    display: flex;
    flex-direction: column;
    gap: 3rem;
    box-shadow: 0 0 30px hsl(var(--accent-neon) / 0.2);
}

.game-area {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.game-header {
    text-align: center;
}

.game-title {
    font-size: 2.5rem;
    font-weight: 900;
    background: linear-gradient(45deg, 
        hsl(var(--accent-neon)), 
        hsl(var(--accent-blue)), 
        hsl(var(--accent-pink)));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: var(--shadow-neon);
    margin-bottom: 2rem;
    letter-spacing: 0.2rem;
}

.game-stats {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.stat-label {
    font-size: 0.9rem;
    color: hsl(var(--text-secondary));
    text-transform: uppercase;
    letter-spacing: 0.1rem;
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: hsl(var(--accent-neon));
    text-shadow: var(--shadow-neon);
}

.game-board {
    position: relative;
    border: 2px solid hsl(var(--accent-neon));
    border-radius: 15px;
    background: hsl(var(--bg-tertiary));
    box-shadow: 
        0 0 30px hsl(var(--accent-neon) / 0.3),
        inset 0 0 30px hsl(var(--bg-primary) / 0.5);
    overflow: hidden;
    width: 100%;
    height: 100%;
    max-width: calc(100vh - 4rem);
    max-height: calc(100vh - 4rem);
}

#gameCanvas {
    display: block;
    background: transparent;
    width: 100%;
    height: 100%;
}

.game-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: hsl(var(--bg-primary) / 0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(10px);
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

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

.overlay-content {
    text-align: center;
    padding: 2rem;
}

#overlayTitle {
    font-size: 2.5rem;
    font-weight: 700;
    color: hsl(var(--accent-pink));
    text-shadow: var(--shadow-pink);
    margin-bottom: 1rem;
    letter-spacing: 0.2rem;
}

#overlayMessage {
    font-size: 1.2rem;
    color: hsl(var(--text-secondary));
    margin-bottom: 2rem;
}

.game-controls {
    display: flex;
    gap: 1rem;
    justify-content: center;
}

.neon-btn {
    background: transparent;
    border: 2px solid hsl(var(--accent-neon));
    color: hsl(var(--accent-neon));
    padding: 0.8rem 1.5rem;
    font-family: 'Orbitron', monospace;
    font-weight: 700;
    font-size: 1rem;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 0.1rem;
    position: relative;
    overflow: hidden;
}

.neon-btn:hover {
    background: hsl(var(--accent-neon) / 0.1);
    box-shadow: var(--shadow-neon);
    transform: translateY(-2px);
}

.neon-btn:active {
    transform: translateY(0);
}

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

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

.game-instructions {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.instruction {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.8rem 1rem;
    background: hsl(var(--bg-secondary) / 0.5);
    border-radius: 8px;
    border: 1px solid hsl(var(--bg-tertiary));
    backdrop-filter: blur(10px);
}

.key {
    background: hsl(var(--bg-tertiary));
    color: hsl(var(--accent-blue));
    padding: 0.3rem 0.6rem;
    border-radius: 4px;
    font-weight: 700;
    font-size: 0.9rem;
    border: 1px solid hsl(var(--accent-blue) / 0.3);
    min-width: 2rem;
    text-align: center;
}

.instruction span:last-child {
    color: hsl(var(--text-secondary));
    font-size: 0.9rem;
}

/* Responsive Design */
@media (max-width: 1024px) {
    .game-layout {
        flex-direction: column;
    }
    
    .sidebar {
        width: 100%;
        min-width: auto;
        height: auto;
        border-right: none;
        border-bottom: 2px solid hsl(var(--accent-neon) / 0.3);
        padding: 1rem 2rem;
        gap: 2rem;
    }
    
    .game-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        flex-wrap: wrap;
        gap: 2rem;
    }
    
    .game-title {
        font-size: 2rem;
        margin-bottom: 0;
    }
    
    .game-stats {
        flex-direction: row;
        gap: 2rem;
    }
    
    .game-instructions {
        flex-direction: row;
        gap: 1rem;
        flex-wrap: wrap;
        justify-content: center;
    }
    
    .instruction {
        flex: 1;
        min-width: 150px;
    }
}

@media (max-width: 768px) {
    .sidebar {
        padding: 1rem;
    }
    
    .game-title {
        font-size: 1.5rem;
    }
    
    .stat-value {
        font-size: 1.5rem;
    }
    
    .game-controls {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .neon-btn {
        padding: 0.6rem 1rem;
        font-size: 0.9rem;
    }
}

/* Animation keyframes */
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

@keyframes glow {
    0%, 100% { 
        box-shadow: 0 0 20px hsl(var(--accent-neon) / 0.3); 
    }
    50% { 
        box-shadow: 0 0 30px hsl(var(--accent-neon) / 0.6); 
    }
}

.pulse {
    animation: pulse 1s ease-in-out infinite;
}

.glow {
    animation: glow 2s ease-in-out infinite;
}
