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

body {
    font-family: 'Crimson Text', 'Times New Roman', serif;
    background: 
        /* Central warm glow */
        radial-gradient(ellipse at 50% 50%, rgba(255, 180, 80, 0.12), transparent 60%),
        /* Softer fireplace smoke */
        radial-gradient(ellipse at 20% 0%, rgba(160, 140, 120, 0.08), transparent 40%),
        radial-gradient(ellipse at 80% 0%, rgba(180, 150, 130, 0.06), transparent 35%),
        /* Warmer fireplace glow */
        radial-gradient(circle at 10% 90%, rgba(255, 120, 40, 0.25), transparent 50%),
        radial-gradient(circle at 90% 90%, rgba(255, 160, 60, 0.20), transparent 45%),
        /* Warmer candlelight */
        radial-gradient(circle at 30% 20%, rgba(255, 200, 80, 0.15), transparent 30%),
        radial-gradient(circle at 70% 25%, rgba(255, 220, 100, 0.12), transparent 25%),
        /* Fond principal plus chaleureux */
        linear-gradient(135deg, #2a1810 0%, #3d251a 30%, #2a1810 60%, #1f140c 100%);
    min-height: 100vh;
    color: #ffd700;
    position: relative;
    overflow-x: hidden;
}

/* Warmer animated fireplace flames effect */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: 
        /* Warmer dancing flames */
        radial-gradient(ellipse at 15% 85%, rgba(255, 120, 30, 0.3), transparent 40%),
        radial-gradient(ellipse at 85% 85%, rgba(255, 180, 60, 0.25), transparent 35%),
        radial-gradient(ellipse at 50% 95%, rgba(255, 140, 80, 0.2), transparent 30%),
        /* Warmer candle flickering */
        radial-gradient(ellipse at 25% 15%, rgba(255, 200, 80, 0.18), transparent 20%),
        radial-gradient(ellipse at 75% 20%, rgba(255, 220, 100, 0.15), transparent 18%);
    pointer-events: none;
    z-index: -1;
    animation: tavernFire 6s ease-in-out infinite;
}

/* Smoke particles */
body::after {
    content: '';
    position: fixed;
    top: -10%;
    left: 0;
    right: 0;
    bottom: 0;
    background: 
        radial-gradient(2px 2px at 20% 30%, rgba(139, 134, 128, 0.3), transparent),
        radial-gradient(2px 2px at 40% 70%, rgba(139, 134, 128, 0.2), transparent),
        radial-gradient(1px 1px at 80% 10%, rgba(139, 134, 128, 0.3), transparent),
        radial-gradient(1px 1px at 90% 40%, rgba(139, 134, 128, 0.2), transparent);
    background-size: 200px 200px, 150px 150px, 100px 100px, 120px 120px;
    pointer-events: none;
    z-index: -1;
    animation: smoke 20s linear infinite;
}

@keyframes tavernFire {
    0%, 100% { 
        opacity: 1;
        filter: blur(0px);
    }
    25% { 
        opacity: 0.8;
        filter: blur(0.5px);
    }
    50% { 
        opacity: 1.2;
        filter: blur(0px);
    }
    75% { 
        opacity: 0.9;
        filter: blur(0.3px);
    }
}

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

.container {
    max-width: 1600px;
    margin: 0 auto;
    padding: 15px;
    position: relative;
    height: 100vh;
    display: flex;
    flex-direction: column;
}

header {
    background: transparent;
    padding: 20px 25px;
    margin-bottom: 0px;
    position: relative;
    overflow: hidden;
    flex-shrink: 0;
}



header h1 {
    color: #ffd700;
    margin-bottom: 20px;
    text-align: center;
    font-size: 2.4rem;
    text-shadow: 
        4px 4px 12px rgba(0, 0, 0, 0.95),
        0 0 20px rgba(255, 215, 0, 0.8),
        0 0 40px rgba(255, 140, 0, 0.4),
        2px 2px 8px rgba(0, 0, 0, 0.9);
    font-weight: 700;
    letter-spacing: 3px;
    position: relative;
    z-index: 1;
}

.home-link {
    color: inherit;
    text-decoration: none;
    transition: all 0.3s ease;
    cursor: pointer;
    display: inline-block;
}

.home-link:hover {
    color: #fff8dc;
    transform: scale(1.02);
    text-shadow: 
        4px 4px 12px rgba(0, 0, 0, 0.95),
        0 0 25px rgba(255, 215, 0, 0.9),
        0 0 50px rgba(255, 140, 0, 0.6),
        2px 2px 8px rgba(0, 0, 0, 0.9);
}

.deck-info {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 15px;
    position: relative;
    z-index: 1;
    background: 
        linear-gradient(145deg, 
            rgba(120, 80, 45, 0.95) 0%, 
            rgba(100, 65, 35, 0.98) 50%, 
            rgba(80, 55, 30, 0.95) 100%);
    padding: 10px;
    border-radius: 6px;
    border: 2px solid rgba(218, 165, 32, 0.3);
    box-shadow: 
        0 5px 15px rgba(0, 0, 0, 0.5),
        inset 0 2px 4px rgba(255, 200, 80, 0.2);
    width: 100%;
    flex-shrink: 0;
}



.faction-selectors {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: space-between;
    margin-bottom: 10px;
    min-height: 0;
}

#primary-faction, #secondary-faction {
    background: 
        linear-gradient(145deg, 
            rgba(160, 90, 40, 0.9) 0%, 
            rgba(120, 80, 45, 0.95) 50%, 
            rgba(100, 65, 35, 0.9) 100%);
    border: 2px solid rgba(180, 140, 60, 0.8);
    border-radius: 6px;
    padding: 6px 8px;
    font-family: 'Crimson Text', serif;
    font-size: 0.85rem;
    font-weight: 600;
    color: #ffd700;
    flex: 1;
    min-width: 120px;
    box-shadow: 
        inset 0 2px 4px rgba(0, 0, 0, 0.5),
        0 2px 8px rgba(0, 0, 0, 0.3),
        0 0 10px rgba(255, 180, 60, 0.15);
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
    cursor: pointer;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

#primary-faction:focus, #secondary-faction:focus {
    outline: none;
    border-color: #ffd700;
    box-shadow: 
        inset 0 2px 4px rgba(0, 0, 0, 0.5),
        0 2px 8px rgba(0, 0, 0, 0.3),
        0 0 15px rgba(255, 215, 0, 0.4);
}

#primary-faction option, #secondary-faction option {
    background: rgba(42, 24, 16, 0.95);
    color: #ffd700;
}

.url-display {
    display: flex;
    flex-direction: column;
    gap: 8px;
    position: relative;
    z-index: 1;
    min-height: 0;
}

.url-input-container {
    display: flex;
    gap: 8px;
    align-items: center;
    width: 100%;
    min-height: 0;
}

#copy-url, #copy-decklist {
    flex: 1;
    padding: 10px 12px;
    background: 
        linear-gradient(145deg, #b8860b, #daa520 50%, #b8860b);
    color: #2c1810;
    border: 2px solid #8b6914;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 700;
    transition: all 0.3s;
    box-shadow: 
        0 4px 8px rgba(0, 0, 0, 0.4),
        inset 0 2px 4px rgba(255, 255, 255, 0.3);
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
    font-size: 0.85rem;
    text-align: center;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

#copy-url:hover, #copy-decklist:hover {
    background: 
        linear-gradient(145deg, #daa520, #ffd700 50%, #daa520);
    transform: translateY(-2px);
    box-shadow: 
        0 6px 12px rgba(0, 0, 0, 0.5),
        inset 0 2px 4px rgba(255, 255, 255, 0.4);
}

/* Animation de bouton pressé */
@keyframes buttonPress {
    0% {
        transform: translateY(0) scale(1);
    }
    50% {
        transform: translateY(2px) scale(0.98);
        box-shadow: 
            0 2px 4px rgba(0, 0, 0, 0.6),
            inset 0 1px 2px rgba(0, 0, 0, 0.3);
    }
    100% {
        transform: translateY(0) scale(1);
    }
}

.button-pressed {
    animation: buttonPress 0.15s ease-in-out;
}

#copy-url:active, #copy-decklist:active {
    transform: translateY(0) scale(0.95);
    box-shadow: 
        0 2px 4px rgba(0, 0, 0, 0.6),
        inset 0 1px 2px rgba(0, 0, 0, 0.3);
}

.main-content {
    display: grid;
    grid-template-columns: 2fr 1fr; /* Collection = 2/3, Deck = 1/3 */
    gap: 20px;
    flex: 1;
    min-height: 0;
}

.available-cards-section,
.deck-section {
    background: 
        linear-gradient(145deg, 
            rgba(160, 90, 40, 0.9) 0%, 
            rgba(120, 80, 45, 0.95) 50%, 
            rgba(100, 65, 35, 0.9) 100%);
    padding: 20px;
    border-radius: 12px;
    /* Tavern effect with warmer metal borders */
    box-shadow: 
        0 15px 30px rgba(0, 0, 0, 0.7),
        inset 0 3px 8px rgba(255, 200, 80, 0.25),
        inset 0 -2px 6px rgba(0, 0, 0, 0.4),
        0 0 25px rgba(255, 180, 60, 0.2);
    border: 3px solid;
    border-image: linear-gradient(45deg, #8b6914, #b8860b, #daa520, #654321) 1;
    position: relative;
    display: flex;
    flex-direction: column;
    min-height: 0;
    min-width: 0;
    overflow: hidden;
}

/* Decorative inner border */
.available-cards-section::before,
.deck-section::before {
    content: '';
    position: absolute;
    top: 8px;
    left: 8px;
    right: 8px;
    bottom: 8px;
    border: 1px dashed rgba(218, 165, 32, 0.3);
    border-radius: 8px;
    pointer-events: none;
}

.deck-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 15px;
    position: relative;
    z-index: 1;
    width: 100%;
    min-width: 0;
    overflow: hidden;
}

.deck-header h2 {
    color: #ffd700;
    margin: 0;
    font-size: 1.6rem;
    text-shadow: 
        4px 4px 10px rgba(0, 0, 0, 0.95),
        0 0 15px rgba(255, 215, 0, 0.7),
        2px 2px 6px rgba(0, 0, 0, 0.9);
    text-align: left;
    border-bottom: 3px solid rgba(139, 105, 20, 0.6);
    padding-bottom: 10px;
}

.available-cards-section h2,
.deck-section h2:not(.deck-header h2) {
    color: #ffd700; /* Plus contrasté */
    margin-bottom: 15px;
    font-size: 1.6rem;
    text-shadow: 
        4px 4px 10px rgba(0, 0, 0, 0.95), /* Ombre plus forte */
        0 0 15px rgba(255, 215, 0, 0.7),
        2px 2px 6px rgba(0, 0, 0, 0.9);
    text-align: center;
    border-bottom: 3px solid rgba(139, 105, 20, 0.6);
    padding-bottom: 10px;
    flex-shrink: 0;
    position: relative;
    z-index: 1;
}

.filter-controls {
    display: flex;
    gap: 12px;
    margin-bottom: 15px;
    flex-wrap: wrap;
    flex-shrink: 0;
}

/* Dropdown personnalisé pour les factions */
.faction-filter-dropdown {
    position: relative;
    display: inline-block;
}

.faction-filter-button {
    padding: 8px 12px;
    border: 2px solid rgba(180, 140, 60, 0.7);
    border-radius: 8px;
    background: 
        linear-gradient(145deg, 
            rgba(160, 90, 40, 0.9) 0%, 
            rgba(120, 80, 45, 0.95) 50%, 
            rgba(100, 65, 35, 0.9) 100%);
    color: #ffd700;
    font-family: 'Crimson Text', serif;
    font-size: 0.9rem;
    box-shadow: 
        inset 0 2px 6px rgba(0, 0, 0, 0.5),
        0 2px 4px rgba(255, 180, 60, 0.3);
    text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.8);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-width: 180px;
    gap: 10px;
}

.faction-filter-button:hover {
    background: 
        linear-gradient(145deg, 
            rgba(180, 100, 50, 0.9) 0%, 
            rgba(140, 90, 55, 0.95) 50%, 
            rgba(120, 75, 45, 0.9) 100%);
    box-shadow: 
        inset 0 2px 6px rgba(0, 0, 0, 0.5),
        0 4px 8px rgba(255, 180, 60, 0.4);
}

.dropdown-arrow {
    transition: transform 0.3s ease;
    font-size: 0.8rem;
}

.faction-filter-dropdown.open .dropdown-arrow {
    transform: rotate(180deg);
}

.faction-filter-list {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: 
        linear-gradient(145deg, 
            rgba(160, 90, 40, 0.98) 0%, 
            rgba(120, 80, 45, 0.98) 50%, 
            rgba(100, 65, 35, 0.98) 100%);
    border: 2px solid rgba(180, 140, 60, 0.7);
    border-top: none;
    border-radius: 0 0 8px 8px;
    box-shadow: 
        0 8px 16px rgba(0, 0, 0, 0.6),
        inset 0 1px 3px rgba(255, 200, 80, 0.2);
    z-index: 1000;
    max-height: 300px;
    overflow-y: auto;
    display: none;
}

.faction-filter-dropdown.open .faction-filter-list {
    display: block;
}

.faction-checkbox-item {
    display: flex;
    align-items: center;
    padding: 8px 12px;
    cursor: pointer;
    color: #ffd700;
    font-family: 'Crimson Text', serif;
    font-size: 0.9rem;
    gap: 10px;
    transition: background-color 0.2s ease;
    text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.8);
}

.faction-checkbox-item:hover {
    background: rgba(255, 200, 80, 0.15);
}

.faction-checkbox-item input[type="checkbox"] {
    display: none;
}

.checkmark {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(180, 140, 60, 0.7);
    border-radius: 3px;
    background: rgba(160, 90, 40, 0.3);
    position: relative;
    flex-shrink: 0;
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.3);
}

.faction-checkbox-item input[type="checkbox"]:checked + .checkmark {
    background: 
        linear-gradient(145deg, 
            rgba(255, 215, 0, 0.9) 0%, 
            rgba(218, 165, 32, 0.9) 100%);
    border-color: #ffd700;
}

.faction-checkbox-item input[type="checkbox"]:checked + .checkmark::after {
    content: '✓';
    position: absolute;
    top: -2px;
    left: 2px;
    color: #654321;
    font-size: 12px;
    font-weight: bold;
}

#search-filter,
#sort-filter,
#order-filter {
    padding: 8px 12px;
    border: 2px solid rgba(180, 140, 60, 0.7);
    border-radius: 8px;
    background: 
        linear-gradient(145deg, 
            rgba(160, 90, 40, 0.9) 0%, 
            rgba(120, 80, 45, 0.95) 50%, 
            rgba(100, 65, 35, 0.9) 100%);
    color: #ffd700;
    font-family: 'Crimson Text', serif;
    font-size: 0.9rem;
    box-shadow: 
        inset 0 2px 6px rgba(0, 0, 0, 0.5),
        0 2px 4px rgba(255, 180, 60, 0.3);
    text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.8);
}

#search-filter {
    flex: 1;
    min-width: 150px;
}

#search-filter::placeholder {
    color: rgba(255, 215, 0, 0.7); /* Plus contrasté */
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
}

#clear-deck {
    padding: 10px 14px;
    border: 2px solid #8b1538;
    border-radius: 8px; /* Carré avec coins arrondis au lieu de rond */
    cursor: pointer;
    font-weight: 700;
    transition: all 0.3s;
    font-family: 'Crimson Text', serif;
    text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.8);
    font-size: 1.4rem; /* Plus gros : 1.2rem → 1.4rem */
    background: 
        linear-gradient(145deg, #8b1538, #a0184a 50%, #8b1538);
    color: #ffcccb;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.4);
    width: 48px; /* Plus gros : 40px → 48px */
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
}

#clear-deck:hover {
    background: 
        linear-gradient(145deg, #a0184a, #c71e3f 50%, #a0184a);
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.5);
}

#clear-deck:active {
    transform: translateY(0) scale(0.95);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.6);
}

.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    column-gap: 15px;
    row-gap: 275px;
    overflow-y: auto;
    padding: 15px;
    flex: 1;
    min-height: 0;
    align-content: start;
    /* Tavern scrollbar */
    scrollbar-width: thin;
    scrollbar-color: #8b6914 rgba(42, 24, 16, 0.8);
}

.cards-grid::-webkit-scrollbar {
    width: 8px;
}

.cards-grid::-webkit-scrollbar-track {
    background: 
        linear-gradient(45deg, rgba(42, 24, 16, 0.8), rgba(34, 19, 12, 0.8));
    border-radius: 4px;
    border: 1px solid rgba(139, 105, 20, 0.5);
}

.cards-grid::-webkit-scrollbar-thumb {
    background: 
        linear-gradient(145deg, #8b6914, #b8860b 50%, #8b6914);
    border-radius: 4px;
    border: 1px solid #654321;
}

.card {
    background: 
        linear-gradient(145deg, 
            rgba(160, 82, 45, 0.95) 0%, 
            rgba(139, 69, 19, 0.95) 50%, 
            rgba(101, 67, 33, 0.95) 100%);
    border-radius: 8px;
    padding: 8px;
    text-align: center;
    /* Shading of card placed on tavern table */
    box-shadow: 
        0 6px 15px rgba(0, 0, 0, 0.6),
        inset 0 2px 4px rgba(255, 215, 0, 0.2),
        inset 0 -1px 2px rgba(0, 0, 0, 0.3),
        0 0 8px rgba(255, 140, 0, 0.1);
    transition: all 0.3s ease;
    border: 2px solid rgba(139, 105, 20, 0.6);
    cursor: pointer;
    position: relative;
    overflow: hidden;
    /* Tailles optimisées pour les images */
    width: 100%;
    aspect-ratio: 3/4;
    justify-self: center;
    max-width: 200px;
}

/* Card popup styles */
.card-popup {
    z-index: 1001 !important;
    pointer-events: none;
    user-select: none;
}

/* Magical glow effect */
.card::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, 
        transparent, 
        rgba(255, 215, 0, 0.3), 
        transparent);
    transition: left 0.6s;
}

.card:hover::before {
    left: 100%;
}

.card:hover {
    transform: translateY(-8px) scale(1.05);
    box-shadow: 
        0 20px 40px rgba(0, 0, 0, 0.7),
        0 0 25px rgba(255, 215, 0, 0.4),
        inset 0 2px 8px rgba(255, 215, 0, 0.3);
    border-color: #ffd700;
    z-index: 10;
}

.card img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 4px;
    border: 1px solid rgba(139, 105, 20, 0.6);
    background: 
        linear-gradient(45deg, 
            rgba(42, 24, 16, 0.9), 
            rgba(83, 53, 27, 0.9));
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(255, 215, 0, 0.6);
    font-size: 10px;
    box-shadow: 
        inset 0 2px 4px rgba(0, 0, 0, 0.5),
        0 1px 2px rgba(255, 140, 0, 0.2);
}

.card-placeholder {
    width: 100%;
    height: 100%;
    background: 
        linear-gradient(45deg, 
            rgba(42, 24, 16, 0.9), 
            rgba(83, 53, 27, 0.9));
    border-radius: 4px;
    border: 1px solid rgba(139, 105, 20, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(255, 215, 0, 0.6);
    font-size: 10px;
    text-align: center;
    padding: 5px;
    box-shadow: 
        inset 0 2px 4px rgba(0, 0, 0, 0.5),
        0 1px 2px rgba(255, 140, 0, 0.2);
}

/* Suppression des anciens styles qui ne sont plus nécessaires */
.card-name,
.card-cost,
.card-faction {
    display: none;
}

.quantity-badge {
    position: absolute;
    top: -0px;
    right: -0px;
    border-radius: 50%;
    width: 42px;
    height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: 700;
    border: 3px solid #654321;
    box-shadow: 
        0 4px 12px rgba(0, 0, 0, 0.7),
        inset 0 2px 4px rgba(255, 255, 255, 0.3);
    text-shadow: 
        2px 2px 4px rgba(0, 0, 0, 0.9),
        1px 1px 2px rgba(0, 0, 0, 0.8);
    z-index: 2;
    color: #ffffff;
}

/* Couleurs de fond par faction */
.faction-dm-bg {
    background: 
        linear-gradient(145deg, #6a5acd, #8a2be2 50%, #6a5acd);
}

.faction-pg-bg {
    background: 
        linear-gradient(145deg, #b22222, #dc143c 50%, #b22222);
}

.faction-wh-bg {
    background: 
        linear-gradient(145deg, #228b22, #32cd32 50%, #228b22);
}

.faction-ao-bg {
    background: 
        linear-gradient(145deg, #4682b4, #5a9fd4 50%, #4682b4);
}

.faction-n-bg {
    background: 
        linear-gradient(145deg, #808080, #a0a0a0 50%, #808080);
}

/* Styles pour les cartes désactivées */
.card-disabled {
    opacity: 0.4;
    filter: grayscale(60%);
    cursor: not-allowed !important;
    position: relative;
}

.card-disabled:hover {
    transform: none !important;
    box-shadow: 
        0 8px 16px rgba(0, 0, 0, 0.4),
        inset 0 2px 6px rgba(255, 200, 80, 0.15),
        inset 0 -2px 4px rgba(0, 0, 0, 0.3);
}

.disabled-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 3;
    pointer-events: none;
    display: flex;
    align-items: center;
    justify-content: center;
}

.disabled-message {
    background: rgba(0, 0, 0, 0.85);
    color: #ff6b6b;
    padding: 8px 12px;
    border-radius: 6px;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.9);
    font-family: 'Crimson Text', serif;
    text-align: center;
    font-weight: 600;
    line-height: 1.2;
    border: 1px solid rgba(255, 107, 107, 0.4);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.6);
    max-width: 90px;
    word-wrap: break-word;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.disabled-emoji {
    font-size: 1.5rem;
    line-height: 1;
}

.disabled-text {
    font-size: 0.55rem;
    line-height: 1.1;
}

/* Animation pour les messages sur les cartes */
@keyframes cardMessageFade {
    0% {
        opacity: 0;
        transform: translateX(-50%) translateY(10px);
    }
    100% {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

/* Animation de secousse pour les cartes */
@keyframes shake {
    0%, 100% { transform: rotate(0deg); }
    10% { transform: rotate(-2deg); }
    20% { transform: rotate(2deg); }
    30% { transform: rotate(-2deg); }
    40% { transform: rotate(2deg); }
    50% { transform: rotate(-1deg); }
    60% { transform: rotate(1deg); }
    70% { transform: rotate(-1deg); }
    80% { transform: rotate(1deg); }
    90% { transform: rotate(0deg); }
}

/* Animation de clignotement rouge */
@keyframes redFlash {
    0%, 100% { 
        background: inherit;
        box-shadow: inherit;
    }
    25%, 75% { 
        background: rgba(220, 20, 60, 0.3);
        box-shadow: 0 0 20px rgba(220, 20, 60, 0.6), inset 0 0 20px rgba(220, 20, 60, 0.2);
    }
    50% { 
        background: rgba(220, 20, 60, 0.5);
        box-shadow: 0 0 25px rgba(220, 20, 60, 0.8), inset 0 0 25px rgba(220, 20, 60, 0.3);
    }
}

/* Classes pour appliquer les animations */
.shaking {
    animation: shake 0.6s ease-in-out;
    transform-origin: center center;
}

.shake-red-flash {
    animation: shake 0.6s ease-in-out, redFlash 0.6s ease-in-out;
    transform-origin: center center;
}

.deck-card {
    position: relative;
}

.deck-card:hover {
    border-color: #8b1538;
}

.deck-card .remove-btn {
    position: absolute;
    top: 4px;
    left: 4px;
    background: 
        linear-gradient(145deg, #8b1538, #a0184a 50%, #8b1538);
    color: #ffcccb;
    border: 1px solid #5d0e24;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 700;
    display: none;
    box-shadow: 
        0 3px 6px rgba(0, 0, 0, 0.6),
        inset 0 1px 2px rgba(255, 255, 255, 0.2);
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.9);
    z-index: 2;
}

.deck-card:hover .remove-btn {
    display: flex;
    align-items: center;
    justify-content: center;
}

.remove-btn:active {
    transform: scale(0.85);
    box-shadow: 
        0 1px 3px rgba(0, 0, 0, 0.8),
        inset 0 1px 2px rgba(0, 0, 0, 0.5);
}

#deck-count {
    color: rgba(218, 165, 32, 0.8);
    font-weight: normal;
    font-size: 0.95rem;
    text-shadow: 
        2px 2px 6px rgba(0, 0, 0, 0.9),
        1px 1px 3px rgba(0, 0, 0, 0.8);
}

.deck-count {
    font-family: 'Crimson Text', serif;
    color: rgba(218, 165, 32, 0.7);
    font-weight: normal;
    font-size: 0.85rem;
    text-shadow: 
        1px 1px 3px rgba(0, 0, 0, 0.8);
    text-align: left;
    margin-top: 4px;
    margin-left: 2px;
}

.deck-header-text {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    flex: 1;
    min-width: 0;
}

.deck-header-text h2 {
    margin: 0;
    margin-bottom: 0;
}

.deck-title-container {
    width: 100%;
    flex: 1;
    min-width: 0;
}

#deck-title {
    width: 100%;
    background: rgba(255, 215, 0, 0.08);
    border: 2px solid rgba(255, 215, 0, 0.3);
    border-radius: 6px;
    padding: 8px 12px;
    font-family: 'Crimson Text', serif;
    font-size: 20px;
    font-weight: 600;
    color: #ffd700;
    text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.8);
    transition: all 0.3s ease;
    outline: none;
    overflow-x: auto;
    white-space: nowrap;
    text-overflow: clip;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 215, 0, 0.6) transparent;
    box-shadow: 
        inset 0 2px 4px rgba(0, 0, 0, 0.3),
        0 2px 6px rgba(255, 215, 0, 0.15);
}

#deck-title::placeholder {
    color: rgba(255, 215, 0, 0.5);
    font-style: italic;
    font-weight: 400;
}

#deck-title::-webkit-scrollbar {
    height: 4px;
}

#deck-title::-webkit-scrollbar-track {
    background: rgba(255, 215, 0, 0.1);
    border-radius: 2px;
}

#deck-title::-webkit-scrollbar-thumb {
    background: rgba(255, 215, 0, 0.6);
    border-radius: 2px;
}

#deck-title::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 215, 0, 0.8);
}

#deck-title:hover {
    border-color: rgba(255, 215, 0, 0.5);
    background: rgba(255, 215, 0, 0.12);
    box-shadow: 
        inset 0 2px 4px rgba(0, 0, 0, 0.3),
        0 4px 8px rgba(255, 215, 0, 0.2);
}

#deck-title:focus {
    border-color: #ffd700;
    background: rgba(255, 215, 0, 0.15);
    box-shadow: 
        inset 0 2px 4px rgba(0, 0, 0, 0.3),
        0 0 12px rgba(255, 215, 0, 0.4),
        0 4px 8px rgba(255, 215, 0, 0.25);
}

/* Empty deck style */
.empty-deck {
    grid-column: 1 / -1;
    text-align: center;
    color: rgba(255, 215, 0, 0.6);
    font-style: italic;
    padding: 40px 20px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.8);
}

/* Loading message style */
.loading-message {
    text-align: center;
    color: #ffd700;
    font-size: 1.2rem;
    padding: 60px 20px;
    line-height: 1.6;
    background: 
        linear-gradient(145deg, 
            rgba(42, 24, 16, 0.8), 
            rgba(83, 53, 27, 0.6));
    border-radius: 8px;
    border: 2px solid rgba(139, 105, 20, 0.4);
    box-shadow: 
        0 4px 12px rgba(0, 0, 0, 0.3),
        inset 0 2px 4px rgba(255, 200, 80, 0.2);
    margin: 20px;
    font-family: 'Crimson Text', serif;
    animation: loadingPulse 2s ease-in-out infinite;
    font-weight: 600;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.8);
}

@keyframes loadingPulse {
    0%, 100% { 
        opacity: 1;
        transform: scale(1);
    }
    50% { 
        opacity: 0.8;
        transform: scale(1.02);
    }
}

/* Theme by faction Cards & Tankards - Couleurs complètes */
.faction-dm { 
    border-left: 4px solid #6a5acd; /* Dark Magic - Violet */
    border-top: 2px solid rgba(106, 90, 205, 0.3);
    border-right: 2px solid rgba(106, 90, 205, 0.3);
    border-bottom: 2px solid rgba(106, 90, 205, 0.3);
}

.faction-pg { 
    border-left: 4px solid #b22222; /* Primitive & Goblin - Rouge */
    border-top: 2px solid rgba(178, 34, 34, 0.3);
    border-right: 2px solid rgba(178, 34, 34, 0.3);
    border-bottom: 2px solid rgba(178, 34, 34, 0.3);
}

.faction-wh { 
    border-left: 4px solid #228b22; /* White & Human - Vert */
    border-top: 2px solid rgba(34, 139, 34, 0.3);
    border-right: 2px solid rgba(34, 139, 34, 0.3);
    border-bottom: 2px solid rgba(34, 139, 34, 0.3);
}

.faction-ao { 
    border-left: 4px solid #4682b4; /* Ancient Ones - Bleu */
    border-top: 2px solid rgba(70, 130, 180, 0.3);
    border-right: 2px solid rgba(70, 130, 180, 0.3);
    border-bottom: 2px solid rgba(70, 130, 180, 0.3);
}

.faction-n { 
    border-left: 4px solid #808080; /* Nature - Gris */
    border-top: 2px solid rgba(128, 128, 128, 0.3);
    border-right: 2px solid rgba(128, 128, 128, 0.3);
    border-bottom: 2px solid rgba(128, 128, 128, 0.3);
}

/* Green effect for White & Human cards */
.faction-wh {
    background: 
        linear-gradient(145deg, 
            rgba(34, 139, 34, 0.25) 0%, 
            rgba(139, 69, 19, 0.9) 30%, 
            rgba(101, 67, 33, 0.9) 70%, 
            rgba(34, 139, 34, 0.25) 100%);
}

/* Mystical effect for Dark Magic cards */
.faction-dm {
    background: 
        linear-gradient(145deg, 
            rgba(106, 90, 205, 0.25) 0%, 
            rgba(139, 69, 19, 0.9) 30%, 
            rgba(101, 67, 33, 0.9) 70%, 
            rgba(106, 90, 205, 0.25) 100%);
}

/* Primitive effect for Primitive & Goblin cards */
.faction-pg {
    background: 
        linear-gradient(145deg, 
            rgba(178, 34, 34, 0.25) 0%, 
            rgba(139, 69, 19, 0.9) 30%, 
            rgba(101, 67, 33, 0.9) 70%, 
            rgba(178, 34, 34, 0.25) 100%);
}

/* Ancient effect for Ancient Ones cards */
.faction-ao {
    background: 
        linear-gradient(145deg, 
            rgba(70, 130, 180, 0.25) 0%, 
            rgba(139, 69, 19, 0.9) 30%, 
            rgba(101, 67, 33, 0.9) 70%, 
            rgba(70, 130, 180, 0.25) 100%);
}

/* Natural effect for Nature cards */
.faction-n {
    background: 
        linear-gradient(145deg, 
            rgba(128, 128, 128, 0.25) 0%, 
            rgba(139, 69, 19, 0.9) 30%, 
            rgba(101, 67, 33, 0.9) 70%, 
            rgba(128, 128, 128, 0.25) 100%);
}





/* Interface mobile optimisée pour usage vertical */
@media (max-width: 768px) {
    .container {
        padding: 2px;
        height: 100vh;
        gap: 2px;
        display: flex;
        flex-direction: column;
        overflow: hidden;
    }

    header {
        padding: 5px 8px;
        margin-bottom: 2px;
        flex-shrink: 0;
        background: transparent;
    }

    header h1 {
        font-size: 1.4rem;
        margin-bottom: 5px;
        letter-spacing: 0.5px;
    }

    /* Layout mobile : tout en colonne avec hauteurs optimisées */
    .main-content {
        grid-template-columns: 1fr;
        gap: 4px;
        flex: 1;
        min-height: 0;
        display: flex;
        flex-direction: column;
    }

    /* Interface très compacte pour le deck */
    .deck-info {
        gap: 4px;
        margin-bottom: 4px;
        padding: 6px;
        width: 100%;
    }



    /* Factions très compactes */
    .faction-selectors {
        display: flex;
        gap: 4px;
        align-items: center;
        justify-content: center;
        flex-wrap: wrap;
    }

    #primary-faction, #secondary-faction {
        width: 110px;
        max-width: 110px;
        min-width: 90px;
        font-size: 0.7rem;
        padding: 3px 5px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    /* URL display très compact */
    .url-display {
        flex-direction: column;
        gap: 3px;
        align-items: stretch;
    }

    /* Container pour les boutons */
    .url-input-container {
        display: flex;
        gap: 3px;
        align-items: center;
        width: 100%;
    }

    #copy-url, #copy-decklist {
        flex: 1;
        padding: 4px 6px;
        font-size: 0.65rem;
        text-align: center;
        min-width: 0;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    /* Sections optimisées avec flex - tailles égales */
    .available-cards-section {
        padding: 6px;
        border-radius: 6px;
        overflow: hidden;
        flex: 1;
        min-height: 0;
        display: flex;
        flex-direction: column;
    }

    .deck-section {
        padding: 6px;
        border-radius: 6px;
        overflow: hidden;
        flex: 1;
        min-height: 0;
        display: flex;
        flex-direction: column;
    }

    /* Titres très compacts */
    .available-cards-section h2,
    .deck-section h2 {
        font-size: 1rem;
        margin-bottom: 4px;
    }



    .deck-count {
        font-size: 0.7rem;
        margin-top: 2px;
        margin-left: 1px;
    }

    .deck-header-text h2 {
        font-size: 1rem;
    }

    #deck-title {
        font-size: 16px;
        padding: 3px 5px;
    }

    #deck-title::-webkit-scrollbar {
        display: none;
    }
    
    /* Contrôles de filtres très compacts */
    .filter-controls {
        gap: 4px;
        flex-direction: row;
        margin-bottom: 4px;
        flex-shrink: 0;
        align-items: center;
        padding: 3px 6px;
    }

    .faction-filter-button {
        font-size: 0.7rem;
        padding: 4px 6px;
        flex: 0 0 100px;
        order: 1;
        min-width: 100px;
    }

    #search-filter {
        font-size: 0.75rem;
        padding: 4px 6px;
        flex: 1;
        order: 2;
    }

    /* Bouton clear repositionné */
    .deck-header {
        margin-bottom: 4px;
        flex-shrink: 0;
        padding: 3px 6px;
    }

    #clear-deck {
        width: 28px;
        height: 28px;
        font-size: 1rem;
    }

    /* Grille de cartes mobile - Grid compact */
    .cards-grid {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(85px, 1fr));
        gap: 3px;
        padding: 4px 6px;
        overflow-y: auto;
        overflow-x: hidden;
        flex: 1;
        min-height: 0;
    }

    /* Cartes pour grid mobile - plus compactes */
    .card {
        width: 100%;
        height: 110px;
        border-radius: 4px;
        border: 1px solid rgba(218, 165, 32, 0.4);
    }

    .card img {
        border-radius: 6px;
        width: auto;
        height: 100%;
        max-height: calc(100% - 12px);
        object-fit: contain;
        display: block;
    }

    /* Badges mieux proportionnés */
    .quantity-badge {
        width: 32px;
        height: 32px;
        font-size: 16px;
        top: -4px;
        right: -4px;
    }

    /* Messages désactivés adaptés */
    .disabled-message {
        padding: 6px 10px;
        font-size: 1rem;
        max-width: 80px;
    }

    .disabled-emoji {
        font-size: 1.4rem;
    }

    .disabled-text {
        font-size: 0.5rem;
    }

    /* Section du deck optimisée */
    .deck-section .cards-grid {
        display: flex;
        flex-direction: row;
        overflow-x: auto;
        overflow-y: hidden;
    }

    /* Bouton de suppression adapté */
    .deck-card .remove-btn {
        width: 20px;
        height: 20px;
        font-size: 12px;
        top: 4px;
        left: 4px;
    }

    /* Améliorations du scroll horizontal */
    .cards-grid::-webkit-scrollbar {
        height: 6px;
        width: 6px;
    }

    .cards-grid::-webkit-scrollbar-thumb {
        border-radius: 3px;
    }

    /* Empty deck message */
    .empty-deck {
        padding: 30px 15px;
        font-size: 0.9rem;
        width: 100%;
        text-align: center;
        flex: 1;
    }
}

/* Media query pour très petits écrans */
@media (max-width: 480px) {
    header h1 {
        font-size: 1.2rem;
        margin-bottom: 4px;
    }

    .faction-selectors {
        flex-direction: row;
        gap: 3px;
        align-items: center;
        justify-content: center;
        flex-wrap: wrap;
    }
    
    .deck-info {
        width: 100%;
        padding: 4px;
    }

    #primary-faction, #secondary-faction {
        font-size: 0.65rem;
        padding: 2px 4px;
        width: 100px;
        max-width: 100px;
        min-width: 80px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .deck-count {
        font-size: 0.6rem;
        margin-top: 1px;
        margin-left: 1px;
    }

    .deck-header-text h2 {
        font-size: 0.9rem;
    }

    #deck-title {
        font-size: 14px;
        padding: 2px 4px;
    }

    #deck-title::-webkit-scrollbar {
        display: none;
    }
    
    /* Défilement horizontal pour très petits écrans */
    .cards-grid {
        display: flex;
        flex-direction: row;
        gap: 10px;
        padding: 12px;
        overflow-x: auto;
        overflow-y: hidden;
    }

    /* Cartes pour très petits écrans - hauteur maximale et largeur proportionnée */
    .card {
        flex: 0 0 auto;
        padding: 8px;
        border-radius: 10px;
        scroll-snap-align: start;
        height: 100%;
        display: flex;
        align-items: center;
        justify-content: center;
        width: auto;
        min-width: fit-content;
    }

    .card img {
        border-radius: 8px;
        width: auto;
        height: 100%;
        max-height: calc(100% - 16px);
        object-fit: contain;
        display: block;
    }

    /* Badges plus gros pour la lisibilité */
    .quantity-badge {
        width: 36px;
        height: 36px;
        font-size: 18px;
        top: -6px;
        right: -6px;
    }

    /* Messages adaptés */
    .disabled-message {
        max-width: 90px;
        padding: 8px 12px;
        font-size: 1.1rem;
    }

    .disabled-emoji {
        font-size: 1.6rem;
    }

    .disabled-text {
        font-size: 0.55rem;
    }

    /* Section du deck cohérente */
    .deck-section .cards-grid {
        display: flex;
        flex-direction: row;
        overflow-x: auto;
        overflow-y: hidden;
    }

    /* Bouton de suppression plus gros */
    .deck-card .remove-btn {
        width: 24px;
        height: 24px;
        font-size: 14px;
        top: 6px;
        left: 6px;
    }

    /* Contrôles restent en ligne même sur très petits écrans */
    .filter-controls {
        flex-direction: row;
        gap: 6px;
    }

    .faction-filter-button {
        flex: 0 0 100px;
        order: 1;
        min-width: 100px;
    }

    #search-filter {
        order: 2;
    }
}
