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

:root {
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-tertiary: #334155;
    --text-primary: #ffffff;
    --text-secondary: #cbd5e1;
    --border-color: #475569;
    --accent-purple: #a855f7;
    --accent-blue: #3b82f6;
    --accent-green: #10b981;
    --accent-yellow: #fbbf24;
    --accent-red: #ef4444;
    --accent-amber: #f59e0b;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(to bottom right, #0f172a, #1e293b, #0f172a);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
}

.app {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    z-index: 40;
}

.sidebar-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    height: 100vh;
    width: 280px;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    padding: 24px;
    overflow-y: auto;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    z-index: 50;
}

.sidebar.active {
    transform: translateX(0);
}

.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.sidebar-header h2 {
    font-size: 20px;
    font-weight: bold;
}

.close-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 24px;
    cursor: pointer;
    padding: 0;
    width: 24px;
    height: 24px;
}

.close-btn:hover {
    color: var(--text-primary);
}

/* Auth Section */
.auth-section {
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 16px;
    margin-bottom: 16px;
}

#loggedOutView p {
    color: var(--text-secondary);
    font-size: 12px;
    margin-bottom: 12px;
}

.signup-btn {
    display: block;
    width: 100%;
    padding: 10px;
    background: linear-gradient(to right, var(--accent-purple), var(--accent-blue));
    color: white;
    border: none;
    border-radius: 6px;
    text-decoration: none;
    text-align: center;
    font-weight: bold;
    cursor: pointer;
    transition: opacity 0.3s ease;
}

.signup-btn:hover {
    opacity: 0.9;
}

.user-info {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.user-name {
    font-size: 14px;
    font-weight: bold;
    color: var(--text-primary);
}

.logout-btn {
    padding: 8px 12px;
    background: var(--accent-red);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    font-weight: bold;
    transition: background 0.3s ease;
}

.logout-btn:hover {
    background: #dc2626;
}

/* Game Stats */
.game-stats {
    display: grid;
    gap: 16px;
    margin-bottom: 24px;
    padding-bottom: 24px;
    border-bottom: 1px solid var(--border-color);
}

.stat-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

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

.stat-value {
    font-size: 20px;
    font-weight: bold;
}

.stat-value.level-value {
    color: var(--accent-purple);
}

.stat-value.progress-value {
    color: var(--accent-blue);
}

.stat-value.streak-value {
    color: var(--accent-amber);
}

.stat-value.accuracy-value {
    color: var(--accent-green);
}

.stat-value.score-value {
    color: var(--accent-green);
}

.end-game-btn {
    width: 100%;
    padding: 12px;
    background: var(--accent-red);
    color: white;
    border: none;
    border-radius: 8px;
    font-weight: bold;
    cursor: pointer;
    transition: background 0.3s ease;
}

.end-game-btn:hover {
    background: #dc2626;
}

/* User Stats */
.user-stats {
    border-top: 1px solid var(--border-color);
    border-bottom: 1px solid var(--border-color);
    padding: 16px 0;
    margin-bottom: 16px;
}

/* Sidebar Tabs */
.sidebar-tabs {
    display: flex;
    flex-direction: column;
    gap: 8px;
    border-top: 1px solid var(--border-color);
    padding-top: 16px;
}

.tab-btn {
    padding: 10px;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: left;
    font-size: 14px;
    font-weight: 500;
}

.tab-btn:hover {
    background: #475569;
}

.tab-btn.active {
    background: var(--accent-blue);
    color: white;
}

/* Main Container */
.main-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 16px;
    width: 100%;
}

.header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    width: 100%;
    max-width: 800px;
    margin-bottom: 32px;
}

.header-content h1 {
    font-size: 48px;
    font-weight: bold;
    margin-bottom: 8px;
}

.header-content p {
    color: var(--text-secondary);
    font-size: 14px;
}

.menu-btn {
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 32px;
    cursor: pointer;
    padding: 8px;
    transition: color 0.3s ease;
}

.menu-btn:hover {
    color: var(--text-secondary);
}

/* Game Area */
.game-area {
    width: 100%;
    max-width: 800px;
}

.level-progress {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 32px;
    padding: 0 16px;
}

.level-info {
    text-align: center;
}

.info-label {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.info-value {
    font-size: 28px;
    font-weight: bold;
}

/* Timer */
.timer-section {
    margin-bottom: 32px;
}

.timer-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.timer-header span:first-child {
    font-size: 12px;
    color: var(--text-secondary);
}

.timer-value {
    color: var(--text-primary);
    font-weight: bold;
}

.timer-bar {
    width: 100%;
    height: 16px;
    background: var(--bg-tertiary);
    border-radius: 9999px;
    overflow: hidden;
}

.timer-fill {
    height: 100%;
    background: var(--accent-green);
    width: 100%;
    transition: width 0.05s linear, background 0.3s ease;
    border-radius: 9999px;
}

.timer-fill.warning {
    background: var(--accent-yellow);
}

.timer-fill.danger {
    background: var(--accent-red);
}

/* Color Display */
.color-display {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 24px;
    margin-bottom: 32px;
}

.color-box {
    width: 160px;
    height: 160px;
    border-radius: 8px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.5);
    transition: transform 0.3s ease;
}

.color-box:hover {
    transform: scale(1.05);
}

.color-name {
    font-size: 28px;
    font-weight: bold;
    color: var(--text-primary);
    text-align: center;
}

/* Feedback */
.feedback {
    text-align: center;
    font-size: 20px;
    font-weight: bold;
    color: var(--text-primary);
    margin-bottom: 24px;
    min-height: 28px;
    animation: bounce 0.6s ease;
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

/* Color Buttons */
.color-buttons {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.color-btn {
    height: 80px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.3);
}

.color-btn:hover {
    transform: scale(1.1);
    border-color: #64748b;
}

.color-btn:active {
    transform: scale(0.95);
}

/* Accuracy Display */
.accuracy-display {
    text-align: center;
    font-size: 12px;
    color: var(--text-secondary);
}

/* Ready Screen */
.ready-screen {
    text-align: center;
}

.ready-screen h2 {
    font-size: 36px;
    font-weight: bold;
    margin-bottom: 24px;
}

.instructions-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    padding: 24px;
    border-radius: 8px;
    margin-bottom: 24px;
    text-align: left;
}

.instructions-card h3 {
    font-size: 18px;
    font-weight: bold;
    margin-bottom: 16px;
}

.instructions-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.instructions-list li {
    color: var(--text-secondary);
    font-size: 14px;
}

.start-btn {
    width: 100%;
    padding: 16px;
    background: linear-gradient(to right, var(--accent-purple), var(--accent-blue));
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
}

.start-btn:hover {
    background: linear-gradient(to right, #9333ea, #1d4ed8);
}

/* Game Over Screen */
.game-over-screen {
    text-align: center;
}

.game-over-screen h2 {
    font-size: 48px;
    font-weight: bold;
    margin-bottom: 24px;
}

.game-over-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    padding: 32px;
    border-radius: 8px;
    margin-bottom: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.game-over-stat {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.game-over-stat .stat-label {
    font-size: 12px;
    color: var(--text-secondary);
}

.game-over-stat .stat-value.large {
    font-size: 40px;
}

.new-high-score {
    font-size: 20px;
    font-weight: bold;
    color: var(--accent-yellow);
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

.play-again-btn {
    width: 100%;
    padding: 16px;
    background: linear-gradient(to right, var(--accent-purple), var(--accent-blue));
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
}

.play-again-btn:hover {
    background: linear-gradient(to right, #9333ea, #1d4ed8);
}

/* Leaderboard */
.leaderboard-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 16px;
}

.leaderboard-entry {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    padding: 16px;
    border-radius: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.leaderboard-rank {
    font-size: 24px;
    font-weight: bold;
    min-width: 40px;
}

.leaderboard-info {
    flex: 1;
    text-align: left;
    margin-left: 16px;
}

.leaderboard-name {
    color: var(--text-primary);
    font-weight: bold;
    margin-bottom: 4px;
}

.leaderboard-level {
    color: var(--text-secondary);
    font-size: 12px;
}

.leaderboard-stats {
    text-align: right;
}

.leaderboard-score {
    color: var(--text-primary);
    font-weight: bold;
}

.leaderboard-games {
    color: var(--text-secondary);
    font-size: 12px;
}

/* Achievements */
.achievements-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 12px;
    margin-top: 16px;
}

.achievement-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    padding: 16px;
    border-radius: 8px;
    text-align: center;
    transition: all 0.3s ease;
}

.achievement-card.locked {
    opacity: 0.5;
    background: var(--bg-tertiary);
}

.achievement-card:hover {
    transform: translateY(-4px);
    border-color: var(--accent-blue);
}

.achievement-icon {
    font-size: 32px;
    margin-bottom: 8px;
}

.achievement-name {
    color: var(--text-primary);
    font-weight: bold;
    font-size: 12px;
    margin-bottom: 4px;
}

.achievement-desc {
    color: var(--text-secondary);
    font-size: 10px;
}

/* Tab Content */
.tab-content {
    width: 100%;
}

.tab-content h2 {
    font-size: 32px;
    font-weight: bold;
    margin-bottom: 24px;
}

/* Responsive Design */
@media (max-width: 768px) {
    .header-content h1 {
        font-size: 36px;
    }

    .color-box {
        width: 120px;
        height: 120px;
    }

    .color-buttons {
        grid-template-columns: repeat(auto-fit, minmax(60px, 1fr));
        gap: 12px;
    }

    .color-btn {
        height: 60px;
    }

    .instructions-card {
        padding: 16px;
    }

    .game-over-card {
        padding: 16px;
    }

    .sidebar {
        width: 240px;
    }
}

@media (max-width: 480px) {
    .main-container {
        padding: 8px;
    }

    .header {
        margin-bottom: 16px;
    }

    .header-content h1 {
        font-size: 28px;
    }

    .header-content p {
        font-size: 12px;
    }

    .color-box {
        width: 100px;
        height: 100px;
    }

    .color-name {
        font-size: 20px;
    }

    .color-buttons {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }

    .color-btn {
        height: 50px;
    }

    .ready-screen h2 {
        font-size: 24px;
    }

    .game-over-screen h2 {
        font-size: 32px;
    }

    .sidebar {
        width: 200px;
    }
}


/* SweetAlert2 Customizations */
.swal2-popup {
    background-color: var(--bg-secondary) !important;
    color: var(--text-primary) !important;
    border-radius: 8px !important;
    border: 1px solid var(--border-color) !important;
}

.swal2-title {
    color: var(--text-primary) !important;
}

.swal2-html-container {
    color: var(--text-secondary) !important;
}

.swal-button-login {
    background: linear-gradient(to right, var(--accent-purple), var(--accent-blue)) !important;
    color: white !important;
    border: none !important;
    border-radius: 6px !important;
    font-weight: bold !important;
    padding: 10px 20px !important;
    margin: 5px !important;
    cursor: pointer !important;
    transition: opacity 0.3s ease !important;
}

.swal-button-login:hover {
    opacity: 0.9 !important;
}

.swal-button-guest {
    background: var(--bg-tertiary) !important;
    color: var(--text-primary) !important;
    border: 1px solid var(--border-color) !important;
    border-radius: 6px !important;
    font-weight: bold !important;
    padding: 10px 20px !important;
    margin: 5px !important;
    cursor: pointer !important;
    transition: all 0.3s ease !important;
}

.swal-button-guest:hover {
    background: #475569 !important;
}

.swal2-actions {
    flex-wrap: wrap;
    justify-content: center;
}

/* Leaderboard Styling */
.leaderboard-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 20px;
}

.leaderboard-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: var(--bg-tertiary);
    padding: 12px 16px;
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.2);
}

.leaderboard-item.current-user {
    border: 2px solid var(--accent-yellow);
}

.leaderboard-rank {
    font-weight: bold;
    font-size: 1.1em;
    color: var(--text-primary);
    width: 30px;
    text-align: center;
}

.leaderboard-name {
    flex-grow: 1;
    font-weight: 500;
    color: var(--text-primary);
    margin-left: 10px;
}

.leaderboard-score, .leaderboard-level {
    font-weight: bold;
    color: var(--accent-green);
    min-width: 60px;
    text-align: right;
}

.leaderboard-level {
    color: var(--accent-purple);
}

/* Sidebar Drawer Improvements */
.sidebar {
    width: 300px; /* Slightly wider for better content display */
}

.auth-section .signup-btn {
    margin-bottom: 10px; /* Add space between buttons */
}

.user-info {
    align-items: flex-start; /* Align user info to the left */
}

.user-name {
    font-size: 16px;
}

.logout-btn {
    width: 100%; /* Full width for logout button */
}

.game-stats .stat-item {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
}

.game-stats .stat-label, .game-stats .stat-value {
    margin-bottom: 0;
}

.user-stats .stat-item {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
}

.user-stats .stat-label, .user-stats .stat-value {
    margin-bottom: 0;
}

.sidebar-tabs {
    flex-direction: row; /* Make tabs horizontal */
    justify-content: space-around;
    border-top: none;
    padding-top: 0;
    margin-top: 20px;
}

.tab-btn {
    flex: 1;
    text-align: center;
    padding: 12px 0;
    margin: 0 5px;
}

.tab-btn:first-child {
    margin-left: 0;
}

.tab-btn:last-child {
    margin-right: 0;
}
