* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
}

header {
    background: white;
    border-radius: 15px;
    padding: 20px 30px;
    margin-bottom: 30px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

h1 {
    color: #333;
    font-size: 2em;
}

.actions {
    display: flex;
    gap: 10px;
}

.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.btn-primary {
    background: #667eea;
    color: white;
}

.btn-primary:hover {
    background: #5a67d8;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.btn-secondary {
    background: #48bb78;
    color: white;
}

.btn-secondary:hover {
    background: #38a169;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(72, 187, 120, 0.4);
}

.btn-danger {
    background: #f56565;
    color: white;
}

.btn-danger:hover {
    background: #e53e3e;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(245, 101, 101, 0.4);
}

.btn-admin {
    background: #805ad5;
    color: white;
}

.btn-admin:hover {
    background: #6b46c1;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(128, 90, 213, 0.4);
}

main {
    background: white;
    border-radius: 15px;
    padding: 30px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
}

.tierlist {
    margin-bottom: 30px;
}

.tier-row {
    display: flex;
    margin-bottom: 10px;
    min-height: 100px;
    background: #f7fafc;
    border-radius: 10px;
    overflow: hidden;
}

.tier-label {
    width: 100px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    color: white;
    position: relative;
    cursor: pointer;
    padding: 5px;
    box-sizing: border-box;
}

.tier-text {
    line-height: 1.1;
    user-select: none;
    text-align: center;
    word-break: break-word;
    hyphens: auto;
    max-width: 90px;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: clamp(1.2em, 4vw, 2.5em);
    max-height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.edit-tier-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    border-radius: 50%;
    width: 25px;
    height: 25px;
    font-size: 12px;
    cursor: pointer;
    margin-top: 5px;
    opacity: 0;
    transition: all 0.3s ease;
    color: white;
}

.tier-label:hover .edit-tier-btn {
    opacity: 1;
}

.edit-tier-btn:hover {
    background: rgba(255, 255, 255, 0.4);
    transform: scale(1.1);
}

.tier-input {
    background: rgba(255, 255, 255, 0.9);
    border: 2px solid white;
    border-radius: 5px;
    color: #333;
    font-size: 0.8em;
    font-weight: bold;
    text-align: center;
    width: 80px;
    padding: 5px;
    margin: 2px 0;
}

.s-tier {
    background: linear-gradient(135deg, #ff6b6b, #ff8e53);
}

.a-tier {
    background: linear-gradient(135deg, #feca57, #ff9ff3);
}

.b-tier {
    background: linear-gradient(135deg, #48dbfb, #0abde3);
}

.c-tier {
    background: linear-gradient(135deg, #00d2d3, #54a0ff);
}

.tier-items {
    flex: 1;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    padding: 10px;
    gap: 10px;
    min-height: 100px;
    border: 2px dashed transparent;
    transition: all 0.3s ease;
}

.tier-items.drag-over {
    background: rgba(102, 126, 234, 0.1);
    border-color: #667eea;
}

.unranked-section {
    margin-top: 40px;
}

.unranked-section h3 {
    color: #4a5568;
    margin-bottom: 15px;
    font-size: 1.3em;
}

.unranked-items {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    padding: 20px;
    background: #f7fafc;
    border-radius: 10px;
    min-height: 150px;
    border: 2px dashed #cbd5e0;
    transition: all 0.3s ease;
}

.unranked-items.drag-over {
    background: rgba(102, 126, 234, 0.1);
    border-color: #667eea;
}

.icon-item {
    width: 80px;
    height: 80px;
    border-radius: 10px;
    overflow: hidden;
    cursor: move;
    transition: all 0.3s ease;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    position: relative;
}

.icon-item:hover {
    transform: scale(1.1);
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.2);
    z-index: 10;
}

.icon-item.dragging {
    opacity: 0.5;
    transform: scale(0.9);
}

.icon-item.touch-dragging {
    opacity: 0.3;
    transform: scale(0.8);
}

.touch-ghost {
    border: 2px solid #667eea;
    box-shadow: 0 10px 30px rgba(102, 126, 234, 0.5) !important;
}

.tier-items.touch-drag-over,
.unranked-items.touch-drag-over {
    background: rgba(102, 126, 234, 0.2) !important;
    border-color: #667eea !important;
    border-style: solid !important;
}

/* Améliorer l'UX tactile */
@media (hover: none) and (pointer: coarse) {
    .icon-item {
        cursor: default;
        user-select: none;
        -webkit-user-select: none;
        -webkit-touch-callout: none;
    }
    
    .icon-item:active {
        transform: scale(0.95);
        transition: transform 0.1s ease;
    }
}

.icon-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    pointer-events: none;
}

/* Modal styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    animation: fadeIn 0.3s ease;
}

.modal-content {
    background-color: white;
    margin: 10% auto;
    padding: 30px;
    border-radius: 15px;
    width: 90%;
    max-width: 500px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: slideIn 0.3s ease;
}

.modal-large {
    max-width: 900px;
}

.close {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    transition: color 0.3s ease;
}

.close:hover {
    color: #000;
}

.modal h2 {
    color: #333;
    margin-bottom: 20px;
}

.share-link-container {
    margin-top: 20px;
}

.share-link-container label {
    display: block;
    margin-bottom: 10px;
    color: #666;
    font-weight: 500;
}

.share-link-group {
    display: flex;
    gap: 10px;
}

#shareLink {
    flex: 1;
    padding: 10px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    font-size: 14px;
    background: #f7fafc;
}

#imageContainer {
    margin: 20px 0;
    text-align: center;
    max-height: 500px;
    overflow-y: auto;
}

#imageContainer img {
    max-width: 100%;
    border-radius: 10px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideIn {
    from {
        transform: translateY(-50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Responsive design */
@media (max-width: 768px) {
    header {
        flex-direction: column;
        gap: 20px;
    }

    .actions {
        flex-wrap: wrap;
        justify-content: center;
    }

    .tier-label {
        width: 70px;
        padding: 3px;
    }

    .tier-text {
        max-width: 65px;
        font-size: clamp(0.8em, 5vw, 1.8em) !important;
        max-height: 60px;
    }

    .edit-tier-btn {
        width: 20px;
        height: 20px;
        font-size: 10px;
        margin-top: 3px;
    }

    .tier-input {
        width: 60px;
        font-size: 0.7em;
        padding: 3px;
    }

    .icon-item {
        width: 60px;
        height: 60px;
    }

    .tier-row {
        min-height: 80px;
    }
}

@media (max-width: 480px) {
    .tier-label {
        width: 60px;
        padding: 2px;
    }

    .tier-text {
        max-width: 55px;
        font-size: clamp(0.6em, 4vw, 1.5em) !important;
        max-height: 50px;
    }

    .tier-input {
        width: 50px;
        font-size: 0.6em;
    }

    .tier-row {
        min-height: 70px;
    }

    .icon-item {
        width: 50px;
        height: 50px;
    }
}
