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

:root {
    --primary-color: #2c3e50;
    --secondary-color: #3498db;
    --accent-color: #e74c3c;
    --background-color: #0f0f1b;
    --game-bg: #16213e;
    --info-bg: #0f3460;
    --text-color: #ecf0f1;
    --border-radius: 10px;
    --box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2);
    --neon-glow: 0 0 10px rgba(52, 152, 219, 0.7), 0 0 20px rgba(52, 152, 219, 0.5), 0 0 30px rgba(52, 152, 219, 0.3);
    --neon-text-glow: 0 0 5px #fff, 0 0 10px #3498db, 0 0 15px #3498db, 0 0 20px #3498db;
}

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

body {
    display: flex;
    flex-direction: column;
    align-items: center;
    font-family: 'Poppins', sans-serif;
    background-color: var(--background-color);
    color: var(--text-color);
    min-height: 100vh;
    height: 100vh;
    width: 100vw;
    margin: 0;
    padding: 0;
    position: relative;
    overflow: hidden;
}

/* Animated background */
body::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(125deg, #0f0f1b 0%, #16213e 50%, #0f3460 100%);
    z-index: -1;
    animation: gradientBG 15s ease infinite;
    background-size: 400% 400%;
}

@keyframes gradientBG {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

/* Stars animation */
.stars {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    pointer-events: none;
    overflow: hidden;
}

.star {
    position: absolute;
    width: 2px;
    height: 2px;
    background-color: white;
    border-radius: 50%;
    animation: twinkle var(--duration, 5s) infinite ease-in-out;
    opacity: var(--opacity, 0.7);
}

.stars .star:nth-child(1) { top: 10%; left: 5%; --duration: 4s; --opacity: 0.9; }
.stars .star:nth-child(2) { top: 20%; left: 15%; --duration: 6s; --opacity: 0.8; }
.stars .star:nth-child(3) { top: 30%; left: 25%; --duration: 5s; --opacity: 0.7; }
.stars .star:nth-child(4) { top: 40%; left: 35%; --duration: 7s; --opacity: 0.9; }
.stars .star:nth-child(5) { top: 50%; left: 45%; --duration: 4s; --opacity: 0.8; }
.stars .star:nth-child(6) { top: 60%; left: 55%; --duration: 6s; --opacity: 0.7; }
.stars .star:nth-child(7) { top: 70%; left: 65%; --duration: 5s; --opacity: 0.9; }
.stars .star:nth-child(8) { top: 80%; left: 75%; --duration: 7s; --opacity: 0.8; }
.stars .star:nth-child(9) { top: 90%; left: 85%; --duration: 4s; --opacity: 0.7; }
.stars .star:nth-child(10) { top: 15%; left: 95%; --duration: 6s; --opacity: 0.9; }
.stars .star:nth-child(11) { top: 25%; left: 5%; --duration: 5s; --opacity: 0.8; }
.stars .star:nth-child(12) { top: 35%; left: 15%; --duration: 7s; --opacity: 0.7; }
.stars .star:nth-child(13) { top: 45%; left: 25%; --duration: 4s; --opacity: 0.9; }
.stars .star:nth-child(14) { top: 55%; left: 35%; --duration: 6s; --opacity: 0.8; }
.stars .star:nth-child(15) { top: 65%; left: 45%; --duration: 5s; --opacity: 0.7; }
.stars .star:nth-child(16) { top: 75%; left: 55%; --duration: 7s; --opacity: 0.9; }
.stars .star:nth-child(17) { top: 85%; left: 65%; --duration: 4s; --opacity: 0.8; }
.stars .star:nth-child(18) { top: 95%; left: 75%; --duration: 6s; --opacity: 0.7; }
.stars .star:nth-child(19) { top: 5%; left: 85%; --duration: 5s; --opacity: 0.9; }
.stars .star:nth-child(20) { top: 15%; left: 95%; --duration: 7s; --opacity: 0.8; }

@keyframes twinkle {
    0%, 100% { transform: scale(1); opacity: var(--opacity); }
    50% { transform: scale(1.5); opacity: 1; }
}

h1 {
    color: var(--text-color);
    font-family: 'Orbitron', sans-serif;
    font-size: 3.5rem;
    margin: 0.5rem 0;
    text-shadow: var(--neon-text-glow);
    position: relative;
    animation: glow 3s ease-in-out infinite alternate;
    letter-spacing: 5px;
    text-transform: uppercase;
}

h1::before, h1::after {
    content: '';
    position: absolute;
    height: 3px;
    width: 50px;
    background: linear-gradient(90deg, transparent, var(--secondary-color), transparent);
    top: 50%;
    transform: translateY(-50%);
    animation: expandLine 2s ease-in-out infinite alternate;
}

h1::before {
    left: -70px;
}

h1::after {
    right: -70px;
}

@keyframes expandLine {
    from { width: 30px; opacity: 0.5; }
    to { width: 70px; opacity: 1; }
}

@keyframes glow {
    0% { text-shadow: 0 0 5px #fff, 0 0 10px #e74c3c, 0 0 15px #e74c3c; }
    50% { text-shadow: 0 0 10px #fff, 0 0 20px #3498db, 0 0 30px #3498db; }
    100% { text-shadow: 0 0 5px #fff, 0 0 10px #e74c3c, 0 0 15px #e74c3c; }
}

#game-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1.5rem;
    margin-top: 0.5rem;
    perspective: 1000px;
    width: 100%;
    height: calc(100vh - 6rem); /* Account for header */
    max-width: 100vw;
}

#game-board {
    border: 3px solid var(--secondary-color);
    background-color: var(--game-bg);
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow), var(--neon-glow);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    animation: boardAppear 1s ease-out forwards;
    position: relative;
    overflow: hidden;
    height: 100%;
    max-height: calc(100vh - 7rem);
}

#game-board::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: conic-gradient(transparent, rgba(52, 152, 219, 0.1), transparent 30%);
    animation: rotate 10s linear infinite;
}

@keyframes rotate {
    100% { transform: rotate(360deg); }
}

@keyframes boardAppear {
    from { transform: scale(0.9) rotateY(20deg); opacity: 0; }
    to { transform: scale(1) rotateY(0); opacity: 1; }
}

#game-board:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 25px rgba(0, 0, 0, 0.3);
}

#game-info {
    background-color: var(--info-bg);
    padding: 1.5rem;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    min-width: 200px;
    transform: translateZ(20px);
    animation: infoAppear 1s ease-out 0.3s forwards;
    opacity: 0;
    border: 2px solid rgba(52, 152, 219, 0.3);
    backdrop-filter: blur(5px);
    position: relative;
    overflow: hidden;
}

#game-info::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.1), transparent);
    animation: shine 5s infinite;
}

@keyframes shine {
    0% { left: -100%; }
    20% { left: 100%; }
    100% { left: 100%; }
}

@keyframes infoAppear {
    from { transform: translateX(50px); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

#game-info h2, #game-info h3 {
    margin-bottom: 1rem;
    font-size: 1.2rem;
    border-bottom: 2px solid var(--secondary-color);
    padding-bottom: 0.5rem;
    color: var(--text-color);
}

#score, #level {
    font-weight: bold;
    color: var(--accent-color);
    font-size: 1.3rem;
    animation: pulse 2s infinite;
}

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

#next-piece-container {
    margin-top: 1.5rem;
    background-color: rgba(255, 255, 255, 0.05);
    padding: 1rem;
    border-radius: var(--border-radius);
}

#next-piece {
    border: 2px solid var(--secondary-color);
    background-color: var(--game-bg);
    border-radius: 5px;
    display: block;
    margin: 0.5rem auto 0;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

#start-button, #restart-button {
    margin-top: 1.5rem;
    padding: 0.8rem 1.5rem;
    font-size: 1rem;
    font-weight: 600;
    font-family: 'Orbitron', sans-serif;
    cursor: pointer;
    background: linear-gradient(135deg, var(--secondary-color), #2980b9);
    color: white;
    border: none;
    border-radius: 50px;
    width: 100%;
    box-shadow: 0 4px 15px rgba(52, 152, 219, 0.4);
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    text-transform: uppercase;
    letter-spacing: 2px;
}

#start-button::before, #restart-button::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: 0.5s;
}

#start-button:hover, #restart-button:hover {
    transform: translateY(-3px);
    box-shadow: 0 7px 20px rgba(52, 152, 219, 0.6), 0 0 15px rgba(52, 152, 219, 0.8);
    text-shadow: 0 0 5px rgba(255, 255, 255, 0.7);
}

#start-button:hover::before, #restart-button:hover::before {
    left: 100%;
}

#start-button:active, #restart-button:active {
    transform: translateY(0);
    box-shadow: 0 3px 10px rgba(52, 152, 219, 0.4);
}

#start-button:focus, #restart-button:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.5);
}

/* Responsive design */
@media (max-width: 768px) {
    h1 {
        font-size: 2.5rem;
        margin: 0.3rem 0;
    }
    
    #game-container {
        flex-direction: column;
        align-items: center;
        height: calc(100vh - 4rem);
    }
    
    #game-board {
        height: 70vh;
        max-height: 70vh;
    }
    
    #game-info {
        margin-top: 0.5rem;
        margin-left: 0;
        width: 90%;
        max-width: 300px;
        padding: 0.8rem;
    }
    
    #next-piece-container {
        margin-top: 0.5rem;
    }
    
    #start-button, #restart-button {
        margin-top: 0.5rem;
        padding: 0.5rem 1rem;
    }
}

/* Particle container for effects */
#particles-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
    overflow: hidden;
}

/* Game over overlay */
#game-over {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.9);
    z-index: 10;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    animation: fadeIn 0.5s ease-in-out;
    margin: 0;
    padding: 0;
}

#game-over h2 {
    color: var(--text-color);
    font-family: 'Orbitron', sans-serif;
    font-size: 4rem;
    margin-bottom: 2rem;
    text-shadow: 0 0 10px var(--accent-color), 0 0 20px var(--accent-color), 0 0 30px var(--accent-color);
    animation: pulseGameOver 2s infinite alternate;
    letter-spacing: 5px;
}

@keyframes pulseGameOver {
    from { transform: scale(1); text-shadow: 0 0 10px var(--accent-color), 0 0 20px var(--accent-color); }
    to { transform: scale(1.05); text-shadow: 0 0 20px var(--accent-color), 0 0 30px var(--accent-color), 0 0 40px var(--accent-color); }
}

#game-over button {
    padding: 1rem 2rem;
    font-size: 1.2rem;
    background-color: var(--accent-color);
    color: white;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.3s ease;
}

#game-over button:hover {
    transform: scale(1.1);
    box-shadow: 0 0 20px var(--accent-color);
}

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