/* ─── TOP BAR ─────────────────────────────────────────────────────────────── */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #ffffff;
    border-bottom: 2px solid #c7d2fe;
    height: 68px;
    padding: 0 20px;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 200;
    box-shadow: 0 2px 14px rgba(0,0,0,0.07)
}

.topbar-sep {
    width: 1px;
    height: 34px;
    background: #e2e8f0;
    flex-shrink: 0
}


/* ─── Home button ─── */
.topbar-home-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    border: none;
    cursor: pointer;
    flex-shrink: 0;
    box-shadow: 0 3px 12px rgba(118,75,162,0.4);
    transition: transform 0.2s, box-shadow 0.2s
}
.topbar-home-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(118,75,162,0.55);
    color: #fff
}
.topbar-home-btn svg { width: 18px; height: 18px }

/* ─── Logo ─── */
.topbar-logo { flex-shrink: 0; direction: ltr }

.topbar-logo-text {
    font-size: 1.35rem;
    font-weight: 900;
    letter-spacing: -0.3px;
    line-height: 1.1;
    direction: ltr;
    display: inline-block;
    background: linear-gradient(90deg, #6366f1 0%, #818cf8 30%, #a855f7 65%, #c084fc 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text
}

.tl-app {
    font-size: 1.6rem;
    font-weight: 900;
    letter-spacing: -1.5px
}

.topbar-logo-sub {
    font-size: 0.58rem;
    color: #94a3b8;
    margin-top: 2px;
    letter-spacing: 0.5px
}

/* ─── User ─── */
.topbar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0
}

.topbar-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #3b82f6;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.95rem;
    font-weight: 700;
    flex-shrink: 0
}

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

.topbar-user-name {
    font-size: 0.85rem;
    font-weight: 700;
    color: #1e293b;
    line-height: 1
}

@keyframes badge-glow {
    0%, 100% { box-shadow: 0 2px 14px rgba(124,58,237,0.55), inset 0 1px 0 rgba(255,255,255,0.2) }
    50%       { box-shadow: 0 4px 26px rgba(168,85,247,0.85), 0 0 0 3px rgba(168,85,247,0.14), inset 0 1px 0 rgba(255,255,255,0.28) }
}
@keyframes badge-shimmer {
    0%        { transform: translateX(-220%) skewX(-18deg) }
    38%, 100% { transform: translateX(280%)  skewX(-18deg) }
}
.topbar-rank-badge {
    font-size: 0.76rem;
    font-weight: 800;
    color: #fff;
    background: linear-gradient(135deg, #4c1d95 0%, #7c3aed 40%, #a855f7 72%, #c084fc 100%);
    border-radius: 22px;
    padding: 5px 14px 5px 11px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    width: fit-content;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    text-shadow: 0 1px 4px rgba(0,0,0,0.4);
    box-shadow: 0 3px 16px rgba(124,58,237,0.6), inset 0 1px 0 rgba(255,255,255,0.22);
    animation: badge-glow 2.5s ease-in-out infinite;
    transition: transform 0.15s;
    letter-spacing: 0.2px;
    white-space: nowrap;
}
.topbar-rank-badge::before {
    content: '';
    position: absolute;
    top: 0; bottom: 0;
    left: -60%;
    width: 45%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.32), transparent);
    transform: skewX(-18deg);
    animation: badge-shimmer 3.5s ease-in-out infinite 1s
}
.topbar-rank-badge:hover {
    animation: none;
    box-shadow: 0 5px 28px rgba(124,58,237,0.9), 0 0 0 3px rgba(168,85,247,0.22), inset 0 1px 0 rgba(255,255,255,0.3);
    transform: translateY(-2px) scale(1.07)
}

/* ─── Rank track modal ─────────────────────────────────────────────────────── */
.rank-modal {
    background: linear-gradient(160deg, #0f172a 0%, #1e1b4b 100%);
    border: 1px solid rgba(99,102,241,0.22);
    border-radius: 22px;
    width: 580px;
    max-width: 95vw;
    max-height: 86vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 32px 90px rgba(0,0,0,0.7), 0 0 0 1px rgba(99,102,241,0.1);
    overflow: hidden
}

.rank-modal-hdr {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 22px 28px;
    background: linear-gradient(120deg, rgba(79,70,229,0.24) 0%, rgba(168,85,247,0.16) 100%);
    border-bottom: 1px solid rgba(99,102,241,0.18);
    flex-shrink: 0;
    position: relative;
    overflow: hidden
}

.rank-modal-hdr::before {
    content: '';
    position: absolute;
    top: -55px; right: -30px;
    width: 140px; height: 140px;
    background: radial-gradient(circle, rgba(168,85,247,0.32) 0%, transparent 70%);
    pointer-events: none
}

.rank-modal-hdr::after {
    content: '';
    position: absolute;
    bottom: -40px; left: 20px;
    width: 90px; height: 90px;
    background: radial-gradient(circle, rgba(99,102,241,0.2) 0%, transparent 70%);
    pointer-events: none
}

.rank-modal-title {
    font-size: 1.2rem;
    font-weight: 900;
    color: #e2e8f0;
    display: flex;
    align-items: center;
    gap: 10px;
    text-shadow: 0 2px 14px rgba(99,102,241,0.65);
    letter-spacing: -0.3px;
    position: relative
}

.rank-modal-close {
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.1);
    color: #64748b;
    font-size: 1rem;
    cursor: pointer;
    padding: 5px 10px;
    border-radius: 8px;
    transition: background 0.15s, color 0.15s;
    font-family: 'Heebo', sans-serif;
    position: relative
}
.rank-modal-close:hover { background: rgba(255,255,255,0.15); color: #e2e8f0 }

.rank-modal-body { overflow-y: auto; flex: 1; padding: 6px 0 }

.rank-modal-body::-webkit-scrollbar { width: 5px }
.rank-modal-body::-webkit-scrollbar-track { background: transparent }
.rank-modal-body::-webkit-scrollbar-thumb { background: rgba(99,102,241,0.3); border-radius: 99px }
.rank-modal-body::-webkit-scrollbar-thumb:hover { background: rgba(99,102,241,0.52) }

/* Row */
.rm-row {
    --tier-color: #818cf8;
    --tier-bg: rgba(99,102,241,0.05);
    --tier-border: rgba(99,102,241,0.38);
    --tier-glow: rgba(99,102,241,0.22);
    --tier-icon-bg: rgba(99,102,241,0.13);

    display: flex;
    align-items: center;
    gap: 16px;
    padding: 14px 24px;
    border-bottom: 1px solid rgba(255,255,255,0.035);
    direction: rtl;
    background: var(--tier-bg);
    border-right: 3px solid var(--tier-border);
    transition: background 0.2s
}

.rm-row:last-child { border-bottom: none }

/* Tier colour tokens */
.rm-tier-bronze   { --tier-color:#e8a050; --tier-bg:rgba(205,127,50,0.05);  --tier-border:rgba(205,127,50,0.42); --tier-glow:rgba(205,127,50,0.28); --tier-icon-bg:rgba(205,127,50,0.16) }
.rm-tier-silver   { --tier-color:#c0c8d8; --tier-bg:rgba(192,200,216,0.05); --tier-border:rgba(192,200,216,0.32); --tier-glow:rgba(192,200,216,0.2);  --tier-icon-bg:rgba(192,200,216,0.1) }
.rm-tier-gold     { --tier-color:#f8b800; --tier-bg:rgba(248,184,0,0.05);   --tier-border:rgba(248,184,0,0.44);  --tier-glow:rgba(248,184,0,0.3);   --tier-icon-bg:rgba(248,184,0,0.16) }
.rm-tier-platinum { --tier-color:#38e8ff; --tier-bg:rgba(56,232,255,0.05);  --tier-border:rgba(56,232,255,0.35); --tier-glow:rgba(56,232,255,0.24); --tier-icon-bg:rgba(56,232,255,0.12) }
.rm-tier-master   { --tier-color:#d89eff; --tier-bg:rgba(192,132,252,0.07); --tier-border:rgba(192,132,252,0.5); --tier-glow:rgba(192,132,252,0.32); --tier-icon-bg:rgba(192,132,252,0.16) }

/* Current row — per-tier tinted bg (avoids color-mix()) */
.rm-tier-bronze.rm-current   { background: rgba(205,127,50,0.14) }
.rm-tier-silver.rm-current   { background: rgba(192,200,216,0.1) }
.rm-tier-gold.rm-current     { background: rgba(248,184,0,0.13)  }
.rm-tier-platinum.rm-current { background: rgba(56,232,255,0.11) }
.rm-tier-master.rm-current   { background: rgba(192,132,252,0.14)}

.rm-row.rm-current {
    border-right-width: 4px;
    box-shadow: 0 0 32px var(--tier-glow), inset 0 0 50px rgba(255,255,255,0.015)
}

.rm-row.rm-done { opacity: 0.48 }

.rm-icon {
    font-size: 1.75rem;
    flex-shrink: 0;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: var(--tier-icon-bg);
    border: 1px solid var(--tier-border);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 14px var(--tier-glow);
    line-height: 1
}

.rm-row.rm-current .rm-icon {
    box-shadow: 0 4px 24px var(--tier-glow), 0 0 0 3px rgba(255,255,255,0.06)
}

.rm-info { flex: 1; text-align: right }

.rm-name {
    font-weight: 800;
    font-size: 0.95rem;
    color: #94a3b8;
    margin-bottom: 2px
}

.rm-row.rm-current .rm-name {
    color: var(--tier-color);
    font-size: 1rem;
    text-shadow: 0 0 14px var(--tier-glow)
}

.rm-range {
    font-size: 0.75rem;
    color: #64748b
}

.rm-row.rm-current .rm-range { color: #94a3b8 }

/* Progress bar */
.rm-progress-wrap {
    height: 6px;
    background: rgba(255,255,255,0.07);
    border-radius: 99px;
    margin-top: 8px;
    overflow: hidden
}

.rm-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--tier-border), var(--tier-color));
    border-radius: 99px;
    transition: width 0.9s cubic-bezier(.4,0,.2,1);
    box-shadow: 0 0 10px var(--tier-glow)
}

.rm-progress-label {
    font-size: 0.7rem;
    color: var(--tier-color);
    margin-top: 4px;
    font-weight: 700;
    opacity: 0.9
}

/* Status column */
.rm-status {
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    min-width: 92px
}

.rm-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 6px 14px;
    border-radius: 99px;
    font-size: 0.72rem;
    font-weight: 700;
    font-family: 'Heebo', sans-serif;
    white-space: nowrap;
    border: none
}

.rm-btn-done    { background: rgba(34,197,94,0.14); color: #4ade80; border: 1px solid rgba(34,197,94,0.28) }
.rm-btn-current { background: var(--tier-color); color: #0c0a1e; box-shadow: 0 3px 16px var(--tier-glow); font-weight: 900; text-shadow: 0 1px 2px rgba(0,0,0,0.2) }
.rm-btn-locked  { background: rgba(255,255,255,0.06); color: #475569; border: 1px solid rgba(255,255,255,0.1) }

.rm-remaining {
    font-size: 0.65rem;
    color: #64748b;
    font-weight: 600;
    text-align: center
}

.rm-loading {
    padding: 48px;
    text-align: center;
    color: #334155;
    font-size: 0.9rem
}

/* ─── Stats ─── */
.topbar-stat { text-align: center; flex-shrink: 0 }

.topbar-stat-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px
}

.topbar-stat-val {
    font-size: 1.25rem;
    font-weight: 900;
    color: #f59e0b;
    letter-spacing: -0.5px;
    line-height: 1
}

.topbar-stat-emoji { font-size: 1rem; line-height: 1 }

.topbar-stat-label {
    font-size: 0.6rem;
    color: #94a3b8;
    margin-top: 3px;
    letter-spacing: 0.2px
}

/* ─── Achievements button ─── */
@keyframes topbar-achv-pulse {
    0%, 100% { box-shadow: 0 3px 16px rgba(217,119,6,0.45), inset 0 1px 0 rgba(255,255,255,0.2) }
    50%       { box-shadow: 0 3px 24px rgba(251,191,36,0.65), inset 0 1px 0 rgba(255,255,255,0.25) }
}

@keyframes topbar-trophy-float {
    0%, 100% { transform: translateY(0) rotate(0deg) }
    40%       { transform: translateY(-2px) rotate(-6deg) }
    70%       { transform: translateY(-1px) rotate(4deg) }
}

.topbar-achv-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 8px 16px;
    background: linear-gradient(145deg, #b45309 0%, #d97706 50%, #f59e0b 100%);
    border: 1px solid rgba(255,255,255,0.22);
    border-radius: 12px;
    color: #fff;
    cursor: pointer;
    font-size: 0.68rem;
    font-weight: 800;
    font-family: 'Heebo', sans-serif;
    flex-shrink: 0;
    position: relative;
    overflow: hidden;
    letter-spacing: 0.3px;
    text-shadow: 0 1px 4px rgba(0,0,0,0.3);
    animation: topbar-achv-pulse 3s ease-in-out infinite;
    transition: transform 0.15s;
    line-height: 1
}

.topbar-achv-btn::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(110deg, transparent 25%, rgba(255,255,255,0.18) 50%, transparent 75%);
    transform: translateX(-160%);
    transition: transform 0.65s ease
}

.topbar-achv-btn:hover {
    animation: none;
    box-shadow: 0 5px 26px rgba(217,119,6,0.7), inset 0 1px 0 rgba(255,255,255,0.3);
    transform: translateY(-2px)
}

.topbar-achv-btn:hover::before { transform: translateX(160%) }

.topbar-achv-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(217,119,6,0.4)
}

.topbar-achv-btn svg {
    width: 18px;
    height: 18px;
    color: #fde68a;
    filter: drop-shadow(0 0 5px rgba(251,191,36,0.9)) drop-shadow(0 0 10px rgba(251,191,36,0.4));
    animation: topbar-trophy-float 3s ease-in-out infinite
}

.topbar-achv-btn:hover svg {
    animation: none;
    transform: scale(1.18) rotate(-8deg);
    transition: transform 0.2s ease;
    filter: drop-shadow(0 0 8px rgba(251,191,36,1)) drop-shadow(0 0 18px rgba(251,191,36,0.6))
}

/* ─── Contact button ─── */
.topbar-contact-btn {
    display: flex;
    align-items: center;
    padding: 8px 16px;
    background: transparent;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    color: #64748b;
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 600;
    font-family: 'Heebo', sans-serif;
    flex-shrink: 0;
    transition: border-color 0.18s, color 0.18s
}
.topbar-contact-btn:hover { border-color: #94a3b8; color: #334155 }

/* ─── User dropdown ─── */
.topbar-user {
    position: relative;
    cursor: pointer;
    border-radius: 10px;
    padding: 4px 6px;
    transition: background 0.15s
}
.topbar-user:hover { background: #f8fafc }
.topbar-user-chevron {
    width: 14px;
    height: 14px;
    color: #94a3b8;
    flex-shrink: 0;
    transition: transform 0.22s
}
.topbar-user.open .topbar-user-chevron { transform: rotate(180deg) }

.topbar-user-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    background: #fff;
    border-radius: 14px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.14), 0 0 0 1px rgba(226,232,240,0.8);
    min-width: 180px;
    padding: 8px;
    z-index: 500;
    direction: rtl;
    animation: card-enter 0.18s ease
}
.topbar-user-dropdown.open { display: block }

.tud-name {
    font-size: 0.78rem;
    font-weight: 700;
    color: #1e293b;
    padding: 6px 10px 8px;
    border-bottom: 1px solid #f1f5f9;
    margin-bottom: 4px
}

.tud-item {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 8px 10px;
    border-radius: 8px;
    font-size: 0.8rem;
    font-weight: 600;
    color: #374151;
    text-decoration: none;
    background: none;
    border: none;
    cursor: pointer;
    font-family: 'Heebo', sans-serif;
    transition: background 0.15s;
    direction: rtl;
    box-sizing: border-box
}
.tud-item:hover { background: #f8faff }
.tud-item svg { width: 16px; height: 16px; flex-shrink: 0 }
.tud-item--logout { color: #dc2626 }
.tud-item--logout:hover { background: #fef2f2 }

/* ─── Achievements modal ─── */
.achv-modal {
    background: #fff;
    border-radius: 20px;
    width: 520px;
    max-width: 94vw;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0,0,0,0.2)
}

.achv-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid #f1f5f9
}

.achv-modal-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.1rem;
    font-weight: 800;
    color: #1e293b
}

.achv-modal-title svg { width: 22px; height: 22px; color: #d97706 }

.achv-modal-close {
    background: transparent;
    border: none;
    color: #94a3b8;
    font-size: 1.1rem;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
    transition: background 0.15s
}
.achv-modal-close:hover { background: #f1f5f9; color: #64748b }

.achv-modal-body { padding: 40px 24px; overflow-y: auto }

.achv-empty { text-align: center; color: #94a3b8; font-size: 0.9rem }
