:root {
    --primary-red: #8B0000;
    --primary-gold: #FFD700;
    --secondary-gold: #DAA520;
    --glass-bg: rgba(20, 0, 0, 0.6);
    --glass-border: rgba(255, 215, 0, 0.3);
    --neon-glow: 0 0 10px rgba(255, 215, 0, 0.5);
    --text-shadow: 0 0 5px rgba(255, 215, 0, 0.8);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    user-select: none;
}

body {
    background-color: #050000;
    background-image:
        radial-gradient(circle at 50% 50%, #2a0000 0%, #000 100%);
    color: #fff;
    font-family: 'Cinzel', serif;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

/* Animated Background Particles (Simulated with gradients) */
body::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background:
        radial-gradient(circle at 20% 30%, rgba(139, 0, 0, 0.2) 0%, transparent 20%),
        radial-gradient(circle at 80% 70%, rgba(218, 165, 32, 0.1) 0%, transparent 20%);
    animation: pulseBg 10s infinite alternate;
    z-index: -1;
}

@keyframes pulseBg {
    0% {
        transform: scale(1);
        opacity: 0.5;
    }

    100% {
        transform: scale(1.1);
        opacity: 0.8;
    }
}

#game-container {
    position: relative;
    width: 900px;
    height: 700px;
    background: rgba(20, 0, 0, 0.4);
    backdrop-filter: blur(10px);
    border: 1px solid var(--glass-border);
    box-shadow:
        0 0 30px rgba(139, 0, 0, 0.3),
        inset 0 0 50px rgba(0, 0, 0, 0.5);
    border-radius: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

/* Decorative Elements */
.onion-dome {
    position: absolute;
    bottom: -20px;
    width: 200px;
    height: 250px;
    background: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><path d="M50 0 C20 30 10 60 10 80 L90 80 C90 60 80 30 50 0 Z" fill="none" stroke="%23DAA520" stroke-width="1" stroke-opacity="0.3"/></svg>') no-repeat center bottom;
    background-size: contain;
    opacity: 0.5;
    z-index: 0;
    filter: drop-shadow(0 0 5px var(--primary-gold));
}

.onion-dome.left {
    left: -60px;
    transform: rotate(-5deg);
}

.onion-dome.right {
    right: -60px;
    transform: rotate(5deg);
}

/* Screens */
.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(5px);
    z-index: 10;
    transition: opacity 0.5s ease;
}

.screen.hidden {
    opacity: 0;
    pointer-events: none;
    z-index: -1;
}

.screen.active {
    opacity: 1;
    pointer-events: all;
}

h2.subtitle {
    font-size: 1.8rem;
    color: #fff;
    margin-bottom: 4rem;
    letter-spacing: 5px;
    text-transform: uppercase;
    opacity: 0.8;
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
}

h3 {
    color: var(--primary-gold);
    margin-bottom: 15px;
    font-size: 1.1rem;
    text-align: center;
    text-shadow: var(--text-shadow);
    letter-spacing: 2px;
}

/* Buttons */
.btn {
    background: linear-gradient(45deg, #8B0000, #500000);
    color: #fff;
    border: 1px solid var(--primary-gold);
    padding: 18px 50px;
    font-family: 'Cinzel', serif;
    font-size: 1.3rem;
    margin: 15px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    box-shadow: 0 0 15px rgba(139, 0, 0, 0.4);
    min-width: 240px;
    position: relative;
    overflow: hidden;
    border-radius: 5px;
}

.btn::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;
}

.btn:hover::before {
    left: 100%;
}

.btn:hover {
    background: linear-gradient(45deg, #a00000, #700000);
    transform: scale(1.05);
    box-shadow: 0 0 25px rgba(255, 215, 0, 0.4);
    border-color: #fff;
}

/* Game Layout */
#game-screen {
    background: transparent;
    flex-direction: row;
    justify-content: center;
    align-items: center;
    padding-top: 0;
    gap: 40px;
}

.sidebar {
    width: 180px;
    display: flex;
    flex-direction: column;
    gap: 30px;
    z-index: 5;
}

.panel {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    padding: 20px;
    text-align: center;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.3);
    border-radius: 15px;
    backdrop-filter: blur(5px);
    transition: transform 0.3s;
}

.panel:hover {
    transform: translateY(-5px);
    box-shadow: var(--neon-glow);
}

.board-container {
    position: relative;
    padding: 5px;
    border: 2px solid var(--primary-gold);
    background: rgba(0, 0, 0, 0.8);
    box-shadow: 0 0 30px rgba(255, 215, 0, 0.2);
    z-index: 5;
    border-radius: 5px;
}

canvas {
    display: block;
}

#game-canvas {
    background: radial-gradient(circle at center, #1a0505 0%, #000 100%);
    /* Grid lines handled in JS or subtle CSS */
    box-shadow: inset 0 0 20px #000;
}

#score-display,
#level-display,
#lines-display,
#highscore-display {
    font-family: 'Roboto Mono', monospace;
    font-size: 1.8rem;
    color: #fff;
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
}

#pause-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(5px);
    color: var(--primary-gold);
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 3rem;
    font-weight: bold;
    letter-spacing: 5px;
    text-shadow: var(--neon-glow);
    z-index: 20;
}

/* Leaderboard */
#leaderboard-list {
    list-style: none;
    width: 70%;
    margin-bottom: 40px;
    max-height: 350px;
    overflow-y: auto;
    background: rgba(0, 0, 0, 0.3);
    padding: 20px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

#leaderboard-list li {
    display: flex;
    justify-content: space-between;
    padding: 15px;
    border-bottom: 1px solid rgba(255, 215, 0, 0.2);
    font-family: 'Roboto Mono', monospace;
    font-size: 1.2rem;
}

#leaderboard-list li:first-child {
    color: var(--primary-gold);
    font-weight: bold;
    font-size: 1.4rem;
    text-shadow: 0 0 10px var(--primary-gold);
}

input[type="text"] {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid var(--primary-gold);
    color: #fff;
    padding: 15px;
    font-family: 'Roboto Mono', monospace;
    font-size: 1.4rem;
    text-align: center;
    margin: 20px 0;
    outline: none;
    border-radius: 5px;
    width: 300px;
}

input[type="text"]:focus {
    background: rgba(255, 255, 255, 0.2);
    box-shadow: 0 0 15px rgba(255, 215, 0, 0.3);
}

.controls-info {
    margin-top: 50px;
    text-align: center;
    color: rgba(255, 255, 255, 0.6);
    font-family: 'Roboto Mono', monospace;
    font-size: 0.9rem;
    line-height: 1.8;
    background: rgba(0, 0, 0, 0.3);
    padding: 15px;
    border-radius: 10px;
}

.hidden {
    display: none !important;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.3);
}

::-webkit-scrollbar-thumb {
    background: var(--primary-red);
    border-radius: 4px;
}