#error-message {
    margin-top: 1.5rem;
    padding: 1rem;
    background: var(--error-bg);
    border: 1px solid var(--remove-color);
    border-radius: 12px;
    color: #fca5a5;
    font-size: 0.9rem;
    text-align: center;
}

#results-container {
    margin-top: 2rem;
    border-top: 1px solid var(--glass-border);
    padding-top: 2rem;
    animation: fadeIn 0.4s ease forwards;
}

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

.results-header {
    position: relative;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 1rem;
    margin-bottom: 0;
    padding: 5.5rem 1.5rem 2rem 1.5rem;
    border-radius: 16px 16px 0 0;
    overflow: hidden;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-bottom: none;
    cursor: pointer;
    transition: filter 0.2s;
}

.results-header:hover {
    filter: brightness(1.1);
}

#commander-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-size: cover;
    background-position: top center;
    opacity: 0;
    z-index: 0;
    transition: opacity 0.5s ease;
}

#commander-bg::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(to right, rgba(20, 20, 30, 0.95) 0%, rgba(20, 20, 30, 0.4) 100%);
}

.results-header-content {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: flex-start;
    gap: 0.75rem;
    width: 100%;
}

.results-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
    margin: 0;
    text-shadow: 0 2px 10px rgba(0,0,0,0.8);
}

.item-quantity {
    font-weight: 700;
    margin-right: 0.5rem;
    color: rgba(255, 255, 255, 0.9);
}

/* FAQ Section */
.faq-section {
    margin-top: 3rem;
    padding-top: 2rem;
    border-top: 1px solid var(--glass-border);
}

.faq-section h2 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 1.5rem;
    color: rgba(255, 255, 255, 0.9);
}

.faq-item {
    margin-bottom: 1.25rem;
}

.faq-item h3 {
    font-size: 1rem;
    font-weight: 500;
    color: var(--primary);
    margin-bottom: 0.5rem;
}

.type-badge {
    font-size: 0.65rem;
    font-weight: 600;
    width: 20px;
    height: 20px;
    display: inline-flex;
    justify-content: center;
    align-items: center;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.8);
}

.type-creature { background: rgba(46, 204, 113, 0.2); border-color: rgba(46, 204, 113, 0.4); color: #2ecc71; }
.type-artifact { background: rgba(189, 195, 199, 0.2); border-color: rgba(189, 195, 199, 0.4); color: #bdc3c7; }
.type-enchantment { background: rgba(155, 89, 182, 0.2); border-color: rgba(155, 89, 182, 0.4); color: #9b59b6; }
.type-instant { background: rgba(52, 152, 219, 0.2); border-color: rgba(52, 152, 219, 0.4); color: #3498db; }
.type-sorcery { background: rgba(231, 76, 60, 0.2); border-color: rgba(231, 76, 60, 0.4); color: #e74c3c; }
.type-planeswalker { background: rgba(241, 196, 15, 0.2); border-color: rgba(241, 196, 15, 0.4); color: #f1c40f; }
.type-land { background: rgba(211, 84, 0, 0.2); border-color: rgba(211, 84, 0, 0.4); color: #e67e22; }
.type-battle { background: rgba(26, 188, 156, 0.2); border-color: rgba(26, 188, 156, 0.4); color: #1abc9c; }

.badge {
    background: rgba(255, 255, 255, 0.1);
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.85rem;
    font-weight: 600;
}

/* Card Hover Preview */
#card-preview-container {
    position: fixed;
    z-index: 9999;
    pointer-events: none; /* prevent the preview from capturing mouse events */
    width: 250px;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6);
    opacity: 0;
    transition: opacity 0.15s ease-in-out;
}

#card-preview-container:not(.hidden) {
    opacity: 1;
}

#card-preview-container.hidden {
    display: block; /* Override default hidden so opacity transition works, rely on opacity=0 and pointer-events=none */
    opacity: 0;
}

#card-preview-img {
    width: 100%;
    display: block;
    border-radius: 12px; /* standard MTG card corner */
}

.perfect-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    padding: 2rem;
    background: var(--add-bg);
    border-radius: 16px;
    border: 1px solid rgba(16, 185, 129, 0.2);
    color: var(--add-color);
    text-align: center;
}

.diff-lists {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.section-title {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.remove-title { color: var(--remove-color); }
.add-title { color: var(--add-color); }

.checklist {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.check-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    -webkit-user-select: none;
    user-select: none;
    padding: 0.75rem 1rem;
    border-radius: 12px;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid transparent;
    transition: all 0.2s ease;
    cursor: pointer;
}

.check-item:hover {
    background: rgba(0, 0, 0, 0.4);
}

.check-item.remove {
    border-left: 3px solid var(--remove-color);
}

.check-item.add {
    border-left: 3px solid var(--add-color);
}

@keyframes destroyCard {
    0% { transform: scale(1) rotate(0); filter: brightness(1); }
    30% { transform: scale(1.02) rotate(-1deg); filter: brightness(1.5) sepia(1) hue-rotate(-50deg) saturate(5); border-color: rgba(231, 76, 60, 0.8); }
    100% { transform: scale(0.98) rotate(1deg); opacity: 0.4; filter: grayscale(1) blur(1px); border-color: rgba(255, 255, 255, 0.05); }
}

@keyframes shineCard {
    0% { box-shadow: 0 0 0 rgba(46, 204, 113, 0); border-color: rgba(255, 255, 255, 0.05); }
    40% { box-shadow: 0 0 25px rgba(46, 204, 113, 0.8), inset 0 0 15px rgba(46, 204, 113, 0.5); border-color: rgba(46, 204, 113, 1); transform: scale(1.02); }
    100% { box-shadow: 0 0 10px rgba(46, 204, 113, 0.2); border-color: rgba(46, 204, 113, 0.4); transform: scale(1); opacity: 0.6; }
}

.check-item.remove.checked {
    animation: destroyCard 0.5s ease-out forwards;
    text-decoration: line-through;
}

.check-item.add.checked {
    animation: shineCard 0.8s ease-out forwards;
    text-decoration: line-through;
}

.checkbox {
    width: 20px;
    height: 20px;
    border-radius: 6px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.2s ease;
}

.check-item.remove .checkbox.checked-box {
    background: var(--remove-color);
    border-color: var(--remove-color);
}

.check-item.add .checkbox.checked-box {
    background: var(--add-color);
    border-color: var(--add-color);
}

.checkbox svg {
    width: 12px;
    height: 12px;
    stroke: white;
    stroke-width: 3;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.checkbox.checked-box svg {
    opacity: 1;
}

.item-qty {
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.check-item.remove .item-qty { color: var(--remove-color); }
.check-item.add .item-qty { color: var(--add-color); }

.item-name {
    flex: 1;
    font-weight: 500;
}

/* Hover preview animations for checked items */
/* Static checked states for preview */
.preview-remove-checked img {
    filter: grayscale(1) brightness(0.6);
    box-shadow: 0 0 30px rgba(231, 76, 60, 0.4);
    border: 2px solid rgba(231, 76, 60, 0.6);
}

.preview-add-checked img {
    box-shadow: 0 0 30px rgba(46, 204, 113, 0.4);
    border: 2px solid rgba(46, 204, 113, 0.6);
}

/* Animated states for when it is JUST checked */
.preview-add-animate img {
    box-shadow: 0 0 30px rgba(46, 204, 113, 1);
    border: 2px solid rgba(46, 204, 113, 1);
}

.preview-add-animate::after {
    content: "";
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    border-radius: 12px;
    background: linear-gradient(125deg, rgba(255,255,255,0) 0%, rgba(255,255,255,0.4) 40%, rgba(255,255,255,0.8) 50%, rgba(255,255,255,0.4) 60%, rgba(255,255,255,0) 100%);
    background-size: 200% 200%;
    animation: foilShine 0.8s ease-in-out forwards;
    pointer-events: none;
    mix-blend-mode: overlay;
}

@keyframes foilShine {
    0% { background-position: -100% -100%; }
    100% { background-position: 200% 200%; }
}

/* Favorites Section */
.favorites-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    margin-bottom: 2rem;
}

.favorite-card {
    position: relative;
    border-radius: 12px;
    height: 70px;
    overflow: visible;
    cursor: pointer;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    padding: 0 1rem;
}

.favorite-card:hover {
    transform: translateY(-2px);
    border-color: rgba(255, 255, 255, 0.25);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.favorite-card-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 11px;
    overflow: hidden;
    background-size: cover;
    background-position: center 25%;
    opacity: 0.6;
    z-index: 0;
    transition: opacity 0.2s ease;
}

.deck-delete-btn {
    position: absolute;
    top: 0;
    left: 0;
    transform: translate(-50%, -50%);
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #ef4444;
    border: 2px solid #0f172a;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    cursor: pointer;
    padding: 0;
    z-index: 20;
    transition: transform 0.15s ease, background-color 0.15s ease;
}

.deck-delete-btn:hover {
    transform: translate(-50%, -50%) scale(1.2);
    background: #dc2626;
}

.favorite-card:hover .favorite-card-bg {
    opacity: 0.8;
}

.favorite-card-bg::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(to right, rgba(15, 15, 22, 0.95) 0%, rgba(15, 15, 22, 0.3) 100%);
}

.favorite-card-content {
    position: relative;
    z-index: 1;
    width: 100%;
}

.favorite-deck-name {
    font-size: 0.95rem;
    font-weight: 600;
    color: white;
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
}

@media (max-width: 480px) {
    .favorites-grid {
        grid-template-columns: 1fr;
    }
}

.favorite-card.pinned-card {
    border-color: #eab308;
    box-shadow: 0 0 10px rgba(234, 179, 8, 0.2);
}

.pin-container {
    position: absolute;
    right: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    z-index: 2;
    padding: 0.5rem;
    color: rgba(255, 255, 255, 0.3);
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.pin-container:hover {
    color: #eab308;
    background: rgba(255, 255, 255, 0.1);
    transform: translateY(-50%) scale(1.1);
}

.pin-star.pinned {
    color: #eab308;
    fill: #eab308;
}


/* Responsive Card Hit Row */
.card-hit-row {
    display: grid;
    grid-template-areas: 
        "name name"
        "price badges";
    grid-template-columns: auto 1fr;
    gap: 4px 6px;
    padding: 2px 0 2px 8px;
    align-items: center;
}
.card-hit-name { grid-area: name; }
.card-hit-price { grid-area: price; }
.card-hit-badges { grid-area: badges; display: flex; gap: 6px; flex-wrap: wrap; }

@media (min-width: 640px) {
    .card-hit-row {
        grid-template-areas: "price name badges";
        grid-template-columns: auto auto 1fr;
        gap: 8px;
    }
}
