:root {
    --bg-main: #0e0e11;
    --bg-card: #16161b;
    --bg-hover: #1e1e24;
    --border-color: #2a2a35;
    --accent-purple: #7b61ff;
    --text-main: #ffffff;
    --text-muted: #8b8b9e;

    /* --- BASE RARITY GRADIENTS --- */
    --rarity-secret: linear-gradient(150deg, #c60000 10%, #500000 45%, #f40000 80%);
    --rarity-exclusive: linear-gradient(150deg, #ec0004 10%, #e385ef 90%);
    --rarity-mythic: linear-gradient(-125deg, #33ffcc 15%, #45ff41, #d6ff33, #fdd233, #ff7c33, #ff3346, #ff33b7 85%);
    --rarity-legendary: linear-gradient(150deg, #f1ff00 10%, #ff6f00 45%, #ffff00 80%);
    --rarity-epic: linear-gradient(150deg, #b20eff 10%, #3e00d4, #ae04ff 80%);
    --rarity-rare: linear-gradient(150deg, #08f3ff 10%, #2747d3, #03c6ff);
}

body {
    margin: 0;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--bg-main);
    color: var(--text-main);
}

.navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 30px;
    background-color: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
}

.logo {
    font-size: 1.2rem;
    font-weight: bold;
}

.nav-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1rem;
    cursor: pointer;
    margin-left: 20px;
}

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

.builder-section {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 40px; 
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
}

#team-title {
    background-color: var(--bg-main);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    padding: 10px 15px;
    border-radius: 6px;
    outline: none;
    font-size: 1rem;
    width: 250px;
}

#team-title:focus {
    border-color: var(--accent-purple);
}

.team-grid {
    display: flex;
    justify-content: center;
    gap: 25px; 
}

.team-column {
    display: flex;
    flex-direction: column;
    gap: 20px; 
}

/* --- 7th Slot Styles --- */
.seventh-slot-container {
    display: flex;
    margin-left: 5px; 
    padding-left: 35px; 
    border-left: 2px dashed var(--border-color); 
    position: relative;
}

.caloric-stone-title {
    color: #ffcc00; 
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-size: 0.85rem;
    text-align: center;
    text-shadow: 0 2px 4px rgba(0,0,0,0.8);
    position: absolute;
    top: -42px; 
    left: 35px; 
    width: 120px; 
    line-height: 1.1; 
}

/* --- Team Slots --- */
.slot-card {
    background-color: var(--bg-main);
    border: 2px dashed var(--border-color);
    border-radius: 8px;
    position: relative; 
    cursor: pointer;
    box-sizing: border-box;
    overflow: visible; 
    display: flex;
    align-items: center;
    justify-content: center;
}

.unit-slot, .familiar-slot, .demon-slot {
    width: 120px;
    height: 135px; 
}

.memoria-slot {
    width: 120px;
    height: 170px; 
}

/* --- GLOWING BORDER SYSTEM --- */
.card-background {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    border-radius: 8px;
    z-index: 0;
}

.card-background::before {
    content: "";
    position: absolute;
    inset: 0px;
    border-radius: 8px;
    background: inherit;
    filter: blur(10px);
    z-index: -2;
    opacity: 0.85;
}

.card-background::after {
    content: '';
    position: absolute;
    inset: 3px; 
    background-color: var(--bg-main); 
    border-radius: 5px; 
    z-index: -1;
}
/* ------------------------------- */

.card-character {
    position: absolute;
    top: 8px; 
    left: 50%;
    transform: translateX(-50%);
    max-width: 95%; 
    max-height: 70%; 
    width: auto; 
    height: auto;
    object-fit: contain; 
    z-index: 2;
    pointer-events: none; 
}

.placeholder-text {
    color: var(--text-muted);
    font-size: 0.9rem;
    font-weight: bold;
    z-index: 3;
}

.equipped-name {
    position: absolute;
    bottom: 6px;
    left: 0;
    width: 100%;
    text-align: center;
    color: white;
    font-size: 0.9rem; 
    font-weight: 900;
    font-family: 'Arial Black', Impact, sans-serif;
    -webkit-text-stroke: 1px black;
    paint-order: stroke fill;
    text-shadow: 0px 2px 2px rgba(0,0,0,1);
    z-index: 5;
    pointer-events: none;
    line-height: 1; 
    padding: 0 4px; 
    box-sizing: border-box;
}

.badge {
    position: absolute;
    width: 24px;
    height: 24px;
    border-radius: 4px;
    z-index: 4;
    object-fit: contain;
    filter: drop-shadow(0px 2px 2px rgba(0,0,0,0.8));
}

.trait-badge {
    top: 35%; 
    left: 12px;
}

.element-container {
    position: absolute;
    top: 6px;
    right: 6px;
    display: flex;
    flex-direction: column; 
    gap: 4px;
    z-index: 4;
}

.element-container .element-badge {
    position: static; 
}

/* --- Modal (Popup) Styles --- */
.modal-overlay {
    display: none; 
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background-color: rgba(0, 0, 0, 0.85); 
    z-index: 100;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    width: 95%; max-width: 1300px; height: 85vh; 
    display: flex; flex-direction: column; padding: 25px;
}

.modal-header {
    display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px;
}

#close-modal-btn {
    background: none; border: none; color: var(--text-muted); font-size: 2rem; cursor: pointer;
}

.modal-search {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 20px;
}

.modal-search input {
    width: 100%; padding: 12px; background-color: var(--bg-main);
    border: 1px solid var(--border-color); color: white; border-radius: 8px; box-sizing: border-box; 
}

.modal-filters {
    display: flex;
    gap: 12px;
}

.modal-filters select {
    flex: 1;
    padding: 10px 12px;
    background-color: var(--bg-main);
    border: 1px solid var(--border-color);
    color: white;
    border-radius: 8px;
    outline: none;
    font-size: 0.95rem;
    cursor: pointer;
}

.modal-filters select:focus {
    border-color: var(--accent-purple);
}

.modal-grid {
    flex-grow: 1; overflow-y: auto; display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 20px; 
    align-content: start; 
    padding-top: 30px;
    padding: 20px;
    padding-right: 25px;
}

.modal-card {
    border: none;
    background-color: transparent;
    border-radius: 8px;
    position: relative; 
    cursor: pointer;
    box-sizing: border-box;
    overflow: visible; 
    height: 135px; 
}

.memoria-modal-card {
    height: 170px; 
}

/* --- Layout Structure --- */
.team-layout {
    display: flex;
    justify-content: center;
    gap: 30px; 
}

/* --- Sidebar Controls --- */
.sidebar-column {
    display: flex;
    flex-direction: column;
    gap: 20px; 
    width: 200px;
}

.control-block {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 10px;
    background-color: var(--bg-main);
    border: 1px dashed var(--border-color);
    border-radius: 8px;
    padding: 15px;
    box-sizing: border-box;
}

.unit-controls { height: 135px; } 
.familiar-controls { 
    height: 135px; 
    padding: 10px 15px; 
    gap: 6px; 
}
.familiar-controls label {
    line-height: 1.2; 
}
.memoria-controls { height: 170px; justify-content: flex-start; padding-top: 30px; }

.control-block label {
    color: var(--text-muted);
    font-size: 0.8rem;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.control-block select {
    background-color: var(--bg-card);
    color: var(--text-main);
    border: 1px solid var(--border-color);
    padding: 8px;
    border-radius: 4px;
    outline: none;
    font-size: 0.9rem;
    cursor: pointer;
}

.control-block select:focus {
    border-color: var(--accent-purple);
}

.memoria-slot .trait-badge {
    top: 40px;       /* Pushes it down into the red square area */
    left: 20px;      /* Moves it in from the left edge */
    right: auto;     /* Clears any default right-side positioning */
    bottom: auto;    /* Clears any default bottom positioning */
    width: 28px;     /* Slightly increases the size */
    height: 28px;    
    z-index: 5;      /* Keeps it safely above the background/character */
}