/* Utility classes */
.hidden {
    display: none !important;
}/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, #0a0a0a 0%, #1a1a2e 100%);
    color: #ffffff;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

/* Main container */
.game-container {
    display: flex;
    gap: 20px;
    padding: 20px;
    max-width: 1200px;
    margin: 0 auto;
    align-items: stretch;
}

/* Game wrapper */
.game-wrapper {
    position: relative;
    background: linear-gradient(135deg, #1e3c72 0%, #2a5298 50%, #7e3a7e 100%);
    border-radius: 16px;
    padding: 15px;
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.3), 0 0 30px rgba(126, 58, 126, 0.2);
}

#tetris-canvas {
    display: block;
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.3);
}

/* Sidebar */
.sidebar {
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-width: 400px;
    flex: 0 0 400px;
}

.sidebar .leaderboard-section {
    flex: 1;
}

/* Info panels with glassmorphism */
.info-panel {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    padding: 10px;
    text-align: center;
    transition: all 0.3s ease;
}

.info-panel:hover {
    background: rgba(255, 255, 255, 0.15);
    transform: translateY(-2px);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
}

.info-panel h3 {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 2px;
    margin-bottom: 4px;
    color: rgba(255, 255, 255, 0.8);
}

.info-panel .value {
    font-size: 1.6rem;
    font-weight: bold;
    background: linear-gradient(135deg, #4a69bd, #e056fd);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Controls panel */
.controls-panel {
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 10px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.controls-left {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.controls-right {
    display: flex;
    align-items: flex-end;
}

.level-selector {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.level-selector label {
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.8);
    white-space: nowrap;
}

.level-selector input {
    width: 80px;
    padding: 6px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.1);
    color: white;
    font-size: 0.9rem;
    text-align: center;
}

/* Buttons */
.btn {
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 1px;
    white-space: nowrap;
}

.btn-full {
    width: 100%;
}

.btn-primary {
    background: linear-gradient(135deg, #4a69bd, #e056fd);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(224, 86, 253, 0.3);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.15);
}

/* Instructions panel */
.instructions-panel {
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 12px 15px;
}

.instructions-panel h3 {
    font-size: 0.9rem;
    margin-bottom: 8px;
    text-align: center;
}

.key-bindings {
    font-size: 0.8rem;
}

.key-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 3px 0;
    color: rgba(255, 255, 255, 0.8);
}

.key {
    background: rgba(255, 255, 255, 0.1);
    padding: 4px 8px;
    border-radius: 4px;
    font-family: monospace;
    font-size: 0.8rem;
    min-width: 60px;
    text-align: center;
    display: inline-block;
}

/* Leaderboard section */
.leaderboard-section {
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    padding: 12px 15px;
    display: flex;
    flex-direction: column;
}

.leaderboard-section h2 {
    text-align: center;
    margin-bottom: 8px;
    font-size: 1.2rem;
    background: linear-gradient(135deg, #4a69bd, #e056fd);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.leaderboard-content {
    max-height: 170px;
    overflow-y: auto;
}

/* Custom scrollbar for leaderboard */
.leaderboard-content::-webkit-scrollbar {
    width: 6px;
}

.leaderboard-content::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 3px;
}

.leaderboard-content::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
}

.leaderboard-content::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

.leaderboard-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.leaderboard-table th,
.leaderboard-table td {
    padding: 6px 10px;
    text-align: left;
}

.leaderboard-table th {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 1px;
    color: rgba(255, 255, 255, 0.8);
    position: sticky;
    top: 0;
    z-index: 10;
    /* Add these to ensure the header stays opaque */
    background-color: rgba(26, 26, 46, 0.95);
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

.leaderboard-table tr {
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.leaderboard-table tbody tr:hover {
    background: rgba(255, 255, 255, 0.05);
}

.leaderboard-table td:first-child {
    font-weight: bold;
    color: #e056fd;
}

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

.game-over-overlay:not(.hidden) {
    opacity: 1;
}

.game-over-content {
    text-align: center;
    padding: 40px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.game-over-content h2 {
    font-size: 2.5rem;
    margin-bottom: 20px;
    background: linear-gradient(135deg, #4a69bd, #e056fd);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.final-score {
    font-size: 1.5rem;
    margin-bottom: 30px;
    color: rgba(255, 255, 255, 0.9);
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(5px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.modal:not(.hidden) {
    opacity: 1;
}

.modal-content {
    background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
    border-radius: 16px;
    padding: 40px;
    min-width: 400px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.modal-content h2 {
    text-align: center;
    margin-bottom: 30px;
    font-size: 2rem;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    color: rgba(255, 255, 255, 0.8);
}

.form-group input {
    width: 100%;
    padding: 12px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.1);
    color: white;
    font-size: 1rem;
}

.score-summary {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
    text-align: center;
}

.score-summary p {
    margin: 5px 0;
    font-size: 1.1rem;
}

.modal-buttons {
    display: flex;
    gap: 10px;
}

.modal-buttons button {
    flex: 1;
}

/* Game credit */
.game-credit {
    text-align: center;
    margin-top: 10px;
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.7);
}

.game-credit a {
    color: #e056fd;
    text-decoration: none;
    transition: all 0.3s ease;
}

.game-credit a:hover {
    color: #ff6fb5;
    text-decoration: underline;
}

/* Game stats row */
.game-stats {
    display: flex;
    gap: 10px;
}

.game-stats .info-panel {
    flex: 1;
}

/* Responsive adjustments */
@media (max-width: 1000px) {
    .game-container {
        flex-direction: column;
        align-items: center;
    }
    
    .sidebar {
        min-width: unset;
        flex: unset;
        width: 100%;
        max-width: 520px;
    }
    
    .game-stats {
        flex-wrap: wrap;
    }
}

/* CORS Warning */
.cors-warning {
    text-align: center;
    margin-top: 15px;
    padding: 10px;
    background: rgba(224, 86, 253, 0.1);
    border: 1px solid rgba(224, 86, 253, 0.3);
    border-radius: 8px;
}

.cors-warning p {
    margin: 5px 0;
    color: #e056fd;
    font-size: 0.85rem;
}

.btn-small {
    font-size: 0.75rem;
    padding: 6px 12px;
}

/* Auth section */
.auth-section {
    display: flex;
}

#clerk-auth {
    width: 100%;
}

#clerk-auth .btn {
    width: 100%;
}