/* =========================================
   1. CONFIGURATION GÉNÉRALE (CORE)
   ========================================= */
html {
    position: relative;
    overflow-x: hidden;
    overflow-y: auto;
}

body { 
    font-family: 'Lato', sans-serif; 
    background: #1e272e; 
    color: white; 
    display: flex; 
    flex-direction: column; 
    align-items: center; 
    margin: 0; 
    padding: 5px; 
    user-select: none; 
    min-height: 100vh;
    overflow-x: hidden; 
    overflow-y: auto; /* Permettre le scroll vertical si nécessaire */
    -webkit-tap-highlight-color: transparent; 
    position: relative; /* Pour le positionnement absolu du bouton Paramètres */
}

/* Transitions */
.screen {
    display: none;
    width: 100%;
    max-width: 1200px;
    animation: fadeIn 0.3s ease-out;
    position: relative;
    margin: 0 auto;
    padding-top: 115px !important; /* Espace pour settings (60px) + bouton close (55px) */
    box-sizing: border-box;
}

/* Le world-screen n'a pas de bouton close — juste l'espace pour le bloc settings */
#world-screen {
    padding-top: 65px !important;
}

.active-screen { 
    display: flex; 
    flex-direction: column; 
    align-items: center; 
    margin: 0 auto; /* Centrer le screen */
}

@keyframes fadeIn { 
    from { opacity: 0; transform: translateY(10px); } 
    to { opacity: 1; transform: translateY(0); } 
}

@keyframes fadeInOut {
    0% { opacity: 0; transform: scale(0.5); }
    20% { opacity: 1; transform: scale(1.2); }
    40% { opacity: 1; transform: scale(1); }
    60% { opacity: 1; transform: scale(1); }
    80% { opacity: 0.8; transform: scale(0.9); }
    100% { opacity: 0; transform: scale(0.5); }
}

/* =========================================
   2. BOUTON PARAMÈTRES
   ========================================= */
/* Conteneur wrapper pour le bouton Paramètres (positionné en haut à droite, position absolue, disparaît au scroll) */
/* IMPORTANT: Le bouton est positionné par rapport au body, donc il disparaît quand on scroll */
#settings-wrapper {
    position: absolute !important;
    top: 0 !important;
    right: 0 !important;
    left: auto !important;
    bottom: auto !important;
    width: 100% !important;
    height: 0 !important;
    z-index: 99999 !important;
    pointer-events: none !important; /* Permettre les clics à travers, sauf sur le bouton */
    margin: 0 !important;
    padding: 0 !important;
    transform: none !important;
    will-change: auto !important;
    contain: none !important;
}

#settings-selector {
    position: absolute !important;
    top: 10px !important;
    right: 10px !important;
    left: auto !important;
    bottom: auto !important;
    z-index: 99999 !important;
    font-family: 'Lato', sans-serif;
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    pointer-events: auto !important; /* Permettre les interactions sur le bouton */
    transform: none !important;
    margin: 0 !important;
    padding: 0 !important;
    will-change: auto !important;
    contain: none !important;
}

#btn-settings-toggle {
    background: #34495e;
    border: 2px solid #555;
    border-radius: 8px;
    padding: 8px 12px;
    cursor: pointer;
    font-size: 16px;
    color: #ecf0f1;
    display: flex;
    align-items: center;
    gap: 5px;
    transition: all 0.2s ease;
    font-family: 'Lato', sans-serif;
}

#btn-settings-toggle:hover {
    background: #3498db;
    border-color: #2980b9;
    transform: scale(1.05);
}

/* Bouton adresse Solana (en haut à gauche) */
#wallet-address-selector {
    position: absolute !important;
    top: 10px !important;
    left: 10px !important;
    right: auto !important;
    bottom: auto !important;
    z-index: 99999 !important;
    font-family: 'Lato', sans-serif;
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    pointer-events: auto !important;
    transform: none !important;
    margin: 0 !important;
    padding: 0 !important;
    will-change: auto !important;
    contain: none !important;
}

#btn-wallet-address {
    background: #34495e;
    border: 2px solid #555;
    border-radius: 8px;
    padding: 8px 12px;
    cursor: pointer;
    font-size: 18px;
    color: #ffffff;
    font-weight: bold;
    display: flex;
    align-items: center;
    gap: 5px;
    transition: all 0.2s ease;
    font-family: 'Lato', sans-serif;
    text-shadow: 
        -1px -1px 0 #000,
        1px -1px 0 #000,
        -1px 1px 0 #000,
        1px 1px 0 #000,
        -2px -2px 0 #000,
        2px -2px 0 #000,
        -2px 2px 0 #000,
        2px 2px 0 #000;
    white-space: nowrap;
}

#btn-wallet-address:hover {
    background: #3498db;
    border-color: #2980b9;
    transform: scale(1.05);
}

#settings-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 5px;
    background: #2c3e50;
    border: 2px solid #555;
    border-radius: 8px;
    overflow: hidden;
    min-width: 180px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.5);
    animation: fadeIn 0.2s ease-out;
    display: none;
}

.settings-section {
    padding: 10px 0;
}

.settings-section-title {
    padding: 8px 15px;
    color: #f1c40f;
    font-size: 12px;
    font-weight: bold;
    text-transform: uppercase;
    border-bottom: 1px solid #555;
    margin-bottom: 5px;
}

.language-option {
    width: 100%;
    padding: 10px 15px;
    background: #34495e;
    border: none;
    color: #ecf0f1;
    cursor: pointer;
    text-align: left;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    font-family: 'Lato', sans-serif;
    transition: background 0.2s ease;
}

.language-option:hover {
    background: #3498db;
}

.language-option:not(:first-child) {
    border-top: 1px solid #555;
}

.confirmation-option {
    width: 100%;
    padding: 10px 15px;
    background: #34495e;
    border: none;
    color: #ecf0f1;
    cursor: pointer;
    text-align: left;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    font-family: 'Lato', sans-serif;
    transition: background 0.2s ease;
}

.confirmation-option:hover {
    background: #3498db;
}

/* Cacher le bouton Paramètres pendant le combat */
#combat-screen.active-screen ~ #settings-wrapper,
#combat-screen[style*="display: flex"] ~ #settings-wrapper {
    display: none !important;
    visibility: hidden !important;
}

/* Cacher le bouton adresse Solana pendant le combat */
#combat-screen.active-screen ~ #wallet-address-selector,
#combat-screen[style*="display: flex"] ~ #wallet-address-selector {
    display: none !important;
    visibility: hidden !important;
}

/* S'assurer que le bouton est visible sur desktop */
@media (min-width: 901px) {
    #settings-wrapper {
        display: block !important;
        visibility: visible !important;
    }
    #settings-selector {
        display: block !important;
        visibility: visible !important;
        opacity: 1 !important;
    }
    #wallet-address-selector {
        display: block !important;
        visibility: visible !important;
        opacity: 1 !important;
    }
}

/* =========================================
   3. ÉCRAN DE SÉLECTION (STARTERS)
   ========================================= */
#starter-screen {
    display: none; /* Caché par défaut, affiché uniquement après connexion si nécessaire */
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 90vh;
}

.starter-container {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
    justify-content: center;
}

.starter-card {
    background: #2c3e50;
    border: 2px solid #555;
    border-radius: 15px;
    padding: 20px;
    width: 130px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    position: relative;
    overflow: hidden;
}

.starter-card:hover {
    transform: scale(1.1) translateY(-5px);
    border-color: #f1c40f;
    background: #34495e;
    box-shadow: 0 10px 20px rgba(0,0,0,0.5);
}

.starter-icon {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    margin: 0 auto 15px auto;
    font-size: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 4px solid rgba(255,255,255,0.2);
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
    position: relative;
    overflow: hidden;
    /* Les dimensions seront ajustées dynamiquement par JavaScript selon size et thickness */
}

/* =========================================
   4. UI DU MONDE
   ========================================= */
#main-app {
    display: flex;
    flex-direction: column;
    gap: 15px;
    justify-content: flex-start;
    align-items: center;
    width: 100%;
    max-width: 1100px;
    position: relative;
    margin: 0 auto; /* Centrer le main-app */
    z-index: 1; /* S'assurer que le main-app est en dessous du bouton Paramètres */
}

#world-container {
    position: relative;
    max-width: 800px; 
    width: 100%;
    height: auto;
    aspect-ratio: 1 / 1; 
    box-shadow: 0 0 30px rgba(0,0,0,0.6);
    border: 4px solid #444;
    border-radius: 12px;
    background: #2c3e50;
    overflow: hidden;
    z-index: 1; /* S'assurer que la map est en dessous du bouton Paramètres */
}

#worldCanvas {
    width: 100%;
    height: 100%;
    background-color: #34495e;
    touch-action: none;
    cursor: crosshair;
}

/* Bouton Free Spin - Open World (tour gratuit mystery box) */
#free-spin-btn {
    position: absolute;
    width: 54px;
    height: 54px;
    background: none;
    border: none;
    outline: none;
    cursor: pointer;
    padding: 0;
    z-index: 200;
    transform: translate(-50%, -50%);
    animation: freeSpin-pulse 2s ease-in-out infinite;
    transform-origin: center center;
}
#free-spin-btn img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}
@media (min-width: 769px) {
    #free-spin-btn { width: 90px; height: 90px; }
}
@keyframes freeSpin-pulse {
    0%   { opacity: 1;    transform: translate(-50%, -50%) scale(1); }
    50%  { opacity: 0.55; transform: translate(-50%, -50%) scale(0.82); }
    100% { opacity: 1;    transform: translate(-50%, -50%) scale(1); }
}

#sidebar {
    flex: 1; 
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: #222;
    padding: 15px;
    border-radius: 10px;
    border: 1px solid #444;
    min-height: 400px;
    max-width: 300px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
}

/* Boutons et minimap positionnés sur le canvas */
.world-canvas-btn {
    min-width: 110px;
    max-width: 135px;
    padding: 12px 16px;
    background: #3498db;
    color: white;
    border: 3px solid #000;
    border-radius: 6px;
    font-weight: bold;
    cursor: pointer;
    text-transform: uppercase;
    font-size: 12px;
    transition: all 0.2s;
    box-shadow: 0 3px 10px rgba(0,0,0,0.3);
    transform: translate(-50%, -50%);
    pointer-events: auto;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    white-space: nowrap;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    text-shadow: 
        -2px -2px 0 #000,
        2px -2px 0 #000,
        -2px 2px 0 #000,
        2px 2px 0 #000,
        0 -2px 0 #000,
        0 2px 0 #000,
        -2px 0 0 #000,
        2px 0 0 #000;
}

.world-canvas-btn:hover {
    filter: brightness(1.2);
    transform: translate(-50%, -50%) translateY(-2px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.4);
}

.world-canvas-btn:active {
    transform: translate(-50%, -50%) scale(0.95);
    box-shadow: 0 2px 5px rgba(0,0,0,0.3);
}

#world-minimap-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    background: transparent;
    padding: 0;
    border-radius: 0;
    border: none;
    box-shadow: none;
    transform: translate(-50%, calc(-50% - 30px));
    pointer-events: auto;
    touch-action: manipulation;
    width: fit-content;
    height: fit-content;
}

#world-minimap-container #zone-indicator {
    font-size: 12px;
    color: #ffffff;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 0;
    text-align: center;
    line-height: 1.2;
    text-shadow: 
        -2px -2px 0 #000,
        2px -2px 0 #000,
        -2px 2px 0 #000,
        2px 2px 0 #000,
        0 -2px 0 #000,
        0 2px 0 #000,
        -2px 0 0 #000,
        2px 0 0 #000,
        -1px -1px 0 #000,
        1px -1px 0 #000,
        -1px 1px 0 #000,
        1px 1px 0 #000;
}

#world-minimap-container #miniMapCanvas {
    width: 67px;
    height: 67px;
    background: #000;
    border: 2px solid #7f8c8d;
    border-radius: 4px;
    image-rendering: pixelated;
    touch-action: none;
    transition: width 0.2s ease, height 0.2s ease;
}

/* Minimap agrandie (double taille) */
#world-minimap-container.minimap-expanded {
    transform: translate(-50%, calc(-50% - 30px));
}

#world-minimap-container.minimap-expanded #miniMapCanvas {
    width: 134px;
    height: 134px;
}

#world-minimap-container.minimap-expanded #zone-indicator {
    font-size: 14px;
    line-height: 1.3;
}

/* Pop-up de minimap x10 */
#minimap-popup-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.7);
    z-index: 100005;
    justify-content: center;
    align-items: center;
}

#minimap-popup {
    background: #34495e;
    border: 3px solid #f1c40f;
    border-radius: 15px;
    padding: 20px;
    max-width: 670px;
    width: 90%;
    box-shadow: 0 15px 50px rgba(241, 196, 15, 0.3);
    cursor: pointer;
}

#minimap-popup h3 {
    color: #f1c40f;
    margin: 0 0 10px 0;
    font-size: 1.3em;
    text-align: center;
}

#zone-indicator-popup {
    color: #ecf0f1;
    font-size: 14px;
    margin-bottom: 10px;
    text-align: center;
}

#miniMapCanvasPopup {
    width: 100%;
    height: auto;
    display: block;
    border-radius: 8px;
    cursor: pointer;
}

/* Barre mobile - Masquée sur desktop */
#world-mobile-bar {
    display: none;
}

/* Barre horizontale pour mobile - Organisation en flexbox */
@media (max-width: 768px) {
    #world-mobile-bar {
        position: absolute;
        bottom: 10px;
        left: 50%;
        transform: translateX(-50%);
        width: calc(100% - 20px);
        max-width: 98%;
        display: flex !important;
        align-items: center;
        justify-content: center;
        gap: 6px;
        z-index: 1000;
        pointer-events: none;
        overflow: visible !important;
        padding: 0 5px;
        box-sizing: border-box;
    }
    
    #world-mobile-bar > * {
        pointer-events: auto;
    }
    
    #world-mobile-bar .world-canvas-btn {
        flex: 0 0 auto;
        min-width: 62px !important;
        max-width: 72px !important;
        padding: 10px 8px !important;
        font-size: 8px !important;
        border-radius: 4px;
        box-shadow: 0 2px 6px rgba(0,0,0,0.4) !important;
        border: 3px solid #000 !important;
        transform: none !important;
        position: relative !important;
        left: auto !important;
        top: auto !important;
        z-index: 1001 !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        visibility: visible !important;
        opacity: 1 !important;
        margin: 0 !important;
        text-align: center;
        line-height: 1.2;
        text-shadow: 
            -1.5px -1.5px 0 #000,
            1.5px -1.5px 0 #000,
            -1.5px 1.5px 0 #000,
            1.5px 1.5px 0 #000,
            0 -1.5px 0 #000,
            0 1.5px 0 #000,
            -1.5px 0 0 #000,
            1.5px 0 0 #000;
    }
    
    #world-mobile-bar #world-minimap-container {
        flex: 0 0 auto;
        padding: 0 !important;
        border-radius: 0;
        border: none !important;
        gap: 1px !important;
        transform: none !important;
        position: relative !important;
        left: auto !important;
        top: auto !important;
        z-index: 1000 !important;
        background: transparent !important;
        box-shadow: none !important;
        margin: 0 !important;
        width: fit-content !important;
        height: fit-content !important;
    }
    
    #world-mobile-bar #world-minimap-container #zone-indicator {
        font-size: 7px !important;
        margin: 0;
        padding: 0;
        letter-spacing: 0.3px;
        line-height: 1;
    }
    
    #world-mobile-bar #world-minimap-container #miniMapCanvas {
        width: 50px !important;
        height: 50px !important;
        margin: 0 !important;
    }
    
    #world-mobile-bar #world-minimap-container.minimap-expanded #miniMapCanvas {
        width: 100px !important;
        height: 100px !important;
    }
    
    #world-mobile-bar #world-minimap-container.minimap-expanded #zone-indicator {
        font-size: 9px !important;
    }
    
}

@media (max-width: 480px) {
    #world-mobile-bar .world-canvas-btn {
        min-width: 56px !important;
        max-width: 66px !important;
        padding: 8px 6px !important;
        font-size: 7px !important;
        border-radius: 4px;
        box-shadow: 0 2px 6px rgba(0,0,0,0.4) !important;
        border: 3px solid #000 !important;
        text-align: center;
        line-height: 1.2;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        text-shadow: 
            -1px -1px 0 #000,
            1px -1px 0 #000,
            -1px 1px 0 #000,
            1px 1px 0 #000,
            0 -1px 0 #000,
            0 1px 0 #000,
            -1px 0 0 #000,
            1px 0 0 #000;
    }
    
    #world-mobile-bar {
        gap: 5px;
        bottom: 8px;
    }
    
    #world-mobile-bar #world-minimap-container {
        padding: 0 !important;
        border: none !important;
        gap: 1px !important;
        background: transparent !important;
        box-shadow: none !important;
        margin: 0 !important;
        width: fit-content !important;
        height: fit-content !important;
    }
    
    #world-mobile-bar #world-minimap-container #zone-indicator {
        font-size: 6px !important;
        margin: 0 !important;
        padding: 0 !important;
        letter-spacing: 0.2px;
        line-height: 1 !important;
    }
    
    #world-mobile-bar #world-minimap-container #miniMapCanvas {
        width: 45px !important;
        height: 45px !important;
        margin: 0 !important;
    }
    
    #world-mobile-bar #world-minimap-container.minimap-expanded #miniMapCanvas {
        width: 90px !important;
        height: 90px !important;
    }
    
    #world-mobile-bar #world-minimap-container.minimap-expanded #zone-indicator {
        font-size: 8px !important;
    }
    
}

.sidebar-box {
    background: #2c3e50;
    border: 1px solid #555;
    border-radius: 6px;
    padding: 10px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
}

#zone-indicator {
    font-size: 13px;
    color: #f1c40f;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 5px;
}

#miniMapCanvas {
    width: 100%;
    max-width: 120px;
    aspect-ratio: 1/1;
    background: #000;
    border: 2px solid #7f8c8d;
    border-radius: 4px;
    image-rendering: pixelated; 
}

.btn-sidebar {
    width: 100%;
    padding: 12px;
    background: #3498db;
    color: white;
    border: 4px solid #000;
    border-radius: 5px;
    font-weight: bold;
    cursor: pointer;
    margin-top: 5px;
    text-transform: uppercase;
    font-size: 12px;
    transition: 0.2s;
    text-shadow: 
        -2px -2px 0 #000,
        2px -2px 0 #000,
        -2px 2px 0 #000,
        2px 2px 0 #000,
        0 -2px 0 #000,
        0 2px 0 #000,
        -2px 0 0 #000,
        2px 0 0 #000;
}
.btn-sidebar:hover { filter: brightness(1.2); transform: translateY(-2px); }

.info-box {
    font-size: 11px;
    color: #aaa;
    text-align: left;
    line-height: 1.4;
    font-style: italic;
}

/* --- CORRECTION BULLE --- */
#action-bubble {
    position: absolute;
    display: none;
    background: white;
    color: #222;
    padding: 8px 16px;
    border-radius: 20px;
    font-weight: bold;
    font-size: 13px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.4);
    
    /* On définit juste le transform horizontal ici. 
       Le JS ajoutera la partie verticale (-100% ou 0) */
    transform: translateX(-50%);
    
    cursor: pointer;
    z-index: 100;
    border: 2px solid #c0392b;
    white-space: nowrap; 
}

@media (max-width: 900px) {
    #main-app {
        flex-direction: column; 
        align-items: center;
    }
    #world-bottom-bar {
        flex-wrap: wrap;
        padding: 10px;
        gap: 8px;
        max-width: 95%;
    }
    .world-bar-btn {
        min-width: 100px;
        max-width: 120px;
        padding: 12px 15px;
        font-size: 11px;
    }
    #world-minimap-container {
        order: -1; /* La minimap en premier sur mobile */
        width: 100%;
        max-width: 100%;
        min-width: auto;
    }
    #world-minimap-container #miniMapCanvas {
        width: 67px;
        height: 67px;
    }
    #sidebar {
        width: 95%;
        max-width: 100%;
        flex-direction: row; 
        flex-wrap: wrap;
        justify-content: space-between;
        min-height: auto;
    }
    .sidebar-box { width: 48%; } 
    .btn-sidebar { width: 48%; }
    .info-box { width: 100%; text-align: center;}
}

/* =========================================
   5. HUB (MAISON)
   ========================================= */
#hub-screen {
    background: #2c3e50;
    padding: 15px;
    border-radius: 12px;
    width: 95%;
    border: 1px solid #444;
    position: relative;
    box-sizing: border-box;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}

.hub-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    width: 100%;
}

.hub-title {
    margin: 0;
    color: #f1c40f;
    font-size: 24px;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 2px;
}

.close-btn {
    background: #e74c3c;
    color: white;
    border: 3px solid #c0392b;
    padding: 12px 24px;
    cursor: pointer;
    border-radius: 8px;
    font-weight: bold;
    font-size: 18px;
    z-index: 9999;
    box-shadow: 0 4px 12px rgba(231, 76, 60, 0.5), 0 2px 4px rgba(0, 0, 0, 0.6);
    transition: all 0.2s ease;
    text-transform: uppercase;
    letter-spacing: 2px;
    min-width: 100px;
    text-align: center;
    position: absolute;
    top: 62px;
    right: 15px;
}

.close-btn:hover {
    background: #c0392b;
    border-color: #a93226;
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(231, 76, 60, 0.7), 0 4px 8px rgba(0, 0, 0, 0.7);
}

.close-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(231, 76, 60, 0.5), 0 1px 2px rgba(0, 0, 0, 0.6);
}

.hub-columns {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 20px;
    margin-top: 20px;
}

/* Optimisation desktop pour le menu - épouse mieux l'écran */
@media (min-width: 901px) {
    #hub-screen.screen {
        width: 98% !important;
        max-width: 1400px !important;
        padding: 20px;
    }
    
    /* Espace pour settings (fixed) + close-btn (fixed) */
    #hub-screen {
        margin-top: 0 !important;
        padding-top: 115px !important;
    }

    #hub-screen .panel {
        width: 380px !important;
        max-width: 380px !important;
    }
    
    #hub-screen .panel#inventory-panel {
        width: 360px !important;
        max-width: 360px !important;
    }
    
    #hub-screen .panel#details-panel-container {
        width: 360px !important;
        max-width: 360px !important;
    }
    
    #hub-screen .hub-columns {
        gap: 30px;
        justify-content: center;
    }
    
    /* Optimisation desktop pour la section TEAM */
    #dofemage-screen.screen {
        width: 98% !important;
        max-width: 1400px !important;
        padding: 20px;
    }
    
    #dofemage-screen .hub-columns {
        max-width: 1400px !important;
        gap: 30px;
        justify-content: center;
    }
    
    #dofemage-screen .panel:first-child {
        width: 50% !important;
        min-width: 500px;
        max-width: 700px !important;
    }
    
    #dofemage-screen .panel:last-child {
        width: 45% !important;
        min-width: 450px;
        max-width: 600px !important;
    }
    
    /* Optimisation desktop pour la section BESTIAIRE */
    #bestiary-screen.screen {
        width: 98% !important;
        max-width: 1400px !important;
        padding: 20px;
    }
    
    #bestiary-screen .hub-columns {
        gap: 30px;
        justify-content: center;
    }
    
    #bestiary-screen .panel {
        width: 360px !important;
        max-width: 360px !important;
    }
}

/* Optimisation mobile pour l'en-tête du hub */
@media (max-width: 768px) {
    #hub-screen {
        width: 100% !important;
        max-width: 100% !important;
        padding: 10px !important;
        border-radius: 0;
        margin: 0;
    }
    
    /* Espace pour settings (fixed) + close-btn (fixed) */
    #hub-screen {
        margin-top: 0 !important;
        padding-top: 115px !important;
    }

    .hub-header {
        padding: 0 5px;
        margin-bottom: 10px;
        position: relative;
    }
    
    .hub-title {
        font-size: 20px;
        letter-spacing: 1px;
    }
    
    .close-btn {
        padding: 10px 20px;
        font-size: 16px;
        min-width: 90px;
        text-transform: uppercase;
        letter-spacing: 1.5px;
        position: absolute;
        top: 62px;
        right: 15px;
        z-index: 9999;
    }
    
    #hub-screen .panel {
        width: calc(100% - 20px) !important;
        max-width: calc(100% - 20px) !important;
        padding: 12px;
        margin: 0 auto;
    }
    
    #hub-screen .hub-columns {
        width: 100%;
        padding: 0;
        gap: 15px;
        flex-direction: column;
        align-items: stretch;
        margin-top: 15px;
    }
    
    /* Centrer parfaitement l'avatar du héros entre les deux colonnes d'équipement sur mobile */
    .char-avatar-container {
        left: 50% !important;
        transform: translateX(-50%) !important;
    }
}

@media (max-width: 480px) {
    #hub-screen {
        width: 100% !important;
        max-width: 100% !important;
        padding: 5px !important;
        border-radius: 0;
        margin: 0;
    }
    
    /* Espace pour settings (fixed) + close-btn (fixed) */
    #hub-screen {
        margin-top: 0 !important;
        padding-top: 115px !important;
    }
    
    .hub-header {
        padding: 0;
        margin-bottom: 10px;
        position: relative;
    }
    
    .hub-title {
        font-size: 18px;
        letter-spacing: 0.5px;
    }
    
    .close-btn {
        padding: 8px 16px;
        font-size: 14px;
        min-width: 80px;
        text-transform: uppercase;
        letter-spacing: 1px;
        position: absolute;
        top: 62px;
        right: 15px;
        z-index: 9999;
    }
    
    #hub-screen .panel {
        width: calc(100% - 10px) !important;
        max-width: calc(100% - 10px) !important;
        padding: 10px;
        min-height: auto;
        margin: 0 auto;
    }
    
    #hub-screen .hub-columns {
        padding: 0;
        gap: 12px;
        margin-top: 10px;
    }
    
    /* Ajuster la fiche de personnage pour mobile */
    .char-sheet {
        width: 100% !important;
        max-width: 100% !important;
        height: auto !important;
        min-height: 260px;
    }
    
    /* Centrer parfaitement l'avatar du héros entre les deux colonnes d'équipement sur mobile */
    .char-avatar-container {
        left: 50% !important;
        transform: translateX(-50%) !important;
    }
    
    /* Ajuster la grille d'inventaire pour mobile */
    .inv-grid {
        grid-template-columns: repeat(4, 1fr) !important;
        gap: 5px;
    }
}

.panel {
    background: #34495e;
    padding: 15px;
    border-radius: 10px;
    border: 1px solid #555;
    width: 100%;
    max-width: 600px;
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
    min-height: 500px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

.section-title {
    color: #f1c40f;
    border-bottom: 2px solid #555;
    margin-bottom: 15px;
    padding-bottom: 8px;
    font-size: 1.3em;
    text-transform: uppercase;
    font-weight: bold;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
}

/* FICHE PERSO */
.char-sheet {
    position: relative;
    width: 280px;
    height: 260px;
    background: #222;
    border-radius: 15px;
    border: 2px solid #555;
    margin: 0 auto;
    background-image: radial-gradient(circle at center, #333 0%, #222 70%);
}

.char-avatar-container {
    position: absolute;
    top: 80px;
    left: 90px;
    text-align: center;
    width: 100px;
    cursor: help;
}

.char-avatar {
    width: 90px;
    height: 90px;
    background: #3498db;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 45px;
    border: 4px solid white;
    margin: 0 auto;
    box-shadow: 0 0 20px rgba(52, 152, 219, 0.6);
}

.equip-slot {
    width: 50px;
    height: 50px;
    background: rgba(255, 255, 255, 0.05);
    border: 2px dashed #555;
    border-radius: 8px;
    position: absolute;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    z-index: 10;
    transition: 0.2s;
}

.equip-slot.filled {
    border: 2px solid #f39c12;
    background: #2c3e50;
    cursor: grab;
    box-shadow: 0 0 10px rgba(243, 156, 18, 0.3);
}

#slot-head   { top: 20px; left: 20px; }
#slot-body   { top: 100px; left: 20px; }
#slot-finger { top: 180px; left: 20px; }
#slot-neck   { top: 20px; right: 20px; }
#slot-hands  { top: 100px; right: 20px; }
#slot-feet   { top: 180px; right: 20px; }

.hero-xp-area { margin-top: 8px; width: 100%; }
.xp-container { 
    background: #444; 
    height: 14px; 
    width: 100%; 
    border-radius: 7px; 
    overflow: hidden; 
    border: 1px solid #000; 
    position: relative;
}
.xp-fill { background: linear-gradient(90deg, #3498db, #2980b9); height: 100%; width: 0%; transition: width 0.5s; }

#hero-xp-text {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    font-size: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
    text-shadow: 1px 1px 1px #000;
}

.char-stats {
    background: rgba(0, 0, 0, 0.7);
    padding: 10px;
    border-radius: 8px;
    font-size: 12px;
    border: 1px solid #444;
}

.char-sheet .char-stats {
    position: absolute;
    bottom: 15px;
    left: 15px;
    right: 15px;
}

.mini-stat-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 4px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding-bottom: 2px;
}

.stat-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
    padding: 4px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    font-size: 12px;
    width: 100%;
}

.stat-val {
    font-weight: bold;
    margin-left: 10px;
}

.inventory-tabs {
    display: flex;
    gap: 5px;
    margin-top: 10px;
    margin-bottom: 5px;
    overflow-x: auto;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    flex-shrink: 0; /* Ne jamais écraser la barre d'onglets dans un flex-column */
}

.inventory-tabs::-webkit-scrollbar {
    display: none;
}

.inventory-tab {
    flex: 1 0 auto;
    padding: 8px 12px;
    background: #2c3e50;
    border: 4px solid #000;
    border-radius: 4px;
    color: #bdc3c7;
    font-size: 12px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
    text-shadow: 
        -2px -2px 0 #000,
        2px -2px 0 #000,
        -2px 2px 0 #000,
        2px 2px 0 #000,
        0 -2px 0 #000,
        0 2px 0 #000,
        -2px 0 0 #000,
        2px 0 0 #000;
}

.inventory-tab:hover {
    background: #34495e;
    border-color: #666;
}

.inventory-tab.active {
    background: #3498db;
    border-color: #2980b9;
    color: white;
}

.inv-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 6px;
    margin-top: 10px;
    background: rgba(0, 0, 0, 0.3);
    padding: 8px;
    border-radius: 8px;
    min-height: 150px;
    max-height: 300px;
    overflow-y: auto;
}

.item-box {
    width: 42px;
    height: 42px;
    background: #3e4a59;
    border: 1px solid #555;
    border-radius: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    position: relative;
    cursor: grab;
    transition: transform 0.1s;
}
.item-box:active { transform: scale(0.9); }

.item-quantity {
    position: absolute;
    bottom: 2px;
    right: 2px;
    background: rgba(0, 0, 0, 0.8);
    color: #f1c40f;
    font-size: 10px;
    font-weight: bold;
    padding: 1px 4px;
    border-radius: 3px;
    min-width: 14px;
    text-align: center;
    line-height: 1.2;
}

.monster-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    overflow-y: auto;
    max-height: 350px;
}

.card {
    background: #222;
    padding: 10px;
    border-radius: 8px;
    border: 1px solid #555;
    display: flex;
    align-items: center;
    gap: 12px;
    position: relative;
    cursor: pointer;
    transition: 0.2s;
}

.card:hover { border-color: #f1c40f; transform: translateX(5px); }
.card.selected { border-color: #2ecc71; background: #283747; box-shadow: 0 0 10px rgba(46, 204, 113, 0.2); }

.mon-avatar {
    font-size: 24px;
    width: 40px;
    height: 40px;
    background: #333;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid rgba(255,255,255,0.1);
    position: relative;
    overflow: hidden;
}

.squad-badge {
    position: absolute;
    top: 5px;
    right: 5px;
    background: #2ecc71;
    color: white;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    font-size: 10px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: bold;
    border: 1px solid white;
}

.spell-tag {
    display: inline-block;
    background: #34495e;
    border: 1px solid #555;
    padding: 3px 8px;
    margin: 2px;
    border-radius: 12px;
    font-size: 10px;
    cursor: help;
    transition: 0.2s;
}
.spell-tag:hover { background: #9b59b6; color: white; transform: translateY(-2px); }

/* =========================================
   6. COMBAT (OPTIMISÉ)
   ========================================= */
   #game-layout {
    display: flex;
    flex-direction: column;
    gap: 0; /* Pas d'espace entre les éléments pour les coller */
    width: 100%;
    align-items: center;
}

#combatCanvas {
    width: 100%;
    max-width: 800px; 
    height: auto;
    aspect-ratio: 1/1;
    background: #2c3e50;
    border: 4px solid #444;
    border-top: none; /* Pas de bordure en haut pour coller avec le log */
    border-radius: 0 0 8px 8px; /* Arrondi seulement en bas */
    cursor: crosshair;
}

#ui-panel {
    width: 100%;
    max-width: 800px;
    background: #2c3e50;
    padding: 10px;
    border-radius: 8px;
    border: 1px solid #555;
    display: flex;
    flex-direction: row;
    gap: 10px;
    align-items: flex-start;
    box-sizing: border-box;
    margin-top: 10px; /* Petit espace entre le canvas et le panneau UI */
}

/* Nouvelle structure des actions de combat */
#combat-entity-display {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

#combat-actions-main {
    display: flex;
    flex: 1;
    min-width: 0;
    min-height: 116px; /* Hauteur fixe : 2 lignes de boutons (2 * 50px) + gap (8px) = 116px */
}

#combat-active-entity-wrapper {
    position: relative;
    width: 80px;
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto;
}

#combat-timer-gauge {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 100px;
    height: 100px;
    transform: translate(-50%, -50%) rotate(-90deg);
    pointer-events: none;
    z-index: 1;
    display: block;
    visibility: visible;
    opacity: 1;
    margin: 0;
    padding: 0;
}

#combat-timer-circle-bg {
    fill: none;
    stroke: #222;
    stroke-width: 12;
    opacity: 1;
}

#combat-timer-circle {
    fill: none;
    stroke: #ffd700;
    stroke-width: 12;
    stroke-dasharray: 263.89;
    stroke-dashoffset: 0;
    stroke-linecap: round;
    transition: stroke-dashoffset 0.3s linear, stroke 0.3s ease;
    filter: drop-shadow(0 0 6px rgba(255, 215, 0, 1)) drop-shadow(0 0 3px rgba(255, 215, 0, 0.8));
    opacity: 1;
}

#combat-active-entity-circle {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: #34495e;
    border: 3px solid #555;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
    position: relative;
    z-index: 2;
}

#combat-entity-display .btn-run {
    width: 80px;
    padding: 6px;
    font-size: 11px;
    background: #e74c3c;
    margin: 0;
    border: 4px solid #000;
    text-shadow: 
        -2px -2px 0 #000,
        2px -2px 0 #000,
        -2px 2px 0 #000,
        2px 2px 0 #000,
        0 -2px 0 #000,
        0 2px 0 #000,
        -2px 0 0 #000,
        2px 0 0 #000;
}

#combat-actions-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
    gap: 8px;
    flex: 1;
    min-height: 0;
}

.combat-action-btn {
    background: #34495e;
    border: 4px solid #000;
    border-radius: 6px;
    color: white;
    font-weight: bold;
    font-size: 14px;
    padding: 12px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 50px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    text-shadow: 
        -2px -2px 0 #000,
        2px -2px 0 #000,
        -2px 2px 0 #000,
        2px 2px 0 #000,
        0 -2px 0 #000,
        0 2px 0 #000,
        -2px 0 0 #000,
        2px 0 0 #000;
}

.combat-action-btn:hover:not(:disabled) {
    background: #3d566e;
    border-color: #f1c40f;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.3);
}

.combat-action-btn:active:not(:disabled) {
    transform: translateY(0);
}

.combat-action-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    filter: grayscale(0.7);
    background: #2c3e50 !important;
}

#combat-btn-spell {
    background: #9b59b6;
}

#combat-btn-item {
    background: #e67e22;
}

#combat-btn-dofemon {
    background: #3498db;
}

#combat-btn-end-turn {
    background: #27ae60;
}

#combat-actions-list {
    display: flex;
    flex-direction: row;
    gap: 8px;
    flex: 1;
    min-width: 0;
    margin-left: 0;
    min-height: 116px; /* Même hauteur minimale que #combat-actions-main pour éviter le changement de taille */
    align-items: stretch;
}

#combat-actions-list #actions-container {
    flex: 1;
    min-height: 0;
    max-height: none;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
    position: relative; /* Créer un contexte de stacking */
}

/* Tooltip fixe pour les boutons de combat (pour éviter d'être coupé par overflow) */
.combat-tooltip-fixed {
    position: fixed;
    background: rgba(10, 10, 10, 0.95);
    color: #f1c40f;
    padding: 8px;
    border-radius: 6px;
    border: 1px solid #7f8c8d;
    font-size: 11px;
    white-space: pre-wrap;
    z-index: 999999; /* Z-index très élevé pour passer au-dessus de tout */
    width: max-content;
    max-width: 160px;
    text-align: center;
    box-shadow: 0 10px 25px rgba(0,0,0,0.9);
    pointer-events: none;
    line-height: 1.3;
    animation: tooltipFade 0.2s forwards;
}

/* Masquer le tooltip CSS par défaut pour les boutons de combat */
.combat-btn-tooltip:hover::after {
    display: none !important;
}

#combat-actions-list #actions-container .combat-action-btn,
#combat-actions-list #actions-container .btn {
    width: 100%;
    min-width: 0;
}

#combat-actions-list .btn-cancel {
    background: #c0392b;
    width: auto;
    min-width: 50px;
    margin: 0;
    border: 4px solid #000;
    text-shadow: 
        -2px -2px 0 #000,
        2px -2px 0 #000,
        -2px 2px 0 #000,
        2px 2px 0 #000,
        0 -2px 0 #000,
        0 2px 0 #000,
        -2px 0 0 #000,
        2px 0 0 #000;
    flex-shrink: 0;
    align-self: stretch;
    display: flex;
    align-items: center;
    justify-content: center;
    writing-mode: horizontal-tb;
    padding: 8px 12px;
}

/* Responsive pour mobile */
@media (max-width: 600px) {
    #combat-active-entity-wrapper {
        width: 70px;
        height: 70px;
        display: flex;
        align-items: center;
        justify-content: center;
        position: relative;
    }
    
    #combat-timer-gauge {
        width: 90px !important;
        height: 90px !important;
        top: 50% !important;
        left: 50% !important;
        transform: translate(-50%, -50%) rotate(-90deg) !important;
        margin: 0 !important;
        padding: 0 !important;
    }
    
    #combat-active-entity-circle {
        width: 70px;
        height: 70px;
        position: relative;
        margin: 0;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    #combat-entity-display .btn-run {
        width: 70px;
        font-size: 10px;
        padding: 5px;
    }
    
    .combat-action-btn {
        font-size: 12px;
        padding: 10px;
        min-height: 45px;
    }
    
    #combat-actions-list #actions-container {
        max-height: 150px;
    }
    
    #ui-panel {
        flex-direction: row;
        gap: 8px;
    }
    
    #combat-actions-main {
        flex: 1;
        min-width: 0;
    }
    
    #combat-actions-list {
        flex: 1;
        min-width: 0;
    }
}

/* Conteneur de la timeline en haut de l'écran de combat */
#combat-timeline-container {
    width: 100%;
    max-width: 800px;
    background: #2c3e50;
    padding: 10px;
    border-radius: 8px 8px 0 0; /* Arrondi seulement en haut */
    border: 1px solid #555;
    border-bottom: none; /* Pas de bordure en bas pour coller avec le log */
    margin-bottom: 0;
    box-sizing: border-box;
}

/* Timeline Intégrée et Discrète */
#timeline {
    display: flex;
    gap: 5px; /* Espacement réduit */
    background: transparent; /* Fond transparent pour fondre dans l'UI */
    padding: 0;
    border-radius: 0;
    justify-content: center;
    min-height: auto;
    margin-bottom: 0;
    border: none; /* Plus de bordure */
}

.timeline-entity {
    width: 28px; /* Taille réduite (avant 35px) */
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #444;
    font-size: 16px; /* Emoji plus petit */
    border: 2px solid transparent;
    transition: 0.3s;
}

.timeline-entity.active {
    border-color: #f1c40f; /* Bordure or pour le tour actif */
    transform: scale(1.2);
    background: #555;
    box-shadow: 0 0 5px rgba(241, 196, 15, 0.5);
    z-index: 10;
}

.timeline-entity-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
    display: block;
}

/* Dézoom de l'image du héros pour voir son corps en entier */
.timeline-hero-image {
    object-fit: contain;
    width: 80%;
    height: 80%;
}

/* Bordures colorées selon le type d'entité */
.timeline-enemy {
    border: 2px solid #e74c3c !important; /* Rouge pour les ennemis */
}

.timeline-ally,
.timeline-hero {
    border: 2px solid #2ecc71 !important; /* Vert pour les alliés et le héros */
}

/* La bordure active (or) doit avoir la priorité */
.timeline-entity.active.timeline-enemy {
    border-color: #f1c40f !important; /* Or pour le tour actif, même pour les ennemis */
}

.timeline-entity.active.timeline-ally,
.timeline-entity.active.timeline-hero {
    border-color: #f1c40f !important; /* Or pour le tour actif, même pour les alliés */
}

/* BOUTONS */
.btn {
    width: 100%;
    padding: 12px; /* Un peu moins haut */
    margin: 4px 0;
    color: white;
    border: 4px solid #000;
    border-radius: 6px;
    font-weight: bold;
    font-size: 13px;
    text-align: left;
    padding-left: 20px;
    cursor: pointer;
    position: relative; 
    transition: filter 0.2s, transform 0.1s;
    box-shadow: 0 3px 0 rgba(0,0,0,0.2);
    text-shadow: 
        -2px -2px 0 #000,
        2px -2px 0 #000,
        -2px 2px 0 #000,
        2px 2px 0 #000,
        0 -2px 0 #000,
        0 2px 0 #000,
        -2px 0 0 #000,
        2px 0 0 #000;
}

.btn:hover { filter: brightness(1.15); transform: translateY(-1px); }
.btn:active { transform: translateY(2px); box-shadow: 0 1px 0 rgba(0,0,0,0.2); }
.btn:disabled { 
    background: #555 !important; 
    opacity: 0.6; 
    cursor: not-allowed; 
    box-shadow: none; 
    transform: none;
}

.btn-attack { background: #c0392b; }
.btn-item { background: #e67e22; }
.btn-stone { background: #7f8c8d; color: #222; }
#btn-pass { 
    background: #f1c40f; 
    color: #222; 
    text-align: center; 
    margin-top: auto; 
}

.btn-flee {
    background: transparent;
    border: 1px solid #c0392b;
    color: #c0392b;
    text-align: center;
    margin-top: 10px;
    font-size: 12px;
    padding: 8px;
    width: auto;
    align-self: center;
    border-radius: 20px;
    box-shadow: none;
}

#log {
    width: 100%;
    max-width: 800px;
    height: 80px; /* Un peu moins haut */
    overflow-y: auto;
    background: #1a1a1a;
    font-size: 10px;
    font-family: 'Consolas', monospace;
    padding: 6px;
    margin-top: 0; /* Pas de marge en haut pour coller avec la timeline */
    margin-bottom: 0; /* Pas de marge en bas pour coller avec le canvas */
    border: 1px solid #444;
    border-top: none; /* Pas de bordure en haut pour coller avec la timeline */
    border-radius: 0; /* Pas d'arrondi pour coller avec les autres éléments */
    color: #ccc;
    box-sizing: border-box;
}

/* =========================================
   7. TOOLTIPS (BULLES D'INFO AMÉLIORÉES)
   ========================================= */

/* A. Tooltip Flottant (Suivi de souris en combat) */
#combat-tooltip {
    position: absolute;
    display: none;
    background: rgba(0, 0, 0, 0.95);
    border: 1px solid #f1c40f;
    padding: 8px;
    border-radius: 6px;
    color: white;
    font-size: 9px;
    z-index: 1000;
    pointer-events: none;
    box-shadow: 0 8px 20px rgba(0,0,0,0.8);
    white-space: pre-wrap;
    min-width: 180px;
    max-width: 260px;
    backdrop-filter: blur(4px);
    line-height: 1.2;
}

/* B. Tooltip Fixe (Inventaire & Équipement) - BASE */
.equip-slot.filled:hover::after,
.item-box:hover::after,
.btn:not(:disabled) {
    position: relative; /* S'assurer que le bouton est le contexte de positionnement */
    z-index: 1; /* Z-index de base pour le bouton */
}

.btn:not(:disabled):hover {
    z-index: 100000; /* Z-index très élevé au survol pour que le tooltip passe au-dessus */
}

.btn:not(:disabled):hover::after {
    content: attr(data-tooltip);
    position: absolute;
    
    /* Par défaut : Au-dessus et centré */
    bottom: 110%; 
    left: 50%;
    transform: translateX(-50%);
    
    background: rgba(10, 10, 10, 0.95);
    color: #f1c40f;
    padding: 8px;
    border-radius: 6px;
    border: 1px solid #7f8c8d;
    font-size: 11px;
    white-space: pre-wrap;
    z-index: 100001; /* Z-index encore plus élevé pour le tooltip lui-même */
    width: max-content;
    max-width: 160px; /* Moins large pour éviter les débordements */
    text-align: center;
    box-shadow: 0 10px 25px rgba(0,0,0,0.9);
    pointer-events: none;
    line-height: 1.3;
    opacity: 0;
    animation: tooltipFade 0.2s forwards;
}

/* --- LOGIQUE INTELLIGENTE POUR L'INVENTAIRE --- */

/* 1. Les objets de la colonne de GAUCHE (1, 6, 11...) : On aligne à gauche */
.inv-grid .item-box:nth-child(5n+1):hover::after {
    left: 0;
    transform: none; /* On enlève le centrage */
    text-align: left;
}

/* 2. Les objets de la colonne de DROITE (5, 10, 15...) : On aligne à droite */
.inv-grid .item-box:nth-child(5n):hover::after {
    left: auto; /* On annule le left */
    right: 0;   /* On colle à droite */
    transform: none;
    text-align: right;
}

/* 3. Les 5 premiers objets (1ère ligne) : On affiche EN DESSOUS (pour ne pas couper en haut) */
.inv-grid .item-box:nth-child(-n+5):hover::after {
    bottom: auto;
    top: 115%;
}

/* --- LOGIQUE POUR LES BOUTONS DE SORTS EN COMBAT --- */
/* Les boutons de sorts en haut (premières lignes) : afficher le tooltip en bas */
.spell-btn-top:hover {
    z-index: 100000; /* Même z-index élevé pour les boutons en haut */
}

.spell-btn-top:hover::after {
    bottom: auto;
    top: 115%;
    animation: tooltipFadeBottom 0.2s forwards;
}

@keyframes tooltipFadeBottom {
    from { opacity: 0; transform: translate(-50%, -5px); }
    to { opacity: 1; transform: translate(-50%, 0); }
}

/* --- LOGIQUE POUR L'ÉQUIPEMENT --- */
/* (J'ai supprimé la règle qui forçait le casque vers le bas. Tout va vers le haut maintenant) */

/* Animation d'apparition */
@keyframes tooltipFade {
    from { opacity: 0; transform: translate(-50%, 5px); }
    to { opacity: 1; transform: translate(-50%, 0); }
}

/* Petits ajustements d'animation pour les cas spécifiques (Gauche/Droite) */
.inv-grid .item-box:nth-child(5n+1):hover::after { animation: tooltipFadeLeft 0.2s forwards; }
.inv-grid .item-box:nth-child(5n):hover::after { animation: tooltipFadeRight 0.2s forwards; }

@keyframes tooltipFadeLeft { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }
@keyframes tooltipFadeRight { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }


/* =========================================
   8. MAGASIN (SHOP)
   ========================================= */
.shop-grid {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 8px;
    max-height: 500px;
    overflow-y: auto;
}

.shop-item {
    background: #222;
    border: 1px solid #555;
    padding: 12px;
    border-radius: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 15px;
    transition: all 0.2s;
}
.shop-item:hover {
    background: #2a2a2a;
    border-color: #666;
}

.shop-quantity-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 320px;
    flex-shrink: 0;
}

.btn-quantity {
    background: #34495e;
    color: white;
    border: 2px solid #555;
    padding: 10px 14px;
    border-radius: 5px;
    font-weight: bold;
    cursor: pointer;
    font-size: 18px;
    width: 42px;
    height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    flex-shrink: 0;
}

.btn-quantity:hover {
    background: #2c3e50;
    filter: brightness(1.2);
    transform: scale(1.1);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
}

.btn-quantity:active {
    transform: scale(0.95);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.shop-quantity-display {
    width: 45px;
    text-align: center;
    font-weight: bold;
    font-size: 18px;
    color: white;
    padding: 0 10px;
    flex-shrink: 0;
}

.btn-buy {
    background: #f1c40f;
    color: #222;
    border: 4px solid #000;
    padding: 14px 24px;
    border-radius: 6px;
    font-weight: bold;
    cursor: pointer;
    font-size: 18px;
    width: 165px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
    transition: all 0.2s;
    flex-shrink: 0;
    /* Pas de text-shadow pour les prix afin d'assurer une meilleure lisibilité */
}
.btn-buy:hover { 
    filter: brightness(1.15); 
    transform: scale(1.08); 
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.4);
}
.btn-buy:active { 
    transform: scale(0.96); 
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.shop-item-sell {
    cursor: pointer;
    border-color: #f1c40f; /* Bordure dorée pour indiquer vendable */
}
.shop-item-sell:hover {
    background: #c0392b; /* Rouge au survol pour "Vendre/Supprimer" */
}

/* =========================================
   9. DOFEDEX & DOFEMAGE LISTS (NEW)
   ========================================= */

.dofedex-entry {
    color: white;
    padding: 15px;
    border-radius: 12px;
    border: 2px solid rgba(255,255,255,0.2);
    box-shadow: 0 4px 12px rgba(0,0,0,0.4);
    text-shadow: 1px 1px 2px #000;
    transition: all 0.3s ease;
    background: linear-gradient(135deg, rgba(62,74,89,0.9), rgba(44,62,80,0.9));
}

.dofedex-entry:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 20px rgba(0,0,0,0.5);
}

/* DoFemons non capturés : image en noir et blanc dans le Dofedex */
.dofedex-img-uncaught {
    filter: grayscale(100%) drop-shadow(2px 2px 4px rgba(0,0,0,0.5)) !important;
}
#dofedex-details-panel .dofedex-img-uncaught {
    filter: grayscale(100%) drop-shadow(4px 4px 8px rgba(0,0,0,0.5)) !important;
}

/* Écran Dofedex : centrage et layout responsive */
#dofedex-screen {
    flex-direction: column;
    align-items: center;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    padding-left: 10px;
    padding-right: 10px;
}

#dofedex-screen .hub-columns {
    width: 100%;
    max-width: 1200px;
    box-sizing: border-box;
}

/* Panneau de détails Dofedex : éviter débordement et bien centrer */
#dofedex-details-panel-container {
    box-sizing: border-box;
}

#dofedex-details-panel {
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
    overflow-x: hidden;
}

#dofedex-details-panel .dofedex-details-header {
    max-width: 100%;
}

#dofedex-details-panel .dofedex-details-header h2 {
    word-break: break-word;
    overflow-wrap: break-word;
}

#dofedex-details-title {
    text-align: center;
    word-break: break-word;
}

.dofemage-entry {
    background: #222;
    color: #ddd;
    padding: 10px;
    border-radius: 6px;
    border: 1px solid #3498db;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

/* =========================================
   9b. WEAKNESS CHARTS
   ========================================= */

.weakness-cycles-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
    padding: 10px 5px;
}

.weakness-cycle-card {
    background: linear-gradient(135deg, rgba(44,62,80,0.95), rgba(30,39,46,0.95));
    border: 2px solid rgba(230,126,34,0.4);
    border-radius: 16px;
    padding: 20px 15px;
    display: flex;
    flex-direction: column;
    align-items: center;
    box-shadow: 0 4px 16px rgba(0,0,0,0.4);
    transition: transform 0.2s, box-shadow 0.2s;
}

.weakness-cycle-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 24px rgba(0,0,0,0.5), 0 0 15px rgba(230,126,34,0.15);
}

.weakness-cycle-title {
    color: #e67e22;
    margin: 0 0 10px 0;
    font-size: 16px;
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 1px;
    text-shadow: 1px 1px 3px rgba(0,0,0,0.5);
}

.weakness-svg {
    width: 100%;
    max-width: 320px;
    height: auto;
}

@media (max-width: 768px) {
    .weakness-cycles-grid {
        grid-template-columns: 1fr;
    }
}

/* =========================================
   10. POINTS DE COMPÉTENCE
   ========================================= */

.skill-btn {
    background: #3498db;
    color: white;
    border: 1px solid #2980b9;
    border-radius: 4px;
    font-weight: bold;
    cursor: pointer;
    font-size: 14px;
    transition: 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.skill-btn:hover:not(:disabled) {
    background: #2980b9;
    filter: brightness(1.1);
    transform: scale(1.1);
}

.skill-btn:active:not(:disabled) {
    transform: scale(0.95);
}

.skill-btn:disabled {
    background: #555;
    border-color: #444;
    color: #aaa;
    cursor: not-allowed;
    opacity: 0.5;
}

/* =========================================
   11. TOAST NOTIFICATIONS
   ========================================= */

.toast {
    position: fixed;
    top: 60px;
    right: 20px;
    background: #2c3e50;
    color: white;
    padding: 15px 20px;
    border-radius: 8px;
    border: 2px solid #3498db;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
    z-index: 100000;
    font-size: 14px;
    font-weight: bold;
    min-width: 250px;
    max-width: 400px;
    display: flex;
    align-items: center;
    gap: 10px;
    animation: toastSlideIn 0.3s ease-out, toastFadeOut 0.3s ease-in 2.7s forwards;
    pointer-events: none;
}

.toast-success {
    border-color: #2ecc71;
    background: linear-gradient(135deg, #27ae60, #2c3e50);
}

.toast-error {
    border-color: #e74c3c;
    background: linear-gradient(135deg, #c0392b, #2c3e50);
}

@keyframes toastSlideIn {
    from {
        opacity: 0;
        transform: translateX(400px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes toastFadeOut {
    from {
        opacity: 1;
        transform: translateX(0);
    }
    to {
        opacity: 0;
        transform: translateX(400px);
    }
}

/* =========================================
   12. OPTIMISATION MOBILE - DOFEDEX & TEAM
   ========================================= */

/* Sur mobile en portrait, élargir les panels DOFEDEX et TEAM */
/* Utilisation de max-width pour cibler les téléphones en portrait */
@media (max-width: 768px) and (orientation: portrait) {
    /* Espace pour settings (fixed) + close-btn (fixed) */
    #dofedex-screen,
    #dofemage-screen {
        padding-top: 115px !important;
    }
    
    /* DOFEDEX - Panel principal (liste des monstres) */
    #dofedex-main-panel {
        width: 90% !important;
        max-width: 90% !important;
    }

    /* DOFEDEX - Onglets : 2 lignes de 2 sur mobile */
    #dofedex-main-panel .inventory-tabs {
        flex-wrap: wrap;
    }
    #dofedex-main-panel .inventory-tab {
        flex: 1 1 40%;
    }

    /* DOFEDEX - Panel de détails */
    #dofedex-details-panel-container {
        width: 90% !important;
        max-width: 90% !important;
        position: relative !important;
        top: auto !important;
    }

    /* TEAM - Panel principal (liste des monstres) */
    #dofemage-screen .panel:first-child {
        width: 90% !important;
        max-width: 90% !important;
    }

    /* TEAM - Panel de détails */
    #dofemage-screen .panel:last-child {
        width: 90% !important;
        max-width: 90% !important;
        position: relative !important;
        top: auto !important;
    }

    /* Ajuster le conteneur hub-columns pour centrer les panels */
    #dofedex-screen .hub-columns,
    #dofemage-screen .hub-columns {
        flex-direction: column;
        align-items: center;
        gap: 15px;
    }

    /* Panneau détails Dofemon : avatar et stats responsive */
    #dofedex-details-panel .dofedex-details-avatar-wrap {
        width: min(200px, 70vw) !important;
        height: min(200px, 70vw) !important;
    }

    #dofedex-details-panel .dofedex-details-avatar-wrap img {
        max-width: min(150px, 55vw) !important;
        max-height: min(150px, 55vw) !important;
    }

    #dofedex-details-panel .dofedex-details-stats {
        grid-template-columns: 1fr !important;
    }

    #dofedex-details-panel .dofedex-details-header h2 {
        font-size: 1.25rem !important;
    }
}

/* Pour les très petits écrans en portrait */
@media (max-width: 480px) and (orientation: portrait) {
    /* DOFEDEX - Panel principal */
    #dofedex-main-panel {
        width: 90% !important;
        max-width: 90% !important;
    }
    
    /* DOFEDEX - Panel de détails */
    #dofedex-details-panel-container {
        width: 90% !important;
        max-width: 90% !important;
    }

    #dofedex-details-panel {
        padding: 12px 10px !important;
    }

    #dofedex-details-panel .dofedex-details-avatar-wrap {
        width: min(160px, 65vw) !important;
        height: min(160px, 65vw) !important;
    }

    #dofedex-details-panel .dofedex-details-stats {
        grid-template-columns: 1fr !important;
    }

    #dofedex-details-panel .dofedex-details-header h2 {
        font-size: 1.1rem !important;
    }
    
    /* TEAM - Panel principal */
    #dofemage-screen .panel:first-child {
        width: 90% !important;
        max-width: 90% !important;
    }
    
    /* TEAM - Panel de détails */
    #dofemage-screen .panel:last-child {
        width: 90% !important;
        max-width: 90% !important;
    }
}

/* Fallback pour les navigateurs qui ne supportent pas orientation */
/* On utilise max-width avec une hauteur minimale pour cibler les téléphones en portrait */
@media (max-width: 768px) and (min-height: 500px) {
    /* Espace pour settings (fixed) + close-btn (fixed) */
    #dofedex-screen,
    #dofemage-screen {
        padding-top: 115px !important;
    }
    
    /* DOFEDEX - Panel principal (liste des monstres) */
    #dofedex-main-panel {
        width: 90% !important;
        max-width: 90% !important;
    }

    /* DOFEDEX - Onglets : 2 lignes de 2 sur mobile */
    #dofedex-main-panel .inventory-tabs {
        flex-wrap: wrap;
    }
    #dofedex-main-panel .inventory-tab {
        flex: 1 1 40%;
    }

    /* DOFEDEX - Panel de détails */
    #dofedex-details-panel-container {
        width: 90% !important;
        max-width: 90% !important;
        position: relative !important;
        top: auto !important;
    }

    /* TEAM - Panel principal (liste des monstres) */
    #dofemage-screen .panel:first-child {
        width: 90% !important;
        max-width: 90% !important;
    }

    /* TEAM - Panel de détails */
    #dofemage-screen .panel:last-child {
        width: 90% !important;
        max-width: 90% !important;
        position: relative !important;
        top: auto !important;
    }

    /* Ajuster le conteneur hub-columns pour centrer les panels */
    #dofedex-screen .hub-columns,
    #dofemage-screen .hub-columns {
        flex-direction: column;
        align-items: center;
        gap: 15px;
    }

    #dofedex-details-panel .dofedex-details-avatar-wrap {
        width: min(200px, 70vw) !important;
        height: min(200px, 70vw) !important;
    }

    #dofedex-details-panel .dofedex-details-stats {
        grid-template-columns: 1fr !important;
    }
}

/* =========================================
   13. OPTIMISATION MOBILE - SHOP
   ========================================= */

/* Sur mobile, faire que les panels du shop épousent parfaitement les limites */
@media (max-width: 768px) {
    #shop-screen,
    #dofemon-shop-screen,
    #bestiary-screen,
    #marabou-screen,
    #quest-screen,
    #hero-skin-screen {
        padding-top: 115px !important; /* Espace pour settings (fixed) + close-btn (fixed) */
    }

    #shop-screen .close-btn,
    #dofemon-shop-screen .close-btn,
    #bestiary-screen .close-btn,
    #marabou-screen .close-btn,
    #quest-screen .close-btn,
    #hero-skin-screen .close-btn {
        position: absolute;
        top: 62px;
        right: 15px;
        z-index: 9999;
    }
    
    #shop-screen .panel {
        width: calc(100% - 20px) !important;
        max-width: calc(100% - 20px) !important;
        padding: 12px;
    }
    
    #shop-screen .hub-columns {
        width: 100%;
        padding: 0 10px;
        gap: 15px;
    }
    
    .shop-quantity-controls {
        width: 100% !important;
        flex-wrap: wrap;
        gap: 6px;
        justify-content: center;
    }
    
    .shop-item {
        flex-direction: column;
        gap: 12px;
        align-items: stretch;
    }
    
    .shop-item > div:first-child {
        padding-right: 0;
    }
}

/* Pour les très petits écrans */
@media (max-width: 480px) {
    #shop-screen .panel {
        width: calc(100% - 10px) !important;
        max-width: calc(100% - 10px) !important;
        padding: 10px;
        min-height: auto;
    }
    
    #shop-screen .hub-columns {
        padding: 0 5px;
        gap: 12px;
    }
    
    .shop-quantity-controls {
        width: 100% !important;
        gap: 5px;
    }
    
    .btn-quantity {
        width: 38px !important;
        height: 38px !important;
        font-size: 16px;
        padding: 8px 10px;
    }
    
    .shop-quantity-display {
        width: 35px !important;
        font-size: 16px;
    }
    
    .btn-buy {
        width: 100% !important;
        height: 42px;
        font-size: 16px;
        padding: 12px 20px;
    }
    
    .shop-item {
        padding: 10px;
    }
    
    .shop-grid {
        gap: 10px;
        padding: 5px;
    }
}

/* =========================================
   14. OPTIMISATION MOBILE - DIALOGUE PNJ
   ========================================= */

/* Styles de base pour la bulle de dialogue PNJ */
#npc-dialog-bubble {
    box-sizing: border-box;
    overflow-wrap: break-word;
    word-wrap: break-word;
}

/* Sur mobile, s'assurer que la bulle épouse parfaitement l'écran */
@media (max-width: 768px) {
    #npc-dialog-bubble {
        box-sizing: border-box !important;
        max-width: calc(100vw - 20px) !important;
        width: calc(100vw - 20px) !important;
        left: 10px !important;
        right: auto !important;
    }
    
    #npc-dialog-content {
        box-sizing: border-box;
        word-wrap: break-word;
        overflow-wrap: break-word;
    }
}

/* Pour les très petits écrans */
@media (max-width: 480px) {
    #npc-dialog-bubble {
        left: 5px !important;
        right: auto !important;
        max-width: calc(100vw - 10px) !important;
        width: calc(100vw - 10px) !important;
        padding: 12px !important;
    }
}

/* =========================================
   15. OPTIMISATION MOBILE - BESTIAIRE
   ========================================= */

/* Titre bestiary en double taille */
#bestiary-screen h1 {
    font-size: 3em;
}

/* Sur mobile, faire que les panels du bestiaire épousent parfaitement les limites */
@media (max-width: 768px) {
    #bestiary-screen {
        width: 100% !important;
        max-width: 100% !important;
        padding: 115px 10px 10px 10px !important; /* Espace pour settings + close-btn */
        box-sizing: border-box;
    }
    
    #bestiary-screen .panel {
        width: calc(100% - 20px) !important;
        max-width: calc(100% - 20px) !important;
        padding: 12px;
        margin: 0 auto;
    }
    
    #bestiary-screen .hub-columns {
        width: 100%;
        padding: 0;
        gap: 15px;
        flex-direction: column;
        align-items: stretch;
    }
    
    #bestiary-screen h1 {
        font-size: 40px;
        margin-bottom: 10px;
        padding: 0 10px;
    }
    
    #bestiary-screen .close-btn {
        position: absolute;
        top: 62px;
        right: 15px;
        z-index: 9999;
    }
}

/* Pour les très petits écrans */
@media (max-width: 480px) {
    #bestiary-screen {
        width: 100% !important;
        max-width: 100% !important;
        padding: 115px 5px 5px 5px !important; /* Espace pour settings + close-btn */
        box-sizing: border-box;
    }
    
    #bestiary-screen .panel {
        width: calc(100% - 10px) !important;
        max-width: calc(100% - 10px) !important;
        padding: 10px;
        min-height: auto;
        margin: 0 auto;
    }
    
    #bestiary-screen .hub-columns {
        padding: 0;
        gap: 12px;
    }
    
    #bestiary-screen h1 {
        font-size: 36px;
        margin-bottom: 8px;
        padding: 0 5px;
    }
    
    /* Ajuster les boutons de tri pour qu'ils s'adaptent mieux */
    #bestiary-screen .sort-btn {
        font-size: 10px !important;
        padding: 5px 7px !important;
    }
    
    #bestiary-sort-label {
        font-size: 10px !important;
    }
    
    /* Ajuster le conteneur de tri */
    #bestiary-screen .panel > div:first-of-type {
        flex-wrap: wrap;
        gap: 4px;
    }
}

/* =========================================
   POP-UP DE VICTOIRE
   ========================================= */
#victory-popup-overlay {
    animation: fadeIn 0.3s ease-out;
}

#victory-popup {
    animation: victoryPopupSlideIn 0.4s ease-out;
}

@keyframes victoryPopupSlideIn {
    from {
        opacity: 0;
        transform: scale(0.8) translateY(-20px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.victory-quarter {
    animation: fadeIn 0.5s ease-out;
}

/* Animation de clignotement pour les barres d'XP pleines */
@keyframes xpBarBlink {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(52, 152, 219, 0.7);
    }
    50% {
        box-shadow: 0 0 20px 5px rgba(52, 152, 219, 0.9);
    }
}

.victory-xp-bar-full {
    animation: xpBarBlink 0.8s infinite;
}

/* Animation de progression de la barre d'XP */
@keyframes xpBarGlow {
    0% {
        transform: translateX(-100%);
    }
    100% {
        transform: translateX(100%);
    }
}

.victory-xp-bar-glow-animate {
    animation: xpBarGlow 1.5s infinite;
}

/* Style pour les messages de level-up */
.victory-levelup-message {
    background: rgba(230, 126, 34, 0.2);
    border-left: 3px solid #e67e22;
    padding: 10px;
    border-radius: 5px;
    color: #ecf0f1;
    animation: fadeIn 0.3s ease-out;
}

.victory-levelup-message strong {
    color: #e67e22;
}

/* Style pour les drops */
.victory-drop-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
    background: rgba(243, 156, 18, 0.1);
    border-radius: 5px;
    color: #ecf0f1;
    animation: fadeIn 0.3s ease-out;
}

.victory-drop-item:first-child {
    background: rgba(241, 196, 15, 0.2);
    border-left: 3px solid #f1c40f;
    font-weight: bold;
}

/* Responsive pour le pop-up de victoire */
@media (max-width: 768px) {
    #victory-popup-content {
        grid-template-columns: 1fr !important;
        grid-template-rows: auto auto auto auto !important;
    }
    
    .victory-quarter {
        grid-column: 1 !important;
    }
    
    .victory-quarter:nth-child(1) {
        grid-row: 1 !important;
    }
    
    .victory-quarter:nth-child(2) {
        grid-row: 2 !important;
    }
    
    .victory-quarter:nth-child(3) {
        grid-row: 3 !important;
    }
    
    .victory-quarter:nth-child(4) {
        grid-row: 4 !important;
    }
}

/* =========================================
   ROUE D'ÉQUIPEMENT ALÉATOIRE
   ========================================= */
.wheel-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10000;
    animation: fadeIn 0.3s ease-out;
}

.wheel-modal-content {
    background: #2c3e50;
    border: 3px solid #3498db;
    border-radius: 20px;
    padding: 40px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.8);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.wheel-container {
    position: relative;
    width: 400px;
    height: 400px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.wheel-arrow {
    position: absolute;
    top: -30px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 40px;
    color: #f1c40f;
    z-index: 10001;
    text-shadow: 0 0 10px rgba(241, 196, 15, 0.8);
    animation: arrowPulse 1s infinite;
}

@keyframes arrowPulse {
    0%, 100% {
        transform: translateX(-50%) translateY(0);
    }
    50% {
        transform: translateX(-50%) translateY(-5px);
    }
}

.item-wheel {
    width: 350px;
    height: 350px;
    border-radius: 50%;
    position: relative;
    border: 8px solid #f1c40f;
    overflow: hidden;
    background: #1e272e;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    box-shadow: 0 0 40px rgba(241, 196, 15, 0.6), inset 0 0 20px rgba(0, 0, 0, 0.3);
}

/* Images personnalisées pour les roues selon la rareté */
.item-wheel.wheel-common {
    background-image: url('images/ui/wheel_common.png');
}

.item-wheel.wheel-rare {
    background-image: url('images/ui/wheel_rare.png');
}

.item-wheel.wheel-legendary {
    background-image: url('images/ui/wheel_legendary.png');
}

/* Logo Dofemon au centre de la roue */
.item-wheel::before {
    content: '';
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 120px;
    height: 120px;
    background-image: url('images/logo_dofemon.png');
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    z-index: 5;
    /* Fallback si l'image n'existe pas - affiche un cercle avec texte */
    background-color: #1e272e;
    border-radius: 50%;
    border: 4px solid #f1c40f;
    box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.5);
}

/* Texte de fallback si le logo n'existe pas */
.item-wheel::after {
    content: 'DOFEMON';
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    font-size: 18px;
    font-weight: bold;
    color: #f1c40f;
    z-index: 6;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.8);
    pointer-events: none;
    /* Masquer si le logo existe */
    display: none;
}

.item-wheel-section {
    position: absolute;
    width: 75%;
    height: 75%;
    left: 50%;
    top: 50%;
    transform-origin: 0% 0%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    font-size: 16px;
    font-weight: bold;
    color: white;
    text-shadow: 2px 2px 6px rgba(0, 0, 0, 0.9);
    box-sizing: border-box;
    overflow: hidden;
    /* Triangle de 60 degrés - dimensions augmentées pour garantir le chevauchement */
    /* Pour un angle de 60° : tan(30°) ≈ 0.577 */
    /* Le triangle part du centre (0%, 0%), va à droite (100%, 0%), puis au point calculé */
    /* Pour couvrir exactement 60°, le point en bas doit être à tan(30°) * 100% ≈ 57.7% */
    /* On utilise 75% de taille pour garantir que les sections se chevauchent et éliminent les espaces */
    clip-path: polygon(0% 0%, 100% 0%, 57.7% 100%);
    /* Contour noir épais pour chaque section */
    border: 3px solid #000;
    border-left: none;
    border-top: none;
}

/* Contenu centré dans chaque section triangulaire - rapproché du centre */
.item-wheel-section > div {
    position: absolute;
    /* Position plus proche du centre de la roue pour meilleure visibilité */
    /* Le centre est à (50%, 50%), on place le contenu à environ 30% du rayon */
    left: 45%;
    top: 26%;
    transform: translate(-50%, -50%);
    text-align: center;
    z-index: 2;
}

/* Orientation du contenu vers l'extérieur selon la section */
/* Rotation de 120° pour orienter le contenu vers l'extérieur */
.item-wheel-section:nth-child(1) > div {
    transform: translate(-50%, -50%) rotate(120deg);
}

.item-wheel-section:nth-child(2) > div {
    transform: translate(-50%, -50%) rotate(120deg);
}

.item-wheel-section:nth-child(3) > div {
    transform: translate(-50%, -50%) rotate(120deg);
}

.item-wheel-section:nth-child(4) > div {
    transform: translate(-50%, -50%) rotate(120deg);
}

.item-wheel-section:nth-child(5) > div {
    transform: translate(-50%, -50%) rotate(120deg);
}

.item-wheel-section:nth-child(6) > div {
    transform: translate(-50%, -50%) rotate(120deg);
}


/* Positionnement des 6 sections en cercle (60 degrés chacune) */
/* Chaque section est un triangle de 60 degrés partant du centre */
.item-wheel-section:nth-child(1) {
    background: #9b59b6;
    transform: rotate(0deg);
}

.item-wheel-section:nth-child(1)::after {
    content: '';
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 1px;
    background: #f1c40f;
    pointer-events: none;
    z-index: 10;
}

.item-wheel-section:nth-child(2) {
    background: #1abc9c;
    transform: rotate(60deg);
}

.item-wheel-section:nth-child(2)::after {
    content: '';
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 1px;
    background: #f1c40f;
    pointer-events: none;
    z-index: 10;
}

.item-wheel-section:nth-child(3) {
    background: #3498db;
    transform: rotate(120deg);
}

.item-wheel-section:nth-child(3)::after {
    content: '';
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 1px;
    background: #f1c40f;
    pointer-events: none;
    z-index: 10;
}

.item-wheel-section:nth-child(4) {
    background: #2ecc71;
    transform: rotate(180deg);
}

.item-wheel-section:nth-child(4)::after {
    content: '';
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 1px;
    background: #f1c40f;
    pointer-events: none;
    z-index: 10;
}

.item-wheel-section:nth-child(5) {
    background: #e74c3c;
    transform: rotate(240deg);
}

.item-wheel-section:nth-child(5)::after {
    content: '';
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 1px;
    background: #f1c40f;
    pointer-events: none;
    z-index: 10;
}

.item-wheel-section:nth-child(6) {
    background: #f39c12;
    transform: rotate(300deg);
}

.item-wheel-section:nth-child(6)::after {
    content: '';
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 1px;
    background: #f1c40f;
    pointer-events: none;
    z-index: 10;
}

.item-wheel-spinning {
    animation: wheelSpin 3s cubic-bezier(0.17, 0.67, 0.12, 0.99) forwards;
}

@keyframes wheelSpin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(var(--final-rotation, 2160deg));
    }
}

.wheel-section-label {
    font-size: 13px;
    margin-top: 8px;
    text-align: center;
    font-weight: normal;
    white-space: nowrap;
    letter-spacing: 0.5px;
}

/* =========================================
   MYSTERY BOX SLOT MACHINE
   ========================================= */
.mb-slot-outer {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.mb-slot-pointer-top,
.mb-slot-pointer-bot {
    font-size: 26px;
    color: #f1c40f;
    text-shadow: 0 0 10px rgba(241, 196, 15, 0.8);
    animation: arrowPulse 1s infinite;
    line-height: 1;
}

.mb-slot-window {
    width: 330px;
    height: 130px;
    overflow: hidden;
    border: 3px solid #f1c40f;
    border-radius: 12px;
    background: #1a1a2e;
    box-shadow: 0 0 20px rgba(241, 196, 15, 0.3), inset 0 0 15px rgba(0, 0, 0, 0.5);
    position: relative;
}

.mb-slot-window::before,
.mb-slot-window::after {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    width: 55px;
    z-index: 2;
    pointer-events: none;
}

.mb-slot-window::before {
    left: 0;
    background: linear-gradient(to right, rgba(26, 26, 46, 0.92), transparent);
}

.mb-slot-window::after {
    right: 0;
    background: linear-gradient(to left, rgba(26, 26, 46, 0.92), transparent);
}

.mb-slot-center-highlight {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    top: 0;
    width: 110px;
    height: 100%;
    border-left: 2px solid rgba(241, 196, 15, 0.5);
    border-right: 2px solid rgba(241, 196, 15, 0.5);
    pointer-events: none;
    z-index: 3;
    background: rgba(241, 196, 15, 0.06);
}

.mb-slot-strip {
    display: flex;
    flex-direction: row;
    height: 130px;
    will-change: transform;
}

.mb-slot-item {
    width: 110px;
    height: 130px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    padding: 6px 4px;
    box-sizing: border-box;
}

.mb-slot-item img {
    width: 52px;
    height: 52px;
    object-fit: contain;
}

.mb-slot-item-name {
    font-size: 10px;
    text-align: center;
    color: #ccc;
    line-height: 1.2;
    max-width: 100px;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.mb-slot-item.rarity-rare {
    background: linear-gradient(to bottom, rgba(52, 152, 219, 0.15), transparent);
}

.mb-slot-item.rarity-legendary {
    background: linear-gradient(to bottom, rgba(241, 196, 15, 0.18), transparent);
}

.mystery-box-shop-item {
    border: 2px solid #f1c40f !important;
    background: linear-gradient(135deg, rgba(241, 196, 15, 0.08) 0%, rgba(44, 62, 80, 0.95) 100%) !important;
    box-shadow: 0 0 12px rgba(241, 196, 15, 0.2);
}

.btn-mystery-box-free {
    background: linear-gradient(135deg, #27ae60, #2ecc71);
    color: #fff;
    border: none;
    border-radius: 6px;
    padding: 10px 16px;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    white-space: nowrap;
    box-shadow: 0 2px 8px rgba(46, 204, 113, 0.4);
    transition: transform 0.1s, box-shadow 0.1s;
}

.btn-mystery-box-free:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(46, 204, 113, 0.6);
}

.btn-mystery-box-paid {
    background: linear-gradient(135deg, #e67e22, #f39c12);
    color: #fff;
    border: none;
    border-radius: 6px;
    padding: 10px 12px;
    font-size: 13px;
    font-weight: bold;
    cursor: pointer;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 4px;
    box-shadow: 0 2px 8px rgba(243, 156, 18, 0.4);
    transition: transform 0.1s, box-shadow 0.1s;
}

.btn-mystery-box-paid:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(243, 156, 18, 0.6);
}

.mb-free-timer {
    font-size: 11px;
    color: #95a5a6;
    text-align: right;
    margin-top: 3px;
}

/* =========================================
   CHAT GLOBAL
   ========================================= */

/* Conteneur principal du chat */
#chat-container {
    max-width: 800px;
    width: 100%;
    height: 400px; /* ~moitié de la map (800px) */
    display: flex;
    flex-direction: column;
    background: #1a1a2e;
    border: 2px solid #444;
    border-top: none;
    border-radius: 0 0 12px 12px;
    overflow: hidden;
    box-shadow: 0 5px 20px rgba(0,0,0,0.4);
}

/* Header du chat */
#chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 14px;
    background: #16213e;
    border-bottom: 1px solid #333;
    min-height: 36px;
    flex-shrink: 0;
}

#chat-title {
    font-size: 14px;
    font-weight: bold;
    color: #f1c40f;
}

#chat-header-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

#chat-slow-mode-indicator {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    color: #e67e22;
    font-weight: bold;
    background: rgba(230,126,34,0.15);
    padding: 3px 8px;
    border-radius: 10px;
}

#chat-slow-mode-timer {
    color: #e74c3c;
    font-weight: bold;
}

#chat-toggle-btn {
    background: none;
    border: 1px solid #555;
    color: #aaa;
    cursor: pointer;
    font-size: 14px;
    padding: 3px 8px;
    border-radius: 4px;
    transition: all 0.2s;
}

#chat-toggle-btn:hover {
    background: #2c3e50;
    color: #ecf0f1;
}

/* Corps du chat */
#chat-body {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0; /* Important pour le flex shrink */
    overflow: hidden;
}

/* Zone des messages */
#chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 8px 12px;
    display: flex;
    flex-direction: column;
    gap: 3px;
    scrollbar-width: thin;
    scrollbar-color: #444 #1a1a2e;
}

#chat-messages::-webkit-scrollbar {
    width: 6px;
}

#chat-messages::-webkit-scrollbar-track {
    background: #1a1a2e;
}

#chat-messages::-webkit-scrollbar-thumb {
    background: #444;
    border-radius: 3px;
}

#chat-messages::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* Message individuel */
.chat-message {
    font-size: 13px;
    line-height: 1.5;
    padding: 2px 0;
    word-wrap: break-word;
    overflow-wrap: break-word;
    color: #ecf0f1; /* Messages globaux : blanc */
}

/* Message privé */
.chat-message-private {
    background: rgba(52, 152, 219, 0.1);
    border-left: 3px solid #3498db;
    padding: 3px 8px;
    border-radius: 0 4px 4px 0;
    margin: 2px 0;
}

.chat-message-private .chat-text-private {
    color: #3498db; /* Messages privés : bleu */
}

/* Éléments d'un message */
.chat-time {
    color: #555;
    font-size: 11px;
    margin-right: 4px;
}

.chat-username {
    font-weight: bold;
    color: #f1c40f;
}

.chat-username-mine {
    color: #2ecc71;
}

.chat-separator {
    color: #666;
    margin-right: 4px;
}

.chat-text {
    color: #ecf0f1;
}

.chat-text-private {
    color: #3498db;
}

.chat-pm-icon {
    font-size: 11px;
    margin-right: 2px;
}

.chat-pm-arrow {
    color: #3498db;
    margin: 0 3px;
    font-weight: bold;
}

/* Zone d'erreur */
#chat-error {
    font-size: 12px;
    color: #e74c3c;
    text-align: center;
    padding: 4px 8px;
    background: rgba(231, 76, 60, 0.1);
    border-top: 1px solid rgba(231,76,60,0.2);
    flex-shrink: 0;
}

/* Zone de saisie */
#chat-input-area {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 10px;
    background: #16213e;
    border-top: 1px solid #333;
    flex-shrink: 0;
}

#chat-input {
    flex: 1;
    padding: 8px 12px;
    background: #0f3460;
    border: 1px solid #444;
    border-radius: 20px;
    color: #ecf0f1;
    font-size: 13px;
    font-family: 'Lato', sans-serif;
    outline: none;
    transition: border-color 0.2s;
}

#chat-input:focus {
    border-color: #f1c40f;
}

#chat-input::placeholder {
    color: #555;
    font-size: 12px;
}

#chat-char-counter {
    font-size: 11px;
    color: #666;
    min-width: 24px;
    text-align: center;
    flex-shrink: 0;
}

#chat-send-btn {
    background: #2ecc71;
    border: none;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 16px;
    transition: background 0.2s, transform 0.1s;
    flex-shrink: 0;
}

#chat-send-btn:hover {
    background: #27ae60;
}

#chat-send-btn:active {
    transform: scale(0.9);
}

/* Chat réduit */
#chat-container.chat-collapsed #chat-body {
    display: none;
}

#chat-container.chat-collapsed {
    height: auto;
}

#chat-container.chat-collapsed #chat-toggle-btn {
    transform: rotate(180deg);
}

/* =========================================
   CHAT - RESPONSIVE MOBILE
   ========================================= */

/* Tablettes et petits écrans */
@media (max-width: 768px) {
    #chat-container {
        height: 280px;
        border-radius: 0 0 8px 8px;
    }

    .chat-message {
        font-size: 12px;
    }

    #chat-input {
        font-size: 14px; /* Plus grand pour le confort sur mobile */
        padding: 8px 10px;
    }

    #chat-input::placeholder {
        font-size: 11px;
    }

    #chat-send-btn {
        width: 34px;
        height: 34px;
        font-size: 14px;
    }

    #chat-header {
        padding: 6px 10px;
    }

    #chat-title {
        font-size: 13px;
    }
}

/* Petits mobiles */
@media (max-width: 480px) {
    #chat-container {
        height: 220px;
        border-width: 1px;
    }

    .chat-message {
        font-size: 11px;
        line-height: 1.4;
    }

    .chat-time {
        font-size: 10px;
    }

    #chat-input-area {
        padding: 6px 8px;
        gap: 4px;
    }

    #chat-input {
        padding: 7px 10px;
        font-size: 14px;
        border-radius: 16px;
    }

    #chat-input::placeholder {
        font-size: 10px;
    }

    #chat-char-counter {
        display: none; /* Cacher le compteur sur très petit écran */
    }

    #chat-send-btn {
        width: 32px;
        height: 32px;
        font-size: 13px;
    }

    #chat-header {
        padding: 5px 8px;
        min-height: 32px;
    }

    #chat-title {
        font-size: 12px;
    }

    #chat-slow-mode-indicator {
        font-size: 10px;
        padding: 2px 6px;
    }
}

/* Mode paysage mobile - chat plus court */
@media (max-height: 500px) and (orientation: landscape) {
    #chat-container {
        height: 150px;
    }

    #chat-header {
        padding: 4px 10px;
        min-height: 28px;
    }

    #chat-input-area {
        padding: 4px 8px;
    }

    #chat-input {
        padding: 5px 10px;
    }

    .chat-message {
        font-size: 11px;
        line-height: 1.3;
        padding: 1px 0;
    }
}

/* =========================================
   TAVERNE (LISTE D'AMIS)
   ========================================= */

/* Ligne d'ami */
.tavern-friend-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    background: rgba(0,0,0,0.25);
    border: 1px solid #444;
    border-radius: 10px;
    margin-bottom: 8px;
    transition: background 0.2s ease, border-color 0.2s ease;
}

.tavern-friend-row:hover {
    background: rgba(243,156,18,0.08);
    border-color: #f39c12;
}

.tavern-friend-info {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.tavern-friend-avatar {
    font-size: 22px;
}

.tavern-status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
    box-shadow: 0 0 4px currentColor;
}

.tavern-status-online {
    background-color: #2ecc71;
    box-shadow: 0 0 6px #2ecc71;
}

.tavern-status-offline {
    background-color: #e74c3c;
    box-shadow: 0 0 4px #e74c3c;
}

.tavern-friend-name {
    color: #ecf0f1;
    font-weight: bold;
    font-size: 14px;
}

/* Boutons d'actions amis */
.tavern-friend-actions {
    display: flex;
    gap: 5px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.tavern-btn {
    padding: 6px 10px;
    border: 2px solid #555;
    border-radius: 8px;
    background: #34495e;
    color: #ecf0f1;
    font-size: 11px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.tavern-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 3px 8px rgba(0,0,0,0.3);
}

.tavern-btn-inspect {
    border-color: #3498db;
    color: #3498db;
}
.tavern-btn-inspect:hover {
    background: #3498db;
    color: white;
}

.tavern-btn-talk {
    border-color: #2ecc71;
    color: #2ecc71;
}
.tavern-btn-talk:hover {
    background: #2ecc71;
    color: white;
}

.tavern-btn-duel {
    border-color: #e74c3c;
    color: #e74c3c;
}
.tavern-btn-duel:hover {
    background: #e74c3c;
    color: white;
}

.tavern-btn-coop {
    border-color: #9b59b6;
    color: #9b59b6;
}
.tavern-btn-coop:hover {
    background: #9b59b6;
    color: white;
}

.tavern-btn-remove {
    border-color: #7f8c8d;
    color: #7f8c8d;
    padding: 6px 8px;
}
.tavern-btn-remove:hover {
    background: #e74c3c;
    border-color: #e74c3c;
    color: white;
}

/* Résultats de recherche */
.tavern-search-result-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 10px;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}

.tavern-search-result-row:last-child {
    border-bottom: none;
}

.tavern-search-username {
    color: #ecf0f1;
    font-size: 13px;
    font-weight: bold;
}

.tavern-add-friend-btn {
    padding: 5px 12px;
    border: 2px solid #2ecc71;
    border-radius: 6px;
    background: transparent;
    color: #2ecc71;
    font-size: 12px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s ease;
}

.tavern-add-friend-btn:hover {
    background: #2ecc71;
    color: white;
}

/* Demandes en attente */
.tavern-pending-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 0;
}

.tavern-pending-name {
    color: #ecf0f1;
    font-size: 13px;
}

.tavern-pending-actions {
    display: flex;
    gap: 5px;
}

.tavern-btn-accept {
    border-color: #2ecc71;
    color: #2ecc71;
}
.tavern-btn-accept:hover {
    background: #2ecc71;
    color: white;
}

.tavern-btn-reject {
    border-color: #e74c3c;
    color: #e74c3c;
}
.tavern-btn-reject:hover {
    background: #e74c3c;
    color: white;
}

/* Panneau d'inspection */
.tavern-inspect-header {
    position: relative;
    margin-bottom: 10px;
}

.tavern-inspect-close {
    position: absolute;
    top: 0;
    right: 0;
    background: none;
    border: none;
    color: #95a5a6;
    font-size: 18px;
    cursor: pointer;
    padding: 5px;
    line-height: 1;
}
.tavern-inspect-close:hover {
    color: #e74c3c;
}

.tavern-inspect-section {
    background: rgba(0,0,0,0.2);
    border-radius: 8px;
    padding: 10px;
    margin-bottom: 10px;
    border: 1px solid rgba(255,255,255,0.05);
}

.tavern-inspect-stats {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.tavern-stat-line {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: #bdc3c7;
}

.tavern-inspect-spells {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}

.tavern-spell-badge {
    background: rgba(0,0,0,0.3);
    border-radius: 6px;
    padding: 3px;
    border: 1px solid #555;
}

.tavern-inspect-team {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.tavern-team-card {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    background: rgba(0,0,0,0.25);
    border-radius: 8px;
    border-left: 3px solid #bdc3c7;
}

.tavern-team-info {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

/* Scrollbar personnalisée pour la taverne */
#tavern-friend-list::-webkit-scrollbar,
#tavern-inspect-panel::-webkit-scrollbar,
#tavern-search-results::-webkit-scrollbar {
    width: 6px;
}

#tavern-friend-list::-webkit-scrollbar-track,
#tavern-inspect-panel::-webkit-scrollbar-track,
#tavern-search-results::-webkit-scrollbar-track {
    background: rgba(0,0,0,0.2);
    border-radius: 3px;
}

#tavern-friend-list::-webkit-scrollbar-thumb,
#tavern-inspect-panel::-webkit-scrollbar-thumb,
#tavern-search-results::-webkit-scrollbar-thumb {
    background: #555;
    border-radius: 3px;
}

#tavern-friend-list::-webkit-scrollbar-thumb:hover,
#tavern-inspect-panel::-webkit-scrollbar-thumb:hover,
#tavern-search-results::-webkit-scrollbar-thumb:hover {
    background: #777;
}

/* Taverne — popup positionné juste sous le bloc settings */
#tavern-popup-overlay {
    align-items: flex-start !important;
    padding-top: 62px !important;
    box-sizing: border-box !important;
}

#tavern-popup {
    max-height: calc(90vh - 62px) !important;
}

#tavern-close-btn {
    top: 15px !important;
}

#tavern-title {
    padding-right: 130px;
}

/* Responsive taverne */
@media (max-width: 700px) {
    #tavern-popup {
        max-width: 100% !important;
        width: 100% !important;
        border-radius: 10px !important;
        padding: 15px !important;
        max-height: 90vh !important;
    }

    .tavern-friend-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .tavern-friend-actions {
        width: 100%;
        justify-content: flex-start;
    }

    .tavern-btn {
        font-size: 10px;
        padding: 5px 8px;
    }

}

/* Style du bouton Delete (rouge) */
.tavern-btn-remove {
    color: #e74c3c !important;
    background: rgba(231,76,60,0.15) !important;
    border-color: #e74c3c !important;
    font-weight: bold !important;
}

.tavern-btn-remove:hover {
    background: rgba(231,76,60,0.35) !important;
}

/* =========================================
   PVP POPUPS
   ========================================= */

.pvp-popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.75);
    z-index: 100100;
    display: flex;
    justify-content: center;
    align-items: center;
}

.pvp-popup {
    background: linear-gradient(135deg, #1e272e 0%, #2c3e50 100%);
    border: 3px solid #f39c12;
    border-radius: 15px;
    padding: 30px;
    max-width: 400px;
    width: 90%;
    text-align: center;
    color: #ecf0f1;
    box-shadow: 0 15px 50px rgba(243, 156, 18, 0.3);
}

.pvp-popup-icon {
    font-size: 48px;
    margin-bottom: 15px;
}

.pvp-popup-btn {
    padding: 10px 25px;
    border: none;
    border-radius: 8px;
    font-weight: bold;
    cursor: pointer;
    margin: 5px;
    font-size: 14px;
    transition: opacity 0.2s;
}

.pvp-popup-btn:hover {
    opacity: 0.85;
}

.pvp-btn-accept {
    background: #2ecc71;
    color: #fff;
}

.pvp-btn-decline {
    background: #e74c3c;
    color: #fff;
}

.pvp-btn-cancel {
    background: #7f8c8d;
    color: #fff;
}

.pvp-btn-return {
    background: #3498db;
    color: #fff;
}

.pvp-challenge-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-top: 15px;
}

.pvp-progress-bar {
    width: 100%;
    height: 6px;
    background: #34495e;
    border-radius: 3px;
    margin: 15px 0;
    overflow: hidden;
}

.pvp-progress-bar > div {
    height: 100%;
    background: #f39c12;
    border-radius: 3px;
    transition: width 0.5s linear;
}

/* =========================================
   CO-OP DUNGEONS
   ========================================= */

.coop-popup {
    border-color: #2ecc71 !important;
    box-shadow: 0 15px 50px rgba(46, 204, 113, 0.3) !important;
}

.coop-popup .pvp-progress-bar > div {
    background: #2ecc71;
}

.coop-dungeon-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    margin-bottom: 8px;
    background: rgba(46, 204, 113, 0.1);
    border: 1px solid rgba(46, 204, 113, 0.3);
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s;
}

.coop-dungeon-row:hover {
    background: rgba(46, 204, 113, 0.25);
    border-color: #2ecc71;
}

.coop-dungeon-row .dungeon-name {
    font-weight: bold;
    color: #ecf0f1;
    font-size: 14px;
}

.coop-dungeon-row .dungeon-keys {
    font-size: 12px;
    color: #bdc3c7;
}

.timeline-coop-partner {
    border: 2px solid #3498db !important;
}

.timeline-entity.active.timeline-coop-partner {
    border-color: #f1c40f !important;
}

/* =========================================
   JEWELRY POPUP - positionné juste sous le bloc settings
   ========================================= */

#jewelry-popup-overlay {
    align-items: flex-start !important;
    padding-top: 62px !important;
    box-sizing: border-box !important;
}

#jewelry-popup {
    max-height: calc(90vh - 62px) !important;
}

#jewelry-close-btn {
    top: 15px !important;
}

#jewelry-popup-title {
    padding-right: 130px;
}

/* =============================================
   COLISEUM
   ============================================= */

.coliseum-screen {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
    border: 3px solid #f1c40f;
    border-radius: 20px;
    padding: 20px;
    max-width: 700px;
    width: 95%;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 0 40px rgba(241, 196, 15, 0.3), 0 15px 50px rgba(0,0,0,0.6);
}

.coliseum-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.coliseum-title {
    color: #f1c40f;
    margin: 0;
    font-size: 1.5em;
    text-shadow: 0 0 15px rgba(241, 196, 15, 0.5);
}

/* Conteneurs des popups avec bouton CLOSE en haut à droite */
#tavern-popup,
#jewelry-popup {
    position: relative;
}

.coliseum-close-btn {
    background: #e74c3c;
    border: 3px solid #c0392b;
    border-radius: 8px;
    color: white;
    font-size: 18px;
    font-weight: bold;
    cursor: pointer;
    padding: 12px 24px;
    transition: all 0.2s ease;
    font-family: 'Lato', sans-serif;
    letter-spacing: 2px;
    min-width: 100px;
    text-align: center;
    text-transform: uppercase;
    box-shadow: 0 4px 12px rgba(231, 76, 60, 0.5), 0 2px 4px rgba(0, 0, 0, 0.6);
}
.coliseum-close-btn:hover {
    background: #c0392b;
    border-color: #a93226;
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(231, 76, 60, 0.7), 0 4px 8px rgba(0, 0, 0, 0.7);
}
.coliseum-close-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(231, 76, 60, 0.5), 0 1px 2px rgba(0, 0, 0, 0.6);
}

/* Tabs */
.coliseum-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 15px;
}

.coliseum-tab {
    flex: 1;
    padding: 10px 15px;
    border: 2px solid #555;
    border-radius: 10px;
    background: #2c3e50;
    color: #bdc3c7;
    font-size: 0.95em;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s;
}
.coliseum-tab:hover {
    background: #34495e;
    border-color: #f1c40f;
    color: #f1c40f;
}
.coliseum-tab.active {
    background: linear-gradient(135deg, #f39c12, #f1c40f);
    color: #1a1a2e;
    border-color: #f1c40f;
}

/* Section container */
.coliseum-section {
    flex: 1;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: #f1c40f #1a1a2e;
}

/* Doors container */
.coliseum-doors-container {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* Individual door card */
.coliseum-door {
    background: linear-gradient(135deg, #2c3e50 0%, #34495e 100%);
    border: 2px solid #555;
    border-radius: 12px;
    padding: 12px 15px;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: all 0.3s;
}
.coliseum-door:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 20px rgba(0,0,0,0.3);
}

/* Door tiers */
.coliseum-door[data-tier="bronze"] { border-color: #cd7f32; }
.coliseum-door[data-tier="silver"] { border-color: #c0c0c0; }
.coliseum-door[data-tier="gold"]   { border-color: #ffd700; }
.coliseum-door[data-tier="platinum"] { border-color: #e5e4e2; box-shadow: 0 0 10px rgba(229,228,226,0.3); }
.coliseum-door[data-tier="diamond"] { border-color: #b9f2ff; box-shadow: 0 0 15px rgba(185,242,255,0.4); }

.coliseum-door[data-tier="bronze"] .coliseum-door-tier { color: #cd7f32; }
.coliseum-door[data-tier="silver"] .coliseum-door-tier { color: #c0c0c0; }
.coliseum-door[data-tier="gold"] .coliseum-door-tier   { color: #ffd700; }
.coliseum-door[data-tier="platinum"] .coliseum-door-tier { color: #e5e4e2; }
.coliseum-door[data-tier="diamond"] .coliseum-door-tier { color: #b9f2ff; }

.coliseum-door-header {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 130px;
}
.coliseum-door-icon {
    font-size: 1.4em;
}
.coliseum-door-tier {
    font-weight: bold;
    font-size: 0.9em;
}

.coliseum-door-bet {
    color: #f1c40f;
    font-weight: bold;
    font-size: 0.95em;
    min-width: 120px;
    text-align: center;
}

.coliseum-door-status {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 100px;
}

.coliseum-status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
}
.coliseum-status-dot.free {
    background: #2ecc71;
    box-shadow: 0 0 6px #2ecc71;
}
.coliseum-status-dot.occupied {
    background: #e74c3c;
    box-shadow: 0 0 6px #e74c3c;
    animation: coliseum-pulse 1.5s ease-in-out infinite;
}

.coliseum-status-text {
    color: #ecf0f1;
    font-size: 0.85em;
}

@keyframes coliseum-pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.6; transform: scale(1.3); }
}

.coliseum-door-btn {
    margin-left: auto;
    padding: 8px 14px;
    border: 2px solid #3498db;
    border-radius: 8px;
    background: linear-gradient(135deg, #2980b9, #3498db);
    color: #fff;
    font-weight: bold;
    font-size: 0.85em;
    cursor: pointer;
    transition: all 0.3s;
    white-space: nowrap;
}
.coliseum-door-btn:hover {
    background: linear-gradient(135deg, #3498db, #5dade2);
    transform: scale(1.05);
}
.coliseum-door-btn.fight {
    background: linear-gradient(135deg, #e74c3c, #c0392b);
    border-color: #e74c3c;
    animation: coliseum-fight-glow 1.5s ease-in-out infinite;
}
.coliseum-door-btn.fight:hover {
    background: linear-gradient(135deg, #c0392b, #e74c3c);
}

@keyframes coliseum-fight-glow {
    0%, 100% { box-shadow: 0 0 5px rgba(231, 76, 60, 0.3); }
    50% { box-shadow: 0 0 20px rgba(231, 76, 60, 0.7); }
}

/* Waiting zone */
.coliseum-waiting-zone {
    text-align: center;
    padding: 30px 20px;
    margin-top: 15px;
    background: linear-gradient(135deg, #1e272e 0%, #2c3e50 100%);
    border: 2px solid #f39c12;
    border-radius: 15px;
    animation: coliseum-waiting-border 3s linear infinite;
}

@keyframes coliseum-waiting-border {
    0%   { border-color: #f39c12; }
    33%  { border-color: #f1c40f; }
    66%  { border-color: #e67e22; }
    100% { border-color: #f39c12; }
}

.coliseum-waiting-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #555;
    border-top: 4px solid #f1c40f;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 15px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.coliseum-waiting-text {
    color: #f1c40f;
    font-size: 1.1em;
    font-weight: bold;
    margin: 0 0 8px;
}

.coliseum-waiting-bet {
    color: #ecf0f1;
    font-size: 0.95em;
    margin: 0 0 15px;
}

.coliseum-leave-btn {
    padding: 10px 25px;
    border: 2px solid #e74c3c;
    border-radius: 8px;
    background: linear-gradient(135deg, #c0392b, #e74c3c);
    color: #fff;
    font-weight: bold;
    font-size: 0.95em;
    cursor: pointer;
    transition: all 0.3s;
}
.coliseum-leave-btn:hover {
    background: linear-gradient(135deg, #e74c3c, #ff6b6b);
    transform: scale(1.05);
}

/* Rankings */
.coliseum-search-bar {
    display: flex;
    gap: 8px;
    margin-bottom: 15px;
}

.coliseum-search-bar input {
    flex: 1;
    padding: 10px 15px;
    border: 2px solid #555;
    border-radius: 10px;
    background: #2c3e50;
    color: #ecf0f1;
    font-size: 0.95em;
    outline: none;
    transition: border-color 0.3s;
}
.coliseum-search-bar input:focus {
    border-color: #f1c40f;
}
.coliseum-search-bar input::placeholder {
    color: #7f8c8d;
}

.coliseum-search-btn {
    padding: 10px 15px;
    border: 2px solid #f1c40f;
    border-radius: 10px;
    background: #2c3e50;
    color: #f1c40f;
    font-size: 1.1em;
    cursor: pointer;
    transition: all 0.3s;
}
.coliseum-search-btn:hover {
    background: #f1c40f;
    color: #1a1a2e;
}

.coliseum-ranking-table-wrapper {
    overflow-x: auto;
}

.coliseum-ranking-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9em;
}

.coliseum-ranking-table thead th {
    background: #2c3e50;
    color: #f1c40f;
    padding: 10px 8px;
    text-align: left;
    border-bottom: 2px solid #f1c40f;
    position: sticky;
    top: 0;
    z-index: 1;
}

.coliseum-ranking-table tbody tr {
    border-bottom: 1px solid #34495e;
    transition: background 0.2s;
}
.coliseum-ranking-table tbody tr:hover {
    background: rgba(241, 196, 15, 0.1);
}

.coliseum-ranking-table td {
    padding: 10px 8px;
    color: #ecf0f1;
}

/* Top 3 highlight */
.coliseum-ranking-table tbody tr.rank-1 td:first-child { color: #ffd700; font-weight: bold; font-size: 1.1em; }
.coliseum-ranking-table tbody tr.rank-2 td:first-child { color: #c0c0c0; font-weight: bold; }
.coliseum-ranking-table tbody tr.rank-3 td:first-child { color: #cd7f32; font-weight: bold; }

.coliseum-ranking-table tbody tr.rank-1 { background: rgba(255, 215, 0, 0.08); }
.coliseum-ranking-table tbody tr.rank-2 { background: rgba(192, 192, 192, 0.06); }
.coliseum-ranking-table tbody tr.rank-3 { background: rgba(205, 127, 50, 0.06); }

/* Pagination */
.coliseum-ranking-pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
    margin-top: 15px;
    padding-top: 10px;
    border-top: 1px solid #34495e;
}

.coliseum-page-btn {
    padding: 6px 14px;
    border: 2px solid #555;
    border-radius: 8px;
    background: #2c3e50;
    color: #ecf0f1;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s;
}
.coliseum-page-btn:hover:not(:disabled) {
    border-color: #f1c40f;
    color: #f1c40f;
}
.coliseum-page-btn:disabled {
    opacity: 0.4;
    cursor: default;
}

#coliseum-rank-page {
    color: #f1c40f;
    font-weight: bold;
    font-size: 1em;
}

/* Mobile responsive */
@media (max-width: 600px) {
    #coliseum-popup-overlay {
        padding-top: 115px !important;
    }

    .coliseum-screen {
        width: 100%;
        max-width: 100%;
        border-radius: 0;
        max-height: calc(100vh - 115px);
        height: calc(100vh - 115px);
        padding: 12px;
    }

    .coliseum-door {
        flex-wrap: wrap;
        gap: 8px;
        padding: 10px;
    }

    .coliseum-door-header {
        min-width: unset;
        flex: 1;
    }

    .coliseum-door-bet {
        min-width: unset;
        font-size: 0.85em;
    }

    .coliseum-door-status {
        min-width: unset;
    }

    .coliseum-door-btn {
        width: 100%;
        margin-left: 0;
        text-align: center;
        padding: 10px;
    }

    .coliseum-tabs {
        gap: 5px;
    }
    .coliseum-tab {
        padding: 8px 10px;
        font-size: 0.85em;
    }
}