/* Deck Builder Layout */
.deck-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* Deck Slots */
.deck-slots-area {
    margin-bottom: 30px;
}

.deck-slots-area h2 {
    margin-bottom: 15px;
    color: var(--primary-color);
    display: flex;
    align-items: center;
    gap: 10px;
}

.deck-slots {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 15px;
}

@media (min-width: 1024px) {
    .deck-slots {
        max-width: 800px;
        margin: 0 auto;
    }
}

.deck-slot {
    aspect-ratio: 2/3;
    background: var(--card-bg);
    border: 2px dashed var(--border-color);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
    overflow: hidden;
}

.deck-slot:hover {
    border-color: var(--primary-color);
    background: rgba(var(--primary-color-rgb), 0.05);
}

.deck-slot.filled {
    border-style: solid;
    border-color: var(--primary-color);
}

.deck-slot .placeholder {
    color: #aaa;
    font-size: 2rem;
}

.deck-slot img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.deck-slot .remove-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s;
    color: white;
    font-weight: bold;
    font-size: 1.2rem;
}

.deck-slot:hover .remove-overlay {
    opacity: 1;
}

/* Summary Panel */
.deck-summary {
    background: rgba(255, 255, 255, 0.05);
    /* Glassmorphism */
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 30px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

/* ... */
.stat-item {
    background: rgba(0, 0, 0, 0.2);
    padding: 10px;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

/* ... */
.card-item {
    background: rgba(255, 255, 255, 0.05);
    /* Glassmorphism */
    backdrop-filter: blur(5px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    position: relative;
}

.summary-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 10px;
}

.summary-header h3 {
    margin: 0;
    color: var(--text-color);
}

.summary-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
}

.summary-column h4 {
    margin-top: 0;
    margin-bottom: 15px;
    color: var(--primary-color);
    font-size: 1.1rem;
}

/* Potential List */
.potential-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.potential-item {
    margin-bottom: 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-color);
}

.potential-item:last-child {
    border-bottom: none;
}

.potential-name {
    font-weight: bold;
    margin-bottom: 4px;
    display: block;
}

.potential-desc {
    font-size: 0.9rem;
    color: #888;
    line-height: 1.4;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    text-align: left;
}

/* Stat Summary */
.global-stats-container {
    margin-bottom: 10px;
}

.category-stats-container {
    display: grid;
    gap: 10px;
    grid-template-columns: repeat(2, 1fr);
}

@media (min-width: 768px) {
    .category-stats-container {
        grid-template-columns: repeat(4, 1fr);
    }
}

.stat-grid {
    display: grid;
    gap: 10px;
}

.global-stats-grid {
    grid-template-columns: repeat(2, 1fr);
}

.category-stats-grid {
    grid-template-columns: 1fr;
}

.stat-item {
    background: rgba(0, 0, 0, 0.2);
    padding: 10px;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.stat-label {
    font-size: 0.9rem;
    color: #888;
    margin-bottom: 4px;
}

.stat-value {
    font-weight: bold;
    font-size: 1.1rem;
    color: var(--primary-color);
}

.empty-message {
    color: #aaa;
    font-style: italic;
    grid-column: 1 / -1;
    text-align: center;
    padding: 20px;
}

/* Card Selection */
.card-selection {
    margin-top: 30px;
}

.search-bar {
    margin-bottom: 20px;
}

.search-bar input {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--input-border);
    border-radius: 8px;
    background: var(--input-bg);
    color: var(--text-color);
    font-size: 1rem;
}

.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 15px;
}

.card-item {
    background: rgba(255, 255, 255, 0.05);
    /* Glassmorphism */
    backdrop-filter: blur(5px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    position: relative;
}

.card-item:hover {
    transform: translateY(-4px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.card-item.disabled {
    opacity: 0.5;
    pointer-events: none;
    filter: grayscale(100%);
}

.card-image {
    width: 100%;
    aspect-ratio: 2/3;
    object-fit: cover;
}

.card-info {
    padding: 10px;
}

.card-name {
    font-weight: bold;
    font-size: 0.95rem;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.card-type {
    font-size: 0.8rem;
    color: #888;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .deck-slots {
        grid-template-columns: repeat(5, 1fr);
        gap: 8px;
    }

    .summary-content {
        grid-template-columns: 1fr;
    }

    .card-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 10px;
    }

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

/* Rarity Badge */
.rarity-badge {
    position: absolute;
    top: 5px;
    right: 5px;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: bold;
    color: white;
    z-index: 2;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

.rarity-badge.SSR {
    background: linear-gradient(135deg, #f2aa4c, #d48828);
}

.rarity-badge.SR {
    background: linear-gradient(135deg, #cb85f7, #a04ce0);
}

.rarity-badge.R {
    background: #888;
    display: none;
    /* Optional: Hide R badge if desired */
}

/* Stat Summary Sections */
.stat-section-title {
    font-size: 1.1rem;
    font-weight: bold;
    color: var(--text-highlight);
    margin-bottom: 10px;
    padding-bottom: 5px;
    border-bottom: 1px solid var(--border-color);
}

.category-group {
    margin-bottom: 15px;
    padding: 10px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 8px;
}

.category-title {
    font-size: 0.95rem;
    color: var(--text-color);
    margin-bottom: 8px;
    opacity: 0.9;
    font-weight: bold;
}

/* Type Badge */
.type-badge {
    position: absolute;
    top: 6px;
    left: 6px;
    background: rgba(0, 0, 0, 0.7);
    color: #fff;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: bold;
    z-index: 2;
    pointer-events: none;
}

/* Extended Header Styles */
.deck-header-wrapper {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--header-bg);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border-color);
}

.deck-controls-header {
    padding: 0 1rem 10px 1rem;
    display: flex;
    flex-direction: column;
    margin-top: -15px;
    gap: 1rem;
    max-width: 1200px;
    margin: -15px auto 0 auto;
    width: 100%;
    box-sizing: border-box;
}

.deck-controls-row {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    margin-bottom: 1rem;
}

.deck-navigation {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    font-style: italic;
    padding: 0;
    max-width: 70%;
}

.level-toggle-wrapper {
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    justify-content: flex-end;
}

.deck-slots {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 10px;
    max-width: 600px;
    margin: 0 auto;
    width: 100%;
}

@media (max-width: 768px) {
    .deck-controls-row {
        /* Prevent Stacking */
        flex-direction: row;
        gap: 0;
        margin-bottom: 0.5rem;
    }

    .deck-navigation {
        justify-content: center;
        width: 100%;
        padding-right: 0;
    }
}

/* Hide original summary header level toggle if it still exists */
.summary-header .level-toggle {
    display: none;
}

/* Navigation Buttons */
.nav-btn {
    background: transparent;
    border: 1px solid #888;
    color: var(--text-color);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    font-size: 1rem;
    font-weight: bold;
}

.nav-btn:hover {
    background: rgba(0, 0, 0, 0.05);
    border-color: var(--primary-color);
    color: var(--primary-color);
    transform: scale(1.05);
}

[data-theme="dark"] .nav-btn {
    border-color: #666;
}

[data-theme="dark"] .nav-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--primary-color);
}

/* Refined UI Styles */
.deck-navigation h2 {
    margin: 0;
    color: var(--text-highlight);
    font-size: 1.5rem;
}