:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --accent: #f59e0b;
    --bg-dark: #0f172a;
    --card-bg: rgba(30, 41, 59, 0.7);
    --text: #f1f5f9;
    --text-muted: #94a3b8;
    --border: rgba(51, 65, 85, 0.5);
    --radius: 12px;
    --shadow: 0 10px 15px -3px rgb(0 0 0 / 0.3);
}

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

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-dark);
    color: var(--text);
    overflow: hidden;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
}

.game-container {
    width: 100%;
    height: 100%;
    max-width: 1200px;
    display: flex;
    flex-direction: column;
    position: relative;
    z-index: 10;
}

/* Header */
.game-header {
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    backdrop-filter: blur(12px);
    background: rgba(15, 23, 42, 0.6);
    border-bottom: 1px solid var(--border);
}

.back-link {
    color: var(--text);
    text-decoration: none;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: 0.2s;
}

.back-link:hover {
    color: var(--primary);
    transform: translateX(-5px);
}

.stats-group {
    display: flex;
    gap: 2rem;
}

.stat-item {
    font-family: 'Outfit', sans-serif;
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--accent);
}

.stat-item span {
    color: white;
}

/* Main Layout */
#game-stage {
    flex-grow: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 2rem;
    position: relative;
}

.game-layout {
    display: grid;
    grid-template-columns: auto 300px;
    gap: 2rem;
    align-items: start;
}

.board-container {
    background: #000;
    padding: 5px;
    border-radius: 8px;
    border: 4px solid var(--border);
    box-shadow: 0 0 40px rgba(37, 99, 235, 0.2);
    height: 600px;
}

canvas#tetrisCanvas {
    height: 100%;
    display: block;
}

/* Side Panels */
.game-aside {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.hud-panel {
    background: var(--card-bg);
    backdrop-filter: blur(8px);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
}

.hud-panel h3 {
    font-family: 'Outfit';
    font-size: 1rem;
    color: var(--primary);
    margin-bottom: 1rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

#math-hud {
    text-align: center;
    border-left: 4px solid var(--accent);
}

.numbers-display {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.8rem;
    margin-bottom: 1.5rem;
}

.number-box {
    background: rgba(255,255,255,0.1);
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    font-weight: 800;
    border-radius: 8px;
    color: white;
    font-family: 'Outfit';
}

.operator {
    font-size: 1.5rem;
    color: var(--accent);
    font-weight: 800;
}

.math-instruction {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
}

.buffer-display {
    background: rgba(0, 0, 0, 0.4);
    border: 2px solid var(--primary);
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1.5rem;
    font-family: 'JetBrains Mono', monospace;
    font-size: 1.8rem;
    letter-spacing: 4px;
    color: var(--accent);
    min-height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: inset 0 0 10px rgba(0,0,0,0.5);
}

.buffer-display.active {
    border-color: var(--accent);
    box-shadow: 0 0 15px var(--accent-glow);
}

.buffer-display.success {
    border-color: #10b981;
    background: rgba(16, 185, 129, 0.1);
}

.rotation-info {
    text-align: left;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.info-row {
    margin-top: 0.4rem;
}

.info-row i {
    color: var(--accent);
}

.next-piece-panel {
    text-align: center;
    padding: 1rem;
}

#nextCanvas {
    width: 80px;
    height: 80px;
}

.controls-guide p {
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Overlays */
.overlay {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    backdrop-filter: blur(10px);
}

.overlay-content {
    background: var(--card-bg);
    border: 1px solid var(--border);
    padding: 3rem;
    border-radius: 20px;
    text-align: center;
    max-width: 500px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

.overlay h1 {
    font-family: 'Outfit';
    font-size: 3rem;
    color: var(--primary);
    margin-bottom: 1rem;
}

.btn-primary {
    background: var(--primary);
    color: white;
    border: none;
    padding: 1rem 2.5rem;
    font-size: 1.2rem;
    font-weight: 700;
    border-radius: 12px;
    cursor: pointer;
    transition: 0.3s;
    margin: 2rem 0;
}

.btn-primary:hover {
    background: var(--primary-dark);
    transform: scale(1.05);
}

.instructions {
    text-align: left;
    background: rgba(0,0,0,0.2);
    padding: 1.5rem;
    border-radius: 12px;
}

.instructions p {
    margin-bottom: 0.5rem;
    font-size: 0.95rem;
}

/* Background Effects */
.bg-decoration {
    position: fixed;
    inset: 0;
    z-index: 0;
    overflow: hidden;
}

.shape {
    position: absolute;
    filter: blur(80px);
    opacity: 0.2;
    border-radius: 50%;
}

.shape-1 {
    width: 400px;
    height: 400px;
    background: var(--primary);
    top: -100px;
    left: -100px;
}

.shape-2 {
    width: 300px;
    height: 300px;
    background: var(--accent);
    bottom: -50px;
    right: -50px;
}

/* Animations */
@keyframes shake {
    0% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    50% { transform: translateX(5px); }
    75% { transform: translateX(-5px); }
    100% { transform: translateX(0); }
}

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

/* Responsive */
@media (max-width: 900px) {
    .game-layout {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto;
    }
    .game-aside {
        flex-direction: row;
        flex-wrap: wrap;
    }
    .hud-panel {
        flex: 1;
    }
}
