:root {
    --bg-color: #0f172a;
    --panel-bg: rgba(30, 41, 59, 0.7);
    --accent-color: #38bdf8;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --grid-line: rgba(255, 255, 255, 0.05);
    --neon-glow: 0 0 10px rgba(56, 189, 248, 0.5);
    --font-main: 'Outfit', sans-serif;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-main);
    background-color: var(--bg-color);
    color: var(--text-primary);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    overflow: hidden;
    background: radial-gradient(circle at top right, #1e293b, #0f172a);
}

.app-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2rem;
    padding: 2rem;
    backdrop-filter: blur(10px);
}

header h1 {
    font-size: 3rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 2px;
    background: linear-gradient(to right, #38bdf8, #818cf8);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: 0 0 20px rgba(56, 189, 248, 0.3);
}

.game-container {
    display: flex;
    gap: 2rem;
    align-items: flex-start;
}

.game-board-wrapper {
    position: relative;
    padding: 4px;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.05));
    border-radius: 12px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
}

canvas#tetris {
    display: block;
    background-color: rgba(15, 23, 42, 0.95);
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.game-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.85);
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 12px;
    backdrop-filter: blur(5px);
    transition: opacity 0.3s ease;
}

.game-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.overlay-content {
    text-align: center;
}

.overlay-content h2 {
    font-size: 2rem;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.btn-primary {
    background: linear-gradient(135deg, #38bdf8, #2563eb);
    border: none;
    padding: 0.8rem 2rem;
    font-size: 1.2rem;
    color: white;
    border-radius: 50px;
    cursor: pointer;
    font-family: var(--font-main);
    font-weight: 600;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 0 20px rgba(56, 189, 248, 0.6);
}

.btn-secondary {
    background: transparent;
    border: 2px solid #38bdf8;
    padding: 0.5rem 1.5rem;
    font-size: 1rem;
    color: #38bdf8;
    border-radius: 50px;
    cursor: pointer;
    font-family: var(--font-main);
    font-weight: 600;
    margin-top: 1rem;
    transition: all 0.2s;
}

.btn-secondary:hover {
    background: rgba(56, 189, 248, 0.1);
}

.hidden {
    display: none !important;
}

.input-group {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
    margin-bottom: 1rem;
}

#player-name {
    padding: 0.8rem;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: rgba(255, 255, 255, 0.1);
    color: white;
    font-family: var(--font-main);
    font-size: 1rem;
    outline: none;
}

#player-name:focus {
    border-color: var(--accent-color);
}

.leaderboard-container {
    background: rgba(0, 0, 0, 0.3);
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    max-height: 360px;
    overflow-y: auto;
    width: 100%;
    min-width: 280px;
}

.leaderboard-container h3 {
    color: #fbbf24;
    margin-bottom: 0.5rem;
    font-size: 1.2rem;
}

#leaderboard-list {
    list-style: none;
    padding: 0;
}

#leaderboard-list li {
    display: flex;
    justify-content: space-between;
    padding: 0.3rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    font-size: 0.9rem;
}

#leaderboard-list li:nth-child(1) {
    color: #fbbf24;
    font-weight: bold;
}

#leaderboard-list li:nth-child(2) {
    color: #94a3b8;
    font-weight: bold;
}

#leaderboard-list li:nth-child(3) {
    color: #b45309;
    font-weight: bold;
}

.final-score {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
    color: var(--accent-color);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(37, 99, 235, 0.6);
}

.btn-primary:active {
    transform: translateY(0);
}

.game-info {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    min-width: 160px;
}

.info-panel {
    background: var(--panel-bg);
    padding: 1.5rem;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    text-align: center;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.info-panel h3,
.controls-guide h3 {
    font-size: 0.9rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 0.5rem;
}

.info-panel div {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--text-primary);
}

.next-piece-panel canvas {
    margin-top: 0.5rem;
}

.controls-guide {
    margin-top: 1rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.controls-guide ul {
    list-style: none;
}

.controls-guide li {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.5rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.controls-guide li:last-child {
    border-bottom: none;
}

.controls-guide span {
    font-weight: 700;
    color: var(--accent-color);
    background: rgba(56, 189, 248, 0.1);
    padding: 2px 6px;
    border-radius: 4px;
}

@media (max-width: 600px) {
    .game-container {
        flex-direction: column;
        align-items: center;
    }

    .game-info {
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
    }

    .controls-guide {
        display: none;
    }
}