/* ============================================
   PROFIL-XP.CSS - Extension XP/Niveau/Récompenses (ULTRA)
   À ajouter après profil.css
   ============================================ */

/* ============================================
   SECTION XP & NIVEAU
   ============================================ */
.xp-section {
    padding: 0 0 30px;
}

/* Premium Card */
.xp-card {
    background: linear-gradient(165deg, #151515 0%, #0a0a0a 50%, #0d0d0d 100%);
    border-radius: 20px;
    padding: 24px;
    position: relative;
    overflow: hidden;
    border: 1px solid #1a1a1a;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
}

/* Gold top line */
.xp-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 20%;
    right: 20%;
    height: 1px;
    background: linear-gradient(90deg, transparent, #d4af37, transparent);
    opacity: 0.5;
}

/* Subtle glow */
.xp-card::after {
    content: '';
    position: absolute;
    top: -100px;
    left: 50%;
    transform: translateX(-50%);
    width: 300px;
    height: 200px;
    background: radial-gradient(ellipse, rgba(212, 175, 55, 0.06) 0%, transparent 70%);
    pointer-events: none;
}

/* Header */
.xp-header {
    display: flex;
    align-items: center;
    gap: 18px;
    margin-bottom: 24px;
    position: relative;
    z-index: 1;
}

/* Level Badge */
.level-badge-container {
    position: relative;
    width: 80px;
    height: 80px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.badge-outer-ring {
    position: absolute;
    border-radius: 50%;
    pointer-events: none;
}

.badge-glow-ring {
    position: absolute;
    border-radius: 50%;
    pointer-events: none;
}

.badge-shimmer,
.badge-pulse,
.badge-rays {
    position: absolute;
    border-radius: 50%;
    pointer-events: none;
    display: none;
}

.particles {
    position: absolute;
    border-radius: 50%;
    pointer-events: none;
}

.particle {
    position: absolute;
}

.level-badge {
    position: relative;
    width: 60px;
    height: 60px;
    background: linear-gradient(145deg, #1a1a1a 0%, #0a0a0a 100%);
    border-radius: 50%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border: 2px solid #333;
    box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.5);
    z-index: 2;
}

.level-label {
    font-size: 8px;
    font-weight: 700;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: #555;
}

.level-number {
    font-size: 26px;
    font-weight: 700;
    color: #888;
    line-height: 1;
}

/* Badge Edit Button (pencil) */
.badge-edit-btn {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 22px;
    height: 22px;
    background: linear-gradient(145deg, #2a2a2a, #1a1a1a);
    border: 1.5px solid rgba(212, 175, 55, 0.5);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 5;
    color: #d4af37;
    transition: transform 0.15s, box-shadow 0.15s;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
    padding: 0;
}

.badge-edit-btn:active {
    transform: scale(0.9);
}

/* ============================================
   BADGE STYLE PICKER (Fullscreen Gallery)
   ============================================ */
.badge-picker-fullscreen {
    position: fixed;
    inset: 0;
    z-index: 1500;
    background: #050505;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.badge-picker-close {
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 1501;
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    color: #888;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
    padding: 0;
}

.badge-picker-close:active {
    background: rgba(255, 255, 255, 0.16);
    color: #fff;
}

.badge-picker-header {
    padding: 24px 16px 0;
    text-align: center;
}

.badge-picker-title {
    font-size: 13px;
    font-weight: 600;
    color: #d4af37;
    letter-spacing: 2px;
    text-transform: uppercase;
}

.badge-picker-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 14px;
    padding: 20px 16px 40px;
}

/* Showcase card */
.picker-showcase {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 24px 8px 16px;
    background: linear-gradient(165deg, #0a0a0a 0%, #050505 100%);
    border-radius: 20px;
    border: 2px solid #1a1a1a;
    position: relative;
    overflow: hidden;
    cursor: pointer;
    transition: border-color 0.25s, box-shadow 0.25s;
    -webkit-tap-highlight-color: transparent;
}

.picker-showcase:active {
    transform: scale(0.97);
}

.picker-showcase.active {
    border-color: rgba(212, 175, 55, 0.5);
    box-shadow: 0 0 20px rgba(212, 175, 55, 0.1);
}

/* Badge wrapper — scales the 80px badge up for display */
.picker-badge-wrapper {
    position: relative;
    width: 120px;
    height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 12px;
    overflow: visible;
}

.picker-badge-wrapper .level-badge-container {
    width: 80px;
    height: 80px;
    transform: scale(1.35);
}

.picker-badge-wrapper .level-badge {
    width: 60px;
    height: 60px;
}

.picker-badge-wrapper .level-number {
    font-size: 26px;
}

/* Card name */
.picker-card-name {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: #666;
    text-align: center;
}

.picker-showcase.active .picker-card-name {
    color: #d4af37;
}

/* Disruptif separator */
.badge-picker-separator {
    grid-column: 1 / -1;
    text-align: center;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 3px;
    text-transform: uppercase;
    color: #ff0040;
    padding: 16px 0 4px;
    border-top: 1px solid rgba(255, 0, 64, 0.2);
    margin-top: 8px;
}

/* Disruptif card — full width, larger badge */
.picker-showcase.disruptif {
    grid-column: 1 / -1;
    border-color: rgba(255, 0, 64, 0.15);
    padding: 32px 16px 20px;
}

.picker-showcase.disruptif .picker-badge-wrapper {
    width: 180px;
    height: 180px;
}

.picker-showcase.disruptif .picker-badge-wrapper .level-badge-container {
    transform: scale(2);
}

.picker-showcase.disruptif.active {
    border-color: rgba(255, 0, 64, 0.5);
    box-shadow: 0 0 25px rgba(255, 0, 64, 0.1);
}

.picker-showcase.disruptif.active .picker-card-name {
    color: #ff0040;
}

.picker-card-tier {
    font-size: 9px;
    font-weight: 600;
    color: #ff0040;
    letter-spacing: 2px;
    text-transform: uppercase;
    margin-top: 4px;
}

/* Info */
.xp-info { flex: 1; }

.xp-rank-title {
    font-size: 16px;
    font-weight: 600;
    color: #fff;
    margin-bottom: 4px;
}

.xp-next-level {
    font-size: 12px;
    color: var(--text-secondary, #888);
}

.xp-next-level strong {
    color: #d4af37;
}

/* ============================================
   XP BAR
   ============================================ */
.xp-bar-section {
    position: relative;
    z-index: 1;
    margin-bottom: 8px;
}

.xp-bar-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 10px;
}

.xp-label {
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    color: #666;
}

.xp-values {
    font-size: 14px;
    font-weight: 600;
    color: #d4af37;
}

.xp-bar-track {
    height: 12px;
    background: #0a0a0a;
    border-radius: 6px;
    overflow: hidden;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.5);
}

.xp-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #a67c00, #d4af37, #f4e4a6, #d4af37, #a67c00);
    background-size: 200% 100%;
    border-radius: 6px;
    animation: xp-shimmer 2.5s ease-in-out infinite;
    box-shadow: 0 0 12px rgba(212, 175, 55, 0.4);
    position: relative;
    transition: width 0.8s ease;
}

/* Gloss effect */
.xp-bar-fill::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 50%;
    background: linear-gradient(180deg, rgba(255,255,255,0.25) 0%, transparent 100%);
    border-radius: 6px 6px 0 0;
}

@keyframes xp-shimmer {
    0%, 100% { background-position: 200% center; }
    50% { background-position: 0% center; }
}

/* ============================================
   MINI CHEST BUTTON
   ============================================ */
.xp-chest-wrapper {
    position: absolute;
    bottom: -6px;
    right: 0;
    z-index: 10;
}

.xp-chest-btn {
    width: 44px;
    height: 44px;
    background: linear-gradient(145deg, #1c1c1c, #0d0d0d);
    border-radius: 12px;
    border: none;
    cursor: pointer;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.15s;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
}

.xp-chest-btn:active { transform: scale(0.92); }

/* Gold border */
.xp-chest-btn::before {
    content: '';
    position: absolute;
    inset: -1.5px;
    border-radius: 13px;
    background: linear-gradient(145deg, #d4af37, #a67c00, #d4af37);
    z-index: -1;
    opacity: 0.6;
}

.xp-chest-btn.has-chest {
    animation: chest-glow 2s ease-in-out infinite;
}

@keyframes chest-glow {
    0%, 100% { box-shadow: 0 4px 12px rgba(0,0,0,0.5), 0 0 15px rgba(212,175,55,0.15); }
    50% { box-shadow: 0 4px 12px rgba(0,0,0,0.5), 0 0 25px rgba(212,175,55,0.35); }
}

.chest-icon { width: 28px; height: 28px; }

.chest-count {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    background: linear-gradient(145deg, #ff5555, #cc3333);
    border-radius: 9px;
    font-size: 10px;
    font-weight: 700;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--bg-primary, #0a0a0a);
    font-family: inherit;
}

/* ============================================
   STATS ROW
   ============================================ */
.xp-stats {
    display: flex;
    justify-content: space-between;
    padding: 20px 10px 0;
    margin-top: 20px;
    border-top: 1px solid rgba(255,255,255,0.04);
    position: relative;
    z-index: 1;
}

.stat-item { text-align: center; flex: 1; }
.stat-item:not(:last-child) { border-right: 1px solid rgba(255,255,255,0.04); }

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

.stat-label {
    font-size: 9px;
    font-weight: 600;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: #555;
    margin-top: 6px;
}


/* ============================================
   "VOIR RÉCOMPENSES" LINK
   ============================================ */
.xp-rewards-link {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    margin-top: 16px;
    padding: 12px;
    background: rgba(212, 175, 55, 0.06);
    border: 1px solid rgba(212, 175, 55, 0.2);
    border-radius: 12px;
    color: var(--color-rare, #d4af37);
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    position: relative;
    z-index: 1;
    transition: background 0.2s, border-color 0.2s;
}

.xp-rewards-link:active {
    background: rgba(212, 175, 55, 0.12);
    border-color: rgba(212, 175, 55, 0.4);
}

.xp-rewards-link svg {
    flex-shrink: 0;
}

/* ============================================
   REWARDS FULLSCREEN VIEW (LANDSCAPE)
   ============================================ */
.rewards-fullscreen {
    position: fixed;
    inset: 0;
    background: #050505;
    z-index: 2000;
    overflow: hidden;
    color: #fff;
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', Roboto, sans-serif;
}

/* Rotate hint (portrait only) */
.rv-rotate-hint {
    display: none;
    position: absolute;
    inset: 0;
    background: #0a0a0a;
    z-index: 2001;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 20px;
}

.rv-rotate-hint svg {
    animation: rv-rotate-phone 2s ease-in-out infinite;
}

@keyframes rv-rotate-phone {
    0%, 100% { transform: rotate(0deg); }
    50% { transform: rotate(90deg); }
}

.rv-rotate-hint p {
    color: #888;
    font-size: 14px;
}

@media (orientation: portrait) {
    .rv-rotate-hint { display: flex; }
    .rv-container { display: none !important; }
}

/* Main grid container */
.rv-container {
    width: 100%;
    height: 100%;
    display: grid;
    grid-template-columns: 380px 1fr;
    position: relative;
    overflow: hidden;
}

/* Background textures */
.rv-container::before {
    content: '';
    position: absolute;
    inset: 0;
    background:
        radial-gradient(ellipse at 20% 50%, rgba(212, 175, 55, 0.03) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 30%, rgba(212, 175, 55, 0.02) 0%, transparent 40%);
    pointer-events: none;
}

.rv-container::after {
    content: '';
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(rgba(212, 175, 55, 0.02) 1px, transparent 1px),
        linear-gradient(90deg, rgba(212, 175, 55, 0.02) 1px, transparent 1px);
    background-size: 50px 50px;
    pointer-events: none;
    opacity: 0.5;
}

/* Close button */
.rv-close {
    position: absolute;
    top: 16px;
    right: 16px;
    z-index: 10;
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.08);
    border: none;
    border-radius: 50%;
    color: #888;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}

.rv-close:active {
    background: rgba(255, 255, 255, 0.16);
    color: #fff;
}

/* ---- LEFT PANEL ---- */
.rv-left {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 30px;
    position: relative;
    border-right: 1px solid rgba(212, 175, 55, 0.1);
}

.rv-user-name {
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 3px;
    text-transform: uppercase;
    color: #888;
    margin-bottom: 24px;
}

/* Badge container */
.rv-badge-container {
    position: relative;
    width: 220px;
    height: 220px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Scale the standard 80px badge up — badge circle becomes ~160px */
.rv-badge-container .level-badge-container {
    width: 80px;
    height: 80px;
    transform: scale(2.7);
}

.rv-badge-container .level-badge {
    width: 60px;
    height: 60px;
}

.rv-badge-container .level-number {
    font-size: 26px;
}

/* Wings */
.rv-wing {
    position: absolute;
    width: 50px;
    height: 70px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 1;
}

.rv-wing svg {
    width: 100%;
    height: 100%;
}

.rv-wing-left {
    right: 100%;
    margin-right: -6px;
}

.rv-wing-right {
    left: 100%;
    margin-left: -6px;
    transform: translateY(-50%) scaleX(-1);
}

/* Level title below badge */
.rv-level-title {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 3px;
    text-transform: uppercase;
    color: #d4af37;
    margin-top: 12px;
    text-align: center;
}

/* XP section */
.rv-xp {
    width: 100%;
    max-width: 260px;
    margin-top: 24px;
}

.rv-xp-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}

.rv-xp-label {
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: #666;
}

.rv-xp-values {
    font-size: 12px;
    color: #d4af37;
    font-weight: 500;
}

.rv-xp-bar {
    height: 22px;
    background: #111;
    border-radius: 11px;
    border: 1px solid #222;
    overflow: hidden;
    box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.5);
}

.rv-xp-fill {
    height: 100%;
    background: linear-gradient(90deg, #a67c00, #d4af37, #f4e4a6, #d4af37);
    background-size: 200% 100%;
    border-radius: 11px;
    animation: xp-shimmer 3s ease-in-out infinite;
    transition: width 1s ease;
}

/* Stats */
.rv-stats {
    display: flex;
    gap: 24px;
    margin-top: 24px;
}

.rv-stat { text-align: center; }

.rv-stat-value {
    font-size: 22px;
    font-weight: 600;
    color: #fff;
}

.rv-stat-label {
    font-size: 9px;
    font-weight: 500;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: #555;
    margin-top: 2px;
}

/* ---- RIGHT PANEL ---- */
.rv-right {
    padding: 24px 30px;
    overflow-y: auto;
    position: relative;
}

.rv-panel-header {
    margin-bottom: 20px;
}

.rv-panel-title {
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 3px;
    text-transform: uppercase;
    color: #d4af37;
}

/* Privileges */
.rv-privileges {
    margin-bottom: 24px;
}

.rv-section-title {
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: #555;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.rv-section-title::after {
    content: '';
    flex: 1;
    height: 1px;
    background: linear-gradient(90deg, #333, transparent);
}

.rv-privileges-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.rv-priv {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: rgba(255, 255, 255, 0.02);
    border-radius: 10px;
    border: 1px solid #1a1a1a;
}

.rv-priv-icon {
    width: 30px;
    height: 30px;
    background: linear-gradient(145deg, #1a1a1a, #0d0d0d);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    border: 1px solid #222;
    flex-shrink: 0;
}

.rv-priv-info { flex: 1; min-width: 0; }

.rv-priv-name {
    font-size: 11px;
    font-weight: 500;
    color: #ccc;
    margin-bottom: 1px;
}

.rv-priv-value {
    font-size: 10px;
    color: #4ade80;
}

.rv-priv.locked { opacity: 0.4; }
.rv-priv.locked .rv-priv-value { color: #555; }

.rv-priv.new { position: relative; }

.rv-priv.new::before {
    content: 'NEW';
    position: absolute;
    top: -5px;
    right: -4px;
    font-size: 7px;
    font-weight: bold;
    background: #4ade80;
    color: #000;
    padding: 2px 5px;
    border-radius: 4px;
}

/* Rewards */
.rv-rewards {
    background: rgba(212, 175, 55, 0.03);
    border-radius: 14px;
    padding: 16px;
    border: 1px solid rgba(212, 175, 55, 0.1);
    margin-bottom: 20px;
}

.rv-rewards-header { margin-bottom: 12px; }

.rv-rewards-title {
    font-size: 13px;
    font-weight: 600;
    color: #d4af37;
}

.rv-rewards-subtitle {
    font-size: 10px;
    color: #666;
    margin-top: 2px;
}

.rv-rewards-grid {
    display: flex;
    gap: 10px;
}

.rv-reward {
    width: 76px;
    height: 76px;
    background: linear-gradient(145deg, #1a1a1a, #0d0d0d);
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border: 2px solid #222;
    position: relative;
    cursor: pointer;
    transition: all 0.2s;
}

.rv-reward:active {
    transform: scale(0.95);
}

.rv-reward.available {
    border-color: rgba(212, 175, 55, 0.4);
    box-shadow: 0 0 18px rgba(212, 175, 55, 0.1);
}

.rv-reward.available::before {
    content: '';
    position: absolute;
    inset: -2px;
    border-radius: 14px;
    background: conic-gradient(from 0deg, transparent, rgba(212, 175, 55, 0.3), transparent, transparent);
    animation: rv-glow-rotate 4s linear infinite;
    z-index: -1;
}

.rv-reward-icon {
    font-size: 26px;
    margin-bottom: 2px;
}

.rv-reward-label {
    font-size: 8px;
    color: #666;
    text-align: center;
}

.rv-reward.locked { opacity: 0.4; }

.rv-lock-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
}

/* Next level */
.rv-next-level {
    padding: 14px;
    background: rgba(255, 255, 255, 0.02);
    border-radius: 12px;
    border: 1px solid #1a1a1a;
}

.rv-next-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.rv-next-title {
    font-size: 10px;
    font-weight: 600;
    color: #888;
    letter-spacing: 1px;
    text-transform: uppercase;
}

.rv-next-xp {
    font-size: 11px;
    color: #d4af37;
}

.rv-next-unlocks {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.rv-unlock-tag {
    font-size: 10px;
    padding: 4px 10px;
    background: rgba(212, 175, 55, 0.1);
    border: 1px solid rgba(212, 175, 55, 0.2);
    border-radius: 20px;
    color: #d4af37;
    white-space: nowrap;
}


/* ============================================
   FLASH OVERLAY
   ============================================ */
.flash-overlay {
    position: fixed;
    inset: 0;
    background: radial-gradient(circle at center, rgba(255, 255, 255, 0.95), rgba(244, 228, 166, 0.8));
    opacity: 0;
    pointer-events: none;
    z-index: 3000;
}

.flash-overlay.flash {
    animation: flash-bang 0.5s ease-out forwards;
}

@keyframes flash-bang {
    0% { opacity: 0; }
    15% { opacity: 1; }
    100% { opacity: 0; }
}

/* ============================================
   CONFETTI CANVAS
   ============================================ */
#chest-confetti {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 2500;
}

/* ============================================
   CHEST MODAL (ULTRA)
   ============================================ */
#chest-modal {
    padding: 24px;
}

#chest-modal .modal-backdrop {
    background: rgba(0, 0, 0, 0.92);
    backdrop-filter: blur(12px);
}

.chest-modal-container {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 360px;
}

/* Screen shake */
.chest-modal-container.shake {
    animation: screen-shake 0.6s ease-out;
}

@keyframes screen-shake {
    0%, 100% { transform: translateX(0) rotate(0); }
    10% { transform: translateX(-8px) rotate(-1deg); }
    20% { transform: translateX(8px) rotate(1deg); }
    30% { transform: translateX(-6px) rotate(-0.5deg); }
    40% { transform: translateX(6px) rotate(0.5deg); }
    50% { transform: translateX(-4px) rotate(-0.3deg); }
    60% { transform: translateX(4px) rotate(0.3deg); }
    70% { transform: translateX(-2px) rotate(0); }
    80% { transform: translateX(2px) rotate(0); }
}

#chest-modal .modal-content {
    background: linear-gradient(165deg, #1a1a1a 0%, #0d0d0d 100%);
    border: 1px solid #2a2a2a;
    border-radius: 24px;
    padding: 36px 28px 32px;
    text-align: center;
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.6);
    position: relative;
    overflow: hidden;
}

#chest-modal .modal-content::before {
    content: '';
    position: absolute;
    top: 0;
    left: 15%;
    right: 15%;
    height: 1px;
    background: linear-gradient(90deg, transparent, #d4af37, transparent);
    opacity: 0.6;
}

/* ============================================
   CHEST STAGE
   ============================================ */
.chest-stage {
    width: 180px;
    height: 180px;
    margin: 0 auto 24px;
    position: relative;
    cursor: pointer;
    perspective: 600px;
}

.chest-model {
    width: 100%;
    height: 100%;
    position: relative;
    transform-style: preserve-3d;
    transition: transform 0.3s ease;
}

.chest-stage:hover .chest-model {
    transform: rotateY(-5deg) rotateX(3deg) scale(1.02);
}

.chest-stage.opened .chest-model {
    animation: chest-bounce 0.5s ease-out;
}

@keyframes chest-bounce {
    0% { transform: scale(1); }
    30% { transform: scale(1.1); }
    50% { transform: scale(0.95); }
    70% { transform: scale(1.03); }
    100% { transform: scale(1); }
}

.chest-svg {
    width: 100%;
    height: 100%;
    filter: drop-shadow(0 15px 40px rgba(0, 0, 0, 0.6)) drop-shadow(0 5px 20px rgba(212, 175, 55, 0.2));
}

.chest-lid {
    transform-origin: 50% 95%;
    transition: transform 0.7s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.chest-stage.opened .chest-lid {
    transform: rotateX(-120deg);
}

/* God rays */
.god-rays {
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 300px;
    height: 300px;
    opacity: 0;
    pointer-events: none;
    background:
        conic-gradient(from 0deg at 50% 100%,
            transparent 0deg,
            rgba(244, 228, 166, 0.4) 5deg,
            transparent 10deg,
            transparent 20deg,
            rgba(244, 228, 166, 0.3) 25deg,
            transparent 30deg,
            transparent 45deg,
            rgba(244, 228, 166, 0.35) 50deg,
            transparent 55deg,
            transparent 70deg,
            rgba(244, 228, 166, 0.3) 75deg,
            transparent 80deg,
            transparent 90deg
        );
    filter: blur(2px);
}

.chest-stage.opened .god-rays {
    animation: rays-appear 1.5s ease-out forwards;
}

@keyframes rays-appear {
    0% { opacity: 0; transform: translateX(-50%) translateY(20px) scale(0.5); }
    30% { opacity: 1; }
    100% { opacity: 0; transform: translateX(-50%) translateY(-50px) scale(1.5); }
}

/* Central glow burst */
.glow-burst {
    position: absolute;
    top: 25%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 20px;
    height: 20px;
    border-radius: 50%;
    opacity: 0;
    pointer-events: none;
}

.chest-stage.opened .glow-burst {
    animation: glow-explode 0.8s ease-out forwards;
}

@keyframes glow-explode {
    0% {
        opacity: 1;
        width: 20px;
        height: 20px;
        box-shadow:
            0 0 20px 10px rgba(255, 255, 255, 0.9),
            0 0 40px 20px rgba(244, 228, 166, 0.8),
            0 0 80px 40px rgba(212, 175, 55, 0.6),
            0 0 120px 60px rgba(212, 175, 55, 0.3);
    }
    100% {
        opacity: 0;
        width: 200px;
        height: 200px;
        box-shadow:
            0 0 30px 15px rgba(255, 255, 255, 0),
            0 0 60px 30px rgba(244, 228, 166, 0),
            0 0 100px 50px rgba(212, 175, 55, 0),
            0 0 150px 75px rgba(212, 175, 55, 0);
    }
}

/* Sparkles */
.sparkles {
    position: absolute;
    top: 30%;
    left: 50%;
    transform: translateX(-50%);
    pointer-events: none;
}

.sparkle {
    position: absolute;
    width: 10px;
    height: 10px;
    opacity: 0;
}

.sparkle::before, .sparkle::after {
    content: '';
    position: absolute;
    background: #f4e4a6;
}

.sparkle::before {
    width: 100%;
    height: 2px;
    top: 50%;
    transform: translateY(-50%);
    border-radius: 1px;
}

.sparkle::after {
    width: 2px;
    height: 100%;
    left: 50%;
    transform: translateX(-50%);
    border-radius: 1px;
}

.chest-stage.opened .sparkle {
    animation: sparkle-fly 0.9s ease-out forwards;
}

@keyframes sparkle-fly {
    0% { opacity: 1; transform: translate(0, 0) scale(1) rotate(0deg); }
    100% { opacity: 0; transform: translate(var(--x), var(--y)) scale(0) rotate(180deg); }
}

.sparkle:nth-child(1) { --x: -70px; --y: -90px; animation-delay: 0.05s; }
.sparkle:nth-child(2) { --x: 70px; --y: -80px; animation-delay: 0.08s; }
.sparkle:nth-child(3) { --x: -45px; --y: -110px; animation-delay: 0.11s; }
.sparkle:nth-child(4) { --x: 45px; --y: -100px; animation-delay: 0.14s; }
.sparkle:nth-child(5) { --x: -95px; --y: -50px; animation-delay: 0.06s; }
.sparkle:nth-child(6) { --x: 95px; --y: -55px; animation-delay: 0.1s; }
.sparkle:nth-child(7) { --x: -30px; --y: -125px; animation-delay: 0.15s; }
.sparkle:nth-child(8) { --x: 30px; --y: -120px; animation-delay: 0.18s; }
.sparkle:nth-child(9) { --x: 0px; --y: -135px; animation-delay: 0.12s; }
.sparkle:nth-child(10) { --x: -110px; --y: -25px; animation-delay: 0.09s; }
.sparkle:nth-child(11) { --x: 110px; --y: -30px; animation-delay: 0.13s; }
.sparkle:nth-child(12) { --x: -60px; --y: -70px; animation-delay: 0.2s; }
.sparkle:nth-child(13) { --x: 60px; --y: -65px; animation-delay: 0.22s; }
.sparkle:nth-child(14) { --x: -80px; --y: -40px; animation-delay: 0.16s; }
.sparkle:nth-child(15) { --x: 80px; --y: -45px; animation-delay: 0.19s; }

/* Floating coins */
.coins {
    position: absolute;
    top: 35%;
    left: 50%;
    transform: translateX(-50%);
    pointer-events: none;
}

.coin {
    position: absolute;
    width: 16px;
    height: 16px;
    background: radial-gradient(circle at 30% 30%, #f4e4a6, #d4af37, #a67c00);
    border-radius: 50%;
    opacity: 0;
    box-shadow: inset -2px -2px 4px rgba(0,0,0,0.3), 0 2px 8px rgba(212,175,55,0.5);
}

.chest-stage.opened .coin {
    animation: coin-fly 1s ease-out forwards;
}

@keyframes coin-fly {
    0% { opacity: 1; transform: translate(0, 0) rotateY(0deg) scale(1); }
    100% { opacity: 0; transform: translate(var(--x), var(--y)) rotateY(720deg) scale(0.5); }
}

.coin:nth-child(1) { --x: -50px; --y: -100px; animation-delay: 0.1s; }
.coin:nth-child(2) { --x: 50px; --y: -90px; animation-delay: 0.15s; }
.coin:nth-child(3) { --x: -30px; --y: -120px; animation-delay: 0.2s; }
.coin:nth-child(4) { --x: 30px; --y: -110px; animation-delay: 0.25s; }
.coin:nth-child(5) { --x: 0px; --y: -130px; animation-delay: 0.18s; }
.coin:nth-child(6) { --x: -70px; --y: -70px; animation-delay: 0.22s; }
.coin:nth-child(7) { --x: 70px; --y: -75px; animation-delay: 0.28s; }
.coin:nth-child(8) { --x: -20px; --y: -95px; animation-delay: 0.3s; }

/* Modal text */
.chest-modal-title {
    font-size: 22px;
    font-weight: 700;
    color: #fff;
    margin-bottom: 4px;
}

.chest-modal-subtitle {
    font-size: 13px;
    color: #666;
    margin-bottom: 28px;
    transition: color 0.3s;
}

.chest-modal-subtitle.success {
    color: #d4af37;
}

/* Rewards row */
.rewards-row {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin-bottom: 24px;
    opacity: 0;
    transform: translateY(25px) scale(0.9);
    transition: all 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

.rewards-row.visible {
    opacity: 1;
    transform: translateY(0) scale(1);
}

.reward-item {
    width: 90px;
    padding: 16px 10px 14px;
    background: linear-gradient(165deg, #1f1f1f 0%, #111 100%);
    border-radius: 16px;
    border: 1px solid #2a2a2a;
    position: relative;
    overflow: hidden;
    transition: transform 0.3s, box-shadow 0.3s;
}

.rewards-row.visible .reward-item {
    animation: reward-pop 0.5s ease-out backwards;
}

.reward-item:nth-child(1) { animation-delay: 0.1s; }
.reward-item:nth-child(2) { animation-delay: 0.2s; }
.reward-item:nth-child(3) { animation-delay: 0.3s; }

@keyframes reward-pop {
    0% { transform: scale(0) rotate(-10deg); opacity: 0; }
    60% { transform: scale(1.1) rotate(3deg); }
    100% { transform: scale(1) rotate(0deg); opacity: 1; }
}

.reward-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: 20%;
    right: 20%;
    height: 1px;
    background: linear-gradient(90deg, transparent, #d4af37, transparent);
    opacity: 0.4;
}

.reward-icon {
    font-size: 32px;
    margin-bottom: 8px;
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.3));
}

.reward-amount {
    font-size: 18px;
    font-weight: 700;
    color: #d4af37;
}

.reward-label {
    font-size: 9px;
    font-weight: 600;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    color: #555;
    margin-top: 4px;
}

/* Claim Button */
.claim-btn {
    width: 100%;
    padding: 16px;
    background: linear-gradient(145deg, #d4af37, #a67c00);
    border: none;
    border-radius: 14px;
    font-size: 14px;
    font-weight: 700;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    color: #000;
    cursor: pointer;
    font-family: inherit;
    position: relative;
    overflow: hidden;
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.5s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: 0 4px 20px rgba(212, 175, 55, 0.3);
}

.claim-btn.visible {
    opacity: 1;
    transform: translateY(0);
}

.claim-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.4), transparent);
    animation: btn-shimmer 2s ease-in-out infinite;
}

@keyframes btn-shimmer {
    0%, 100% { left: -100%; }
    50% { left: 100%; }
}

.claim-btn:active {
    transform: scale(0.97);
}


/* ============================================
   RESPONSIVE ADJUSTMENTS
   ============================================ */
@media (max-width: 600px) {
    .level-badge-container {
        width: 72px;
        height: 72px;
    }

    .level-badge {
        width: 54px;
        height: 54px;
    }

    .level-number {
        font-size: 22px;
    }

    .badge-edit-btn {
        width: 20px;
        height: 20px;
    }

    .xp-bar-track {
        height: 10px;
    }

    .xp-chest-btn {
        width: 40px;
        height: 40px;
    }

    .chest-icon {
        width: 24px;
        height: 24px;
    }

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

    .xp-rank-title {
        font-size: 14px;
    }

}
