/**
 * Time Attack Game Mode
 * Styles for Time Attack mode including timer, difficulty selection, leaderboard, and results
 */

/* ===================================== */
/* TIME ATTACK BANNER (Home Page)        */
/* ===================================== */

.time-attack-banner {
    background: rgba(254, 243, 199, 0.5);
    border-radius: 20px;
    padding: 30px;
    color: #2d2748;
    margin-bottom: 30px;
    box-shadow: 0 8px 32px rgba(245, 158, 11, 0.2);
    position: relative;
    overflow: hidden;
    border: 2px solid rgba(245, 158, 11, 0.3);
}

.time-attack-banner::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.1) 0%, transparent 70%);
    animation: pulse-slow 4s ease-in-out infinite;
}

.time-attack-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    position: relative;
    z-index: 1;
}

.time-attack-header h2 {
    color: #2d2748;
    margin: 0;
}

.time-attack-badge {
    background: rgba(245, 158, 11, 0.15);
    border: 2px solid rgba(245, 158, 11, 0.5);
    padding: 6px 14px;
    border-radius: 20px;
    font-weight: bold;
    font-size: 0.85em;
    color: #ea580c;
    backdrop-filter: blur(10px);
}

.time-attack-description {
    font-size: 1em;
    line-height: 1.6;
    margin-bottom: 0;
    position: relative;
    z-index: 1;
    color: #2d2748;
    opacity: 0.85;
}

.time-attack-banner .banner-actions {
    position: relative;
    z-index: 1;
}

.time-attack-btn {
    background: var(--primary-color) !important;
}

.time-attack-btn:hover {
    background: var(--primary-dark) !important;
}

.time-attack-difficulty-select {
    display: flex;
    gap: 12px;
    position: relative;
    z-index: 1;
}

.ta-difficulty-btn {
    flex: 1;
    padding: 12px 16px;
    border: none;
    background: #f59e0b;
    border-radius: 10px;
    color: white;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.3);
}

.ta-difficulty-btn:hover {
    background: #d97706;
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(245, 158, 11, 0.4);
}

.ta-difficulty-name {
    font-size: 0.95em;
    letter-spacing: 0.5px;
}

.ta-leaderboard-btn {
    width: 100%;
    padding: 15px;
    margin-top: 15px;
    background: #f59e0b;
    border: none;
    border-radius: 15px;
    color: white;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    z-index: 1;
    box-shadow: 0 4px 15px rgba(245, 158, 11, 0.3);
}

.ta-leaderboard-btn:hover {
    background: #d97706;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(245, 158, 11, 0.4);
}

/* ===================================== */
/* TIME ATTACK BANNER (In-Game)          */
/* ===================================== */

#time-attack-banner {
    background: rgba(231, 76, 60, 0.15);
    border: 2px solid rgba(231, 76, 60, 0.3);
    border-radius: 20px;
    padding: 25px;
    margin-bottom: 20px;
    text-align: center;
    animation: pulse 2s infinite;
    box-shadow: 0 6px 20px rgba(231, 76, 60, 0.2);
}

#time-attack-banner h2 {
    margin: 0 0 8px 0;
    font-size: 28px;
    background: #e74c3c;
}

#time-attack-banner p {
    margin: 0;
    font-size: 15px;
    color: var(--text-color);
    opacity: 0.9;
}

/* ===================================== */
/* DIFFICULTY SELECTION                  */
/* ===================================== */

#time-attack-difficulty-selection {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin-top: 20px;
    flex-wrap: wrap;
}

.time-attack-difficulty-btn {
    flex: 1;
    min-width: 140px;
    max-width: 200px;
    padding: 18px 25px;
    border-radius: 15px;
    border: 3px solid transparent;
    font-size: 17px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.time-attack-difficulty-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
}

#time-attack-easy-btn {
    background: #27ae60;
    color: white;
}

#time-attack-easy-btn:hover {
    background: #229954;
}

#time-attack-medium-btn {
    background: #f39c12;
    color: white;
}

#time-attack-medium-btn:hover {
    background: #e67e22;
}

#time-attack-hard-btn {
    background: #e74c3c;
    color: white;
}

#time-attack-hard-btn:hover {
    background: #c0392b;
}

/* ===================================== */
/* TIMER DISPLAY                         */
/* ===================================== */

#time-attack-timer-container {
    width: 120px;
    height: 120px;
    position: relative;
    margin: 20px auto;
}

.time-attack-timer-svg {
    transform: rotate(-90deg);
}

.time-attack-timer-background {
    fill: none;
    stroke: #e0e0e0;
    stroke-width: 10;
}

.time-attack-timer-progress {
    fill: none;
    stroke: #e74c3c;
    stroke-width: 10;
    stroke-linecap: round;
    transition: stroke-dashoffset 1s linear, stroke 0.3s ease;
}

.time-attack-timer-progress.warning {
    stroke: #f39c12;
    animation: pulse-fast 1s infinite;
}

.time-attack-timer-progress.critical {
    stroke: #c0392b;
    animation: pulse-fast 0.5s infinite;
}

.time-attack-timer-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 28px;
    font-weight: bold;
    color: #e74c3c;
}

.time-attack-timer-text.warning {
    color: #f39c12;
}

.time-attack-timer-text.critical {
    color: #c0392b;
    animation: flicker 0.3s infinite;
}

/* ===================================== */
/* TIME ATTACK GAME PAGE LAYOUT          */
/* ===================================== */

#time-attack-page {
    flex: 1;
    /* Take remaining space in game-container */
    min-height: 0;
    /* Allow flexbox to shrink below content size */
    overflow: visible;
    /* Allow scrolling when zoomed */
}

/* Game input section - fixed size */
#time-attack-page .section:nth-child(1) {
    flex-shrink: 0;
    /* Don't shrink input section */
    flex-grow: 0;
    /* Don't grow */
}

/* Guess history section - fills remaining space and scrolls internally */
#time-attack-page .section:nth-child(2) {
    display: flex;
    flex-direction: column;
    background: rgba(243, 156, 18, 0.03);
    border: 1px solid rgba(13, 148, 136, 0.15);
    flex: 1;
    /* Take all remaining space */
    min-height: 150px;
    /* Reduced to ensure quit button fits */
    overflow: hidden;
}

#time-attack-page .section:nth-child(2) h2 {
    margin-bottom: 15px;
    font-size: 1.1em;
    color: var(--primary-color);
    flex-shrink: 0;
}

#time-attack-page .section:nth-child(2) #ta-guess-history {
    flex: 1;
    min-height: 0;
    /* IMPORTANT: Allow flex to constrain height */
    overflow-y: auto;
    overflow-x: hidden;
    background: rgba(255, 255, 255, 0.4);
    border: 1px solid rgba(13, 148, 136, 0.1);
    border-radius: 10px;
    padding: 10px;
}

/* Custom scrollbar for guess history */
#time-attack-page .section:nth-child(2) #ta-guess-history::-webkit-scrollbar {
    width: 8px;
}

#time-attack-page .section:nth-child(2) #ta-guess-history::-webkit-scrollbar-track {
    background: rgba(13, 148, 136, 0.1);
    border-radius: 4px;
}

#time-attack-page .section:nth-child(2) #ta-guess-history::-webkit-scrollbar-thumb {
    background: rgba(var(--primary-color-rgb), 0.4);
    border-radius: 4px;
}

#time-attack-page .section:nth-child(2) #ta-guess-history::-webkit-scrollbar-thumb:hover {
    background: rgba(var(--primary-color-rgb), 0.6);
}

body.dark-mode #time-attack-page .section:nth-child(2) #ta-guess-history {
    background: rgba(0, 0, 0, 0.2);
}

body.dark-mode #time-attack-page .section:nth-child(2) #ta-guess-history::-webkit-scrollbar-thumb {
    background: rgba(96, 197, 242, 0.3);
}

body.dark-mode #time-attack-page .section:nth-child(2) #ta-guess-history::-webkit-scrollbar-thumb:hover {
    background: rgba(96, 197, 242, 0.5);
}

/* Dark mode enhancements */
body.dark-mode #time-attack-page .section:nth-child(1) {
    background: rgba(13, 148, 136, 0.08);
    border: 2px solid rgba(13, 148, 136, 0.3);
}

body.dark-mode #time-attack-page .section:nth-child(2) {
    background: rgba(243, 156, 18, 0.06);
    border: 1px solid rgba(13, 148, 136, 0.25);
}

/* Quit button */
#time-attack-page button#quit-time-attack {
    margin-top: 8px;
    margin-bottom: 0;
    flex-shrink: 0;
    /* Don't let it shrink */
    flex-grow: 0;
    /* Don't let it grow */
}

/* ===================================== */
/* TIME ATTACK STATS                     */
/* ===================================== */

#time-attack-stats {
    display: flex;
    justify-content: space-around;
    margin: 20px 0;
    gap: 15px;
    flex-wrap: wrap;
}

.time-attack-stat {
    text-align: center;
    flex: 1;
    min-width: 120px;
    padding: 12px;
    background: rgba(231, 76, 60, 0.1);
    border-radius: 12px;
    border: 2px solid rgba(231, 76, 60, 0.2);
}

.time-attack-stat-label {
    font-size: 13px;
    color: var(--text-color);
    opacity: 0.8;
    margin-bottom: 5px;
    font-weight: 600;
}

.time-attack-stat-value {
    font-size: 24px;
    font-weight: 700;
    color: #e74c3c;
}

/* ===================================== */
/* LEADERBOARD MODAL HEADER              */
/* ===================================== */

.ta-leaderboard-modal-header {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 25px;
    margin: -25px -25px 25px -25px;
    background: var(--primary-color);
    border-radius: 28px 28px 0 0;
    position: relative;
    overflow: hidden;
}

.ta-leaderboard-modal-header::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -20%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.15) 0%, transparent 70%);
    animation: pulse-slow 4s ease-in-out infinite;
}

.ta-leaderboard-icon {
    width: 70px;
    height: 70px;
    background: rgba(255, 215, 0, 0.3);
    border-radius: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 36px;
    color: #FFD700;
    flex-shrink: 0;
    position: relative;
    z-index: 1;
    backdrop-filter: blur(10px);
    border: 2px solid rgba(255, 215, 0, 0.5);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3), 0 0 30px rgba(255, 215, 0, 0.3);
    filter: drop-shadow(0 0 10px rgba(255, 215, 0, 0.4));
}

.ta-leaderboard-title-section {
    flex: 1;
    position: relative;
    z-index: 1;
}

.ta-leaderboard-title {
    margin: 0;
    font-size: 30px;
    font-weight: 800;
    color: #ffffff;
    text-shadow: none;
    filter: drop-shadow(0 3px 8px rgba(0, 0, 0, 0.5));
    letter-spacing: 1px;
    text-transform: uppercase;
}

.ta-leaderboard-subtitle {
    margin: 8px 0 0 0;
    font-size: 15px;
    color: #FFF9E6;
    font-weight: 600;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

/* ===================================== */
/* LEADERBOARD GRID (Div-based)          */
/* ===================================== */

.leaderboard-table {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 10px;
}

.leaderboard-header,
.leaderboard-row {
    display: grid;
    grid-template-columns: 70px 150px 90px 90px;
    gap: 15px;
    padding: 12px 20px;
    align-items: center;
}

.leaderboard-header {
    background: var(--primary-color);
    color: white;
    font-weight: 700;
    border-radius: 10px;
    font-size: 0.9em;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    box-shadow: 0 2px 8px rgba(var(--primary-color-rgb), 0.3);
    position: sticky;
    top: 0;
    z-index: 10;
    margin-bottom: 2px;
}

/* Header text must be WHITE on purple gradient */
.leaderboard-header .lb-rank,
.leaderboard-header .lb-username,
.leaderboard-header .lb-wins,
.leaderboard-header .lb-avg {
    color: #ffffff !important;
}

/* Header column alignment - must match row alignment */
.leaderboard-header .lb-rank {
    text-align: center;
    font-size: 0.9em;
}

.leaderboard-header .lb-username {
    text-align: left;
}

.leaderboard-header .lb-wins {
    text-align: center;
}

.leaderboard-header .lb-avg {
    text-align: center;
}

.leaderboard-row {
    background: rgba(255, 255, 255, 0.7);
    border: 1px solid rgba(var(--primary-color-rgb), 0.1);
    border-radius: 8px;
    transition: all 0.3s ease;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.leaderboard-row:hover {
    transform: translateX(3px);
    box-shadow: 0 4px 12px rgba(var(--primary-color-rgb), 0.15);
    background: rgba(255, 255, 255, 0.9);
    border-color: rgba(var(--primary-color-rgb), 0.2);
}

.leaderboard-row.top-1 {
    background: rgba(255, 215, 0, 0.25);
    border: 2px solid rgba(255, 215, 0, 0.5);
    border-left: 4px solid #ffd700;
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(255, 215, 0, 0.2);
}

.leaderboard-row.top-2 {
    background: rgba(192, 192, 192, 0.25);
    border: 2px solid rgba(192, 192, 192, 0.5);
    border-left: 4px solid #c0c0c0;
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(192, 192, 192, 0.2);
}

.leaderboard-row.top-3 {
    background: rgba(205, 127, 50, 0.25);
    border: 2px solid rgba(205, 127, 50, 0.5);
    border-left: 4px solid #cd7f32;
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(205, 127, 50, 0.2);
}

/* Highlight current user's row */
.leaderboard-row.current-user {
    background: rgba(13, 148, 136, 0.25) !important;
    border: 2px solid rgba(13, 148, 136, 0.5) !important;
    border-left: 4px solid rgba(13, 148, 136, 0.8) !important;
    font-weight: 600;
    box-shadow: 0 3px 12px rgba(13, 148, 136, 0.3) !important;
}

/* Row text colors (for light backgrounds) */
.leaderboard-row .lb-rank {
    font-weight: 700;
    text-align: center;
    color: #6b5a9f;
    font-size: 1.2em;
}

.leaderboard-row .lb-username {
    font-weight: 600;
    text-align: left;
    color: #2d2748;
}

.leaderboard-row .lb-wins,
.leaderboard-row .lb-avg {
    text-align: center;
    font-size: 0.95em;
    color: #5a4d73;
    font-weight: 500;
}

/* Scrollable Container - Fixed height for 5 rows */
#ta-leaderboard-container {
    height: 400px;
    overflow: hidden;
}

#ta-leaderboard-content {
    height: 400px;
    overflow-y: auto;
    overflow-x: hidden;
    /* Hide scrollbar but keep functionality */
    scrollbar-width: none;
    /* Firefox */
    -ms-overflow-style: none;
    /* IE and Edge */
}

#ta-leaderboard-content::-webkit-scrollbar {
    display: none;
    /* Chrome, Safari, Opera */
}

/* Loading and Empty States */
#ta-leaderboard-loading,
#modal-daily-leaderboard-loading {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-secondary);
    font-size: 1em;
}

/* Empty state for leaderboards */
#ta-leaderboard-content .no-data,
#modal-daily-leaderboard-content .no-data {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-secondary);
    font-size: 1em;
    background: rgba(var(--primary-color-rgb), 0.05);
    border-radius: 10px;
    border: 2px dashed rgba(var(--primary-color-rgb), 0.2);
}

#ta-leaderboard-content .error-message,
#modal-daily-leaderboard-content .error-message {
    text-align: center;
    padding: 40px 20px;
    color: var(--danger-color);
    font-size: 1em;
    background: rgba(231, 76, 60, 0.1);
    border-radius: 10px;
    border: 2px solid rgba(231, 76, 60, 0.3);
}

/* ===================================== */
/* LEADERBOARD TABS                      */
/* ===================================== */

.leaderboard-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
    padding: 5px;
    background: rgba(var(--primary-color-rgb), 0.05);
    border-radius: 12px;
}

.lb-tab {
    flex: 1;
    padding: 12px 20px;
    background: transparent;
    border: none;
    border-radius: 8px;
    color: var(--text-color);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    opacity: 0.7;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.lb-tab:hover {
    opacity: 1;
    background: rgba(var(--primary-color-rgb), 0.1);
    transform: translateY(-1px);
}

.lb-tab.active {
    opacity: 1;
    background: var(--primary-color);
    color: white;
    box-shadow: 0 2px 8px rgba(var(--primary-color-rgb), 0.3);
}

/* Remove old tab styles */
.time-attack-leaderboard-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    border-bottom: 2px solid rgba(var(--primary-color-rgb), 0.2);
}

.time-attack-tab {
    flex: 1;
    padding: 12px 20px;
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    color: var(--text-color);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    opacity: 0.6;
}

.time-attack-tab:hover {
    opacity: 0.9;
    background: rgba(var(--primary-color-rgb), 0.05);
}

.time-attack-tab.active {
    opacity: 1;
    border-bottom-color: var(--primary-color);
    background: rgba(var(--primary-color-rgb), 0.1);
}

/* ===================================== */
/* LEADERBOARD TABLE                     */
/* ===================================== */

.time-attack-leaderboard-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0 8px;
    margin-top: 10px;
}

.time-attack-leaderboard-table thead th {
    text-align: left;
    padding: 12px 15px;
    font-weight: 700;
    font-size: 14px;
    color: var(--text-color);
    opacity: 0.8;
    border-bottom: 2px solid rgba(var(--primary-color-rgb), 0.2);
}

.time-attack-leaderboard-table tbody tr {
    background: rgba(255, 255, 255, 0.6);
    transition: all 0.2s ease;
}

.time-attack-leaderboard-table tbody tr:hover {
    transform: translateX(3px);
    box-shadow: 0 2px 8px rgba(13, 148, 136, 0.15);
}

.time-attack-leaderboard-table tbody td {
    padding: 12px 15px;
    border-top: 1px solid rgba(13, 148, 136, 0.1);
    border-bottom: 1px solid rgba(13, 148, 136, 0.1);
}

.time-attack-leaderboard-table tbody td:first-child {
    border-left: 1px solid rgba(13, 148, 136, 0.1);
    border-radius: 10px 0 0 10px;
}

.time-attack-leaderboard-table tbody td:last-child {
    border-right: 1px solid rgba(13, 148, 136, 0.1);
    border-radius: 0 10px 10px 0;
}

/* Top 3 ranks styling */
.time-attack-leaderboard-table tbody tr.rank-1 {
    background: rgba(255, 215, 0, 0.2);
    border-left: 4px solid #FFD700;
}

.time-attack-leaderboard-table tbody tr.rank-2 {
    background: rgba(192, 192, 192, 0.2);
    border-left: 4px solid #C0C0C0;
}

.time-attack-leaderboard-table tbody tr.rank-3 {
    background: rgba(205, 127, 50, 0.2);
    border-left: 4px solid #CD7F32;
}

.time-attack-rank {
    font-weight: 700;
    font-size: 16px;
}

.time-attack-player-name {
    font-weight: 600;
    color: var(--primary-color);
}

.time-attack-score {
    font-weight: 700;
    font-size: 18px;
    color: #e74c3c;
}

/* ===================================== */
/* TIME ATTACK RESULTS PAGE              */
/* ===================================== */

#time-attack-result-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin: 30px 0;
}

.time-attack-result-stat {
    text-align: center;
    padding: 20px;
    background: rgba(231, 76, 60, 0.1);
    border-radius: 15px;
    border: 2px solid rgba(231, 76, 60, 0.2);
    transition: all 0.3s ease;
}

.time-attack-result-stat:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(231, 76, 60, 0.2);
}

.time-attack-result-stat-icon {
    font-size: 36px;
    margin-bottom: 10px;
}

.time-attack-result-stat-label {
    font-size: 14px;
    color: var(--text-color);
    opacity: 0.8;
    margin-bottom: 8px;
    font-weight: 600;
}

.time-attack-result-stat-value {
    font-size: 32px;
    font-weight: 700;
    color: #e74c3c;
}

#time-attack-result-message {
    text-align: center;
    font-size: 20px;
    color: var(--text-color);
    margin: 20px 0;
    line-height: 1.6;
}

/* ===================================== */
/* DARK MODE                             */
/* ===================================== */

body.dark-mode .time-attack-banner {
    background: rgba(245, 158, 11, 0.2);
    border-color: rgba(245, 158, 11, 0.4);
}

body.dark-mode .time-attack-header h2 {
    color: #ffffff;
}

body.dark-mode .time-attack-description {
    color: #e0d8f0;
    opacity: 0.85;
}

body.dark-mode .time-attack-badge {
    color: #fcd34d;
    background: rgba(245, 158, 11, 0.2);
    border-color: rgba(245, 158, 11, 0.6);
}

body.dark-mode .ta-difficulty-btn {
    background: #f59e0b;
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.4);
}

body.dark-mode .ta-difficulty-btn:hover {
    background: #d97706;
    box-shadow: 0 6px 16px rgba(245, 158, 11, 0.5);
}

body.dark-mode .time-attack-btn {
    background: #f59e0b;
    box-shadow: 0 4px 15px rgba(245, 158, 11, 0.3);
}

body.dark-mode .time-attack-btn:hover {
    background: #d97706;
    box-shadow: 0 6px 20px rgba(245, 158, 11, 0.4);
}

body.dark-mode .time-attack-leaderboard-table tbody tr {
    background: rgba(255, 255, 255, 0.05);
}

body.dark-mode .time-attack-leaderboard-table tbody tr:hover {
    background: rgba(255, 255, 255, 0.08);
}

body.dark-mode .time-attack-stat {
    background: rgba(231, 76, 60, 0.15);
    border-color: rgba(231, 76, 60, 0.3);
}

body.dark-mode .time-attack-result-stat {
    background: rgba(231, 76, 60, 0.15);
    border-color: rgba(231, 76, 60, 0.3);
}

body.dark-mode .leaderboard-header {
    background: rgba(var(--primary-color-rgb), 0.3);
    border: 1px solid rgba(var(--primary-color-rgb), 0.4);
    box-shadow: 0 2px 8px rgba(var(--primary-color-rgb), 0.2);
}

/* Dark mode - Header text stays WHITE */
body.dark-mode .leaderboard-header .lb-rank,
body.dark-mode .leaderboard-header .lb-username,
body.dark-mode .leaderboard-header .lb-wins,
body.dark-mode .leaderboard-header .lb-avg {
    color: #ffffff !important;
}

body.dark-mode .leaderboard-row {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(13, 148, 136, 0.15);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

body.dark-mode .leaderboard-row:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(13, 148, 136, 0.3);
    box-shadow: 0 4px 12px rgba(13, 148, 136, 0.15);
}

body.dark-mode .leaderboard-row.top-1 {
    background: rgba(255, 215, 0, 0.15);
    border: 2px solid rgba(255, 215, 0, 0.4);
    border-left: 4px solid rgba(255, 215, 0, 0.8);
    box-shadow: 0 2px 8px rgba(255, 215, 0, 0.15);
}

body.dark-mode .leaderboard-row.top-2 {
    background: rgba(192, 192, 192, 0.15);
    border: 2px solid rgba(192, 192, 192, 0.4);
    border-left: 4px solid rgba(192, 192, 192, 0.8);
    box-shadow: 0 2px 8px rgba(192, 192, 192, 0.15);
}

body.dark-mode .leaderboard-row.top-3 {
    background: rgba(205, 127, 50, 0.15);
    border: 2px solid rgba(205, 127, 50, 0.4);
    border-left: 4px solid rgba(205, 127, 50, 0.8);
    box-shadow: 0 2px 8px rgba(205, 127, 50, 0.15);
}

/* Dark mode - Row text colors (bright on dark background) */
body.dark-mode .leaderboard-row .lb-rank {
    color: var(--primary-color);
    font-size: 1.2em;
}

body.dark-mode .leaderboard-row .lb-username {
    color: #e4e7f0;
}

body.dark-mode .leaderboard-row .lb-wins,
body.dark-mode .leaderboard-row .lb-avg {
    color: #a0a8c8;
}

body.dark-mode .leaderboard-row.current-user {
    background: rgba(13, 148, 136, 0.15) !important;
    border: 2px solid rgba(13, 148, 136, 0.4) !important;
    border-left: 4px solid rgba(13, 148, 136, 0.8) !important;
    box-shadow: 0 2px 8px rgba(13, 148, 136, 0.15) !important;
}

body.dark-mode .leaderboard-tabs {
    background: rgba(255, 255, 255, 0.05);
}

body.dark-mode .lb-tab:hover {
    background: rgba(255, 255, 255, 0.08);
}

body.dark-mode .lb-tab.active {
    background: rgba(var(--primary-color-rgb), 0.8);
    color: white;
}

body.dark-mode .ta-leaderboard-modal-header {
    background: var(--primary-color);
}

body.dark-mode .ta-leaderboard-icon {
    background: rgba(255, 215, 0, 0.25);
    border-color: rgba(255, 215, 0, 0.4);
    color: #FFD700;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4), 0 0 35px rgba(255, 215, 0, 0.4);
}

/* ===================================== */
/* RESPONSIVE                            */
/* ===================================== */

@media screen and (max-width: 768px) {
    .time-attack-banner {
        padding: 25px;
    }

    .ta-difficulty-btn {
        padding: 12px 14px;
    }

    .ta-difficulty-name {
        font-size: 0.9em;
    }

    #time-attack-banner h2 {
        font-size: 24px;
    }

    #time-attack-banner p {
        font-size: 14px;
    }

    .time-attack-difficulty-btn {
        min-width: 120px;
        padding: 15px 20px;
        font-size: 15px;
    }

    #time-attack-timer-container {
        width: 100px;
        height: 100px;
    }

    .time-attack-timer-text {
        font-size: 24px;
    }

    #time-attack-stats {
        gap: 10px;
    }

    .time-attack-stat {
        min-width: 100px;
        padding: 10px;
    }

    .time-attack-stat-value {
        font-size: 20px;
    }

    .time-attack-leaderboard-table thead th {
        padding: 10px 12px;
        font-size: 13px;
    }

    .time-attack-leaderboard-table tbody td {
        padding: 10px 12px;
        font-size: 14px;
    }

    #time-attack-result-stats {
        grid-template-columns: 1fr;
        gap: 15px;
    }

    .leaderboard-header,
    .leaderboard-row {
        grid-template-columns: 50px 1fr 65px 65px;
        gap: 8px;
        font-size: 0.8em;
        padding: 10px 12px;
    }

    .ta-leaderboard-modal-header {
        padding: 20px;
        margin: -20px -20px 20px -20px;
        gap: 15px;
    }

    .ta-leaderboard-icon {
        width: 60px;
        height: 60px;
        font-size: 28px;
    }

    .ta-leaderboard-title {
        font-size: 24px;
    }

    .ta-leaderboard-subtitle {
        font-size: 14px;
    }
}

@media screen and (max-width: 480px) {
    #time-attack-banner {
        padding: 20px;
    }

    #time-attack-difficulty-selection {
        flex-direction: column;
        gap: 10px;
    }

    .time-attack-difficulty-btn {
        max-width: 100%;
    }

    #time-attack-timer-container {
        width: 90px;
        height: 90px;
    }

    .time-attack-timer-text {
        font-size: 20px;
    }

    .time-attack-tab {
        padding: 10px 15px;
        font-size: 14px;
    }

    .time-attack-result-stat-value {
        font-size: 28px;
    }

    #time-attack-result-message {
        font-size: 18px;
    }

    .leaderboard-header,
    .leaderboard-row {
        grid-template-columns: 45px 1fr 55px 55px;
        gap: 6px;
        font-size: 0.75em;
        padding: 8px 10px;
    }

    .lb-rank {
        font-size: 1em !important;
    }

    .lb-username {
        font-size: 0.95em;
    }

    .lb-wins,
    .lb-avg {
        font-size: 0.9em;
    }

    .lb-tab {
        padding: 10px 15px;
        font-size: 14px;
    }

    .ta-leaderboard-modal-header {
        padding: 15px;
        margin: -15px -15px 15px -15px;
        gap: 12px;
    }

    .ta-leaderboard-icon {
        width: 55px;
        height: 55px;
        font-size: 26px;
        border-radius: 14px;
    }

    .ta-leaderboard-title {
        font-size: 20px;
    }

    .ta-leaderboard-subtitle {
        font-size: 13px;
    }
}