:root {
    --primary: #6366f1;
    --secondary: #8b5cf6;
    --bg-start: #0f0c29;
    --bg-mid: #302b63;
    --bg-end: #24243e;
    --text-primary: #ffffff;
    --text-secondary: rgba(255, 255, 255, 0.7);
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(135deg, var(--bg-start) 0%, var(--bg-mid) 50%, var(--bg-end) 100%);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 2rem;
}

.tetris-container {
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 1.5rem;
    padding: 2rem;
    max-width: 900px;
    width: 100%;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3), 0 0 40px rgba(99, 102, 241, 0.3);
}

.tetris-header {
    text-align: center;
    margin-bottom: 2rem;
}

.tetris-logo-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

.tetris-logo {
    height: 3.5rem;
    width: auto;
    max-width: 3.5rem;
    object-fit: contain;
    filter: drop-shadow(0 0 20px var(--primary));
}

.tetris-header h1 {
    font-size: 2rem;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin: 0;
}

.music-control {
    display: flex;
    justify-content: center;
    margin-bottom: 1rem;
}

.music-toggle-label {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
    user-select: none;
}

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

.music-toggle {
    display: none;
}

.toggle-slider {
    position: relative;
    width: 50px;
    height: 26px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 13px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    transition: all 0.3s;
}

.toggle-slider::before {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    left: 3px;
    top: 2px;
    background: var(--text-secondary);
    border-radius: 50%;
    transition: all 0.3s;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.music-toggle:checked + .toggle-slider {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border-color: var(--primary);
}

.music-toggle:checked + .toggle-slider::before {
    transform: translateX(24px);
    background: white;
}

.music-toggle-label:hover .toggle-slider {
    border-color: var(--primary);
}

.score-board {
    display: flex;
    justify-content: center;
    gap: 2rem;
    flex-wrap: wrap;
}

.score-item {
    background: rgba(255, 255, 255, 0.1);
    padding: 0.75rem 1.5rem;
    border-radius: 0.75rem;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.score-item .label {
    color: var(--text-secondary);
    margin-right: 0.5rem;
    font-size: 0.875rem;
}

.score-item span:last-child {
    font-weight: 600;
    font-size: 1.25rem;
    color: var(--primary);
}

.tetris-main {
    display: flex;
    gap: 2rem;
    justify-content: center;
    align-items: flex-start;
    flex-wrap: wrap;
}

.tetris-sidebar {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.next-piece, .controls {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 1rem;
    padding: 1.5rem;
}

.next-piece h3, .controls h3 {
    font-size: 1rem;
    color: var(--text-secondary);
    margin-bottom: 1rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

#nextCanvas {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 0.5rem;
    display: block;
}

.control-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.tetris-game {
    position: relative;
}

#gameCanvas {
    background: rgba(0, 0, 0, 0.5);
    border: 2px solid var(--primary);
    border-radius: 0.5rem;
    display: block;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5), 0 0 20px rgba(99, 102, 241, 0.3);
    max-width: 100%;
    height: auto;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
}

.game-over, .paused {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(15, 12, 41, 0.95);
    backdrop-filter: blur(10px);
    border: 2px solid var(--primary);
    border-radius: 1rem;
    padding: 2rem;
    text-align: center;
    z-index: 10;
    min-width: 300px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
}

.game-over h2, .paused h2 {
    font-size: 2rem;
    margin-bottom: 1rem;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.game-over p {
    margin-bottom: 1.5rem;
    color: var(--text-secondary);
}

.game-over button, .paused button {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 0.5rem;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    margin: 0.5rem;
    transition: all 0.2s;
}

.game-over button:hover, .paused button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.4);
}

.hidden {
    display: none;
}

.tetris-footer {
    margin-top: 2rem;
    display: flex;
    justify-content: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.tetris-footer button {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 0.75rem 1.5rem;
    border-radius: 0.5rem;
    font-size: 0.9375rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.tetris-footer button:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: var(--primary);
    transform: translateY(-2px);
}

/* Mobile Controls */
.mobile-controls {
    display: none; /* Hidden on desktop */
    margin-top: 1.5rem;
    gap: 0.75rem;
    flex-direction: column;
    align-items: center;
}

.control-row {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
}

.control-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.2);
    color: var(--text-primary);
    padding: 1rem 1.5rem;
    border-radius: 0.75rem;
    font-size: 1.5rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    min-width: 60px;
    min-height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.control-btn:active {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border-color: var(--primary);
    transform: scale(0.95);
    box-shadow: 0 0 20px rgba(99, 102, 241, 0.5);
}

.control-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: var(--primary);
}

#btnHardDrop {
    font-size: 1.25rem;
    flex: 1;
    max-width: 200px;
}

@media (max-width: 768px) {
    .tetris-container {
        padding: 1rem;
        max-width: 100%;
    }
    
    body {
        padding: 0.5rem;
    }
    
    .tetris-logo {
        height: 2.5rem;
        max-width: 2.5rem;
    }
    
    .tetris-header h1 {
        font-size: 1.5rem;
    }
    
    .tetris-main {
        flex-direction: column;
        align-items: center;
    }
    
    .tetris-sidebar {
        width: 100%;
        max-width: 100%;
        order: 2;
    }
    
    .tetris-game {
        order: 1;
        width: 100%;
    }
    
    #gameCanvas {
        width: 100% !important;
        max-width: 100% !important;
        height: auto !important;
    }
    
    /* Show mobile controls on mobile */
    .mobile-controls {
        display: flex;
        order: 3;
        width: 100%;
    }
    
    .tetris-footer {
        order: 4;
        flex-direction: column;
        width: 100%;
    }
    
    .tetris-footer button {
        width: 100%;
        max-width: 300px;
    }
    
    .score-board {
        gap: 1rem;
    }
    
    .score-item {
        padding: 0.5rem 1rem;
        font-size: 0.875rem;
    }
    
    .score-item .label {
        font-size: 0.75rem;
    }
    
    .score-item span:last-child {
        font-size: 1rem;
    }
    
    .next-piece, .controls {
        padding: 1rem;
    }
    
    .next-piece h3, .controls h3 {
        font-size: 0.875rem;
        margin-bottom: 0.75rem;
    }
    
    #nextCanvas {
        width: 100%;
        max-width: 120px;
        height: auto;
    }
    
    .control-list {
        font-size: 0.75rem;
    }
}

@media (max-width: 480px) {
    .tetris-container {
        padding: 0.75rem;
    }
    
    .tetris-header h1 {
        font-size: 1.25rem;
    }
    
    .control-btn {
        min-width: 50px;
        min-height: 50px;
        padding: 0.75rem 1rem;
        font-size: 1.25rem;
    }
    
    #btnHardDrop {
        font-size: 1rem;
    }
    
    .score-board {
        gap: 0.5rem;
    }
    
    .score-item {
        padding: 0.5rem 0.75rem;
    }
}

