/* ========================================
   OPUS - GAMIFICATION CSS
   XP, Niveaux, Achievements, Streaks
   ======================================== */

/* === VARIABLES === */
:root {
    --gam-gold: #ffd700;
    --gam-xp-bar: linear-gradient(90deg, #667eea 0%, #764ba2 50%, #f093fb 100%);
    --gam-streak-fire: #ff6b35;
    --gam-achievement-glow: rgba(255, 215, 0, 0.3);
    --gam-levelup-glow: rgba(102, 126, 234, 0.5);
}

/* ═══════════════════════════════════════════════════════════════
   WIDGET HEADER (mini profil dans le header)
   ═══════════════════════════════════════════════════════════════ */

.gamification-widget {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    background: #374151;
    border: 2px solid #4b5563;
    border-radius: 9999px;
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
}

.gamification-widget:hover {
    background: #374151;
    border-color: #667eea;
    color: #667eea;
    transform: translateY(-1px);
}

.gam-widget-content {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Badge niveau */
.gam-level-badge {
    position: relative;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 50%;
    font-weight: 700;
    font-size: 12px;
    color: white;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.4);
    flex-shrink: 0;
}

.gam-level-badge::after {
    content: '';
    position: absolute;
    inset: -2px;
    border-radius: 50%;
    border: 1.5px solid rgba(255, 215, 0, 0.4);
    animation: pulse-ring 2s infinite;
}

@keyframes pulse-ring {
    0%, 100% { transform: scale(1); opacity: 0.4; }
    50% { transform: scale(1.05); opacity: 0; }
}

/* Info XP */
.gam-xp-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 70px;
}

.gam-xp-text {
    font-size: 9px;
    color: rgba(255, 255, 255, 0.65);
    font-weight: 500;
    white-space: nowrap;
}

.gam-xp-bar {
    height: 4px;
    background: rgba(255, 255, 255, 0.12);
    border-radius: 2px;
    overflow: hidden;
    position: relative;
}

.gam-xp-fill {
    height: 100%;
    background: var(--gam-xp-bar);
    border-radius: 2px;
    transition: width 0.5s ease;
    position: relative;
}

.gam-xp-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
    animation: xp-shine 2s infinite;
}

@keyframes xp-shine {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

/* Streak */
.gam-streak {
    display: flex;
    align-items: center;
    gap: 2px;
    padding: 2px 6px;
    background: rgba(255, 107, 53, 0.2);
    border-radius: 12px;
    border: 1px solid rgba(255, 107, 53, 0.25);
}

.gam-streak-icon {
    font-size: 12px;
    animation: flame-flicker 0.5s infinite alternate;
}

@keyframes flame-flicker {
    0% { transform: scale(1) rotate(-2deg); }
    100% { transform: scale(1.05) rotate(2deg); }
}

.gam-streak-count {
    font-weight: 700;
    font-size: 11px;
    color: var(--gam-streak-fire);
}

.gam-streak.inactive {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.1);
}

.gam-streak.inactive .gam-streak-icon {
    animation: none;
    opacity: 0.5;
}

.gam-streak.inactive .gam-streak-count {
    color: rgba(255, 255, 255, 0.5);
}

/* ═══════════════════════════════════════════════════════════════
   MODAL PROFIL GAMIFICATION
   ═══════════════════════════════════════════════════════════════ */

.gamification-modal {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.gamification-modal.active {
    opacity: 1;
    visibility: visible;
}

.gam-modal-content {
    width: 95%;
    max-width: 600px;
    max-height: 90vh;
    background: rgba(20, 25, 50, 0.95);
    backdrop-filter: blur(20px);
    border-radius: 24px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    overflow: hidden;
    transform: scale(0.9) translateY(20px);
    transition: transform 0.3s ease;
    display: flex;
    flex-direction: column;
}

.gamification-modal.active .gam-modal-content {
    transform: scale(1) translateY(0);
}

/* Header profil */
.gam-profile-header {
    padding: 24px;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.3) 0%, rgba(118, 75, 162, 0.3) 100%);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    position: relative;
    overflow: hidden;
}

.gam-profile-header::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255,255,255,0.1) 0%, transparent 50%);
    animation: rotate-bg 20s linear infinite;
}

@keyframes rotate-bg {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.gam-profile-info {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    gap: 20px;
}

.gam-profile-level {
    width: 80px;
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 50%;
    font-size: 32px;
    font-weight: 800;
    color: white;
    box-shadow: 0 8px 30px rgba(102, 126, 234, 0.5);
    border: 3px solid rgba(255, 215, 0, 0.5);
}

.gam-profile-details {
    flex: 1;
}

.gam-profile-title {
    font-size: 14px;
    color: rgba(255, 255, 255, 0.6);
    margin-bottom: 4px;
}

.gam-profile-xp {
    font-size: 24px;
    font-weight: 700;
    color: white;
    margin-bottom: 8px;
}

.gam-profile-xp span {
    font-size: 14px;
    color: rgba(255, 255, 255, 0.5);
    font-weight: 400;
}

.gam-profile-bar {
    height: 10px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 5px;
    overflow: hidden;
}

.gam-profile-bar-fill {
    height: 100%;
    background: var(--gam-xp-bar);
    border-radius: 5px;
    transition: width 0.5s ease;
}

.gam-profile-close {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    border-radius: 50%;
    color: white;
    font-size: 20px;
    cursor: pointer;
    transition: all 0.2s ease;
    z-index: 2;
}

.gam-profile-close:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: rotate(90deg);
}

/* Stats row */
.gam-stats-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    padding: 16px 24px;
    background: rgba(0, 0, 0, 0.2);
}

.gam-stat {
    text-align: center;
    padding: 12px 8px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 12px;
}

.gam-stat-value {
    font-size: 20px;
    font-weight: 700;
    color: white;
    margin-bottom: 4px;
}

.gam-stat-label {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.5);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.gam-stat.streak .gam-stat-value {
    color: var(--gam-streak-fire);
}

/* Tabs */
.gam-tabs {
    display: flex;
    padding: 0 24px;
    gap: 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(0, 0, 0, 0.1);
}

.gam-tab {
    padding: 12px 16px;
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.5);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    position: relative;
    transition: color 0.2s ease;
}

.gam-tab:hover {
    color: rgba(255, 255, 255, 0.8);
}

.gam-tab.active {
    color: white;
}

.gam-tab.active::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, #667eea, #764ba2);
    border-radius: 2px 2px 0 0;
}

/* Content scrollable */
.gam-modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px 24px;
}

/* Category tabs for achievements */
.gam-category-tabs {
    display: flex;
    flex-wrap: nowrap;
    gap: 6px;
    margin-bottom: 16px;
}

.gam-category-tab {
    padding: 6px 12px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    color: rgba(255, 255, 255, 0.6);
    font-size: 11px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.gam-category-tab:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

.gam-category-tab.active {
    background: linear-gradient(135deg, #667eea, #764ba2);
    border-color: transparent;
    color: white;
}

/* ═══════════════════════════════════════════════════════════════
   ACHIEVEMENTS GRID
   ═══════════════════════════════════════════════════════════════ */

.gam-achievements-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 12px;
}

.gam-achievement {
    position: relative;
    padding: 16px 12px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    text-align: center;
    transition: all 0.3s ease;
    cursor: default;
}

.gam-achievement:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
}

.gam-achievement.unlocked {
    background: rgba(255, 215, 0, 0.1);
    border-color: rgba(255, 215, 0, 0.3);
}

.gam-achievement.unlocked:hover {
    box-shadow: 0 8px 25px var(--gam-achievement-glow);
}

.gam-achievement.locked {
    opacity: 0.5;
    filter: grayscale(0.5);
}

.gam-achievement.secret.locked .gam-achievement-icon,
.gam-achievement.secret.locked .gam-achievement-name {
    filter: blur(4px);
}

.gam-achievement-icon {
    font-size: 36px;
    margin-bottom: 8px;
    display: block;
}

.gam-achievement-name {
    font-size: 12px;
    font-weight: 600;
    color: white;
    margin-bottom: 4px;
    line-height: 1.3;
}

.gam-achievement-desc {
    font-size: 10px;
    color: rgba(255, 255, 255, 0.5);
    line-height: 1.3;
}

.gam-achievement-xp {
    position: absolute;
    top: 8px;
    right: 8px;
    padding: 2px 6px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    border-radius: 10px;
    font-size: 10px;
    font-weight: 600;
    color: white;
}

.gam-achievement-date {
    margin-top: 8px;
    font-size: 9px;
    color: rgba(255, 215, 0, 0.7);
}

/* Achievement presque débloqué (>= 80%) */
.gam-achievement.almost {
    border-color: rgba(34, 197, 94, 0.4);
    background: rgba(34, 197, 94, 0.1);
}

.gam-achievement.almost .gam-achievement-icon {
    animation: pulse-almost 2s ease-in-out infinite;
}

@keyframes pulse-almost {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

/* Barre de progression achievement */
.gam-achievement-progress {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 6px;
    width: 100%;
}

.gam-progress-bar {
    flex: 1;
    height: 6px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
    overflow: hidden;
}

.gam-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #22c55e, #4ade80);
    border-radius: 3px;
    transition: width 0.5s ease;
}

.gam-progress-text {
    font-size: 10px;
    color: rgba(255, 255, 255, 0.6);
    min-width: 50px;
    text-align: right;
}

/* Couleurs selon progression */
.gam-achievement.locked .gam-progress-fill {
    background: linear-gradient(90deg, #6b7280, #9ca3af);
}

.gam-achievement.almost .gam-progress-fill {
    background: linear-gradient(90deg, #22c55e, #4ade80);
}

.gam-achievement.almost .gam-progress-text {
    color: #4ade80;
    font-weight: 600;
}

/* Achievement prêt à débloquer (>= 100%) */
.gam-achievement.ready {
    border-color: rgba(251, 191, 36, 0.6);
    background: rgba(251, 191, 36, 0.15);
}

.gam-achievement.ready .gam-achievement-icon {
    animation: pulse-ready 1s ease-in-out infinite;
}

@keyframes pulse-ready {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.15); }
}

.gam-achievement.ready .gam-progress-fill {
    background: linear-gradient(90deg, #f59e0b, #fbbf24);
}

.gam-achievement.ready .gam-progress-text {
    color: #fbbf24;
    font-weight: 700;
}

/* Bouton "Réclamer" */
.gam-claim-btn {
    margin-top: 8px;
    padding: 6px 16px;
    background: linear-gradient(135deg, #f59e0b, #d97706);
    border: none;
    border-radius: 20px;
    color: white;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
    animation: pulse-claim 1.5s ease-in-out infinite;
}

.gam-claim-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 15px rgba(245, 158, 11, 0.4);
}

@keyframes pulse-claim {
    0%, 100% { box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.4); }
    50% { box-shadow: 0 0 0 8px rgba(245, 158, 11, 0); }
}

/* Achievement secret (non débloqué) */
.gam-achievement.secret {
    border-color: rgba(139, 92, 246, 0.3);
    background: rgba(139, 92, 246, 0.08);
    opacity: 0.7;
}

.gam-achievement.secret .gam-achievement-icon {
    filter: grayscale(0.5);
    opacity: 0.8;
}

.gam-achievement.secret .gam-achievement-name,
.gam-achievement.secret .gam-achievement-xp {
    color: rgba(139, 92, 246, 0.7);
    font-style: italic;
}

.gam-achievement.secret:hover {
    opacity: 0.9;
    border-color: rgba(139, 92, 246, 0.5);
}

/* Achievement unlock animation */
.gam-achievement.just-unlocked {
    animation: achievement-unlock 0.6s ease;
}

@keyframes achievement-unlock {
    0% { transform: scale(0.5); opacity: 0; }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); opacity: 1; }
}

/* ═══════════════════════════════════════════════════════════════
   OBJECTIFS QUOTIDIENS
   ═══════════════════════════════════════════════════════════════ */

.gam-objectives-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.gam-objective {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: all 0.3s ease;
}

.gam-objective.completed {
    background: rgba(76, 175, 80, 0.15);
    border-color: rgba(76, 175, 80, 0.3);
}

.gam-objective-icon {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    font-size: 24px;
}

.gam-objective.completed .gam-objective-icon {
    background: rgba(76, 175, 80, 0.3);
}

.gam-objective-info {
    flex: 1;
}

.gam-objective-title {
    font-size: 14px;
    font-weight: 600;
    color: white;
    margin-bottom: 4px;
}

.gam-objective-progress {
    display: flex;
    align-items: center;
    gap: 10px;
}

.gam-objective-bar {
    flex: 1;
    height: 6px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
    overflow: hidden;
}

.gam-objective-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #4facfe, #00f2fe);
    border-radius: 3px;
    transition: width 0.3s ease;
}

.gam-objective.completed .gam-objective-bar-fill {
    background: linear-gradient(90deg, #4caf50, #8bc34a);
}

.gam-objective-count {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.6);
    min-width: 50px;
    text-align: right;
}

.gam-objective-xp {
    padding: 6px 12px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    color: white;
}

.gam-objective.completed .gam-objective-xp {
    background: linear-gradient(135deg, #4caf50, #8bc34a);
}

.gam-objective.completed .gam-objective-xp::before {
    content: '✓ ';
}

/* ═══════════════════════════════════════════════════════════════
   HISTORIQUE XP
   ═══════════════════════════════════════════════════════════════ */

.gam-history-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.gam-history-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 12px;
}

.gam-history-icon {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    font-size: 18px;
}

.gam-history-info {
    flex: 1;
}

.gam-history-action {
    font-size: 13px;
    font-weight: 500;
    color: white;
}

.gam-history-time {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.4);
}

.gam-history-xp {
    font-size: 14px;
    font-weight: 700;
    color: #4caf50;
}

.gam-history-xp::before {
    content: '+';
}

/* ═══════════════════════════════════════════════════════════════
   LEADERBOARD
   ═══════════════════════════════════════════════════════════════ */

.gam-leaderboard-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.gam-leaderboard-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.gam-leaderboard-item.top-1 {
    background: linear-gradient(135deg, rgba(255, 215, 0, 0.2), rgba(255, 193, 7, 0.1));
    border-color: rgba(255, 215, 0, 0.3);
}

.gam-leaderboard-item.top-2 {
    background: linear-gradient(135deg, rgba(192, 192, 192, 0.15), rgba(158, 158, 158, 0.1));
    border-color: rgba(192, 192, 192, 0.3);
}

.gam-leaderboard-item.top-3 {
    background: linear-gradient(135deg, rgba(205, 127, 50, 0.15), rgba(176, 141, 87, 0.1));
    border-color: rgba(205, 127, 50, 0.3);
}

.gam-leaderboard-item.current-user {
    border-color: rgba(102, 126, 234, 0.5);
    box-shadow: 0 0 20px rgba(102, 126, 234, 0.2);
}

.gam-rank {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    font-weight: 700;
    font-size: 14px;
}

.gam-leaderboard-item.top-1 .gam-rank {
    background: linear-gradient(135deg, #ffd700, #ffb300);
    color: #5d4600;
}

.gam-leaderboard-item.top-2 .gam-rank {
    background: linear-gradient(135deg, #c0c0c0, #9e9e9e);
    color: #424242;
}

.gam-leaderboard-item.top-3 .gam-rank {
    background: linear-gradient(135deg, #cd7f32, #b08d57);
    color: #3e2723;
}

.gam-leaderboard-item:not(.top-1):not(.top-2):not(.top-3) .gam-rank {
    background: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.7);
}

.gam-leaderboard-user {
    flex: 1;
}

.gam-leaderboard-name {
    font-size: 14px;
    font-weight: 600;
    color: white;
}

.gam-leaderboard-level {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.5);
}

.gam-leaderboard-xp {
    font-size: 14px;
    font-weight: 700;
    color: #667eea;
}

/* ═══════════════════════════════════════════════════════════════
   TOASTS NOTIFICATIONS
   ═══════════════════════════════════════════════════════════════ */

.gam-toast-container {
    position: fixed;
    bottom: 100px;
    right: 20px;
    z-index: 10001;
    display: flex;
    flex-direction: column;
    gap: 12px;
    pointer-events: none;
}

.gam-toast {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 20px;
    background: rgba(20, 25, 50, 0.95);
    backdrop-filter: blur(20px);
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4);
    transform: translateX(120%);
    transition: transform 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    pointer-events: auto;
}

.gam-toast.show {
    transform: translateX(0);
}

.gam-toast.xp {
    border-color: rgba(102, 126, 234, 0.3);
}

.gam-toast.achievement {
    border-color: rgba(255, 215, 0, 0.3);
}

.gam-toast.levelup {
    border-color: rgba(240, 147, 251, 0.3);
    animation: levelup-glow 1s ease infinite alternate;
}

@keyframes levelup-glow {
    0% { box-shadow: 0 8px 30px rgba(240, 147, 251, 0.2); }
    100% { box-shadow: 0 8px 40px rgba(240, 147, 251, 0.5); }
}

.gam-toast-icon {
    font-size: 28px;
}

.gam-toast-content {
    flex: 1;
}

.gam-toast-title {
    font-size: 14px;
    font-weight: 600;
    color: white;
    margin-bottom: 2px;
}

.gam-toast-desc {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.6);
}

.gam-toast-xp {
    font-size: 16px;
    font-weight: 700;
    color: #4caf50;
}

.gam-toast-xp::before {
    content: '+';
}

/* ═══════════════════════════════════════════════════════════════
   MODAL LEVEL UP
   ═══════════════════════════════════════════════════════════════ */

.gam-levelup-modal {
    position: fixed;
    inset: 0;
    z-index: 10002;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.8);
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.gam-levelup-modal.active {
    opacity: 1;
    visibility: visible;
}

.gam-levelup-content {
    text-align: center;
    padding: 40px 60px;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.3) 0%, rgba(118, 75, 162, 0.3) 100%);
    backdrop-filter: blur(20px);
    border-radius: 30px;
    border: 2px solid rgba(255, 215, 0, 0.5);
    transform: scale(0.5);
    transition: transform 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.gam-levelup-modal.active .gam-levelup-content {
    transform: scale(1);
    animation: levelup-bounce 0.6s ease 0.3s;
}

@keyframes levelup-bounce {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

.gam-levelup-stars {
    font-size: 40px;
    margin-bottom: 16px;
    animation: stars-sparkle 1s ease infinite;
}

@keyframes stars-sparkle {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.7; transform: scale(1.1); }
}

.gam-levelup-title {
    font-size: 18px;
    color: rgba(255, 255, 255, 0.7);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 3px;
}

.gam-levelup-level {
    font-size: 72px;
    font-weight: 800;
    background: linear-gradient(135deg, #ffd700, #ff6b35, #ffd700);
    background-size: 200% 200%;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: gradient-shift 2s ease infinite;
    margin-bottom: 16px;
}

@keyframes gradient-shift {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}

.gam-levelup-subtitle {
    font-size: 14px;
    color: rgba(255, 255, 255, 0.5);
}

.gam-levelup-close {
    margin-top: 24px;
    padding: 12px 32px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    border: none;
    border-radius: 25px;
    color: white;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.gam-levelup-close:hover {
    transform: scale(1.05);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.4);
}

/* ═══════════════════════════════════════════════════════════════
   ACHIEVEMENT UNLOCK MODAL
   ═══════════════════════════════════════════════════════════════ */

.gam-achievement-modal {
    position: fixed;
    inset: 0;
    z-index: 10002;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.8);
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.gam-achievement-modal.active {
    opacity: 1;
    visibility: visible;
}

.gam-achievement-modal-content {
    text-align: center;
    padding: 40px;
    background: rgba(20, 25, 50, 0.95);
    backdrop-filter: blur(20px);
    border-radius: 30px;
    border: 2px solid rgba(255, 215, 0, 0.5);
    box-shadow: 0 0 60px var(--gam-achievement-glow);
    transform: scale(0.5) rotate(-10deg);
    transition: transform 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    max-width: 320px;
}

.gam-achievement-modal.active .gam-achievement-modal-content {
    transform: scale(1) rotate(0deg);
}

.gam-achievement-unlocked-icon {
    font-size: 80px;
    margin-bottom: 16px;
    display: block;
    animation: icon-pop 0.5s ease 0.3s backwards;
}

@keyframes icon-pop {
    0% { transform: scale(0) rotate(-180deg); }
    100% { transform: scale(1) rotate(0deg); }
}

.gam-achievement-unlocked-label {
    font-size: 12px;
    color: var(--gam-gold);
    text-transform: uppercase;
    letter-spacing: 2px;
    margin-bottom: 8px;
}

.gam-achievement-unlocked-name {
    font-size: 24px;
    font-weight: 700;
    color: white;
    margin-bottom: 8px;
}

.gam-achievement-unlocked-desc {
    font-size: 14px;
    color: rgba(255, 255, 255, 0.6);
    margin-bottom: 16px;
}

.gam-achievement-unlocked-xp {
    display: inline-block;
    padding: 8px 20px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    border-radius: 20px;
    font-size: 16px;
    font-weight: 700;
    color: white;
}

.gam-achievement-unlocked-xp::before {
    content: '+';
}

/* ═══════════════════════════════════════════════════════════════
   EMPTY STATES
   ═══════════════════════════════════════════════════════════════ */

.gam-empty {
    text-align: center;
    padding: 40px 20px;
    color: rgba(255, 255, 255, 0.4);
}

.gam-empty-icon {
    font-size: 48px;
    margin-bottom: 12px;
    opacity: 0.5;
}

.gam-empty-text {
    font-size: 14px;
}

/* ═══════════════════════════════════════════════════════════════
   SETTINGS TOGGLE
   ═══════════════════════════════════════════════════════════════ */

.gam-settings {
    padding: 20px 0;
}

.gam-setting-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 12px;
    margin-bottom: 12px;
}

.gam-setting-info {
    flex: 1;
}

.gam-setting-title {
    font-size: 14px;
    font-weight: 500;
    color: white;
    margin-bottom: 4px;
}

.gam-setting-desc {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.5);
}

.gam-toggle {
    position: relative;
    width: 50px;
    height: 26px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 13px;
    cursor: pointer;
    transition: background 0.3s ease;
}

.gam-toggle.active {
    background: linear-gradient(135deg, #667eea, #764ba2);
}

.gam-toggle::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 20px;
    height: 20px;
    background: white;
    border-radius: 50%;
    transition: transform 0.3s ease;
}

.gam-toggle.active::after {
    transform: translateX(24px);
}

/* ═══════════════════════════════════════════════════════════════
   MOBILE RESPONSIVE
   ═══════════════════════════════════════════════════════════════ */

@media (max-width: 768px) {
    .gamification-widget {
        padding: 6px 12px;
        gap: 8px;
    }

    .gam-level-badge {
        width: 36px;
        height: 36px;
        font-size: 14px;
    }

    .gam-xp-info {
        min-width: 80px;
    }

    .gam-xp-text {
        font-size: 10px;
    }

    .gam-streak-count {
        font-size: 12px;
    }

    .gam-modal-content {
        max-height: 95vh;
        border-radius: 20px 20px 0 0;
        margin-top: auto;
    }

    .gam-profile-header {
        padding: 20px;
    }

    .gam-profile-level {
        width: 60px;
        height: 60px;
        font-size: 24px;
    }

    .gam-profile-xp {
        font-size: 20px;
    }

    .gam-stats-row {
        grid-template-columns: repeat(2, 1fr);
        padding: 12px 16px;
    }

    .gam-achievements-grid {
        grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
        gap: 8px;
    }

    .gam-achievement {
        padding: 12px 8px;
    }

    .gam-achievement-icon {
        font-size: 28px;
    }

    .gam-achievement-name {
        font-size: 11px;
    }

    .gam-toast-container {
        left: 20px;
        right: 20px;
        bottom: 80px;
    }

    .gam-toast {
        width: 100%;
    }

    .gam-levelup-content {
        padding: 30px 40px;
        margin: 20px;
    }

    .gam-levelup-level {
        font-size: 56px;
    }
}

@media (max-width: 480px) {
    .gamification-widget {
        padding: 4px 10px;
    }

    .gam-level-badge {
        width: 32px;
        height: 32px;
        font-size: 12px;
    }

    .gam-xp-info {
        display: none;
    }

    .gam-stats-row {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }

    .gam-stat-value {
        font-size: 16px;
    }

    .gam-achievements-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* ═══════════════════════════════════════════════════════════════
   LEADERBOARD
   ═══════════════════════════════════════════════════════════════ */

.gam-leaderboard {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.gam-leaderboard-header {
    display: grid;
    grid-template-columns: 50px 1fr 70px 90px;
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    font-size: 12px;
    color: var(--text-secondary, #8b8b8b);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.gam-leaderboard-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.gam-leaderboard-row {
    display: grid;
    grid-template-columns: 50px 1fr 70px 90px;
    align-items: center;
    padding: 12px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 8px;
    transition: background 0.2s;
}

.gam-leaderboard-row:hover {
    background: rgba(255, 255, 255, 0.06);
}

.gam-leaderboard-row.top-3 {
    background: linear-gradient(135deg, rgba(255, 215, 0, 0.1) 0%, rgba(255, 215, 0, 0.02) 100%);
}

.gam-lb-rank {
    font-weight: 600;
    color: var(--text-secondary, #8b8b8b);
}

.gam-lb-rank.medal {
    font-size: 20px;
}

.gam-lb-player {
    display: flex;
    align-items: center;
    gap: 8px;
}

.gam-lb-username {
    font-weight: 500;
    color: var(--text-primary, #fff);
}

.gam-lb-streak {
    font-size: 12px;
    color: #ff6b35;
    background: rgba(255, 107, 53, 0.15);
    padding: 2px 6px;
    border-radius: 10px;
}

.gam-lb-level {
    text-align: center;
    font-weight: 600;
    color: var(--primary-color, #ffcb05);
}

.gam-lb-xp {
    text-align: right;
    font-weight: 500;
    color: var(--text-primary, #fff);
}

.gam-empty-hint {
    font-size: 12px;
    color: var(--text-secondary, #8b8b8b);
    margin-top: 8px;
}

@media (max-width: 480px) {
    .gam-leaderboard-header,
    .gam-leaderboard-row {
        grid-template-columns: 40px 1fr 50px 70px;
        padding: 8px;
    }

    .gam-lb-rank.medal {
        font-size: 16px;
    }

    .gam-lb-streak {
        display: none;
    }
}

/* ═══════════════════════════════════════════════════════════════
   SETTINGS
   ═══════════════════════════════════════════════════════════════ */

.gam-settings {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.gam-setting-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 12px;
    gap: 16px;
}

.gam-setting-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
}

.gam-setting-label {
    font-weight: 600;
    font-size: 15px;
    color: #ffffff;
}

.gam-setting-desc {
    font-size: 13px;
    color: #b0b0b0;
    line-height: 1.4;
}

/* Toggle Switch - Settings */
.gam-settings .gam-toggle {
    position: relative !important;
    display: inline-block !important;
    width: 52px !important;
    height: 28px !important;
    flex-shrink: 0 !important;
    background: none !important;
    border: none !important;
    padding: 0 !important;
    margin: 0 !important;
}

.gam-settings .gam-toggle input[type="checkbox"] {
    position: absolute !important;
    opacity: 0 !important;
    width: 0 !important;
    height: 0 !important;
    pointer-events: none !important;
    display: none !important;
}

.gam-settings .gam-toggle-slider {
    position: absolute !important;
    cursor: pointer !important;
    top: 0 !important;
    left: 0 !important;
    width: 52px !important;
    height: 28px !important;
    background-color: #4a4a5a !important;
    border-radius: 28px !important;
    transition: background-color 0.3s ease !important;
    border: none !important;
}

.gam-settings .gam-toggle-slider:before {
    position: absolute !important;
    content: "" !important;
    height: 22px !important;
    width: 22px !important;
    left: 3px !important;
    top: 3px !important;
    background-color: #999 !important;
    border-radius: 50% !important;
    transition: transform 0.3s ease, background-color 0.3s ease !important;
}

.gam-settings .gam-toggle input[type="checkbox"]:checked + .gam-toggle-slider {
    background-color: #22c55e !important;
}

.gam-settings .gam-toggle input[type="checkbox"]:checked + .gam-toggle-slider:before {
    transform: translateX(24px) !important;
    background-color: #fff !important;
}

/* Masquer le ::after qui crée un deuxième cercle */
.gam-settings .gam-toggle::after {
    display: none !important;
    content: none !important;
}
