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

:root {
    --primary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --secondary-gradient: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    --dark-gradient: linear-gradient(135deg, #2c3e50 0%, #34495e 100%);
    --accent-color: #00d4ff;
    --success-color: #00ff88;
    --warning-color: #ffaa00;
    --danger-color: #ff4757;
    --text-primary: #ffffff;
    --text-secondary: #b8c6db;
    --bg-dark: #0f0f23;
    --bg-card: rgba(255, 255, 255, 0.1);
    --shadow-glow: 0 8px 32px rgba(31, 38, 135, 0.37);
    --shadow-intense: 0 15px 35px rgba(0, 0, 0, 0.1), 0 5px 15px rgba(0, 0, 0, 0.07);
}

body {
    font-family: 'Inter', sans-serif;
    background: var(--bg-dark);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    background-image: 
        radial-gradient(circle at 20% 80%, rgba(120, 119, 198, 0.3) 0%, transparent 50%),
        radial-gradient(circle at 80% 20%, rgba(255, 119, 198, 0.3) 0%, transparent 50%),
        radial-gradient(circle at 40% 40%, rgba(120, 219, 255, 0.2) 0%, transparent 50%);
}

.game-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
    min-height: 100vh;
}

/* Header Styles */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    padding: 20px 0;
}

.title {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

.title-main {
    font-family: 'Orbitron', monospace;
    font-size: 3rem;
    font-weight: 900;
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: 0 0 30px rgba(102, 126, 234, 0.5);
    letter-spacing: 3px;
}

.title-sub {
    font-family: 'Inter', sans-serif;
    font-size: 1rem;
    font-weight: 300;
    color: var(--text-secondary);
    margin-top: -5px;
    letter-spacing: 2px;
}

.back-link {
    color: var(--text-secondary);
    text-decoration: none;
    padding: 12px 24px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 25px;
    backdrop-filter: blur(10px);
    background: var(--bg-card);
    transition: all 0.3s ease;
    font-weight: 500;
}

.back-link:hover {
    color: var(--text-primary);
    border-color: var(--accent-color);
    transform: translateY(-2px);
    box-shadow: var(--shadow-glow);
}

/* Game Layout */
.game-wrapper {
    display: grid;
    grid-template-columns: 1fr 2fr 1fr;
    gap: 30px;
    align-items: start;
}

/* Panel Styles */
.left-panel, .right-panel {
    display: flex;
    flex-direction: column;
    gap: 25px;
}

/* Stats Container */
.stats-container {
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    padding: 25px;
    box-shadow: var(--shadow-glow);
}

.stat-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding: 10px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.stat-item:last-child {
    margin-bottom: 0;
    border-bottom: none;
}

.stat-label {
    font-size: 0.9rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.stat-value {
    font-family: 'Orbitron', monospace;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--accent-color);
    text-shadow: 0 0 10px rgba(0, 212, 255, 0.3);
}

/* Next/Hold Piece Containers */
.next-piece-container, .hold-piece-container {
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    padding: 20px;
    text-align: center;
    box-shadow: var(--shadow-glow);
}

.next-title, .hold-title, .controls-title, .scores-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 15px;
    color: var(--text-primary);
}

#next-canvas, #hold-canvas {
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.hold-info {
    margin-top: 10px;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* Game Board */
.game-board-container {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
}

#game-canvas {
    border-radius: 15px;
    background: rgba(0, 0, 0, 0.5);
    border: 2px solid var(--accent-color);
    box-shadow: 
        0 0 50px rgba(0, 212, 255, 0.3),
        inset 0 0 20px rgba(0, 0, 0, 0.5);
}

/* Game Overlay */
.game-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 15px;
    transition: opacity 0.3s ease;
}

.overlay-content {
    text-align: center;
    padding: 40px;
}

#overlay-title {
    font-family: 'Orbitron', monospace;
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 15px;
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

#overlay-message {
    font-size: 1.1rem;
    color: var(--text-secondary);
    margin-bottom: 30px;
}

/* Buttons */
.game-btn, .control-btn {
    background: var(--primary-gradient);
    border: none;
    color: white;
    padding: 15px 30px;
    border-radius: 25px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 1px;
    box-shadow: var(--shadow-intense);
}

.game-btn:hover, .control-btn:hover {
    transform: translateY(-3px);
    box-shadow: 
        0 20px 40px rgba(102, 126, 234, 0.4),
        var(--shadow-intense);
}

.control-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 20px;
    font-size: 0.9rem;
    width: 100%;
    justify-content: center;
}

.btn-icon {
    font-size: 1.2rem;
}

/* Controls Info */
.controls-info {
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    padding: 20px;
    box-shadow: var(--shadow-glow);
}

.control-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    padding: 8px 0;
}

.key {
    background: var(--dark-gradient);
    padding: 4px 8px;
    border-radius: 6px;
    font-family: 'Orbitron', monospace;
    font-size: 0.8rem;
    font-weight: 600;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.action {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* Game Controls */
.game-controls {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* High Scores */
.high-scores {
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    padding: 20px;
    box-shadow: var(--shadow-glow);
}

.score-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.score-entry {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.rank {
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 0.9rem;
}

.score-entry .score {
    font-family: 'Orbitron', monospace;
    font-weight: 600;
    color: var(--accent-color);
}

/* Responsive Design */
@media (max-width: 1200px) {
    .game-wrapper {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    
    .left-panel, .right-panel {
        flex-direction: row;
        justify-content: space-around;
        flex-wrap: wrap;
    }
    
    .left-panel > *, .right-panel > * {
        flex: 1;
        min-width: 200px;
    }
}

@media (max-width: 768px) {
    .title-main {
        font-size: 2rem;
    }
    
    .header {
        flex-direction: column;
        gap: 15px;
        text-align: center;
    }
    
    .game-container {
        padding: 15px;
    }
    
    #game-canvas {
        width: 250px;
        height: 500px;
    }
    
    .left-panel, .right-panel {
        flex-direction: column;
    }
}

/* Animation Classes */
.fade-in {
    animation: fadeIn 0.3s ease;
}

.pulse {
    animation: pulse 2s infinite;
}

.shake {
    animation: shake 0.5s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

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

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

/* Particle effects */
.particle {
    position: absolute;
    width: 4px;
    height: 4px;
    background: var(--accent-color);
    border-radius: 50%;
    pointer-events: none;
    animation: particle 1s ease-out forwards;
}

@keyframes particle {
    0% {
        opacity: 1;
        transform: scale(1);
    }
    100% {
        opacity: 0;
        transform: scale(0) translateY(-50px);
    }
}