/* Challenges Page CSS - Optimized & Clean */

/* Visibility classes */
.hidden {
    display: none !important;
}

.challenge-game-area {
    display: none; /* Hidden by default */
}

.challenge-game-area.active {
    display: block; /* Shown when active */
}

.welcome-section {
    display: block; /* Shown by default */
}

.welcome-section.hidden {
    display: none;
}

/* Base styles */
.main.challenges-page {
    min-height: calc(100vh - 80px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem 1rem;
    overflow-x: hidden;
}

.welcome-section {
    width: 100%;
    max-width: 1000px;
    margin: 0 auto;
    animation: fadeIn 0.6s ease-out;
    padding: 0 1.5rem;
}

.welcome-card {
    background: var(--bg-card);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid var(--glass-border);
    border-radius: var(--border-radius-lg);
    padding: 4rem 2.5rem;
    text-align: center;
    box-shadow: var(--shadow-lg);
    position: relative;
    overflow: hidden;
}

.welcome-card::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(168, 85, 255, 0.05) 0%, transparent 70%);
    pointer-events: none;
    z-index: -1;
}

.welcome-title {
    font-size: clamp(2.5rem, 5vw, 4rem);
    font-weight: 900;
    margin-bottom: 1rem;
    background: linear-gradient(135deg, #fff 30%, var(--primary-light) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -1px;
}

.welcome-subtitle {
    color: var(--text-secondary);
    font-size: 1.25rem;
    margin-bottom: 4rem;
    font-weight: 500;
}

/* Mode Selection - Row 1 (3 Buttons) */
.mode-selection-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 2rem;
    margin-bottom: 3rem;
}

.mode-card {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: var(--border-radius-md);
    padding: 2.5rem 2rem;
    text-decoration: none !important;
    transition: var(--transition);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
    height: 100%;
    position: relative;
    overflow: hidden;
}

.mode-card::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, var(--primary-color) 0%, transparent 100%);
    opacity: 0;
    transition: opacity 0.4s ease;
    z-index: 0;
}

.mode-card:hover {
    background: rgba(168, 85, 255, 0.05);
    border-color: var(--primary-color);
    transform: translateY(-10px);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
}

.mode-card:hover::after {
    opacity: 0.05;
}

.mode-icon {
    width: 64px;
    height: 64px;
    background: rgba(168, 85, 255, 0.1);
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary-color);
    transition: var(--transition);
    z-index: 1;
    border: 1px solid rgba(168, 85, 255, 0.2);
}

.mode-card:hover .mode-icon {
    background: var(--primary-color);
    color: #fff;
    transform: scale(1.1) rotate(5deg);
    box-shadow: 0 0 20px rgba(168, 85, 255, 0.4);
}

.mode-title {
    color: #fff !important;
    font-size: 1.4rem;
    font-weight: 800;
    margin: 0;
    z-index: 1;
}

.mode-desc {
    color: var(--text-secondary) !important;
    font-size: 0.9rem;
    line-height: 1.6;
    margin: 0;
    z-index: 1;
}

.btn-mode {
    margin-top: auto;
    padding: 0.75rem 2rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    color: #fff;
    font-weight: 700;
    transition: var(--transition);
    z-index: 1;
}

.mode-card:hover .btn-mode {
    background: var(--primary-color);
    border-color: var(--primary-color);
    box-shadow: 0 4px 15px rgba(168, 85, 255, 0.4);
}

/* Welcome Actions - Row 2 (2 Buttons) */
.welcome-actions {
    display: flex;
    justify-content: center;
    gap: 1.25rem;
    padding-top: 2rem;
    border-top: 1px solid var(--glass-border);
}

.action-btn {
    flex: 0 1 220px;
    background: rgba(255, 255, 255, 0.05) !important;
    border: 1px solid var(--glass-border) !important;
    border-radius: 14px !important;
    padding: 0.875rem 1.5rem !important;
    color: #fff !important;
    font-weight: 700 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 0.75rem !important;
    cursor: pointer !important;
    transition: var(--transition) !important;
    font-family: inherit !important;
    font-size: 0.95rem !important;
}

.action-btn:hover {
    background: rgba(255, 255, 255, 0.1) !important;
    border-color: var(--primary-light) !important;
    transform: translateY(-2px);
}

.action-btn svg {
    color: var(--primary-light);
}

/* Responsive */
@media (max-width: 992px) {
    .mode-selection-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 1rem;
    }
    
    .mode-card {
        padding: 1.5rem 1rem;
    }
    
    .mode-card h3 {
        font-size: 1.1rem;
    }
}

@media (max-width: 768px) {
    .mode-selection-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .mode-card:last-child {
        grid-column: span 2;
    }
    
    .welcome-title {
        font-size: 2.25rem;
    }
}

@media (max-width: 480px) {
    .mode-selection-grid {
        grid-template-columns: 1fr;
    }
    
    .mode-card:last-child {
        grid-column: auto;
    }
    
    .welcome-actions {
        flex-direction: column;
        align-items: center;
    }
    
    .action-btn {
        width: 100%;
        max-width: none;
    }

    .hint-section {
        flex-direction: column;
        gap: 0.75rem;
        padding: 1rem;
    }

    .hint-btn-modern {
        max-width: none;
    }
}

/* Game Area */
.challenge-game-area {
    width: 100%;
    max-width: 1100px;
    margin: 0 auto;
    animation: fadeIn 0.5s ease-out;
}

/* Custom Game Header */
.custom-game-header {
    width: 100%;
    height: 60px;
    background: #f7f1d5;
    border-bottom: 2px solid #333;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    position: sticky;
    top: 0;
    z-index: 1000;
}

.header-back-btn {
    width: 44px;
    height: 38px;
    background: transparent;
    border: 2px solid #333;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #333;
    transition: all 0.2s ease;
}

.header-back-btn:hover {
    background: rgba(0, 0, 0, 0.05);
    transform: translateX(3px);
}

.game-title {
    font-size: 1.4rem !important;
    font-weight: 800 !important;
    color: #333 !important;
    margin: 0 !important;
    text-shadow: none !important;
    font-family: 'Tajawal', sans-serif;
}

.header-logo {
    width: 44px;
    height: 44px;
}

.header-logo img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: 8px;
}

/* Hint Trigger Button (Lightbulb) */
.hint-trigger-wrapper {
    margin-top: 2rem;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.45rem;
}

.hint-inline-box {
    min-height: 54px;
    max-width: min(620px, 82vw);
    padding: 0.75rem 1rem;
    background: rgba(16, 1, 34, 0.92);
    border: 2px solid var(--primary-light);
    border-radius: 16px;
    display: none;
    align-items: center;
    justify-content: flex-end;
    box-shadow: 0 8px 20px rgba(168, 85, 255, 0.28);
}

.hint-inline-box.has-hint {
    display: flex;
}

.hint-inline-text {
    color: var(--text-primary);
    font-size: 1rem;
    font-weight: 700;
    line-height: 1.45;
    text-align: right;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.hint-trigger-btn {
    width: 54px;
    height: 54px;
    background: linear-gradient(135deg, var(--primary-dark), var(--primary-color));
    border: 2px solid var(--primary-light);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #fff;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 0 rgba(91, 33, 182, 0.95), 0 10px 20px rgba(168, 85, 255, 0.35);
}

.hint-trigger-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 0 rgba(91, 33, 182, 0.95), 0 14px 24px rgba(168, 85, 255, 0.45);
}

.hint-trigger-btn:active {
    transform: translateY(2px);
    box-shadow: 0 2px 0 rgba(91, 33, 182, 0.95), 0 6px 12px rgba(168, 85, 255, 0.3);
}

/* Hint Menu Popup */
.hint-menu-popup {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    padding: 1.5rem;
}

.hint-menu-popup.active {
    display: flex;
    animation: fadeIn 0.3s ease;
}

.hint-menu-content {
    background: var(--bg-card-solid);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    width: 100%;
    max-width: 320px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.2);
    position: relative;
}

.hint-menu-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 1.5rem;
    background: transparent;
    border: none;
    border-bottom: 1px solid var(--glass-border);
    cursor: pointer;
    transition: background 0.2s ease;
    text-align: right;
    font-family: 'Tajawal', sans-serif;
    color: var(--text-primary);
}

.hint-menu-item:last-of-type {
    border-bottom: none;
}

.hint-menu-item:hover:not(:disabled) {
    background: rgba(168, 85, 255, 0.08);
}

.hint-menu-item:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.hint-menu-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.hint-menu-label {
    font-weight: 700;
    font-size: 1.05rem;
}

.hint-menu-cost {
    font-size: 0.9rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.hint-menu-close {
    margin-top: 1rem;
    width: 44px;
    height: 44px;
    background: linear-gradient(135deg, var(--primary-dark), var(--primary-color));
    border: 2px solid var(--primary-light);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    align-self: center;
    margin-bottom: -22px;
    position: absolute;
    bottom: -60px;
    box-shadow: 0 4px 0 rgba(91, 33, 182, 0.95);
    color: #fff;
}

/* Adjust Game Area for new background */
.guess-container {
    background: transparent !important;
    backdrop-filter: none !important;
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
}

.image-frame {
    background: transparent !important;
    border: none !important;
    border-radius: 18px !important;
    box-shadow: none !important;
}

.letter-box {
    background: #fff !important;
    border: 3px solid #333 !important;
    border-radius: 12px !important;
    color: #333 !important;
    box-shadow: 0 4px 0 rgba(0, 0, 0, 0.1) !important;
}

.letter-box:focus {
    border-color: #000 !important;
    transform: translateY(-2px) !important;
    box-shadow: 0 6px 0 rgba(0, 0, 0, 0.15) !important;
}

.guess-instruction {
    display: block !important;
    margin: 0 0 0.85rem !important;
    text-align: center;
    color: var(--primary-light) !important;
    text-shadow: 0 2px 12px rgba(168, 85, 255, 0.35);
    font-weight: 800;
}

.progress-container {
    display: flex;
    align-items: center;
    gap: 1.25rem;
    min-width: 220px;
}

.progress-bar {
    flex: 1;
    height: 8px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-dark), var(--primary-color));
    width: 0;
    transition: width 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
    box-shadow: 0 0 15px rgba(168, 85, 255, 0.5);
}

.progress-text {
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 800;
    font-family: 'IBM Plex Sans Arabic', sans-serif;
}

.game-header {
    background: transparent;
    backdrop-filter: none;
    padding: 0;
    border-radius: 0;
    border: none;
    margin: 0;
    display: block;
    box-shadow: none;
    width: 0;
    height: 0;
}

.game-header h2 {
    font-size: 1.5rem;
    font-weight: 800;
    margin: 0;
    text-align: right;
    width: max-content;
    position: fixed;
    top: 44%;
    right: 22px;
    z-index: 1200;
    pointer-events: none;
    transform: translateY(-50%);
}

#challengeQuestion {
    position: fixed;
    top: calc(44% + 34px);
    right: 22px;
    z-index: 1200;
    margin: 0 !important;
    text-align: right !important;
    width: max-content;
    pointer-events: none;
}

@media (max-width: 768px) {
    .game-header {
        width: 100%;
        height: auto;
        display: flex;
        justify-content: center;
        margin-bottom: 0.4rem;
    }

    .game-header h2 {
        position: static;
        transform: none;
        right: auto;
        top: auto;
        font-size: 1.15rem;
        text-align: center;
    }

    #challengeQuestion {
        position: static;
        top: auto;
        right: auto;
        width: 100%;
        font-size: 0.98rem !important;
        text-align: center !important;
        margin-bottom: 0.6rem !important;
    }

    .game-main-grid {
        gap: 0.8rem;
    }

    .image-frame {
        width: min(520px, 88vw);
    }

    .image-frame img {
        max-height: 42vh;
    }

    .input-section {
        max-width: 92vw;
    }

    .letter-boxes {
        gap: 0.35rem;
        margin-bottom: 0.75rem;
    }

    .letter-box {
        width: 42px;
        height: 54px;
        font-size: 1.2rem;
    }

    .hint-trigger-wrapper {
        margin-top: 1rem;
        width: 100%;
        gap: 0.35rem;
    }

    .hint-inline-box {
        flex: 1;
        min-height: 48px;
        max-width: none;
        padding: 0.55rem 0.75rem;
        border-width: 2px;
        border-radius: 12px;
    }

    .hint-inline-text {
        font-size: 0.9rem;
        white-space: normal;
        overflow: visible;
        text-overflow: clip;
    }

    .challenge-alert {
        top: 78px;
        right: 10px;
        min-width: 0;
        max-width: calc(100vw - 20px);
        font-size: 0.86rem;
        padding: 0.6rem 0.75rem;
    }
}

.game-main-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.2rem;
    align-items: center;
    justify-items: center;
    max-width: 760px;
    margin: 0 auto;
}

.image-section,
.input-section {
    width: 100%;
}

.image-section {
    order: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.input-section {
    order: 2;
}

.image-frame {
    position: relative;
    background: transparent;
    backdrop-filter: none;
    padding: 0;
    border-radius: var(--border-radius-md);
    border: none;
    box-shadow: none;
    overflow: hidden;
    width: min(620px, 92vw);
    display: flex;
    justify-content: center;
}

.image-frame img {
    display: block;
    width: auto;
    height: auto;
    max-width: 100%;
    max-height: 56vh;
    object-fit: contain;
    border-radius: 16px;
    opacity: 0;
    transition: opacity 0.4s ease;
}

.image-frame img.loaded {
    opacity: 1;
}

.image-skeleton {
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, 
        rgba(255, 255, 255, 0.03) 25%, 
        rgba(255, 255, 255, 0.06) 50%, 
        rgba(255, 255, 255, 0.03) 75%
    );
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
    border-radius: 16px;
}

.input-section {
    position: static;
    width: 100%;
    max-width: 760px;
}

.guess-container {
    background: var(--bg-card);
    backdrop-filter: var(--glass-blur);
    padding: 0.25rem 0 0;
    border-radius: var(--border-radius-md);
    border: 0;
    box-shadow: none;
}

.challenge-alert {
    position: fixed;
    top: 92px;
    right: 18px;
    z-index: 2600;
    min-width: 260px;
    max-width: min(420px, 88vw);
    padding: 0.7rem 0.95rem;
    border-radius: 12px;
    border: 1px solid var(--glass-border);
    background: rgba(16, 1, 34, 0.92);
    color: var(--text-primary);
    box-shadow: 0 14px 34px rgba(0, 0, 0, 0.32);
    font-size: 0.92rem;
    line-height: 1.5;
    text-align: right;
    animation: toastSlideIn 0.2s ease-out;
}

.challenge-alert.success {
    border-color: rgba(34, 197, 94, 0.5);
    background: rgba(8, 51, 26, 0.95);
}

.challenge-alert.error {
    border-color: rgba(251, 113, 133, 0.55);
    background: rgba(66, 20, 30, 0.95);
}

@keyframes toastSlideIn {
    from { opacity: 0; transform: translateX(12px); }
    to { opacity: 1; transform: translateX(0); }
}

.guess-instruction {
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
    text-align: center;
}

.letter-boxes {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
    justify-content: center;
    margin-bottom: 1rem;
}

.letter-box {
    width: 48px;
    height: 60px;
    background: rgba(255, 255, 255, 0.03);
    border: 2px solid var(--glass-border);
    border-radius: 10px;
    color: #fff;
    text-align: center;
    font-size: 1.4rem;
    font-weight: 800;
    transition: all 0.2s ease;
}
.letter-box:focus {
    border-color: var(--primary-color);
    background: rgba(168, 85, 255, 0.08);
    transform: translateY(-4px);
    box-shadow: 0 10px 20px rgba(168, 85, 255, 0.2);
    outline: none;
}

.letter-box.revealed {
    color: var(--primary-light);
    border-color: var(--primary-color);
    background: rgba(168, 85, 255, 0.05);
}

.letter-box.correct {
    border-color: var(--success) !important;
    background: rgba(34, 197, 94, 0.1) !important;
    color: #fff !important;
    animation: correctPulse 0.5s ease-in-out;
}

.letter-box.wrong {
    border-color: var(--danger) !important;
    background: rgba(251, 113, 133, 0.1) !important;
    color: #fff !important;
    animation: wrongShake 0.4s ease-in-out;
}

@keyframes correctPulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.08); box-shadow: 0 0 20px rgba(34, 197, 94, 0.4); }
    100% { transform: scale(1); }
}

@keyframes wrongShake {
    0%, 100% { transform: translateX(0); }
    20%, 60% { transform: translateX(-6px); }
    40%, 80% { transform: translateX(6px); }
}

/* Hint Section Redesign */
.hint-section {
    display: none;
    gap: 1.25rem;
    justify-content: center;
    margin: 2rem 0;
    padding: 1.5rem;
    background: rgba(255, 255, 255, 0.02);
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.word-group {
    display: inline-flex;
    gap: 0.45rem;
}


.hint-btn-modern {
    flex: 1;
    max-width: 200px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    padding: 0.8rem 1rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.hint-btn-modern:hover:not(:disabled) {
    background: rgba(168, 85, 255, 0.1);
    border-color: var(--primary-color);
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(168, 85, 255, 0.15);
}

.hint-btn-modern:active:not(:disabled) {
    transform: translateY(0);
}

.hint-btn-modern:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    filter: grayscale(1);
}

.hint-icon {
    font-size: 1.5rem;
    background: rgba(255, 255, 255, 0.05);
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    transition: all 0.3s ease;
}

.hint-btn-modern:hover .hint-icon {
    background: var(--primary-color);
    transform: scale(1.1) rotate(5deg);
}

.hint-content {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    text-align: right;
}

.hint-label {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-primary);
    white-space: nowrap;
    font-family: 'Tajawal', sans-serif;
}

.hint-count {
    font-size: 0.75rem;
    color: var(--primary-light);
    font-weight: 800;
    opacity: 0.8;
    font-family: 'Tajawal', sans-serif;
}

.game-btn.secondary {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    padding: 0.75rem 1.5rem;
    border-radius: 14px;
    color: #fff;
    text-decoration: none;
    font-weight: 800;
    font-size: 0.95rem;
    transition: var(--transition);
    box-shadow: var(--shadow-sm);
    font-family: 'Tajawal', sans-serif;
}

.game-btn.secondary:hover {
    background: rgba(168, 85, 255, 0.1);
    border-color: var(--primary-color);
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(168, 85, 255, 0.2);
}

/* Modals */
.simple-modal {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(8px);
}

.simple-modal-content {
    background: var(--bg-card-solid);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    padding: 2.5rem;
    width: 100%;
    max-width: 480px;
    position: relative;
    animation: zoomIn 0.3s ease-out;
}

.modal-close {
    position: absolute;
    top: 1rem;
    left: 1rem;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 1.5rem;
    cursor: pointer;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes zoomIn { from { transform: scale(0.95); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* Leaderboard Styles */
.leaderboard-container {
    max-width: 850px;
    margin: 2rem auto;
    padding: 0 1.5rem;
    animation: fadeIn 0.6s ease-out;
}

.leaderboard-card {
    background: var(--bg-card);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid var(--glass-border);
    border-radius: var(--border-radius-lg);
    padding: 3.5rem 3rem;
    box-shadow: var(--shadow-lg);
    position: relative;
    overflow: hidden;
}

.leaderboard-card::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(168, 85, 255, 0.05) 0%, transparent 70%);
    pointer-events: none;
    z-index: -1;
}

.leaderboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 3.5rem;
    flex-wrap: wrap;
    gap: 2rem;
}

.leaderboard-title-group {
    flex: 1;
    min-width: 250px;
}

.leaderboard-title-group h2 {
    font-size: clamp(2rem, 4vw, 2.8rem);
    font-weight: 900;
    margin-bottom: 0.75rem;
    color: #fff;
    letter-spacing: -1px;
    background: linear-gradient(135deg, #fff 30%, var(--primary-light) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.leaderboard-title-group p {
    color: var(--text-secondary);
    font-size: 1.1rem;
    font-weight: 500;
}

.leaderboard-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.leaderboard-item {
    display: flex;
    align-items: center;
    padding: 1.25rem 2rem;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 20px;
    transition: var(--transition);
    position: relative;
}

.leaderboard-item:hover {
    background: rgba(168, 85, 255, 0.06);
    border-color: rgba(168, 85, 255, 0.3);
    transform: translateX(-8px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

.leaderboard-rank {
    width: 50px;
    font-size: 1.5rem;
    font-weight: 900;
    color: var(--text-secondary);
    font-family: 'IBM Plex Sans Arabic', sans-serif;
}

.leaderboard-item:nth-child(1) {
    background: linear-gradient(90deg, rgba(255, 215, 0, 0.05) 0%, rgba(255, 255, 255, 0.02) 100%);
    border-color: rgba(255, 215, 0, 0.2);
}
.leaderboard-item:nth-child(1) .leaderboard-rank { 
    color: #FFD700; 
    font-size: 2rem;
    text-shadow: 0 0 15px rgba(255, 215, 0, 0.3);
}

.leaderboard-item:nth-child(2) {
    background: linear-gradient(90deg, rgba(192, 192, 192, 0.05) 0%, rgba(255, 255, 255, 0.02) 100%);
    border-color: rgba(192, 192, 192, 0.2);
}
.leaderboard-item:nth-child(2) .leaderboard-rank { color: #C0C0C0; }

.leaderboard-item:nth-child(3) {
    background: linear-gradient(90deg, rgba(205, 127, 50, 0.05) 0%, rgba(255, 255, 255, 0.02) 100%);
    border-color: rgba(205, 127, 50, 0.2);
}
.leaderboard-item:nth-child(3) .leaderboard-rank { color: #CD7F32; }

.leaderboard-user {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 1.25rem;
}

.leaderboard-avatar {
    width: 56px;
    height: 56px;
    border-radius: 16px;
    background: rgba(168, 85, 255, 0.1);
    border: 2px solid var(--glass-border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    color: var(--primary-light);
    overflow: hidden;
    transition: var(--transition);
}

.leaderboard-item:hover .leaderboard-avatar {
    border-color: var(--primary-color);
    transform: rotate(-5deg) scale(1.1);
}

.leaderboard-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.leaderboard-name {
    font-weight: 800;
    color: #fff;
    font-size: 1.2rem;
    letter-spacing: -0.3px;
}

.leaderboard-score {
    text-align: left;
    background: rgba(0, 0, 0, 0.2);
    padding: 0.6rem 1.25rem;
    border-radius: 14px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.score-value {
    display: inline-block;
    font-size: 1.4rem;
    font-weight: 900;
    color: var(--primary-light);
    margin-left: 0.4rem;
}

.score-label {
    display: inline-block;
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 700;
}

@media (max-width: 768px) {
    .leaderboard-card {
        padding: 2.5rem 1.5rem;
    }
    
    .leaderboard-header {
        flex-direction: column;
        text-align: center;
        margin-bottom: 2.5rem;
    }
    
    .leaderboard-item {
        padding: 1rem;
        flex-wrap: wrap;
        gap: 1rem;
    }

    .leaderboard-rank {
        width: 30px;
        font-size: 1.2rem;
    }
    
    .leaderboard-user {
        gap: 0.75rem;
    }

    .leaderboard-avatar {
        width: 44px;
        height: 44px;
    }
    
    .leaderboard-name {
        font-size: 1rem;
    }

    .leaderboard-score {
        width: 100%;
        text-align: center;
        margin-top: 0.5rem;
    }
}

/* Success Modal */
.game-success-modal {
    position: fixed;
    inset: 0;
    z-index: 3000;
    display: none; /* Controlled by JS */
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
}

.success-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    z-index: -1;
    animation: fadeIn 0.4s ease-out;
}

.success-content {
    background: var(--bg-card-solid);
    border: 1px solid var(--glass-border);
    border-radius: 32px;
    padding: 3.5rem 2.5rem;
    width: 100%;
    max-width: 480px;
    text-align: center;
    position: relative;
    box-shadow: 0 20px 60px rgba(168, 85, 255, 0.2);
    animation: zoomIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.success-icon {
    width: 80px;
    height: 80px;
    background: linear-gradient(135deg, var(--success), #15803d);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    margin: 0 auto 2rem;
    box-shadow: 0 10px 25px rgba(34, 197, 94, 0.4);
    animation: bounceIn 0.6s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.success-title {
    font-size: 2.2rem;
    font-weight: 900;
    margin-bottom: 1.5rem;
    background: linear-gradient(135deg, #fff 30%, var(--primary-light) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.answer-display {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 20px;
    padding: 1.5rem;
    margin-bottom: 2rem;
}

.answer-label {
    display: block;
    color: var(--text-secondary);
    font-size: 0.95rem;
    margin-bottom: 0.5rem;
    font-weight: 600;
}

.answer-value {
    color: var(--primary-light);
    font-size: 1.8rem;
    font-weight: 900;
    letter-spacing: 1px;
}

.reward-box {
    background: linear-gradient(135deg, rgba(168, 85, 255, 0.1), rgba(168, 85, 255, 0.05));
    border: 1px solid rgba(168, 85, 255, 0.2);
    border-radius: 20px;
    padding: 1.5rem;
    margin-bottom: 2.5rem;
    animation: slideUp 0.5s ease-out 0.3s backwards;
}

.reward-title {
    color: var(--warning);
    font-weight: 800;
    font-size: 1.1rem;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.reward-title::before, .reward-title::after {
    content: '★';
}

.reward-badges {
    display: flex;
    justify-content: center;
    gap: 1rem;
}

.badge-item {
    display: inline-flex;
    align-items: center;
    padding: 0.5rem 1rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    font-size: 0.9rem;
    font-weight: 700;
    color: #fff;
}

.badge-item.letter { border-color: var(--primary-color); color: var(--primary-light); }
.badge-item.admin { border-color: var(--warning); color: var(--warning); }

.success-actions {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.success-actions .game-btn {
    width: 100%;
    justify-content: center;
    padding: 1rem !important;
    font-size: 1.1rem !important;
}

.game-btn.primary {
    background: linear-gradient(135deg, var(--primary-dark), var(--primary-color)) !important;
    color: #fff !important;
    border: none !important;
    box-shadow: 0 8px 20px rgba(168, 85, 255, 0.3) !important;
    font-family: 'Tajawal', sans-serif !important;
}

.game-btn.primary:hover {
    transform: translateY(-3px);
    filter: brightness(1.1);
    box-shadow: 0 12px 25px rgba(168, 85, 255, 0.4) !important;
}

@keyframes bounceIn {
    0% { transform: scale(0.3); opacity: 0; }
    50% { transform: scale(1.05); opacity: 1; }
    70% { transform: scale(0.9); }
    100% { transform: scale(1); }
}

@keyframes slideUp {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

@media (max-width: 480px) {
    .success-content {
        padding: 2.5rem 1.5rem;
    }
    .success-title { font-size: 1.8rem; }
    .answer-value { font-size: 1.5rem; }
}
