/* ==========================================================================
   AzTyping - Gamification, Live Leaderboard, Daily Challenges & Achievements
   ========================================================================== */

/* Stats & Progress View */
.stats-screen-layout { display: flex; flex-direction: column; gap: 20px; width: 100%; }
.sub-nav-card { padding: 10px 16px; background: var(--card-bg); border-radius: 16px; border: 1.5px solid rgba(110,68,255,0.1); width: 100%; }
.sub-menu { list-style: none; display: flex; flex-direction: row; gap: 8px; flex-wrap: wrap; }
.sub-item { padding: 8px 14px; border-radius: 12px; cursor: pointer; color: var(--text-muted); font-weight: 600; transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1); display: flex; align-items: center; gap: 6px; }
.sub-item:hover { background: rgba(110,68,255,0.08); color: var(--primary-purple); transform: translateY(-1px); }
.sub-item.active { background: linear-gradient(135deg, #EDE9FE, #DDD6FE); color: #5B21B6; font-weight: 700; transform: translateY(-1px); box-shadow: 0 4px 12px rgba(110, 68, 255, 0.15); }

/* Leaderboard */
.leaderboard-layout { display: flex; flex-direction: column; gap: 20px; width: 100%; }
.leaderboard-table-card { display: flex; flex-direction: column; gap: 14px; }

/* Achievements */
.achievements-screen-layout { display: flex; flex-direction: column; gap: 20px; width: 100%; }
.achievements-main-content { display: flex; flex-direction: column; gap: 16px; }

/* Settings */
.settings-screen-layout { display: flex; flex-direction: column; gap: 20px; width: 100%; }

/* Themes Customizer */
.themes-screen-layout { display: flex; flex-direction: column; gap: 20px; width: 100%; }
.stats-main-content { display: flex; flex-direction: column; gap: 20px; }
.stats-header-row { display: flex; justify-content: space-between; align-items: center; }
.date-range-badge { background: linear-gradient(135deg, #E0E7FF, #EEF2FF); color: #4338CA; padding: 7px 16px; border-radius: 14px; font-size: 0.95rem; font-weight: bold; border: 1px solid #C7D2FE; }
.overview-cards-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.stat-overview-card { display: flex; flex-direction: column; gap: 8px; padding: 18px; border: 1.5px solid rgba(110,68,255,0.1); border-radius: 18px; transition: transform 0.2s, box-shadow 0.2s; }
.stat-overview-card:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(110,68,255,0.1); }
.val-row { display: flex; align-items: baseline; justify-content: space-between; }
.badge-up { color: #16A34A; background: #DCFCE7; font-size: 0.8rem; padding: 3px 8px; border-radius: 8px; font-weight: bold; }
.stats-graphs-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.full-chart-svg { width: 100%; height: 140px; }
.summary-metrics-bar { display: flex; justify-content: space-around; align-items: center; position: relative; padding: 22px; border: 1.5px solid rgba(110,68,255,0.1); border-radius: 18px; }
.summary-sticky { position: absolute; right: 20px; top: -15px; transform: rotate(4deg); padding: 8px 16px; font-weight: bold; }

/* History Table Styling */
.stats-table-wrapper { width: 100%; overflow-x: auto; }
.stats-history-table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 0.92rem; }
.stats-history-table th { background: rgba(110,68,255,0.06); color: var(--text-muted); font-weight: 700; text-align: left; padding: 10px 14px; text-transform: uppercase; font-size: 0.75rem; letter-spacing: 0.05em; border-bottom: 1.5px solid rgba(110,68,255,0.12); }
.stats-history-table th:first-child { border-top-left-radius: 10px; border-bottom-left-radius: 10px; }
.stats-history-table th:last-child { border-top-right-radius: 10px; border-bottom-right-radius: 10px; }
.stats-history-table td { padding: 12px 14px; border-bottom: 1px solid rgba(0,0,0,0.05); color: var(--text-main); font-weight: 500; }
.stats-history-table tr:last-child td { border-bottom: none; }
.stats-history-table tr:hover td { background: rgba(110,68,255,0.03); }
.table-mode-badge { display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: 20px; font-size: 0.8rem; font-weight: 700; background: rgba(110,68,255,0.08); color: var(--primary-purple); }
.table-wpm-val { font-weight: 800; font-family: 'JetBrains Mono', monospace; color: var(--primary-purple); }
.table-acc-val { font-weight: 700; font-family: 'JetBrains Mono', monospace; color: #22C55E; }
.table-raw-val { font-family: 'JetBrains Mono', monospace; color: var(--text-muted); }

/* Games Hub Detailed Styling */
.games-hub-detailed-layout { display: flex; flex-direction: column; gap: 24px; }
.games-detailed-header { display: flex; align-items: center; justify-content: space-between; position: relative; padding: 8px 0; }
.g-header-title { display: flex; align-items: center; gap: 16px; }
.back-btn { background: transparent; border: none; cursor: pointer; color: var(--text-main); transition: transform 0.2s ease; }
.back-btn:hover { transform: translateX(-4px); }
.gamepad-mini-doodle { vertical-align: middle; margin-left: 8px; transform: rotate(10deg); }

.games-filter-tabs { display: flex; gap: 8px; background: rgba(110,68,255,0.06); padding: 6px; border-radius: 16px; border: 1.5px solid rgba(110,68,255,0.1); }
.filter-tab { background: transparent; border: none; padding: 8px 18px; border-radius: 12px; font-weight: 700; color: var(--text-muted); cursor: pointer; transition: all 0.2s ease; }
.filter-tab:hover { color: var(--primary-purple); background: rgba(110,68,255,0.08); }
.filter-tab.active { background: linear-gradient(135deg, #6E44FF, #8B5CF6); color: #FFF; box-shadow: 0 4px 14px rgba(110,68,255,0.3); }

.games-header-sticky { display: none; }

.dgc-desc { font-family: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif !important; font-size: 0.88rem; font-weight: 500; color: var(--text-muted); line-height: 1.4; }


/* ====================================================== */
/* FEATURE 1: LEADERBOARD MODE FILTER TABS                */
/* ====================================================== */
.leader-mode-tab {
    padding: 5px 14px;
    border: 1.5px solid rgba(110,68,255,0.25);
    border-radius: 20px;
    background: transparent;
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
}
.leader-mode-tab:hover {
    border-color: #6E44FF;
    color: #6E44FF;
    background: rgba(110,68,255,0.07);
}
.leader-mode-tab.active {
    background: #6E44FF;
    border-color: #6E44FF;
    color: #fff;
    box-shadow: 0 3px 10px rgba(110,68,255,0.35);
}


/* ============================================================
   PHASE 2 — LIVE LEADERBOARD STYLES
   ============================================================ */
.lb-header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 16px;
}
.lb-mode-filters {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}
.lb-filter-btn {
    padding: 5px 12px;
    border: 1.5px solid var(--input-border, #CBD5E1);
    border-radius: 20px;
    background: transparent;
    font-size: 0.78rem;
    font-weight: 700;
    font-family: 'Outfit', sans-serif;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.18s ease;
}
.lb-filter-btn:hover {
    border-color: var(--primary-purple, #6E44FF);
    color: var(--primary-purple, #6E44FF);
}
.lb-filter-btn.active {
    background: var(--primary-purple, #6E44FF);
    border-color: var(--primary-purple, #6E44FF);
    color: #fff;
    box-shadow: 0 3px 10px rgba(110,68,255,0.3);
}

.lb-loading-bar { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
.lb-loading-bar.hidden { display: none; }
.lb-skeleton-row {
    height: 42px;
    border-radius: 10px;
    background: linear-gradient(90deg, rgba(110,68,255,0.06) 0%, rgba(110,68,255,0.12) 50%, rgba(110,68,255,0.06) 100%);
    background-size: 200% 100%;
    animation: skeletonShimmer 1.5s infinite linear;
}
@keyframes skeletonShimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}
.lb-empty-state {
    text-align: center;
    padding: 24px;
    color: var(--text-muted);
    font-size: 0.9rem;
    font-weight: 600;
}


/* ============================================================
   PHASE 5 — DAILY CHALLENGE CARD
   ============================================================ */
.daily-challenge-card {
    display: flex;
    gap: 20px;
    align-items: stretch;
    background: linear-gradient(135deg, rgba(110,68,255,0.04), rgba(59,130,246,0.04));
    border: 1.5px solid rgba(110,68,255,0.18);
    border-radius: 18px;
    padding: 20px 22px;
    margin-bottom: 0;
    animation: fadeSlideIn 0.5s ease both;
}
@keyframes fadeSlideIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.dc-left {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.dc-right {
    width: 230px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
    border-left: 1.5px solid var(--card-border, #E2E8F0);
    padding-left: 20px;
}
.dc-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: linear-gradient(135deg, var(--primary-purple,#6E44FF), #5B21B6);
    color: #fff;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.78rem;
    font-weight: 800;
    letter-spacing: 0.3px;
    width: fit-content;
}
.dc-passage-preview {
    font-size: 0.9rem;
    line-height: 1.55;
    color: var(--text-main);
    font-style: italic;
    max-width: 480px;
    flex: 1;
}
.dc-play-btn { width: fit-content; font-size: 0.88rem; padding: 9px 20px; }

.dc-lb-title {
    font-size: 0.88rem;
    font-weight: 800;
    color: var(--text-main);
    margin: 0;
}
.dc-leaderboard { display: flex; flex-direction: column; gap: 5px; }
.dc-lb-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.8rem;
    padding: 4px 0;
    border-bottom: 1px dashed var(--card-border, #E2E8F0);
}
.dc-lb-row:last-child { border-bottom: none; }
.dc-lb-rank { font-weight: 800; color: var(--text-muted); width: 22px; }
.dc-lb-name { font-weight: 700; flex: 1; color: var(--text-main); }
.dc-lb-wpm { font-weight: 800; color: var(--primary-purple, #6E44FF); }
.dc-lb-empty { color: var(--text-muted); font-style: italic; font-size: 0.78rem; justify-content: center; }

@media (max-width: 680px) {
    .daily-challenge-card { flex-direction: column; }
    .dc-right { width: 100%; border-left: none; border-top: 1.5px solid var(--card-border, #E2E8F0); padding-left: 0; padding-top: 14px; }
}


/* ============================================================
   PHASE 6 — ACHIEVEMENT UNLOCK TOAST
   ============================================================ */
.achievement-toast {
    position: fixed;
    bottom: 28px;
    right: 28px;
    z-index: 99999;
    animation: achToastIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) both;
    min-width: 280px;
    max-width: 340px;
}
.achievement-toast.hidden { display: none !important; }
@keyframes achToastIn {
    from { opacity: 0; transform: translateX(60px) scale(0.9); }
    to   { opacity: 1; transform: translateX(0) scale(1); }
}
@keyframes achToastOut {
    from { opacity: 1; transform: translateX(0); }
    to   { opacity: 0; transform: translateX(80px); }
}
.achievement-toast.hiding { animation: achToastOut 0.3s ease both; }

.ach-toast-inner {
    display: flex;
    align-items: center;
    gap: 14px;
    background: var(--card-bg, #fff);
    border: 2px solid rgba(110,68,255,0.25);
    border-radius: 16px;
    padding: 14px 16px;
    box-shadow: 0 20px 50px -10px rgba(0,0,0,0.25), 0 0 0 1px rgba(110,68,255,0.08);
    backdrop-filter: blur(12px);
}
.ach-toast-icon {
    font-size: 2rem;
    width: 48px;
    height: 48px;
    border-radius: 12px;
    background: linear-gradient(135deg, rgba(110,68,255,0.12), rgba(110,68,255,0.06));
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.ach-toast-body { flex: 1; }
.ach-toast-label {
    font-size: 0.7rem;
    font-weight: 800;
    color: var(--primary-purple, #6E44FF);
    text-transform: uppercase;
    letter-spacing: 0.8px;
    margin-bottom: 2px;
    font-family: 'Outfit', sans-serif;
}
.ach-toast-name {
    font-size: 0.95rem;
    font-weight: 800;
    color: var(--text-main);
    margin-bottom: 2px;
}
.ach-toast-xp {
    font-size: 0.8rem;
    font-weight: 700;
    color: #22C55E;
}
.ach-toast-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 0.9rem;
    cursor: pointer;
    padding: 4px;
    border-radius: 50%;
    line-height: 1;
    transition: background 0.15s;
    align-self: flex-start;
}
.ach-toast-close:hover { background: rgba(0,0,0,0.08); }
