/* --- GLOBAL --- */

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: #111827; }
::-webkit-scrollbar-thumb { background: #374151; border-radius: 4px; }

/* TIER LIST ROW */
.tier-row { 
    display: flex; align-items: stretch; border-bottom: 1px solid #1f2937; 
    min-height: 120px; /* Réduit un peu pour les petits écrans */
    background: #0f172a; 
}

.tier-label { 
    width: 80px; /* Mobile : plus étroit */
    display: flex; align-items: center; justify-content: center; 
    font-weight: 900; font-size: 20px; color: #000; 
    text-shadow: 0 1px 2px rgba(255,255,255,0.4); 
    outline: none; word-break: break-word; text-align: center; 
    padding: 2px; flex-shrink: 0; cursor: text; 
}
/* Laptop/Desktop : label plus large */
@media (min-width: 1024px) {
    .tier-label { width: 200px; font-size: 22px; padding: 5px; }
    .tier-row { min-height: 170px; }
}

.tier-settings { 
    width: 30px; background-color: #1e293b; border-right: 1px solid #374151; 
    display: flex; flex-direction: column; align-items: center; 
    justify-content: space-evenly; flex-shrink: 0; 
}
@media (min-width: 1024px) { .tier-settings { width: 40px; } }

/* SETTINGS BUTTONS */
.setting-btn { 
    width: 24px; height: 24px; border-radius: 6px; cursor: pointer; 
    display: flex; align-items: center; justify-content: center; 
    font-size: 12px; color: #9ca3af; transition: all 0.2s; 
}
.setting-btn:hover { background: #374151; color: white; }

/* COLOR PICKER */
.color-wrapper { 
    width: 20px; height: 20px; border-radius: 50%; overflow: hidden; 
    border: 2px solid #374151; position: relative; cursor: pointer;
    box-shadow: inset 0 0 5px rgba(0,0,0,0.5);
}
@media (min-width: 1024px) { .color-wrapper { width: 26px; height: 26px; } }

.color-wrapper input[type="color"] { 
    position: absolute; top: -50%; left: -50%; 
    width: 200%; height: 200%; padding: 0; margin: 0; 
    border: none; cursor: pointer; background: none;
}
input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
input[type="color"]::-webkit-color-swatch { border: none; }

.tier-items { flex-grow: 1; display: flex; flex-wrap: wrap; padding: 4px; gap: 4px; background: #0f172a; align-content: center; }
@media (min-width: 1024px) { .tier-items { padding: 8px; gap: 8px; } }

/* SIDEBAR & SEARCH */
.sidebar-section { border-bottom: 1px solid #374151; padding: 10px; display: flex; flex-direction: column; }
.search-input { 
    background: #1f2937; border: 1px solid #374151; color: white; 
    padding: 10px; border-radius: 8px; width: 100%; outline: none; 
    transition: border 0.2s; font-size: 16px; 
}
.search-input:focus { border-color: #3b82f6; }

#results { 
    display: grid; grid-template-columns: repeat(auto-fill, minmax(90px, 1fr)); 
    gap: 8px; padding: 10px; overflow-y: auto; align-items: start;
    /* Mobile : hauteur flexible pour les résultats */
    min-height: 200px;
    max-height: 30vh; /* Réduit pour laisser place à la zone d'attente */
}
@media (min-width: 1024px) {
    #results { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 12px; max-height: 45vh; padding: 15px;}
}

/* ZONE D'ATTENTE RESPONSIVE */
#unranked { 
    display: flex; 
    flex-wrap: wrap; /* On autorise le retour à la ligne */
    gap: 8px; 
    padding: 10px; 
    align-content: flex-start;
    
    /* Mobile : Hauteur juste nécessaire pour afficher une game card (106px) + padding */
    min-height: 110px; 
    max-height: 45vh; /* Augmenté pour plus de confort */
    overflow-y: auto; /* Scroll vertical si on a trop de jeux */
}

/* PC : On garde la logique sidebar verticale */
@media (min-width: 1024px) {
    #unranked { 
        padding: 10px; 
        min-height: 100px; 
        max-height: none; /* Sur PC, c'est le layout flex qui gère la hauteur */
        flex-grow: 1; 
    }
}

/* CARDS */
.game-card { 
    width: 80px; height: 106px; /* Mobile : plus petit */
    cursor: grab; background-size: cover; background-position: center; 
    border-radius: 4px; border: 1px solid #333; position: relative; 
    box-shadow: 0 2px 4px rgba(0,0,0,0.5); flex-shrink: 0;
    flex-shrink: 0; 
}
@media (min-width: 1024px) {
    .game-card { width: 120px; height: 160px; border-radius: 6px; box-shadow: 0 4px 6px rgba(0,0,0,0.5); }
}

.delete-card-btn { 
    display: none; 
    position: absolute; 
    top: -8px; 
    right: -8px; 
    background: #ef4444; 
    color: white; 
    border-radius: 50%; 
    width: 20px; 
    height: 20px; 
    text-align: center;
    line-height: 20px;
    font-weight: bold; 
    font-size: 12px; 
    cursor: pointer; 
    z-index: 20;
}
.game-card:hover .delete-card-btn { display: block; }

/* Mobile : Bouton un peu plus grand mais raisonnable */
@media (max-width: 1024px) { 
    .delete-card-btn { 
        display: block;
        opacity: 0.95; 
        width: 26px; 
        height: 26px; 
        line-height: 26px;
        font-size: 14px;
        top: -10px;
        right: -10px;
        touch-action: manipulation;
    }
}

/* Feedback visuel pendant le drag depuis la recherche */
.search-result.sortable-ghost {
    opacity: 0.3 !important;
    transform: scale(0.95);
}

.search-result.sortable-drag {
    cursor: grabbing !important;
    box-shadow: 0 8px 16px rgba(0,0,0,0.5);
    transform: rotate(2deg);
}

/* SEARCH RESULTS */
.search-result { cursor: pointer; width: 90px; display: flex; flex-direction: column; align-items: center; margin-bottom: 8px; }
.search-result img { width: 90px; height: 120px; border-radius: 6px; object-fit: cover; border: 2px solid transparent; flex-shrink: 0; }
@media (min-width: 1024px) {
    .search-result { width: 110px; }
    .search-result img { width: 110px; height: 148px; }
}
.search-result:hover img { border-color: #3b82f6; }
.search-result-title { font-size: 10px; text-align: center; line-height: 1.1; margin-top: 4px; width: 100%; color: #e5e7eb; font-weight: 500; word-wrap: break-word; }

/* FILTERS */
.filter-chip { padding: 4px 8px; border-radius: 20px; font-size: 10px; font-weight: bold; cursor: pointer; border: 1px solid transparent; transition: all 0.2s; user-select: none; opacity: 0.5; filter: grayscale(0.8); white-space: nowrap; margin-bottom: 4px;}
.filter-chip.active { opacity: 1; filter: grayscale(0); border-color: rgba(255,255,255,0.2); transform: scale(1.05); }

/* BADGES & COLORS */
.bg-main { background: #2563eb; color: white; }
.bg-remake { background: #f59e0b; color: black; }
.bg-remaster { background: #06b6d4; color: white; }
.bg-dlc { background: #9333ea; color: white; }
.bg-fangame { background: #be185d; color: white; }
.bg-junk { background: #374151; color: #d1d5db; }
.cat-badge { font-size: 8px; padding: 1px 4px; border-radius: 3px; position: absolute; bottom: 2px; right: 2px; font-weight: bold; box-shadow: 0 1px 3px rgba(0,0,0,0.9); }

.loader { border: 3px solid #f3f3f3; border-top: 3px solid #3b82f6; border-radius: 50%; width: 20px; height: 20px; animation: spin 1s linear infinite; display: none; }
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

.btn-header { padding: 8px 12px; border-radius: 6px; font-size: 12px; font-weight: bold; display: flex; align-items: center; gap: 4px; transition: background 0.2s; white-space: nowrap; justify-content: center; }
@media (min-width: 1024px) { .btn-header { padding: 6px 16px; font-size: 14px; gap: 6px; } }

/* FIX Z-INDEX - Couches d'affichage */
#left-panel { position: relative; z-index: 1; }

.btn-add-row {
    margin-top: 10px; width: 100%; border: 2px dashed #374151; color: #9ca3af;
    border-radius: 8px; padding: 12px; font-weight: bold; cursor: pointer; transition: all 0.2s;
    display: flex; align-items: center; justify-content: center; gap: 10px;
}
.btn-add-row:hover { border-color: #60a5fa; color: #60a5fa; background: rgba(37, 99, 235, 0.05); }

/* Language Selector */
[data-lang-btn] {
    transition: all 0.2s;
    font-weight: 500;
}

[data-lang-btn].lang-active {
    background: #3b82f6;
    color: white;
    font-weight: 700;
}

[data-lang-btn]:not(.lang-active):hover {
    background: #374151;
}