.container {
    max-width: 1600px;
    margin: 0 auto;
    padding: 0 20px;
}

.hero-compact {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 2rem 0;
    text-align: center;
}

.hero-compact h1 {
    font-size: 2rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.hero-compact p {
    font-size: 1rem;
    opacity: 0.9;
}

/* Sección de búsqueda de la home */
.home-search-section {
    padding: 3rem 0;
}

.home-search-wrapper {
    max-width: 600px;
    margin: 0 auto;
    padding: 0 1rem;
}

.home-search-wrapper h2 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
    text-align: center;
}

.home-search-subtitle {
    color: #6b7280;
    text-align: center;
    margin-bottom: 2rem;
}

/* Tabs de la home */
.home-search-tabs {
    display: flex;
    justify-content: center;
    margin-bottom: 1.5rem;
    background: #f1f5f9;
    border-radius: 0.5rem;
    padding: 0.25rem;
    width: fit-content;
    margin-left: auto;
    margin-right: auto;
}

.home-tab {
    background: none;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 0.375rem;
    cursor: pointer;
    font-weight: 500;
    color: #64748b;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.2s;
}

.home-tab.active {
    background: white;
    color: #3b82f6;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* Paneles de la home */
.home-search-panel {
    display: none;
    max-width: 800px;
    margin-left: auto;
    margin-right: auto;
}

.home-search-panel.active {
    display: block;
}

/* Input de búsqueda de la home */
.home-input-group {
    display: flex;
    border: 1px solid #d1d5db;
    border-radius: 0.5rem;
    overflow: hidden;
    margin-bottom: 1rem;
    background: white;
    width: 100%;
}

.home-search-input {
    flex: 1;
    padding: 1rem;
    border: none;
    outline: none;
    font-size: 1rem;
    background: transparent;
}

.home-search-input:focus {
    outline: none;
}

.home-input-group:focus-within {
    border-color: #3b82f6;
    box-shadow: 0 0 0 1px #3b82f6;
}

.home-search-btn {
    background: #3b82f6;
    border: none;
    color: white;
    padding: 1rem;
    cursor: pointer;
    transition: background 0.2s;
}

.home-search-btn:hover {
    background: #2563eb;
}

/* Integrated Search Tabs & Input */
.mobile-scan-container {
    display: none;
}

.home-search-container {
    display: flex;
    justify-content: center;
    max-width: 800px;
    margin: 0 auto 1.5rem;
    /* Add bottom margin since tabs wrapper lost it */
}

.home-search-content {
    flex: 1;
    min-width: 0;
}

.home-search-tabs.side-tabs {
    flex-direction: row;
    margin: 0;
    width: auto;
    border-radius: 0.5rem 0 0 0.5rem;
    padding: 0;
    background: #f1f5f9;
    border: 1px solid #d1d5db;
    border-right: none;
    display: flex;
    align-items: stretch;
}

.home-search-tabs.side-tabs .home-tab {
    margin: 0;
    border-radius: 0;
    border-right: 1px solid #e2e8f0;
    height: auto;
    background: transparent;
    box-shadow: none;
    padding: 0 1.25rem;
    /* Adjust padding if needed */
}

.home-search-tabs.side-tabs .home-tab:first-child {
    border-top-left-radius: 0.375rem;
    border-bottom-left-radius: 0.375rem;
}

.home-search-tabs.side-tabs .home-tab:last-child {
    border-right: none;
}

.home-search-tabs.side-tabs .home-tab.active {
    background: white;
    color: #3b82f6;
    font-weight: 600;
}

.home-input-group.attached-left {
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
    margin-bottom: 0;
    border-left: 1px solid #e2e8f0;
}

.home-search-content .home-search-panel {
    max-width: none;
    margin: 0;
}

/* Resultados de la home */
.home-search-results {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 0.5rem;
    max-height: 300px;
    overflow-y: auto;
}

/* Popular & Latest Cards Section */
.popular-cards {
    padding: 60px 0 20px;
    background: #f9fafb;
    min-height: 450px;
    contain: layout;
}

.latest-cards {
    padding: 60px 0;
    background: #f9fafb;
    min-height: 450px;
    contain: layout;
}

/* Insights Section (Combined) */
.insights-section {
    padding: 60px 0 20px;
    background: #f9fafb;
}

.insights-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 40px;
}

/* Adjust columns */
.insights-column {
    display: flex;
    flex-direction: column;
}

/* Remove padding from combined sections since parent handles it */
.top-month {
    padding: 0;
    background: none;
}

.deck-metrics {
    padding: 0;
    background: none;
}

.top-month-grid {
    grid-template-columns: 1fr;
    gap: 16px;
    min-height: auto;
}

.type-badge {
    position: absolute;
    top: 10px;
    left: 10px;
    background: rgba(17, 24, 39, 0.85);
    color: #fff;
    padding: 6px 10px;
    border-radius: 8px;
    font-size: 0.8rem;
    z-index: 2;
}

.section-subtitle {
    color: #6b7280;
    text-align: center;
    margin-bottom: 2rem;
    font-size: 1rem;
    margin-top: -1rem;
}

/* Cards grid and item styles for home page */
.cards-grid {
    display: grid;
    gap: 24px;
    min-height: 240px;
    contain: layout;
}

.cards-grid-6 {
    grid-template-columns: repeat(6, 1fr);
}

.cards-grid-5 {
    grid-template-columns: repeat(5, 1fr);
}

.cards-grid-4 {
    grid-template-columns: repeat(4, 1fr);
}

.cards-grid-3 {
    grid-template-columns: repeat(3, 1fr);
}

.card-item {
    background: white;
    border-radius: 12px;
    overflow: hidden;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    text-decoration: none;
    color: inherit;
    display: block;
    position: relative;
    border: 1px solid #e2e8f0;
    cursor: pointer;
}

.card-item:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
    text-decoration: none;
    color: inherit;
}

.card-image-container {
    position: relative;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.card-image {
    width: 100%;
    height: 100%;
    object-fit: contain;
    transition: transform 0.3s ease;
}

.card-item:hover .card-image {
    transform: scale(1.05);
}

/* Decks grid for home page */
.decks-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 25px;
    margin-bottom: 30px;
}

/* Additional styles for unified deck cards in home */
.card-author {
    color: #6b7280;
    font-size: 0.875rem;
    margin-bottom: 12px;
}

.card-colors {
    display: flex;
    gap: 6px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.color-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 500;
    color: white;
    text-decoration: none;
}

.color-badge.red {
    background: rgba(255, 107, 107, 0.9);
}

.color-badge.blue {
    background: rgba(78, 205, 196, 0.9);
}

.color-badge.green {
    background: rgba(86, 171, 47, 0.9);
}

.color-badge.white {
    background: rgba(160, 160, 160, 0.9);
    color: #333;
}

.color-badge.colorless {
    background: rgba(99, 99, 99, 0.9);
}

.card-description {
    color: #6b7280;
    font-size: 0.875rem;
    line-height: 1.4;
    margin-bottom: 12px;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.card-meta {
    color: #6b7280;
    font-size: 0.875rem;
    margin-bottom: 12px;
}

.card-updated {
    font-style: italic;
}

/* Dark mode for additional elements */
body.dark-mode .card-author {
    color: #94a3b8;
}

body.dark-mode .card-description {
    color: #94a3b8;
}

body.dark-mode .card-meta {
    color: #94a3b8;
}

.card-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(59, 130, 246, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
    color: white;
    font-size: 1.5rem;
}

.card-item:hover .card-overlay {
    opacity: 1;
}

.card-info {
    padding: 1rem;
    position: relative;
    /* Override unified-cards.css */
    height: auto;
    min-height: auto;
    display: block;
}

.card-name {
    font-size: 1.1rem;
    font-weight: 600;
    color: #1f2937;
    margin-bottom: 0.5rem;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    /* Ensure consistent height for 1 or 2 lines */
    min-height: 3.1rem;
}

.card-stats {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 0.75rem;
}

.card-stats .material-symbols-outlined {
    font-size: 20px;
}

.card-stats .stat {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: #6b7280;
    font-size: 0.8rem;
    font-weight: 500;
    line-height: 1rem;
    justify-content: center;
}

.card-stats .stat i {
    color: #3b82f6;
}

.card-cost {
    position: absolute;
    top: -0.75rem;
    right: 1rem;
}

.cost-badge {
    background: #3b82f6;
    color: white;
    padding: 0.25rem 0.75rem;
    border-radius: 1rem;
    font-size: 0.8rem;
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.3);
}

.no-popular-cards {
    grid-column: 1 / -1;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 300px;
}

.empty-state {
    text-align: center;
    padding: 3rem;
    max-width: 400px;
}

.empty-state i {
    color: #d1d5db;
    margin-bottom: 1.5rem;
}

.empty-state h3 {
    color: #374151;
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
}

.empty-state p {
    color: #6b7280;
    margin-bottom: 2rem;
    line-height: 1.6;
}

/* Resultados de búsqueda */
.card-result,
.deck-result {
    display: flex;
    align-items: center;
    padding: 0.75rem;
    border-bottom: 1px solid #e2e8f0;
    cursor: pointer;
}

.card-result:hover,
.deck-result:hover {
    background: white;
}

.card-result:last-child,
.deck-result:last-child {
    border-bottom: none;
}

.card-result img {
    width: 32px;
    height: 44px;
    object-fit: cover;
    border-radius: 0.25rem;
    margin-right: 0.75rem;
}

.deck-result-icon {
    width: 36px;
    height: 36px;
    background: #e2e8f0;
    border-radius: 0.375rem;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 0.75rem;
    color: #64748b;
}

.card-result-info,
.deck-result-info {
    flex: 1;
}

.card-result-name,
.deck-result-name {
    font-weight: 500;
    margin-bottom: 0.125rem;
    font-size: 0.9rem;
}

.card-result-details,
.deck-result-author {
    font-size: 0.8rem;
    color: #64748b;
}

.no-results,
.loading-search {
    padding: 2rem;
    text-align: center;
    color: #64748b;
}

/* Dark mode para la home */
body.dark-mode .hero-compact {
    background: linear-gradient(135deg, #5a67d8 0%, #6b46c1 100%);
}

body.dark-mode .home-search-section {
    background: #0f172a;
}

body.dark-mode .home-search-wrapper h2 {
    color: #f1f5f9;
}

body.dark-mode .home-search-subtitle {
    color: #94a3b8;
}

body.dark-mode .home-search-tabs {
    background: #1e293b;
}

body.dark-mode .home-tab {
    color: #94a3b8;
}

body.dark-mode .home-tab.active {
    background: #334155;
    color: #60a5fa;
}

body.dark-mode .home-input-group {
    border-color: #374151;
    background: #1f2937;
}

/* Dark mode for Integrated Search Side Tabs */
body.dark-mode .home-search-tabs.side-tabs {
    background: #1f2937;
    border-color: #374151;
}

body.dark-mode .home-search-tabs.side-tabs .home-tab {
    border-right-color: #374151;
    color: #94a3b8;
}

body.dark-mode .home-search-tabs.side-tabs .home-tab.active {
    background: #334155;
    color: #60a5fa;
}

body.dark-mode .home-input-group.attached-left {
    border-left-color: #374151;
}

body.dark-mode .home-search-input {
    background: #1f2937;
    color: #f1f5f9;
}

body.dark-mode .home-search-results {
    background: #1e293b;
    border-color: #374151;
}

/* Dark mode para Popular & Latest Cards */
body.dark-mode .popular-cards,
body.dark-mode .latest-cards,
body.dark-mode .insights-section {
    background: #1f2937;
}

body.dark-mode .top-month {
    background: #1f2937;
}

/* Deck Metrics */
.deck-metrics {
    padding: 60px 0 20px;
    background: #f9fafb;
}


.metrics-grid {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.metrics-row-split {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}


.metric-card {
    background: white;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    padding: 24px;
}

.metric-card__header {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    color: #1f2937;
    margin-bottom: 18px;
}

.metric-card__header i {
    color: #3b82f6;
}

.metric-card__value {
    font-size: 1.1rem;
    font-weight: 700;
    color: #111827;
    margin-bottom: 6px;
}

.metric-card__value--lg {
    font-size: 2rem;
    line-height: 1.1;
}

.metric-card__meta {
    color: #6b7280;
    font-size: 0.9rem;
    margin-bottom: 10px;
}

.metric-card__empty {
    color: #9ca3af;
    font-style: italic;
}

.metric-card__list {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.metric-row {
    display: grid;
    grid-template-columns: 42px 1fr 58px;
    align-items: center;
    gap: 10px;
}

.metric-row__label {
    color: #374151;
    font-weight: 600;
    font-size: 0.9rem;
}

.metric-row__value {
    color: #374151;
    font-weight: 600;
    font-size: 0.9rem;
    text-align: right;
}

.progress {
    height: 20px;
    background: #e5e7eb;
    border-radius: 999px;
    overflow: hidden;
}

.progress__bar {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #3b82f6, #06b6d4);
    border-radius: 999px;
    transition: width 0.6s ease;
}

/* Dark mode for metrics */
body.dark-mode .deck-metrics {
    background: #1f2937;
}

body.dark-mode .metric-card {
    background: #374151;
    border-color: #4b5563;
}

body.dark-mode .metric-card__header {
    color: #f3f4f6;
}

body.dark-mode .metric-card__value {
    color: #f9fafb;
}

body.dark-mode .metric-card__meta {
    color: #94a3b8;
}

body.dark-mode .metric-row__label,
body.dark-mode .metric-row__value {
    color: #e5e7eb;
}

body.dark-mode .progress {
    background: #334155;
}

body.dark-mode .section-subtitle {
    color: #94a3b8;
}

body.dark-mode .card-item {
    background: #374151;
    border-color: #4a5568;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

body.dark-mode .card-item:hover {
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

body.dark-mode .card-name {
    color: #f1f5f9;
}

body.dark-mode .card-stats .stat {
    color: #94a3b8;
}

body.dark-mode .card-stats .stat i {
    color: #60a5fa;
}

body.dark-mode .cost-badge {
    background: #60a5fa;
    box-shadow: 0 2px 8px rgba(96, 165, 250, 0.3);
}

body.dark-mode .empty-state i {
    color: #4a5568;
}

body.dark-mode .empty-state h3 {
    color: #f1f5f9;
}

body.dark-mode .empty-state p {
    color: #94a3b8;
}

body.dark-mode .card-result:hover,
body.dark-mode .deck-result:hover {
    background: #334155;
}

body.dark-mode .card-result-name,
body.dark-mode .deck-result-name {
    color: #f1f5f9;
}

body.dark-mode .deck-result-icon {
    background: #374151;
    color: #94a3b8;
}

/* Responsive */
@media (max-width: 768px) {
    .hero-compact {
        background: none !important;
        background-image: none !important;
        padding-bottom: 0;
    }

    .hero-compact h1 {
        font-size: 1.75rem;
        /* Ensure text is visible on potentially white background if needed, 
           but usually hero has text color set to white. 
           If the background is transparent, we might need dark text unless 
           site background is dark. Assuming site is light mode by default. */
        color: #1f2937;
    }

    /* If hero-compact has other text */
    .hero-compact p {
        color: #4b5563;
    }

    body.dark-mode .hero-compact h1 {
        color: #f3f4f6;
    }

    body.dark-mode .hero-compact p {
        color: #9ca3af;
    }

    /* Remove padding from sections to tighten up layout if needed */
    .popular-cards {
        padding: 20px 0 20px;
    }

    .latest-cards {
        padding: 20px 0;
    }

    /* Mobile Carousel - Horizontal Scrolling */
    .popular-cards .cards-grid,
    .latest-cards .cards-grid,
    .insights-section .cards-grid,
    .popular-decks .decks-grid {
        display: flex;
        overflow-x: auto;
        scroll-snap-type: x mandatory;
        gap: 16px;
        padding-bottom: 20px;
        /* Space for scrollbar */
        padding-left: 20px;
        /* Align with container padding */
        padding-right: 20px;
        margin-left: -20px;
        /* Offset container padding for full bleed */
        margin-right: -20px;
        -webkit-overflow-scrolling: touch;

        /* Reset grid template columns if any */
        grid-template-columns: none;
    }

    /* Ensure all items are visible and formatted for carousel */
    .cards-grid .card-item,
    .decks-grid .deck-card {
        min-width: 260px;
        max-width: 260px;
        scroll-snap-align: center;
        flex-shrink: 0;
        margin-right: 0;
        display: block !important;
        /* Ensure hidden items are shown */
    }

    /* Stack insights grid columns vertically but keep the carousel within them */
    .insights-grid {
        grid-template-columns: 1fr;
        gap: 40px;
        width: 100%;
        overflow: hidden;
        /* Prevent horizontal spill */
    }

    .insights-column {
        width: 100%;
        min-width: 0;
        /* Important for flex children scrolling */
    }

    .metrics-row-split {
        grid-template-columns: 1fr;
    }

    .metrics-grid {
        width: 100%;
    }

    .metric-card {
        width: 100%;
        box-sizing: border-box;
        /* Ensure padding doesn't add to width */
    }


    .card-info {
        padding: 1rem;
    }

    .card-name {
        font-size: 1rem;
    }

    .section-subtitle {
        font-size: 0.9rem;
        padding: 0 1rem;
    }

    /* Mobile Home Changes */
    .home-search-container {
        display: none !important;
    }

    .mobile-scan-container {
        display: flex;
        gap: 1rem;
        padding: 1rem 0;
    }

    .scan-btn {
        flex: 1;
        display: inline-flex;
        justify-content: center;
        align-items: center;
        gap: 0.5rem;
        padding: 1rem;
        font-size: 1.1rem;
        white-space: nowrap;

        /* Shared 3D styles */
        border: none;
        border-radius: 12px;
        font-weight: 700;
        text-transform: capitalize;
        /* or none */
        position: relative;
        top: 0;
        transition: all 0.1s ease-in-out;
        color: white;
    }

    .scan-btn:hover {
        text-decoration: none;
        color: white;
    }

    .scan-btn:active {
        top: 6px;
        /* Push down */
        box-shadow: 0 0 0 0 rgba(0, 0, 0, 0) !important;
        /* Remove shadow on press */
        transform: translateY(2px);
    }

    /* 3D Blue Button */
    .btn-my-decks {
        background-color: #3b82f6 !important;
        /* Blue-500 */
        box-shadow: 0 6px 0 #1d4ed8 !important;
        /* Blue-700 */
        color: white !important;
    }

    .btn-my-decks:hover {
        background-color: #2563eb !important;
        /* Blue-600 */
        color: white !important;
    }

    .btn-my-decks:active {
        box-shadow: 0 0 0 #1d4ed8 !important;
        top: 6px;
    }

    /* 3D Green/Teal Button */
    .btn-scan-cards {
        background-color: #10b981 !important;
        /* Emerald-500 - More distinct Green */
        box-shadow: 0 6px 0 #047857 !important;
        /* Emerald-700 */
        color: white !important;
    }

    .btn-scan-cards:hover {
        background-color: #059669 !important;
        /* Emerald-600 */
        color: white !important;
    }

    .btn-scan-cards:active {
        box-shadow: 0 0 0 #047857 !important;
        top: 6px;
    }

    /* Blue-700 */
}

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

    .card-image-container {
        height: 240px;
    }

    .card-info {
        padding: 0.75rem;
    }

    .card-name {
        font-size: 0.9rem;
    }

    .card-stats .stat {
        font-size: 0.7rem;
    }
}

/* Mobile Scan Banner */
.mobile-scan-banner-container {
    display: none;
    margin-top: 1.5rem;
    margin-bottom: 0.5rem;
}

@media (max-width: 768px) {
    .mobile-scan-banner-container {
        display: block;
    }
    .mobile-scan-banner-img {
        width: 100%;
        height: auto;
        border-radius: 12px;
        box-shadow: 0 4px 12px rgba(0,0,0,0.15);
        display: block;
    }
    .mobile-scan-banner-link {
        display: block;
        transition: transform 0.2s ease;
    }
    .mobile-scan-banner-link:active {
        transform: scale(0.98);
    }
}
